The Map() of IOBufferMemoryDescriptor failure and cause the DriverKit Start() repeat

Hello Everyone,

I am trying to develop a DriverKit for RAID system, using PCIDriverKit & SCSIControllerDriverKit framework. The driver can detect the Vendor ID and Device ID. But before communicating to the RAID system, I would like to simulate a virtual Volume using a memory block to talk with macOS.

In the UserInitializeController(), I allocated a 512K memory for a IOBufferMemoryDescriptor* volumeBuffer, but fail to use Map() to map memory for volumeBuffer.

result = ivars->volumeBuffer->Map(
        0,                       // Options: Use default
        0,                       // Offset: Start of the buffer
        ivars->volumeSize,       // Length: Must not exceed buffer size
        0,                       // Flags: Use default
        nullptr,                 // Address space: Default address space
        &mappedAddress           // Output parameter
);
Log("Memory mapped completed at address: 0x%llx", mappedAddress); // this line never run

The Log for Map completed never run, just restart to run the Start() and makes this Driver re-run again and again, in the end, the driver eat out macOS's memory and system halt.

Are the parameters for Map() error? or I should not put this code in UserInitializeController()?

Any help is appreciated! Thanks in advance.

Charles

The Map() of IOBufferMemoryDescriptor failure and cause the DriverKit Start() repeat
 
 
Q