• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 #ifndef GTASK_TASK_ADAPTOR_H
14 #define GTASK_TASK_ADAPTOR_H
15 
16 #include <dlist.h>
17 #include "tee_internal_api.h"
18 #include "tee_internal_task_pub.h"
19 
20 struct srv_adaptor_config_t {
21     uint32_t task_prio;
22     uint32_t agent_id;
23     bool is_need_release_ta_res;
24     bool crash_callback;
25     bool is_need_create_msg;
26     bool is_need_release_msg;
27 };
28 
29 typedef void (*register_ta_to_task_f)(const struct reg_ta_info *reg_msg, uint32_t dest_task_id);
30 typedef void (*unregister_ta_to_task_f)(const char *cur_task_name,
31     const struct reg_ta_info *reg_msg, uint32_t dest_task_id);
32 typedef void (*task_crash_callback_f)(const TEE_UUID *uuid, const char *task_name,
33     const struct srv_adaptor_config_t *config);
34 typedef void (*register_agent_buffer_to_task_f)(uint32_t agent_id, uint32_t dest_task_id);
35 typedef void (*send_ta_create_msg_to_task_f)(const char *cur_task_name,
36     const struct reg_ta_info *msg, uint32_t dest_task_id);
37 typedef void (*send_ta_release_msg_to_task_f)(const char *cur_task_name,
38     const struct reg_ta_info *msg, uint32_t dest_task_id);
39 
40 #define INVALID_TASK_ID 0
41 #define MAX_TASK_NAME_LEN 64
42 struct task_adaptor_info {
43     struct dlist_node task_node;
44     char task_name[MAX_TASK_NAME_LEN];
45     TEE_UUID uuid;
46     uint32_t task_id;
47     uint32_t task_prio;
48     bool is_agent;
49     uint32_t agent_id;
50     uint32_t agent_status;
51     bool is_need_release_ta_res;
52     bool crash_callback;
53     bool is_need_create_msg;
54     bool is_need_release_msg;
55     struct task_caller_info caller_info;
56     register_ta_to_task_f register_ta_to_task;
57     unregister_ta_to_task_f unregister_ta_to_task;
58     task_crash_callback_f task_crash_callback;
59     register_agent_buffer_to_task_f register_agent_buffer_to_task;
60     send_ta_create_msg_to_task_f send_ta_create_msg_to_task;
61     send_ta_release_msg_to_task_f send_ta_release_msg_to_task;
62 };
63 
64 typedef void (*task_init_priv_info_f)(struct task_adaptor_info *task);
65 
66 struct task_adaptor_info *find_task_by_taskid(uint32_t task_id);
67 void del_task_from_list(const TEE_UUID *uuid);
68 void send_register_ta_to_task(const struct reg_ta_info *reg_msg, uint32_t dest_task_id);
69 void send_unregister_ta_to_task(const char *cur_task_name, const struct reg_ta_info *reg_msg,
70     uint32_t dest_task_id);
71 struct task_adaptor_info *find_task_by_uuid(const TEE_UUID *uuid);
72 struct task_adaptor_info *register_task_proc(const TEE_UUID *uuid, uint16_t task_prio, const char *task_name,
73     const task_init_priv_info_f task_init_priv_info, const struct srv_adaptor_config_t *srv_config);
74 void task_adapt_send_ta_create_msg(const struct reg_ta_info *msg, uint32_t dest_task_id);
75 void task_adapt_send_ta_release_msg(const struct reg_ta_info *msg, uint32_t dest_task_id);
76 
77 #if (defined CONFIG_APP_TEE_TEST_SERVICE || defined CONFIG_APP_TEE_TEST_SERVICE_A64)
78 struct task_adaptor_info *register_task_test_srv(void);
79 #endif
80 #endif
81