1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef __CS_H 13 #define __CS_H 14 15 #include <tee_msg_type.h> 16 #include <ipclib.h> 17 #include <stdint.h> 18 #include <stddef.h> 19 #include <semaphore.h> 20 21 #define CS_SERVER_MAX_MSG_LEN 2048 22 23 struct cs_req_msg { 24 msg_header hdr; 25 char payload[]; 26 } __attribute__((__packed__)); 27 28 struct reply_cs_msg { 29 msg_header hdr; 30 } __attribute__((__packed__)); 31 32 struct thread_init_info { 33 cref_t channel; 34 void *(*func)(void *arg); 35 uint32_t max_thread; 36 sem_t *thread_sem; 37 int32_t capid; 38 int32_t task_id; 39 int32_t shadow; 40 size_t stack_size; 41 void* args; 42 }; 43 44 typedef intptr_t (*dispatch_fn_t)(void *msg, cref_t *p_msg_hdl, struct src_msginfo *info); 45 46 void cs_server_loop(cref_t channel, const dispatch_fn_t dispatch_fns[], unsigned n_dispatch_fns, int (*hook)(void), void *cur_thread); 47 48 #endif 49