smwikipedia
smwikipedia

Reputation: 64205

A question about Device drivers & Kernel

Currently, my OS boot from floppy. Since floppy driver is obsolete, i am planning to change the booting media.

As I try to figure out what booting media to use, I realize that no matter what I choose, I need to write device driver for it. Though the Real Mode BIOS may provide me with some interrupts to interact with that device, I am on my own once entered the Protected Mode. So I start to read the < Linux Device Driver 3rd edition > for some guide. But that book is about writing device driver for Linux system. So, that implies that device drivers are specific to operating system.

Now I got the following questions:

Upvotes: 0

Views: 681

Answers (1)

Mat
Mat

Reputation: 206689

A device driver is a piece of code that implements the interface between a device and (usually) the operating system kernel. In that regard, it is necessarily dependent on the operating system it's targeted for - that's is core purpose, making that operating system aware of the device and allow it to use its functions.

This is not to say that code for a device driver can't be shared on different OSes. Some parts of them could be portable (the device side), but the interface side (that interacts with the OS) is dependent on the API that OS defines/provides.

Layout in memory is entirely system dependent. There doesn't have to be any specific memory layout policies for drivers versus other kernel services. The device itself might very well impose memory layout constraints, but that's a different topic.

The OS defines how it interacts with device drivers through APIs. You've got the documentation for how Linux does it in that (great) book. Other OSes could do it differently - the OS designers set the rules. If you're the one creating the kernel, you define the APIs.

Hot-plug is not easy. One way of doing mapping is to use some form of lookup table with information from the device as a "key", and the suitable device driver structure/pointer/whatever as the value, or the other way around (having an API in your drivers that lets you know what device IDs the can handle). Device IDs could be PCI devices IDs, USB identifiers, ... depends on the bus and type of device.

Upvotes: 3

Related Questions