Device Drivers For Different IO Bus architectures

Hello Folks I am trying to find out some details about writing device drivers . If a device is capable of talking to different IO buses like PCI / ISA / PCI express etc . Is writing a driver to it on a unix / linux system be different If so in what way .

To elaborate the question more let us say a particular device could have different firmware on so it can talk to to CPU over different IO Bus as required and if the interface to the layer2 / firm ware is kept as same as possible , would the driver writing be any different .

Basically i am trying to find out if writing device drivers is different based on the IO bus used. I believe it should not be so , but i would like to here from the experts there .

thanks subra

Reply to
avsrk
Loading thread data ...

It depends on the operating system of course, but for the two "big" OS's, Windows and Linux, there are two different Interfaces.

On Unix, you can expect the open/close read/write ioctl model.

On Windows, you can expect the CreateFile/CloseHandle ReadFile/ WriteFile DeviceIoControl model.

Principle is roughly the same, but of course, the code will be completely different, both in kernel-mode and user-mode.

On Windows, bus drivers try to hide the specifics of buses as much as possible with bus drivers. For example, Microsoft made great effort to reduce the tedium of worrying about the specifics of the bus, I/O ports, interrupts, etc. Instead, with Plug-And-Play, the hardware interacts with kernel-mode components at boot time to create "a layer of fat" even between the already existing layer of fat that sits on top of the bus. That layer of fat presents, as best as it can, an interface that is uniform and more or less consistent between various network adapter drivers. The driver that the hardware manufacturer writes (this would be you) is called a Mini-Port, that "minimizes the difficulty of porting" the driver between various Windows platform like Intel IA-32 and MIPS.

But the simple answer to your questions:

  1. Can I write a device driver on Windows and expect to be able to support it with some reasonable percentage? No.
  2. If I write a driver for PCI on Windows for network adapter, will much of the code be reusable to run onto a similar adapter from different manufacturer but with different bus? Often times yes. At least the function interfaces will have a lot in common.

-Le Chaud Lapin-

Reply to
Le Chaud Lapin

Apart for interrupt requests (and previously set up DMA transfers), the device is passive and only reacts to actions by the CPU, running the device driver program.

So you really have to look at the problem from the CPU point of view. First you have to gain access to the correct bus, then to the correct card (e.g. setting up some PCI registers). Doing the actual transfer to 8/16 data registers would be similar or identical in different environments.

Paul

Reply to
Paul Keinanen

Le Thu, 08 Feb 2007 12:44:14 -0800, avsrk a écrit :

Of course it is different, on Linux at the very least. I think it can't be feasible to unify different I/O buses interfaces on the same Device driver API inside the kernel. See :

formatting link
Especially The Role of the Device Driver section, a very instructive discussion about "Policy and mechanism". And ... If you are a programmer see some piece of code if the kernel source tree, many years ago i started my Linux Driver readings with this : /usr/src/linux-xx/drivers/usb/serial/ftdi_sio.c

Cheers, Habib.

Reply to
habib.bouaziz-viallet

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.