Messages in this thread |  | | From | David Hinds <> | Subject | Future directions in kernel/driver configuration | Date | Thu, 5 Sep 1996 15:11:21 -0700 (PDT) |
| |
I've been doing some work on figuring out a good way to allow my PCMCIA driver package to work well as either loadable modules or integrated into the kernel. Currently, the drivers can only be used as loadable modules, in part to avoid the trouble of having them integrated into the Linux kernel source tree. This is troublesome because it means that PCMCIA devices are never available until after the system has booted, so the root filesystem can't be on a PCMCIA device.
Anyway, I've worked out a scheme by which I can link any arbitrary driver *module* into an uncompressed kernel image (vmlinux, not vmlinuz), by doing some link-time symbol fiddling. Essentially, I first build a kernel with something like this in the init code:
extern int driver_stub(void); static int (*driver_ptr)(void) = driver_stub;
{ if (driver_ptr != NULL) driver_ptr(); }
and I link vmlinux with "-defsym driver_stub=NULL". Now, this vmlinux file has no undefined references, but I can later redefine driver_stub to point to something else, by doing something like:
ld -o vmnew -defsym driver_stub=init_module vmlinux pcmcia.o
With some extra "-defsym" fiddling, I can take care of kernels with module version checking, also. And I can use "strip" to get rid of the init_module and cleanup_module symbols, so that I can repeat the process to link multiple modules.
It seems like this could be a nice replacement for the current scheme of having different object files for drivers compiled as loadable modules, or compiled to be linked directly into the kernel. Also, it makes most configuration options link-time instead of compile-time.
What do people think about this as a way of revamping how kernels are configured for different driver sets? I plan to finish implementing it for PCMCIA, at least, which should be a sort of proof-of-concept.
-- Dave Hinds dhinds@hyper.stanford.edu
|  |