1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-21 23:56:18 +04:00

Add kernel stack for exception handling

Signed-off-by: Harry Chen <i@harrychen.xyz>
This commit is contained in:
Harry Chen 2019-04-02 01:41:48 +08:00
parent 4ddcdeb004
commit 0a02315990
4 changed files with 33 additions and 8 deletions

2
.gitignore vendored
View File

@ -13,3 +13,5 @@ Cargo.lock
# for eclipse # for eclipse
.project .project
.vscode

View File

@ -5,9 +5,22 @@
.globl _start .globl _start
_start: _start:
la sp, bootstacktop # setup stack and gp
la gp, _gp la sp, bootstacktop
la gp, _gp
# set ebase
la t0, trap_entry
mfc0 t1, 15 # C0_EBASE
or t1, t1, t0
mtc0 t1, 15
# exit bootstrap mode
mfc0 t0, 12 # C0_STATUS
andi t0, t0, 0xFFBFFFFF # set BEV (bit 22) to 0
mtc0 t0, 12
# directly jump to main function
b rust_main b rust_main
nop nop

View File

@ -17,6 +17,8 @@ SECTIONS
*(.text.entry) *(.text.entry)
*(.text .text.*) *(.text .text.*)
. = ALIGN(4K); . = ALIGN(4K);
*(.text.ebase)
. = ALIGN(4K);
etext = .; etext = .;
} }

View File

@ -2,8 +2,10 @@
.set noat .set noat
.set noreorder .set noreorder
.section .text .section .text.ebase
.globl trap_entry .globl trap_entry
.org 0x0
trap_entry: trap_entry:
# +0x000: TLB-miss vector # +0x000: TLB-miss vector
b general_trap_vec b general_trap_vec
@ -18,10 +20,9 @@ general_trap_vec:
nop # delayslot nop # delayslot
trap_from_user: trap_from_user:
# TODO: load kstack, we can use k0 to store something # load kstack, we can use k0 to store something
# la k0, address_of_kstack la k0, kernel_stack
# addiu sp, k0, size_of_kstack la sp, kernel_stack_top
nop
trap_from_kernel: trap_from_kernel:
/* /*
@ -92,7 +93,7 @@ trap_from_kernel:
# prepare to call rust_trap # prepare to call rust_trap
jal rust_trap jal rust_trap
addiu a0, sp, 16 /* set argument */ addiu a0, sp, 16 /* set argument (trapframe) */
.globl trap_return .globl trap_return
trap_return: trap_return:
@ -148,3 +149,10 @@ trap_return:
eret eret
nop nop
.section .bss.stack
.align 12 #PGSHIFT
.global kernel_stack
kernel_stack:
.space 1024 * 16 # 16KB for kernel stack
.global kernel_stack_top
kernel_stack_top: