Class SmcUtil
java.lang.Object
oshi.util.platform.mac.SmcUtil
Provides access to SMC calls on macOS
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intKernel index for SMC calls.static final byteSMC command to read bytes.static final byteSMC command to read key info.static final StringSMC key for CPU temperature (Intel).static final StringSMC key for CPU voltage (Intel).static final StringSMC key for CPU voltage (Apple Silicon).static final StringSMC key for the number of fans.static final StringSMC key format string for fan speed (use with fan index).Apple Silicon CPU temperature keys, tried in order until one returns a positive value.Apple Silicon GPU temperature keys, tried in order until one returns a positive value. -
Method Summary
Modifier and TypeMethodDescriptionstatic intsmcCall(IOKit.IOConnect conn, int index, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Call SMCstatic intsmcClose(IOKit.IOConnect conn) Close connection to SMC.static doublesmcGetFirstFloat(IOKit.IOConnect conn, List<String> keys) Get the first positive value from a list of SMC keys.static doublesmcGetFloat(IOKit.IOConnect conn, String key) Get a value from SMC which is in a floating point datatype (SP78, FPE2, FLT)static intsmcGetKeyInfo(IOKit.IOConnect conn, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Get cached keyInfo if it exists, or generate new keyInfostatic longsmcGetLong(IOKit.IOConnect conn, String key) Get a 64-bit integer value from SMCstatic IOKit.IOConnectsmcOpen()Open a connection to SMC.static intsmcReadKey(IOKit.IOConnect conn, String key, IOKit.SMCVal val) Read a key from SMC
-
Field Details
-
SMC_KEY_FAN_NUM
-
SMC_KEY_FAN_SPEED
SMC key format string for fan speed (use with fan index).- See Also:
-
SMC_KEY_CPU_TEMP
-
SMC_KEY_CPU_VOLTAGE
-
SMC_KEYS_CPU_TEMP_AS
-
SMC_KEYS_GPU_TEMP_AS
-
SMC_KEY_CPU_VOLTAGE_AS
SMC key for CPU voltage (Apple Silicon).- See Also:
-
SMC_CMD_READ_BYTES
public static final byte SMC_CMD_READ_BYTESSMC command to read bytes.- See Also:
-
SMC_CMD_READ_KEYINFO
public static final byte SMC_CMD_READ_KEYINFOSMC command to read key info.- See Also:
-
KERNEL_INDEX_SMC
public static final int KERNEL_INDEX_SMCKernel index for SMC calls.- See Also:
-
-
Method Details
-
smcOpen
Open a connection to SMC.- Returns:
- The connection if successful, null if failure
-
smcClose
Close connection to SMC.- Parameters:
conn- The connection- Returns:
- 0 if successful, nonzero if failure
-
smcGetFloat
Get a value from SMC which is in a floating point datatype (SP78, FPE2, FLT)- Parameters:
conn- The connectionkey- The key to retrieve- Returns:
- Double representing the value
-
smcGetFirstFloat
Get the first positive value from a list of SMC keys.- Parameters:
conn- The connectionkeys- The keys to try in order- Returns:
- The first value greater than 0, or 0 if all keys fail
-
smcGetLong
Get a 64-bit integer value from SMC- Parameters:
conn- The connectionkey- The key to retrieve- Returns:
- Long representing the value
-
smcGetKeyInfo
public static int smcGetKeyInfo(IOKit.IOConnect conn, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Get cached keyInfo if it exists, or generate new keyInfo- Parameters:
conn- The connectioninputStructure- Key data inputoutputStructure- Key data output- Returns:
- 0 if successful, nonzero if failure
-
smcReadKey
Read a key from SMC- Parameters:
conn- The connectionkey- Key to readval- Structure to receive the result- Returns:
- 0 if successful, nonzero if failure
-
smcCall
public static int smcCall(IOKit.IOConnect conn, int index, IOKit.SMCKeyData inputStructure, IOKit.SMCKeyData outputStructure) Call SMC- Parameters:
conn- The connectionindex- Kernel indexinputStructure- Key data inputoutputStructure- Key data output- Returns:
- 0 if successful, nonzero if failure
-