metee

Loading...
Searching...
No Matches
metee.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Apache-2.0 */
2/*
3 * Copyright (C) 2014-2021 Intel Corporation
4 */
8#ifndef __METEE_H
9#define __METEE_H
10
11#ifdef __cplusplus
12 extern "C" {
13#endif
14
15#include <stddef.h>
16#include <stdint.h>
18#ifdef _WIN32
19 #include <Windows.h>
20 #include <initguid.h>
21
22 #ifndef METEE_DLL
23 #define METEE_DLL_API
24 #else /* METEE_DLL */
25 #ifdef METEE_DLL_EXPORT
26 #define METEE_DLL_API __declspec(dllexport)
27 #else
28 #define METEE_DLL_API __declspec(dllimport)
29 #endif /* METEE_DLL_EXPORT */
30 #endif /* METEE_DLL */
31 #define TEEAPI METEE_DLL_API __stdcall
32 #define TEE_DEVICE_HANDLE HANDLE
33 #define TEE_INVALID_DEVICE_HANDLE ((void*)0)
34#else /* _WIN32 */
35 #include <linux/uuid.h>
36
37 #ifndef METEE_DLL
38 #define METEE_DLL_API
39 #else
40 #ifdef METEE_DLL_EXPORT
41 #define METEE_DLL_API __attribute__((__visibility__("default")))
42 #else
43 #define METEE_DLL_API
44 #endif /* METEE_DLL_EXPORT */
45 #endif /* METEE_DLL */
46 #define TEEAPI METEE_DLL_API
47 #define GUID uuid_le
48 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
49 const uuid_le name = UUID_LE(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
50 #define TEE_DEVICE_HANDLE int
51 #define TEE_INVALID_DEVICE_HANDLE (-1)
52 #ifndef IN
53 #define IN
54 #endif
55 #ifndef OUT
56 #define OUT
57 #endif
58 #ifndef OPTIONAL
59 #define OPTIONAL
60 #endif
61#endif /* _WIN32 */
63
66 enum tee_log_level {
67 TEE_LOG_LEVEL_QUIET = 0,
68 TEE_LOG_LEVEL_ERROR = 1,
69 TEE_LOG_LEVEL_VERBOSE = 2
70};
71
75 typedef struct _TEEHANDLE {
76
77 void *handle;
78 size_t maxMsgLen;
79 uint8_t protcolVer;
80 enum tee_log_level log_level;
81} TEEHANDLE;
82
87 typedef TEEHANDLE *PTEEHANDLE;
88
89
90
92#define TEEHANDLE_ZERO {0}
93
94 typedef uint16_t TEESTATUS;
96#define TEE_ERROR_BASE 0x0000U
98#define TEE_SUCCESS (TEE_ERROR_BASE + 0)
100#define TEE_INTERNAL_ERROR (TEE_ERROR_BASE + 1)
102#define TEE_DEVICE_NOT_FOUND (TEE_ERROR_BASE + 2)
104#define TEE_DEVICE_NOT_READY (TEE_ERROR_BASE + 3)
106#define TEE_INVALID_PARAMETER (TEE_ERROR_BASE + 4)
108#define TEE_UNABLE_TO_COMPLETE_OPERATION (TEE_ERROR_BASE + 5)
110#define TEE_TIMEOUT (TEE_ERROR_BASE + 6)
112#define TEE_NOTSUPPORTED (TEE_ERROR_BASE + 7)
114#define TEE_CLIENT_NOT_FOUND (TEE_ERROR_BASE + 8)
116#define TEE_BUSY (TEE_ERROR_BASE + 9)
118#define TEE_DISCONNECTED (TEE_ERROR_BASE + 10)
120#define TEE_INSUFFICIENT_BUFFER (TEE_ERROR_BASE + 11)
122#define TEE_PERMISSION_DENIED (TEE_ERROR_BASE + 12)
123
126#define TEE_IS_SUCCESS(Status) (((TEESTATUS)(Status)) == TEE_SUCCESS)
127
135 TEESTATUS TEEAPI TeeInit(IN OUT PTEEHANDLE handle, IN const GUID *guid,
136 IN OPTIONAL const char *device);
137
138#ifdef _WIN32
147 TEESTATUS TEEAPI TeeInitGUID(IN OUT PTEEHANDLE handle, IN const GUID *guid,
148 IN OPTIONAL const GUID *device);
149#endif /* _WIN32 */
150
158 TEESTATUS TEEAPI TeeInitHandle(IN OUT PTEEHANDLE handle, IN const GUID *guid,
159 IN const TEE_DEVICE_HANDLE device_handle);
160
165 TEESTATUS TEEAPI TeeConnect(OUT PTEEHANDLE handle);
166
176 TEESTATUS TEEAPI TeeRead(IN PTEEHANDLE handle, IN OUT void *buffer, IN size_t bufferSize,
177 OUT OPTIONAL size_t *pNumOfBytesRead, IN OPTIONAL uint32_t timeout);
178
188 TEESTATUS TEEAPI TeeWrite(IN PTEEHANDLE handle, IN const void *buffer, IN size_t bufferSize,
189 OUT OPTIONAL size_t *numberOfBytesWritten, IN OPTIONAL uint32_t timeout);
190
197 TEESTATUS TEEAPI TeeFWStatus(IN PTEEHANDLE handle,
198 IN uint32_t fwStatusNum, OUT uint32_t *fwStatus);
199
205 void TEEAPI TeeDisconnect(IN PTEEHANDLE handle);
206
212TEE_DEVICE_HANDLE TEEAPI TeeGetDeviceHandle(IN PTEEHANDLE handle);
213
216 typedef struct {
217 uint16_t major;
218 uint16_t minor;
219 uint16_t hotfix;
220 uint16_t build;
221} teeDriverVersion_t;
222
229 TEESTATUS TEEAPI GetDriverVersion(IN PTEEHANDLE handle, IN OUT teeDriverVersion_t *driverVersion);
230
237uint32_t TEEAPI TeeSetLogLevel(IN PTEEHANDLE handle, IN uint32_t log_level);
238
244uint32_t TEEAPI TeeGetLogLevel(IN const PTEEHANDLE handle);
245
246#ifdef __cplusplus
247}
248#endif
249
250#endif /* __METEE_H */
TEESTATUS
uint16_t TEESTATUS
Definition metee.h:94
tee_log_level
tee_log_level
Definition metee.h:66
TEE_LOG_LEVEL_ERROR
@ TEE_LOG_LEVEL_ERROR
Definition metee.h:68
TEE_LOG_LEVEL_VERBOSE
@ TEE_LOG_LEVEL_VERBOSE
Definition metee.h:69
TEE_LOG_LEVEL_QUIET
@ TEE_LOG_LEVEL_QUIET
Definition metee.h:67
PTEEHANDLE
TEEHANDLE * PTEEHANDLE
A type definition for pointer to TEEHANDLE.
Definition metee.h:87
GetDriverVersion
TEESTATUS TEEAPI GetDriverVersion(IN PTEEHANDLE handle, IN OUT teeDriverVersion_t *driverVersion)
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)
TeeGetDeviceHandle
TEE_DEVICE_HANDLE TEEAPI TeeGetDeviceHandle(IN PTEEHANDLE handle)
TeeFWStatus
TEESTATUS TEEAPI TeeFWStatus(IN PTEEHANDLE handle, IN uint32_t fwStatusNum, OUT uint32_t *fwStatus)
TeeGetLogLevel
uint32_t TEEAPI TeeGetLogLevel(IN const PTEEHANDLE handle)
TeeInitHandle
TEESTATUS TEEAPI TeeInitHandle(IN OUT PTEEHANDLE handle, IN const GUID *guid, IN const TEE_DEVICE_HANDLE device_handle)
TeeInit
TEESTATUS TEEAPI TeeInit(IN OUT PTEEHANDLE handle, IN const GUID *guid, IN OPTIONAL const char *device)
TeeDisconnect
void TEEAPI TeeDisconnect(IN PTEEHANDLE handle)
TeeConnect
TEESTATUS TEEAPI TeeConnect(OUT PTEEHANDLE handle)
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)
TEEHANDLE
struct _TEEHANDLE TEEHANDLE
TeeSetLogLevel
uint32_t TEEAPI TeeSetLogLevel(IN PTEEHANDLE handle, IN uint32_t log_level)
_TEEHANDLE
Definition metee.h:75
_TEEHANDLE::protcolVer
uint8_t protcolVer
Definition metee.h:79
_TEEHANDLE::log_level
enum tee_log_level log_level
Definition metee.h:80
_TEEHANDLE::maxMsgLen
size_t maxMsgLen
Definition metee.h:78
_TEEHANDLE::handle
void * handle
Definition metee.h:77
teeDriverVersion_t
Definition metee.h:216
teeDriverVersion_t::major
uint16_t major
Definition metee.h:217
teeDriverVersion_t::build
uint16_t build
Definition metee.h:220
teeDriverVersion_t::minor
uint16_t minor
Definition metee.h:218
teeDriverVersion_t::hotfix
uint16_t hotfix
Definition metee.h:219