Page 1 of 1
Can kernel load drivers and other stuff?
Posted: Sun Nov 11, 2007 7:38 pm
by meh
I have a single stage bootloader, and I was wondering if the kernel can load the drivers and filesystem.
Oh, I already got my operating system to boot.
Posted: Sun Nov 11, 2007 9:53 pm
by AndrewAPrice
Of course! You have two approaches to this:
- The monolithic way:
You usually have a few drivers in built (e.g. a FAT driver and a floppy driver). Once you have these implemented, and some form of loading programs, loading a driver is nearly exactly the same. Just copy the contents of the driver executable to memory and have some sort of interface describing common functions (init/detect/get type (video, input, disk, etc) /and type-specific functions).
- The microkernel way:
All servers/drivers exist within their own memory space just like loading any other program (except they take higher priority in terms of scheduling). Having a temporary read-only disk driver in built to load the initial servers/drivers, or loading a virtual disk image into memory is a matter of personal choice.
Either way, I'd recommend you keep your drivers within your kernel to start off with, and wait until your OS reaches a level where you manage virtual memory and load programs off a disk, before you begin to decide what you should be moved into external files and loaded off disk.
Posted: Mon Nov 12, 2007 5:59 pm
by meh
Thank you.
Posted: Tue Nov 13, 2007 3:30 am
by AJ
Hi,
Just one thing to add. I am going for the modular monolithic approach at present. My boot loader loads the kernel and an initial ramdisk in to memory. Other basic drivers can be on the ramdisk. This means that the only required built-in driver is the ramdisk driver. If a driver is broken, I may have to put a new version on the ramdisk image, but I don't have to worry about a kernel rebuild.
Cheers,
Adam
Posted: Tue Nov 13, 2007 5:00 am
by AndrewAPrice
I have one big "driver pool", and every driver (in the kernel or in a module) adds itself to the driver pool. Then the kernel loops through each driver in the driver pool and calls their DetectDevices(), CreateDevices(unsigned int no) functions, which return device objects. The kernel adds these device objects to the "device pool", and then loops through the device pool and runs Initialise() on each device.