I'm working with Apple's DriverKitUserClientSample code as a basis, but I'm trying to use the PCIDriverKit.
In my MyClass::Start method I successfully get the IOPCIDevice from the provider, and call Open() and GetBusDeviceFunction() on it, getting the correct values. This method (MyClass::Start) is called when I install the DEXT using the DriverKitSampleApp.
I save the pointer to this IOPCIDevice as a member in the MyClass::IVars struct.
After installing the DEXT I want to access that same device using a user program I'm writing, that calls a different method MyClass::Foo. But when I try to run the same two functions Open() and/or GetBusDeviceFunction() from my method MyClass::Foo I get a kernel crash. With LLDB I see that I'm getting a GPF when accessing the IOPCIDevice object, even though I can still access other members of the MyClass::IVars struct (ints, chars etc) with no problem.
What am I doing wrong? Any hint?
Problem resolved: I didn't call
Start(provider, SUPERDISPATCH)in myStart()function before casting the provider toIOPCIDevice. After adding this to the code, crash stopped occurring.