1

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.

PC_Study
  • 15
  • 4
  • The return value of [MmMapIoSpace](https://msdn.microsoft.com/en-us/library/windows/hardware/ff554618(v=vs.85).aspx) will be a pointer you can use to read and write the FPGA RAM. –  Aug 24 '17 at 01:36
  • Thanks for the reply. I use MmMapIoSpace to obtain the Virtual address. I plan to use RtlCopyMemory to copy the data to the virtual address. That data will come from an IORequest Buffer. At the moment I don't have any hardware to confirm this. – PC_Study Aug 24 '17 at 02:09

1 Answers1

0

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