使用 IOKit 获取 IODeviceTree 路径
我正在尝试使用 IOKit 框架获取设备的 IODeviceTree 路径。我可以使用以下代码获取设备的 IOService 路径 (IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@B/AppleMCP79AHCI
):
CFMutableDictionaryRef matchingDict = NULL;
matchingDict = IOServiceMatching("AppleMCP79AHCI");
io_service_t sataService;
io_string_t path;
sataService = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
IORegistryEntryGetPath(sataService, kIOServicePlane, path);
NSLog(@"%s", path);
但是,我需要获取IODeviceTree
平面中的设备。在IODeviceTree
平面中,路径类似于IODeviceTree:/PCI0@0/SATA@B
。我尝试简单地将 kIOServicePlane
替换为 kIODeviceTreePlane
但它什么也没返回。我没有使用 IOKit 的经验,所以我很确定我在这里做了一些明显的事情。
谢谢
I'm trying to get the IODeviceTree path of a device using the IOKit framework. I'm able to get the IOService path (IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@B/AppleMCP79AHCI
) of the device using this code:
CFMutableDictionaryRef matchingDict = NULL;
matchingDict = IOServiceMatching("AppleMCP79AHCI");
io_service_t sataService;
io_string_t path;
sataService = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
IORegistryEntryGetPath(sataService, kIOServicePlane, path);
NSLog(@"%s", path);
However, I need to get the path for the device in the IODeviceTree
plane. In the IODeviceTree
plane, the path would be something like IODeviceTree:/PCI0@0/SATA@B
. I tried simply replacing kIOServicePlane
with kIODeviceTreePlane
but it returned nothing. I have no experience with IOKit
, so I'm pretty sure theres something obvious I'm doing here.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弄清楚了,我只是使用了 IODeviceTree 中不存在的类名。
Figured it out, I was just using a class name that didn't exist in the IODeviceTree.