dynamic driver registration was Re: RTEMS sound device driver
Joel Sherrill
joel.sherrill at OARcorp.com
Thu Feb 7 23:17:08 UTC 2002
Chris.. did you ever submit documentation for the
dynamic driver support? I can't find it. Please
send a patch against doc/user/io.t and possibly
doc/user/conf.t. :)
Pattara Kiatisevi wrote:
>
> Firstly thank you for all answer.
>
> On Thu, 7 Feb 2002, Aaron J. Grier wrote:
>
> > On Thu, Feb 07, 2002 at 07:02:49PM +0100, Pattara Kiatisevi wrote:
> > > I am going to write a device driver for a sound device to be run with
> > > RTEMS and LEON chip. As I have very little experience with RTEMS, I
> > > have some questions:
> > >
> > > Client program that will use this device driver:
> > > ================================================
> > >
> > > -in Linux I do:
> > > audio_fd = open("/dev/dsp",O_WRONLY , 0)
> > > -in RTEMS:
> > > Will the above open() work? or do I have to:
> > > rtems_io_open( xxx )? And how can I know what "xxx" should be?
> >
> > it depends where the device driver registers itself. if it registers
> > itself as "/dev/dsp" then the above will work.
>
> But how exactly is this "registering" process? I took a look at the
> existing driver code as suggested and draft the steps as follow.
Most drivers are currently statically registered but Chris Johns
recently submitted dynamic driver installation. See the
rtems_io_register_driver() service. I have asked him for
docs for it.
> -I create a file contained device driver's code: sound-driver.c
> -Which should contain initialize(), open(), close(), read(),
> write(), and control(). Arguments of these functions = like in console.c?
> -In the initialize() I would have sth. like:
>
> rtems_io_register_name( "/dev/dsp", major, 0 );
>
> -In my application file, I do open(), ioctl(), write(), close() to
> /dev/dsp as usual.
Right.
> -And then how can I tell RTEMS to call this sound device driver when there
> is access to /dev/dsp? Something to do with
> #def CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE and I have to create my own
> Device_drivers? (Hmm, but how and where? :) )
The easiest thing in your situation would be to use the dynamic
registration. It looks like the default setup has (unfortunately)
extra slots in the driver table. It shouldn't though. :(
Ideally you would define CONFIGURE_MAXIMUM_DRIVERS high enough to
cover statically and dynamically registered drivers.
Please, please keep good notes, submit patches, etc. This is a good
project more than one person would like to be able to reproduce.
> Thank you very much.
>
> Gruss,
> Ott
>
> The best things in life are free. - B.G. DeSilva (1927)
> ----------------------------------------------------------------------
> Ott Pattara Kiatisevi T L W G
> M.Sc. INFOTECH Student, Stuttgart, Germany http://linux.thai.net/
> ----------------------------------------------------------------------
>
> >
> > > -in Linux I do:
> > > int format = AFMT_S16_LE;
> > > ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format);
> > > -in RTEMS?
> > > What should I do?
> >
> > again, this is completely dependent on the device driver. there is no
> > reason why this couldn't be supported.
> >
> > > -in Linux I do:
> > > sizewritten = write(audio_fd, audio_buffer, inputsize);
> > > -in RTEMS:
> > > I should use rtems_io_write() right? And how about the parameters?
> >
> > RTEMS supports write() with the same parameters. but it is up to the
> > device driver to interpret these parameters.
> >
> > > Device driver:
> > > ==============
> > >
> > > -The place that I have to put the device driver code is under
> > > <rtems>/c/src/lib/libbsp/sparc/leon/ right? As I couldn't find any
> > > implementation of audio driver before, does it have any template so
> > > that I could know which functions should exist in order to support the
> > > above client calls?
> >
> > look at the other device drivers for your target. a device driver has
> > six interface points (initialize, open, close, read, write, and
> > control). to write a device driver you fill these in and add an entry
> > to your application's device driver list. it's quite elegant once you
> > get the hang of it.
> >
> > look in the console driver for your BSP to start.
> >
> > > I'm porting Ogg Vorbis Player (which runs on Linux/UNIX) to RTEMS. At
> > > first I think that it could be sth. like "source-code compatible" but
> > > in the real it is not right?
> >
> > I'm not familiar with the ogg source code, but I'm guessing that if you
> > can get a suitable device driver in place, it has a good chance of
> > working.
> >
> > --
> > Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
> > "In a few thousand years people will be scratching their heads
> > wondering how on earth the first computer was invented and
> > bootstrapped without a prior computer to do it with."
> > -- Chris Malcolm, on comp.arch
> >
> >
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list