Search code examples
windowsdriverpcikmdf

WINDOWS KMDF PCI DRIVER:- API For Writing Data To MemoryMapped Virtual Address


I have the task of writing a KMDF based PCI driver for Windows. Basically the objective is to write data to RAM which is on a FGPGA board (The board doesn't exist yet). A PCI interface on the FPGA will allow data to be directly read and written to the FPGA RAM.

The idea is the necessary memory mapping information will be stored in BAR0 register. The memory descriptor type would be CmResourceTypeMemory. The first step would be to read the BAR0 register info and create a memory map.

Using another board, I have written a basic driver which performs the above.

However once I have the memory address (Virtual), I would then like to read and write from that memory. I notice windows has APIs for reading and writing to PORTS and REGISTERs. Is there something equivalent for writing and reading various amounts of data to the virtual address:- I.E. Coping a data buffer to the virtual address. Copying directly seems like one option, however I suspect there may be an API to perform this.

I`ve looked at various github PCI examples, however they tend to use register and port read and writes.


Solution

  • Use the READ_REGISTER_BUFFER_xxx and WRITE_REGISTER_BUFFER_xxx routines. See the HAL Library Routines section in the MSDN documentation.