metee
Loading...
Searching...
No Matches
metee.h File Reference

metee library API More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  _TEEHANDLE
 
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 struct _TEEHANDLE TEEHANDLE
 
typedef TEEHANDLEPTEEHANDLE
 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 }
 

Functions

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)
 
void TEEAPI TeeDisconnect (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)
 

Detailed Description

metee library API

Definition in file metee.h.

Macro Definition Documentation

◆ TEE_BUSY

#define TEE_BUSY   (TEE_ERROR_BASE + 9)

The device is busy

Definition at line 116 of file metee.h.

◆ TEE_CLIENT_NOT_FOUND

#define TEE_CLIENT_NOT_FOUND   (TEE_ERROR_BASE + 8)

The ME client is not present in the firmware

Definition at line 114 of file metee.h.

◆ TEE_DEVICE_NOT_FOUND

#define TEE_DEVICE_NOT_FOUND   (TEE_ERROR_BASE + 2)

The device is not in the system or is not working

Definition at line 102 of file metee.h.

◆ TEE_DEVICE_NOT_READY

#define TEE_DEVICE_NOT_READY   (TEE_ERROR_BASE + 3)

The device is not ready for the operation

Definition at line 104 of file metee.h.

◆ TEE_DISCONNECTED

#define TEE_DISCONNECTED   (TEE_ERROR_BASE + 10)

The ME client is not connected

Definition at line 118 of file metee.h.

◆ TEE_ERROR_BASE

#define TEE_ERROR_BASE   0x0000U

METEE ERROR BASE

Definition at line 96 of file metee.h.

◆ TEE_INSUFFICIENT_BUFFER

#define TEE_INSUFFICIENT_BUFFER   (TEE_ERROR_BASE + 11)

The buffer for read not big enough

Definition at line 120 of file metee.h.

◆ TEE_INTERNAL_ERROR

#define TEE_INTERNAL_ERROR   (TEE_ERROR_BASE + 1)

An internal error occurred in the library

Definition at line 100 of file metee.h.

◆ TEE_INVALID_PARAMETER

#define TEE_INVALID_PARAMETER   (TEE_ERROR_BASE + 4)

An invalid parameter was used in the call

Definition at line 106 of file metee.h.

◆ TEE_IS_SUCCESS

#define TEE_IS_SUCCESS ( Status)
Value:
(((TEESTATUS)(Status)) == TEE_SUCCESS)
uint16_t TEESTATUS
Definition metee.h:94
#define TEE_SUCCESS
Definition metee.h:98

Macro for successful operation result check

Definition at line 126 of file metee.h.

◆ TEE_NOTSUPPORTED

#define TEE_NOTSUPPORTED   (TEE_ERROR_BASE + 7)

The operation is not supported

Definition at line 112 of file metee.h.

◆ TEE_PERMISSION_DENIED

#define TEE_PERMISSION_DENIED   (TEE_ERROR_BASE + 12)

The user don't have permission for this operation

Definition at line 122 of file metee.h.

◆ TEE_SUCCESS

#define TEE_SUCCESS   (TEE_ERROR_BASE + 0)

METEE SUCCESS

Definition at line 98 of file metee.h.

◆ TEE_TIMEOUT

#define TEE_TIMEOUT   (TEE_ERROR_BASE + 6)

The operation has timed out

Definition at line 110 of file metee.h.

◆ TEE_UNABLE_TO_COMPLETE_OPERATION

#define TEE_UNABLE_TO_COMPLETE_OPERATION   (TEE_ERROR_BASE + 5)

It is not possible to complete the operation

Definition at line 108 of file metee.h.

◆ TEEHANDLE_ZERO

#define TEEHANDLE_ZERO   {0}

ZERO/NULL device handle

Definition at line 92 of file metee.h.

Typedef Documentation

◆ PTEEHANDLE

A type definition for pointer to TEEHANDLE.

Definition at line 87 of file metee.h.

◆ TEEHANDLE

typedef struct _TEEHANDLE TEEHANDLE

Structure to store connection data

◆ TEESTATUS

typedef uint16_t TEESTATUS

return status for API functions

Definition at line 94 of file metee.h.

Enumeration Type Documentation

◆ tee_log_level

log level

Enumerator
TEE_LOG_LEVEL_QUIET 

no log prints

TEE_LOG_LEVEL_ERROR 

error log prints

TEE_LOG_LEVEL_VERBOSE 

verbose log prints

Definition at line 66 of file metee.h.

Function Documentation

◆ GetDriverVersion()

TEESTATUS TEEAPI GetDriverVersion ( IN PTEEHANDLE handle,
IN OUT teeDriverVersion_t * driverVersion )

Obtains version of the TEE device driver Not implemented on Linux

Parameters
handleThe handle of the session.
driverVersionPointer to driver version struct
Returns
0 if successful, otherwise error code.

◆ TeeConnect()

TEESTATUS TEEAPI TeeConnect ( OUT PTEEHANDLE handle)

Connects to the TEE driver and starts a session

Parameters
handleA handle to the TEE device
Returns
0 if successful, otherwise error code

◆ TeeDisconnect()

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.

Parameters
handleThe handle of the session to close.

◆ TeeFWStatus()

TEESTATUS TEEAPI TeeFWStatus ( IN PTEEHANDLE handle,
IN uint32_t fwStatusNum,
OUT uint32_t * fwStatus )

Retrieves specified FW status register.

Parameters
handleThe handle of the session.
fwStatusNumThe FW status register number (0-5).
fwStatusThe memory to store obtained FW status.
Returns
0 if successful, otherwise error code.

◆ TeeGetDeviceHandle()

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

Parameters
handleThe handle of the session.
Returns
device handle

◆ TeeGetLogLevel()

uint32_t TEEAPI TeeGetLogLevel ( IN const PTEEHANDLE handle)

Retrieve current log level

Parameters
handleThe handle of the session.
Returns
current log level

◆ TeeInit()

TEESTATUS TEEAPI TeeInit ( IN OUT PTEEHANDLE handle,
IN const GUID * guid,
IN OPTIONAL const char * device )

Initializes a TEE connection

Parameters
handleA handle to the TEE device. All subsequent calls to the lib's functions must be with this handle
guidGUID of the FW client that want to start a session
deviceoptional device path, set NULL to use default
Returns
0 if successful, otherwise error code

◆ TeeInitHandle()

TEESTATUS TEEAPI TeeInitHandle ( IN OUT PTEEHANDLE handle,
IN const GUID * guid,
IN const TEE_DEVICE_HANDLE device_handle )

Initializes a TEE connection

Parameters
handleA handle to the TEE device. All subsequent calls to the lib's functions must be with this handle
guidGUID of the FW client that want to start a session
device_handleopen file handle
Returns
0 if successful, otherwise error code

◆ TeeRead()

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.

Parameters
handleThe handle of the session to read from.
bufferA pointer to a buffer that receives the data read from the TEE device.
bufferSizeThe number of bytes to be read.
pNumOfBytesReadA pointer to the variable that receives the number of bytes read, ignored if set to NULL.
timeoutThe timeout to complete read in milliseconds, zero for infinite
Returns
0 if successful, otherwise error code

◆ TeeSetLogLevel()

uint32_t TEEAPI TeeSetLogLevel ( IN PTEEHANDLE handle,
IN uint32_t log_level )

Set log level

Parameters
handleThe handle of the session.
log_levellog level to set
Returns
previous log level

◆ TeeWrite()

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.

Parameters
handleThe handle of the session to write to.
bufferA pointer to the buffer containing the data to be written to the TEE device.
bufferSizeThe number of bytes to be written.
numberOfBytesWrittenA pointer to the variable that receives the number of bytes written, ignored if set to NULL.
timeoutThe timeout to complete write in milliseconds, zero for infinite
Returns
0 if successful, otherwise error code