コード例 #1
0
ファイル: IOUSBNub.cpp プロジェクト: aosm/IOUSBFamily
bool
IOUSBNub::USBComparePropertyWithMask( OSDictionary *matching, const char *key, const char * maskKey )
{
    // This routine will return success if the "key" in the dictionary  matches the key in the property table
    // while applying the "mask" value to both
    // First, check to see if we have both keys
    //
    OSNumber *	registryProperty = NULL;
    OSNumber *	dictionaryProperty = NULL;
    OSNumber *	dictionaryMask = NULL;
    
    registryProperty = OSDynamicCast(OSNumber,  getProperty(key));
    dictionaryProperty = OSDynamicCast(OSNumber, matching->getObject(key));
    dictionaryMask = OSDynamicCast(OSNumber, matching->getObject(maskKey));
    
    if ( registryProperty && dictionaryProperty && dictionaryMask )
    {
		// If all our values are OSNumbers, then get their actual value and do the masking
		// to see if they are equal
		//
		UInt32  registryValue = registryProperty->unsigned32BitValue();
		UInt32  dictionaryValue = dictionaryProperty->unsigned32BitValue();
		UInt32  mask = dictionaryMask->unsigned32BitValue();
		
		if ( (registryValue & mask) == (dictionaryValue & mask) )
		{
			return true;
		}
    }
    
    return false;
}
コード例 #2
0
bool CompareNumberPropertyMask( IOService *owner, OSDictionary *matching, const char *key, const char *maskKey, SInt32 *score, SInt32 increment)
{
	OSNumber *	registryProperty;
    OSNumber *	dictionaryProperty;
    OSNumber *	valueMask;
    
    registryProperty = OSDynamicCast(OSNumber,  owner->getProperty(key));
    dictionaryProperty = OSDynamicCast(OSNumber, matching->getObject(key));
    valueMask = OSDynamicCast(OSNumber, matching->getObject(maskKey));
    
    // If the dicitonary or value mask doesn't exist then return true
    if ( dictionaryProperty && valueMask )
    {
    	if ( registryProperty )
        {
            // If all our values are OSNumbers, then get their actual value and do the masking
            // to see if they are equal
            //
            UInt32  registryValue = registryProperty->unsigned32BitValue();
            UInt32  dictionaryValue = dictionaryProperty->unsigned32BitValue();
            UInt32  mask = valueMask->unsigned32BitValue();
            
            if ( (registryValue & mask) == (dictionaryValue & mask) )
            {
                if ( score )
                    *score += increment;
                return true;
            }
        }
    }
    else
        return true;
    
    return false;
}
コード例 #3
0
// Read the settings from the registry
void Xbox360Peripheral::readSettings(void)
{
    OSBoolean *value = NULL;
    OSNumber *number = NULL;
    OSDictionary *dataDictionary = OSDynamicCast(OSDictionary, getProperty(kDriverSettingKey));
    
    if (dataDictionary == NULL) return;
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftX"));
    if (value != NULL) invertLeftX = value->getValue();
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftY"));
    if (value != NULL) invertLeftY = value->getValue();
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightX"));
    if (value != NULL) invertRightX = value->getValue();
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightY"));
    if (value != NULL) invertRightY = value->getValue();
    number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneLeft"));
    if (number != NULL) deadzoneLeft = number->unsigned32BitValue();
    number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneRight"));
    if (number != NULL) deadzoneRight = number->unsigned32BitValue();
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeLeft"));
    if (value != NULL) relativeLeft = value->getValue();
    value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeRight"));
    if (value != NULL) relativeRight=value->getValue();
    
#if 0
    IOLog("Xbox360Peripheral preferences loaded:\n  invertLeft X: %s, Y: %s\n   invertRight X: %s, Y:%s\n  deadzone Left: %d, Right: %d\n\n",
            invertLeftX?"True":"False",invertLeftY?"True":"False",
            invertRightX?"True":"False",invertRightY?"True":"False",
            deadzoneLeft,deadzoneRight);
#endif
}
コード例 #4
0
//====================================================================================================
// 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;
}
コード例 #5
0
IOReturn ApplePS2SynapticsTouchPad::setParamProperties( OSDictionary * dict )
{
    OSNumber * clicking = OSDynamicCast( OSNumber, dict->getObject("Clicking") );

    if ( clicking )
    {    
        UInt8  newModeByteValue = clicking->unsigned32BitValue() & 0x1 ?
                                  kModeByteValueGesturesEnabled :
                                  kModeByteValueGesturesDisabled;

        if (_touchPadModeByte != newModeByteValue)
        {
            _touchPadModeByte = newModeByteValue;

            //
            // Write the TouchPad mode byte value.
            //

            setTouchPadModeByte(_touchPadModeByte, true);

            //
            // Advertise the current state of the tapping feature.
            //

            setProperty("Clicking", clicking);
        }
    }

    return super::setParamProperties(dict);
}
コード例 #6
0
IOReturn IOAudioLevelControl::validateValue(OSObject *newValue)
{
    IOReturn result = kIOReturnBadArgument;
    OSNumber *number;
    
    number = OSDynamicCast(OSNumber, newValue);
	
	DbgLog("+ IOAudioLevelControl::validateValue[%p] (%p)\n", this, newValue);
   
    if (number) {
        SInt32 newIntValue;
        
        newIntValue = (SInt32)number->unsigned32BitValue();

		DbgLog("  IOAudioLevelControl::validateValue[%p] - newIntValue = %ld, min = %ld, max = %ld\n", this, (long int)newIntValue, (long int)minValue, (long int)maxValue);
        
        if ((newIntValue >= minValue) && (newIntValue <= maxValue)) {
            result = kIOReturnSuccess;
        } else {
            result = kIOReturnError;
        }
    }
    
	DbgLog("- IOAudioLevelControl::validateValue[%p] (%p) returns 0x%lX\n", this, newValue, (long unsigned int)result );
    return result;
}
コード例 #7
0
// GetPlistValue
UInt32 
VoodooPState::getPlistValue(OSDictionary * dictionary,
						   const char * symbol)
{
	OSObject * object = 0;
	OSBoolean * boolean = false;
	OSNumber * number = 0;
	OSString * string = 0;
	object = dictionary->getObject(symbol);
	if (object && (OSTypeIDInst(object) == OSTypeID(OSBoolean)))
	{
		boolean = OSDynamicCast(OSBoolean, object);
		return boolean->getValue();
	}
	if (object && (OSTypeIDInst(object) == OSTypeID(OSNumber)))
	{
		number = OSDynamicCast(OSNumber, object);
		return number->unsigned32BitValue();
	}
	if (object && (OSTypeIDInst(object) == OSTypeID(OSString)))
	{
		string = OSDynamicCast(OSString, object);
		// Implement string to number conversion
	}
	return 0;
}
コード例 #8
0
IOReturn
VoodooPState::setProperties(OSObject * properties)
{
	if (!Ready) {
		return kIOReturnNotReady;
	}
	OSDictionary * dictionary = OSDynamicCast(OSDictionary, properties);

	// to fix p-state
	OSObject * object = dictionary->getObject(keyCurrentPState);
	if (object) {
		// reset
		CpuCount = getCpuCount();

		OSNumber * number = OSDynamicCast(OSNumber, object);
		UInt32 pstate = number->unsigned32BitValue();
		if(pstate >= PStateCount)
			pstate = PStateCount-1;
		Request = pstate;

		// InfoLog("Requested : %d",Request);
		return kIOReturnSuccess;
	}
	return kIOReturnUnsupported;
}
コード例 #9
0
OSNumber * IOHIDDeviceShim::newLocationIDNumber() const
{
    OSNumber *  number;
    UInt32      location = _location;
    
    if (_device && !location)
    {
        if ((number = OSDynamicCast(OSNumber, _device->getProperty("locationID"))) || 
			(number = OSDynamicCast(OSNumber, _device->getProperty(kIOHIDLocationIDKey))))
        {
            location = number->unsigned32BitValue();
        }
        else 
        {
            // Bullshit a location based on the ADB address and handler id        
            if (number = OSDynamicCast(OSNumber, _device->getProperty("address")))
                location |= number->unsigned8BitValue() << 24;
                
            if (number = OSDynamicCast(OSNumber, _device->getProperty("handler id")))
                location |= number->unsigned8BitValue() << 16;
        }
    }
    
    return (location) ? OSNumber::withNumber(location, 32) : 0;
}
コード例 #10
0
ファイル: iTCOWatchdog.cpp プロジェクト: bigmagic/osx-goodies
bool iTCOWatchdog::init (OSDictionary* dict)
{
    OSNumber *nkey;
    OSBoolean *bkey;
    bool res;
    
    //DbgPrint(drvid, "init\n");
    res = super::init(dict);
    
    Timeout = DEFAULT_TIMEOUT;
    SelfFeeding = false;
    WorkaroundBug = false;
    
    if ((conf = OSDynamicCast(OSDictionary, getProperty("Settings"))) &&
        (nkey = OSDynamicCast(OSNumber, conf->getObject("Timeout"))))
        Timeout = nkey->unsigned32BitValue();
    if (conf && (bkey = OSDynamicCast(OSBoolean, conf->getObject("SelfFeeding"))))
        SelfFeeding = bkey->isTrue();
    if (conf && (bkey = OSDynamicCast(OSBoolean, conf->getObject("UnsafeWorkaroundBIOSBug"))))
        WorkaroundBug = bkey->isTrue();
    
    first_run = true;
    is_active = SMIWereEnabled = false;
    
    GCSMem.range = NULL; GCSMem.map = NULL;
    
    lock = IOSimpleLockAlloc();
    
    return res;
}
bool IOAudioSelectorControl::valueExists(SInt32 selectionValue)
{
    bool found = false;
    OSCollectionIterator *iterator;

    assert(availableSelections);
    
    iterator = OSCollectionIterator::withCollection(availableSelections);
    if (iterator) {
        OSDictionary *selection;
        
        while ( (selection = (OSDictionary *)iterator->getNextObject()) ) {
            OSNumber *sValue;
            
            sValue = (OSNumber *)selection->getObject(kIOAudioSelectorControlSelectionValueKey);
            
            if (sValue && ((SInt32)sValue->unsigned32BitValue() == selectionValue)) {
                found = true;
                break;
            }
        }
        
        iterator->release();
    }
    
    return found;
}
コード例 #12
0
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;
}
コード例 #13
0
int VoodooI2CHIDDevice::i2c_hid_acpi_pdata(i2c_hid *ihid) {

    UInt32 guid_1 = 0x3CDFF6F7;
    UInt32 guid_2 = 0x45554267;
    UInt32 guid_3 = 0x0AB305AD;
    UInt32 guid_4 = 0xDE38893D;
    
    
    OSObject *result = NULL;
    OSObject *params[3];
    char buffer[16];
    
    memcpy(buffer, &guid_1, 4);
    memcpy(buffer + 4, &guid_2, 4);
    memcpy(buffer + 8, &guid_3, 4);
    memcpy(buffer + 12, &guid_4, 4);
    
    
    params[0] = OSData::withBytes(buffer, 16);
    params[1] = OSNumber::withNumber(0x1, 8);
    params[2] = OSNumber::withNumber(0x1, 8);
    
    ihid->client->provider->evaluateObject("_DSM", &result, params, 3);

    OSNumber* number = OSDynamicCast(OSNumber, result);
    
    ihid->pdata.hid_descriptor_address = number->unsigned32BitValue();
    
    number->release();
    params[0]->release();
    params[1]->release();
    params[2]->release();

    return 0;
}
コード例 #14
0
OSNumber* Xbox360ControllerClass::newLocationIDNumber() const
{
	IOUSBDevice *device;
    OSNumber *number;
    UInt32 location = 0;

	device = GetOwnerProvider(this);
    if (device)
    {
        if ((number = OSDynamicCast(OSNumber, device->getProperty("locationID"))))
        {
            location = number->unsigned32BitValue();
        }
        else
        {
            // Make up an address
            if ((number = OSDynamicCast(OSNumber, device->getProperty("USB Address"))))
                location |= number->unsigned8BitValue() << 24;

            if ((number = OSDynamicCast(OSNumber, device->getProperty("idProduct"))))
                location |= number->unsigned8BitValue() << 16;
        }
    }

    return (location != 0) ? OSNumber::withNumber(location, 32) : 0;
}
コード例 #15
0
IOReturn ApplePS2Mouse::setParamProperties( OSDictionary * config )
{
	if (NULL == config)
		return 0;
    
    const struct {const char *name; int *var;} int32vars[]={
        {"DefaultResolution",               &defres},
        {"ResolutionMode",                  &resmode},
        {"ScrollResolution",                &scrollres},
        {"MouseYInverter",                  &mouseyinverter},
        {"WakeDelay",                       &wakedelay},
    };
    const struct {const char *name; int *var;} boolvars[]={
        {"ForceDefaultResolution",          &forceres},
        {"ForceSetResolution",              &forcesetres},
        {"ActLikeTrackpad",                 &actliketrackpad},
        {"DisableLEDUpdating",              &noled},
    };
    const struct {const char* name; bool* var;} lowbitvars[]={
        {"TrackpadScroll",                  &scroll},
        {"OutsidezoneNoAction When Typing", &outzone_wt},
        {"PalmNoAction Permanent",          &palm},
        {"PalmNoAction When Typing",        &palm_wt},
    };
    
    OSNumber *num;
    OSBoolean *bl;
    
    // boolean config items
    for (int i = 0; i < countof(boolvars); i++)
        if ((bl=OSDynamicCast (OSBoolean,config->getObject (boolvars[i].name))))
            *boolvars[i].var = bl->isTrue();
    // lowbit config items
	for (int i = 0; i < countof(lowbitvars); i++)
		if ((num=OSDynamicCast (OSNumber,config->getObject(lowbitvars[i].name))))
			*lowbitvars[i].var = (num->unsigned32BitValue()&0x1)?true:false;
    // 32-bit config items
    for (int i = 0; i < countof(int32vars);i++)
        if ((num=OSDynamicCast (OSNumber,config->getObject (int32vars[i].name))))
            *int32vars[i].var = num->unsigned32BitValue();
    
    // convert to IOFixed format...
    defres <<= 16;
    
    return super::setParamProperties(config);
}
コード例 #16
0
ファイル: AppleOnboardPCATAChannel.cpp プロジェクト: OTiZ/osx
UInt32 CLASS::getNumberPropertyValue( const char * propKey ) const
{
    OSNumber * num = OSDynamicCast(OSNumber, getProperty(propKey));
    if (num)
        return num->unsigned32BitValue();
    else
        return 0;
}
コード例 #17
0
UInt32
GetValueFromArray(OSArray * array, UInt8 index) {
	OSObject * object = array->getObject(index);
	if (object && (OSTypeIDInst(object) == OSTypeID(OSNumber))) {
		OSNumber * number = OSDynamicCast(OSNumber, object);
		if (number) return number->unsigned32BitValue();
	}
	return -1;
}
コード例 #18
0
ファイル: IOUSBNub.cpp プロジェクト: aosm/IOUSBFamily
//  This routine will look to see if the OSArray contains any matching keys.  The OSArray has to contain a list of OSNumbers.
bool 
IOUSBNub::USBComparePropertyInArrayWithMask( OSDictionary *matching, const char * arrayName, const char * key, const char * maskKey, 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;
    OSNumber *		dictionaryMask = 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));
    dictionaryMask = OSDynamicCast(OSNumber, matching->getObject(maskKey));
	
	// Iterate over the array looking for the entries
	if (propertyIDArray && registryProperty && dictionaryMask)
	{
		USBLog(7, "%s[%p]::USBComparePropertyInArrayWithMask - 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)
			{
				UInt32  registryValue = registryProperty->unsigned32BitValue();
				UInt32  arrayValue = propertyFromArrayItem->unsigned32BitValue();
				UInt32  mask = dictionaryMask->unsigned32BitValue();
				
				if ( (registryValue & mask) == (arrayValue & mask) )
				{
					USBLog(7, "%s[%p]::USBComparePropertyInArrayWithMask - 0x%x, 0x%x, mask 0x%x matched", getName(), this, (uint32_t)arrayValue, (uint32_t)registryValue, (uint32_t)mask);
					*theProductIDThatMatched = registryValue;
					matches = true;
				}
			}
		}
	}
	
    return matches;
}
コード例 #19
0
bool CompareNumberPropertyArrayWithMask( IOService * owner, OSDictionary * matching, const char * arrayName, const char * key, const char * maskKey, SInt32 * score, SInt32 increment)
{
	OSNumber    *registryProperty = (OSNumber *)owner->copyProperty(key);
    OSArray     *propertyArray = (OSArray *)matching->getObject(arrayName);
	OSNumber    *valueMask = (OSNumber *)matching->getObject(maskKey);
    CONVERT_TO_STACK_RETAIN(registryProperty);

    // If the property array or the value mask doesn't exist then return true
    if( OSDynamicCast(OSArray, propertyArray) && OSDynamicCast(OSNumber, valueMask) )
    {
        if ( OSDynamicCast(OSNumber, registryProperty) )
        {
            OSNumber *propertyFromArray;
            UInt32  registryValue = registryProperty->unsigned32BitValue();
            UInt32  mask = valueMask->unsigned32BitValue();
            
            int i = 0;
            
            for ( i = 0; i < propertyArray->getCount(); i ++ )
            {
                propertyFromArray = OSDynamicCast(OSNumber, propertyArray->getObject(i));
                if ( propertyFromArray )
                {
                    UInt32 propertyFromArrayValue = propertyFromArray->unsigned32BitValue();
                    if( (registryValue & mask) == (propertyFromArrayValue & mask ) )
                    {
                        if ( score )
                            *score += increment;
                        return true;
                        
                    }
                }
            }
        }
	}
    else
        return true;
    
	return false;
}
コード例 #20
0
ファイル: AREngine.cpp プロジェクト: paulz/zirkonium
bool	AREngine::init(OSDictionary* inProperties)
{
	bool theAnswer = false;
	
	//	figure out if altivec is present
	UInt32 theValue = 0;
	UInt32 theValueSize = sizeof(UInt32);
	int theError = 1;
#if __ppc__
	theError = sysctlbyname("hw.optional.altivec", &theValue, &theValueSize, NULL, 0);
#elif __i386__
	theError = sysctlbyname("hw.optional.sse3", &theValue, &theValueSize, NULL, 0);
#else
	#error	unknown processor
#endif
	mHasVectorUnit = theError == 0;
	
	if(IOAudioEngine::init(inProperties))
	{
		//	get the number of blocks
		mNumberBlocks = NUM_BLOCKS;
		OSNumber* theOSNumber = OSDynamicCast(OSNumber, getProperty(NUM_BLOCKS_KEY));
		if(theOSNumber != NULL)
		{
			mNumberBlocks = theOSNumber->unsigned32BitValue();
		}
		
		//	get the block size
		mBlockSize = BLOCK_SIZE;
		theOSNumber = OSDynamicCast(OSNumber, getProperty(BLOCK_SIZE_KEY));
		if(theOSNumber != NULL)
		{
			mBlockSize = theOSNumber->unsigned32BitValue();
		}
		
		theAnswer = true;
	}

	return theAnswer;
}
コード例 #21
0
ファイル: AppleUSBCDC.cpp プロジェクト: Kiichi77/MacOSX
IOService *AppleUSBCDC::probe(IOService *provider, SInt32 *score)
{
	IOUSBDevice *newDevice = NULL;
	UInt8		classValue = 0;
    OSNumber	*classInfo = NULL;
	SInt32		newScore = 0;
    IOService   *res;
	
	XTRACE(this, 0, *score, "probe");
	
	OSBoolean *boolObj = OSDynamicCast(OSBoolean, provider->getProperty("kCDCDoNotMatchThisDevice"));
    if (boolObj && boolObj->isTrue())
    {
        XTRACE(this, 0, *score, "probe - provider doesn't want us to match");
        return NULL;
    }
	
		// Check the device class, we need to handle Miscellaneous or Composite class a little different
	
	classInfo = (OSNumber *)provider->getProperty("bDeviceClass");
    if (classInfo)
    {
        classValue = classInfo->unsigned32BitValue();
		if ((classValue == kUSBCompositeClass) || (classValue == kUSBMiscellaneousClass))
		{
			newDevice = OSDynamicCast(IOUSBDevice, provider);
			if(!newDevice)
			{
				XTRACE(this, 0, 0, "probe - provider invalid");
			} else {
					// Check if it has CDC interfaces
					
				if (checkDevice(newDevice))
				{
					newScore = 1;			// We need to see the device before the Composite driver does
				} else {
					XTRACE(this, 0, 0, "probe - Composite or Micsellaneous class but not CDC");
					return NULL;			// We're not interested
				}
			}
		}
	}

	*score += newScore;
	
    res = super::probe(provider, score);
	
	XTRACE(this, 0, *score, "probe - Exit");
    
    return res;
    
}/* end probe */
コード例 #22
0
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;
}
コード例 #23
0
bool SoundflowerEngine::init(OSDictionary *properties)
{
    bool result = false;
    OSNumber *number = NULL;
    
	//IOLog("SoundflowerEngine[%p]::init()\n", this);

    if (!super::init(properties)) {
        goto Done;
    }
    
    // Do class-specific initialization here
    // If no non-hardware initialization is needed, this function can be removed
    
    number = OSDynamicCast(OSNumber, getProperty(NUM_BLOCKS_KEY));
    if (number) {
        numBlocks = number->unsigned32BitValue();
    } 
	else {
        numBlocks = NUM_BLOCKS;
    }
    
    number = OSDynamicCast(OSNumber, getProperty(BLOCK_SIZE_KEY));
    if (number) {
        blockSize = number->unsigned32BitValue();
    } 
	else {
        blockSize = BLOCK_SIZE;
    }
    
    inputStream = outputStream = NULL;
    duringHardwareInit = FALSE;
	mLastValidSampleFrame = 0;
    result = true;
    
Done:
    return result;
}
コード例 #24
0
bool PhantomAudioEngine::init(OSDictionary *properties)
{
    bool result = false;
    OSNumber *number;
    
    IOLog("PhantomAudioEngine[%p]::init()\n", this);

    if (!super::init(properties)) {
        goto Done;
    }
    
    // Do class-specific initialization here
    // If no non-hardware initialization is needed, this function can be removed
    
    number = OSDynamicCast(OSNumber, getProperty(NUM_BLOCKS_KEY));
    if (number) {
        numBlocks = number->unsigned32BitValue();
    } else {
        numBlocks = NUM_BLOCKS;
    }
    
    number = OSDynamicCast(OSNumber, getProperty(BLOCK_SIZE_KEY));
    if (number) {
        blockSize = number->unsigned32BitValue();
    } else {
        blockSize = BLOCK_SIZE;
    }
    
    duringHardwareInit = FALSE;
    
    result = true;
    
Done:

    return result;
}
コード例 #25
0
OSNumber * IOHIDDeviceShim::newProductIDNumber() const
{
    OSNumber * number       = NULL;
    OSNumber * returnNumber = NULL;
    
    if (_device && 
			((number = OSDynamicCast(OSNumber, _device->getProperty("idProduct"))) || 
			 (number = OSDynamicCast(OSNumber, _device->getProperty(kIOHIDProductIDKey)))))
        returnNumber = OSNumber::withNumber(number->unsigned32BitValue(), 32);

    if ( _hiDevice && returnNumber )
        _hiDevice->setProperty(kIOHIDProductIDKey, returnNumber);

    return returnNumber;
}
コード例 #26
0
UInt32
IOEthernetInterface::getFilters(
    const OSDictionary * dict,
    const OSSymbol *     group )
{
    OSNumber * num;
    UInt32     filters = 0;

    assert( dict && group );

    if (( num = (OSNumber *) dict->getObject(group) ))
    {
        filters = num->unsigned32BitValue();
    }
    return filters;
}
IOReturn IOAudioSelectorControl::replaceAvailableSelection(SInt32 selectionValue, OSString *selectionDescription)
{
    OSCollectionIterator *iterator;
	OSArray *newSelections;
	OSArray *oldAvailableSelections;
    IOReturn result = kIOReturnSuccess;
    
    assert(availableSelections);

	oldAvailableSelections = availableSelections;
	newSelections = OSArray::withArray(availableSelections);
	if (!newSelections)
		return kIOReturnNoMemory;

    iterator = OSCollectionIterator::withCollection(newSelections);
    if (iterator) {
        OSDictionary *	selection;
		UInt32			index;

		index = 0;
        while ( (selection = (OSDictionary *)iterator->getNextObject() )) {
            OSNumber *	sValue;

            sValue = (OSNumber *)selection->getObject(kIOAudioSelectorControlSelectionValueKey);

            if (sValue && ((SInt32)sValue->unsigned32BitValue() == selectionValue)) {
				// Replace the selected dictionary in the array
				newSelections->replaceObject(index, selectionDescription);
				result = kIOReturnSuccess;
                break;
            }
			index++;
        }
		availableSelections = newSelections;
        setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
		oldAvailableSelections->release();

        iterator->release();
    }

	if (kIOReturnSuccess == result) {
		sendChangeNotification(kIOAudioControlRangeChangeNotification);
	}

    return result;
}
コード例 #28
0
// Gets the location ID for this device
OSNumber* WirelessDevice::newLocationIDNumber() const
{
    OSNumber *owner;
    UInt32 location = 0;
    
    if (index == -1)
        return NULL;
    WirelessGamingReceiver *receiver = OSDynamicCast(WirelessGamingReceiver, getProvider());
    if (receiver == NULL)
        return NULL;
    owner = receiver->newLocationIDNumber();
    if (owner != NULL)
    {
        location = owner->unsigned32BitValue() + 1 + index;
        owner->release();
    }
    return OSNumber::withNumber(location, 32);
}
コード例 #29
0
ファイル: IOUSBNub.cpp プロジェクト: aosm/IOUSBFamily
//  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;
}
コード例 #30
0
bool AppleLVMVolume::initWithHeader(OSDictionary * props)
{
    IOLog1("AppleLVMVolume::initWithHeader() entered\n");

    if (lvProps) lvProps->release();
    lvProps = props;
    lvProps->retain();

    if (!getVolumeUUID()) return false;
    if (!getGroupUUID()) return false;
    
    OSNumber * number;
    number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeSequenceKey));
    if (!number) return false;
    lvSequenceNumber = number->unsigned32BitValue();

    number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeExtentCountKey));
    if (!number) return false;
    lvExtentCount = number->unsigned64BitValue();
    
    number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeSizeKey));
    if (!number) return false;
    lvClaimedSize = number->unsigned64BitValue();

    OSString * type = OSDynamicCast(OSString, lvProps->getObject(kAppleLVMVolumeTypeKey));
    if (!type) return false;
    if (type->isEqualTo(kAppleLVMVolumeTypeConcat)) lvTypeID = kLVMTypeConcat;
    if (type->isEqualTo(kAppleLVMVolumeTypeBitMap)) lvTypeID = kLVMTypeBitMap;
    if (type->isEqualTo(kAppleLVMVolumeTypeSnapRO)) lvTypeID = kLVMTypeSnapRO;
    if (type->isEqualTo(kAppleLVMVolumeTypeSnapRW)) lvTypeID = kLVMTypeSnapRW;
    if (type->isEqualTo(kAppleLVMVolumeTypeMaster)) lvTypeID = kLVMTypeMaster;
    if (!lvTypeID) return false;

    lvSnapShot = NULL;  // just clear these, they might not exist yet.
    lvBitMap = NULL;
    lvParent = NULL;

    IOLog1("AppleLVMVolume::initWithHeader() successful for %s, size = %llu extent count = %llu\n",
	   getVolumeUUIDString(), lvClaimedSize, lvExtentCount);
    
    return true;
}