.TH "metee.h" 3 "Sat Mar 2 2024 13:33:21" "metee" \" -*- nroff -*- .ad l .nh .SH NAME metee.h \- metee library API .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fB_TEEHANDLE\fP" .br .ti -1c .RI "struct \fBtee_device_address\fP" .br .ti -1c .RI "struct \fBteeDriverVersion_t\fP" .br .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBTEEHANDLE_ZERO\fP {0}" .br .ti -1c .RI "#define \fBTEE_ERROR_BASE\fP 0x0000U" .br .ti -1c .RI "#define \fBTEE_SUCCESS\fP (\fBTEE_ERROR_BASE\fP + 0)" .br .ti -1c .RI "#define \fBTEE_INTERNAL_ERROR\fP (\fBTEE_ERROR_BASE\fP + 1)" .br .ti -1c .RI "#define \fBTEE_DEVICE_NOT_FOUND\fP (\fBTEE_ERROR_BASE\fP + 2)" .br .ti -1c .RI "#define \fBTEE_DEVICE_NOT_READY\fP (\fBTEE_ERROR_BASE\fP + 3)" .br .ti -1c .RI "#define \fBTEE_INVALID_PARAMETER\fP (\fBTEE_ERROR_BASE\fP + 4)" .br .ti -1c .RI "#define \fBTEE_UNABLE_TO_COMPLETE_OPERATION\fP (\fBTEE_ERROR_BASE\fP + 5)" .br .ti -1c .RI "#define \fBTEE_TIMEOUT\fP (\fBTEE_ERROR_BASE\fP + 6)" .br .ti -1c .RI "#define \fBTEE_NOTSUPPORTED\fP (\fBTEE_ERROR_BASE\fP + 7)" .br .ti -1c .RI "#define \fBTEE_CLIENT_NOT_FOUND\fP (\fBTEE_ERROR_BASE\fP + 8)" .br .ti -1c .RI "#define \fBTEE_BUSY\fP (\fBTEE_ERROR_BASE\fP + 9)" .br .ti -1c .RI "#define \fBTEE_DISCONNECTED\fP (\fBTEE_ERROR_BASE\fP + 10)" .br .ti -1c .RI "#define \fBTEE_INSUFFICIENT_BUFFER\fP (\fBTEE_ERROR_BASE\fP + 11)" .br .ti -1c .RI "#define \fBTEE_PERMISSION_DENIED\fP (\fBTEE_ERROR_BASE\fP + 12)" .br .ti -1c .RI "#define \fBTEE_IS_SUCCESS\fP(Status) (((\fBTEESTATUS\fP)(Status)) == \fBTEE_SUCCESS\fP)" .br .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef void(* \fBTeeLogCallback\fP) (bool is_error, const char *fmt,\&.\&.\&.)" .br .ti -1c .RI "typedef struct \fB_TEEHANDLE\fP \fBTEEHANDLE\fP" .br .ti -1c .RI "typedef \fBTEEHANDLE\fP * \fBPTEEHANDLE\fP" .br .RI "A type definition for pointer to TEEHANDLE\&. " .ti -1c .RI "typedef uint16_t \fBTEESTATUS\fP" .br .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBtee_log_level\fP { \fBTEE_LOG_LEVEL_QUIET\fP = 0, \fBTEE_LOG_LEVEL_ERROR\fP = 1, \fBTEE_LOG_LEVEL_VERBOSE\fP = 2, \fBTEE_LOG_LEVEL_MAX\fP = 3 }" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeInitFull\fP (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID *guid, IN const struct \fBtee_device_address\fP device, IN uint32_t log_level, IN OPTIONAL \fBTeeLogCallback\fP log_callback)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeInit\fP (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID *guid, IN OPTIONAL const char *device)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeInitHandle\fP (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID *guid, IN const TEE_DEVICE_HANDLE device_handle)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeConnect\fP (OUT \fBPTEEHANDLE\fP handle)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeRead\fP (IN \fBPTEEHANDLE\fP handle, IN OUT void *buffer, IN size_t bufferSize, OUT OPTIONAL size_t *pNumOfBytesRead, IN OPTIONAL uint32_t timeout)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeWrite\fP (IN \fBPTEEHANDLE\fP handle, IN const void *buffer, IN size_t bufferSize, OUT OPTIONAL size_t *numberOfBytesWritten, IN OPTIONAL uint32_t timeout)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeFWStatus\fP (IN \fBPTEEHANDLE\fP handle, IN uint32_t fwStatusNum, OUT uint32_t *fwStatus)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeGetTRC\fP (IN \fBPTEEHANDLE\fP handle, OUT uint32_t *trc_val)" .br .ti -1c .RI "void TEEAPI \fBTeeDisconnect\fP (IN \fBPTEEHANDLE\fP handle)" .br .ti -1c .RI "TEE_DEVICE_HANDLE TEEAPI \fBTeeGetDeviceHandle\fP (IN \fBPTEEHANDLE\fP handle)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBGetDriverVersion\fP (IN \fBPTEEHANDLE\fP handle, IN OUT \fBteeDriverVersion_t\fP *driverVersion)" .br .ti -1c .RI "uint32_t TEEAPI \fBTeeSetLogLevel\fP (IN \fBPTEEHANDLE\fP handle, IN uint32_t log_level)" .br .ti -1c .RI "uint32_t TEEAPI \fBTeeGetLogLevel\fP (IN const \fBPTEEHANDLE\fP handle)" .br .ti -1c .RI "\fBTEESTATUS\fP TEEAPI \fBTeeSetLogCallback\fP (IN const \fBPTEEHANDLE\fP handle, \fBTeeLogCallback\fP log_callback)" .br .in -1c .SH "Detailed Description" .PP metee library API .PP Definition in file \fBmetee\&.h\fP\&. .SH "Macro Definition Documentation" .PP .SS "#define TEE_BUSY (\fBTEE_ERROR_BASE\fP + 9)" The device is busy .PP Definition at line \fB141\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_CLIENT_NOT_FOUND (\fBTEE_ERROR_BASE\fP + 8)" The ME client is not present in the firmware .PP Definition at line \fB139\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_DEVICE_NOT_FOUND (\fBTEE_ERROR_BASE\fP + 2)" The device is not in the system or is not working .PP Definition at line \fB127\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_DEVICE_NOT_READY (\fBTEE_ERROR_BASE\fP + 3)" The device is not ready for the operation .PP Definition at line \fB129\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_DISCONNECTED (\fBTEE_ERROR_BASE\fP + 10)" The ME client is not connected .PP Definition at line \fB143\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_ERROR_BASE 0x0000U" METEE ERROR BASE .PP Definition at line \fB121\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_INSUFFICIENT_BUFFER (\fBTEE_ERROR_BASE\fP + 11)" The buffer for read not big enough .br .PP Definition at line \fB145\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_INTERNAL_ERROR (\fBTEE_ERROR_BASE\fP + 1)" An internal error occurred in the library .PP Definition at line \fB125\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_INVALID_PARAMETER (\fBTEE_ERROR_BASE\fP + 4)" An invalid parameter was used in the call .PP Definition at line \fB131\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_IS_SUCCESS(Status) (((\fBTEESTATUS\fP)(Status)) == \fBTEE_SUCCESS\fP)" Macro for successful operation result check .PP Definition at line \fB151\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_NOTSUPPORTED (\fBTEE_ERROR_BASE\fP + 7)" The operation is not supported .PP Definition at line \fB137\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_PERMISSION_DENIED (\fBTEE_ERROR_BASE\fP + 12)" The user don't have permission for this operation .br .PP Definition at line \fB147\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_SUCCESS (\fBTEE_ERROR_BASE\fP + 0)" METEE SUCCESS .PP Definition at line \fB123\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_TIMEOUT (\fBTEE_ERROR_BASE\fP + 6)" The operation has timed out .PP Definition at line \fB135\fP of file \fBmetee\&.h\fP\&. .SS "#define TEE_UNABLE_TO_COMPLETE_OPERATION (\fBTEE_ERROR_BASE\fP + 5)" It is not possible to complete the operation .PP Definition at line \fB133\fP of file \fBmetee\&.h\fP\&. .SS "#define TEEHANDLE_ZERO {0}" ZERO/NULL device handle .PP Definition at line \fB117\fP of file \fBmetee\&.h\fP\&. .SH "Typedef Documentation" .PP .SS "typedestruct \fB_TEEHANDLE\fP * \fBPTEEHANDLE\fP" .PP A type definition for pointer to TEEHANDLE\&. .PP Definition at line \fB94\fP of file \fBmetee\&.h\fP\&. .SS "typedef struct \fB_TEEHANDLE\fP \fBTEEHANDLE\fP" Structure to store connection data .SS "typedef void(* TeeLogCallback) (bool is_error, const char *fmt,\&.\&.\&.)" log callback function format .PP Definition at line \fB76\fP of file \fBmetee\&.h\fP\&. .SS "typedef uint16_t \fBTEESTATUS\fP" return status for API functions .PP Definition at line \fB119\fP of file \fBmetee\&.h\fP\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBtee_log_level\fP" log level .PP \fBEnumerator\fP .in +1c .TP \fB\fITEE_LOG_LEVEL_QUIET \fP\fP no log prints .TP \fB\fITEE_LOG_LEVEL_ERROR \fP\fP error log prints .TP \fB\fITEE_LOG_LEVEL_VERBOSE \fP\fP verbose log prints .TP \fB\fITEE_LOG_LEVEL_MAX \fP\fP upper sentinel .PP Definition at line \fB67\fP of file \fBmetee\&.h\fP\&. .SH "Function Documentation" .PP .SS "\fBTEESTATUS\fP TEEAPI GetDriverVersion (IN \fBPTEEHANDLE\fP handle, IN OUT \fBteeDriverVersion_t\fP * driverVersion)" Obtains version of the TEE device driver Not implemented on Linux .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .br \fIdriverVersion\fP Pointer to driver version struct .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code\&. .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeConnect (OUT \fBPTEEHANDLE\fP handle)" Connects to the TEE driver and starts a session .PP \fBParameters\fP .RS 4 \fIhandle\fP A handle to the TEE device .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SS "void TEEAPI TeeDisconnect (IN \fBPTEEHANDLE\fP handle)" Closes the session to TEE driver Make sure that you call this function as soon as you are done with the device, as other clients might be blocked until the session is closed\&. .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session to close\&. .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeFWStatus (IN \fBPTEEHANDLE\fP handle, IN uint32_t fwStatusNum, OUT uint32_t * fwStatus)" Retrieves specified FW status register\&. .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .br \fIfwStatusNum\fP The FW status register number (0-5)\&. .br \fIfwStatus\fP The memory to store obtained FW status\&. .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code\&. .RE .PP .SS "TEE_DEVICE_HANDLE TEEAPI TeeGetDeviceHandle (IN \fBPTEEHANDLE\fP handle)" Returns handle of TEE device Obtains HECI device handle on Windows and mei device file descriptor on Linux .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .RE .PP \fBReturns\fP .RS 4 device handle .RE .PP .SS "uint32_t TEEAPI TeeGetLogLevel (IN const \fBPTEEHANDLE\fP handle)" Retrieve current log level .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .RE .PP \fBReturns\fP .RS 4 current log level .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeGetTRC (IN \fBPTEEHANDLE\fP handle, OUT uint32_t * trc_val)" Retrieves TRC register\&. .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .br \fItrc_val\fP The memory to store obtained TRC value\&. .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code\&. .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeInit (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID * guid, IN OPTIONAL const char * device)" Initializes a TEE connection .PP \fBParameters\fP .RS 4 \fIhandle\fP A handle to the TEE device\&. All subsequent calls to the lib's functions must be with this handle .br \fIguid\fP GUID of the FW client that want to start a session .br \fIdevice\fP optional device path, set NULL to use default .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeInitFull (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID * guid, IN const struct \fBtee_device_address\fP device, IN uint32_t log_level, IN OPTIONAL \fBTeeLogCallback\fP log_callback)" Initializes a TEE connection .PP \fBParameters\fP .RS 4 \fIhandle\fP A handle to the TEE device\&. All subsequent calls to the lib's functions must be with this handle .br \fIguid\fP GUID of the FW client that want to start a session .br \fIdevice\fP device address structure .br \fIlog_level\fP log level to set (from enum tee_log_level) .br \fIlog_callback\fP pointer to function to run for log write, set NULL to use built-in function .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeInitHandle (IN OUT \fBPTEEHANDLE\fP handle, IN const GUID * guid, IN const TEE_DEVICE_HANDLE device_handle)" Initializes a TEE connection .PP \fBParameters\fP .RS 4 \fIhandle\fP A handle to the TEE device\&. All subsequent calls to the lib's functions must be with this handle .br \fIguid\fP GUID of the FW client that want to start a session .br \fIdevice_handle\fP open file handle .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeRead (IN \fBPTEEHANDLE\fP handle, IN OUT void * buffer, IN size_t bufferSize, OUT OPTIONAL size_t * pNumOfBytesRead, IN OPTIONAL uint32_t timeout)" Read data from the TEE device synchronously\&. .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session to read from\&. .br \fIbuffer\fP A pointer to a buffer that receives the data read from the TEE device\&. .br \fIbufferSize\fP The number of bytes to be read\&. .br \fIpNumOfBytesRead\fP A pointer to the variable that receives the number of bytes read, ignored if set to NULL\&. .br \fItimeout\fP The timeout to complete read in milliseconds, zero for infinite .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeSetLogCallback (IN const \fBPTEEHANDLE\fP handle, \fBTeeLogCallback\fP log_callback)" Set log callback .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .br \fIlog_callback\fP pointer to function to run for log write, set NULL to use built-in function .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code\&. .RE .PP .SS "uint32_t TEEAPI TeeSetLogLevel (IN \fBPTEEHANDLE\fP handle, IN uint32_t log_level)" Set log level .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session\&. .br \fIlog_level\fP log level to set .RE .PP \fBReturns\fP .RS 4 previous log level .RE .PP .SS "\fBTEESTATUS\fP TEEAPI TeeWrite (IN \fBPTEEHANDLE\fP handle, IN const void * buffer, IN size_t bufferSize, OUT OPTIONAL size_t * numberOfBytesWritten, IN OPTIONAL uint32_t timeout)" Writes the specified buffer to the TEE device synchronously\&. .PP \fBParameters\fP .RS 4 \fIhandle\fP The handle of the session to write to\&. .br \fIbuffer\fP A pointer to the buffer containing the data to be written to the TEE device\&. .br \fIbufferSize\fP The number of bytes to be written\&. .br \fInumberOfBytesWritten\fP A pointer to the variable that receives the number of bytes written, ignored if set to NULL\&. .br \fItimeout\fP The timeout to complete write in milliseconds, zero for infinite .RE .PP \fBReturns\fP .RS 4 0 if successful, otherwise error code .RE .PP .SH "Author" .PP Generated automatically by Doxygen for metee from the source code\&.