本文整理汇总了C++中IOPCIDevice::getDeviceMemoryCount方法的典型用法代码示例。如果您正苦于以下问题:C++ IOPCIDevice::getDeviceMemoryCount方法的具体用法?C++ IOPCIDevice::getDeviceMemoryCount怎么用?C++ IOPCIDevice::getDeviceMemoryCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOPCIDevice
的用法示例。
在下文中一共展示了IOPCIDevice::getDeviceMemoryCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pmem_iokit_enumerate_pci
kern_return_t pmem_iokit_enumerate_pci(pmem_pci_callback_t callback,
void *ctx) {
kern_return_t error = KERN_FAILURE;
OSObject *obj = nullptr;
OSDictionary *search = nullptr;
OSIterator *iter = nullptr;
IOPCIDevice *dev = nullptr;
IODeviceMemory *mem = nullptr;
IOItemCount mem_count = 0;
int cmp;
search = IOService::serviceMatching("IOPCIDevice");
iter = IOService::getMatchingServices(search);
if (!iter) {
pmem_error("Couldn't find any PCI devices.");
goto bail;
}
while ((obj = iter->getNextObject())) {
cmp = strncmp("IOPCIDevice",
obj->getMetaClass()->getClassName(),
strlen("IOPCIDevice"));
if (cmp != 0) {
// I haven't seen the above return anything other than
// PCI devices, but Apple's documentation is sparse (which
// is a nice word for what it is) and doesn't actually
// say anything about what's guaranteed to be returned.
// I'd just as well rather not chance it.
pmem_warn("Expected IOPCIDevice but got %s - skipping.",
obj->getMetaClass()->getClassName());
continue;
}
dev = (IOPCIDevice *)obj;
mem_count = dev->getDeviceMemoryCount();
pmem_debug("Found PCI device %s", dev->getName());
for (unsigned idx = 0; idx < mem_count; ++idx) {
pmem_debug("Memory segment %d found.", idx);
mem = dev->getDeviceMemoryWithIndex(idx);
pmem_signal_t signal = callback(dev, mem, idx, ctx);
if (signal == pmem_Stop) {
error = KERN_FAILURE;
goto bail;
}
}
}
error = KERN_SUCCESS;
bail:
if (iter) {
iter->release();
}
if (search) {
search->release();
}
return error;
}