Device Driver Interface design
Posted: Wed Aug 17, 2005 11:09 am
Hi Guys and Girls,
I've been killing brain cells trying to come up with a way to interface device drivers with my kernel.
Certain questions have been bugging me, can't come up with solutions I'm happy with. I'd like your comments please.
Here is my design so far,(still a work in progress)
I treat drivers the same a processes, they are created in the same way.
The service header structure containes the following fields
- name of the driver
- array of functions the driver provides
- interrupt number it want to use
The driver has to initialize this structure before it registers itself with the kernel.
If a process is a driver, it has to call the RegisterDeviceService(service header) function during its initialization. This function adds a new entry in the device driver table for the device. It also returns a handle for the driver.
[Problem 1]
I need to come up with a way for device drivers to process the device interrupt they want to service and for them to have access to the data a device generates when an interrupt fires.
Allowing them to run at CPL 0 is not Secure.
Also device drivers might need to write their own Interrupt Service Routines.
How can I allow device drivers to use their own interrupt routines without creating a security problem?
Processes that needs a service i.e. read key from keyboard has to use findService(service name,Family class) to find the service they want. In my example they will have to use findService("Keyboard",INPUT);
This returns a handle to be used for subsequent calls.
[problem 2]
I'm sure we will have name clashes.
I was thinking of using FIXED names, CONSTANTS like DEVICE\KEYBOARD,DEVICE\MOUSE. Is there a better way to do this?
Then the final function is requestService(service handle,function,data buffer). Service handle is provided by the call above, the function is a service the driver provides eg read key and data buffer is where the driver will put the data.
This what I have so far, will add to it as I clear up these problems.
Any suggests, pointers or references to reading materials will be highly appreciated. Thanks
I've been killing brain cells trying to come up with a way to interface device drivers with my kernel.
Certain questions have been bugging me, can't come up with solutions I'm happy with. I'd like your comments please.
Here is my design so far,(still a work in progress)
I treat drivers the same a processes, they are created in the same way.
The service header structure containes the following fields
- name of the driver
- array of functions the driver provides
- interrupt number it want to use
The driver has to initialize this structure before it registers itself with the kernel.
If a process is a driver, it has to call the RegisterDeviceService(service header) function during its initialization. This function adds a new entry in the device driver table for the device. It also returns a handle for the driver.
[Problem 1]
I need to come up with a way for device drivers to process the device interrupt they want to service and for them to have access to the data a device generates when an interrupt fires.
Allowing them to run at CPL 0 is not Secure.
Also device drivers might need to write their own Interrupt Service Routines.
How can I allow device drivers to use their own interrupt routines without creating a security problem?
Processes that needs a service i.e. read key from keyboard has to use findService(service name,Family class) to find the service they want. In my example they will have to use findService("Keyboard",INPUT);
This returns a handle to be used for subsequent calls.
[problem 2]
I'm sure we will have name clashes.
I was thinking of using FIXED names, CONSTANTS like DEVICE\KEYBOARD,DEVICE\MOUSE. Is there a better way to do this?
Then the final function is requestService(service handle,function,data buffer). Service handle is provided by the call above, the function is a service the driver provides eg read key and data buffer is where the driver will put the data.
This what I have so far, will add to it as I clear up these problems.
Any suggests, pointers or references to reading materials will be highly appreciated. Thanks