Kernel loadable modules (streams not device drivers)

Kernel loadable modules (streams not device drivers)

Post by ms » Sun, 15 Mar 1992 06:18:27



        This question pertains to stream modules on a Sun Sparc 1 running
        SunOS4.1.1

        I'm currently writing an application that requires me to do some
        processing of raw data that comes across a serial line.  I've
        decided that the appropriate way of dealing with this (and
        hiding the horrors from the application level program) is to
        insert a module into the stream.

        Using that brilliant piece of documentation, known as "STREAMS
        Programming" in the Sun documentation set, I've run into
        problems when I come to push (ioctl(fd, I_PUSH, "modname"))
        my module.  It returns an error indicating that I have an
        invalid arguement to my ioctl call.  Okay, I think, it obviously
        doesn't know of the existance of my module.

        Now it strikes me that I can add my module information into
        the fmodsw structure in /sys/sun/str_conf.c and remake a
        kernel that knows the module name and the variable name
        of my streamtab structure.  Unfortunately I'm not root
        and the sys-op is not interested in creating a new kernel
        for me.

        My alternative is to use modload to dynamically load the
        module into the kernel when I need it.  The only documentation
        on this is in the device drive section of the manual set.
        It is as good a document as streams manual (which doesn't
        tell you how to register a module to load - argh).  I
        have written a wrapper program that sets up the vdldrv struct
        (not being able to figure out what things should be set to
        I set pointers to NULL as I don't want to define character
        or block device entry points or controller information, and
        any variables to 0).  The wrapper also defines a xxxinit for
        modload.

        Modload successfull loads the compiled wrapper (-DKERNEL -Dsun4c)
        and gives an address where the (I assume) xxxinit resides and the
        module id.  Using adb I debug the kernel and look at fmodsw struct.
        You've guessed it: my module information isn't there.  When I try
        to run my program, it again can not find my module name and blows
        up on the I_PUSH.

        What I would like to know is what am I doing wrong.  Has anyone
        got streams to work in the manner that I have described above?
        Does anyone have any other suggestions/alternatives.

                        advTHANKSance

--
                                      ,
"A storm breaks trees,             Mark -%)

           Solzhenitsyn                 ...!{uunet!ubc-cs, utai}!calgary!msw

 
 
 

Kernel loadable modules (streams not device drivers)

Post by Matthias Urlic » Mon, 16 Mar 1992 13:53:24




<
<    This question pertains to stream modules on a Sun Sparc 1 running
<    SunOS4.1.1
<
<    Now it strikes me that I can add my module information into
<    the fmodsw structure in /sys/sun/str_conf.c and remake a
<    kernel that knows the module name and the variable name
<    of my streamtab structure.  Unfortunately I'm not root
<    and the sys-op is not interested in creating a new kernel
<    for me.
<
<    My alternative is to use modload to dynamically load the
<    module into the kernel when I need it.

Unfortunately, Sun in their infinite wisdom decided that nobody would want to
dynamically load Streams modules, so there's no way to tell the dynamic
loader that your code has a fmodsw structure, so it's not linked into
fmodsw automatically, so you have to do it yourself. Code snippet follows.

I usually call the load procedure "XXXload". "XXXinit" is used to do the
actual device initialization. (Some kernel autoconfiguration systems, e.g.
A/UX, automatically include XXXinit in the list of routines which are called
at kernel startup time if they see it.)

#ifdef sun
#include <sys/conf.h>
#include <sys/buf.h>
#include <sundev/mbvar.h>
#include <sun/autoconf.h>
#include <sun/vddrv.h>

static struct vdldrv vd =
{
    VDMAGIC_PSEUDO,
    "XXX",
    NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0,

Quote:};

static struct fmodsw *XXX_fmod;

XXXload (fc, vdp, vdi, vds)
    unsigned int fc;
    struct vddrv *vdp;
    addr_t vdi;
    struct vdstat *vds;
{
    switch (fc) {
    case VDLOAD:
        {
            int dev, i;

            /* Find free entry in fmodsw */
            for (dev = 0; dev < fmodcnt; dev++) {
                if (fmodsw[dev].f_str == NULL)
                    break;
            }
            if (dev == fmodcnt)
                return (ENODEV);
            XXX_fmod = &fmodsw[dev];

            /* If you think a kernel would have strcpy() you're mistaken. */
            for (i = 0; i <= FMNAMESZ; i++)
                XXX_fmod->f_name[i] = something_minfo.mi_idname[i];

            XXX_fmod->f_str = &something_streamtab;
        }
        vdp->vdd_vdtab = (struct vdlinkage *) & vd;

        XXXinit();
        return 0;
    case VDUNLOAD:
        {
            int dev;

            for (dev = 0; dev < NSOMETHING; dev++)
                if (XXX_data[dev]->q != NULL) {
                    /* One of the modules is still open */
                    return (EIO);
                }
        }
        XXX_fmod->f_name[0] = '\0';
        XXX_fmod->f_str = NULL;
        return 0;
    case VDSTAT:
        return 0;
    default:
        return EIO;
    }

Quote:}

#endif
--

Humboldtstrasse 7 -- 7500 Karlsruhe 1 -- Germany  --  +49-721-9612521     \o)/

 
 
 

1. Ft. Worth - Linux Kernel Module Programmer - Unix kernel modules & Unix device drivers

Linux Kernel Module Programmer - A very loose environment, casual attire,
needs an intermediate to advanced Linux Kernel Module Programmer
immediately for a critical role. This person must have specific experience
in programming Unix kernel modules or drivers and TCP/sockets, preferably
with Linux kernel modules or drivers, or an understanding or experience of
parallel and distributed processing. Program a Linux kernal module to
fulfill the need for a routing program performing communications and shared
server resource management on web servers. These programming tasks are below
the socket level, but some manipulation of sockets is part of the tasks.
This person will perform cutting edge server applications development in a
parallel and distributed environment. This experience is a huge resume
boost.

Required Skills: MUST HAVE experience in programming a Unix or Linux KERNAL
MODULE or DRIVER! ... and C / Unix, networks and protocols, an innovative
mind that enjoys thinking out of the box, good work ethic, work well alone,
self motivated, requires little supervision.

Desired Skills: parallel and distributed processing.

Start Date: ASAP

Type: - Permanent -

Pay Range: $60,000 - $65,000 Annual
+stock options

Benefits: Health Insurance, Life Insurance, Dental Insurance, Disability
Insurance, Paid Vacation, Paid Sick Leave, Stock Options, Flex Time

Location: Ft. Worth , TX - Hurst, TX
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TO APPLY, PLEASE CALL OR FORWARD RESUME TO:

Larry Bergstrom
Computer Staff, LLC
1701 W. Northwest Highway
Grapevine, Texas 76051-8105

OFFICE metro  (817) 329-5009
FAX   (817) 329-5091
WEBSITE:  http://www.compstaffonline.com/listings.html
HOME  (817) 251-2029
MOBILE  (817) 723-4298
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Information Technology Contract & Permanent Placement Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALL RESUME RESPONDENTS ARE HELD CONFIDENTIAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. kernel not using memory

3. loadable kernel module load--NOT!

4. Question about 2.2.6 Errata

5. Loadable Kernel Module loads--NOT!

6. Trivia

7. Help on Installing Linux on Win98.

8. loadable kernel module loads--NOT!

9. can't probe ppp module in kernel 2.2.2.5-15 using loadable module

10. Dynamically loadable STREAM modules

11. Loadable streams module