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 thread_svc_regs; 30 struct ts_ops { 31 TEE_Result (*enter_open_session)(struct ts_session *s); 32 TEE_Result (*enter_invoke_cmd)(struct ts_session *s, uint32_t cmd); 33 void (*enter_close_session)(struct ts_session *s); 34 void (*dump_state)(struct ts_ctx *ctx); 35 void (*dump_ftrace)(struct ts_ctx *ctx); 36 void (*destroy)(struct ts_ctx *ctx); 37 uint32_t (*get_instance_id)(struct ts_ctx *ctx); 38 bool (*handle_svc)(struct thread_svc_regs *regs); 39 }; 40 41 struct ts_session *ts_get_current_session(void); 42 struct ts_session *ts_get_current_session_may_fail(void); 43 44 void ts_push_current_session(struct ts_session *sess); 45 struct ts_session *ts_pop_current_session(void); 46 struct ts_session *ts_get_calling_session(void); 47 48 #endif /*__KERNEL_TS_MANAGER_H*/ 49