Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Question on loading firmware into PCIe device.

Erik_DabrowskyErik_Dabrowsky Member - All Emails Posts: 25


I'd like to get an answer to a question and some ideas/feedback on a good way to load a firmware binary into my PCIe device.

The card requires that I specify the address of the firmware code in system memory using four 16 bit registers (it can support a 64 bit address) and two 16 bit registers for the length. Then write a command to another register to cause it to read the data from system memory. The firmware binary is approx 256kb.

My game plan so far is to read the firmware binary off disk and into a WDFMemory object during DriverEntry. This way if the file is not found or something is wrong with it, I can fail the driver early (also the framework will clean up the memory object for me when the driver unloads).

Next in the EvtDeviceAdd callback I'll set up a WDFDMAEnabler and WDFCommonBuffer. I'll need this later anyway for other DMA operations.

The routine to actually load the firmware into the device will probably be called from EvtDeviceD0EntryPostInterruptsEnabled.
In this routine I plan to copy the data from the WDFMemory buffer to the WDFCommonBuffer, then start a DMA transaction.

Here's where I hit a bit of a snag. The WdfDmaTransactionInitialize function requires an MDL and a VirtualAddress.
I'm assuming I can supply the virtual address of the WDFCommonBuffer, but where do I get the MDL from?
Do I need to call IoAllocateMdl and MmBuildMdlForNonPagedPool and then pass that to the WdfDmaTransactionInitialize function?



  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,631

    Ah! I just did this... don’t use a DMA transaction. Instead, just pass the Logical address of the Common Buffer to your device to use in its DMA operation. Done!


    Peter Viscarola

  • Erik_DabrowskyErik_Dabrowsky Member - All Emails Posts: 25

    Thanks Peter. This feels like one of those "duh!" moments where the answer was right in front of my face and I didn't see it. For some reason I was thinking the "map registers" part of it happened later in the DMA process.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 20 Apr 2020 OSR Seminar Space & ONLINE
Writing WDF Drivers 11 May 2020 OSR Seminar Space & ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA