Post

Replies

Boosts

Views

Activity

IOServiceNameMatching can't find dext service
I'm using the following code to find the dext service. The driver is enabled in iOS settings prior to launching the app. io_service_t mService = IO_OBJECT_NULL; kern_return_t ret = kIOReturnSuccess; io_iterator_t iterator = IO_OBJECT_NULL; if (__builtin_available(iOS 15.0, *)) { ret = IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceNameMatching("MyDriver"), &iterator); } else { // Fallback on earlier versions } if (ret != kIOReturnSuccess) { printf("Unable to find service"); } while ((mService = IOIteratorNext(iterator)) != IO_OBJECT_NULL) { //Only able to find service if launching the app first and then connecting the device .......... } I noticed the call IOServiceNameMatching doesn't return the same result for the following workflows: Launch the app first and then connect the device, IOServiceGetMatchingServices can find the service. Connect the device to USB-C port first, then launch the app, the same call can't find a matching service (iterator is null). I would need to disconnect and reconnect the device while the app is running in order to find the matching dext. Any suggestion on how to find the matching dext service for workflow #2? Thanks
6
0
485
Aug ’24
Build DriverKit in projects with a test plan
I'm trying to build an XCode project that contains an app and another target for the DriverKit, and run into the following linker issue: ld: file cannot be open()ed, errno=2 path=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.profile_driverkit.a in '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.profile_driverkit.a' clang: error: linker command failed with exit code 1 (use -v to see invocation) My project has Code Coverage enabled. I noticed that if I disabled Code Coverage for all targets, I would be able to build successfully, and the driverKit would work as expected. I wonder if it would be possible to build DriverKit without disabling code coverage. Thanks
2
0
379
Jul ’24
Transfer large data using IOUserClient AsyncCompletion
I'm trying to make an asynchronous bulk data read using IOUSBHostPipe AsyncIO/CompleteAsyncIO and send the data back to the user-space application using AsyncCompletion. virtual void AsyncCompletion(OSAction *action, IOReturn status, const IOUserClientAsyncArgumentsArray asyncData, uint32_t asyncDataCount); My understanding is that the IOUserClientAsyncArgumentsArray asyncData in AsyncCompletion method has a limited size of 128 bytes, and the data I need to send back is over 10k bytes. Would it be possible to send such large data from the driver to the user-space application using async callback? Thanks
1
0
457
Jun ’24
DriverKit CompleteAsyncIO callback
I'm trying to make an asynchronous bulk data read using AsyncIO/CompleteAsyncIO. The problem I'm facing is that the AsyncIO succeeds but CompleteAsyncIO/ReadComplete doesn't get called when the AsyncIO's completion timeout is set to 0. Changing the completion timeout to a non-zero would trigger ReadComplete but I keep getting the (0x2d6) "I/O Timeout" error Any idea what I'm doing wrong? Also, is there any limit for the maximum buffer length the callback can accept? Thanks. struct MyDriver_IVars { OSAction* callbackAction = nullptr; // registered callback action by app IOUSBHostInterface* interface; IOUSBHostPipe* pipe; IOBufferMemoryDescriptor* inDataBuffer; OSAction* ioCompleteCallback = nullptr; // read complete callback action uint32_t MAX_LENGTH = 1024; }; kern_return_t IMPL(MyDriver, Start){ //........... ret = ivars->interface->CopyPipe(endpoint->bEndpointAddress, &ivars->pipe); ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionInOut, ivars->MAX_LENGTH, &ivars->inDataBuffer); ret = CreateActionReadComplete(ivars->MAX_LENGTH, &ivars->ioCompleteCallback); //........... } kern_return_t MyDriver::ReadData(int nbytes, int timeout) { //........... kern_return_t ret = ivars->pipe->AsyncIO(ivars->inDataBuffer, ivars->MAX_LENGTH, ivars->ioCompleteCallback, 0); //........... } void IMPL(MyDriver, ReadComplete) { Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount); //AsyncCompletion(ivars->callbackAction, .................. } virtual void ReadComplete(OSAction* action, IOReturn status, uint32_t actualByteCount, uint64_t completionTimestamp) TYPE(IOUSBHostPipe::CompleteAsyncIO);
1
0
453
Jun ’24