Linux STREAMS (LiS)


Installing Pre-Compiled Drivers

LiS makes provision for you to add your own STREAMS drivers to the build of LiS. You drivers are built outside the LiS source code tree. The object code and configuration information pertaining to your driver must be copied into the LiS source code tree in order to be incorporated into LiS.

The LiS pkg Directory

The directory /usr/src/LiS/pkg is the directory where pre-compiled drivers are to be copied. This directory contains subdirectories, one for each driver to be linked in with LiS when LiS is built.

If you have a driver named foo then you need to do a mkdir /usr/src/LiS/pkg/foo to create the directory that will contain the components of your driver.

Driver Components

You need to copy the following files into your package directory (/usr/src/LiS/pkg/foo).

  Component Description
 

Makefile

A make file to do anything that needs to be done just prior to linking your driver's object code file into LiS. If there is nothing to be done then just provide a dummy default target. The Makefile has to be present for the LiS build procedure to function properly.

 

Driver.o

Any number of object files with suffix ".o" will do. These files can be copied into this directory from elsewhere, they do not have to be built by the Makefile. Alternatively, the Makefile can copy in updated driver object files as needed. Which style you use is entirely up to you.

 

Space.c

This is optional. If you want to incorporate configuration information from your Config file into your driver at link time, then place a file by this name into your driver's package directory. Your Makefile should contain an include ../proto/Makefile to incorporate a rule to make this file into an object file. Your Space.c file should include the file config.h in it. See the section on Configuration for more details about Space.c and config.h.

 

Config

This is the STREAMS configuration file for your driver. It is combined with other Config files for other drivers to produce a master Config file. This master Config file is then processed by the LiS strconf utility to produce, among other things, the file config.h. See the section on Configuration for more information about the Config file.

Dynamically Loadable STREAMS Drivers

You can also compile your STREAMS driver as a loadable module and load it dynamically either on demand or using the insmod command.

In order to do this you need to inform the Linux kernel that your driver depends upon the LiS STREAMS driver. You do this by placing an entry into the file /etc/conf.modules (on newer distributions of Linux this file has been renamed to /etc/modules.conf) . In order to code this entry correctly, you need to know the major device number that is to be assigned to your driver. One way to find this out is to make a directory for your driver in the LiS pkg directory and include a Config file but no object code. You can then use the resulting config.h file (located in the directory /usr/src/LiS/include/sys/LiS and left behind by the LiS build process) to determine your driver's major device number.

When your driver loads and you register it, you need to ask for this major device number.

The entry in the /etc/conf.modules file looks like the following:

alias char-major-maj streams

This entry tells the kernel that a driver with major device number maj is dependent upon the module named "streams," the module name for LiS. The LiS strconf utility program contains constructs which support this process. See the Configuration section for more information.

Tip: Be sure not to include your driver's ".o" file in the LiS pkg directory. Instead you will need to copy it to the appropriate subdirectory of /lib/modules.