Understand the role of drivers in bridging the gap between software and hardware, ensuring smooth hardware functionality.

Drivers Documentation

Post

Replies

Boosts

Views

Activity

Adjust Latency Timer for the AppleUSBFTDI Driver
How do I adjust the latency timer for the AppleUSBFTDI driver? I am developing an app in Swift using Xcode on a MacBook Pro M1 running Big Sur, for clinical brain-computer interface (BCI) research. The app needs very low-latency streaming from an external USB device. The external device is a headset which connects via Bluetooth to an FT231X chip mounted on a USB-Serial dongle. The FT231X chip reads timestamped EEG data from the headset. The issue is that the AppleUSBFTDI driver is buffering the packets coming in from the headset, which causes jitter in the timestamps. Typically, with proprietary drivers from FTDI, the solution is to reconfigure them to reduce the latency timer to 1ms. The Info.plist is edited to add new key/value pairs. Is there a similar solution for Apple's built-in driver?
1
1
718
Sep ’21
PCI dext: scatter-gather DMA to application buffer
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?
4
0
1.9k
Dec ’21
Launching Network System Extension from LaunchAgent
In another question on this forum (https://developer.apple.com/forums/thread/124775) eskimo stated that launching a system extension from an daemon is not the right approach and that the OSSystemExtensionRequest.activationRequest API should be called from an App. My question is, does this same restriction apply to a LaunchAgent started App? If so, to ensure activation as soon as possible is the only option to use a SMLoginItemSetEnabled helper to start the App on login?
5
0
1k
Mar ’22
is XPC from app to CMIOExtension possible?
I built an app which hosts a CMIOExtension. The app works, and it can activate the extension. The extension loads in e.g. Photo Booth and shows the expected video (a white horizontal line which moves down the picture). I have a couple of questions about this though. The sample Camera Extension is built with a CMIOExtension dictionary with just one entry, CMIOExtensionMachServiceName which is $(TeamIdentifierPrefix)$(PRODUCT_BUNDLE_IDENTIFIER) This Mach service name won't work though. When attempting to activate the extension, sysextd says that the extensions has an invalid mach service name or is not signed, the value must be prefixed with one of the App Groups in the entitlement. So in order to get the sample extension to activate from my app, I have to change its CMIOExtensionMachServiceName to <my team ID>.com.mycompany.my-app-group.<myextensionname> Is this to be expected? The template CMIOExtension generates its own video using a timer. My app is intended to capture video from a source, filter that video, then feed it to the CMIOExtension, somehow. The template creates an app group called "$(TeamIdentifierPrefix)com.example.app-group", which suggests that it might be possible to use XPC to send frames from the app to the extension. However, I've been unable to do so. I've used NSXPCConnection * connection = [[NSXPCConnection alloc] initWithMachServiceName:, using the CMIOExtensionMachServiceName with no options and with the NSXPCConnectionPrivileged option. I've tried NSXPCConnection * connection = [[NSXPCConnection alloc] initWithServiceName: using the extension's bundle identifier. In all cases when I send the first message I get an error in the remote object proxy's handler: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named <whatever name I try> was invalidated: failed at lookup with error 3 - No such process." According to the "Daemons and Services Programming Guide" an XPC service should have a CFBundlePackageType of XPC!, but a CMIOExtension is of type SYSX. It can't be both. Does the CMIOExtension loading apparatus cook up a synthetic name for the XPC service, and if so, what is it? If none, how is one expected to get pixel buffers into the camera extension?
19
0
6.9k
May ’22
CoreMedia I/O Camera Extension Installation Error (Invalid Signature)
Hi! I'm trying to move from CoreMedio I/O DAL Plug-In to CoreMedia I/O camera extensions, announced in macOS 12.3. I created a test extension, placed it inside my app bundle into Contents/Library/SystemExtensions and signed with codesigning certificate. But when I try to install my extension from inside my app, using this code (Swift): func requestActivation() { guard case .idle = status else { fatalError("Invalid state") } print("Requesting activation of extension \"\(extensionIdentifier)\"") let req = OSSystemExtensionRequest.activationRequest(forExtensionWithIdentifier: extensionIdentifier, queue: DispatchQueue.main) req.delegate = self OSSystemExtensionManager.shared.submitRequest(req) status = .requested } I'm getting an error: OSSystemExtensionErrorDomain error 8: Code Signature Invalid which is rather generic. Can anybody tell me what I am doing wrong? Or at least propose some steps to find it out? I'm posting here entitlements and codesign output for my extension and containing application for further information. kdg@admins-Mac-mini SystemExtensions % codesign -d --entitlements - ./com.visicom.VirtualCamera.avextension.systemextension Executable=/Applications/VirtualCamera.app/Contents/Library/SystemExtensions/com.visicom.VirtualCamera.avextension.systemextension/Contents/MacOS/com.visicom.VirtualCamera.avextension [Dict] [Key] com.apple.security.app-sandbox [Value] [Bool] true [Key] com.apple.security.application-groups [Value] [Array] [String] 6SUWV7QQBJ.com.visicom.VirtualCamera kdg@admins-Mac-mini /Applications % codesign -d --entitlements - ./VirtualCamera.app Executable=/Applications/VirtualCamera.app/Contents/MacOS/VirtualCamera [Dict] [Key] com.apple.developer.system-extension.install [Value] [Bool] true [Key] com.apple.security.app-sandbox [Value] [Bool] true [Key] com.apple.security.application-groups [Value] [Array] [String] 6SUWV7QQBJ.com.visicom.VirtualCamera [Key] com.apple.security.files.user-selected.read-only [Value] [Bool] true kdg@admins-Mac-mini SystemExtensions % codesign -dvvv ./com.visicom.VirtualCamera.avextension.systemextension Executable=/Applications/VirtualCamera.app/Contents/Library/SystemExtensions/com.visicom.VirtualCamera.avextension.systemextension/Contents/MacOS/com.visicom.VirtualCamera.avextension Identifier=com.visicom.VirtualCamera.avextension Format=bundle with Mach-O universal (x86_64 arm64) CodeDirectory v=20500 size=1553 flags=0x10700(hard,kill,expires,runtime) hashes=37+7 location=embedded Hash type=sha256 size=32 CandidateCDHash sha256=25bd80657bfd6e0ab95467146c7b532817e9e520 CandidateCDHashFull sha256=25bd80657bfd6e0ab95467146c7b532817e9e5209fd50b0cb7ceef40dcfb40e8 Hash choices=sha256 CMSDigest=25bd80657bfd6e0ab95467146c7b532817e9e5209fd50b0cb7ceef40dcfb40e8 CMSDigestType=2 CDHash=25bd80657bfd6e0ab95467146c7b532817e9e520 Signature size=9006 Authority=Developer ID Application: Visicom Media Inc. (6SUWV7QQBJ) Authority=Developer ID Certification Authority Authority=Apple Root CA Timestamp=7 Jul 2022, 21:49:32 Info.plist entries=23 TeamIdentifier=6SUWV7QQBJ Runtime Version=12.3.0 Sealed Resources version=2 rules=13 files=0 Internal requirements count=1 size=200 kdg@admins-Mac-mini /Applications % codesign -dvvv ./VirtualCamera.app Executable=/Applications/VirtualCamera.app/Contents/MacOS/VirtualCamera Identifier=com.visicom.VirtualCamera Format=app bundle with Mach-O universal (x86_64 arm64) CodeDirectory v=20500 size=1989 flags=0x10700(hard,kill,expires,runtime) hashes=51+7 location=embedded Hash type=sha256 size=32 CandidateCDHash sha256=31e15fbbd436a67a20c5b58c597d8a4796a67720 CandidateCDHashFull sha256=31e15fbbd436a67a20c5b58c597d8a4796a6772020308fb69f4ee80b4e32788b Hash choices=sha256 CMSDigest=31e15fbbd436a67a20c5b58c597d8a4796a6772020308fb69f4ee80b4e32788b CMSDigestType=2 CDHash=31e15fbbd436a67a20c5b58c597d8a4796a67720 Signature size=9006 Authority=Developer ID Application: Visicom Media Inc. (6SUWV7QQBJ) Authority=Developer ID Certification Authority Authority=Apple Root CA Timestamp=7 Jul 2022, 21:58:09 Info.plist entries=20 TeamIdentifier=6SUWV7QQBJ Runtime Version=12.3.0 Sealed Resources version=2 rules=13 files=4 Internal requirements count=1 size=188 Thanks in advance!
7
0
2k
Jul ’22
Can't add custom property into IORegistry on iPadOS 16
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; }
2
4
1.1k
Sep ’22
USBDriverKit driver doesn't match, instead uses standard HID drivers
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
4
0
1.8k
Oct ’22
DriverKit versions and corresponding macOS versions
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?
1
1
1.1k
Nov ’22
ASUS XONAR PCI Audio Card kext signing/distribution
hi, so i have a little bit of work left on the Asus Xonar family of audio devices. thanks to APPUL's samplepciaudiodriver code and their excellent documentation, Evegeny Gavrilov's kxAudio driver for MAC and Takashi Iwai's exceptional documentation of the ALSA API i have something that is ready for testing. the stats look good, but unfortunately i this is my second HDAV1.3 deluxe. the other one is also in the same room consuming all of my devices with powered audio outputs. no matter, i am in the process of acquiring another xonar sound card in this family. which brings me to my question: what is the benefit of getting an apple developer account for 99 dollars a year? will i be able to distribute a beta kext with my signature that will allow people to test the binary? i don't think others could run a self-signed kext built on one machine, on another, correct? so would a developer license allow others to test a binary built on my machine, assuming they're x86? my hope is that the developer program would allow me to test the binaries and solicit input from enthusiast mac pro owners WORLD WIDE. i them hope to create a new program that will give us the wealth mixers/controls this fantastic line is capable of providing.
6
0
2k
Jan ’23
DriverKit driver doesn't appear in Settings when installed with iPad app
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.
3
1
1.2k
Feb ’23
Subclassing from IOUserUSBSerial
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
2
0
795
Mar ’23
IOPSCopyPowerSourcesInfo → kIOPSBatteryHealthKey returning incorrect value
IOPSCopyPowerSourcesInfo → kIOPSBatteryHealthKey returning incorrect value Background: I write software to monitor computer system health. I'm having problems getting battery health information on my new M2 notebook. Given the following Objective-C program: #include <Foundation/NSObjCRuntime.h> #include <IOKit/ps/IOPSKeys.h> #include <IOKit/ps/IOPowerSources.h> #include <assert.h> int main() { CFTypeRef psInfo = IOPSCopyPowerSourcesInfo(); assert(psInfo != NULL); CFArrayRef list = IOPSCopyPowerSourcesList(psInfo); assert(list != NULL); long count = CFArrayGetCount(list); for(long i = 0; i < count; i++) { CFDictionaryRef ps = IOPSGetPowerSourceDescription( psInfo, CFArrayGetValueAtIndex(list, i)); assert(ps != NULL); CFStringRef deviceName = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSNameKey)); assert(deviceName != NULL); CFStringRef serialNumber = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSHardwareSerialNumberKey)); assert(serialNumber != NULL); CFStringRef health = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSBatteryHealthKey)); assert(health != NULL); NSLog(@"\nName=\"%@\"\nSerialNumber=\"%@\"\n" "BatteryHealth=\"%@\"\n", (__bridge NSString*)deviceName, (__bridge NSString*)serialNumber, (__bridge NSString*)health); } CFRelease(list); CFRelease(psInfo); return 0; } and looking at the IOPSKeys.h header, I expect to get one of "Poor", "Fair", or "Good" for the value of kIOPSBatteryHealthKey. https://opensource.apple.com/source/IOKitUser/IOKitUser-1845.81.1/ps.subproj/IOPSKeys.h.auto.html Instead, on my 2022 M2 Macbook Air running 13.2.1 (22D68), I get the following output: Name="InternalBattery-0" SerialNumber="F8Y2422145S10X2A7" BatteryHealth="Check Battery" At the same time, the "System Information app says "Condition: Normal". Am I missing something? This seems to be a bug, right? Should I look into filing a Technical Support Incident?
2
0
969
Mar ’23
Driver(dext) interface maximum data size
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.
2
0
618
May ’23
Is SCSIPeripheralsDriverKit on board?
I've try to develop a dext to send SCSI commands to some storage products, but when I try to implements SCSIPeripheralsDriverKit/IOUserSCSIPeripheralDeviceType00 interface, I... just don't know how to do it, I tried to convert kext way to Driverkit way, but I always block by error warnings. After I google a lots of solutions, I was wondering is this feature working? or Is there any samples or guideline?
0
0
461
Jun ’23