update small
This commit is contained in:
parent
9f19ea65e8
commit
12b0c2ed98
|
@ -16,9 +16,9 @@ SECTIONS
|
|||
*(.text.entry)
|
||||
*(.text .text.*)
|
||||
. = ALIGN(4K);
|
||||
_swap_seg = .;
|
||||
_swap_frame = .;
|
||||
*(.swap)
|
||||
ASSERT(. - _swap_seg <= 4K, "swap segment larger than one page");
|
||||
ASSERT(. - _swap_frame <= 4K, "swap frame larger than one page");
|
||||
_etext = .;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ pub extern "C" fn rust_main(hart_id: usize) -> ! {
|
|||
|
||||
static _sidata: u32;
|
||||
|
||||
fn _swap_seg();
|
||||
fn _swap_frame();
|
||||
fn _user2supervisor();
|
||||
fn _supervisor2user();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -84,7 +86,8 @@ pub extern "C" fn rust_main(hart_id: usize) -> ! {
|
|||
};
|
||||
println!("Test #{}: {:?} and {:?}", i, frame_0.start_address(), frame_1.start_address());
|
||||
}
|
||||
println!("swap segment: {:#x}", _swap_seg as usize);
|
||||
println!("swap frame: {:#x}, user2supervisor: {:#x}, supervisor2user: {:#x}",
|
||||
_swap_frame as usize, _user2supervisor as usize, _supervisor2user as usize);
|
||||
// let executor = task::Executor::default();
|
||||
|
||||
// executor.spawn(async {
|
||||
|
|
|
@ -52,6 +52,7 @@ impl SwapContext {
|
|||
// 先保存 SwapContext,然后切换到内核的地址空间
|
||||
#[naked]
|
||||
#[link_section = ".swap"]
|
||||
#[export_name = "_user2supervisor"]
|
||||
unsafe extern "C" fn user2supervisor() -> ! {
|
||||
asm!(
|
||||
// 交换 a0 和 sscratch(原先保存着交换栈的栈顶指针)
|
||||
|
@ -120,6 +121,7 @@ unsafe extern "C" fn user2supervisor() -> ! {
|
|||
|
||||
// trap_frame作为ctx?
|
||||
#[link_section = ".swap"]
|
||||
#[export_name = "_supervisor2user"]
|
||||
unsafe extern "C" fn supervisor2user(ctx: usize, satp: usize) -> ! {
|
||||
asm!("
|
||||
csrw satp, {satp}
|
||||
|
|
Loading…
Reference in New Issue