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 stack: 0x8000, // just enough stack to get us to entry64mp
}; };
start_ap(apic_id, ENTRYOTHER_ADDR); start_ap(apic_id, ENTRYOTHER_ADDR);
while unsafe{ !STARTED[i as usize] } {}
} }
} }
fn copy_entryother() { fn copy_entryother() {
@ -44,4 +44,11 @@ struct EntryArgs {
kstack: u64, kstack: u64,
page_table: u32, page_table: u32,
stack: 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;
} }

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

@ -86,8 +86,9 @@ pub extern "C" fn other_main() -> ! {
arch::gdt::init(); arch::gdt::init();
arch::idt::init(); arch::idt::init();
arch::driver::apic::other_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()); 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 unsafe{ let a = *(0xdeadbeaf as *const u8); } // Page fault
loop {} loop {}
} }

Loading…
Cancel
Save