Skip to content

Commit 1575f0e

Browse files
wayne renfanghuaqi
authored andcommitted
libsecureshield: improve the comments and declartions
Improve the code comments and declartions in freertos port for secureshield and freertos kernel secure example
1 parent 062743c commit 1575f0e

File tree

9 files changed

+29
-38
lines changed

9 files changed

+29
-38
lines changed

example/freertos/kernel_secure/background_container.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static void interrupt_high_pri(void *p_excinf)
268268

269269
/**
270270
* \brief low priority interrupt
271-
* \details write AUX_IRQ_HINT to raise higher priority interrtupt.
271+
* \details write AUX_IRQ_HINT to raise higher priority interrupt.
272272
* \param[in] *p_excinf
273273
*/
274274
static void interrupt_low_pri(void *p_exinf)

example/freertos/kernel_secure/container1.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ typedef struct {
5858

5959

6060
extern uint8_t _f_data_container12_shared[];
61-
extern uint8_t _e_bss_container12_shared[];
62-
6361

6462
extern int32_t init_secret(void);
6563
extern int32_t operate_secret(char* pwd, uint32_t cmd, char * data);

example/freertos/kernel_secure/container_cfg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
#include "container2.h"
4242
#include "background_container.h"
4343

44-
// Container 1: two special memory regions for initialization and communication with container 2
44+
// Container 1: one special memory region for communication with container 2
4545
static CONTAINER_AC_TABLE g_container1_act[] = {
4646
{init_secret, 0, SECURESHIELD_AC_INTERFACE},
4747
{operate_secret, 3, SECURESHIELD_AC_INTERFACE},
4848
{(void *)CONTAINER_12_SHARED_ORIGIN, CONTAINER_12_SHARED_LENGTH, SECURESHIELD_ACDEF_URAM}
4949
};
5050

51-
// Container 2: special memory regions for communication with container 2
51+
// Container 2: one special memory region for communication with container 2
5252
static CONTAINER_AC_TABLE g_container2_act[] = {
5353
{(void *)CONTAINER_12_SHARED_ORIGIN, CONTAINER_12_SHARED_LENGTH, SECURESHIELD_ACDEF_URAM},
5454
{trusted_ops, 0, SECURESHIELD_AC_INTERFACE}
@@ -71,6 +71,7 @@ static CONTAINER_AC_TABLE g_main_container_act[] = {
7171
{(void *)0x100, 0x6, SECURESHIELD_AC_AUX},
7272
{(void *)0x75, 0x1, SECURESHIELD_AC_AUX},
7373
#endif
74+
/* if LIB_SECURESHIELD_VERSION == 2, the following interrupts are configured as normal interrupts */
7475
{default_interrupt_handler, INTNO_LOW_PRI, SECURESHIELD_AC_IRQ},
7576
{default_interrupt_handler, INTNO_HIGH_PRI, SECURESHIELD_AC_IRQ},
7677
{default_interrupt_handler, INTNO_TIMER0, SECURESHIELD_AC_IRQ}
@@ -79,6 +80,6 @@ static CONTAINER_AC_TABLE g_main_container_act[] = {
7980
/* enable secureshield, set the access control table of background container */
8081
SECURESHIELD_SET_MODE_AC(SECURESHIELD_ENABLED, g_main_container_act);
8182

82-
/* configure the other container */
83+
/* configure other containers */
8384
SECURESHIELD_CONTAINER_CONFIG(container1, g_container1_act, 1024);
8485
SECURESHIELD_CONTAINER_CONFIG(container2, g_container2_act, 1024);

example/freertos/kernel_secure/secureshield_appl_config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
#ifndef _SECURESHIELD_APPL_CONFIG_H_
3535
#define _SECURESHIELD_APPL_CONFIG_H_
3636

37-
/* tell linker script template, there is a region named container1 in normal rom, its size is 2048 bytes */
37+
/* tell linker script template, there is a region named container1 in normal rom, its size is 2048 bytes
38+
* container2 related definiion is a placeholder to generate necessary symbols */
3839
#define SECURESHIELD_REGION_CONTAINERS_ROM \
3940
GEN_CONTAINER_ROM_SECTION(container1, 2048) \
4041
GEN_CONTAINER_ROM_SECTION(container2, 0)
4142

42-
/* tell linker script template, there is a region named container12 in normal ram, its size is 2048 bytes */
43+
/* tell linker script template, there are regions named container1, container2 and container12 in normal
44+
* ram who sizes are 2048 bytes */
4345
#define SECURESHIELD_REGION_CONTAINERS_RAM \
4446
GEN_CONTAINER_RAM_SECTION(container1, 2048) \
4547
GEN_CONTAINER_RAM_SECTION(container2, 2048) \

os/freertos/portable/Synopsys/ARC/arc_support.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ dispatch_r:
112112
.align 4
113113
start_dispatch:
114114
/*
115-
* this routine is called in the non-task conext during the startup of the kernel
115+
* this routine is called in the non-task context during the startup of the kernel
116116
* , and all the interrupts are locked.
117117
*
118118
* when the dispatcher is called, the cpu is locked, no nest exception (CPU exception/interrupt).
@@ -177,7 +177,7 @@ exc_entry_cpu:
177177
st r1, [exc_nest_count]
178178
cmp r0, 0
179179
bne exc_handler_1
180-
/* chang to interrupt stack if interrupt happened in task context */
180+
/* change to exception stack if interrupt happened in task context */
181181
mov sp, _e_stack
182182
exc_handler_1:
183183
PUSH blink
@@ -268,7 +268,7 @@ exc_entry_int:
268268
st r2, [exc_nest_count]
269269
cmp r3, 0
270270
bne irq_handler_1
271-
/* chang to interrupt stack if interrupt happened in task context */
271+
/* change to exception stack if interrupt happened in task context */
272272
mov sp, _e_stack
273273
irq_handler_1:
274274
PUSH blink
@@ -308,7 +308,7 @@ ret_int_1: /* return from non-task context */
308308
rtie
309309
/* there is a dispatch request */
310310
ret_int_2:
311-
/* clear dispatch requst */
311+
/* clear dispatch request */
312312
mov r0, 0
313313
st r0, [context_switch_reqflg]
314314

os/freertos/portable/Synopsys/ARC_EM_SECURESHIELD/arc_freertos_exceptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
2+
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
33
All rights reserved
44
55
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
@@ -78,9 +78,7 @@ extern void exc_entry_cpu(void); /* cpu exception entry for freertos */
7878
extern void exc_entry_int(void); /* int exception entry for freertos */
7979

8080
/* task dispatch functions in .s */
81-
extern void start_r(void);
8281
extern void start_dispatch();
83-
extern void dispatch();
8482

8583
extern void freertos_exc_init(void);
8684

os/freertos/portable/Synopsys/ARC_EM_SECURESHIELD/arc_support.s

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@
8989
.align 4
9090
start_dispatch:
9191
/*
92-
* this routine is called in the non-task conext during the startup of the kernel
92+
* this routine is called in the non-task context during the startup of the kernel
9393
* , and all the interrupts are locked.
9494
*
95-
* when the dispatcher is called, the cpu is locked, no nest exception (CPU exception/interrupt).
9695
* In target_initialize, all interrupt priority mask should be cleared, cpu should be
9796
* locked, the interrupts outside the kernel such as fiq can be
9897
* enabled.
@@ -112,7 +111,7 @@ dispatcher:
112111
/*
113112
* before dispatcher is called, task context | cpu locked | dispatch enabled
114113
* should be satisfied. In this routine, the processor will jump
115-
* into the entry of next to run task
114+
* into the entry of next to run task through exception return
116115
*
117116
* i.e. kernel mode, IRQ disabled, dispatch enabled
118117
*/
@@ -141,7 +140,7 @@ exc_entry_cpu:
141140
st r1, [exc_nest_count]
142141
cmp r0, 0
143142
bne exc_handler_1
144-
/* chang to interrupt stack if interrupt happened in task context */
143+
/* change to exception stack if interrupt happened in task context */
145144
mov sp, _e_stack
146145
exc_handler_1:
147146
PUSH blink
@@ -188,19 +187,7 @@ ret_exc_r_1:
188187
exc_entry_int:
189188
clri /* disable interrupt */
190189

191-
#if ARC_FEATURE_FIRQ == 1
192-
#if ARC_FEATURE_RGF_NUM_BANKS > 1
193-
lr r0, [AUX_IRQ_ACT] /* check whether it is P0 interrupt */
194-
btst r0, 0
195-
jnz exc_entry_firq
196-
#else
197-
PUSH r10
198-
lr r10, [AUX_IRQ_ACT]
199-
btst r10, 0
200-
POP r10
201-
jnz exc_entry_firq
202-
#endif
203-
#endif
190+
/* FIRQ and banking is not supported now in secureshield */
204191
INTERRUPT_PROLOGUE
205192

206193
mov blink, sp
@@ -210,7 +197,7 @@ exc_entry_int:
210197
st r2, [exc_nest_count]
211198
cmp r3, 0
212199
bne irq_handler_1
213-
/* chang to interrupt stack if interrupt happened in task context */
200+
/* change to exception stack if interrupt happened in task context */
214201
mov sp, _e_stack
215202
irq_handler_1:
216203
PUSH blink
@@ -242,7 +229,7 @@ ret_int:
242229
ld r0, [context_switch_reqflg]
243230
cmp r0, 0
244231
beq ret_int_r_1
245-
/* clear dispatch requst */
232+
/* clear dispatch request */
246233
mov r0, 0
247234
st r0, [context_switch_reqflg]
248235

@@ -263,6 +250,12 @@ ret_int:
263250
st r0, [ulCriticalNesting]
264251
RESTORE_CALLEE_REGS
265252
ret_int_r_1:
253+
/* differences between INTERRUPT_EPILOGUE and EXCEPTION_EPILOGUE:
254+
* INTERRUPT_EPIOLOGUE is a subset of EXCEPTION_EPIOLOGUE.
255+
* In EXCEPTION_EPILOGUE, all regs are popped through SW.
256+
* IN INTERRUPT_EPILOGUE, some regs are popped through SW, the left
257+
* part is popped by HW (interrupt return).
258+
*/
266259
INTERRUPT_EPILOGUE
267260
rtie
268261
/** @endcond */

os/freertos/portable/Synopsys/ARC_EM_SECURESHIELD/freertos_tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
2+
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
33
All rights reserved
44
55
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

os/freertos/portable/Synopsys/ARC_EM_SECURESHIELD/port.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,10 @@ static void prvSetupTimerInterrupt(void)
121121

122122
/*
123123
* Setup the stack of a new task so it is ready to be placed under the
124-
* scheduler control. The registers have to be placed on the stack in
124+
* scheduler control. The registers have to be placed on the stack in
125125
* the order that the port expects to find them.
126126
*
127-
* For ARC, task context switch is implemented with the help of SWI exception
128-
* It's not efficient but simple.
127+
* For ARC, task context switch is implemented with the help of TRAP exception
129128
*
130129
*/
131130
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )

0 commit comments

Comments
 (0)