Skip to content

Commit

Permalink
libteec: Move OP-TEE defined fields into an imp struct
Browse files Browse the repository at this point in the history
GlobalPlatform TEE Client API Specification v1.0 specifies that
the structs TEEC_Context, TEEC_Session, TEEC_SharedMemory,
and TEEC_Operation shall have a user defined struct named imp.
In OP-TEE the struct is not there and instead the user defined
fields are declared directly in the top structs.
This commit introduces the imp struct to better support using
different implementations. The imp fields now represent the
implementation defined parts of the structs that was
previously declared directly in the top struct. All previously
available parameters are preserved in the imp struct.
The updated version of the imp structure makes it easier to
create a binding for Rust.
Adding the missing imp struct to the structs in OP-TEE is an
ABI breakage which requires a version major update of libteec.

Link: #348
Reported-by: Tom Hebb <tommyhebb@gmail.com>
Signed-off-by: Julianus Larson <julianus.larson@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
JLLinaro authored and jforissier committed Apr 2, 2024
1 parent 7749688 commit 3eac340
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 106 deletions.
2 changes: 1 addition & 1 deletion libteec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(libteec
VERSION 1.0.0
VERSION 2.0.0
LANGUAGES C)

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion libteec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ all: libteec
################################################################################
# Teec configuration
################################################################################
MAJOR_VERSION := 1
MAJOR_VERSION := 2
MINOR_VERSION := 0
PATCH_VERSION := 0
LIB_NAME := libteec.so
Expand Down
41 changes: 24 additions & 17 deletions libteec/include/tee_client_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ typedef uint32_t TEEC_Result;
*/
typedef struct {
/* Implementation defined */
int fd;
bool reg_mem;
bool memref_null;
struct {
int fd;
bool reg_mem;
bool memref_null;
} imp;
} TEEC_Context;

/**
Expand Down Expand Up @@ -314,16 +316,15 @@ typedef struct {
size_t size;
uint32_t flags;
/*
* Implementation-Defined
* Implementation defined
*/
int id;
size_t alloced_size;
void *shadow_buffer;
int registered_fd;
union {
bool dummy;
uint8_t flags;
} internal;
struct {
int id;
size_t alloced_size;
void *shadow_buffer;
int registered_fd;
uint32_t flags;
} imp;
} TEEC_SharedMemory;

/**
Expand Down Expand Up @@ -405,8 +406,10 @@ typedef union {
*/
typedef struct {
/* Implementation defined */
TEEC_Context *ctx;
uint32_t session_id;
struct {
TEEC_Context *ctx;
uint32_t session_id;
} imp;
} TEEC_Session;

/**
Expand All @@ -419,16 +422,20 @@ typedef struct {
* create the correct flags.
* 0 means TEEC_NONE is passed for all params.
* @param params Array of parameters of type TEEC_Parameter.
* @param session Internal pointer to the last session used by
* @param imp Implementation defined parameter. Here it is a struct
* containing one parameter: session. session is an
* internal pointer to the last session used by
* TEEC_InvokeCommand with this operation.
*
*/
typedef struct {
uint32_t started;
uint32_t paramTypes;
TEEC_Parameter params[TEEC_CONFIG_PAYLOAD_REF_COUNT];
/* Implementation-Defined */
TEEC_Session *session;
/* Implementation defined */
struct {
TEEC_Session *session;
} imp;
} TEEC_Operation;

/**
Expand Down
Loading

0 comments on commit 3eac340

Please sign in to comment.