From 9b41a1276853b5eb37172d172f8d6a63f344a5fe Mon Sep 17 00:00:00 2001 From: ablechen <17895010372@163.com> Date: Tue, 8 Nov 2022 21:46:12 +0800 Subject: [PATCH] allocate memory for trap --- code/os/05-traps/start.S | 6 ++++++ code/os/06-interrupts/start.S | 6 ++++++ code/os/07-hwtimer/start.S | 6 ++++++ code/os/08-preemptive/start.S | 6 ++++++ code/os/09-lock/start.S | 6 ++++++ code/os/10-swtimer/start.S | 6 ++++++ code/os/11-syscall/start.S | 6 ++++++ 7 files changed, 42 insertions(+) diff --git a/code/os/05-traps/start.S b/code/os/05-traps/start.S index c7ad5e4..7c19fa8 100644 --- a/code/os/05-traps/start.S +++ b/code/os/05-traps/start.S @@ -30,12 +30,18 @@ _start: add sp, sp, t0 # move the current hart stack pointer # to its place in the stack space + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks diff --git a/code/os/06-interrupts/start.S b/code/os/06-interrupts/start.S index c7ad5e4..7c19fa8 100644 --- a/code/os/06-interrupts/start.S +++ b/code/os/06-interrupts/start.S @@ -30,12 +30,18 @@ _start: add sp, sp, t0 # move the current hart stack pointer # to its place in the stack space + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks diff --git a/code/os/07-hwtimer/start.S b/code/os/07-hwtimer/start.S index c7ad5e4..7c19fa8 100644 --- a/code/os/07-hwtimer/start.S +++ b/code/os/07-hwtimer/start.S @@ -30,12 +30,18 @@ _start: add sp, sp, t0 # move the current hart stack pointer # to its place in the stack space + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks diff --git a/code/os/08-preemptive/start.S b/code/os/08-preemptive/start.S index 0b730a9..e127424 100644 --- a/code/os/08-preemptive/start.S +++ b/code/os/08-preemptive/start.S @@ -40,12 +40,18 @@ _start: or t0, t0, a1 csrw mstatus, t0 + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks diff --git a/code/os/09-lock/start.S b/code/os/09-lock/start.S index 0b730a9..e127424 100644 --- a/code/os/09-lock/start.S +++ b/code/os/09-lock/start.S @@ -40,12 +40,18 @@ _start: or t0, t0, a1 csrw mstatus, t0 + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks diff --git a/code/os/10-swtimer/start.S b/code/os/10-swtimer/start.S index 0b730a9..9a9e5fc 100644 --- a/code/os/10-swtimer/start.S +++ b/code/os/10-swtimer/start.S @@ -40,8 +40,14 @@ _start: or t0, t0, a1 csrw mstatus, t0 + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c +trap_stack: + .skip STACK_SIZE + park: wfi j park diff --git a/code/os/11-syscall/start.S b/code/os/11-syscall/start.S index ba34f12..d595d7c 100644 --- a/code/os/11-syscall/start.S +++ b/code/os/11-syscall/start.S @@ -64,12 +64,18 @@ _start: or t0, t0, a1 csrw mstatus, t0 + la t0, trap_stack + csrw mscratch, t0 + j start_kernel # hart 0 jump to c park: wfi j park +trap_stack: + .skip STACK_SIZE + stacks: .skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks -- Gitee