diff options
| author | Man, Jianting (Meco) <[email protected]> | 2021-08-17 16:56:10 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-17 16:56:10 -0500 |
| commit | 3e6578916f892e4456d9dff4bbd44590a0cb4bc8 (patch) | |
| tree | b98d9fe601ce62e17b37f5b971f0cc9f965fa0e3 /libcpu/aarch64/cortex-a53 | |
| parent | 37a9231e6219b94f7cde8bdea9251e260c4bed18 (diff) | |
| parent | 196f340e5d845efd005b57a2089e0642266a79be (diff) | |
Merge branch 'master' into security
Diffstat (limited to 'libcpu/aarch64/cortex-a53')
| -rw-r--r-- | libcpu/aarch64/cortex-a53/entry_point.S | 7 | ||||
| -rw-r--r-- | libcpu/aarch64/cortex-a53/interrupt.c | 29 | ||||
| -rw-r--r-- | libcpu/aarch64/cortex-a53/interrupt.h | 4 | ||||
| -rw-r--r-- | libcpu/aarch64/cortex-a53/stack.c | 108 | ||||
| -rw-r--r-- | libcpu/aarch64/cortex-a53/trap.c | 45 |
5 files changed, 119 insertions, 74 deletions
diff --git a/libcpu/aarch64/cortex-a53/entry_point.S b/libcpu/aarch64/cortex-a53/entry_point.S index 6d2c69226b..552e5916ce 100644 --- a/libcpu/aarch64/cortex-a53/entry_point.S +++ b/libcpu/aarch64/cortex-a53/entry_point.S @@ -35,7 +35,7 @@ _start: // ldr x2, =EL1_stack // mov sp, x2 - ldr x1, =_start + ldr x1, =init_el1_stack_limit // set up EL1 mrs x0, CurrentEL // CurrentEL Register. bit 2, 3. Others reserved @@ -109,3 +109,8 @@ _start: bl entry // for failsafe, halt this core too b .L__current_cpu_idle +.bss +.align 3 +init_el1_stack: + .space 4096 +init_el1_stack_limit: diff --git a/libcpu/aarch64/cortex-a53/interrupt.c b/libcpu/aarch64/cortex-a53/interrupt.c index a412ca1953..ba49be5132 100644 --- a/libcpu/aarch64/cortex-a53/interrupt.c +++ b/libcpu/aarch64/cortex-a53/interrupt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -7,8 +7,9 @@ * Date Author Notes * 2018/5/3 Bernard first version * 2019-07-28 zdzn add smp support - * 2019-08-09 zhangjun fixup the problem of smp startup and scheduling issues, + * 2019-08-09 zhangjun fixup the problem of smp startup and scheduling issues, * write addr to mailbox3 to startup smp, and we use mailbox0 for ipi + * 2021-07-31 GuEe-GUI Add gic pl390 branch */ #include <rthw.h> @@ -19,6 +20,10 @@ #include "armv8.h" #include "interrupt.h" +#ifdef BSP_USING_GIC390 +#include <gic_pl390.h> +#endif + #define MAX_HANDLERS 72 #ifdef RT_USING_SMP @@ -41,6 +46,7 @@ void rt_hw_vector_init(void) rt_hw_set_current_vbar((rt_ubase_t)&system_vectors); // cpu_gcc.S } +#ifndef BSP_USING_GIC static void default_isr_handler(int vector, void *param) { #ifdef RT_USING_SMP @@ -49,12 +55,16 @@ static void default_isr_handler(int vector, void *param) rt_kprintf("unhandled irq: %d\n",vector); #endif } +#endif /** * This function will initialize hardware interrupt */ void rt_hw_interrupt_init(void) { +#ifdef BSP_USING_GIC390 + arm_gic_irq_init(); +#else rt_uint32_t index; /* mask all of interrupts */ @@ -76,6 +86,7 @@ void rt_hw_interrupt_init(void) rt_interrupt_from_thread = 0; rt_interrupt_to_thread = 0; rt_thread_switch_interrupt_flag = 0; +#endif } /** @@ -84,6 +95,9 @@ void rt_hw_interrupt_init(void) */ void rt_hw_interrupt_mask(int vector) { +#ifdef BSP_USING_GIC390 + arm_gic_mask(vector); +#else if (vector < 32) { IRQ_DISABLE1 = (1 << vector); @@ -98,6 +112,7 @@ void rt_hw_interrupt_mask(int vector) vector = vector - 64; IRQ_DISABLE_BASIC = (1 << vector); } +#endif } /** @@ -106,6 +121,9 @@ void rt_hw_interrupt_mask(int vector) */ void rt_hw_interrupt_umask(int vector) { +#ifdef BSP_USING_GIC390 + arm_gic_umask(vector); +#else if (vector < 32) { IRQ_ENABLE1 = (1 << vector); @@ -120,6 +138,7 @@ void rt_hw_interrupt_umask(int vector) vector = vector - 64; IRQ_ENABLE_BASIC = (1 << vector); } +#endif } /** @@ -160,15 +179,15 @@ void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask) } if(cpu_mask & 0x2) { - send_ipi_msg(1, ipi_vector); + send_ipi_msg(1, ipi_vector); } if(cpu_mask & 0x4) { - send_ipi_msg(2, ipi_vector); + send_ipi_msg(2, ipi_vector); } if(cpu_mask & 0x8) { - send_ipi_msg(3, ipi_vector); + send_ipi_msg(3, ipi_vector); } __DSB(); } diff --git a/libcpu/aarch64/cortex-a53/interrupt.h b/libcpu/aarch64/cortex-a53/interrupt.h index 8e741ed4e6..72e69bd808 100644 --- a/libcpu/aarch64/cortex-a53/interrupt.h +++ b/libcpu/aarch64/cortex-a53/interrupt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -14,8 +14,6 @@ #include <rthw.h> #include <board.h> -#include "raspi.h" - #define INT_IRQ 0x00 #define INT_FIQ 0x01 diff --git a/libcpu/aarch64/cortex-a53/stack.c b/libcpu/aarch64/cortex-a53/stack.c index 68222c2c67..751793d7a3 100644 --- a/libcpu/aarch64/cortex-a53/stack.c +++ b/libcpu/aarch64/cortex-a53/stack.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -21,70 +21,70 @@ * This function will initialize thread stack * * @param tentry the entry of thread - * @param parameter the parameter of entry + * @param parameter the parameter of entry * @param stack_addr the beginning stack address * @param texit the function will be called when thread exit * * @return stack address */ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, - rt_uint8_t *stack_addr, void *texit) + rt_uint8_t *stack_addr, void *texit) { - rt_ubase_t *stk; - rt_ubase_t current_el; + rt_ubase_t *stk; + rt_ubase_t current_el; - stk = (rt_ubase_t*)stack_addr; + stk = (rt_ubase_t*)stack_addr; - *(--stk) = ( rt_ubase_t ) 11; /* X1 */ - *(--stk) = ( rt_ubase_t ) parameter; /* X0 */ - *(--stk) = ( rt_ubase_t ) 33; /* X3 */ - *(--stk) = ( rt_ubase_t ) 22; /* X2 */ - *(--stk) = ( rt_ubase_t ) 55; /* X5 */ - *(--stk) = ( rt_ubase_t ) 44; /* X4 */ - *(--stk) = ( rt_ubase_t ) 77; /* X7 */ - *(--stk) = ( rt_ubase_t ) 66; /* X6 */ - *(--stk) = ( rt_ubase_t ) 99; /* X9 */ - *(--stk) = ( rt_ubase_t ) 88; /* X8 */ - *(--stk) = ( rt_ubase_t ) 11; /* X11 */ - *(--stk) = ( rt_ubase_t ) 10; /* X10 */ - *(--stk) = ( rt_ubase_t ) 13; /* X13 */ - *(--stk) = ( rt_ubase_t ) 12; /* X12 */ - *(--stk) = ( rt_ubase_t ) 15; /* X15 */ - *(--stk) = ( rt_ubase_t ) 14; /* X14 */ - *(--stk) = ( rt_ubase_t ) 17; /* X17 */ - *(--stk) = ( rt_ubase_t ) 16; /* X16 */ - *(--stk) = ( rt_ubase_t ) 19; /* X19 */ - *(--stk) = ( rt_ubase_t ) 18; /* X18 */ - *(--stk) = ( rt_ubase_t ) 21; /* X21 */ - *(--stk) = ( rt_ubase_t ) 20; /* X20 */ - *(--stk) = ( rt_ubase_t ) 23; /* X23 */ - *(--stk) = ( rt_ubase_t ) 22; /* X22 */ - *(--stk) = ( rt_ubase_t ) 25; /* X25 */ - *(--stk) = ( rt_ubase_t ) 24; /* X24 */ - *(--stk) = ( rt_ubase_t ) 27; /* X27 */ - *(--stk) = ( rt_ubase_t ) 26; /* X26 */ - *(--stk) = ( rt_ubase_t ) 29; /* X29 */ - *(--stk) = ( rt_ubase_t ) 28; /* X28 */ - *(--stk) = ( rt_ubase_t ) 0; /* XZR - has no effect, used so there are an even number of registers. */ - *(--stk) = ( rt_ubase_t ) texit; /* X30 - procedure call link register. */ + *(--stk) = ( rt_ubase_t ) 11; /* X1 */ + *(--stk) = ( rt_ubase_t ) parameter; /* X0 */ + *(--stk) = ( rt_ubase_t ) 33; /* X3 */ + *(--stk) = ( rt_ubase_t ) 22; /* X2 */ + *(--stk) = ( rt_ubase_t ) 55; /* X5 */ + *(--stk) = ( rt_ubase_t ) 44; /* X4 */ + *(--stk) = ( rt_ubase_t ) 77; /* X7 */ + *(--stk) = ( rt_ubase_t ) 66; /* X6 */ + *(--stk) = ( rt_ubase_t ) 99; /* X9 */ + *(--stk) = ( rt_ubase_t ) 88; /* X8 */ + *(--stk) = ( rt_ubase_t ) 11; /* X11 */ + *(--stk) = ( rt_ubase_t ) 10; /* X10 */ + *(--stk) = ( rt_ubase_t ) 13; /* X13 */ + *(--stk) = ( rt_ubase_t ) 12; /* X12 */ + *(--stk) = ( rt_ubase_t ) 15; /* X15 */ + *(--stk) = ( rt_ubase_t ) 14; /* X14 */ + *(--stk) = ( rt_ubase_t ) 17; /* X17 */ + *(--stk) = ( rt_ubase_t ) 16; /* X16 */ + *(--stk) = ( rt_ubase_t ) 19; /* X19 */ + *(--stk) = ( rt_ubase_t ) 18; /* X18 */ + *(--stk) = ( rt_ubase_t ) 21; /* X21 */ + *(--stk) = ( rt_ubase_t ) 20; /* X20 */ + *(--stk) = ( rt_ubase_t ) 23; /* X23 */ + *(--stk) = ( rt_ubase_t ) 22; /* X22 */ + *(--stk) = ( rt_ubase_t ) 25; /* X25 */ + *(--stk) = ( rt_ubase_t ) 24; /* X24 */ + *(--stk) = ( rt_ubase_t ) 27; /* X27 */ + *(--stk) = ( rt_ubase_t ) 26; /* X26 */ + *(--stk) = ( rt_ubase_t ) 29; /* X29 */ + *(--stk) = ( rt_ubase_t ) 28; /* X28 */ + *(--stk) = ( rt_ubase_t ) 0; /* XZR - has no effect, used so there are an even number of registers. */ + *(--stk) = ( rt_ubase_t ) texit; /* X30 - procedure call link register. */ - current_el = rt_hw_get_current_el(); + current_el = rt_hw_get_current_el(); - if(current_el == 3) - { - *(--stk) = INITIAL_SPSR_EL3; - } - else if(current_el == 2) - { - *(--stk) = INITIAL_SPSR_EL2; - } - else - { - *(--stk) = INITIAL_SPSR_EL1; - } + if(current_el == 3) + { + *(--stk) = INITIAL_SPSR_EL3; + } + else if(current_el == 2) + { + *(--stk) = INITIAL_SPSR_EL2; + } + else + { + *(--stk) = INITIAL_SPSR_EL1; + } - *(--stk) = ( rt_ubase_t ) tentry; /* Exception return address. */ + *(--stk) = ( rt_ubase_t ) tentry; /* Exception return address. */ - /* return task's current stack address */ - return (rt_uint8_t *)stk; + /* return task's current stack address */ + return (rt_uint8_t *)stk; } diff --git a/libcpu/aarch64/cortex-a53/trap.c b/libcpu/aarch64/cortex-a53/trap.c index 41d4d620f6..ca5b6ecd44 100644 --- a/libcpu/aarch64/cortex-a53/trap.c +++ b/libcpu/aarch64/cortex-a53/trap.c @@ -1,10 +1,11 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Date Author Notes - * 2018-10-06 ZhaoXiaowei the first version + * 2018-10-06 ZhaoXiaowei the first version + * 2021-07-31 GuEe-GUI Add gic_pl390 branch */ #include <rtthread.h> @@ -13,6 +14,10 @@ #include "interrupt.h" #include "armv8.h" +#ifdef BSP_USING_GIC390 +#include <gic_pl390.h> +#endif + extern struct rt_thread *rt_current_thread; #ifdef RT_USING_FINSH extern long list_thread(void); @@ -28,14 +33,14 @@ void rt_hw_show_register(struct rt_hw_exp_stack *regs) rt_kprintf("Execption:\n"); rt_kprintf("r00:0x%16.16lx r01:0x%16.16lx r02:0x%16.16lx r03:0x%16.16lx\n", regs->x0, regs->x1, regs->x2, regs->x3); rt_kprintf("r04:0x%16.16lx r05:0x%16.16lx r06:0x%16.16lx r07:0x%16.16lx\n", regs->x4, regs->x5, regs->x6, regs->x7); - rt_kprintf("r08:0x%16.16lx r09:0x%16.16lx r10:0x%16.16lx r11:0x%16.16lx\n", regs->x8, regs->x9, regs->x10, regs->x11); - rt_kprintf("r12:0x%16.16lx r13:0x%16.16lx r14:0x%16.16lx r15:0x%16.16lx\n", regs->x12, regs->x13, regs->x14, regs->x15); - rt_kprintf("r16:0x%16.16lx r17:0x%16.16lx r18:0x%16.16lx r19:0x%16.16lx\n", regs->x16, regs->x17, regs->x18, regs->x19); - rt_kprintf("r20:0x%16.16lx r21:0x%16.16lx r22:0x%16.16lx r23:0x%16.16lx\n", regs->x20, regs->x21, regs->x22, regs->x23); + rt_kprintf("r08:0x%16.16lx r09:0x%16.16lx r10:0x%16.16lx r11:0x%16.16lx\n", regs->x8, regs->x9, regs->x10, regs->x11); + rt_kprintf("r12:0x%16.16lx r13:0x%16.16lx r14:0x%16.16lx r15:0x%16.16lx\n", regs->x12, regs->x13, regs->x14, regs->x15); + rt_kprintf("r16:0x%16.16lx r17:0x%16.16lx r18:0x%16.16lx r19:0x%16.16lx\n", regs->x16, regs->x17, regs->x18, regs->x19); + rt_kprintf("r20:0x%16.16lx r21:0x%16.16lx r22:0x%16.16lx r23:0x%16.16lx\n", regs->x20, regs->x21, regs->x22, regs->x23); rt_kprintf("r24:0x%16.16lx r25:0x%16.16lx r26:0x%16.16lx r27:0x%16.16lx\n", regs->x24, regs->x25, regs->x26, regs->x27); - rt_kprintf("r28:0x%16.16lx r29:0x%16.16lx r30:0x%16.16lx\n", regs->x28, regs->x29, regs->x30); - rt_kprintf("spsr:0x%16.16lx\n", regs->spsr); - rt_kprintf("return pc:0x%16.16lx\n", regs->pc); + rt_kprintf("r28:0x%16.16lx r29:0x%16.16lx r30:0x%16.16lx\n", regs->x28, regs->x29, regs->x30); + rt_kprintf("spsr:0x%16.16lx\n", regs->spsr); + rt_kprintf("return pc:0x%16.16lx\n", regs->pc); } /** @@ -57,7 +62,7 @@ void rt_hw_trap_error(struct rt_hw_exp_stack *regs) } #define GIC_ACK_INTID_MASK (0x000003ff) -#define CORE0_IRQ_SOURCE (0x40000060) +#define CORE0_IRQ_SOURCE (0x40000060) void rt_hw_trap_irq(void) { @@ -65,6 +70,8 @@ void rt_hw_trap_irq(void) uint32_t irq; rt_isr_handler_t isr_func; extern struct rt_irq_desc isr_table[]; + +#ifndef BSP_USING_GIC390 uint32_t value = 0; value = IRQ_PEND_BASIC & 0x3ff; #ifdef BSP_USING_CORETIMER @@ -100,6 +107,15 @@ void rt_hw_trap_irq(void) value &= 0x0f; irq = __rt_ffs(value) + 63; } +#else + irq = arm_gic_get_active_irq(); + + if (irq == GIC390_IRQ_NONE) + { + /* Spurious interrupt */ + return; + } +#endif /* get interrupt service routine */ isr_func = isr_table[irq].handler; @@ -113,11 +129,17 @@ void rt_hw_trap_irq(void) /* turn to interrupt service routine */ isr_func(irq, param); } +#ifndef BSP_USING_GIC390 } +#else + /* end of interrupt */ + arm_gic_ack(irq); +#endif } void rt_hw_trap_fiq(void) { +#ifndef BSP_USING_GIC390 void *param; uint32_t irq; rt_isr_handler_t isr_func; @@ -199,4 +221,5 @@ void rt_hw_trap_fiq(void) isr_func(irq, param); } } +#endif } |
