コード例 #1
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;
}
コード例 #2
0
ファイル: OSMetaClass.cpp プロジェクト: Prajna/xnu
bool
OSMetaClassBase::checkTypeInst(
    const OSMetaClassBase * inst,
    const OSMetaClassBase * typeinst)
{
    const OSMetaClass * toType = OSTypeIDInst(typeinst);
    return typeinst && inst && (0 != inst->metaCast(toType));
}
コード例 #3
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;
}
コード例 #4
0
// GetPlistValue
UInt32 
VoodooPState::getPlistValue(OSDictionary * dictionary,
						   const char * symbol,
						   const char * subdictionary)
{
	OSObject * object = dictionary->getObject(subdictionary);
	if (object && (OSTypeIDInst(object) == OSTypeID(OSDictionary)))
	{
		OSDictionary * newdictionary = OSDynamicCast(OSDictionary, object);
		return getPlistValue(newdictionary, symbol);
	}
	return 0;
}
コード例 #5
0
OSSymbol *
GetSymbolFromArray(OSArray * array, UInt8 index) {
	const OSMetaClass *typeID;
    char stringBuf[255];
	
    typeID = OSTypeIDInst(array->getObject(index));
	if (typeID == OSTypeID(OSString)) {
		return (OSSymbol *)OSDynamicCast(OSString, array->getObject(index));
	} else if (typeID == OSTypeID(OSData)) {
		bzero(stringBuf, sizeof(stringBuf));
		snprintf(stringBuf, sizeof(stringBuf), "%s", 
				 (char *)OSDynamicCast(OSData, array->getObject(index))->getBytesNoCopy());
		return (OSSymbol *)OSSymbol::withCStringNoCopy(stringBuf);
	}
	return (OSSymbol *)unknownObjectKey;
}
コード例 #6
0
// Class probe
IOService * 
VoodooPState::probe(IOService * provider,
				   SInt32 * score)
{
	Ready = false;

	// Probe the superclass
	if (IOService::probe(provider, score) != this) return NULL;
	
	// Read our own values from the property list
	OSDictionary * dictionary = OSDynamicCast(OSDictionary, getProperty(keyPowerControl));
	if (!dictionary) return NULL;
	UseEfiFsb			= getPlistValue(dictionary, keyUseEfiFsb);
	VoltageOverride		= getPlistValue(dictionary, keyVoltageOverride);
	VoltageProbe		= getPlistValue(dictionary, keyVoltageProbe);
	UserVoltageMax		= getPlistValue(dictionary, keyUserVoltageMax);
	UserVoltageMin		= getPlistValue(dictionary, keyUserVoltageMin);
	ColdStart			= getPlistValue(dictionary, keyColdStart);
	TimerInterval		= getPlistValue(dictionary, keyTimerInterval);
	UseACPI				= getPlistValue(dictionary, keyUseACPI);
	if(TimerInterval < 50){
		TimerInterval = 50;
	}
	
	// Get CPU's from I/O Kit
	CpuCount = getCpuCount();
	
	// No CPU's found -> bailout
	if (CpuCount == 0) return NULL;
	
	// Get FSB from /efi/platform
	CpuFSB = gPEClockFrequencyInfo.bus_frequency_max_hz >> 2;
	if (UseEfiFsb) {
		IORegistryEntry * entry = fromPath(keyEfiPlatform, gIODTPlane);
		if (entry) {
			OSObject * object = entry->getProperty(keyEfiFsbFrequency);
			if (object && (OSTypeIDInst(object) == OSTypeID(OSData))) {
				OSData * data = OSDynamicCast(OSData, object);
				if (data) {
					CpuFSB = * (UInt32 *) data->getBytesNoCopy();
					gPEClockFrequencyInfo.bus_frequency_max_hz = CpuFSB << 2;
				}
			}
		}		
	}
	CpuFSB = (CpuFSB+Mega/2) / Mega;	// Mega is enough

#if	SUPPORT_VOODOO_KERNEL
	{
		UInt64 magic;
		nanoseconds_to_absolutetime(~(0), &magic);
		VoodooKernel = (magic == 2);
	}
#endif
	// Enumerate CPU's
	CpuCoreTech = Unknown;
	{
		uint32_t data[4];

		do_cpuid(0, data);
		((uint32_t*)vendor)[0] = data[1];
		((uint32_t*)vendor)[1] = data[3];
		((uint32_t*)vendor)[2] = data[2];
		vendor[15] = 0;

		do_cpuid(1, data);
		CpuSignature = data[0];

		// Features
		((uint32_t*)&Features)[0] = data[3];
		((uint32_t*)&Features)[1] = data[2];

		for( int i = 0; i < 3; i++ ){
			do_cpuid(0x80000002+i, data);
			memcpy( &brand_string[i*16], data, 16 );
		}
		brand_string[16*3] = 0;
	}

	// Find core technology and cross core vendor specifics
	// Intel
	if (!strncmp(vendor, CPUID_VID_INTEL, sizeof(CPUID_VID_INTEL))) {
		if(!intel_probe(this)) return NULL;
	}
	// AMD
	else if (!strncmp(vendor, CPUID_VID_AMD, sizeof(CPUID_VID_AMD))) {
		if(!amd_probe(this)) return NULL;
	}
	// Unknown CPU or core technology
	else {
		ErrorLog("CPU: Core Technology Unknown - Signature %x (%s)(%s)",
				 (unsigned int)CpuSignature,
				 vendor,
				 brand_string);
		return NULL;
	}
	
	return this;
}