This directory has an example loadable kernel server and a user-level
program that communicates with it.  The loadable kernel server accepts
only one MiG-generated remote procedure call, mydriver_do_log(), which
causes the server to log a message using kern_serv_log().   Before the
user program calls mydriver_do_log(), it enables logging by calling
kern_loader_log_level().  After calling mydriver_do_log(), the user
program calls kern_loader_get_log() and then listens on a port for the
reply message.  When the reply message arrives, the user program sends
the message to a handling function (using
kern_loader_reply_handler()).  The handling function prints the data
from the message and exits.  Chapter 3, "Using Loadable Kernel
Servers," of NeXT Operating System Software gives more information on
implementing user-level programs that communicate with loadable kernel
servers.  Writing Loadable Kernel Servers gives information on
implementing your own loadable kernel server.To build the loadable
kernel server and user program, follow these steps:


1)  Make a copy of this directory and change to the new directory in a
    Terminal window.  For example:

localhost> cp -r /NextLibrary/Documentation/NextDev/Examples/Log ~
localhost> cd ~/Log

2)  Run make in the KernelServer directory.  (It's important that you
    make the server before the user program, since the user program
    depends on files created during this step.)

localhost> cd KernelServer
localhost> make

3)  Run make in the User directory.  

localhost> cd ../User
localhost> make

To use the user program:

1)  Allocate the loadable kernel server.  It loads automatically once
    it's allocated.

localhost> su
Password:
localhost# kl_util -a ../KernelServer/mydriver_reloc
Adding server with relocatable /me/Log/User/../KernelServer/ 

mydriver_reloc
Allocating server mydriver
Server mydriver linking /me/Log/User/../KernelServer/mydriver_reloc 

against /mach
Server mydriver linking relocatable "/me/Log/User/../KernelServer/ 

mydriver_reloc"
Server mydriver Allocated
Server mydriver loading
regs.pc = 40294f0
Server mydriver download complete
Server mydriver starting up
Server mydriver Loaded
localhost# 

2)  Run the user program.  

localhost# ./log
Waiting for the log level to change before calling 

mydriver_do_log()...
Calling mydriver_do_log().
Calling kern_loader_get_log().
Received a message on the reply port.
Calling kern_loader_reply_handler().
log_data:  172800757:   This is the log message (at level 

LOG_WARNING).

3)  If you wish to modify the loadable kernel server and then reload
    it, you should delete the running version of the kern_loader
    before allocating the kernel server again.

localhost# kl_util -d mydriver
removing server mydriver
Server mydriver deallocating
Server mydriver unloading
Server mydriver re-Allocated
Server mydriver Deallocated

