none
Simple / Generic PCI Driver with a Small Number of Source Files RRS feed

  • Question

  • Does anyone know of a WDM Device Driver Example for PCI with the .sys and .dll targets made of single or very few source files. I am trying to learn Windows 7 Driver Development and all Microsoft Examples are very difficult to understand!
    • Edited by VS2013User Sunday, September 4, 2016 3:47 PM
    Sunday, September 4, 2016 3:14 PM

Answers

  • if you want small and simple, go with the WDF samples. pcidrv, etc. if you want to learn drivers first without understanding hardware , look at toaster. PCI adds a bunch of complexity.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Sunday, September 4, 2016 4:07 PM
  • You don't need an open source driver development kit, it turns out that KMDF sources are available on GitHub https://github.com/Microsoft/Windows-driver-frameworks

    I can't sell you the sample code it was done for a client.  As Doron pointed out the WDK sample under general\toaster\toastDrv\kmdf\func\simple is a good place to start.   The sample has the basics for a driver that does not talk to hardware.  To this sample you at a minimum for a PCI device will need to add EvtDevicePrepareHardware and EvtDeviceReleaseHardware with the call registration in EvtDeviceAdd.

    You should probably take the simple driver from Toaster, strip out the code you don't want, and add the hardware functions above.  Take a look at one of the PCI samples I mentioned earlier for how to map the device hardware so it is accessible.   Start simple, and feel free to ask a lot of questions on this forum.

    If somebody knows of a simple low cost PCIe card that would be a good example (for instance like the SeaLevel board https://store.osr.com/product/sealevel-8018-digital-io-kit/)  I would be tempted to create a simple sample and put it out there.  Unfortunately, doing it for the old SeaLevel wouldn't do much good because so few systems have regular PCI these days.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by VS2013User Sunday, September 4, 2016 5:28 PM
    Sunday, September 4, 2016 5:05 PM

All replies

  • if you want small and simple, go with the WDF samples. pcidrv, etc. if you want to learn drivers first without understanding hardware , look at toaster. PCI adds a bunch of complexity.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Sunday, September 4, 2016 4:07 PM
  • Thanks for Responding:

    I see many source files in PCIDRV. Are there any simpler examples outside of Microsoft Examples?

    Sunday, September 4, 2016 4:18 PM
  • First why are you specifying WDM?  For any new PCI driver you should be looking at KMDF.  KMDF handles a lot of the nasty coding issues for you.

    As far as a PCI sample unfortunately the only one out there in general is the PLX9x5x or the PCIDRV samples.  These samples have a lot of code in them, but that is because they try to do everything.  You may want to take something like the PCIDRV and walk through the code starting at DriverEntry, you will quickly find that a lot of the calls are for things your PCI device may not do, so you can prune that part of the code.   

    It is unfortunate that there aren't simpler examples out there for people.  I recently did a suite of devices that included a driver to read a set of switches off a PCI board, the total size of the driver source was about 400 lines of code including comments.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Sunday, September 4, 2016 4:19 PM
  • In Linux I can build a PCI Driver in minutes. I cannot believe Microsoft does not provide a simple framework to build a simple driver to read and write a 16K Register space which is what I need!
    Sunday, September 4, 2016 4:20 PM
  • Don, I see you answering a lot of these types of questions. Thanks for the reply. If there was a simple KMDF example I would use it. Any suggestions on this or are there any open source driver development kits out there. I see lots of Driver Development Kits costing thousands of dollars.

    Would you sell me the source code for your Simple PCI Board example? Studying 400 Lines is better than thousands of Lines!

    Sunday, September 4, 2016 4:34 PM
  • You don't need an open source driver development kit, it turns out that KMDF sources are available on GitHub https://github.com/Microsoft/Windows-driver-frameworks

    I can't sell you the sample code it was done for a client.  As Doron pointed out the WDK sample under general\toaster\toastDrv\kmdf\func\simple is a good place to start.   The sample has the basics for a driver that does not talk to hardware.  To this sample you at a minimum for a PCI device will need to add EvtDevicePrepareHardware and EvtDeviceReleaseHardware with the call registration in EvtDeviceAdd.

    You should probably take the simple driver from Toaster, strip out the code you don't want, and add the hardware functions above.  Take a look at one of the PCI samples I mentioned earlier for how to map the device hardware so it is accessible.   Start simple, and feel free to ask a lot of questions on this forum.

    If somebody knows of a simple low cost PCIe card that would be a good example (for instance like the SeaLevel board https://store.osr.com/product/sealevel-8018-digital-io-kit/)  I would be tempted to create a simple sample and put it out there.  Unfortunately, doing it for the old SeaLevel wouldn't do much good because so few systems have regular PCI these days.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by VS2013User Sunday, September 4, 2016 5:28 PM
    Sunday, September 4, 2016 5:05 PM
  • How about a serial PCIe like this?

    Monday, September 5, 2016 11:19 PM