Skip to content

Commit 38c27c8

Browse files
wayne renfanghuaqi
authored andcommitted
libsecureshield: clean up the secureshield_vmpu_exports.h
1. remove unused macros 2. add more comments to the macros and data structure
1 parent 1575f0e commit 38c27c8

File tree

1 file changed

+39
-53
lines changed

1 file changed

+39
-53
lines changed

library/secureshield/export/inc/secureshield_vmpu_exports.h

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@
3333
#ifndef _SECURESHIELD_VMPU_EXPORTS_H_
3434
#define _SECURESHIELD_VMPU_EXPORTS_H_
3535

36-
/* basic access control rights definitions */
36+
/* basic resource access control attribute definitions */
37+
/* access control right in user mode */
3738
#define SECURESHIELD_AC_UEXECUTE 0x0001UL
3839
#define SECURESHIELD_AC_UWRITE 0x0002UL
3940
#define SECURESHIELD_AC_UREAD 0x0004UL
4041
#define SECURESHIELD_AC_UAC (SECURESHIELD_AC_UREAD |\
4142
SECURESHIELD_AC_UWRITE |\
4243
SECURESHIELD_AC_UEXECUTE)
4344

44-
/* access control right in system mode*/
45+
/* access control right in kernel mode */
4546
#define SECURESHIELD_AC_KEXECUTE 0x0008UL
4647
#define SECURESHIELD_AC_KWRITE 0x0010UL
4748
#define SECURESHIELD_AC_KREAD 0x0020UL
@@ -56,96 +57,81 @@
5657
#define SECURESHIELD_AC_ACCESS (SECURESHIELD_AC_UAC | SECURESHIELD_AC_KAC |\
5758
SECURESHIELD_AC_SECURE)
5859

59-
/* system resource definitions */
60+
/* container resource definitions */
6061
#define SECURESHIELD_AC_MEMORY 0x0100UL
61-
#define SECURESHIELD_AC_STACK 0x0200UL
6262
#define SECURESHIELD_AC_PERIPHERAL 0x0400UL
6363
#define SECURESHIELD_AC_INTERFACE 0x0800UL
6464
#define SECURESHIELD_AC_IRQ 0x1000UL
6565
#define SECURESHIELD_AC_AUX 0x2000UL
6666

67-
#define SECURESHIELD_AC_SIZE_ROUND_UP 0x10000000UL
68-
#define SECURESHIELD_AC_SIZE_ROUND_DOWN 0x20000000UL
69-
#define SECURESHIELD_AC_SHARED 0x40000000UL
70-
#define SECURESHIELD_AC_SECURE 0x80000000UL
71-
#define SECURESHIELD_AC_NORMAL 0x0UL
67+
/* extended container resource access control attribute definitions */
68+
#define SECURESHIELD_AC_SIZE_ROUND_UP 0x10000000UL /* the resource size should be rounded up */
69+
#define SECURESHIELD_AC_SIZE_ROUND_DOWN 0x20000000UL /* the resource size should be rounded down */
70+
#define SECURESHIELD_AC_SHARED 0x40000000UL /* the resource is a shared resource (no implementation now) */
71+
#define SECURESHIELD_AC_SECURE 0x80000000UL /* the resource is a secure resource */
72+
#define SECURESHIELD_AC_NORMAL 0x0UL /* the resource is a normal resource */
7273

7374

75+
/* the following macros are combinations based on resource type and resource attribute */
76+
/* ROM area requires user privilege */
7477
#define SECURESHIELD_ACDEF_UROM (SECURESHIELD_AC_MEMORY |\
7578
SECURESHIELD_AC_UREAD |\
7679
SECURESHIELD_AC_KREAD )
77-
80+
/* RAM area requires user privilege */
7881
#define SECURESHIELD_ACDEF_URAM (SECURESHIELD_AC_MEMORY |\
7982
SECURESHIELD_AC_UREAD |\
8083
SECURESHIELD_AC_UWRITE |\
8184
SECURESHIELD_AC_KREAD |\
8285
SECURESHIELD_AC_KWRITE )
8386

84-
#define SECURESHIELD_ACDEF_UCONS SECURESHIELD_ACDEF_UROM
85-
87+
/* instruction area (.text) requires user privilege */
8688
#define SECURESHIELD_ACDEF_UTEXT (SECURESHIELD_ACDEF_UROM |\
8789
SECURESHIELD_AC_EXECUTE)
88-
90+
/* memory area (.data, .bss) requires user privilege */
8991
#define SECURESHIELD_ACDEF_UDATA SECURESHIELD_ACDEF_URAM
9092
#define SECURESHIELD_ACDEF_UBSS SECURESHIELD_ACDEF_URAM
9193

9294

93-
#define SECURESHIELD_ACDEF_UPERIPH (SECURESHIELD_AC_PERIPHERAL |\
95+
/* peripheral area requires user privilege */
96+
#define SECURESHIELD_ACDEF_UPERIPH (SECURESHIELD_AC_PERIPHERAL |\
9497
SECURESHIELD_AC_UREAD |\
9598
SECURESHIELD_AC_UWRITE |\
9699
SECURESHIELD_AC_KREAD |\
97100
SECURESHIELD_AC_KWRITE )
98-
99-
#define SECURESHIELD_ACDEF_USTACK (SECURESHIELD_AC_STACK |\
100-
SECURESHIELD_AC_UREAD |\
101-
SECURESHIELD_AC_UWRITE |\
102-
SECURESHIELD_AC_KREAD |\
103-
SECURESHIELD_AC_KWRITE)
104-
101+
/* ROM area requires kernel privilege */
105102
#define SECURESHIELD_ACDEF_KROM (SECURESHIELD_AC_MEMORY |\
106103
SECURESHIELD_AC_KREAD )
107104

105+
/* RAM area requires kernel privilege */
108106
#define SECURESHIELD_ACDEF_KRAM (SECURESHIELD_AC_MEMORY |\
109107
SECURESHIELD_AC_KREAD |\
110108
SECURESHIELD_AC_KWRITE)
111109

112-
#define SECURESHIELD_ACDEF_KCONS SECURESHIELD_ACDEF_KROM
113-
110+
/* instruction area (.text) requires kernel privilege */
114111
#define SECURESHIELD_ACDEF_KTEXT (SECURESHIELD_ACDEF_KROM |\
115112
SECURESHIELD_AC_KEXECUTE)
116-
113+
/* memory area (.data, .bss) requires user privilege */
117114
#define SECURESHIELD_ACDEF_KDATA SECURESHIELD_ACDEF_KRAM
118115
#define SECURESHIELD_ACDEF_KBSS SECURESHIELD_ACDEF_KRAM
119116

120-
117+
/* peripheral area requires kernel privilege */
121118
#define SECURESHIELD_ACDEF_KPERIPH (SECURESHIELD_AC_PERIPHERAL |\
122119
SECURESHIELD_AC_KREAD |\
123120
SECURESHIELD_AC_KWRITE)
124121

125-
#define SECURESHIELD_ACDEF_KSTACK (SECURESHIELD_AC_STACK |\
126-
SECURESHIELD_AC_KREAD |\
127-
SECURESHIELD_AC_KWRITE)
128-
129122

130123
#define SECURESHIELD_PAD32(x) (32 - (sizeof(x) & ~0x1FUL))
131124
#define SECURESHIELD_CONTAINER_MAGIC 0x42CFB66FUL /* magic number to identify container configuration */
132-
#define SECURESHIELD_CONTAINER_SECURE 0x1
133-
#define SECURESHILED_CONTAINER_NORMAL 0x0
125+
#define SECURESHIELD_CONTAINER_SECURE 0x1 /* container type: secure */
126+
#define SECURESHILED_CONTAINER_NORMAL 0x0 /* container type: normal */
134127

135128
#define SECURESHIELD_MEM_SIZE_ROUND(x) SECURESHIELD_REGION_ROUND_UP(x)
136129

137-
#define SECURESHIELD_MIN_STACK_SIZE 1024
138-
#define SECURESHIELD_MIN_STACK(x) (((x)<SECURESHIELD_MIN_STACK_SIZE)?SECURESHIELD_MIN_STACK_SIZE:(x))
139-
140130

141131
#define SECURESHIELD_REGION_ROUND_DOWN(x) ((x) & ~((1UL<<SECURESHIELD_REGION_BITS(x))-1))
142132
#define SECURESHIELD_REGION_ROUND_UP(x) (1UL<<SECURESHIELD_REGION_BITS(x))
143133
#define SECURESHIELD_STACK_SIZE_ROUND(x) SECURESHIELD_REGION_ROUND_UP(x)
144134

145-
#ifndef SECURESHIELD_SHIELD_STACK_SIZE
146-
#define SECURESHIELD_SHIELD_STACK_SIZE SECURESHIELD_MIN_STACK_SIZE
147-
#endif/*SECURESHIELD_SHIELD_STACK*/
148-
149135

150136
typedef uint32_t CONTAINER_AC;
151137

@@ -158,24 +144,24 @@ typedef struct
158144

159145
typedef struct
160146
{
161-
uint32_t magic;
162-
uint32_t type;
163-
uint32_t stack_size;
164-
uint32_t *stack_area;
147+
uint32_t magic; /* magic number to identify this structure */
148+
uint32_t type; /* container type */
149+
uint32_t stack_size; /* container stack size */
150+
uint32_t *stack_area; /* container stack area */
165151

166-
const CONTAINER_AC_ITEM* const ac_table;
167-
uint32_t ac_count;
152+
const CONTAINER_AC_ITEM* const ac_table; /* container resource access control table */
153+
uint32_t ac_count; /* item counts in container resource access control table */
168154

169155
/* memory area */
170-
void *text_start;
171-
void *text_end;
172-
void *rodata_start;
173-
void *rodata_end;
174-
void *data_start;
175-
void *data_end;
176-
void *data_load_start;
177-
void *bss_start;
178-
void *bss_end;
156+
void *text_start; /* the start address of container's .text section */
157+
void *text_end; /* the end address of container's .text section, no .text section if text_start == text_end */
158+
void *rodata_start; /* the start address of container's .rodata section */
159+
void *rodata_end; /* the end address of container's .rodata section, no .rodata section if rodata_start == text_end */
160+
void *data_start; /* the start address of container's .data section */
161+
void *data_end; /* the end address of container's .data section, no .data section if data_start == data_end */
162+
void *data_load_start; /* the start load address of container's .data section */
163+
void *bss_start; /* the start address of container's .bss section, container stack is in .bss section */
164+
void *bss_end; /* the end address of container's .bss section */
179165
} EMBARC_PACKED CONTAINER_CONFIG;
180166

181167

0 commit comments

Comments
 (0)