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 enum ts_gprof_status { 30 TS_GPROF_SUSPEND, 31 TS_GPROF_RESUME, 32 }; 33 34 struct thread_svc_regs; 35 struct ts_ops { 36 TEE_Result (*enter_open_session)(struct ts_session *s); 37 TEE_Result (*enter_invoke_cmd)(struct ts_session *s, uint32_t cmd); 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 #ifdef CFG_TA_GPROF_SUPPORT 45 void (*gprof_set_status)(enum ts_gprof_status status); 46 #endif 47 }; 48 49 struct ts_session *ts_get_current_session(void); 50 struct ts_session *ts_get_current_session_may_fail(void); 51 52 void ts_push_current_session(struct ts_session *sess); 53 struct ts_session *ts_pop_current_session(void); 54 struct ts_session *ts_get_calling_session(void); 55 56 #endif /*__KERNEL_TS_MANAGER_H*/ 57