Add support for CPU/GPU device temperature and fanspeed using iokit (Apple)
This commit is contained in:
125
include/ext_iokit.h
Normal file
125
include/ext_iokit.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _EXT_IOKIT_H
|
||||
#define _EXT_IOKIT_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
// Apple SMC Keys
|
||||
#define HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT "SGHT"
|
||||
#define HM_IOKIT_SMC_CPU_PROXIMITY "TC0P"
|
||||
#define HM_IOKIT_SMC_GPU_PROXIMITY "TG0P"
|
||||
#define HM_IOKIT_SMC_PECI_GPU "TCGC"
|
||||
|
||||
#define KERNEL_INDEX_SMC 2
|
||||
|
||||
#define DATATYPE_FPE2 "fpe2"
|
||||
#define DATATYPE_UINT8 "ui8 "
|
||||
#define DATATYPE_UINT16 "ui16"
|
||||
#define DATATYPE_UINT32 "ui32"
|
||||
#define DATATYPE_SP78 "sp78"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SMC_CMD_READ_BYTES = 5,
|
||||
SMC_CMD_WRITE_BYTES = 6,
|
||||
SMC_CMD_READ_INDEX = 8,
|
||||
SMC_CMD_READ_KEYINFO = 9,
|
||||
SMC_CMD_READ_PLIMIT = 11,
|
||||
SMC_CMD_READ_VERS = 12
|
||||
|
||||
} SMCCommands_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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 // __APPLE__
|
||||
|
||||
typedef int HM_ADAPTER_IOKIT;
|
||||
|
||||
typedef void *IOKIT_LIB;
|
||||
|
||||
typedef struct hm_iokit_lib
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
io_connect_t conn;
|
||||
#endif // __APPLE__
|
||||
|
||||
} hm_iokit_lib_t;
|
||||
|
||||
typedef hm_iokit_lib_t IOKIT_PTR;
|
||||
|
||||
UInt32 hm_IOKIT_strtoul (char *str, int size, int base);
|
||||
void hm_IOKIT_ultostr (char *str, UInt32 val);
|
||||
kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn);
|
||||
kern_return_t hm_IOKIT_SMCClose (io_connect_t conn);
|
||||
kern_return_t hm_IOKIT_SMCCall (int index, SMCKeyData_t *inData, SMCKeyData_t *outData, io_connect_t conn);
|
||||
kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t conn);
|
||||
int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx);
|
||||
int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp);
|
||||
bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret);
|
||||
int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed);
|
||||
bool iokit_init (void *hashcat_ctx);
|
||||
bool iokit_close (void *hashcat_ctx);
|
||||
|
||||
#endif // _EXT_IOKIT_H
|
||||
@@ -611,7 +611,11 @@ typedef enum user_options_defaults
|
||||
DEBUG_MODE = 0,
|
||||
FORCE = false,
|
||||
HWMON_DISABLE = false,
|
||||
#if defined (__APPLE__)
|
||||
HWMON_TEMP_ABORT = 100,
|
||||
#else
|
||||
HWMON_TEMP_ABORT = 90,
|
||||
#endif
|
||||
HASH_INFO = false,
|
||||
HASH_MODE = 0,
|
||||
HCCAPX_MESSAGE_PAIR = 0,
|
||||
@@ -1589,6 +1593,7 @@ typedef struct backend_ctx
|
||||
bool need_nvml;
|
||||
bool need_nvapi;
|
||||
bool need_sysfs;
|
||||
bool need_iokit;
|
||||
|
||||
int comptime;
|
||||
|
||||
@@ -1632,6 +1637,7 @@ typedef enum kernel_workload
|
||||
#include "ext_nvapi.h"
|
||||
#include "ext_nvml.h"
|
||||
#include "ext_sysfs.h"
|
||||
#include "ext_iokit.h"
|
||||
|
||||
typedef struct hm_attrs
|
||||
{
|
||||
@@ -1639,6 +1645,7 @@ typedef struct hm_attrs
|
||||
HM_ADAPTER_NVML nvml;
|
||||
HM_ADAPTER_NVAPI nvapi;
|
||||
HM_ADAPTER_SYSFS sysfs;
|
||||
HM_ADAPTER_IOKIT iokit;
|
||||
|
||||
int od_version;
|
||||
|
||||
@@ -1663,6 +1670,7 @@ typedef struct hwmon_ctx
|
||||
void *hm_nvml;
|
||||
void *hm_nvapi;
|
||||
void *hm_sysfs;
|
||||
void *hm_iokit;
|
||||
|
||||
hm_attrs_t *hm_device;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user