IOUSBRootHubDevice.cpp [plain text]
#include <libkern/OSByteOrder.h>
#include <IOKit/usb/IOUSBLog.h>
#include <IOKit/usb/IOUSBRootHubDevice.h>
#include <IOKit/usb/IOUSBHubPolicyMaker.h>
#include <IOKit/usb/IOUSBControllerV3.h>
static class IOUSBController_ExtraCurrentIOLockClass gExtraCurrentIOLockClass;
#define super IOUSBHubDevice
#define self this
#ifndef IOUSBROOTHUBDEVICE_USE_KPRINTF
#define IOUSBROOTHUBDEVICE_USE_KPRINTF 0
#endif
#if IOUSBROOTHUBDEVICE_USE_KPRINTF
#undef USBLog
#undef USBError
void kprintf(const char *format, ...)
__attribute__((format(printf, 1, 2)));
#define USBLog( LEVEL, FORMAT, ARGS... ) if ((LEVEL) <= IOUSBROOTHUBDEVICE_USE_KPRINTF) { kprintf( FORMAT "\n", ## ARGS ) ; }
#define USBError( LEVEL, FORMAT, ARGS... ) { kprintf( FORMAT "\n", ## ARGS ) ; }
#endif
#define SAFE_RELEASE_NULL(object) do { \
if (object) object->release(); \
(object) = NULL; \
} while (0)
#define _IORESOURCESENTRY _expansionData->_IOResourcesEntry
#define _STANDARD_PORT_POWER_IN_SLEEP super::_expansionData->_standardPortSleepCurrent
OSDefineMetaClassAndStructors( IOUSBRootHubDevice, IOUSBHubDevice )
IOUSBRootHubDevice*
IOUSBRootHubDevice::NewRootHubDevice()
{
IOUSBRootHubDevice *me = new IOUSBRootHubDevice;
if (!me)
return NULL;
if (!me->init())
{
me->release();
me = NULL;
}
return me;
}
bool
IOUSBRootHubDevice::init()
{
if (!super::init())
return false;
if (!_expansionData)
{
_expansionData = (ExpansionData *)IOMalloc(sizeof(ExpansionData));
if (!_expansionData)
return false;
bzero(_expansionData, sizeof(ExpansionData));
}
return true;
}
bool
IOUSBRootHubDevice::InitializeCharacteristics()
{
UInt32 characteristics = kIOUSBHubDeviceIsRootHub;
USBLog(5, "%s[%p]::InitializeCharacteristics", getName(), this);
if (GetSpeed() == kUSBDeviceSpeedHigh)
characteristics |= kIOUSBHubDeviceIsOnHighSpeedBus;
SetHubCharacteristics(characteristics);
return true;
}
bool
IOUSBRootHubDevice::start(IOService *provider)
{
mach_timespec_t timeSpec;
bool returnValue = false;
OSString * cardTypeRef = NULL;
USBLog(5, "%s[%p]::start", getName(), this);
cardTypeRef = OSDynamicCast(OSString, provider->getProperty("Card Type"));
if ( cardTypeRef && cardTypeRef->isEqualTo("Built-in") )
{
timeSpec.tv_sec = 5;
timeSpec.tv_nsec = 0;
_IORESOURCESENTRY = waitForService(serviceMatching("IOResources"), &timeSpec);
}
else
{
USBLog(6, "IOUSBRootHubDevice[%p]::start - no 'Card Type' property or is NOT 'Built'-in' ", this);
}
returnValue = super::start(provider);
if ( !returnValue)
{
USBLog(5, "IOUSBRootHubDevice[%p]::start - super returned false", this);
return false;
}
_commandGate = IOUSBDevice::_expansionData->_commandGate;
_commandGate->retain();
USBLog(5, "%s[%p]::start (_commandGate %p)", getName(), this, IOUSBDevice::_expansionData->_commandGate);
return returnValue;
}
void
IOUSBRootHubDevice::stop( IOService *provider )
{
if ( _commandGate )
{
_commandGate->release();
_commandGate = NULL;
}
super::stop(provider);
}
void
IOUSBRootHubDevice::free()
{
USBLog(2, "IOUSBRootHubDevice[%p]::+free", this);
if (_expansionData)
{
IOFree(_expansionData, sizeof(ExpansionData));
_expansionData = NULL;
}
super::free();
USBLog(2, "IOUSBRootHubDevice[%p]::-free", this);
}
IOReturn
IOUSBRootHubDevice::GatedDeviceRequest (OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 )
{
IOUSBRootHubDevice *me = (IOUSBRootHubDevice*)owner;
if (!me)
return kIOReturnNotResponding;
return me->DeviceRequestWorker((IOUSBDevRequest*)arg0, (uintptr_t)arg1, (uintptr_t)arg2, (IOUSBCompletion*)arg3);
}
IOReturn
IOUSBRootHubDevice::DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion)
{
return DeviceRequest(request, 0, 0, completion);
}
IOReturn
IOUSBRootHubDevice::DeviceRequest(IOUSBDevRequest *request, UInt32 noDataTimeout, UInt32 completionTimeout, IOUSBCompletion *completion)
{
if (!IOUSBDevice::_expansionData->_commandGate)
{
USBLog(5, "IOUSBRootHubDevice[%p]::DeviceRequest - but no IOUSBDevice::_expansionData->_commandGate", this);
return kIOReturnNotResponding;
}
if (_myPolicyMaker && (_myPolicyMaker->getPowerState() == kIOUSBHubPowerStateLowPower))
{
USBLog(5, "IOUSBRootHubDevice[%p]::DeviceRequest - doing a device request while in low power mode - should be OK", this);
}
return (IOUSBDevice::_expansionData->_commandGate)->runAction(GatedDeviceRequest, request, (void*)noDataTimeout, (void*)completionTimeout, completion);
}
IOReturn
IOUSBRootHubDevice::DeviceRequestWorker(IOUSBDevRequest *request, UInt32 noDataTimeout, UInt32 completionTimeout, IOUSBCompletion *completion)
{
#pragma unused (noDataTimeout, completionTimeout, completion)
IOReturn err = 0;
UInt16 theRequest;
UInt8 dType, dIndex;
if (!request)
return(kIOReturnBadArgument);
theRequest = (request->bRequest << 8) | request->bmRequestType;
switch (theRequest)
{
case kClearDeviceFeature:
if (request->wIndex == 0)
err = _controller->ClearRootHubFeature(request->wValue);
else
err = kIOReturnBadArgument;
break;
case kGetDescriptor:
dType = request->wValue >> 8;
dIndex = request->wValue & 0x00FF;
switch (dType) {
case kUSBDeviceDesc:
err = _controller->GetRootHubDeviceDescriptor((IOUSBDeviceDescriptor*)request->pData);
request->wLenDone = sizeof(IOUSBDeviceDescriptor);
break;
case kUSBConfDesc:
{
OSData *fullDesc = OSData::withCapacity(1024); UInt16 newLength;
err = _controller->GetRootHubConfDescriptor(fullDesc);
newLength = fullDesc->getLength();
if (newLength < request->wLength)
request->wLength = newLength;
bcopy(fullDesc->getBytesNoCopy(), (char *)request->pData, request->wLength);
request->wLenDone = request->wLength;
fullDesc->free();
break;
}
case kUSBStringDesc:
{
OSData *fullDesc = OSData::withCapacity(1024); UInt16 newLength;
err = _controller->GetRootHubStringDescriptor((request->wValue & 0x00ff), fullDesc);
newLength = fullDesc->getLength();
if (newLength < request->wLength)
request->wLength = newLength;
bcopy(fullDesc->getBytesNoCopy(), (char *)request->pData, request->wLength);
request->wLenDone = request->wLength;
fullDesc->free();
break;
}
default:
err = kIOReturnBadArgument;
}
break;
case kGetDeviceStatus:
if ((request->wValue == 0) && (request->wIndex == 0) && (request->pData != 0))
{
*(UInt16*)(request->pData) = HostToUSBWord(1); request->wLenDone = 2;
}
else
err = kIOReturnBadArgument;
break;
case kSetAddress:
if (request->wIndex == 0)
err = _controller->SetHubAddress(request->wValue);
else
err = kIOReturnBadArgument;
break;
case kSetConfiguration:
if (request->wIndex == 0)
configuration = request->wValue;
else
err = kIOReturnBadArgument;
break;
case kSetDeviceFeature:
if (request->wIndex == 0)
err = _controller->SetRootHubFeature(request->wValue);
else
err = kIOReturnBadArgument;
break;
case kGetConfiguration:
if ((request->wIndex == 0) && (request->pData != 0))
{
*(UInt8*)(request->pData) = configuration;
request->wLenDone = 1;
}
else
err = kIOReturnBadArgument;
break;
case kClearInterfaceFeature:
case kClearEndpointFeature:
case kGetInterface:
case kGetInterfaceStatus:
case kGetEndpointStatus:
case kSetInterfaceFeature:
case kSetEndpointFeature:
case kSetDescriptor:
case kSetInterface:
case kSyncFrame:
err = kIOReturnUnsupported;
break;
case kClearHubFeature:
if (request->wIndex == 0)
err = _controller->ClearRootHubFeature(request->wValue);
else
err = kIOReturnBadArgument;
break;
case kClearPortFeature:
err = _controller->ClearRootHubPortFeature(request->wValue, request->wIndex);
break;
case kGetPortState:
if ((request->wValue == 0) && (request->pData != 0))
err = _controller->GetRootHubPortState((UInt8 *)request->pData, request->wIndex);
else
err = kIOReturnBadArgument;
break;
case kGetHubDescriptor:
if ((request->wValue == ((kUSBHubDescriptorType << 8) + 0)) && (request->pData != 0))
{
err = _controller->GetRootHubDescriptor((IOUSBHubDescriptor *)request->pData);
request->wLenDone = sizeof(IOUSBHubDescriptor);
}
else
err = kIOReturnBadArgument;
break;
case kGetHubStatus:
if ((request->wValue == 0) && (request->wIndex == 0) && (request->pData != 0))
{
err = _controller->GetRootHubStatus((IOUSBHubStatus *)request->pData);
request->wLenDone = sizeof(IOUSBHubStatus);
}
else
err = kIOReturnBadArgument;
break;
case kGetPortStatus:
if ((request->wValue == 0) && (request->pData != 0))
{
err = _controller->GetRootHubPortStatus((IOUSBHubPortStatus *)request->pData, request->wIndex);
request->wLenDone = sizeof(IOUSBHubPortStatus);
}
else
err = kIOReturnBadArgument;
break;
case kSetHubDescriptor:
if (request->pData != 0)
err = _controller->SetRootHubDescriptor((OSData *)request->pData);
else
err = kIOReturnBadArgument;
break;
case kSetHubFeature:
if (request->wIndex == 0)
err = _controller->SetRootHubFeature(request->wValue);
else
err = kIOReturnBadArgument;
break;
case kSetPortFeature:
err = _controller->SetRootHubPortFeature(request->wValue, request->wIndex);
break;
default:
err = kIOReturnBadArgument;
}
return(err);
}
bool
IOUSBRootHubDevice::IsRootHub(void)
{
return true;
}
UInt32
IOUSBRootHubDevice::RequestExtraPower(UInt32 requestedPower)
{
OSNumber * numberObject = NULL;
UInt32 totalExtraCurrent = 0;
UInt32 maxPowerPerPort = 0;
UInt32 extraAllocated = 0;
OSObject * propertyObject = NULL;
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::RequestExtraPower - _expansionData or _IORESOURCESENTRY is NULL", getName(), this);
return 0;
}
IOLockLock(gExtraCurrentIOLockClass.lock);
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::RequestExtraPower - _expansionData or _IORESOURCESENTRY is NULL after locking", getName(), this);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return 0;
}
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleCurrentExtra);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
totalExtraCurrent = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::RequestExtraPower - we have a kAppleCurrentExtra with %d", getName(), this, (uint32_t) totalExtraCurrent);
}
SAFE_RELEASE_NULL(propertyObject);
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleMaxPortCurrent);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
maxPowerPerPort = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::RequestExtraPower - we have a kAppleMaxPortCurrent with %d", getName(), this, (uint32_t) maxPowerPerPort);
}
SAFE_RELEASE_NULL(propertyObject);
USBLog(5, "%s[%p]::RequestExtraPower - requestedPower = %d, available: %d", getName(), this, (uint32_t)requestedPower, (uint32_t) totalExtraCurrent);
if (requestedPower > (maxPowerPerPort-kUSB2MaxPowerPerPort)) {
USBLog(5, "%s[%p]::RequestExtraPower - requestedPower = %d was greater than the maximum per port of %d. Using that value instead", getName(), this, (uint32_t)requestedPower, (uint32_t) (maxPowerPerPort-kUSB2MaxPowerPerPort));
requestedPower = maxPowerPerPort-kUSB2MaxPowerPerPort;
}
if (requestedPower <= totalExtraCurrent)
{
extraAllocated = requestedPower;
totalExtraCurrent -= extraAllocated;
USBLog(5, "%s[%p]::RequestExtraPower - setting kAppleCurrentExtra to %d", getName(), this, (uint32_t) totalExtraCurrent);
(_IORESOURCESENTRY)->setProperty(kAppleCurrentExtra, totalExtraCurrent, 32);
}
USBLog(5, "%s[%p]::RequestExtraPower - extraAllocated = %d", getName(), this, (uint32_t)extraAllocated);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return extraAllocated;
}
void
IOUSBRootHubDevice::ReturnExtraPower(UInt32 returnedPower)
{
OSNumber * numberObject = NULL;
OSObject * propertyObject = NULL;
UInt32 powerAvailable = 0;
USBLog(5, "%s[%p]::ReturnExtraPower - returning = %d", getName(), this, (uint32_t)returnedPower);
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::ReturnExtraPower - _expansionData or _IORESOURCESENTRY is NULL", getName(), this);
return;
}
IOLockLock(gExtraCurrentIOLockClass.lock);
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::ReturnExtraPower - _expansionData or _IORESOURCESENTRY is NULL after locking", getName(), this);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return;
}
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleCurrentExtra);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
powerAvailable = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::ReturnExtraPower - we have a kAppleCurrentExtra with %d", getName(), this, (uint32_t) powerAvailable);
}
SAFE_RELEASE_NULL(propertyObject);
if (returnedPower > 0)
{
powerAvailable += returnedPower;
USBLog(5, "%s[%p]::ReturnExtraPower - setting kAppleCurrentExtra to %d", getName(), this, (uint32_t) powerAvailable);
(_IORESOURCESENTRY)->setProperty(kAppleCurrentExtra, powerAvailable, 32);
}
IOLockUnlock(gExtraCurrentIOLockClass.lock);
}
void
IOUSBRootHubDevice::InitializeExtraPower(UInt32 maxPortCurrent, UInt32 totalExtraCurrent)
{
#pragma unused (maxPortCurrent, totalExtraCurrent)
USBLog(1, "%s[%p]::InitializeExtraPower - Obsolete method called", getName(), this);
}
void
IOUSBRootHubDevice::SetSleepCurrent(UInt32 sleepCurrent)
{
USBLog(5, "%s[%p]::SetSleepCurrent - %d", getName(), this, (uint32_t)sleepCurrent);
super::SetSleepCurrent(sleepCurrent);
}
UInt32
IOUSBRootHubDevice::GetSleepCurrent()
{
return super::GetSleepCurrent();
}
UInt32
IOUSBRootHubDevice::RequestSleepPower(UInt32 requestedPower)
{
OSNumber * numberObject = NULL;
UInt32 totalExtraSleepCurrent = 0;
UInt32 maxSleepCurrentPerPort = 0;
UInt32 extraAllocated = 0; OSObject * propertyObject = NULL;
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::RequestSleepPower - _expansionData or _IORESOURCESENTRY is NULL", getName(), this);
return 0;
}
if (requestedPower == 0)
{
USBLog(5, "%s[%p]::RequestSleepPower - asked for 0, returning 0", getName(), this);
return 0;
}
if ( _STANDARD_PORT_POWER_IN_SLEEP == 0)
{
USBLog(5, "%s[%p]::RequestSleepPower - port does not have any _STANDARD_PORT_POWER_IN_SLEEP, returning 0", getName(), this );
return 0;
}
if ( requestedPower <= _STANDARD_PORT_POWER_IN_SLEEP)
{
USBLog(5, "%s[%p]::RequestSleepPower - requested <= _STANDARD_PORT_POWER_IN_SLEEP, returning %d", getName(), this, (uint32_t)requestedPower );
return requestedPower;
}
IOLockLock(gExtraCurrentIOLockClass.lock);
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::RequestSleepPower - _expansionData or _IORESOURCESENTRY is NULL after locking", getName(), this);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return 0;
}
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleCurrentExtraInSleep);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
totalExtraSleepCurrent = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::RequestSleepPower - we have a kAppleCurrentExtraInSleep with %d", getName(), this, (uint32_t) totalExtraSleepCurrent);
}
SAFE_RELEASE_NULL(propertyObject);
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleMaxPortCurrentInSleep);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
maxSleepCurrentPerPort = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::RequestSleepPower - we have a kAppleMaxPortCurrentInSleep with %d", getName(), this, (uint32_t) maxSleepCurrentPerPort);
}
SAFE_RELEASE_NULL(propertyObject);
USBLog(5, "%s[%p]::RequestSleepPower - extra requestedPower = %d, available: %d", getName(), this, (uint32_t) (requestedPower-_STANDARD_PORT_POWER_IN_SLEEP), (uint32_t) totalExtraSleepCurrent);
if (requestedPower > maxSleepCurrentPerPort) {
USBLog(5, "%s[%p]::RequestSleepPower - requestedPower = %d was greater than the maximum per port of %d. Using that value instead", getName(), this, (uint32_t)requestedPower, (uint32_t) maxSleepCurrentPerPort);
requestedPower = maxSleepCurrentPerPort;
}
if ((requestedPower-_STANDARD_PORT_POWER_IN_SLEEP) <= totalExtraSleepCurrent)
{
extraAllocated = (requestedPower-_STANDARD_PORT_POWER_IN_SLEEP);
totalExtraSleepCurrent -= extraAllocated;
USBLog(5, "%s[%p]::RequestSleepPower - updating kAppleCurrentExtraInSleep to %d", getName(), this, (uint32_t) totalExtraSleepCurrent);
(_IORESOURCESENTRY)->setProperty(kAppleCurrentExtraInSleep, totalExtraSleepCurrent, 32);
}
USBLog(5, "%s[%p]::RequestSleepPower - extraAllocated = %d", getName(), this, (uint32_t)extraAllocated);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return extraAllocated+_STANDARD_PORT_POWER_IN_SLEEP;
}
void
IOUSBRootHubDevice::ReturnSleepPower(UInt32 returnedPower)
{
OSNumber * numberObject = NULL;
OSObject * propertyObject = NULL;
UInt32 powerAvailable = 0;
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::ReturnSleepPower - _expansionData or _IORESOURCESENTRY is NULL", getName(), this);
return;
}
USBLog(5, "%s[%p]::ReturnSleepPower - returning = %d", getName(), this, (uint32_t)returnedPower);
IOLockLock(gExtraCurrentIOLockClass.lock);
if ( (_expansionData == NULL) || ( _IORESOURCESENTRY == NULL ))
{
USBLog(5, "%s[%p]::ReturnSleepPower - _expansionData or _IORESOURCESENTRY is NULL after locking", getName(), this);
IOLockUnlock(gExtraCurrentIOLockClass.lock);
return;
}
propertyObject = (_IORESOURCESENTRY)->copyProperty(kAppleCurrentExtraInSleep);
numberObject = OSDynamicCast(OSNumber, propertyObject);
if (numberObject)
{
powerAvailable = numberObject->unsigned32BitValue();
USBLog(5, "%s[%p]::ReturnSleepPower - we have a kAppleCurrentExtraInSleep with %d", getName(), this, (uint32_t) powerAvailable);
}
SAFE_RELEASE_NULL(propertyObject);
if (returnedPower > _STANDARD_PORT_POWER_IN_SLEEP)
{
powerAvailable += (returnedPower-_STANDARD_PORT_POWER_IN_SLEEP);
USBLog(5, "%s[%p]::ReturnSleepPower - setting kAppleCurrentExtraInSleep to %d", getName(), this, (uint32_t) powerAvailable);
(_IORESOURCESENTRY)->setProperty(kAppleCurrentExtraInSleep, powerAvailable, 32);
}
IOLockUnlock(gExtraCurrentIOLockClass.lock);
}
IOReturn
IOUSBRootHubDevice::GetDeviceInformation(UInt32 *info)
{
OSObject * propertyObject = NULL;
OSString * theString = NULL;
bool isBuiltIn = false;
*info = 0;
*info =(( 1 << kUSBInformationDeviceIsCaptiveBit ) |
( 1 << kUSBInformationDeviceIsInternalBit ) |
( 1 << kUSBInformationDeviceIsConnectedBit ) |
( 1 << kUSBInformationDeviceIsEnabledBit ) |
( 1 << kUSBInformationDeviceIsRootHub )
);
propertyObject = _controller->copyProperty("Card Type");
theString = OSDynamicCast(OSString, propertyObject);
if ( theString)
isBuiltIn = theString->isEqualTo("Built-in");
SAFE_RELEASE_NULL(propertyObject);
if (isBuiltIn)
*info |= (1 << kUSBInformationRootHubisBuiltIn);
USBLog(2, "IOUSBRootHubDevice[%p]::GetDeviceInformation returning 0x%x", this, (uint32_t)*info);
return kIOReturnSuccess;
}
void
IOUSBRootHubDevice::SendExtraPowerMessage(UInt32 type, UInt32 returnedPower)
{
OSIterator * rootHubDeviceiterator = NULL;
OSIterator * iterator = NULL;
OSObject * obj = NULL;
USBLog(5, "IOUSBRootHubDevice[%p]::SendExtraPowerMessage - type: %d, argument: %d", this, (uint32_t)type, (uint32_t) returnedPower);
rootHubDeviceiterator = IOService::getMatchingServices(serviceMatching("IOUSBRootHubDevice"));
if ( rootHubDeviceiterator != NULL )
{
while ( (obj = rootHubDeviceiterator->getNextObject()) )
{
IOService * service = ( IOService * ) obj;
USBLog(7, "%s[%p]::SendExtraPowerMessage - found %s (%p)", getName(), this, service->getName(), service);
iterator = service->getParentEntry(gIOServicePlane)->getChildIterator(gIOServicePlane);
if ( !iterator )
{
USBLog(5, "%s[%p]::SendExtraPowerMessage - could not getChildIterator", getName(), this);
continue;
}
if (iterator)
{
OSObject *next;
while( (next = iterator->getNextObject()) )
{
IOUSBDevice *aDevice = OSDynamicCast(IOUSBDevice, next);
if ( aDevice )
{
if ( type == kUSBPowerRequestWakeRelease )
{
USBLog(5, "%s[%p]::SendExtraPowerMessage - sending kIOUSBMessageReleaseExtraCurrent to %s", getName(), this, aDevice->getName());
aDevice->messageClients(kIOUSBMessageReleaseExtraCurrent, &returnedPower, sizeof(UInt32));
}
else if ( type == kUSBPowerRequestWakeReallocate )
{
USBLog(5, "%s[%p]::SendExtraPowerMessage - sending kIOUSBMessageReallocateExtraCurrent to %s", getName(), this, aDevice->getName());
aDevice->messageClients(kIOUSBMessageReallocateExtraCurrent, NULL, 0);
}
}
}
iterator->release();
}
}
rootHubDeviceiterator->release();
}
else
{
USBLog(5, "%s[%p]::RequestExtraPower - Could not find any IOUSBRootHubDevice's", getName(), this);
}
}
OSMetaClassDefineReservedUsed(IOUSBRootHubDevice, 0);
OSMetaClassDefineReservedUsed(IOUSBRootHubDevice, 1);
OSMetaClassDefineReservedUsed(IOUSBRootHubDevice, 2);
OSMetaClassDefineReservedUsed(IOUSBRootHubDevice, 3);
OSMetaClassDefineReservedUsed(IOUSBRootHubDevice, 4);