Page 1 of 1

microkernel and constant driver interface

Posted: Thu Jan 03, 2008 5:48 am
by AndrewAPrice
I have driver interface, which works fine for end devices (e.g. storage devices, input devices, etc), but things like my DMA driver exist within the kernel as a global object my other drivers depend on. It works, but it seems to steer away from my consistent interface.

I'm planning on rewriting my driver interface, and using an event based system. I also wish to move my drivers out of kernel land (including DMA). I'll leave process management (including loading/unloading), memory management, and event management inside of the kernel since these aren't really 'drivers' as such and I don't want to abstract them away.

What I want to know, is how do microkernels handle drivers like DMA? How does a floppy driver find the DMA driver (I don't want to make it a 'special-case' driver, or else I'll be doing that for PCI, USB, etc, and my driver-interface will loose that feeling of consistency) and interact with it? How do drivers in general work in a microkernel environment?

Posted: Thu Jan 03, 2008 4:23 pm
by AndrewAPrice
I've sort of got an idea of how I'm going to do it.

A driver will be an ordinary program that can be loaded like any other. When the program is loaded, a special system call is made that upgrades the program to driver level (only programs started by the super user can make the system call). This system call will register things like the driver's name ("Generic Floppy", "DMA", etc).

There will be a second system call to register a device ("Generic Floppy" will create "Floppy0" "Floppy1" etc, "DMA" will create "DMA8" and "DMA16").

Drivers will use windows-style events (with events like "DRIVER_SHUTDOWN", and pass a special 'device code' which is most likely a pointer in driver-space), although there will be custom events (i.e. "DMA_DO_TRANSFER").

Having drivers run in their own memory space means a memory leak in a driver won't chew up memory on the whole system, only for the driver's process which can instantly be killed if necessary.

Anyway, I need to work out a system to send structs across with my requests, but they can be of varying size.

Posted: Fri Jan 04, 2008 5:53 am
by lukem95
that sounds like a good plan, have you got inter-process-messages working?

Posted: Fri Jan 04, 2008 7:16 pm
by AndrewAPrice
Yes, but right now the most you can send between processes is 20-bytes (an event structure). I have a 'reserved' event which specifies a message is waiting and the size of the message, so I'll get that working first.