|
metee
|
metee library API More...
#include <stddef.h>#include <stdint.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | _TEEHANDLE |
| struct | tee_device_address |
| struct | teeDriverVersion_t |
Macros | |
| #define | TEEHANDLE_ZERO {0} |
| #define | TEE_ERROR_BASE 0x0000U |
| #define | TEE_SUCCESS (TEE_ERROR_BASE + 0) |
| #define | TEE_INTERNAL_ERROR (TEE_ERROR_BASE + 1) |
| #define | TEE_DEVICE_NOT_FOUND (TEE_ERROR_BASE + 2) |
| #define | TEE_DEVICE_NOT_READY (TEE_ERROR_BASE + 3) |
| #define | TEE_INVALID_PARAMETER (TEE_ERROR_BASE + 4) |
| #define | TEE_UNABLE_TO_COMPLETE_OPERATION (TEE_ERROR_BASE + 5) |
| #define | TEE_TIMEOUT (TEE_ERROR_BASE + 6) |
| #define | TEE_NOTSUPPORTED (TEE_ERROR_BASE + 7) |
| #define | TEE_CLIENT_NOT_FOUND (TEE_ERROR_BASE + 8) |
| #define | TEE_BUSY (TEE_ERROR_BASE + 9) |
| #define | TEE_DISCONNECTED (TEE_ERROR_BASE + 10) |
| #define | TEE_INSUFFICIENT_BUFFER (TEE_ERROR_BASE + 11) |
| #define | TEE_PERMISSION_DENIED (TEE_ERROR_BASE + 12) |
| #define | TEE_IS_SUCCESS(Status) |
Typedefs | |
| typedef void(* | TeeLogCallback) (bool is_error, const char *fmt,...) |
| typedef void(* | TeeLogCallback2) (bool is_error, const char *msg) |
| typedef struct _TEEHANDLE | TEEHANDLE |
| typedef TEEHANDLE * | PTEEHANDLE |
| A type definition for pointer to TEEHANDLE. | |
| typedef uint16_t | TEESTATUS |
Enumerations | |
| enum | tee_log_level { TEE_LOG_LEVEL_QUIET = 0 , TEE_LOG_LEVEL_ERROR = 1 , TEE_LOG_LEVEL_VERBOSE = 2 , TEE_LOG_LEVEL_MAX = 3 } |
Functions | |
| TEESTATUS TEEAPI | TeeInitFull (IN OUT PTEEHANDLE handle, IN const GUID *guid, IN const struct tee_device_address device, IN uint32_t log_level, IN OPTIONAL TeeLogCallback log_callback) |
| TEESTATUS TEEAPI | TeeInitFull2 (IN OUT PTEEHANDLE handle, IN const GUID *guid, IN const struct tee_device_address device, IN uint32_t log_level, IN OPTIONAL TeeLogCallback2 log_callback) |
| TEESTATUS TEEAPI | TeeInit (IN OUT PTEEHANDLE handle, IN const GUID *guid, IN OPTIONAL const char *device) |
| TEESTATUS TEEAPI | TeeInitHandle (IN OUT PTEEHANDLE handle, IN const GUID *guid, IN const TEE_DEVICE_HANDLE device_handle) |
| TEESTATUS TEEAPI | TeeConnect (OUT PTEEHANDLE handle) |
| TEESTATUS TEEAPI | TeeRead (IN PTEEHANDLE handle, IN OUT void *buffer, IN size_t bufferSize, OUT OPTIONAL size_t *pNumOfBytesRead, IN OPTIONAL uint32_t timeout) |
| TEESTATUS TEEAPI | TeeWrite (IN PTEEHANDLE handle, IN const void *buffer, IN size_t bufferSize, OUT OPTIONAL size_t *numberOfBytesWritten, IN OPTIONAL uint32_t timeout) |
| TEESTATUS TEEAPI | TeeFWStatus (IN PTEEHANDLE handle, IN uint32_t fwStatusNum, OUT uint32_t *fwStatus) |
| TEESTATUS TEEAPI | TeeGetTRC (IN PTEEHANDLE handle, OUT uint32_t *trc_val) |
| void TEEAPI | TeeDisconnect (IN PTEEHANDLE handle) |
| void TEEAPI | TeeCancelIO (IN PTEEHANDLE handle) |
| TEE_DEVICE_HANDLE TEEAPI | TeeGetDeviceHandle (IN PTEEHANDLE handle) |
| TEESTATUS TEEAPI | GetDriverVersion (IN PTEEHANDLE handle, IN OUT teeDriverVersion_t *driverVersion) |
| uint32_t TEEAPI | TeeSetLogLevel (IN PTEEHANDLE handle, IN uint32_t log_level) |
| uint32_t TEEAPI | TeeGetLogLevel (IN const PTEEHANDLE handle) |
| TEESTATUS TEEAPI | TeeSetLogCallback (IN const PTEEHANDLE handle, TeeLogCallback log_callback) |
| TEESTATUS TEEAPI | TeeSetLogCallback2 (IN const PTEEHANDLE handle, TeeLogCallback2 log_callback) |
| uint32_t TEEAPI | TeeGetMaxMsgLen (IN const PTEEHANDLE handle) |
| uint8_t TEEAPI | TeeGetProtocolVer (IN const PTEEHANDLE handle) |
| TEESTATUS TEEAPI | TeeGetKind (IN PTEEHANDLE handle, IN OUT char *kind, IN OUT size_t *kindSize) |
metee library API
Definition in file metee.h.
| #define TEE_BUSY (TEE_ERROR_BASE + 9) |
| #define TEE_CLIENT_NOT_FOUND (TEE_ERROR_BASE + 8) |
| #define TEE_DEVICE_NOT_FOUND (TEE_ERROR_BASE + 2) |
| #define TEE_DEVICE_NOT_READY (TEE_ERROR_BASE + 3) |
| #define TEE_DISCONNECTED (TEE_ERROR_BASE + 10) |
| #define TEE_INSUFFICIENT_BUFFER (TEE_ERROR_BASE + 11) |
| #define TEE_INTERNAL_ERROR (TEE_ERROR_BASE + 1) |
| #define TEE_INVALID_PARAMETER (TEE_ERROR_BASE + 4) |
| #define TEE_IS_SUCCESS | ( | Status | ) |
Macro for successful operation result check
| #define TEE_NOTSUPPORTED (TEE_ERROR_BASE + 7) |
| #define TEE_PERMISSION_DENIED (TEE_ERROR_BASE + 12) |
| #define TEE_SUCCESS (TEE_ERROR_BASE + 0) |
| #define TEE_TIMEOUT (TEE_ERROR_BASE + 6) |
| #define TEE_UNABLE_TO_COMPLETE_OPERATION (TEE_ERROR_BASE + 5) |
| typedef TEEHANDLE* PTEEHANDLE |
| typedef struct _TEEHANDLE TEEHANDLE |
Structure to store connection data
| typedef void(* TeeLogCallback) (bool is_error, const char *fmt,...) |
| typedef void(* TeeLogCallback2) (bool is_error, const char *msg) |
| enum tee_log_level |
| TEESTATUS TEEAPI GetDriverVersion | ( | IN PTEEHANDLE | handle, |
| IN OUT teeDriverVersion_t * | driverVersion ) |
Obtains version of the TEE device driver Not implemented on Linux
| handle | The handle of the session. |
| driverVersion | Pointer to driver version struct |
| void TEEAPI TeeCancelIO | ( | IN PTEEHANDLE | handle | ) |
Try to stop all in-process reads and writes
| handle | The handle of the session |
| TEESTATUS TEEAPI TeeConnect | ( | OUT PTEEHANDLE | handle | ) |
Connects to the TEE driver and starts a session
| handle | A handle to the TEE device |
| void TEEAPI TeeDisconnect | ( | IN PTEEHANDLE | 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.
| handle | The handle of the session to close. |
| TEESTATUS TEEAPI TeeFWStatus | ( | IN PTEEHANDLE | handle, |
| IN uint32_t | fwStatusNum, | ||
| OUT uint32_t * | fwStatus ) |
Retrieves specified FW status register.
| handle | The handle of the session. |
| fwStatusNum | The FW status register number (0-5). |
| fwStatus | The memory to store obtained FW status. |
| TEE_DEVICE_HANDLE TEEAPI TeeGetDeviceHandle | ( | IN PTEEHANDLE | handle | ) |
Returns handle of TEE device Obtains HECI device handle on Windows and mei device file descriptor on Linux
| handle | The handle of the session. |
| TEESTATUS TEEAPI TeeGetKind | ( | IN PTEEHANDLE | handle, |
| IN OUT char * | kind, | ||
| IN OUT size_t * | kindSize ) |
Obtains kind of the TEE device
| handle | The handle of the session. |
| kind | Buffer to fill with device kind null terminated string, may be NULL. |
| kindSize | Pointer to kind buffer size in bytes, updated to number of bytes filled in buffer, including null character, on out. If buffer is NULL, required size is returned anyway. |
| uint32_t TEEAPI TeeGetLogLevel | ( | IN const PTEEHANDLE | handle | ) |
Retrieve current log level
| handle | The handle of the session. |
| uint32_t TEEAPI TeeGetMaxMsgLen | ( | IN const PTEEHANDLE | handle | ) |
Retrieve client maximum message length (MTU)
| handle | The handle of the session. |
| uint8_t TEEAPI TeeGetProtocolVer | ( | IN const PTEEHANDLE | handle | ) |
Retrieve client protocol version
| handle | The handle of the session. |
| TEESTATUS TEEAPI TeeGetTRC | ( | IN PTEEHANDLE | handle, |
| OUT uint32_t * | trc_val ) |
Retrieves TRC register.
| handle | The handle of the session. |
| trc_val | The memory to store obtained TRC value. |
| TEESTATUS TEEAPI TeeInit | ( | IN OUT PTEEHANDLE | handle, |
| IN const GUID * | guid, | ||
| IN OPTIONAL const char * | device ) |
Initializes a TEE connection
| handle | A handle to the TEE device. All subsequent calls to the lib's functions must be with this handle |
| guid | GUID of the FW client that want to start a session |
| device | optional device path, set NULL to use default |
| TEESTATUS TEEAPI TeeInitFull | ( | IN OUT PTEEHANDLE | handle, |
| IN const GUID * | guid, | ||
| IN const struct tee_device_address | device, | ||
| IN uint32_t | log_level, | ||
| IN OPTIONAL TeeLogCallback | log_callback ) |
Initializes a TEE connection
| handle | A handle to the TEE device. All subsequent calls to the lib's functions must be with this handle |
| guid | GUID of the FW client that want to start a session |
| device | device address structure |
| log_level | log level to set (from enum tee_log_level) |
| log_callback | pointer to function to run for log write, set NULL to use built-in function |
| TEESTATUS TEEAPI TeeInitFull2 | ( | IN OUT PTEEHANDLE | handle, |
| IN const GUID * | guid, | ||
| IN const struct tee_device_address | device, | ||
| IN uint32_t | log_level, | ||
| IN OPTIONAL TeeLogCallback2 | log_callback ) |
Initializes a TEE connection
| handle | A handle to the TEE device. All subsequent calls to the lib's functions must be with this handle |
| guid | GUID of the FW client that want to start a session |
| device | device address structure |
| log_level | log level to set (from enum tee_log_level) |
| log_callback | pointer to function to run for log write, set NULL to use built-in function |
| TEESTATUS TEEAPI TeeInitHandle | ( | IN OUT PTEEHANDLE | handle, |
| IN const GUID * | guid, | ||
| IN const TEE_DEVICE_HANDLE | device_handle ) |
Initializes a TEE connection
| handle | A handle to the TEE device. All subsequent calls to the lib's functions must be with this handle |
| guid | GUID of the FW client that want to start a session |
| device_handle | open file handle |
| TEESTATUS TEEAPI TeeRead | ( | IN PTEEHANDLE | 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.
| handle | The handle of the session to read from. |
| buffer | A pointer to a buffer that receives the data read from the TEE device. |
| bufferSize | The number of bytes to be read. |
| pNumOfBytesRead | A pointer to the variable that receives the number of bytes read, ignored if set to NULL. |
| timeout | The timeout to complete read in milliseconds, zero for infinite |
| TEESTATUS TEEAPI TeeSetLogCallback | ( | IN const PTEEHANDLE | handle, |
| TeeLogCallback | log_callback ) |
Set log callback
| handle | The handle of the session. |
| log_callback | pointer to function to run for log write, set NULL to use built-in function |
| TEESTATUS TEEAPI TeeSetLogCallback2 | ( | IN const PTEEHANDLE | handle, |
| TeeLogCallback2 | log_callback ) |
Set log callback
| handle | The handle of the session. |
| log_callback | pointer to function to run for log write, set NULL to use built-in function |
| uint32_t TEEAPI TeeSetLogLevel | ( | IN PTEEHANDLE | handle, |
| IN uint32_t | log_level ) |
Set log level
| handle | The handle of the session. |
| log_level | log level to set |
| TEESTATUS TEEAPI TeeWrite | ( | IN PTEEHANDLE | 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.
| handle | The handle of the session to write to. |
| buffer | A pointer to the buffer containing the data to be written to the TEE device. |
| bufferSize | The number of bytes to be written. |
| numberOfBytesWritten | A pointer to the variable that receives the number of bytes written, ignored if set to NULL. |
| timeout | The timeout to complete write in milliseconds, zero for infinite |