本文整理汇总了C++中OSArray::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArray::getObject方法的具体用法?C++ OSArray::getObject怎么用?C++ OSArray::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSArray
的用法示例。
在下文中一共展示了OSArray::getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kmod_start
volatile int kmod_start(void)
{
libkern_init0();
OSString* one = OSString::withCString("Anal sex");
OSString* two = OSString::withCString("Cunnilingus");
OSArray* sexthings = OSArray::withCapacity(2);
sexthings->setObject(one);
sexthings->setObject(two);
printk("Hello from IOKit!\n");
printk("Put: %p %p\n", one, two);
printk("OSArray: %p\n", sexthings);
printk("Get: %p %p\n", sexthings->getObject(0), sexthings->getObject(1));
OSSerialize* ser = OSSerialize::withCapacity(1024);
sexthings->serialize(ser);
printk("Serialized: %s \n", ser->text());
return 0;
}
示例2: queryACPICurentBrightnessLevel
UInt32 ACPIBacklightPanel::queryACPICurentBrightnessLevel()
{
//DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
if (_backlightHandler)
return _backlightHandler->getBacklightLevel();
UInt32 level = minAC;
const char* method = _extended ? "XBQC" : "_BQC";
if (kIOReturnSuccess == backLightDevice->evaluateInteger(method, &level))
{
//DbgLog("%s: queryACPICurentBrightnessLevel %s = %d\n", this->getName(), method, level);
OSBoolean * useIdx = OSDynamicCast(OSBoolean, getProperty("BQC use index"));
if (useIdx && useIdx->isTrue())
{
OSArray * levels = queryACPISupportedBrightnessLevels();
if (levels)
{
OSNumber *num = OSDynamicCast(OSNumber, levels->getObject(level));
if (num)
level = num->unsigned32BitValue();
levels->release();
}
}
//DbgLog("%s: queryACPICurentBrightnessLevel returning %d\n", this->getName(), level);
}
else {
IOLog("ACPIBacklight: Error in queryACPICurentBrightnessLevel %s\n", method);
}
//some laptops didn't return anything on startup, return then max value (first entry in _BCL):
return level;
}
示例3: withCString
OSString * ACPIBacklightPanel::getACPIPath(IOACPIPlatformDevice * acpiDevice)
{
OSString * separator = OSString::withCStringNoCopy(".");
OSArray * array = OSArray::withCapacity(10);
char devicePath[512];
bzero(devicePath, sizeof(devicePath));
IOACPIPlatformDevice * parent = acpiDevice;
IORegistryIterator * iter = IORegistryIterator::iterateOver(acpiDevice, gIOACPIPlane, kIORegistryIterateParents | kIORegistryIterateRecursively);
if (iter)
{
do {
array->setObject(parent->copyName(gIOACPIPlane));
array->setObject(separator);
parent = OSDynamicCast(IOACPIPlatformDevice, iter->getNextObject());
} while (parent);
iter->release();
int offset = 0;
OSString * str = OSDynamicCast(OSString, array->getLastObject());
for (int i = array->getCount()-2; ((i>=0) || ((offset + str->getLength()) > sizeof(devicePath))) ; i--)
{
str = OSDynamicCast(OSString, array->getObject(i));
strncpy(devicePath + offset, str->getCStringNoCopy(), str->getLength());
offset += str->getLength();
}
}
return OSString::withCString(devicePath);
}
示例4: CompareDeviceUsagePairs
bool CompareDeviceUsagePairs( IOService * owner, OSDictionary * matching, SInt32 * score, SInt32 increment)
{
// We return success if we match the key in the dictionary with the key in
// the property table, or if the prop isn't present
//
OSArray * pairArray;
OSDictionary * pair;
bool matches = true;
int count;
pairArray = OSDynamicCast(OSArray, matching->getObject( kIOHIDDeviceUsagePairsKey ));
if (pairArray)
{
count = pairArray->getCount();
for (int i=0; i<count; i++)
{
if ( !(pair = OSDynamicCast(OSDictionary,pairArray->getObject(i))) )
continue;
if ( !(matches = CompareDeviceUsage(owner, pair, score, increment)) )
continue;
break;
}
}
return matches;
}
示例5: CompareNumberPropertyArray
bool CompareNumberPropertyArray( IOService * owner, OSDictionary * matching, const char * arrayName, const char * key, SInt32 * score, SInt32 increment)
{
OSNumber *registryProperty = (OSNumber *)owner->copyProperty(key);
OSArray *propertyArray = (OSArray *)matching->getObject(arrayName);
CONVERT_TO_STACK_RETAIN(registryProperty);
// If the property in the matching doesn't exist return true
if ( OSDynamicCast(OSArray, propertyArray) )
{
if ( OSDynamicCast(OSNumber, registryProperty ) )
{
OSNumber *propertyFromArray;
int i = 0;
for ( i = 0; i < propertyArray->getCount(); i ++ )
{
propertyFromArray = OSDynamicCast(OSNumber, propertyArray->getObject(i));
if ( propertyFromArray && propertyFromArray->isEqualTo(registryProperty) )
{
if ( score )
*score += increment;
return true;
}
}
}
}
else
return true;
return false;
}
示例6: LoadConfiguration
void SuperIO::LoadConfiguration(IOService* provider) {
m_Service = provider;
OSBoolean* fanControl = OSDynamicCast(OSBoolean, provider->getProperty("Enable Fan Control"));
m_FanControl = fanControl->getValue();
OSBoolean* alternateRegisters = OSDynamicCast(OSBoolean, provider->getProperty("Register number alternative variant"));
m_AlternateRegisters = alternateRegisters->getValue();
OSArray* fanIDs = OSDynamicCast(OSArray, provider->getProperty("Fan Names"));
if (fanIDs) fanIDs = OSArray::withArray(fanIDs);
if (fanIDs) {
UInt32 count = fanIDs->getCount();
if(count > 5)
count = 5;
for (UInt32 i = 0; i < count; i++) {
OSString* name = OSDynamicCast(OSString, fanIDs->getObject(i));
FanName[i] = name->getCStringNoCopy();
}
fanIDs->release();
}
}
示例7: handleStart
//====================================================================================================
// IOHIDEventOverrideDriver::dispatchKeyboardEvent
//====================================================================================================
bool IOHIDEventOverrideDriver::handleStart( IOService * provider )
{
OSArray * maps = NULL;
if ( !super::handleStart(provider) )
return false;
maps = OSDynamicCast(OSArray, getProperty("ButtonMaps"));
if ( maps ) {
int index;
for ( index=0; index<maps->getCount(); index++ ) {
OSDictionary * map;
OSNumber * number;
uint32_t button;
uint32_t usagePage;
uint32_t usage;
uint32_t eventType;
map = OSDynamicCast(OSDictionary, maps->getObject(index));
if ( !map )
continue;
number = OSDynamicCast(OSNumber, map->getObject("ButtonNumber"));
if ( !number )
continue;
button = number->unsigned32BitValue();
if ( !button || button>32 )
continue;
number = OSDynamicCast(OSNumber, map->getObject("EventType"));
if ( !number )
continue;
eventType = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, map->getObject("UsagePage"));
if ( !number )
continue;
usagePage = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, map->getObject("Usage"));
if ( !number )
continue;
usage = number->unsigned32BitValue();
_buttonMap[button-1].eventType = eventType;
_buttonMap[button-1].usagePage = usagePage;
_buttonMap[button-1].usage = usage;
}
}
return true;
}
示例8: loadPStateOverride
void loadPStateOverride(OSArray* dict) {
//return;
// autodetect
/* Here we load the override pstate table from the given array */
NumberOfPStates = dict->getCount();
for (int i = 0; i < NumberOfPStates; i++) {
OSArray* onePstate = (OSArray*) dict->getObject(i);
PStates[i].AcpiFreq = ((OSNumber*) onePstate->getObject(0))->unsigned16BitValue();
PStates[i].Frequency = MHz_to_FID(PStates[i].AcpiFreq); // this accounts for N/2 automatically
PStates[i].OriginalVoltage = mV_to_VID(((OSNumber*) onePstate->getObject(1))->unsigned16BitValue());
PStates[i].Voltage = PStates[i].OriginalVoltage;
PStates[i].TimesChosen = 0;
info("P-State %d: %d MHz Fr: %d at %d mV\n", i, PStates[i].AcpiFreq, PStates[i].Frequency, VID_to_mV(PStates[i].OriginalVoltage));
}
info("Loaded %d PStates from Info.plist\n", NumberOfPStates);
}
示例9: setupIndexedLevels
UInt32 ACPIBacklightPanel::setupIndexedLevels()
{
DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
OSNumber * num;
OSArray * levels = queryACPISupportedBrightnessLevels();
if (levels)
{
BCLlevelsCount = levels->getCount();
if (BCLlevelsCount < 3)
return 0;
//verify the types of objects is good once for all
for (int i = 0; i< BCLlevelsCount; i++) {
if (!OSDynamicCast(OSNumber, levels->getObject(i)))
return 0;
}
//TODO : manage the case when the list has no order! Linux do that
//test the order of the list
UInt32 min, max;
num = OSDynamicCast(OSNumber, levels->getObject(2));
min = num->unsigned32BitValue();
num = OSDynamicCast(OSNumber, levels->getObject(BCLlevelsCount-1));
max = num->unsigned32BitValue();
if (max < min) //list is reverted !
{
BCLlevels = new UInt32[BCLlevelsCount];
for (int i = 0; i< BCLlevelsCount; i++) {
num = OSDynamicCast(OSNumber, levels->getObject(BCLlevelsCount -1 -i));
BCLlevels[i] = num->unsigned32BitValue();
}
}
else
{
BCLlevelsCount = BCLlevelsCount -2;
BCLlevels = new UInt32[BCLlevelsCount];
for (int i = 0; i< BCLlevelsCount; i++) {
num = OSDynamicCast(OSNumber, levels->getObject(i+2));
BCLlevels[i] = num->unsigned32BitValue();
}
}
//2 first items are min on ac and max on bat
num = OSDynamicCast(OSNumber, levels->getObject(0));
minAC = findIndexForLevel(num->unsigned32BitValue());
setDebugProperty("BCL: Min on AC", num);
num = OSDynamicCast(OSNumber, levels->getObject(1));
maxBat = findIndexForLevel(num->unsigned32BitValue());
setDebugProperty("BCL: Max on Bat", num);
setDebugProperty("Brightness Control Levels", levels);
levels->release();
return BCLlevelsCount-1;
}
return 0;
}
示例10: IORWLockWrite
/*********************************************************************
* Remove drivers from the catalog which match the
* properties in the matching dictionary.
*********************************************************************/
bool
IOCatalogue::removeDrivers(
OSDictionary * matching,
bool doNubMatching)
{
OSOrderedSet * set;
OSCollectionIterator * iter;
OSDictionary * dict;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
if ( !matching )
return false;
set = OSOrderedSet::withCapacity(10,
IOServiceOrdering,
(void *)gIOProbeScoreKey);
if ( !set )
return false;
iter = OSCollectionIterator::withCollection(personalities);
if (!iter)
{
set->release();
return (false);
}
IORWLockWrite(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* This comparison must be done with only the keys in the
* "matching" dict to enable general searches.
*/
if ( dict->isEqualTo(matching, matching) ) {
set->setObject(dict);
array->removeObject(idx);
idx--;
}
}
// Start device matching.
if ( doNubMatching && (set->getCount() > 0) ) {
IOService::catalogNewDrivers(set);
generation++;
}
}
IORWLockUnlock(lock);
set->release();
iter->release();
return true;
}
示例11: CompareDeviceUsage
bool CompareDeviceUsage( IOService * owner, OSDictionary * matching, SInt32 * score, SInt32 increment)
{
// We return success if we match the key in the dictionary with the key in
// the property table, or if the prop isn't present
//
OSObject * usage;
OSObject * usagePage;
OSArray * functions;
OSDictionary * pair;
bool matches = true;
int count;
usage = matching->getObject( kIOHIDDeviceUsageKey );
usagePage = matching->getObject( kIOHIDDeviceUsagePageKey );
functions = OSDynamicCast(OSArray, owner->copyProperty( kIOHIDDeviceUsagePairsKey ));
if ( functions )
{
if ( usagePage || usage )
{
count = functions->getCount();
for (int i=0; i<count; i++)
{
if ( !(pair = (OSDictionary *)functions->getObject(i)) )
continue;
if ( !usagePage ||
!(matches = usagePage->isEqualTo(pair->getObject(kIOHIDDeviceUsagePageKey))) )
continue;
if ( score && !usage )
{
*score += increment / 2;
break;
}
if ( !usage ||
!(matches = usage->isEqualTo(pair->getObject(kIOHIDDeviceUsageKey))) )
continue;
if ( score )
*score += increment;
break;
}
}
functions->release();
} else {
matches = false;
}
return matches;
}
示例12: OSDynamicCast
void AppleACPIPS2Nub::mergeInterruptProperties(IOService *pnpProvider, long)
{
/* Make sure we're called from within start() where these i-vars are valid */
if(m_interruptControllers == NULL || m_interruptSpecifiers == NULL)
return;
/* Get the interrupt controllers/specifiers arrays from the provider, and make sure they
* exist and contain at least one entry. We assume they contain exactly one entry.
*/
OSArray *controllers = OSDynamicCast(OSArray,pnpProvider->getProperty(gIOInterruptControllersKey));
OSArray *specifiers = OSDynamicCast(OSArray,pnpProvider->getProperty(gIOInterruptSpecifiersKey));
if(controllers == NULL || specifiers == NULL)
return;
if(controllers->getCount() == 0 || specifiers->getCount() == 0)
return;
/* Append the first object of each array into our own respective array */
m_interruptControllers->setObject(controllers->getObject(0));
m_interruptSpecifiers->setObject(specifiers->getObject(0));
}
示例13: RegisterServiceInTree
bool IOPlatformExpert::RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider)
{
IOService * aService;
bool registered = false;
OSArray * children;
unsigned int numChildren;
OSDictionary * child;
// make sure someone is not already registered here
if ( NULL == theTreeNode->getObject ("service") ) {
if ( theTreeNode->setObject ("service", OSDynamicCast ( OSObject, theService)) ) {
// 1. CHILDREN ------------------
// we registered the node in the tree...now if the node has children
// registered we must tell this service to add them.
if ( NULL != (children = (OSArray *) theTreeNode->getObject ("children")) ) {
numChildren = children->getCount ();
for ( unsigned int i = 0; i < numChildren; i++ ) {
if ( NULL != (child = (OSDictionary *) children->getObject (i)) ) {
if ( NULL != (aService = (IOService *) child->getObject ("service")) )
theService->addPowerChild (aService);
}
}
}
// 2. PARENT --------------------
// also we must notify the parent of this node (if a registered service
// exists there) of a new child.
if ( theTreeParentNode ) {
if ( NULL != (aService = (IOService *) theTreeParentNode->getObject ("service")) )
if (aService != theProvider)
aService->addPowerChild (theService);
}
registered = true;
}
}
return registered;
}
示例14: OSDynamicCast
// This routine will look to see if the OSArray contains any matching keys. The OSArray has to contain a list of OSNumbers.
bool
IOUSBNub::USBComparePropertyInArray( OSDictionary *matching, const char * arrayName, const char * key, UInt32 * theProductIDThatMatched )
{
// We return success iff we match any entry in the array with the key
OSArray * propertyIDArray = NULL;
OSNumber * registryProperty = NULL;
OSNumber * propertyFromArrayItem = NULL;
bool matches = false;
unsigned int index;
*theProductIDThatMatched = 0;
// Get our nub's value for the key
registryProperty = OSDynamicCast(OSNumber, getProperty(key));
propertyIDArray = OSDynamicCast(OSArray, matching->getObject(arrayName));
// Iterate over the array looking for the entries
if (propertyIDArray && registryProperty)
{
USBLog(7, "%s[%p]::USBComparePropertyInArray - found array with capacity of %d", getName(), this, propertyIDArray->getCount());
for (index = 0; index < propertyIDArray->getCount(); index++)
{
propertyFromArrayItem = OSDynamicCast(OSNumber, propertyIDArray->getObject(index));
if (propertyFromArrayItem)
{
// See if this item has the same value as the one in our registry for this key
matches = propertyFromArrayItem->isEqualTo( registryProperty);
if (matches)
{
*theProductIDThatMatched = propertyFromArrayItem->unsigned32BitValue();
USBLog(7, "%s[%p]::USBComparePropertyInArray - item %d matched: id = 0x%x", getName(), this, index, (uint32_t) *theProductIDThatMatched);
break;
}
else
{
USBLog(7, "%s[%p]::USBComparePropertyInArray - item %d did not match", getName(), this, index);
}
}
}
}
return matches;
}
示例15: IORWLockRead
/*********************************************************************
* Is personality already in the catalog?
*********************************************************************/
OSOrderedSet *
IOCatalogue::findDrivers(
OSDictionary * matching,
SInt32 * generationCount)
{
OSCollectionIterator * iter;
OSDictionary * dict;
OSOrderedSet * set;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
OSKext::uniquePersonalityProperties(matching);
set = OSOrderedSet::withCapacity( 1, IOServiceOrdering,
(void *)gIOProbeScoreKey );
if (!set) return (0);
iter = OSCollectionIterator::withCollection(personalities);
if (!iter)
{
set->release();
return (0);
}
IORWLockRead(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* This comparison must be done with only the keys in the
* "matching" dict to enable general searches.
*/
if ( dict->isEqualTo(matching, matching) )
set->setObject(dict);
}
}
*generationCount = getGenerationCount();
IORWLockUnlock(lock);
iter->release();
return set;
}