How do I start writing my own device drivers for Windows?

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Hi everyone,

Given that I have the following: specific hardware info, some basic programming background, and Visual Studio 6. How would I go about writing my own device drivers for Win32 / NT / XP? I have already looked up the important chipsets used on the device and have obtained data sheets. The only thing is: I don't know where to start. Are there any pages / book that you can direct me to that has basic examples? Thanks...

By the way, I'm only doing this due to the fact that Pinnacle Systems lacks Win XP support for their Studio DC10+ video editing cards. They just don't care about their customers. I figured I can learn something during my semester break. Thanks..

 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
writing device drivers might be harder than you expect because there are a lot of hardware bit configurations/io address/irq/resources you need to take into account....

I once tried working on writing the tcp/ip stack for a cirrus ARM 7 developement board (because it had a chipset for 10baseT ethernet, but no drivers for it!) and something as simple as that took me forever to write, partly because I had no support for that particular board since it was discontinued. BUT I did have the data sheets and had to write the basic functions to communicate with the hardware and let me tell you, it wasn't fun at all.

Well, anyways, to make my story short, I got as far as intializing the chipset and getting it ready to communicate and everything after that was a pain in the arse!

then bam, cirrus sends me the drivers for a newer model, which I had to re-code a little to get it to work with my model. All that work for nothing - but in the end, I ended up having a portable web server that runs on a 12V batteries for weeks! My next stop, porting linux over into it so i can use it as a router :)

anyways, back to your quesiton, I would start by emailing the pinnacle and seeing if they are willing to send you some source code. Then i'd look at the datasheets and figure out how to access the chipset (like, what io addresses it use, how to initialize the chipset, etc, etc). Once you figure that stuff out, your next step would be to figure out how to access the chipset using your OS.
 

Turkey

Senior member
Jan 10, 2000
839
0
0
Read this. I agree with blahblah99... video editing cards are not simple devices and you will likely need to know some video processing algorithms (and possibly how to implement them in the video processor card's assembly). Looking at the Linux driver (if there is one) would be a huge help.
 

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Thanks for the tip! I found some source code for compatible drivers NT drivers for my card. I'll see what I can get from it. Man, this sounds like a lot of work. Maybe if I knew how to "edit" the current drivers to make it XP compatible, then it'd be easier.. Heh.
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Read and re-read the DDK. Don't try and develop a driver from scratch, but find an existing sample that does something close to what you want.

If you don't know C, you have to learn that first, and well. Then you'll need to know all about the Win32 synchronisation functions. Events, spinlocks, mutexes, critical sections. I assume you already know about the stuff about the device you are writting to.

You want to do this in your semester break? Erm, I think you'll need to take another approach.

It is possible to write drivers that sit upon other drivers, (I forget what they are called.) I don't know what would make their current driver not work with XP, but perhaps you could write a driver to sit ontop of their driver to fix whatever the issues are.

Honestly think it will be a better use of your time to sent Pinnacle lots of hate mail telling them to wise up, let them write the driver, and to pick another project.
 

Carceri

Member
Aug 7, 2001
119
0
0
Download the DDK from Microsoft, get a good book about the subject (I really liked "Writing Windows WDM Device Drivers" by Cris Cant) and spend A LOT of time. That should at least get you started.
 

yugpatel

Senior member
Feb 28, 2001
506
0
76
I agree with Moohooya. Just try to fix what is not functioning in the driver rather than re-writing from a scratch.
Just my 2c.
 

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Ahh.. Thanks again! I do have Chris Cant's book in my bookmark. I hope my school library has this. As for sending Pinnacle hate mail, I think many users have already. Check for yourself:

Link

Some of the users' posts were deleted by the mods.

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Looking at the Linux driver (if there is one) would be a huge help.

But be carefull for 2 reasons.

1) Linux drivers are going to be different from Windows because of a lot of different ideas about how things should work in both systems
2) Licensing gets complicated if you want to distribute your driver, GPL'd code (which the Linux driver would most likely be if it's a kernel module) that's released must also be GPL'd.
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Well if you are going ahead with this, keep us informed. I've written one before, granted a simple one, but I might be able to offer help when you run into problems.
 

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Thanks, Moohooya! :) I'll keep that in mind. I'm still in the process of reading the data sheets and an article on writing driver displays for Win CE. I hope this can start me off in the right direction. Another interesting note, I read that my card is similar to other top-end Pinnacle cards. The current drivers do not take advantage of its full features. heh.
 

dszd0g

Golden Member
Jun 14, 2000
1,226
0
0
Qacer, to write good device drivers you probably want an EE with some CS, or a CE degree or equivalent self taught knowledge. Device drivers talk to the hardware in its language; You need to understand how the hardware works. There are some good books out there on writing device drivers from what I hear. I have not read any of them, so I can't recommend one.
 

cookieman

Senior member
Jun 12, 2001
381
0
0
Hi!

I develop drivers on a daily basis but not hardware related, only filesystem hook related.

There are some things I recomend:
- Get a good debuger, I use Numega-SoftIce. link. You'll need one.
- Make yourself familiar with the DDK on that particular platform u want to code. The DDK for the Xp is a little different than for Win2K.
- I think that this package can help you on getting the basic things done around that card you want to code. You can start here.
- You must be very informed about the low level stuff of that card (Studio DC10+). Timings, registers, data format that it is expecting the card.

In your coding be very-very defensive. Take into acount that everything might fail. And if it fails and you do not catch it you get an beautifull blue-screen. Those are relatively hard to decipher.

Drivers are not simple applications. It might take you some time to make used to it.
Plan for a longer trip in driver land...
It can even mean that WinXp will be replaced by some other OS before you get your driver working 100% right... :(

Cheers,
 

LoneShadow

Member
Dec 8, 2001
126
0
0
For learning Device driver programming, read a lil of introduction to device drivers in the ddk, and go through the Toaster sample driver.
all u need is the ddk and a debugger, and run the sample toaster driver.

groups.google.com has few groups for nt kernel and driver development, be in touch with them.

WinDbg is good enuff ( i prefer this one over numega) and its free from MS, but u will need two computers to debug the driver.

If they have a linux driver (source), as someone mentioned above, that would be the best, otherwise ull have to work thru some sample video miniport drivers or simillar drivers source code.

you will also need help from your schoolmates who want to learn driver development, its good to involve a small team, get someone from EE (who does C programming) and someone from CS/CE, there are always peeps who wanna do some good programming in holidays :)
thats the fast way of doing a big project in less time, and yes, dont re-invent the wheel :)

Win2k Drivers usually work for winxp, if they have a good win2k driver that is, see if u can re-use that driver, or other vendors drivers for same chipset (may work).

also, bad driver code could ruin the card or the system(soft/hardware), not trying to scare u, just double check when u r in doubt :)

if u do start to develop this driver, lemme know, ill point u to other webbies for utilities and other stuff

gl and hf :)

LoneShadow
 

noxxic

Senior member
Dec 21, 2000
254
0
0
You may want to check sourceforge.com... Besides having plenty of source code to look at, i'm pretty sure I saw a Zoran chipset (DC10/Buz) or a Buz driver project somewhere in there.