本文整理汇总了C++中OSIterator类的典型用法代码示例。如果您正苦于以下问题:C++ OSIterator类的具体用法?C++ OSIterator怎么用?C++ OSIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop
void IOGUIDPartitionScheme::stop(IOService * provider)
{
//
// Clean up after the media objects we published before terminating.
//
IOMedia * partition;
OSIterator * partitionIterator;
// State our assumptions.
assert(_partitions);
// Detach the media objects we previously attached to the device tree.
partitionIterator = OSCollectionIterator::withCollection(_partitions);
if ( partitionIterator )
{
while ( (partition = (IOMedia *) partitionIterator->getNextObject()) )
{
detachMediaObjectFromDeviceTree(partition);
}
partitionIterator->release();
}
super::stop(provider);
}
示例2: buildEntryTable
IOReturn AppleLM8x::publishChildren(IOService *nub)
{
OSIterator *childIterator = NULL;
IORegistryEntry *childEntry = NULL;
IOService *childNub = NULL;
IOReturn status;
childIterator = nub->getChildIterator(gIODTPlane);
if( childIterator != NULL )
{
// Iterate through children and create nubs
while ( ( childEntry = (IORegistryEntry *)( childIterator->getNextObject() ) ) != NULL )
{
// Build Table
status = buildEntryTable(childEntry);
LUNtableElement++;
// Publish child as IOService
childNub = OSDynamicCast(IOService, OSMetaClass::allocClassWithName("IOService"));
childNub->init(childEntry, gIODTPlane);
childNub->attach(this);
childNub->registerService();
// DLOG("AppleLM8x::publishChildren(0x%x) published child %s\n", kLM8xAddr<<1, childEntry->getName());
}
childIterator->release();
}
return kIOReturnSuccess;
}
示例3: OSDynamicCast
IOReturn
IOI2CLM6x::createChildNubs (
IOService* nub
)
{
OSIterator* childIterator;
IORegistryEntry* childEntry;
IOService* childNub;
require( ( childIterator = nub->getChildIterator( gIODTPlane ) ) != NULL, IOI2CLM6x_createChildNubs_getChildIteratorNull );
while ( ( childEntry = ( IORegistryEntry * ) childIterator->getNextObject() ) != NULL )
{
childNub = OSDynamicCast( IOService, OSMetaClass::allocClassWithName( "IOService" ) );
if ( childNub )
{
childNub->init( childEntry, gIODTPlane );
childNub->attach( this );
childNub->registerService();
}
}
IOI2CLM6x_createChildNubs_getChildIteratorNull:
return( kIOReturnSuccess );
}
示例4: DbgLog
IOACPIPlatformDevice * ACPIBacklightPanel::getChildWithBacklightMethods(IOACPIPlatformDevice * GPUdevice)
{
DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
OSIterator * iter = NULL;
OSObject * entry;
iter = GPUdevice->getChildIterator(gIOACPIPlane);
if (iter)
{
while ( true )
{
entry = iter->getNextObject();
if (NULL == entry)
break;
if (entry->metaCast("IOACPIPlatformDevice"))
{
IOACPIPlatformDevice * device = (IOACPIPlatformDevice *) entry;
if (hasBacklightMethods(device))
{
IOLog("ACPIBacklight: Found Backlight Device: %s\n", device->getName());
return device;
}
}
else {
DbgLog("%s: getChildWithBacklightMethods() Cast Error\n", this->getName());
}
} //end while
iter->release();
DbgLog("%s: getChildWithBacklightMethods() iterator end\n", this->getName());
}
return NULL;
}
示例5: processChildren
void IOPMPagingPlexus::processChildren ( void )
{
OSIterator * childIterator;
IOPowerConnection * nextChildNub;
IORegistryEntry * nextChild;
IOService * child;
unsigned int i;
childIterator = getChildIterator(gIOPowerPlane);
if ( childIterator ) {
while ( (nextChild = (IORegistryEntry *)(childIterator->getNextObject())) ) {
if ( (nextChildNub = OSDynamicCast(IOPowerConnection,nextChild)) ) {
child = (IOService *)nextChild->getChildEntry(gIOPowerPlane);
if ( child->pm_vars->theControllingDriver ) {
for ( i = 1; i < child->pm_vars->theNumberOfPowerStates; i++ ) {
child->pm_vars->thePowerStates[i].inputPowerRequirement |= IOPMPagingAvailable;
}
}
if ( child->pm_vars->myCurrentState ) {
nextChildNub->setDesiredDomainState(kIOPlexusPowerStateCount-1);
}
}
}
childIterator->release();
}
}
示例6: 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;
}
示例7: OSDynamicCast
IOReturn IOI2CMaxim1631::publishChildren(IOService *nub)
{
OSIterator *childIterator = NULL;
IORegistryEntry *childEntry = NULL;
IOService *childNub = NULL;
childIterator = nub->getChildIterator(gIODTPlane);
if( childIterator != NULL )
{
// Iterate through children and create nubs
while ( ( childEntry = (IORegistryEntry *)( childIterator->getNextObject() ) ) != NULL )
{
// Publish child as IOService
childNub = OSDynamicCast(IOService, OSMetaClass::allocClassWithName("IOService"));
childNub->init(childEntry, gIODTPlane);
childNub->attach(this);
childNub->registerService();
DLOG("IOI2CMaxim1631::publishChildren(0x%x) published child %s\n", getI2CAddress(), childEntry->getName());
}
childIterator->release();
}
return kIOReturnSuccess;
}
示例8: OSDynamicCast
IOReturn IOI2CDriveBayGPIO::publishChildren(IOService *provider)
{
IOReturn status = kIOReturnSuccess;
OSIterator *iter;
IORegistryEntry *next;
IOService *nub;
if (iter = provider->getChildIterator(gIODTPlane))
{
// Iterate through children and create nubs
while (next = (IORegistryEntry *)(iter->getNextObject()))
{
nub = OSDynamicCast(IOService, OSMetaClass::allocClassWithName("IOI2CService"));
if (nub)
{
nub->init(next, gIODTPlane);
nub->attach(this);
nub->registerService();
// DLOG("[email protected]%lx::publishChildren published child %s\n", getI2CAddress(), next->getName());
}
}
iter->release();
}
return status;
}
示例9: setCPUState
void MacRISC2CPU::haltCPU(void)
{
OSIterator *childIterator;
IORegistryEntry *childEntry, *childDriver;
IOPCIBridge *pciDriver;
OSData *deviceTypeString;
UInt32 i;
setCPUState(kIOCPUStateStopped);
if (bootCPU)
{
// Some systems require special handling of Ultra-ATA at sleep.
// Call UniN to prepare for that, if necessary
uniN->callPlatformFunction ("setupUATAforSleep", false, (void *)0, (void *)0, (void *)0, (void *)0);
// Notify our pci children to save their state
if (!topLevelPCIBridgeCount) {
// First build list of top level bridges - only need to do once as these don't change
if ((childIterator = macRISC2PE->getChildIterator (gIOServicePlane)) != NULL) {
while ((childEntry = (IORegistryEntry *)(childIterator->getNextObject ())) != NULL) {
deviceTypeString = OSDynamicCast( OSData, childEntry->getProperty( "device_type" ));
if (deviceTypeString) {
if (!strcmp((const char *)deviceTypeString->getBytesNoCopy(), "pci")) {
childDriver = childEntry->copyChildEntry(gIOServicePlane);
if (childDriver) {
pciDriver = OSDynamicCast( IOPCIBridge, childDriver );
if (pciDriver)
if (topLevelPCIBridgeCount < kMaxPCIBridges)
// Remember this driver
topLevelPCIBridges[topLevelPCIBridgeCount++] = pciDriver;
else
kprintf ("MacRISC2CPU::haltCPU - warning, more than %d PCI bridges - cannot save/restore them all\n", kMaxPCIBridges);
childDriver->release();
}
}
}
}
childIterator->release();
}
}
for (i = 0; i < topLevelPCIBridgeCount; i++)
if (pciDriver = topLevelPCIBridges[i]) {
// Got the driver - send the message
pciDriver->setDevicePowerState (NULL, 2);
}
}
kprintf("MacRISC2CPU::haltCPU %ld Here!\n", getCPUNumber());
processor_exit(machProcessor);
}
示例10: warn
bool AutoThrottler::setup(OSObject* owner) {
if (setupDone) return true;
workLoop = IOWorkLoop::workLoop();
if (workLoop == 0) return false;
perfTimer = IOTimerEventSource::timerEventSource(owner, (IOTimerEventSource::Action) &perfTimerWrapper);
if (perfTimer == 0) return false;
/* from Superhai (modified by mercurysquad) */
cpu_count = 0; OSDictionary* service;
mach_timespec_t serviceTimeout = { 60, 0 }; // in seconds
totalTimerEvents = 0;
IOService* firstCPU = IOService::waitForService(IOService::serviceMatching("IOCPU"), &serviceTimeout);
if (!firstCPU) {
warn("IOKit CPUs not found. Auto-throttle may not work.\n");
return false;
} else {
// we got first cpu, so the others should also be available by now. get them
service = IOService::serviceMatching("IOCPU");
}
OSIterator* iterator = IOService::getMatchingServices(service);
if (!iterator) {
warn("IOKit CPU iterator couldn't be created. Auto-throttle may not work.\n");
return false;
}
IOCPU * cpu;
while ((cpu = OSDynamicCast(IOCPU, iterator->getNextObject())))
{
/*dbg("Got I/O Kit CPU %d (%u) named %s", cpu_count, (unsigned int)(cpu->getCPUNumber(), cpu->getCPUName()->getCStringNoCopy());
*/
mach_cpu[cpu_count] = cpu->getMachProcessor();
if (cpu_count++ > max_cpus) break;
}
selfHost = host_priv_self();
if (workLoop->addEventSource(perfTimer) != kIOReturnSuccess) return false;
currentPState = NumberOfPStates - 1;
perfTimer->setTimeoutMS(throttleQuantum * (1 + currentPState));
clock_get_uptime(&lastTime);
if (!targetCPULoad) targetCPULoad = defaultTargetLoad; // % x10
sysctl_register_oid(&sysctl__kern_cputhrottle_targetload);
sysctl_register_oid(&sysctl__kern_cputhrottle_auto);
setupDone = true;
return true;
}
示例11: num_kids
int num_kids(IOService *provider)
{
int total = 1;
//total++;
OSIterator *kids;
const char* poo = provider->getName();
IOLog("name: %s \n", poo);
if (kids = provider->getChildIterator(gIOServicePlane)) {
IOService *nextkid;
while (nextkid = (IOService*)kids->getNextObject()) {
total += num_kids(nextkid);
}
kids->release();
}
return total;
}
示例12: _terminateDrivers
static IOReturn _terminateDrivers(OSDictionary * matching)
{
OSDictionary * dict;
OSIterator * iter;
IOService * service;
IOReturn ret;
if ( !matching )
return kIOReturnBadArgument;
ret = kIOReturnSuccess;
dict = 0;
iter = IORegistryIterator::iterateOver(gIOServicePlane,
kIORegistryIterateRecursively);
if ( !iter )
return kIOReturnNoMemory;
UniqueProperties( matching );
// terminate instances.
do {
iter->reset();
while( (service = (IOService *)iter->getNextObject()) ) {
dict = service->getPropertyTable();
if ( !dict )
continue;
/* Terminate only for personalities that match the matching dictionary.
* This comparison must be done with only the keys in the
* "matching" dict to enable general matching.
*/
if ( !dict->isEqualTo(matching, matching) )
continue;
if ( !service->terminate(kIOServiceRequired|kIOServiceSynchronous) ) {
ret = kIOReturnUnsupported;
break;
}
}
} while( !service && !iter->isValid());
iter->release();
return ret;
}
示例13: isStartUp
bool AppleACPIBatteryDevice::isStartUp()
{
OSDictionary * matching = IOService::serviceMatching("AppleBacklightDisplay");
OSIterator * iter = NULL;
IOService * service = NULL;
if (matching)
{
iter = IOService::getMatchingServices(matching);
matching->release();
}
if (iter)
{
service = OSDynamicCast(IOService, iter->getNextObject());
iter->release();
}
return (service != NULL);
}
示例14: setAggressiveness
IOReturn IOPMPagingPlexus::setAggressiveness ( unsigned long type, unsigned long )
{
OSDictionary * dict;
OSIterator * iter;
OSObject * next;
IOService * candidate = 0;
IOService * pagingProvider;
if( type != kPMMinutesToSleep)
return IOPMNoErr;
IOLockLock(ourLock);
if ( systemBooting ) {
systemBooting = false;
IOLockUnlock(ourLock);
dict = IOBSDNameMatching(rootdevice);
if ( dict ) {
iter = getMatchingServices(dict);
if ( iter ) {
while ( (next = iter->getNextObject()) ) {
if ( (candidate = OSDynamicCast(IOService,next)) ) {
break;
}
}
iter->release();
}
}
if ( candidate ) {
pagingProvider = findProvider(candidate);
if ( pagingProvider ) {
processSiblings(pagingProvider);
pagingProvider->addPowerChild(this);
getPMRootDomain()->removePowerChild(((IOPowerConnection *)getParentEntry(gIOPowerPlane)));
processChildren();
}
}
}
else {
IOLockUnlock(ourLock);
}
return IOPMNoErr;
}
示例15: getBatteryDevice
static IOService * getBatteryDevice()
{
OSDictionary * matching = IOService::serviceMatching("IOPMPowerSource");
OSIterator * iter = NULL;
IOService * bat = NULL;
if (matching)
{
iter = IOService::getMatchingServices(matching);
matching->release();
}
if (iter)
{
bat = OSDynamicCast(IOService, iter->getNextObject());
iter->release();
}
return bat;
}