DriverKit

RSS for tag

Develop device drivers that run in user space using DriverKit.

DriverKit Documentation

Posts under DriverKit tag

71 Posts
Sort by:
Post not yet marked as solved
2 Replies
1.5k Views
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
Posted
by
Post marked as solved
4 Replies
733 Views
Hi , I am trying to write dext code for my existing Kext , i see "IOMemoryDescriptor::withAddress" being used , I dont find any alternatives in "DriverKit", Is there any others ways to achieve this, Any input is appriciated , Thanks, revan
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
I have a IOUSBHostInterface system extension that works great, however if I leave the device plugged in during a reboot, the usual driver is loaded instead and an un-plug + replug is required to load my driver. How can I fix this? It limits the usefulness of my driver.
Posted
by
Post not yet marked as solved
4 Replies
1.8k Views
Hello, I am porting a PCI driver written with IOKit to the new PCIDriverKit framework. I am able to perform DMA with a contiguous buffer allocated inside the dext (with IOBufferMemoryDescriptor::Create). But I would also like to perform DMA to and from a buffer allocated by an application. What I exactly want to do is: Allocate an aligned buffer in the app (with e.g. posix_memalign) Send the pointer to this buffer to the dext In the dext, retrieve the list of pages descriptors to be able to perform DMA without copy into (or from) this buffer. In IOKit, we can use methods such IOMemoryDescriptor::withAddressRange and IODMACommand::gen64IOVMSegments to map and retrieve the scatter gather list but I cannot find any information on how to do this in a dext with the PCIDriverKit framework. Can anybody help me on how to do that?
Posted
by
Post marked as solved
4 Replies
1.7k Views
Hi, I am trying to run an example driver project from https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app?language=objc The project compiles fine, the driver extension is successfully installed and running, however when the client application tries to communicate with the driver (calls IOConnectCallScalarMethod CppUserClient/main.cpp, line 236), the driver crashes, even though there are no modifications of the example code. Does anybody know how to fix it? The project doesn't use any provisioning profile, all three targets are signed to run locally as described in the link. My system: MacOS 11.5.2 BigSur Apple M1 chip XCode 13.2.1 System Integrity Protection status: disabled. systemextensionsctl developer: Developer mode is on also ran command "sudo nvram boot-args=-arm64e_preview_abi" crash report program CppUserClient output
Posted
by
Post marked as solved
7 Replies
4.3k Views
Xcode version : 14.0 Beta 3 macOS version : 13 Beta 3(22A5295i) Hi, I'm signing the DriverKit in Developer ID Application type profile with Developer ID Application (With Kext) type certificate on Xcode. But status shows error with"Xcode 14 and later requires a DriverKit development profile enabled for IOS and macOS.Visit the developer website to create or download a DriverKit profile" I have downloaded all profiles and Certificates to my Mac and installed all of them, then checked the website. I'm wondering what's different between "Development type" & "Developer ID Application type" profile ? and the reason why "2022-07-22 14:41:54.162815+0800 0x22ee2    Error       0x0                  138    0    kernelmanagerd: Error occurred while handling request "DextLaunch(arguments: Optional(["Driver Extension Server Name": com.asix.dext.usbdevice, "Check In Token": 371, "Driver Extension Server Tag": 4294975444, "CFBundleIdentifier": com.asix.dext.usbdevice, "DriverKit Reslide Shared Cache": 0, "kOSBundleDextUniqueIdentifier": <222f1e51 f5e890f7 b467c2a0 da761dbd 9b14dc5f 1bf56ff6 4eeab6b2 fed9683c>]))": Error Domain=NSPOSIXErrorDomain Code=8 "Exec format error" error code show on when I starting the app. I'll appreciate that someone can give me some idea or suggestions. Thanks a lot.
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
We are developing driver for our USB device. Our approach is to run and test driver on macOS first and then verify on iPadOS 16. In the driver we add custom property -"kUSBSerialNumberString" into default properties: OSDictionary * Driver::devicePropertiesWithSerialNumber() {     kern_return_t ret;     OSDictionary *properties = NULL;     OSDictionary *dictionary = NULL;     OSObjectPtr value;     const IOUSBDeviceDescriptor *deviceDescriptor;     deviceDescriptor = ivars->device->CopyDeviceDescriptor();          ret = CopyProperties(&properties);     value = copyStringAtIndex(deviceDescriptor->iSerialNumber, kIOUSBLanguageIDEnglishUS);     Log("Serial number: %{public}s", ((OSString *)value)->getCStringNoCopy());          dictionary = OSDictionary::withDictionary(properties, 0);     OSSafeReleaseNULL(properties);     if (value) {         OSDictionarySetValue(dictionary, "kUSBSerialNumberString", value);         OSSafeReleaseNULL(value);     }     return  dictionary; } next in kern_return_t IMPL(Driver, Start) we call SetProperties:     ret = SetProperties(devicePropertiesWithSerialNumber());     if(ret != kIOReturnSuccess) {         Log("Start() - Failed to set properties: 0x%08x.", ret);         goto Exit;     } We can read our property on macOS using:     func getDeviceProperty(device: io_object_t, key: String) -> AnyObject? {         IORegistryEntryCreateCFProperty(             device, key as CFString, kCFAllocatorDefault, .zero         )?.takeRetainedValue()     }         if let serialNumber = getDeviceProperty(device: driver, key: "kUSBSerialNumberString") {             print("serialNumber: \(serialNumber)")         } However getDevicePropertyon iPadOS returns nil. We are wondering is any limitation for IORegistry entries(properties) on iPadOS16? Is any way to add custom property to IORegistry? BTW, we added debug method to print all the available properties for IORegistry:     private func debugRegistry(device: io_object_t) {         var dictionary: Unmanaged<CFMutableDictionary>?         IORegistryEntryCreateCFProperties(device, &dictionary, kCFAllocatorDefault, .zero)         if let dictionary = dictionary {             let values = dictionary.takeUnretainedValue()             print(values)         }     } It returns just 1 property for iPadOS: { IOClass = IOUserService; } and much more for macOS including our custom one: { CFBundleIdentifier = "****"; CFBundleIdentifierKernel = "com.apple.kpi.iokit"; IOClass = IOUserService; IOMatchCategory = "***"; IOMatchedPersonality = { CFBundleIdentifier = "****"; CFBundleIdentifierKernel = "com.apple.kpi.iokit"; IOClass = IOUserService; IOMatchCategory = "****"; IOPersonalityPublisher = "****"; IOProviderClass = IOUSBHostInterface; IOResourceMatch = IOKit; IOUserClass = Driver; IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac; IOUserServerName = "*****"; UserClientProperties = { IOClass = IOUserUserClient; IOUserClass = DriverUserClient; }; bConfigurationValue = 1; bInterfaceNumber = 1; bcdDevice = 512; idProduct = XXXXX; idVendor = XXXXX; }; IOPersonalityPublisher = "*****"; IOPowerManagement = { CapabilityFlags = 2; CurrentPowerState = 2; MaxPowerState = 2; }; IOProbeScore = 100000; IOProviderClass = IOUSBHostInterface; IOResourceMatch = IOKit; IOUserClass = Driver; IOUserServerCDHash = 9cfd03b5c1b90da709ffb1455a053c5d7cdf47ac; IOUserServerName = "*****"; UserClientProperties = { IOClass = IOUserUserClient; IOUserClass = DriverUserClient; }; bConfigurationValue = 1; bInterfaceNumber = 1; bcdDevice = 512; idProduct = XXXXX; idVendor = XXXXXX; kUSBSerialNumberString = XXXXXXXXXXX; }
Posted
by
Post not yet marked as solved
4 Replies
1.7k Views
I'm trying to built a USBDriverKit driver on the Mac. The driver loads properly but when my device is inserted the driver is ignored and instead the com.apple.AppleUserHIDDrivers driver is loaded. I do not understand what is causing this. The device both have USB and HID cababilities but I want it to work with USBDriverKit so that the driver can be used on the Ipad as well. How can I get the driver to match properly? Entitlements: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.developer.driverkit</key> <true/> <key>com.apple.developer.driverkit.transport.usb</key> <array> <dict> <key>idVendor</key> <integer>1240</integer> </dict> </array> <key>com.apple.developer.driverkit.userclient-access</key> <true/> <key>com.apple.security.app-sandbox</key> <true/> </dict> </plist> Info.plist: ... <dict> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>IOKitPersonalities</key> <dict> <key>ClickerDriver</key> <dict> <key>IOKitDebug</key> <string>65535</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>IOClass</key> <string>IOUserService</string> <key>IOProviderClass</key> <string>IOUSBHostInterface</string> <key>IOUserClass</key> <string>ClickerDriver</string> <key>IOUserServerName</key> <string>example.Clicker.driver</string> <key>bInterfaceClass</key> <string>3</string> <key>bInterfaceSubClass</key> <string>0</string> <key>bConfigurationValue</key> <string>1</string> <key>bInterfaceNumber</key> <string>0</string> <key>idProduct</key> <integer>63</integer> <key>idVendor</key> <integer>1240</integer> <key>UserClientProperties</key> <dict> <key>IOClass</key> <string>IOUserUserClient</string> <key>IOUserClass</key> <string>ClickerDriverUserClient</string> </dict> </dict> </dict> <key>OSBundleUsageDescription</key> <string>The app interprets monitors key presses. </string> </dict> </plist> Output of ioreg -b -n "Simple HID Device Demo" -r -l is attacheded. ioreg.log
Posted
by
Post not yet marked as solved
4 Replies
2.0k Views
My application installs a system extension. When I try to remove the app from the Applications folder (cmd + backspace) I get an error message: "The operation can’t be completed right now because another operation is in progress, such as moving or copying an item or emptying the Bin." According to systemextensionsctl the extension state is "terminating for uninstall but still running". I can see an error in the console logs: kernelmanagerd Failed to terminate dext com.my.driver-dk, error: Kernel request failed: (os/kern) invalid address (1) sysextd a category delegate declined to terminate extension with identifier: com.my.driver-dk sysextd failed to terminate extension with identifier: com.my.driver-dk: Optional(Error Domain=kernelmanagerd.KMError Code=38 "(null)") Issue occurs with macOS 13 - works fine with macOS 12 and macOS 11 What is the problem here? Have there been any changes in macOS in that regard?
Posted
by
Post not yet marked as solved
2 Replies
904 Views
Apple Docs mentions that driver should be approved(enabled) in Settings app. I wonder is there any API available to check that driver is not enabled? To my mind, App with driver should have a following flow: Run App Check that driver is(not) enabled Display message(alert) and ask to enable driver in Settings. Optionally: provide shortcut to exact Settings page Unfortunately, it's not obvious how to check that driver is enabled.
Posted
by
Post not yet marked as solved
1 Replies
1k Views
The "deployment target" for a DEXT is a number like 19.0 or 21.4. Xcode seems to pick the latest version on the machine you are creating the target on as a default - so if I make a new Driver target on Xcode 14 and Ventura, the Deployment Target for the driver will be 21.4. If I'm targeting macOS 12 (for example), what version of DriverKit should I choose, and where is this documented?
Posted
by
Post not yet marked as solved
1 Replies
822 Views
As i read Driverkit can be used to write the device driver. But, I want to filter a device. can Driverkit be used for filtering a particular device?
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
I'm working on a DriverKit driver. I have it running on macOS, including a very simple client app written in SwiftUI. Everything is working fine there. I've added iPadOS as a destination for the app as demonstrated in the WWDC video on DriverKit for iPadOS. The app builds and runs on my iPad, as expected (after a little work to conditionalize out my use of SystemExtensions.framework for installation on macOS). However, after installing and running the app on an iPad, the driver does not show up in Settings->General, nor in the app-specific settings pane triggered by the inclusion of a settings bundle in the app. I've confirmed that the dext is indeed being included in the app bundle when built for iPadOS (in MyApp.app/SystemExtensions/com.me.MyApp.MyDriver.dext). I also can see in the build log that there's a validation step for the dext, and that seems to be succeeding. I don't know why the app isn't being discovered -- or in any case surfaced to the user -- when the app is installed on the iPad. Has anyone faced this problem and solved it? Are there ways to troubleshoot installation/discovery of an embedded DriverKit extensions on iOS? Unlike on macOS, I don't really see any relevant console messages.
Posted
by
Post marked as solved
2 Replies
716 Views
Hey! I'am trying to write my own driver for usb serial device. I'am trying to subclass from IOUserUSBSerial #include <DriverKit/IOService.iig> #include <USBSerialDriverKit/IOUserUSBSerial.iig> class NewDriver: public IOUserUSBSerial { public:     virtual kern_return_t     Start(IOService * provider) override; }; but get a lot of errors such as   "IOUserUSBSerial::handleRxPacket(unsigned char*&, unsigned int&)", referenced from:       vtable for NewDriver in NewDriver.iig.o   "IOUserUSBSerial::handleInterruptPacket(unsigned char const*, unsigned int)", referenced from:       vtable for NewDriver in NewDriver.iig.o   "IOUserUSBSerial::free()", referenced from:       vtable for NewDriver in NewDriver.iig.o   "IOUserUSBSerial::init()", referenced from:       vtable for NewDriver in NewDriver.iig.o   "IOUserUSBSerial::initWith(IOBufferMemoryDescriptor*)", referenced from:       vtable for NewDriver in NewDriver.iig.o   "IOUserUSBSerial::_Dispatch(IOUserUSBSerial*, IORPC)", referenced from:       NewDriver::Start_Impl(IOService*) in NewDriver-e6d71af2158103084ce0c1eba7c6088d.o       NewDriver::_Dispatch(NewDriver*, IORPC) in NewDriver.iig.o   "vtable for IOUserSerial", referenced from:       IOUserSerial::IOUserSerial() in NewDriver.iig.o   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.   "vtable for IOUserUSBSerial", referenced from:       IOUserUSBSerial::IOUserUSBSerial() in NewDriver.iig.o   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.   "non-virtual thunk to IOUserUSBSerial::free()", referenced from:       vtable for NewDriver in NewDriver.iig.o   "non-virtual thunk to IOUserUSBSerial::init()", referenced from:       vtable for NewDriver in NewDriver.iig.o   "non-virtual thunk to IOUserUSBSerial::initWith(IOBufferMemoryDescriptor*)", referenced from:       vtable for NewDriver in NewDriver.iig.o   "non-virtual thunk to IOUserUSBSerial::handleRxPacket(unsigned char*&, unsigned int&)", referenced from:       vtable for NewDriver in NewDriver.iig.o   "non-virtual thunk to IOUserUSBSerial::handleInterruptPacket(unsigned char const*, unsigned int)", referenced from:       vtable for NewDriver in NewDriver.iig.o ld: symbol(s) not found for architecture x86_64 If I making any implementations of this methods errors staying on. What Im doing wrong? Is there anywhere examples for USBSerialDriverKit? Didn't find anything on github
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
Hi all, I got the entiltlements for the DriverKit PCI (primary match). so I added it to my driver app ID. so, I can show the ~~transport.pci entitlement item on my provision profile. However, macOS system still block the my driver, and log show the " Unsatisfied entitlements: com.apple.developer.driverkit.transport.pci"
Posted
by
Post not yet marked as solved
1 Replies
811 Views
I am trying to sign a DriverKit extension for distribution using a Developer ID provisioning profile, but when I try to import the profile to sign the dext I get the error "Platform: MacOS doesn't match platform DriverKit". We requested the entitlement from Apple a few months ago and according to Apple Support it was approved (though we did not get any email directly from the DriverKit approval process). The App ID we are using appears to have the DriverKit capabilities that we need under "Additional Capabillities". Our process right now is this: Go to Certificates, Identifiers, and Profiles Create a new Provisioning Profile and select Developer ID Distribution Select the correct App ID After creating and downloading the profile, import it into Xcode Receive the error "Platform: MacOS does not match DriverKit" According to https://developer.apple.com/documentation/driverkit/requesting_entitlements_for_driverkit_development#3557213, there should perhaps be a prompt adding DriverKit to the provisioning profile and not just the identifier, but we do not see this. Has anybody else run into a similar issue and resolved it? I see a similar thread at https://developer.apple.com/forums/thread/710713, but that one is eight months old and doesn't appear to have a solution.
Posted
by
Post not yet marked as solved
2 Replies
556 Views
Hi All, Is there a limit on the data size of input and output in IOConnectCallStructMethod? I am working with CommunicatingBetweenADriverKitExtensionAndAClientApp. It seems there a buffer size limit in OversizedDataStruct in the sample code. typedef struct { uint64_t foo; uint64_t bar; uint64_t largeArray[511]; } OversizedDataStruct; If I tested by changing 511 to 0x1E00000(30MB), I got below error. Thread 1: EXC_BAD_ACCESS (code=2, address=0x16f20fff8) I need to get large image data(over 30 MBytes) from driver(dext) to user client application. How can I transfer more than 30MB of data from driver to App with IOConnectCallStructMethod? Or is there any other way without using IOConnectCallStructMethod? Please help.
Posted
by
Post not yet marked as solved
0 Replies
378 Views
We are creating an extension to send custom SCSI commands to a USB-connected mass storage device using a SCSIPeripheralsDriverKit. We specified IOUserSCSIPeripheralDeviceType00 as the IOProviderClass and set the device information in idVendor and idProduct. However, the dext is not being called even when the mass storage device is connected. Please help us understand what is needed to get the dext to work.
Posted
by
Post not yet marked as solved
1 Replies
668 Views
Hello, I am trying to run a sample project from Apple's Developer Documentation that creates and interfaces with a DriverKit Dext. The project can be found here: Creating an Audio Device Driver. I have followed all the steps in the README.md file: downloading the code, enabling automatic signing, building the app, moving it to the Applications folder, and launching it. I then open the app, press "Install Dext", enable it through System Preferences, and receive the message "SoundboardDriver has been activated and is ready to use." However, the audio device does not appear in the MIDI app, there is no mention of it in the IORegistry, and I get the message “Driver extension is not running” when I try to press "Open User Client". Is there another step I need to follow to get the app running? Perhaps it's an entitlement issue? I don't see any error/fault message in the console app relating to the app or driver. I am running MacOS 13.4.1 (22F82) and Xcode 14.3.1 (14E300c). I have tried with and without SIP enabled, but the issue persists. Any help or guidance would be greatly appreciated. Best, Henry
Posted
by