diff --git a/SMCWrapper/SMCWrapper.h b/SMCWrapper/SMCWrapper.h index 53ef0cf..28794cb 100644 --- a/SMCWrapper/SMCWrapper.h +++ b/SMCWrapper/SMCWrapper.h @@ -24,13 +24,19 @@ */ #include #include +#include +#include +#include +#include +#include +#include +#include #ifndef __SMC_H__ #define __SMC_H__ #endif #define KERNEL_INDEX_SMC 2 - #define SMC_CMD_READ_BYTES 5 #define SMC_CMD_WRITE_BYTES 6 #define SMC_CMD_READ_INDEX 8 @@ -69,16 +75,15 @@ #define DATATYPE_PWM "{pwm" #define DATATYPE_LSO "{lso" #define DATATYPE_ALA "{ala" + #define DATATYPE_FLAG "flag" #define DATATYPE_CHARSTAR "ch8*" -// key values -#define SMC_KEY_CPU_TEMP "TC0P" -#define SMC_KEY_FAN_SPEED "F%dAc" -#define SMC_KEY_FAN_NUM "FNum" -#define SMC_KEY_BATTERY_TEMP "TB0T" - - +typedef char SMCBytes_t[32]; +typedef char UInt32Char_t[5]; +typedef char Flag[1]; +typedef UInt flag; +typedef UInt16 PWMValue; typedef struct SMCKeyData_vers_t { char major; @@ -102,8 +107,6 @@ typedef struct { char dataAttributes; } SMCKeyData_keyInfo_t; -typedef char SMCBytes_t[32]; - typedef struct { UInt32 key; SMCKeyData_vers_t vers; @@ -116,14 +119,6 @@ typedef struct { SMCBytes_t bytes; } SMCKeyData_t; -typedef char UInt32Char_t[5]; - -typedef char Flag[1]; -typedef UInt8 flag; - - -typedef UInt16 PWMValue; - typedef struct { UInt32Char_t key; UInt32 dataSize; @@ -131,6 +126,16 @@ typedef struct { SMCBytes_t bytes; } SMCVal_t; +typedef enum { + SUCCESS = 0, + FAILURE_IOServiceGetMatchingServices = 1, + FAILURE_NO_SMC_FOUND = 2, + FAILURE_IOServiceOpen = 3, + FAILURE_CALLING_STRUCT_METHOD = 4, + FAILURE_REPRESENTING_STRUCT = 5 +} SMCState_t; + + @interface SMCWrapper : NSObject +(SMCWrapper *)sharedWrapper; -(id) init; @@ -141,11 +146,23 @@ typedef struct { -(BOOL) stringRepresentationForBytes: (SMCBytes_t)bytes withSize: (UInt32)dataSize ofType: (UInt32Char_t)dataType - toNSString: (NSString**)abri; + intoString: (NSString**)abri; +-(BOOL) stringRawRepresentationForBytes: (SMCBytes_t)bytes + withSize: (UInt32)dataSize + ofType: (UInt32Char_t)dataType + intoString: (NSString**)abri; +-(BOOL) stringRawRepresentationForBytes: (SMCBytes_t)bytes + withSize: (UInt32)dataSize + ofType: (UInt32Char_t)dataType + inBuffer: (char *)str; -(BOOL) stringRepresentationOfVal:(SMCVal_t)val inBuffer: (char *)str; -(BOOL) stringRepresentationOfVal:(SMCVal_t)val - toNSString:(NSString**)abri; + intoString:(NSString**)abri; +-(BOOL) stringRawRepresentationOfVal:(SMCVal_t)val + inBuffer:(char *)str; +-(BOOL) stringRawRepresentationOfVal:(SMCVal_t)val + intoString:(NSString**)abri; #ifndef STRIP_COMPATIBILITY -(BOOL) getStringRepresentation: (SMCBytes_t)bytes forSize: (UInt32)dataSize @@ -161,5 +178,6 @@ __deprecated_msg("Use readKey:intoString: instead."); -(BOOL) readKey:(NSString *)key intoVal:(SMCVal_t *)val; -(BOOL) readKey:(NSString *)key intoString:(NSString **)str; -(BOOL) readKey:(NSString *)key intoNumber:(NSNumber **)value; +-(BOOL) typeOfVal:(SMCVal_t)val intoString:(NSString **)str; -(void) dealloc; @end diff --git a/SMCWrapper/SMCWrapper.m b/SMCWrapper/SMCWrapper.m index 30ece75..dfd856f 100644 --- a/SMCWrapper/SMCWrapper.m +++ b/SMCWrapper/SMCWrapper.m @@ -23,15 +23,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include -#include -#include -#include -#include -#include -#include +#include "SMCWrapper.h" -#include "smc.h" //#define STRIP_COMPATIBILIY // AppleSMC IOService connection @@ -175,8 +168,8 @@ -(void) _ultostr:(char *)str * IOConnectCallStructMethod - which is responsible for IOService calls. */ -(kern_return_t) _smcCall:(int)index - forKeyData:(SMCKeyData_t *)inputStructure - toKeyData:(SMCKeyData_t *)outputStructure + forKeyData:(SMCKeyData_t *)inputStructure + toKeyData:(SMCKeyData_t *)outputStructure { size_t structureInputSize; size_t structureOutputSize; @@ -209,8 +202,8 @@ -(kern_return_t) _smcReadKey:(UInt32Char_t)key toValue:(SMCVal_t*)val inputStructure.data8 = SMC_CMD_READ_KEYINFO; result = [self _smcCall: KERNEL_INDEX_SMC - forKeyData: &inputStructure - toKeyData: &outputStructure]; + forKeyData: &inputStructure + toKeyData: &outputStructure]; if (result != kIOReturnSuccess) return result; @@ -314,84 +307,84 @@ -(SMCVal_t) createEmptyValue { -(BOOL) stringRepresentationForBytes: (SMCBytes_t)bytes withSize: (UInt32)dataSize ofType: (UInt32Char_t)dataType - inBuffer: (char *)str + inBuffer: (char *)str { if (dataSize > 0) { - if ((strcmp(dataType, DATATYPE_UINT8) == 0) || - (strcmp(dataType, DATATYPE_UINT16) == 0) || - (strcmp(dataType, DATATYPE_UINT32) == 0)) { - UInt32 uint= [self _strtoul:bytes forSize:dataSize inBase:10]; - snprintf(str, 15, "%u ", (unsigned int)uint); - } - else if (strcmp(dataType, DATATYPE_FP1F) == 0 && dataSize == 2) - snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 32768.0); - else if (strcmp(dataType, DATATYPE_FP4C) == 0 && dataSize == 2) - snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 4096.0); - else if (strcmp(dataType, DATATYPE_FP5B) == 0 && dataSize == 2) - snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 2048.0); - else if (strcmp(dataType, DATATYPE_FP6A) == 0 && dataSize == 2) - snprintf(str, 15, "%.4f ", ntohs(*(UInt16*)bytes) / 1024.0); - else if (strcmp(dataType, DATATYPE_FP79) == 0 && dataSize == 2) - snprintf(str, 15, "%.4f ", ntohs(*(UInt16*)bytes) / 512.0); - else if (strcmp(dataType, DATATYPE_FP88) == 0 && dataSize == 2) - snprintf(str, 15, "%.3f ", ntohs(*(UInt16*)bytes) / 256.0); - else if (strcmp(dataType, DATATYPE_FPA6) == 0 && dataSize == 2) - snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 64.0); - else if (strcmp(dataType, DATATYPE_FPC4) == 0 && dataSize == 2) - snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 16.0); - else if (strcmp(dataType, DATATYPE_FPE2) == 0 && dataSize == 2) - snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 4.0); - else if (strcmp(dataType, DATATYPE_SP1E) == 0 && dataSize == 2) - snprintf(str, 15, "%.5f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 16384.0); - else if (strcmp(dataType, DATATYPE_SP3C) == 0 && dataSize == 2) - snprintf(str, 15, "%.5f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 4096.0); - else if (strcmp(dataType, DATATYPE_SP4B) == 0 && dataSize == 2) - snprintf(str, 15, "%.4f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 2048.0); - else if (strcmp(dataType, DATATYPE_SP5A) == 0 && dataSize == 2) - snprintf(str, 15, "%.4f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 1024.0); - else if (strcmp(dataType, DATATYPE_SP69) == 0 && dataSize == 2) - snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 512.0); - else if (strcmp(dataType, DATATYPE_SP78) == 0 && dataSize == 2) - snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 256.0); - else if (strcmp(dataType, DATATYPE_SP87) == 0 && dataSize == 2) - snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 128.0); - else if (strcmp(dataType, DATATYPE_SP96) == 0 && dataSize == 2) - snprintf(str, 15, "%.2f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 64.0); - else if (strcmp(dataType, DATATYPE_SPB4) == 0 && dataSize == 2) - snprintf(str, 15, "%.2f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 16.0); - else if (strcmp(dataType, DATATYPE_SPF0) == 0 && dataSize == 2) - snprintf(str, 15, "%.0f ", (float)ntohs(*(UInt16*)bytes)); - else if (strcmp(dataType, DATATYPE_SI16) == 0 && dataSize == 2) - snprintf(str, 15, "%d ", ntohs(*(SInt16*)bytes)); - else if (strcmp(dataType, DATATYPE_SI8) == 0 && dataSize == 1) - snprintf(str, 15, "%d ", (signed char)*bytes); - else if (strcmp(dataType, DATATYPE_PWM) == 0 && dataSize == 2) - snprintf(str, 15, "%.1f%% ", ntohs(*(UInt16*)bytes) * 100 / 65536.0); - else if (strcmp(dataType, DATATYPE_CHARSTAR) == 0) - snprintf(str, 15, "%s ", bytes); - else if (strcmp(dataType, DATATYPE_FLAG) == 0) - snprintf(str, 15, "%s ", bytes[0] ? "TRUE" : "FALSE"); - else { - int i; - char tempAb[64]; - for (i = 0; i < dataSize; i++) { - snprintf(tempAb+strlen(tempAb), 8, "%02x ", (unsigned char) bytes[i]); + if ((strcmp(dataType, DATATYPE_UINT8) == 0) || + (strcmp(dataType, DATATYPE_UINT16) == 0) || + (strcmp(dataType, DATATYPE_UINT32) == 0)) { + UInt32 uint= [self _strtoul:bytes forSize:dataSize inBase:10]; + snprintf(str, 15, "%u ", (unsigned int)uint); + } + else if (strcmp(dataType, DATATYPE_FP1F) == 0 && dataSize == 2) + snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 32768.0); + else if (strcmp(dataType, DATATYPE_FP4C) == 0 && dataSize == 2) + snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 4096.0); + else if (strcmp(dataType, DATATYPE_FP5B) == 0 && dataSize == 2) + snprintf(str, 15, "%.5f ", ntohs(*(UInt16*)bytes) / 2048.0); + else if (strcmp(dataType, DATATYPE_FP6A) == 0 && dataSize == 2) + snprintf(str, 15, "%.4f ", ntohs(*(UInt16*)bytes) / 1024.0); + else if (strcmp(dataType, DATATYPE_FP79) == 0 && dataSize == 2) + snprintf(str, 15, "%.4f ", ntohs(*(UInt16*)bytes) / 512.0); + else if (strcmp(dataType, DATATYPE_FP88) == 0 && dataSize == 2) + snprintf(str, 15, "%.3f ", ntohs(*(UInt16*)bytes) / 256.0); + else if (strcmp(dataType, DATATYPE_FPA6) == 0 && dataSize == 2) + snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 64.0); + else if (strcmp(dataType, DATATYPE_FPC4) == 0 && dataSize == 2) + snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 16.0); + else if (strcmp(dataType, DATATYPE_FPE2) == 0 && dataSize == 2) + snprintf(str, 15, "%.2f ", ntohs(*(UInt16*)bytes) / 4.0); + else if (strcmp(dataType, DATATYPE_SP1E) == 0 && dataSize == 2) + snprintf(str, 15, "%.5f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 16384.0); + else if (strcmp(dataType, DATATYPE_SP3C) == 0 && dataSize == 2) + snprintf(str, 15, "%.5f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 4096.0); + else if (strcmp(dataType, DATATYPE_SP4B) == 0 && dataSize == 2) + snprintf(str, 15, "%.4f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 2048.0); + else if (strcmp(dataType, DATATYPE_SP5A) == 0 && dataSize == 2) + snprintf(str, 15, "%.4f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 1024.0); + else if (strcmp(dataType, DATATYPE_SP69) == 0 && dataSize == 2) + snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 512.0); + else if (strcmp(dataType, DATATYPE_SP78) == 0/* && dataSize == 2*/) + snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 256.0); + else if (strcmp(dataType, DATATYPE_SP87) == 0 && dataSize == 2) + snprintf(str, 15, "%.3f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 128.0); + else if (strcmp(dataType, DATATYPE_SP96) == 0 && dataSize == 2) + snprintf(str, 15, "%.2f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 64.0); + else if (strcmp(dataType, DATATYPE_SPB4) == 0 && dataSize == 2) + snprintf(str, 15, "%.2f ", ((SInt16)ntohs(*(UInt16*)bytes)) / 16.0); + else if (strcmp(dataType, DATATYPE_SPF0) == 0 && dataSize == 2) + snprintf(str, 15, "%.0f ", (float)ntohs(*(UInt16*)bytes)); + else if (strcmp(dataType, DATATYPE_SI16) == 0 && dataSize == 2) + snprintf(str, 15, "%d ", ntohs(*(SInt16*)bytes)); + else if (strcmp(dataType, DATATYPE_SI8) == 0 && dataSize == 1) + snprintf(str, 15, "%d ", (signed char)*bytes); + else if (strcmp(dataType, DATATYPE_PWM) == 0 && dataSize == 2) + snprintf(str, 15, "%.1f%% ", ntohs(*(UInt16*)bytes) * 100 / 65536.0); + else if (strcmp(dataType, DATATYPE_CHARSTAR) == 0) + snprintf(str, 15, "%s ", bytes); + else if (strcmp(dataType, DATATYPE_FLAG) == 0) + snprintf(str, 15, "%s ", bytes[0] ? "TRUE" : "FALSE"); + else { + int i; + char tempAb[64]; + for (i = 0; i < dataSize; i++) { + snprintf(tempAb+strlen(tempAb), 8, "%02x ", (unsigned char) bytes[i]); + } + snprintf(str, 15, "%s ", tempAb); } - snprintf(str, 15, "%s ", tempAb); - } return TRUE; } return FALSE; } /** - * stringRepresentationForBytes:withSize:ofType:toNSString - Retrieves a NSString + * stringRepresentationForBytes:withSize:ofType:intoString - Retrieves a NSString * representation of the given values ; returns a bool to indicate success or failure. */ -(BOOL) stringRepresentationForBytes: (SMCBytes_t)bytes withSize: (UInt32)dataSize ofType: (UInt32Char_t)dataType - toNSString: (NSString**)abri + intoString: (NSString**)abri { if (dataSize > 0) { if ((strcmp(dataType, DATATYPE_UINT8) == 0) || @@ -455,7 +448,48 @@ -(BOOL) stringRepresentationForBytes: (SMCBytes_t)bytes } *abri = [[NSString alloc] initWithFormat:@"%s", tempAb]; } - } else { + return TRUE; + } + return FALSE; +} + +/** + * stringRawRepresentationForBytes:withSize:ofType:intoString - Retrieves a NSString raw (hex bytes) + * representation of the given values ; returns a bool to indicate success or failure. + */ +-(BOOL) stringRawRepresentationForBytes: (SMCBytes_t)bytes + withSize: (UInt32)dataSize + ofType: (UInt32Char_t)dataType + intoString: (NSString**)abri +{ + if (dataSize > 0) { + int i; + char tempAb[64]; + for (i = 0; i < dataSize; i++) { + snprintf(tempAb+strlen(tempAb), 8, "%02x ", (unsigned char) bytes[i]); + } + *abri = [[NSString alloc] initWithFormat:@"%s", tempAb]; + return TRUE; + } + return FALSE; +} + +/** + * stringRawRepresentationForBytes:withSize:ofType:inBuffer - Retrieves a CString raw (hex bytes) + * representation of the given values ; returns a bool to indicate success or failure. + */ +-(BOOL) stringRawRepresentationForBytes: (SMCBytes_t)bytes + withSize: (UInt32)dataSize + ofType: (UInt32Char_t)dataType + inBuffer: (char *)str +{ + if (dataSize > 0) { + int i; + char tempAb[64]; + for (i = 0; i < dataSize; i++) { + snprintf(tempAb+strlen(tempAb), 8, "%02x ", (unsigned char) bytes[i]); + } + snprintf(str, 15, "%s ", tempAb); return TRUE; } return FALSE; @@ -472,19 +506,56 @@ -(BOOL) stringRepresentationOfVal:(SMCVal_t)val } /** - * stringRepresentationOfVal:toNSString: - Retrieves a NSString representation + * stringRepresentationOfVal:intoString: - Retrieves a NSString representation * of the given SMCVal_t ; returns a bool to indicate success or failure. */ -(BOOL) stringRepresentationOfVal:(SMCVal_t)val - toNSString:(NSString**)abri + intoString:(NSString**)abri +{ + return [self stringRepresentationForBytes:val.bytes withSize:val.dataSize ofType:val.dataType intoString:abri]; +} + +/** + * stringRawRepresentationOfVal:inBuffer: - Retrieves a NSString representation + * of the given SMCVal_t raw value (hex bytes); returns a bool to indicate success or failure. + */ +-(BOOL) stringRawRepresentationOfVal:(SMCVal_t)val + inBuffer:(char *)str { - return [self stringRepresentationForBytes:val.bytes withSize:val.dataSize ofType:val.dataType toNSString:abri]; + return [self stringRawRepresentationForBytes:val.bytes withSize:val.dataSize ofType:val.dataType inBuffer:str]; } +/** + * stringRawRepresentationOfVal:intoString: - Retrieves a NSString representation + * of the given SMCVal_t raw value (hex bytes); returns a bool to indicate success or failure. + */ +-(BOOL) stringRawRepresentationOfVal:(SMCVal_t)val + intoString:(NSString**)abri +{ + return [self stringRawRepresentationForBytes:val.bytes withSize:val.dataSize ofType:val.dataType intoString:abri]; +} + +/** + * stringRawRepresentationOfVal:intoString: - Retrieves a NSString representation + * of the given SMCVal_t raw value (hex bytes); returns a bool to indicate success or failure. + */ +-(BOOL) typeOfVal:(SMCVal_t)val intoString:(NSString **)str +{ + if (val.dataType) { //check if belongs to type array + *str = [[NSString alloc] initWithCString:val.dataType encoding:NSUTF8StringEncoding]; + return TRUE; + } + return FALSE; +} + +/** + * readKey:intoVal - Wrapper for the internal _smcReadKey that fills the given SMCVal_t, + * taking a NSString (not a CString) as the key name; returns a bool to indicate success or failure. + */ -(BOOL) readKey:(NSString *)key intoVal:(SMCVal_t *)val { kern_return_t result; - result = [self _smcReadKey:[key UTF8String] toValue: val]; + result = [self _smcReadKey:(char*)[key UTF8String] toValue: val]; // Do value checking on val. if (result != kIOReturnSuccess) { return NO; @@ -502,7 +573,7 @@ -(BOOL) readKey:(NSString *)key intoString:(NSString **)str SMCVal_t val; kern_return_t result; - result = [self _smcReadKey:[key UTF8String] toValue: &val]; + result = [self _smcReadKey:(char*)[key UTF8String] toValue: &val]; // Do value checking on val. if (result != kIOReturnSuccess) { @@ -512,7 +583,7 @@ -(BOOL) readKey:(NSString *)key intoString:(NSString **)str // Mac OS X means rubbish FourCC style data type referencing [self stringRepresentationForBytes:val.bytes - withSize:val.dataType + withSize:val.dataSize ofType:val.dataType inBuffer:&cStr[0]]; @@ -575,8 +646,8 @@ -(BOOL) dumpToValueDict:(NSMutableDictionary**)valDict andTypeDict:(NSMutableDic result = [self _smcReadKey:key toValue:&val]; //reads key (by its name, see above) stringKey = [NSString stringWithFormat:@"%s" , key]; - [self stringRepresentationOfVal:val toNSString:&valueKey]; - + [self stringRepresentationOfVal:val intoString:&valueKey]; + typeKey = [NSString stringWithFormat:@"%-4s",val.dataType]; [*valDict setObject:valueKey forKey:stringKey]; [*typeDict setObject:typeKey forKey:stringKey]; diff --git a/SMCWrapper/smc.h b/SMCWrapper/smc.h deleted file mode 100644 index 2f1892c..0000000 --- a/SMCWrapper/smc.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Based on the work included in the Apple System Management Control (SMC) Tool, - * the Apple SMC Tool is Copyright (C) 2006 devnull. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef SMCInfo_smc_h -#define SMCInfo_smc_h - -#define KERNEL_INDEX_SMC 2 - -#define SMC_CMD_READ_BYTES 5 -#define SMC_CMD_WRITE_BYTES 6 -#define SMC_CMD_READ_INDEX 8 -#define SMC_CMD_READ_KEYINFO 9 -#define SMC_CMD_READ_PLIMIT 11 -#define SMC_CMD_READ_VERS 12 - -#define DATATYPE_FP1F "fp1f" -#define DATATYPE_FP4C "fp4c" -#define DATATYPE_FP5B "fp5b" -#define DATATYPE_FP6A "fp6a" -#define DATATYPE_FP79 "fp79" -#define DATATYPE_FP88 "fp88" -#define DATATYPE_FPA6 "fpa6" -#define DATATYPE_FPC4 "fpc4" -#define DATATYPE_FPE2 "fpe2" - -#define DATATYPE_SP1E "sp1e" -#define DATATYPE_SP3C "sp3c" -#define DATATYPE_SP4B "sp4b" -#define DATATYPE_SP5A "sp5a" -#define DATATYPE_SP69 "sp69" -#define DATATYPE_SP78 "sp78" -#define DATATYPE_SP87 "sp87" -#define DATATYPE_SP96 "sp96" -#define DATATYPE_SPB4 "spb4" -#define DATATYPE_SPF0 "spf0" - -#define DATATYPE_UINT8 "ui8 " -#define DATATYPE_UINT16 "ui16" -#define DATATYPE_UINT32 "ui32" - -#define DATATYPE_SI8 "si8 " -#define DATATYPE_SI16 "si16" - -#define DATATYPE_FLAG "flag" -#define DATATYPE_CHARSTAR "ch8*" -#define DATATYPE_PWM "{pwm" - -// @todo: document these structures/types and work out -// where they're utilised. - -typedef struct SMCKeyData_vers_t{ //used to identify SMC firmware version - char major; - char minor; - char build; - char reserved[1]; - UInt16 release; -} SMCKeyData_vers_t; - -typedef struct { - UInt16 version; - UInt16 length; - UInt32 cpuPLimit; - UInt32 gpuPLimit; - UInt32 memPLimit; -} SMCKeyData_pLimitData_t; - -typedef struct { - UInt32 dataSize; - UInt32 dataType; - char dataAttributes; -} SMCKeyData_keyInfo_t; - -typedef char SMCBytes_t[32]; - -typedef struct { - UInt32 key; - SMCKeyData_vers_t vers; - SMCKeyData_pLimitData_t pLimitData; - SMCKeyData_keyInfo_t keyInfo; - char result; - char status; - char data8; - UInt32 data32; - SMCBytes_t bytes; -} SMCKeyData_t; - -typedef char UInt32Char_t[5]; - -typedef struct { - UInt32Char_t key; - UInt32 dataSize; - UInt32Char_t dataType; - SMCBytes_t bytes; -} SMCVal_t; - - -#endif