mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-23 00:16:17 +04:00
Fix alignment issue in TrapFrame.
This commit is contained in:
parent
c59cbe0dbc
commit
cc5bb8a81f
@ -1,3 +1,3 @@
|
||||
/// board specific constants
|
||||
pub const MEMORY_END: usize = 0x8800_0000;
|
||||
pub const KERNEL_HEAP_SIZE: usize = 0x00a0_0000;
|
||||
pub const MEMORY_END: usize = 0x8080_0000;
|
||||
pub const KERNEL_HEAP_SIZE: usize = 0x0044_0000;
|
||||
|
@ -4,7 +4,7 @@
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
|
||||
BASE_ADDRESS = 0x80000000;
|
||||
BASE_ADDRESS = 0x80100000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
@ -32,6 +32,17 @@ trap_from_kernel:
|
||||
* k1 = old stack pointer
|
||||
* sp = kernel stack */
|
||||
|
||||
# align stack pointer
|
||||
andi k0, sp, 0xf
|
||||
beqz k0, sp_aligned
|
||||
nop
|
||||
|
||||
la k0, 0xfffffff0
|
||||
and k0, sp, k0
|
||||
sw sp, -176(k0)
|
||||
move sp, k0
|
||||
|
||||
sp_aligned:
|
||||
# allocate 38 words for trapframe + 6 extra words
|
||||
addiu sp, sp, -176
|
||||
|
||||
@ -147,9 +158,12 @@ trap_return:
|
||||
lw fp, 156(sp)
|
||||
lw ra, 160(sp)
|
||||
|
||||
// save kernel stack
|
||||
la k0, _cur_kstack_ptr
|
||||
# save kernel stack
|
||||
lw k0, 0(sp)
|
||||
addiu k1, sp, 176
|
||||
movn k1, k0, k0
|
||||
|
||||
la k0, _cur_kstack_ptr
|
||||
sw k1, 0(k0)
|
||||
nop
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
///
|
||||
pub use super::board::consts::*;
|
||||
|
||||
pub const KERNEL_OFFSET: usize = 0x80000000;
|
||||
pub const KERNEL_OFFSET: usize = 0x80100000;
|
||||
|
||||
pub const MEMORY_OFFSET: usize = 0x8000_0000;
|
||||
|
||||
|
@ -5,8 +5,10 @@ use mips::tlb;
|
||||
#[derive(Clone)]
|
||||
#[repr(C)]
|
||||
pub struct TrapFrame {
|
||||
/// unused 16 bytes
|
||||
pub unused: [usize; 4],
|
||||
/// Non-zero if the kernel stack is not 16-byte-aligned
|
||||
pub unaligned_kstack: usize,
|
||||
/// unused 12 bytes
|
||||
pub unused: [usize; 3],
|
||||
/// CP0 status register
|
||||
pub status: cp0::status::Status,
|
||||
/// CP0 cause register
|
||||
|
@ -60,6 +60,11 @@ pub unsafe fn restore(flags: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn stack_pointer_not_aligned(sp: usize) {
|
||||
panic!("Stack pointer not aligned: sp = 0x{:x?}", sp);
|
||||
}
|
||||
|
||||
/// Dispatch and handle interrupt.
|
||||
///
|
||||
/// This function is called from `trap.asm`.
|
||||
|
Loading…
Reference in New Issue
Block a user