We have developed a DEXT using PCIDriverKit with IOPCIDevice as its provider. DEXT crashes when accessing Memory Space using MemoryWriteXX APIs available in PCIDriverKit.
We are following the below steps as specified in the Modernize PCI and SCSI drivers with DriverKit presentation.
- We are calling Open() in Start() as PCI DEXTs must open their provider prior to memory/configuration space access. However, this method returns kIOReturnNotOpen error code. This has already been posted as a separate question here.
- We are enabling bus master and memory space as this has to be done before issuing any memory reads/writes.
- Though Open() fails, we are still able to read/write to the device's configuration space using ConfigurationReadxx/ConfigurationWritexx APIs.
- As per the presentation, device memory mapping is done by PCIDriverKit and MemoryReadxx is working fine for reading offsets in a specific memory index (say BAR0).
However, DEXT crashes when we try to use MemoryWritexx for writing to any offset (controller registers) in memory index 0 (BAR0). Our device has only BAR0 available. We verified from the crash log that the point of crash is the MemoryWrite method.
-
Are there any other steps that have to be performed before writing to the memory space using MemoryWrite?
-
Should the Open() call be successful in order to write to the memory space? If yes, how to open a session successfully without Open() returning an error code?
-
The above steps were performed on a M1 machine. We executed the same steps on an Intel machine but even MemoryReadxx API fails there. Is this related to device memory mapping on an Intel machine? How to overcome this issue if PCIDriverKit takes care of device memory mapping?
Any help or suggestions would be greatly appreciated.