Can kernel load drivers and other stuff?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
meh
Member
Member
Posts: 52
Joined: Sun Oct 21, 2007 4:30 pm

Can kernel load drivers and other stuff?

Post 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. :wink:
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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.
My OS is Perception.
meh
Member
Member
Posts: 52
Joined: Sun Oct 21, 2007 4:30 pm

Post by meh »

Thank you.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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.
My OS is Perception.
Post Reply