gpt4 book ai didi

macos - 以编程方式 "unplug and replug"在 OS X 中加载新驱动程序的 USB 设备?

转载 作者:行者123 更新时间:2023-12-04 04:35:34 26 4
gpt4 key购买 nike

我正在 OS X 中开发一个安装程序,为 USB 设备安装 IOKit 驱动程序,我试图让它在最后不需要重新启动。安装程序正确安装驱动程序并重建kext缓存,运行后,如果我拔下并重新插入USB设备,它会正确加载新驱动程序并且一切正常。

但是,我不想要求用户物理拔下设备以便加载新驱动程序。必须有一种方法让 OS X 以编程方式加载新驱动程序 - 实际上模拟设备被拔出并再次插入,或类似的东西。我该怎么做呢?到目前为止,谷歌搜索的时间没有任何结果,所以任何帮助将不胜感激!

最佳答案

IOUSBDeviceInterface187::USBDeviceReEnumerate() 会做你想做的。唯一的问题是找到所有感兴趣的设备并使用 IOServiceGetMatchingServices() 手动调用它们。 .

/*!
@function USBDeviceReEnumerate
@abstract Tells the IOUSBFamily to reenumerate the device.
@discussion This function will send a terminate message to all clients of the IOUSBDevice (such as
IOUSBInterfaces and their drivers, as well as the current User Client), emulating an unplug
of the device. The IOUSBFamily will then enumerate the device as if it had just
been plugged in. This call should be used by clients wishing to take advantage
of the Device Firmware Update Class specification. The device must be open to use this function.
@availability This function is only available with IOUSBDeviceInterface187 and above.
@param self Pointer to the IOUSBDeviceInterface.
@param options A UInt32 reserved for future use. Ignored in current implementation. Set to zero.
@result Returns kIOReturnSuccess if successful, kIOReturnNoDevice if there is no connection to an IOService,
or kIOReturnNotOpen if the device is not open for exclusive access.
*/

IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options);

查看 IOKit/usb/IOUSBLib.h

关于macos - 以编程方式 "unplug and replug"在 OS X 中加载新驱动程序的 USB 设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12786922/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com