http://members.datafast.net.au/dft0802/drivers.htm

Writing PCI device drivers

When it comes to writing drivers, I am not really the best person to ask, as I have never been involved with PCI hardware design, or driver development. I have tinkered around with programming cards in plain DOS, but that's about it. Everything I know, you'll find in the source code of PCI and PCI32, which are included as standard in the distribution ZIP files.

Please don't write asking me to explain, modify or adapt my code to your purposes, as I will simply ignore you. If you can't glean what you want to know from my code, bad luck. Having said that, if you do have an intelligent, well thought out query regarding my code, feel free to ask. I am always happy to help those who have made a genuine effort, but I don't suffer fools. 

Here are some general guidelines on writing PCI Device drivers, however, which I suggest you take onboard:

IRQ Sharing: Learn how to do it!! If you don't understand about how to design software to share hardware interrupts, quit now. We will all be eternally grateful. That also goes for ACPI integration, hot-plug, power management and so on.

Multiple card support: Absolutely!! Design your code to support more than one card!!

PCI bus numbering: Never assume your card will be found on PCI Bus #0!! PCI Bridges are common these days - so scan all the busses for your card, not just Bus #0. for that matter, never assume the AGP Bus is bus #1, because it isn't always!

Device Driver development info & links

I strongly suggest developers study the Linux kernel source. It's messy and scattered over many source code files, but the 'guts' of what you need to know are all in there. The Linux kernel source is a goldmine of techniques, algorithms, technical notes and the like which you should never be without. You can get the kernel source here.

For Windows 2k, XP, 2003, .NET and so on, the only way to access _any_ sort or hardware, is with a kernel mode driver. For this (According to Microsoft), you need the "DDK", or Driver Development Kit. This is a fiendishly complex and expensive bit of software, designed to confuse, frustrate and confound you (oh, and it also produces working drivers, apparently). It's all "too hard" for me, though. Ask Microsoft what it costs if you really want it. Oh, and you'll need visual C++ or Visual Studio to use it, apparently. Pascal/Delphi/Kylix programmers may groan, at this point. 

A simple way to develop Windows drivers is to use a Commercial driver development kit. These kits take the hard work out of driver development and provide almost "wizard" like simplicity. The problem is, they don't suit all circumstances, don't give you 100% freedom to do as you please, and they inevitably cost money too and may have royalty implications. Check out http://www.jungo.com/ for some good examples of pre-packaged driver development kits.

Microsoft have a surprising amount of info on PCI published on their Windows Platform Development section. See Microsoft's PCI page for all the info. Microsoft also have this great page on general Windows driver development.


Reply via email to