getDeviceMemoryWithIndex alternative in PCIDriverKit for DEXT

Hi,
We have PCI storage device for which we use Kernel Driver.
In kernel driver development we use getDeviceMemoryWithIndex to get IODeviceMemory and then we map it using IODeviceMemory->map then we fetch virtual memory using IOMemoryMap->getVirtualAddress.

So my query is what's alternative for this in PCIDriverKit for developing DEXT.

I found _CopyDeviceMemoryWithIndex api which seems similar to getDeviceMemoryWithIndex.
But when I used this api then this is failing with error: 0xe00002cd (Device Not Open.)

I'm doubting this failure because of IOPCIDevice->Open failure for which I have already created another thread [https://developer.apple.com/forums/thread/661711] to discuss this issue.

There is no sample code available so I'm just following WWDC2020 presentation for Modernize PCI and SCSI drivers with DriverKit.

My driver is loading and unloading on device connect/disconnect and able to fetch VID and DEVID from PCI registers. I'm using IOPCIDevice as provider and IOPCIMatch for driver matching.

Any help or suggestion is really appreciated.
Thanks

Still exploring PCIDriverKit for getting this solution. Now after watching Modernize PCI and SCSI drivers with DriverKit I got points on how to proceed. As per the presentation, device memory mapping is done by PCIDriverKit so Memory Space and Configuration Space should be accessible.

There is no issue with Configuration Read/Write and MemoryReadxx is also working fine for reading offsets in a specific memory index (say BAR0).

But MemoryWriteXX APIs are causing DEXT crash.

In kernel driver development we use getDeviceMemoryWithIndex to get Device Memory (BAR0 -> Controller Register) and then we map it using IODeviceMemory->map then we fetch virtual memory using IOMemoryMap->getVirtualAddress.

So again my question is how can I achieve functionality similar to KEXT in DEXT??

I wonder if you have found a solution, I also encountered this problem。

getDeviceMemoryWithIndex alternative in PCIDriverKit for DEXT
 
 
Q