Exemple #1
0
long SuperIOSensor::getValue()
{
	UInt16 value = 0;
	
	switch (group) {
		case kSuperIOTemperatureSensor:
			value = owner->readTemperature(index);
			break;
		case kSuperIOVoltageSensor:
			value = owner->readVoltage(index);
			break;
		case kSuperIOTachometerSensor:
			value = owner->readTachometer(index);
			break;
		default:
			break;
	}
	
	if (*((uint32_t*)type) == *((uint32_t*)TYPE_FP2E)) {
		value = encode_fp2e(value);
	}
	else if (*((uint32_t*)type) == *((uint32_t*)TYPE_FPE2)) {
		value = encode_fpe2(value);
	}
	
	return value;
}
Exemple #2
0
bool SuperIOMonitor::updateSensor(const char *key, const char *type, unsigned char size, SuperIOSensorGroup group, unsigned long index)
{
	long value = 0;
	
	switch (group) {
		case kSuperIOTemperatureSensor:
			value = readTemperature(index);
			break;
		case kSuperIOVoltageSensor:
			value = readVoltage(index);
			break;
		case kSuperIOTachometerSensor:
			value = readTachometer(index);
			break;
		default:
			break;
	}

	if (strcmp(type, TYPE_FP2E) == 0) {
		value = encode_fp2e(value);
	}
	else if (strcmp(type, TYPE_FPE2) == 0) {
		value = encode_fpe2(value);
	}
	
	if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCSetKeyValue, true, (void*)key, (void*)size, (void*)&value, 0))
		return false;
	
	return true;
}
Exemple #3
0
long IT87xSensor::getValue()
{
	UInt16 value = 0;
	switch (group) {
		case kSuperIOTemperatureSensor:
			value = owner->readTemperature(index);
			break;
		case kSuperIOVoltageSensor:
			value = owner->readVoltage(index);
			break;
		case kSuperIOTachometerSensor:
			value = owner->readTachometer(index);
			break;
        case kSuperIOSmartGuardPWMControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardPWMControl(index);
            break;
        case kSuperIOSmartGuardTempFanStop:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanStop(index);
            break;
        case kSuperIOSmartGuardTempFanStart:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanStart(index);
            break;
        case kSuperIOSmartGuardTempFanFullOn:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanFullOn(index);
            break;
        case kSuperIOSmartGuardPWMStart:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardPWMStart(index);
            break;
        case kSuperIOSmartGuardTempFanFullOff:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanFullOff(index);
            break;
        case kSuperIOSmartGuardTempFanControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardFanControl(index);
            break;
        case kSuperIOSmartGuardMainControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardMainControl(index);
            break;
        case kSuperIOSmartGuardRegControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardRegControl(index);
            break;
            
		default:
			break;
	}
    value =  value + ((value - Vf) * Ri)/Rf;
    
	if (*((uint32_t*)type) == *((uint32_t*)TYPE_FP2E)) {
		value = encode_fp2e(value);
	}
    else if (*((uint32_t*)type) == *((uint32_t*)TYPE_FP4C)) {
		value = encode_fp4c(value);
	}
	else if (*((uint32_t*)type) == *((uint32_t*)TYPE_FPE2)) {
		value = encode_fpe2(value);
	}
	
	return value;
}
long IT87xSensor::getValue()
{
	UInt16 value = 0;
	switch (group) {
		case kSuperIOTemperatureSensor:
			value = owner->readTemperature(index);
			break;
		case kSuperIOVoltageSensor:
			value = owner->readVoltage(index);
			break;
		case kSuperIOTachometerSensor:
			value = owner->readTachometer(index);
			break;
    default:
      switch ((SuperIOSensorGroupEx)group) {
        case kSuperIOSmartGuardPWMControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardPWMControl(index);
            break;
        case kSuperIOSmartGuardTempFanStop:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanStop(index);
            break;
        case kSuperIOSmartGuardTempFanStart:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanStart(index);
            break;
        case kSuperIOSmartGuardTempFanFullOn:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanFullOn(index);
            break;
        case kSuperIOSmartGuardPWMStart:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardPWMStart(index);
            break;
        case kSuperIOSmartGuardTempFanFullOff:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardTempFanFullOff(index);
            break;
        case kSuperIOSmartGuardTempFanControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardFanControl(index);
            break;
        case kSuperIOSmartGuardMainControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardMainControl(index);
            break;
        case kSuperIOSmartGuardRegControl:
            value = OSDynamicCast(IT87x, owner)->readSmartGuardRegControl(index);
            break;
            
        default:
          break;
      }
	}
  if (Rf == 0) {
    Rf = 1;
    IOLog("Rf == 0 when getValue index=%d value=%04x\n", (int)index, value);
  }
  value =  value + ((value - Vf) * Ri)/Rf;
   
	if (*((uint32_t*)type) == *((uint32_t*)TYPE_FP2E)) {
		value = encode_fp2e(value);
	}
  else if (*((uint32_t*)type) == *((uint32_t*)TYPE_SP4B)) {
		value = encode_sp4b(value);
	}
	else if (*((uint32_t*)type) == *((uint32_t*)TYPE_FPE2)) {
		value = encode_fpe2(value);
	}
  
//  value = encodeValue(value, scale);
	
	return value;
}
Exemple #5
0
IOReturn ACPIMonitor::callPlatformFunction(const OSSymbol *functionName, bool waitForFunction, void *param1, void *param2, void *param3, void *param4 )
{
    const char* name = (const char*)param1;
    void * data = param2;
//	UInt64 size = (UInt64)param3;
    OSString* key;
#if __LP64__
    UInt64 value;
#else
    UInt32 value;
#endif
    UInt16 val;

    if (functionName->isEqualTo(kFakeSMCSetValueCallback)) {
        if (name && data) {
            if ((key = OSDynamicCast(OSString, sensors->getObject(name)))) {
                InfoLog("Writing key=%s by method=%s value=%x", name, key->getCStringNoCopy(), *(UInt16*)data);
                OSObject * params[1];
                if (key->getChar(0) == 'F') {
                    val = decode_fpe2(*(UInt16*)data);
                } else {
                    val = *(UInt16*)data;
                }
                params[0] = OSDynamicCast(OSObject, OSNumber::withNumber((unsigned long long)val, 32));
                return acpiDevice->evaluateInteger(key->getCStringNoCopy(), &value, params, 1);

                /*
                 virtual IOReturn evaluateInteger( const OSSymbol * objectName,
                 UInt32 *         resultInt32,
                 OSObject *       params[]   = 0,
                 IOItemCount      paramCount = 0,
                 IOOptionBits     options    = 0 );
                 flags_num = OSNumber::withNumber((unsigned long long)flags, 32);
                 */

            }
            return kIOReturnBadArgument;
        }
        return kIOReturnBadArgument;

    }
    if (functionName->isEqualTo(kFakeSMCGetValueCallback)) {

        if (name && data) {
            if ((key = OSDynamicCast(OSString, sensors->getObject(name)))) {
                if (kIOReturnSuccess == acpiDevice->evaluateInteger(key->getCStringNoCopy(), &value)) {

                    val = 0;

                    if (key->getChar(0) == 'V') {
                        val = encode_fp2e(value);
                    }
                    else if (key->getChar(0) == 'F') {
                        if (key->getChar(1) == 'A') {
                            val = encode_fpe2(value);
                        } else if (key->getChar(1) == 'T') {
                            val = encode_fpe2(MEGA10 / value);
                        } else {
                            val = value;
                        }
                    }
                    else val = value;

                    bcopy(&val, data, 2);
                    return kIOReturnSuccess;
                }
            }

            return kIOReturnBadArgument;
        }

        //DebugLog("bad argument key name or data");

        return kIOReturnBadArgument;
    }

    return super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4);
}
IOReturn GeforceSensors::callPlatformFunction(const OSSymbol *functionName, bool waitForFunction, void *param1, void *param2, void *param3, void *param4 )
{
	if (functionName->isEqualTo(kFakeSMCGetValueCallback)) {
		const char* key = (const char*)param1;
		char * data = (char*)param2;
    //		UInt32 size = (UInt64)param3;
		
		if (key && data) {
      OSNumber *number = OSDynamicCast(OSNumber, sensors->getObject(key));
			if (number) {
				
        //				UInt32 index = number->unsigned16BitValue();
        //				
        //				if (index < nvclock.num_cards) {
        //					
        //					if (!set_card(index)){
        //						char buf[80];
        //						WarningLog("%s", get_error(buf, 80));
        //						return kIOReturnSuccess;
        //					}
        
        UInt32 value = 0;
        
        switch (key[0]) {
          case 'T':
            
            switch (key[3]) {
                
              case 'D':
              case 'P':
								
                value = card.temp_get(&card);
                break;
              case 'H':
                
                value = card.core_temp_get(&card);
                break;
                
            }
            
            //bcopy(&value, data, 2);
            memcpy(data, &value, 2);
            
            break;
          case 'C':
            switch (key[3]) {
                
								
              case 'C':
                value=swap_value((UInt16)(card.clocks_get(&card, nouveau_clock_core) / 1000.0f));
                
                //bcopy(&value, data, 2);
                memcpy(data, &value, 4);
                
                break;
              case 'S':
                value=swap_value((UInt16)(card.clocks_get(&card, nouveau_clock_shader) / 1000.0f));
                
                //bcopy(&value, data, 2);
                memcpy(data, &value, 4);
                
                break;
              case 'M':
                value=swap_value((UInt16)(card.clocks_get(&card, nouveau_clock_memory) / 1000.0f));
                
                //bcopy(&value, data, 2);
                memcpy(data, &value, 4);
                
                break;
              case 'R':
                value=swap_value((UInt16)(card.clocks_get(&card, nouveau_clock_rop) / 1000.0f));
                
                //bcopy(&value, data, 2);
                memcpy(data, &value, 4);
                
                break;
            }
            
          case 'V':
            switch (key[3]) {
              case 'G':
                //									value = encode_fp2e( (float)card.voltage_get(&card) / 1000000.0f);
                value = encode_fp2e( (float)card.voltage_get(&card) / 1000.0f);  // Fix for fp2e encoding
                
                //bcopy(&value, data, 2);
                memcpy(data, &value, 2);
                
                break;
								
            }
            
        }
        return kIOReturnSuccess;
      }
    }
    
    return kIOReturnBadArgument;
  }
  
  return kIOReturnBadArgument;
	
	
	return super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4);
}