how do programs find and call device drivers' routines?

时间:2016-02-12 19:47:34

标签: device-driver computer-architecture

Let's say a device driver has been written, compiled and loaded by the OS.

To call its subroutines, I assume one has to know what subroutines are provided by the device drivers (know its interface/API, I guess). So, I also assume we know about this interface thing too (correct me if I'm wrong).

Now the question is how we are supposed to find the entry point of these subroutines to call them; or better to say what is the exact procedure of calling a device driver's subroutines.

I am guessing it should be something like loading a dynamic library in which a linker finally puts the addresses of subroutines in the calling programs' address space.

NOTE

I am completely new to this field, so any information/link/illustration is truly appreciated.

1 个答案:

答案 0 :(得分:0)

The details of this are platform-specific.

For true device drivers, i.e. where the driver is the software interface for a physical device, the driver usually conforms to a certain standard interface that the O/S calls when needed to display something on screen, write a sector on a disk, and so on.

On Windows, if your driver exists to provide a software service that can only be performed in kernel mode, you can define your own call interface within your driver that can then be access from user mode via the DeviceIOControl function.