Start AP one by one. Fix deadlock.

master
WangRunji 7 years ago
parent 2b813b2acc
commit cb19bc5464

@ -25,8 +25,8 @@ pub fn start_other_cores(acpi: &ACPI_Result, mc: &mut MemoryController) {
stack: 0x8000, // just enough stack to get us to entry64mp
};
start_ap(apic_id, ENTRYOTHER_ADDR);
while unsafe{ !STARTED[i as usize] } {}
}
}
fn copy_entryother() {
@ -45,3 +45,10 @@ struct EntryArgs {
page_table: u32,
stack: u32,
}
use consts::MAX_CPU_NUM;
static mut STARTED: [bool; MAX_CPU_NUM] = [false; MAX_CPU_NUM];
pub unsafe fn notify_started(cpu_id: u8) {
STARTED[cpu_id as usize] = true;
}

@ -30,9 +30,11 @@ use arch::driver::vga::Color;
fn print_in_color(args: fmt::Arguments, color: Color) {
use core::fmt::Write;
use arch::driver::vga::*;
let mut writer = vga_writer::VGA_WRITER.lock();
writer.set_color(color);
writer.write_fmt(args).unwrap();
{
let mut writer = vga_writer::VGA_WRITER.lock();
writer.set_color(color);
writer.write_fmt(args).unwrap();
}
COM1.lock().write_fmt(args).unwrap();
}

@ -86,8 +86,9 @@ pub extern "C" fn other_main() -> ! {
arch::gdt::init();
arch::idt::init();
arch::driver::apic::other_init();
// FIXME: deadlock!
let cpu_id = arch::driver::apic::lapic_id();
println!("Hello world! from CPU {}!", arch::driver::apic::lapic_id());
unsafe{ arch::smp::notify_started(cpu_id); }
unsafe{ let a = *(0xdeadbeaf as *const u8); } // Page fault
loop {}
}

Loading…
Cancel
Save