Export Functions from an LKM to a Driver

807567
    I haven't found a way for Solaris to do this yet, but I need to be able to have a loadable kernel module that exports functions that can be called directly from another driver. I have successfully done the same thing in Windows (where the LKM is called an EXPORT_DRIVER) and in Mac OS X and AIX (using a KEXT).

    I think the missing piece is mapping the two modules with each other at link-edit time and load time. I have to believe this is possible in Solaris, does anybody have any suggestions?

    Thanks!
      • 1. Re: Export Functions from an LKM to a Driver
        807567
        No one answered this query, but I figured it out and thought I'd mention what I did in case anyone else has this question later on. I had to do the following:

        1) For the loadable module, wrap it with the structures for a "misc" module (.e.g. use "struct modlmisc"), complete with the init, fini, and _info device entry points.

        2) In the driver that calls code from the loadable modules, add the following global variable:

        char dependson[] = "misc/XXX";

        where XXX is the name of your module file, and "misc" is the path from "/kernel".

        3) Compile everything, put the loadable module's file in the right place on the target host (in this case "/kernel/misc" or "/kernel/misc/sparcv9").

        When the main driver is installed, it will cause the loadable module to be automatically loaded, too, making all its functions available to the main driver.