---
name: "metee.h"
section: "3"
platform: "linux"
package: "intel-metee"
version: "6.2.6-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/metee.h"
---

# metee.h(3)

metee library API

## NAME

metee.h - metee library API

## SYNOPSIS

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

### 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)\

## Detailed Description

metee library API

Definition in file **metee.h**.

## Macro Definition Documentation

### #define TEE\_BUSY (TEE\_ERROR\_BASE + 9)

The device is busy

Definition at line **190** of file **metee.h**.

### #define TEE\_CLIENT\_NOT\_FOUND (TEE\_ERROR\_BASE + 8)

The ME client is not present in the firmware

Definition at line **188** of file **metee.h**.

### #define TEE\_DEVICE\_NOT\_FOUND (TEE\_ERROR\_BASE + 2)

The device is not in the system or is not working

Definition at line **176** of file **metee.h**.

### #define TEE\_DEVICE\_NOT\_READY (TEE\_ERROR\_BASE + 3)

The device is not ready for the operation

Definition at line **178** of file **metee.h**.

### #define TEE\_DISCONNECTED (TEE\_ERROR\_BASE + 10)

The ME client is not connected

Definition at line **192** of file **metee.h**.

### #define TEE\_ERROR\_BASE 0x0000U

METEE ERROR BASE

Definition at line **170** of file **metee.h**.

### #define TEE\_INSUFFICIENT\_BUFFER (TEE\_ERROR\_BASE + 11)

The buffer for read not big enough

Definition at line **194** of file **metee.h**.

### #define TEE\_INTERNAL\_ERROR (TEE\_ERROR\_BASE + 1)

An internal error occurred in the library

Definition at line **174** of file **metee.h**.

### #define TEE\_INVALID\_PARAMETER (TEE\_ERROR\_BASE + 4)

An invalid parameter was used in the call

Definition at line **180** of file **metee.h**.

### #define TEE\_IS\_SUCCESS( Status)

**Value:**

```
(((TEESTATUS)(Status)) == TEE_SUCCESS)
```

Macro for successful operation result check

Definition at line **200** of file **metee.h**.

### #define TEE\_NOTSUPPORTED (TEE\_ERROR\_BASE + 7)

The operation is not supported

Definition at line **186** of file **metee.h**.

### #define TEE\_PERMISSION\_DENIED (TEE\_ERROR\_BASE + 12)

The user don't have permission for this operation

Definition at line **196** of file **metee.h**.

### #define TEE\_SUCCESS (TEE\_ERROR\_BASE + 0)

METEE SUCCESS

Definition at line **172** of file **metee.h**.

### #define TEE\_TIMEOUT (TEE\_ERROR\_BASE + 6)

The operation has timed out

Definition at line **184** of file **metee.h**.

### #define TEE\_UNABLE\_TO\_COMPLETE\_OPERATION (TEE\_ERROR\_BASE + 5)

It is not possible to complete the operation

Definition at line **182** of file **metee.h**.

### #define TEEHANDLE\_ZERO {0}

ZERO/NULL device handle

Definition at line **166** of file **metee.h**.

## Typedef Documentation

### typedef TEEHANDLE\* PTEEHANDLE

A type definition for pointer to **TEEHANDLE**.

Definition at line **125** of file **metee.h**.

### typedef struct \_TEEHANDLE TEEHANDLE

Structure to store connection data

### typedef void(\*) TeeLogCallback(bool is\_error, const char \*fmt,...)

log callback function format

**Deprecated**

Since version 6.0

Definition at line **100** of file **metee.h**.

### typedef void(\*) TeeLogCallback2(bool is\_error, const char \*msg)

log callback function format

Definition at line **104** of file **metee.h**.

### typedef uint16\_t TEESTATUS

return status for API functions

Definition at line **168** of file **metee.h**.

## Enumeration Type Documentation

### enum 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

- ***TEE\_LOG\_LEVEL\_MAX***

  upper sentinel

Definition at line **90** of file **metee.h**.

## Function Documentation

### TEESTATUS TEEAPI GetDriverVersion (IN PTEEHANDLE handle, IN OUT teeDriverVersion\_t \* driverVersion)

Obtains version of the TEE device driver Not implemented on Linux

**Parameters**

*handle* The handle of the session. \
 *driverVersion* Pointer to driver version struct

**Returns**

0 if successful, otherwise error code.

### void TEEAPI TeeCancelIO (IN PTEEHANDLE handle)

Try to stop all in-process reads and writes

**Parameters**

*handle* The handle of the session

### TEESTATUS TEEAPI TeeConnect (OUT PTEEHANDLE handle)

Connects to the TEE driver and starts a session

**Parameters**

*handle* A handle to the TEE device

**Returns**

0 if successful, otherwise error code

### 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**

*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.

**Parameters**

*handle* The handle of the session. \
 *fwStatusNum* The FW status register number (0-5). \
 *fwStatus* The memory to store obtained FW status.

**Returns**

0 if successful, otherwise error code.

### 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**

*handle* The handle of the session.

**Returns**

device handle

### TEESTATUS TEEAPI TeeGetKind (IN PTEEHANDLE handle, IN OUT char \* kind, IN OUT size\_t \* kindSize)

Obtains kind of the TEE device

**Parameters**

*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.

**Returns**

0 if successful, otherwise error code.

### uint32\_t TEEAPI TeeGetLogLevel (IN const PTEEHANDLE handle)

Retrieve current log level

**Parameters**

*handle* The handle of the session.

**Returns**

current log level

### uint32\_t TEEAPI TeeGetMaxMsgLen (IN const PTEEHANDLE handle)

Retrieve client maximum message length (MTU)

**Parameters**

*handle* The handle of the session.

**Returns**

client maximum message length. If client never connected, will return zero.

### uint8\_t TEEAPI TeeGetProtocolVer (IN const PTEEHANDLE handle)

Retrieve client protocol version

**Parameters**

*handle* The handle of the session.

**Returns**

client protocol version. If client never connected, will return zero.

### TEESTATUS TEEAPI TeeGetTRC (IN PTEEHANDLE handle, OUT uint32\_t \* trc\_val)

Retrieves TRC register.

**Parameters**

*handle* The handle of the session. \
 *trc\_val* The memory to store obtained TRC value.

**Returns**

0 if successful, otherwise error code.

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

Initializes a TEE connection

**Parameters**

*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

**Returns**

0 if successful, otherwise error code

### 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

**Deprecated**

Since version 6.0

**Parameters**

*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

**Returns**

0 if successful, otherwise error code

### 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

**Parameters**

*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

**Returns**

0 if successful, otherwise error code

### TEESTATUS TEEAPI TeeInitHandle (IN OUT PTEEHANDLE handle, IN const GUID \* guid, IN const TEE\_DEVICE\_HANDLE device\_handle)

Initializes a TEE connection

**Parameters**

*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

**Returns**

0 if successful, otherwise error code

### 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**

*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

**Returns**

0 if successful, otherwise error code

### TEESTATUS TEEAPI TeeSetLogCallback (IN const PTEEHANDLE handle, TeeLogCallback log\_callback)

Set log callback

**Deprecated**

Since version 6.0

**Parameters**

*handle* The handle of the session. \
 *log\_callback* pointer to function to run for log write, set NULL to use built-in function

**Returns**

0 if successful, otherwise error code.

### TEESTATUS TEEAPI TeeSetLogCallback2 (IN const PTEEHANDLE handle, TeeLogCallback2 log\_callback)

Set log callback

**Parameters**

*handle* The handle of the session. \
 *log\_callback* pointer to function to run for log write, set NULL to use built-in function

**Returns**

0 if successful, otherwise error code.

### uint32\_t TEEAPI TeeSetLogLevel (IN PTEEHANDLE handle, IN uint32\_t log\_level)

Set log level

**Parameters**

*handle* The handle of the session. \
 *log\_level* log level to set

**Returns**

previous log level

### 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**

*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

**Returns**

0 if successful, otherwise error code

## Author

Generated automatically by Doxygen for metee from the source code.
