forked from mirror/smcFanControl
@ -1,5 +1,6 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -mmacosx-version-min=10.4 -Wall -g -framework IOKit
|
CFLAGS = -mmacosx-version-min=10.4 -Wall -g -framework IOKit
|
||||||
|
CPPFLAGS = -DCMD_TOOL_BUILD
|
||||||
|
|
||||||
all: smc
|
all: smc
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ smc: smc.o
|
|||||||
$(CC) $(CFLAGS) -o smc smc.o
|
$(CC) $(CFLAGS) -o smc smc.o
|
||||||
|
|
||||||
smc.o: smc.h smc.c
|
smc.o: smc.h smc.c
|
||||||
$(CC) -c smc.c
|
$(CC) $(CPPFLAGS) -c smc.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f smc smc.o
|
-rm -f smc smc.o
|
||||||
|
|||||||
@ -601,12 +601,53 @@ kern_return_t SMCPrintFans(void)
|
|||||||
return kIOReturnSuccess;
|
return kIOReturnSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kern_return_t SMCPrintTemps(void)
|
||||||
|
{
|
||||||
|
kern_return_t result;
|
||||||
|
SMCKeyData_t inputStructure;
|
||||||
|
SMCKeyData_t outputStructure;
|
||||||
|
|
||||||
|
int totalKeys, i;
|
||||||
|
UInt32Char_t key;
|
||||||
|
SMCVal_t val;
|
||||||
|
|
||||||
|
totalKeys = SMCReadIndexCount();
|
||||||
|
for (i = 0; i < totalKeys; i++)
|
||||||
|
{
|
||||||
|
memset(&inputStructure, 0, sizeof(SMCKeyData_t));
|
||||||
|
memset(&outputStructure, 0, sizeof(SMCKeyData_t));
|
||||||
|
memset(&val, 0, sizeof(SMCVal_t));
|
||||||
|
|
||||||
|
inputStructure.data8 = SMC_CMD_READ_INDEX;
|
||||||
|
inputStructure.data32 = i;
|
||||||
|
|
||||||
|
result = SMCCall(KERNEL_INDEX_SMC, &inputStructure, &outputStructure);
|
||||||
|
if (result != kIOReturnSuccess)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_ultostr(key, outputStructure.key);
|
||||||
|
if ( key[0] != 'T' )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SMCReadKey(key, &val);
|
||||||
|
//printVal(val);
|
||||||
|
if (strcmp(val.dataType, DATATYPE_SP78) == 0 && val.dataSize == 2) {
|
||||||
|
printf("%-4s ", val.key);
|
||||||
|
printSP78(val);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return kIOReturnSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
void usage(char* prog)
|
void usage(char* prog)
|
||||||
{
|
{
|
||||||
printf("Apple System Management Control (SMC) tool %s\n", VERSION);
|
printf("Apple System Management Control (SMC) tool %s\n", VERSION);
|
||||||
printf("Usage:\n");
|
printf("Usage:\n");
|
||||||
printf("%s [options]\n", prog);
|
printf("%s [options]\n", prog);
|
||||||
printf(" -f : fan info decoded\n");
|
printf(" -f : fan info decoded\n");
|
||||||
|
printf(" -t : list all temperatures\n");
|
||||||
printf(" -h : help\n");
|
printf(" -h : help\n");
|
||||||
printf(" -k <key> : key to manipulate\n");
|
printf(" -k <key> : key to manipulate\n");
|
||||||
printf(" -l : list all keys and values\n");
|
printf(" -l : list all keys and values\n");
|
||||||
@ -647,13 +688,16 @@ int main(int argc, char *argv[])
|
|||||||
UInt32Char_t key = { 0 };
|
UInt32Char_t key = { 0 };
|
||||||
SMCVal_t val;
|
SMCVal_t val;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "fhk:lrw:v")) != -1)
|
while ((c = getopt(argc, argv, "fthk:lrw:v")) != -1)
|
||||||
{
|
{
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'f':
|
case 'f':
|
||||||
op = OP_READ_FAN;
|
op = OP_READ_FAN;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
op = OP_READ_TEMPS;
|
||||||
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
strncpy(key, optarg, sizeof(key)); //fix for buffer overflow
|
strncpy(key, optarg, sizeof(key)); //fix for buffer overflow
|
||||||
key[sizeof(key) - 1] = '\0';
|
key[sizeof(key) - 1] = '\0';
|
||||||
@ -727,6 +771,11 @@ int main(int argc, char *argv[])
|
|||||||
if (result != kIOReturnSuccess)
|
if (result != kIOReturnSuccess)
|
||||||
printf("Error: SMCPrintFans() = %08x\n", result);
|
printf("Error: SMCPrintFans() = %08x\n", result);
|
||||||
break;
|
break;
|
||||||
|
case OP_READ_TEMPS:
|
||||||
|
result = SMCPrintTemps();
|
||||||
|
if (result != kIOReturnSuccess)
|
||||||
|
printf("Error: SMCPrintFans() = %08x\n", result);
|
||||||
|
break;
|
||||||
case OP_WRITE:
|
case OP_WRITE:
|
||||||
if (strlen(key) > 0)
|
if (strlen(key) > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#define OP_READ 2
|
#define OP_READ 2
|
||||||
#define OP_READ_FAN 3
|
#define OP_READ_FAN 3
|
||||||
#define OP_WRITE 4
|
#define OP_WRITE 4
|
||||||
|
#define OP_READ_TEMPS 5
|
||||||
|
|
||||||
#define KERNEL_INDEX_SMC 2
|
#define KERNEL_INDEX_SMC 2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user