DriverKit

RSS for tag

Develop device drivers that run in user space using DriverKit.

DriverKit Documentation

Posts under DriverKit tag

62 Posts
Sort by:
Post not yet marked as solved
0 Replies
29 Views
We are experimenting with DriverKit on macOS while DriverKit is still in beta on iPadOS. We want to build a Driver for iPad that will allow to communicate our iPad App with USB device. What we did: Configured and implemented a driver that uses USBDriverKit::IOUSBHostInterface as provider. This driver is automatically matched/started by macOS when we plug our device into USB port. Next we utilised USBDriverKit::IOUSBHostPipe to send/receive data from our device. We print data from device in logs for now. Studied Communicating Between a DriverKit Extension and a Client App Configured and implemented a driver that based on IOUserClient and allows to open communication channel by macOs App using IOServiceOpen API. Driver has callback to pass data to macOS Client App. Currently we want to combine 2 drivers and pass data received from USB device to our client App using callback. Unfortunately, we stuck since now we have 2 instances of driver: First instance is automatically run by macOS when device is plugged Second instance is created when we are connecting from Client App and virtual kern_return_t NewUserClient(uint32_t type, IOUserClient** userClient) method is called. So we can't use second instance to do USB device communication since it has wrong provider(IOUserClient) in kern_return_t Start(IOService * provider) but we need IOUSBHostInterface to start:     ivars->interface = OSDynamicCast(IOUSBHostInterface, provider);     if(ivars->interface == NULL) {         ret = kIOReturnNoDevice;         goto Exit;     } Are we doing it wrong? Maybe instead of automatic matching for IOUSBHostInterface we should do it manually from UserClient driver or use another approach? As we learned we have to create a new service instance in NewUserClient method and can't return driver that was run by OS: kern_return_t IMPL(MyDriver, NewUserClient) {     kern_return_t ret = kIOReturnSuccess;     IOService* client = nullptr;     ret = Create(this, "UserClientProperties", &client);     if (ret != kIOReturnSuccess)     {         goto Exit;     }     *userClient = OSDynamicCast(IOUserClient, client);     if (*userClient == NULL)     {         client->release();         ret = kIOReturnError;         goto Exit;     } Exit:     return ret; } BTW, maybe there is much easier way to forward data from USB device to iPadOS App?
Posted
by myurik2.
Last updated
.
Post not yet marked as solved
6 Replies
2.6k Views
I have a CH340g connected to my M1 MacBook Air running the latest Big Sur 11.2.3. It appeared only one time in /dev, and now will not re-appear. I've tried plugging it in to both ports, unplugging everything except for the CH340g, and also kextunload, kextload on AppleUSBSerial.kext. It does not appear in /dev Has anyone had any luck with this device? Or perhaps some advice?
Posted
by Zambetti.
Last updated
.
Post not yet marked as solved
0 Replies
86 Views
We followed WWDC Session: System Extensions and DriverKit and recreated a code to do USB device communication via IOUSBHostPipe: struct MyDriver_IVars {     IOUSBHostInterface       *interface;     IOUSBHostPipe            *inPipe;     OSAction                 *ioCompleteCallback;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; kern_return_t IMPL(MyDriver, Start) { ...     ivars->maxPacketSize = 64;     ret = ivars->interface->CreateIOBuffer( kIOMemoryDirectionInOut,                                            ivars->maxPacketSize,                                            &ivars->inData);     ret = CreateActionReadComplete(0, &ivars->ioCompleteCallback); ret = ivars->inPipe->AsyncIO(ivars->inData,                                  ivars->maxPacketSize,                                  ivars->ioCompleteCallback,                                  0); ... } Our Driver is started by OS when device is connected. We see that ReadComplete callback is called: void IMPL(MyDriver, ReadComplete) {     Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount); } However it's not obvious how to read data received in this callback. I suspect that we should use IOBufferMemoryDescriptor *inData but we didn't find any good example/sample and documentation is poor. Our callback is called only once. It's not clear how to read a series of data from device? Should we create some loop and call inPipe->AsyncIO from callback? Also it would be helpful to see how to pass data to device. I hope we should fill IOBufferMemoryDescriptor *inData.
Posted
by myurik2.
Last updated
.
Post not yet marked as solved
3 Replies
187 Views
We requested com.apple.developer.driverkit.transport.usb entitlement a few days ago and it looks like it was granted since we see(can select) it at: App Id -> Additional Capabilities Tab -> DriverKit USB Transport - Vendor ID. We tried to choose both options at Additional Entitlements page Default and Driver Kit and System Extension Template for **** Mac Dev. Generated profile displays DriverKit USB Transport - Vendor ID in Enabled Capabilities in browser. However downloaded profile doesn't include com.apple.developer.driverkit.transport.usb. As a result our Driver fails to start and in Console we see: Driver: Unsatisfied entitlements: com.apple.developer.driverkit.transport.usb /Library/SystemExtensions/675FA894-8985-4D86-B0FF-B892B9AEA27B/Driver.dext/Driver signature not valid: -67671 BTW, we tried to modify existing profile and create a new one. Did we miss something? Is any way to check entitlement status with Apple support?
Posted
by myurik2.
Last updated
.
Post not yet marked as solved
3 Replies
382 Views
I watched the session multiple times, but it just gives a high level overview that doesn't really say much about this very exciting and complex new feature. It only mentions actually talking to the driver in passing with a single sentence "apps use the IOKit framework to open user clients". Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit, and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there. Am I missing something, or is this simply not available in Xcode 14 seed 1? Release notes don't mention anything either, and docs are only updated to reflect that some of this stuff is now available on iPadOS 16...
Posted
by fichek.
Last updated
.
Post not yet marked as solved
0 Replies
88 Views
Hello, my goal is to port a virtual audio device written using CoreAudio and IOKit to DriverKit because it is mandatory for App Store distribution for macOS. The driver can be easily installed in Library/Audio/Plug-Ins/HAL and has a .driver extension; it already works in user-space and it is a loopback interface for audio capturing and processing. I have viewed other posts on this forum and the WWDC21 and WWDC22 videos regarding the uses of DriverKit. My question is if it possible to port such driver to DriverKit and embed it in a macOS app for the app store. If yes, is there an example I can follow that allows me to fully embed the driver in an app and consume it from there or if I should still stick to using a separate installer distributing it elsewhere.I have viewed this: https://developer.apple.com/documentation/coreaudio/building_an_audio_server_plug-in_and_driver_extension and it seems that the .driver cannot be embedded in an app in anyway. Thank you kindly for your help, Best regards, Chris
Posted Last updated
.
Post not yet marked as solved
10 Replies
539 Views
We're invited to write PCI drivers for iPad, but there's no capability for PCI Driver Kit in Xcode and a com.apple.developer.driverkit.transport.pci key in your entitlements does not find its way into your embedded.provisionprofile with Automatically Manage Signing nor can you manually add it in the appID portal, because it's not there. Huh?
Posted Last updated
.
Post not yet marked as solved
2 Replies
219 Views
You don't seem to be able to provision USB or PCI iPad DriverKit drivers, so I tried the null driver which requires only the driverkit entitlement, which can be automatically managed by the Xcode 14 beta. I can get it to deploy, but when it is enabled or when it matches, I see errors like "job failed to spawn," Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x105706980 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}} I wonder why that happens for me but didn't happen in the demo.
Posted Last updated
.
Post not yet marked as solved
5 Replies
376 Views
Xcode 14.0 beta (14A5228q) refuses to build a DriverKit extension's installer app unless the dext's bundleID a single . suffix added to the bundling app's bundle ID. The error is error build: Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier. Is this behaviour intentional? Maybe it makes sense for non-driverkit bundled things, but it breaks existing software, invalidates existing dext bundle IDs and leads to awkward bundleIDs like com.foo.installer.mydriver.
Posted Last updated
.
Post not yet marked as solved
0 Replies
89 Views
There is currently no way to "Bring your driver to iPad with DriverKit" because it's impossible to develop a driver because developers can neither deploy to the device nor run there because there is no way to procure development provisioning profiles with the required entitlements for actual hardware (USB, PCI). I bought an M1 iPad just to test this alleged new capability and the only thing it's good for so far is theoretically transferring files quickly or attaching some kind of ethernet dongle. My 1 month no-questions-asked returns window is going to close soon! FB10152280 FB10244398 FB10244627 FB10160665 FB10152361 FB10160793 FB10152210 FB10160567 FB10244046 FB10427776
Posted Last updated
.
Post not yet marked as solved
0 Replies
127 Views
There is no documentation for running, debugging and testing system extensions on iPadOS16. The WWDC 2022 session "Bring your driver to iPad with DriverKit" does not count because (as of beta 2) it is completely unreproducible. This document tells us that to test our system extensions we must disable SIP so it's clearly only for macOS: https://developer.apple.com/documentation/driverkit/debugging_and_testing_system_extensions It would be nice if this document were updated with reproducible instructions for testing system extensions on iPadOS! FB10427776
Posted Last updated
.
Post not yet marked as solved
0 Replies
91 Views
I'm trying to make a DEXT target within my project. It compiles and links fine if I build just its own scheme. However, if I build my app's target, which includes the DEXT as a dependency, the build fails when linking the DEXT. The linker commands are different in the two cases. When built as part of the larger project, the DEXT linker command includes -fsanitize\=undefined. This flag is absent when I build using the DEXT's scheme alone. I searched the .pbxproj for "sanitize" - it doesn't appear, so it looks like Xcode is adding this flag. The linker failure is this: File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.1.6/lib/darwin/libclang_rt.ubsan_driverkit_dynamic.dylib The only files with "driver kit" in their name in that directory are these two: libclang_rt.cc_kext_driverkit.a libclang_rt.driverkit.a The successful link command includes this directive: -lc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.1.6/lib/darwin/libclang_rt.driverkit.a while the unsuccessful link command includes this one: -lc++ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.1.6/lib/darwin/libclang_rt.ubsan_driverkit_dynamic.dylib I tried adding -fno-sanitize=undefined to the OTHER_LINKER_FLAGS for the DEXT target, hoping that this would cancel the effect of the previous -fsanitize, but then I get undefined symbol errors: Undefined symbol: ___ubsan_handle_shift_out_of_bounds Undefined symbol: ___ubsan_handle_type_mismatch_v1 These appear to be referred to by the macros used in the iig magic. I'm using Xcode 13.4.1 (13F100). Does anyone know how I can fix this?
Posted
by ssmith_c.
Last updated
.
Post not yet marked as solved
3 Replies
195 Views
We created Driver sample by Xcode template and following macro was added into code: #define Log(fmt, ...) os_log(OS_LOG_DEFAULT, "Driver - " fmt "\n", ##__VA_ARGS__) We used this macro in init and start. For example: bool ForcePlateDriver::init() { Log("init()"); But our logs are not displayed in Console app. Did we miss something? Is anything else is required to have logs for Driver? Our environment: MacOS Monterey - 12.4 (21F79) Xcode - Version 13.4 (13F17a)
Posted
by myurik2.
Last updated
.
Post not yet marked as solved
0 Replies
98 Views
Hello devs, We are trying to find a development board to test the SPI device with our driver. It turns out that there are no SOM boards available in the market that can support MacOS. How do developers verify their driver can support the device they are porting? Could some devs show us the way to do it?
Posted
by ColinWang.
Last updated
.
Post not yet marked as solved
2 Replies
225 Views
We inspired by announce that DriverKit will come to iPadOs this fall and decided to experiment with DriverKit on macOS. We started from scratch but followed all the recommendations from Sample. With our installer code we can: Install driver extension to macOS system. (systemextensionsctl list shows [activated enabled]) for our driver See driver record using ioreg. So it's displayed: MyDriver <class IOUserService, id 0x10000193b, registered, matched, active, busy 0 (0 ms), retain 7> See *.MyDriver process in Activity Monitor In client code we can find a match: private let dextIdentifier = "MyDriver" private var lastResult: kern_return_t = kIOReturnSuccess private var connection: io_connect_t = IO_OBJECT_NULL var iterator: io_iterator_t = IO_OBJECT_NULL var driver: io_service_t = IO_OBJECT_NULL lastResult = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching(dextIdentifier), &iterator) print("Search for services ...") while case let service = IOIteratorNext(iterator), service != IO_OBJECT_NULL { driver = service } IOObjectRelease(iterator) guard driver != IO_OBJECT_NULL else { return } So driver is not IO_OBJECT_NULL. But we stuck on IOServiceOpen. So code: lastResult = IOServiceOpen(driver, mach_task_self_, UInt32(kIOHIDServerConnectType), &connection); validateLastResult(forOperation: "opening service") prints opening service: (iokit/common) general error since IOServiceOpen returns 0x2bc What we tried: Disable SIP in recovery mode and set systemextensionsctl developer on Result: opening service: (iokit/common) general error Add com.apple.developer.driverkit.userclient-access to our client App. Result: App crashes on start and in Console we see: taskgated-helper - Unsatisfied entitlements: com.apple.developer.driverkit.userclient-access. We requested this entitlement. We found post were com.apple.developer.driverkit.allow-any-userclient-access suggested as solution. Result: Driver extension is not started and we see in Console: taskgated-helper MyDriver: Unsatisfied entitlements: com.apple.developer.driverkit.allow-any-userclient-access amfid /Library/SystemExtensions/B7624EEF-3688-4735-A58B-26FEF4DE353C/MyDriver.dext/MyDriver signature not valid: -67671 We recreated appIds, profiles on developer account that has com.apple.developer.driverkit.allow-any-userclient-access from Apple. Result: Driver extension is started but we still see opening service: (iokit/common) general error We modified CommunicatingBetweenADriverKitExtensionAndAClientApp.zip by setting our appIds and profiles and run in in SIP disabled mode. Result: opening service: (iokit/common) general error Our environment: macOS Monterey 12.4 XCode Version 13.4 (13F17a) Driver Code is pretty straightforward: ///// iig class MyDriver: public IOUserClient { public: virtual bool init(void) override; virtual kern_return_t Start(IOService * provider) override; virtual kern_return_t Stop(IOService* provider) override; virtual void free(void) override; }; ///// cpp #define Log(fmt, ...) os_log(OS_LOG_DEFAULT, "MyDriver - " fmt "\n", ##__VA_ARGS__) struct MyDriver_IVars { OSAction* callbackAction = nullptr; }; bool MyDriver::init() { bool result = false; Log("init()"); result = super::init(); if (result != true) { Log("init() - super::init failed."); goto Exit; } ivars = IONewZero(MyDriver_IVars, 1); if (ivars == nullptr) { Log("init() - Failed to allocate memory for ivars."); goto Exit; } Log("init() - Finished."); return true; Exit: return false; } kern_return_t IMPL(MyDriver, Start) { kern_return_t ret; ret = Start(provider, SUPERDISPATCH); if(ret != kIOReturnSuccess) { Log("Start() - super::Start failed with error: 0x%08x.", ret); goto Exit; } ret = RegisterService(); if (ret != kIOReturnSuccess) { Log("Start() - Failed to register service with error: 0x%08x.", ret); goto Exit; } Log("Start() - Finished."); ret = kIOReturnSuccess; Exit: return ret; } kern_return_t IMPL(MyDriver, Stop) { kern_return_t ret = kIOReturnSuccess; Log("Stop()"); ret = Stop(provider, SUPERDISPATCH); if (ret != kIOReturnSuccess) { Log("Stop() - super::Stop failed with error: 0x%08x.", ret); } return ret; } void MyDriver::free(void) { Log("free()"); IOSafeDeleteNULL(ivars, MyDriver_IVars, 1); super::free(); }
Posted
by myurik2.
Last updated
.
Post not yet marked as solved
1 Replies
128 Views
I am working on a USBDriverKit project and would like to ask if it is possible in driver's code to read a file which is stored outside of the driver bundle? The reason, why the file has to be stored somewhere else than inside of the driver bundle, is that the file's contents should be written by a client app. Therefore it is not possible to use for reading e.g. OSBundle::loadResource method, as the driver bundle inside the /Library/SystemExtensions directory is not writeable by the client app.
Posted Last updated
.
Post marked as solved
2 Replies
513 Views
Hello, I'm developing a kit which works with PCIe card (a calculation accelerator). The kit contains a dynamic library which communicates with PCIe card driver (dext) via userclient part. Test applications inside the kit works well. The kit itself can be used as a python module. But python app doesn't contain the userclient access entitlements and the communication with the driver is broken. Is it possible to make/to sign a module (not application) to work with the hardware (PCIe card)? Or what is the common solution for such case? One of the way is a disabling AMFI but it doesn't work for end-user.
Posted
by P_Egor.
Last updated
.
Post not yet marked as solved
0 Replies
116 Views
I have submitted Driverkit Entitlement many days ago, but just get the following response: Follow-up: 800552688 Thank you for requesting the DriverKit framework capability. You will be contacted once your request has been evaluated. Regards, Apple Developer Relations How can I see the progress of Follow-up: 800552688?
Posted
by vansonhk.
Last updated
.
Post not yet marked as solved
3 Replies
496 Views
I have closely looked at WWDC 2019 videos and DriverKit APIs. I don’t see any support for FireWire devices. Is that coming?
Posted
by pneyrinck.
Last updated
.