Driver discovery
Posted: Thu Sep 18, 2014 11:33 am
I'm wondering how different OS go about deciding which drivers to load at boot time, particularly for microkernels, and whether my devices and drivers stuff is sensible.
As far as my system is concerned a driver is just another service exposed through the kernel's IPC layer. I have a few very basic drivers which are actually in the kernel itself, and once the real user-mode driver is ready it takes over that functionality (I also have a slightly hacky API for transferring the driver state from the early to full drivers so that I can avoid reinitializing things). The relevant part of the startup process is:
- The kernel starts process0
- Process0 starts the namespace service. The namespace service supports (initially empty) namespaces for devices and files.
- The namespace service takes over control of the initial ramdisk from the kernel. It becomes the first device in the device namespace, and the contents of the ramdisk become the first nodes in the files namespace.
- Process0 then starts the device discovery service. This queries ACPI via the kernel to find out what buses we have, and then recursively starts loading and querying bus drivers and device drivers, populating the device namespace as it goes (and files namespace if we hit a mountable volume). Devices for which a driver is not available still get added to the device namespace so that if a driver becomes available later it just attaches itself to the correct node.
So far so good, but how do I know they're there when I discover a mountable volume with more drivers on it? Or choose between them if I have multiple drivers available? The obvious thing seems to be keeping some sort of mainfest in a well-known location on a volume which has drivers, but that seems (a) inelegant, and (b) a security risk.
I'm just kinda talking this through for myself really, but any ideas?
As far as my system is concerned a driver is just another service exposed through the kernel's IPC layer. I have a few very basic drivers which are actually in the kernel itself, and once the real user-mode driver is ready it takes over that functionality (I also have a slightly hacky API for transferring the driver state from the early to full drivers so that I can avoid reinitializing things). The relevant part of the startup process is:
- The kernel starts process0
- Process0 starts the namespace service. The namespace service supports (initially empty) namespaces for devices and files.
- The namespace service takes over control of the initial ramdisk from the kernel. It becomes the first device in the device namespace, and the contents of the ramdisk become the first nodes in the files namespace.
- Process0 then starts the device discovery service. This queries ACPI via the kernel to find out what buses we have, and then recursively starts loading and querying bus drivers and device drivers, populating the device namespace as it goes (and files namespace if we hit a mountable volume). Devices for which a driver is not available still get added to the device namespace so that if a driver becomes available later it just attaches itself to the correct node.
So far so good, but how do I know they're there when I discover a mountable volume with more drivers on it? Or choose between them if I have multiple drivers available? The obvious thing seems to be keeping some sort of mainfest in a well-known location on a volume which has drivers, but that seems (a) inelegant, and (b) a security risk.
I'm just kinda talking this through for myself really, but any ideas?