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?
It looks like you're new here. If you want to get involved, click one of these buttons!
|Upcoming OSR Seminars|
|Writing WDF Drivers||21 Oct 2019||OSR Seminar Space & ONLINE|
|Internals & Software Drivers||18 Nov 2019||Dulles, VA|
|Kernel Debugging||30 Mar 2020||OSR Seminar Space|
|Developing Minifilters||27 Apr 2020||OSR Seminar Space & ONLINE|