How does an O.S. or a high level abstraction layer gain knowledge of the hardware using the device driver?

148 views Asked by At

When reading about hardware/device independence this statement from wikipedia (http://en.wikipedia.org/wiki/Device_independence#Desktop_computing) states that:

The application software does not need to know anything about the hardware on which it was to be used. Instead it discovers the capabilities of the hardware through the standardized abstraction layer, and then use abstracted commands to control the hardware.

I wanted to know about the lower level interaction between the BIOS routine/device driver/HAL/OS and the device controller about discovering the hardware capabilities.

Kindly help me out to understand the communication between these entities that takes place which helps in hardware independence.

1

There are 1 answers

1
Adashi On BEST ANSWER

Hardware devices, normally, connect to the main controller through a standard bus of some kind. For example - PCI, PEX, USB.

Each connected device on the bus will be allocated with a device #, bus #, function #, etc, by the bus controller.

Modern bus contollers either provide the main controller with the ability to perform a scan, or send an event when a device is hot plugged into the bus.

Per each discovered device, it is possible, using the bus controller standard commands (such as read/write registers of a device, by device ID, bus number, etc), to interrogate the device for details such as:

  • Manufacturer ID
  • Device ID
  • Class (controller / networking device / Human interface / imaging device / and so on)

Per bus type, all these details must be available in the same way for every connected HW device, thus enabling the OS to use an abstraction layer.

Once a device has been discovered and identified, the OS will call all the specific bus registered device drivers' probe function, which use the details mentioned above to decide if can handle it. When a device driver probe succeeds, an instance of the driver is allocated and can be used directly by the application that needs to access the HW.

For example: USB PC CAM connects to USB port. An event is sent to the main CPU by the USB bus controller. The CPU will use the standard USB bus controller functions to learn the manufacturer & device ID/s, device class, functions, etc, and will call all the USB registered device drivers probe functions.

If an appropriate device driver is installed (registered), it will successfully create an instance of the device and a video application (such as skype) can use it directly, through DLLs supplied by the driver SW.

Hope this helps.