2 APIs for a STREAMS device driver in Solaris

2 APIs for a STREAMS device driver in Solaris

Post by Sylvain Gagn » Thu, 18 Oct 2001 22:28:53



Hi,

I'm new in Solaris STREAMS Device Driver development. I'm currently porting a
driver from Linux to Solaris. This Linux driver is quite special because it
has two API driving the same hardware. In other words, there are two sets of
open(), close(), read(), write(), ioctl() functions attached to the same
hardware. The main purpose of this approach is to allows the user to send raw
data with the first API or send data that has to be preprocessed with the
second API.

Now I see two different ways to do it under Solaris:

1) I could call mod_install() twice in _init() function. This way, I could
register 2 sets of functions for the same driver. Then, in the 2
respective attach() functions registered, I would map two different driver
name (e.g. /dev/aaa and /dev/bbb). The main problem with this approach is that
I'm not sure I can call mod_install() twice in _init() fucntion. Do you know
if it is possible?

2) I could develop only one STREAMS device driver with two modules (one for
the raw data and one for the preprocessed data ). Then, I would perform a
first open with the first module pushed and a second open (probably a clone)
with the second module pushed. This way, I would have only one API (driver
/dev/aaa) but I could have two different behaviors. Do you think it is
possible? Is it a good approach?

Best regards,
Sylvain G.

 
 
 

2 APIs for a STREAMS device driver in Solaris

Post by Andrew Gabri » Fri, 19 Oct 2001 05:46:42




Quote:>Hi,

>I'm new in Solaris STREAMS Device Driver development. I'm currently porting a
>driver from Linux to Solaris. This Linux driver is quite special because it
>has two API driving the same hardware. In other words, there are two sets of
>open(), close(), read(), write(), ioctl() functions attached to the same
>hardware. The main purpose of this approach is to allows the user to send raw
>data with the first API or send data that has to be preprocessed with the
>second API.

>Now I see two different ways to do it under Solaris:

>1) I could call mod_install() twice in _init() function. This way, I could
>register 2 sets of functions for the same driver. Then, in the 2
>respective attach() functions registered, I would map two different driver
>name (e.g. /dev/aaa and /dev/bbb). The main problem with this approach is that
>I'm not sure I can call mod_install() twice in _init() fucntion. Do you know
>if it is possible?

No idea if that would work.

Quote:>2) I could develop only one STREAMS device driver with two modules (one for
>the raw data and one for the preprocessed data ). Then, I would perform a
>first open with the first module pushed and a second open (probably a clone)
>with the second module pushed. This way, I would have only one API (driver
>/dev/aaa) but I could have two different behaviors. Do you think it is
>possible? Is it a good approach?

Yes - this is how STREAMS was designed to work, with modules
pushed on top of drivers to add extra functionaility.

Another way would be to use different minor unit numbers for
the two devices, detect this at open time, and then split into
two code paths in the one driver depending which minor unit was
opened.

--
Andrew Gabriel
Consultant Software Engineer

 
 
 

2 APIs for a STREAMS device driver in Solaris

Post by Sylvain Gagn » Fri, 19 Oct 2001 20:13:23



>>2) I could develop only one STREAMS device driver with two modules (one for
>>the raw data and one for the preprocessed data ). Then, I would perform a
>>first open with the first module pushed and a second open (probably a clone)
>>with the second module pushed. This way, I would have only one API (driver
>>/dev/aaa) but I could have two different behaviors. Do you think it is
>>possible? Is it a good approach?

>Yes - this is how STREAMS was designed to work, with modules
>pushed on top of drivers to add extra functionaility.

>Another way would be to use different minor unit numbers for
>the two devices, detect this at open time, and then split into
>two code paths in the one driver depending which minor unit was
>opened.

OK ... one more question. My concern is about the loading of modules in a
clone driver. Let's say I create a clonable driver. Then, I open 2 clones of
this driver (clone A and clone B). This way, I use two different minor unit
numbers.If I push a module X in clone A, will this module also be
automatically pushed in clone B? I hope not!

In my case, I would like to have clone A working with module X and clone B
with module Y. I think that the module allows you to have two clones of the
same driver having two different behavior, but I didn't find any confirmation
of this in the documentation.

Thanks,
Sylvain G.

 
 
 

2 APIs for a STREAMS device driver in Solaris

Post by Andrew Gabri » Sat, 20 Oct 2001 04:27:01




Quote:>OK ... one more question. My concern is about the loading of modules in a
>clone driver. Let's say I create a clonable driver. Then, I open 2 clones of
>this driver (clone A and clone B). This way, I use two different minor unit
>numbers.If I push a module X in clone A, will this module also be
>automatically pushed in clone B? I hope not!

No.

Quote:>In my case, I would like to have clone A working with module X and clone B
>with module Y. I think that the module allows you to have two clones of the
>same driver having two different behavior, but I didn't find any confirmation
>of this in the documentation.

This is the case.

--
Andrew Gabriel
Consultant Software Engineer

 
 
 

2 APIs for a STREAMS device driver in Solaris

Post by Sylvain Gagn » Sat, 20 Oct 2001 22:21:22


Thanks all for you help !
Sylvain Gagnon
 
 
 

1. STREAMS device driver for Solaris x86

Hi all,

Reading the STREAMS programmers guide, it says that a STREAMS based device driver
must have an interrupt handler.  Does this mean that you can only write a
STREAMS based device driver for devices which support interrupts, or does it
work with polled devices as well?

Cheers,

Martin.

---
*******************************************************************************

* DRA Malvern                * Phone: (01684) 896329                          *
* St Andrews Road            * Fax:   (01684) 894481                          *
* Malvern                    **************************************************
* Worcs                      * Measure with a micrometer.                     *
* WR14 3PS                   * Mark with chalk.                               *
* United Kingdom             * Cut with an axe.                               *
*******************************************************************************

2. xxgdb

3. Solaris multiplexed stream device driver trouble

4. Sparc install of RH5.2

5. Multi Serial Stream Based Device Driver for Solaris x86

6. need help!!!!!!!!

7. The Parallel port API- I need to write a device driver...!

8. Yellow Dog Linux and ftp/telnet servers

9. Device Drivers & APIs ?

10. api to device driver

11. Device Drivers & API's ?