Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / osx / smc.h
1 /*
2  * Apple System Management Control (SMC) Tool
3  * Copyright (C) 2006 devnull
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef __SMC_H__
21 #define __SMC_H__
22 #endif
23
24 #define SMC_VERSION               "0.01"
25
26 #define OP_NONE               0
27 #define OP_LIST               1
28 #define OP_READ               2
29 #define OP_READ_FAN           3
30 #define OP_WRITE              4
31
32 #define KERNEL_INDEX_SMC      2
33
34 #define SMC_CMD_READ_BYTES    5
35 #define SMC_CMD_WRITE_BYTES   6
36 #define SMC_CMD_READ_INDEX    8
37 #define SMC_CMD_READ_KEYINFO  9
38 #define SMC_CMD_READ_PLIMIT   11
39 #define SMC_CMD_READ_VERS     12
40
41 #define DATATYPE_FPE2         "fpe2"
42 #define DATATYPE_UINT8        "ui8 "
43 #define DATATYPE_UINT16       "ui16"
44 #define DATATYPE_UINT32       "ui32"
45 #define DATATYPE_SP78         "sp78"
46
47 // key values
48 #define SMC_KEY_CPU_TEMP      "TC0D"
49 #define SMC_KEY_GPU_TEMP      "TG0D"
50 #define SMC_KEY_FAN0_RPM_MIN  "F0Mn"
51 #define SMC_KEY_FAN1_RPM_MIN  "F1Mn"
52 #define SMC_KEY_FAN0_RPM_CUR  "F0Ac"
53 #define SMC_KEY_FAN1_RPM_CUR  "F1Ac"
54
55
56 typedef struct {
57   char                  major;
58   char                  minor;
59   char                  build;
60   char                  reserved[1];
61   UInt16                release;
62 } SMCKeyData_vers_t;
63
64 typedef struct {
65   UInt16                version;
66   UInt16                length;
67   UInt32                cpuPLimit;
68   UInt32                gpuPLimit;
69   UInt32                memPLimit;
70 } SMCKeyData_pLimitData_t;
71
72 typedef struct {
73   UInt32                dataSize;
74   UInt32                dataType;
75   char                  dataAttributes;
76 } SMCKeyData_keyInfo_t;
77
78 typedef char              SMCBytes_t[32];
79
80 typedef struct {
81   UInt32                  key;
82   SMCKeyData_vers_t       vers;
83   SMCKeyData_pLimitData_t pLimitData;
84   SMCKeyData_keyInfo_t    keyInfo;
85   char                    result;
86   char                    status;
87   char                    data8;
88   UInt32                  data32;
89   SMCBytes_t              bytes;
90 } SMCKeyData_t;
91
92 typedef const char        UInt32ConstChar_t[5];
93 typedef char              UInt32Char_t[5];
94
95 typedef struct {
96   UInt32Char_t            key;
97   UInt32                  dataSize;
98   UInt32Char_t            dataType;
99   SMCBytes_t              bytes;
100 } SMCVal_t;
101
102 #ifdef __cplusplus
103 extern "C"
104 {
105 #endif
106
107 // prototypes
108 double SMCGetTemperature(const char *key);
109
110 #ifdef __cplusplus
111 }
112 #endif