From 8ddddcec9f5608d6d763fd895b2568677ba35f5d Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 17 Aug 2016 19:38:04 -0600 Subject: [PATCH] Print out more useful information about AP and BSP, create kmain_ap --- arch/x86_64/src/acpi/mod.rs | 2 +- arch/x86_64/src/interrupt.rs | 12 +++++------- arch/x86_64/src/start.rs | 9 ++++----- kernel/lib.rs | 10 +++++++++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/arch/x86_64/src/acpi/mod.rs b/arch/x86_64/src/acpi/mod.rs index 786398c..ffd5b35 100644 --- a/arch/x86_64/src/acpi/mod.rs +++ b/arch/x86_64/src/acpi/mod.rs @@ -53,7 +53,7 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) { // Allocate a stack // TODO: Allocate contiguous let stack_start = allocate_frame().expect("no more frames").start_address().get(); - for i in 0..62 { + for _i in 0..62 { allocate_frame().expect("no more frames"); } let stack_end = allocate_frame().expect("no more frames").start_address().get() + 4096; diff --git a/arch/x86_64/src/interrupt.rs b/arch/x86_64/src/interrupt.rs index e269b08..783e132 100644 --- a/arch/x86_64/src/interrupt.rs +++ b/arch/x86_64/src/interrupt.rs @@ -36,14 +36,12 @@ pub unsafe fn stack_trace() { println!("TRACE: {:>016X}", rbp); //Maximum 64 frames for _frame in 0..64 { - unsafe { - let rip = *(rbp as *const usize).offset(1); - println!(" {:>016X}: {:>016X}", rbp, rip); - if rip == 0 { - break; - } - rbp = *(rbp as *const usize); + let rip = *(rbp as *const usize).offset(1); + println!(" {:>016X}: {:>016X}", rbp, rip); + if rip == 0 { + break; } + rbp = *(rbp as *const usize); } } diff --git a/arch/x86_64/src/start.rs b/arch/x86_64/src/start.rs index 48dd997..0439ef8 100644 --- a/arch/x86_64/src/start.rs +++ b/arch/x86_64/src/start.rs @@ -11,7 +11,6 @@ use allocator::{HEAP_START, HEAP_SIZE}; use externs::memset; use gdt; use idt; -use interrupt; use memory; use paging::{self, entry, Page, VirtualAddress}; @@ -27,6 +26,8 @@ static BSP_PAGE_TABLE: AtomicUsize = ATOMIC_USIZE_INIT; extern { /// Kernel main function fn kmain() -> !; + /// Kernel main for APs + fn kmain_ap() -> !; } /// The entry to Rust, all things must be initialized @@ -71,7 +72,7 @@ pub unsafe extern fn kstart() -> ! { let mut active_table = paging::init(stack_start, stack_end); // Reset AP variables - AP_COUNT.store(1, Ordering::SeqCst); + AP_COUNT.store(0, Ordering::SeqCst); BSP_READY.store(false, Ordering::SeqCst); BSP_PAGE_TABLE.store(controlregs::cr3() as usize, Ordering::SeqCst); @@ -116,7 +117,5 @@ pub unsafe extern fn kstart_ap(stack_start: usize, stack_end: usize) -> ! { print!("{}", ::core::str::from_utf8_unchecked(&[b'A', b'P', b' ', ap_number as u8 + b'0', b'\n'])); - loop { - interrupt::enable_and_halt(); - } + kmain_ap(); } diff --git a/kernel/lib.rs b/kernel/lib.rs index 61ad13d..c5dbf61 100644 --- a/kernel/lib.rs +++ b/kernel/lib.rs @@ -109,6 +109,14 @@ pub mod tests; pub extern fn kmain() { loop { unsafe { interrupt::enable_and_halt(); } - print!("HALT\n"); + print!("INT BSP\n"); + } +} + +#[no_mangle] +pub extern fn kmain_ap() { + loop { + unsafe { interrupt::enable_and_halt() } + print!("INT AP\n"); } }