devc1 wrote:What makes the kernel run a specific driver, my kernel just lists pci devices and runs the driver for the device. But what about an acpi driver ? Should it run all the drivers at once, and if (for e.g.) acpi is not found the driver will just shutdown ?
So there's a chicken-and-egg problem in microkernels in that can be summed up as:
1) I need to load my disk driver so I can read from disk
2) I need to read from disk to load my disk driver.
Depending on where along the micro/monolithic spectrum you're on, you might have the code for loading programs in a service (rather than the kernel) - so how can you load that?
Monolithic kernels are probably easier to get started, because all of this is compiled into the kernel and are not seperate programs.
For microkernels, you have a few options. Some use an
initrd which is a small disk image loaded into memory, so the kernel can read the initial services/drivers. I use GRUB as my bootloader, and GRUB lets you load what are called
"multiboot modules", which just copies the file off disk into memory for you, so your microkernel can load these services/drivers before knowing how to read off a disk.
Getting back to your question:
devc1 wrote:Should it run all the drivers at once, and if (for e.g.) acpi is not found the driver will just shutdown ?
There are two things you can either do:
1) Run the driver. If it doesn't detect the device it's made for, it quits.
2) Enumerate through detected devices and when you recognize one, load the driver.
Most interfaces such as
PCI and
USB let you loop through connected devices and tell you info about the device (PCI has: device id, vendor id, class code, subclass, revision id), and if you have a database of drivers built for your OS, see if a driver exists for that device and try to load it.
It would kind be inefficient for a large OS such as Windows to try to load every known driver on startup, but back to solving the chicken-and-egg problem, on your first boot (e.g. booting the install disk) you probably do have to load every known disk driver and let all but one fail, but then during installation, you could find the driver that actually worked, and write it into your initrd/boot configuration. In this way, you precomputed during installation what the essential devices are, so you don't have to on each boot.
Before
Plug-and-Play it was difficult to detect hardware, and the user had to be familiar with their computer, which often meant video games asking you what type of sound card you had when you installed them: