1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 * Copyright (c) 2017-2020, Linaro Limited 5 */ 6 7 #ifndef __KERNEL_TS_MANAGER_H 8 #define __KERNEL_TS_MANAGER_H 9 10 #include <sys/queue.h> 11 #include <tee_api_types.h> 12 13 struct ts_ctx { 14 TEE_UUID uuid; 15 const struct ts_ops *ops; 16 }; 17 18 struct ts_session { 19 TAILQ_ENTRY(ts_session) link_tsd; 20 struct ts_ctx *ctx; /* Generic TS context */ 21 #if defined(CFG_TA_GPROF_SUPPORT) 22 struct sample_buf *sbuf; /* Profiling data (PC sampling) */ 23 #endif 24 #if defined(CFG_FTRACE_SUPPORT) 25 struct ftrace_buf *fbuf; /* ftrace buffer */ 26 #endif 27 }; 28 29 struct tee_ta_param; 30 struct thread_svc_regs; 31 struct ts_ops { 32 TEE_Result (*enter_open_session)(struct ts_session *s, 33 struct tee_ta_param *param, 34 TEE_ErrorOrigin *eo); 35 TEE_Result (*enter_invoke_cmd)(struct ts_session *s, uint32_t cmd, 36 struct tee_ta_param *param, 37 TEE_ErrorOrigin *eo); 38 void (*enter_close_session)(struct ts_session *s); 39 void (*dump_state)(struct ts_ctx *ctx); 40 void (*dump_ftrace)(struct ts_ctx *ctx); 41 void (*destroy)(struct ts_ctx *ctx); 42 uint32_t (*get_instance_id)(struct ts_ctx *ctx); 43 bool (*handle_svc)(struct thread_svc_regs *regs); 44 }; 45 46 struct ts_session *ts_get_current_session(void); 47 struct ts_session *ts_get_current_session_may_fail(void); 48 49 void ts_push_current_session(struct ts_session *sess); 50 struct ts_session *ts_pop_current_session(void); 51 struct ts_session *ts_get_calling_session(void); 52 53 #endif /*__KERNEL_TS_MANAGER_H*/ 54