• 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 _TC_NS_CLIENT_H_
14 #define _TC_NS_CLIENT_H_
15 #include "tee_client_type.h"
16 #include "tee_ioctl_cmd.h"
17 
18 #ifndef ZERO_SIZE_PTR
19 #define ZERO_SIZE_PTR       ((void *)16)
20 #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= (unsigned long)ZERO_SIZE_PTR)
21 #endif
22 
23 #define UUID_SIZE      16
24 
25 #define TC_NS_CLIENT_IOC_MAGIC 't'
26 #define TC_NS_CLIENT_DEV       "tc_ns_client"
27 #define TC_NS_CLIENT_DEV_NAME  "/dev/tc_ns_client"
28 #define TC_PRIVATE_DEV_NAME  "/dev/tc_private"
29 #define TUI_LISTEN_PATH "/sys/kernel/tui/c_state"
30 
31 enum ConnectCmd {
32     GET_FD,
33     GET_TEEVERSION,
34 };
35 typedef struct {
36     unsigned int method;
37     unsigned int mdata;
38 } TC_NS_ClientLogin;
39 
40 typedef union {
41     struct {
42         unsigned int buffer;
43         unsigned int buffer_h_addr;
44         unsigned int offset;
45         unsigned int h_offset;
46         unsigned int size_addr;
47         unsigned int size_h_addr;
48     } memref;
49     struct {
50         unsigned int a_addr;
51         unsigned int a_h_addr;
52         unsigned int b_addr;
53         unsigned int b_h_addr;
54     } value;
55 } TC_NS_ClientParam;
56 
57 typedef struct {
58     unsigned int code;
59     unsigned int origin;
60 } TC_NS_ClientReturn;
61 
62 typedef struct {
63     unsigned char uuid[UUID_SIZE];
64     unsigned int session_id;
65     unsigned int cmd_id;
66     TC_NS_ClientReturn returns;
67     TC_NS_ClientLogin login;
68     TC_NS_ClientParam params[TEEC_PARAM_NUM];
69     unsigned int paramTypes;
70     bool started;
71     unsigned int callingPid;
72     unsigned int file_size;
73     union {
74         char *file_buffer;
75         unsigned long long file_addr;
76     };
77 } TC_NS_ClientContext;
78 
79 typedef struct {
80     uint32_t seconds;
81     uint32_t millis;
82 } TC_NS_Time;
83 
84 enum SecFileType {
85     LOAD_TA = 0,
86     LOAD_SERVICE,
87     LOAD_LIB,
88     LOAD_DYNAMIC_DRV,
89 };
90 
91 struct SecFileInfo {
92     enum SecFileType fileType;
93     uint32_t fileSize;
94     int32_t secLoadErr;
95 };
96 struct SecLoadIoctlStruct {
97     struct SecFileInfo secFileInfo;
98     TEEC_UUID uuid;
99     union {
100         char *fileBuffer;
101         struct {
102             uint32_t file_addr;
103             uint32_t file_h_addr;
104         } memref;
105     };
106 }__attribute__((packed));
107 
108 struct AgentIoctlArgs {
109     uint32_t id;
110     uint32_t bufferSize;
111     union {
112         void *buffer;
113         unsigned long long addr;
114     };
115 };
116 
117 #endif
118