feat: move boot page table into board

This commit is contained in:
Paul Pan 2024-04-12 22:39:48 +08:00
parent 1f91c77b4f
commit 1a924738f0
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,41 @@
use cfg_if::cfg_if;
use core::arch::global_asm;
cfg_if! {
if #[cfg(target_arch = "riscv32")] {
global_asm!("
.section .text
boot_setup_early_paging:
jr ra
"
);
} else if #[cfg(target_arch = "riscv64")]{
global_asm!("
.section .text
boot_setup_early_paging:
lla t1, boot_page_table
srli t1, t1, 12
li t2, 8 << 60
or t1, t1, t2
csrw satp, t1
sfence.vma
jr ra
.section .temp.boot_page_table
.align 12
boot_page_table:
# sv39 page table
# 0x00000000_00000000 -> 0x00000000 [ 0x00000000_00000000 -> 0x00000000_40000000 ]
# 0x00000000_40000000 -> 0x40000000 [ 0x00000000_40000000 -> 0x00000000_80000000 ]
# 0x00000000_80000000 -> 0x80000000 [ 0x00000000_80000000 -> 0x00000001_00000000 ]
# 0xFFFFFFD0_00000000 -> 0x80000000 [ 0xFFFFFFD0_00000000 -> 0xFFFFFFD0_40000000 ]
.quad (0x00000 << 10) | 0xf
.quad (0x40000 << 10) | 0xf
.quad (0x80000 << 10) | 0xf
.zero 8 * 317
.quad (0x80000 << 10) | 0xf
.zero 8 * 191
"
);
}
}

View File

@ -1,4 +1,5 @@
pub const TIMER_TICKS: u64 = 100_000; // 100ms pub const TIMER_TICKS: u64 = 100_000; // 100ms
mod boot;
pub mod console; pub mod console;
mod lowlevel; mod lowlevel;

View File

@ -5,5 +5,7 @@ pub const UART0_BASE: usize = 0x1000_0000;
pub const UART0_LSR: usize = 0x1000_0005; pub const UART0_LSR: usize = 0x1000_0005;
pub const TEST_DEVICE: *mut u32 = 0x10_0000 as *mut u32; pub const TEST_DEVICE: *mut u32 = 0x10_0000 as *mut u32;
#[path = "../default/boot.rs"]
mod boot;
pub mod console; pub mod console;
mod lowlevel; mod lowlevel;