• 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 LIBSPAWN_COMMON_INCLUDE_SPAWN_INIT_H
14 #define LIBSPAWN_COMMON_INCLUDE_SPAWN_INIT_H
15 
16 #include <stdint.h>
17 #include <tee_defines.h>
18 
19 #define ARGV_SIZE  64
20 #define ARGV0_SIZE 100
21 #define ARGV2_SIZE 8
22 #define MAX_DYN_CLIENT_NUM 20
23 #define CLIENT_NAME_SIZE   72   /* client name len 64 bytes + path len */
24 enum env_index {
25     ENV_PRIORITY_INDEX,
26     ENV_UID_INDEX,
27     ENV_TARGET_TYPE_INDEX,
28     ENV_DRV_INDEX_INDEX,
29     ENV_THREAD_LIMIT_INDEX,
30     ENV_STACK_SIZE_INDEX,
31     ENV_TERMINATE_INDEX,
32     ENV_MAX,
33 };
34 
35 enum argv_index {
36     ARGV_ELF_PATH_INDEX,
37     ARGV_TASK_NAME_INDEX,
38     ARGV_TASK_PATH_INDEX,
39     ARGV_UNCOMMIT_INDEX,
40     ARGV_CLIENT_NAME_INDEX,
41     ARGV_TERMINATE_INDEX,
42     ARGV_MAX,
43 };
44 
45 struct env_param {
46     int32_t priority;
47     uint32_t uid;
48     uint32_t target_type;
49     uint32_t drv_index;
50     uint32_t thread_limit;
51     uint32_t stack_size;
52 };
53 
54 struct env_base_buffer {
55     char priority[ARGV_SIZE];
56     char uid[ARGV_SIZE];
57     char target_type[ARGV_SIZE];
58 } __attribute__((packed));
59 
60 struct env_drv_base_buffer {
61     char drv_index[ARGV_SIZE];
62     char thread_limit[ARGV_SIZE];
63     char stack_size[ARGV_SIZE];
64 } __attribute__((packed));
65 
66 struct argv_base_buffer {
67     char elf_path[ARGV_SIZE];
68     char task_name[ARGV0_SIZE];
69     char task_path[ARGV_SIZE];
70     char uncommit[ARGV2_SIZE];
71     char client_name[CLIENT_NAME_SIZE * MAX_DYN_CLIENT_NUM];
72 } __attribute__((packed));
73 
74 struct spawn_buffer {
75     struct env_base_buffer env;
76     struct argv_base_buffer argv;
77 } __attribute__((packed));
78 
79 struct spawn_drv_buffer {
80     struct env_base_buffer env;
81     struct env_drv_base_buffer env_drv;
82     struct argv_base_buffer argv;
83 } __attribute__((packed));
84 
85 /* msg used for drvmgr and drv process */
86 #define DRV_SPAWN_SYNC_NAME "drv_spawn_sync"
87 #define PROCESS_INIT_SUCC 0x1
88 #define PROCESS_INIT_FAIL 0x2
89 struct spawn_sync_msg {
90     uint32_t msg_id;
91 };
92 
93 int32_t set_env_for_task(const struct env_param *param, const struct tee_uuid *uuid, struct env_base_buffer *env);
94 
95 int32_t set_drv_env_for_task(const struct env_param *param, struct env_drv_base_buffer *env);
96 
97 #endif
98