mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-23 16:36:18 +04:00
Enable multi-core on RV32.
This commit is contained in:
parent
250f1385d3
commit
182c595a20
@ -13,7 +13,8 @@ _save_context:
|
|||||||
# save x registers except x2 (sp)
|
# save x registers except x2 (sp)
|
||||||
sw x1, 1*4(sp)
|
sw x1, 1*4(sp)
|
||||||
sw x3, 3*4(sp)
|
sw x3, 3*4(sp)
|
||||||
sw x4, 4*4(sp)
|
# tp(x4) = hartid. DON'T change.
|
||||||
|
# sw x4, 4*4(sp)
|
||||||
sw x5, 5*4(sp)
|
sw x5, 5*4(sp)
|
||||||
sw x6, 6*4(sp)
|
sw x6, 6*4(sp)
|
||||||
sw x7, 7*4(sp)
|
sw x7, 7*4(sp)
|
||||||
@ -73,7 +74,7 @@ _restore_context:
|
|||||||
# restore x registers except x2 (sp)
|
# restore x registers except x2 (sp)
|
||||||
lw x1, 1*4(sp)
|
lw x1, 1*4(sp)
|
||||||
lw x3, 3*4(sp)
|
lw x3, 3*4(sp)
|
||||||
lw x4, 4*4(sp)
|
# lw x4, 4*4(sp)
|
||||||
lw x5, 5*4(sp)
|
lw x5, 5*4(sp)
|
||||||
lw x6, 6*4(sp)
|
lw x6, 6*4(sp)
|
||||||
lw x7, 7*4(sp)
|
lw x7, 7*4(sp)
|
||||||
|
@ -42,7 +42,7 @@ pub unsafe fn restore(flags: usize) {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn rust_trap(tf: &mut TrapFrame) {
|
pub extern fn rust_trap(tf: &mut TrapFrame) {
|
||||||
use super::riscv::register::scause::{Trap, Interrupt as I, Exception as E};
|
use super::riscv::register::scause::{Trap, Interrupt as I, Exception as E};
|
||||||
trace!("Interrupt: {:?}", tf.scause.cause());
|
trace!("Interrupt @ CPU{}: {:?} ", super::cpu::id(), tf.scause.cause());
|
||||||
match tf.scause.cause() {
|
match tf.scause.cause() {
|
||||||
Trap::Interrupt(I::SupervisorSoft) => ipi(),
|
Trap::Interrupt(I::SupervisorSoft) => ipi(),
|
||||||
Trap::Interrupt(I::SupervisorTimer) => timer(),
|
Trap::Interrupt(I::SupervisorTimer) => timer(),
|
||||||
@ -50,7 +50,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
|
|||||||
Trap::Exception(E::UserEnvCall) => syscall(tf),
|
Trap::Exception(E::UserEnvCall) => syscall(tf),
|
||||||
_ => ::trap::error(tf),
|
_ => ::trap::error(tf),
|
||||||
}
|
}
|
||||||
::trap::before_return();
|
|
||||||
trace!("Interrupt end");
|
trace!("Interrupt end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize) -> ! {
|
|||||||
memory::init();
|
memory::init();
|
||||||
timer::init();
|
timer::init();
|
||||||
|
|
||||||
|
::process::init();
|
||||||
|
::thread::spawn(::fs::shell);
|
||||||
|
|
||||||
unsafe { cpu::start_others(hart_mask); }
|
unsafe { cpu::start_others(hart_mask); }
|
||||||
::kmain();
|
::kmain();
|
||||||
}
|
}
|
||||||
@ -33,8 +36,7 @@ pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize) -> ! {
|
|||||||
fn others_main() -> ! {
|
fn others_main() -> ! {
|
||||||
interrupt::init();
|
interrupt::init();
|
||||||
timer::init();
|
timer::init();
|
||||||
cpu::send_ipi(0);
|
::kmain();
|
||||||
loop { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "no_bbl")]
|
#[cfg(feature = "no_bbl")]
|
||||||
|
@ -97,7 +97,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
|
|||||||
T_DIVIDE | T_GPFLT | T_ILLOP => error(tf),
|
T_DIVIDE | T_GPFLT | T_ILLOP => error(tf),
|
||||||
_ => panic!("Unhandled interrupt {:x}", tf.trap_num),
|
_ => panic!("Unhandled interrupt {:x}", tf.trap_num),
|
||||||
}
|
}
|
||||||
::trap::before_return();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn breakpoint() {
|
fn breakpoint() {
|
||||||
|
@ -47,6 +47,9 @@ pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
|
|||||||
|
|
||||||
driver::init();
|
driver::init();
|
||||||
|
|
||||||
|
::process::init();
|
||||||
|
::thread::spawn(::fs::shell);
|
||||||
|
|
||||||
AP_CAN_INIT.store(true, Ordering::Relaxed);
|
AP_CAN_INIT.store(true, Ordering::Relaxed);
|
||||||
|
|
||||||
::kmain();
|
::kmain();
|
||||||
|
@ -62,11 +62,6 @@ pub mod arch;
|
|||||||
pub mod arch;
|
pub mod arch;
|
||||||
|
|
||||||
pub fn kmain() -> ! {
|
pub fn kmain() -> ! {
|
||||||
if arch::cpu::id() == 0 {
|
|
||||||
process::init();
|
|
||||||
thread::spawn(fs::shell);
|
|
||||||
}
|
|
||||||
|
|
||||||
process::processor().run();
|
process::processor().run();
|
||||||
|
|
||||||
// thread::test::local_key();
|
// thread::test::local_key();
|
||||||
|
@ -11,9 +11,6 @@ pub fn timer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn before_return() {
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn error(tf: &TrapFrame) -> ! {
|
pub fn error(tf: &TrapFrame) -> ! {
|
||||||
error!("{:#x?}", tf);
|
error!("{:#x?}", tf);
|
||||||
let pid = processor().pid();
|
let pid = processor().pid();
|
||||||
|
Loading…
Reference in New Issue
Block a user