1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 08:26:17 +04:00

Enable multi-core on RV32.

This commit is contained in:
WangRunji 2018-10-31 11:45:25 +08:00
parent 250f1385d3
commit 182c595a20
7 changed files with 11 additions and 15 deletions

View File

@ -13,7 +13,8 @@ _save_context:
# save x registers except x2 (sp)
sw x1, 1*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 x6, 6*4(sp)
sw x7, 7*4(sp)
@ -73,7 +74,7 @@ _restore_context:
# restore x registers except x2 (sp)
lw x1, 1*4(sp)
lw x3, 3*4(sp)
lw x4, 4*4(sp)
# lw x4, 4*4(sp)
lw x5, 5*4(sp)
lw x6, 6*4(sp)
lw x7, 7*4(sp)

View File

@ -42,7 +42,7 @@ pub unsafe fn restore(flags: usize) {
#[no_mangle]
pub extern fn rust_trap(tf: &mut TrapFrame) {
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() {
Trap::Interrupt(I::SupervisorSoft) => ipi(),
Trap::Interrupt(I::SupervisorTimer) => timer(),
@ -50,7 +50,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
Trap::Exception(E::UserEnvCall) => syscall(tf),
_ => ::trap::error(tf),
}
::trap::before_return();
trace!("Interrupt end");
}

View File

@ -26,6 +26,9 @@ pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize) -> ! {
memory::init();
timer::init();
::process::init();
::thread::spawn(::fs::shell);
unsafe { cpu::start_others(hart_mask); }
::kmain();
}
@ -33,8 +36,7 @@ pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize) -> ! {
fn others_main() -> ! {
interrupt::init();
timer::init();
cpu::send_ipi(0);
loop { }
::kmain();
}
#[cfg(feature = "no_bbl")]

View File

@ -97,7 +97,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
T_DIVIDE | T_GPFLT | T_ILLOP => error(tf),
_ => panic!("Unhandled interrupt {:x}", tf.trap_num),
}
::trap::before_return();
}
fn breakpoint() {

View File

@ -47,6 +47,9 @@ pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
driver::init();
::process::init();
::thread::spawn(::fs::shell);
AP_CAN_INIT.store(true, Ordering::Relaxed);
::kmain();

View File

@ -62,11 +62,6 @@ pub mod arch;
pub mod arch;
pub fn kmain() -> ! {
if arch::cpu::id() == 0 {
process::init();
thread::spawn(fs::shell);
}
process::processor().run();
// thread::test::local_key();

View File

@ -11,9 +11,6 @@ pub fn timer() {
}
}
pub fn before_return() {
}
pub fn error(tf: &TrapFrame) -> ! {
error!("{:#x?}", tf);
let pid = processor().pid();