Print out more useful information about AP and BSP, create kmain_ap
This commit is contained in:
parent
0d995bfb5c
commit
8ddddcec9f
|
@ -53,7 +53,7 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
// Allocate a stack
|
// Allocate a stack
|
||||||
// TODO: Allocate contiguous
|
// TODO: Allocate contiguous
|
||||||
let stack_start = allocate_frame().expect("no more frames").start_address().get();
|
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");
|
allocate_frame().expect("no more frames");
|
||||||
}
|
}
|
||||||
let stack_end = allocate_frame().expect("no more frames").start_address().get() + 4096;
|
let stack_end = allocate_frame().expect("no more frames").start_address().get() + 4096;
|
||||||
|
|
|
@ -36,14 +36,12 @@ pub unsafe fn stack_trace() {
|
||||||
println!("TRACE: {:>016X}", rbp);
|
println!("TRACE: {:>016X}", rbp);
|
||||||
//Maximum 64 frames
|
//Maximum 64 frames
|
||||||
for _frame in 0..64 {
|
for _frame in 0..64 {
|
||||||
unsafe {
|
let rip = *(rbp as *const usize).offset(1);
|
||||||
let rip = *(rbp as *const usize).offset(1);
|
println!(" {:>016X}: {:>016X}", rbp, rip);
|
||||||
println!(" {:>016X}: {:>016X}", rbp, rip);
|
if rip == 0 {
|
||||||
if rip == 0 {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
rbp = *(rbp as *const usize);
|
|
||||||
}
|
}
|
||||||
|
rbp = *(rbp as *const usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ use allocator::{HEAP_START, HEAP_SIZE};
|
||||||
use externs::memset;
|
use externs::memset;
|
||||||
use gdt;
|
use gdt;
|
||||||
use idt;
|
use idt;
|
||||||
use interrupt;
|
|
||||||
use memory;
|
use memory;
|
||||||
use paging::{self, entry, Page, VirtualAddress};
|
use paging::{self, entry, Page, VirtualAddress};
|
||||||
|
|
||||||
|
@ -27,6 +26,8 @@ static BSP_PAGE_TABLE: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||||
extern {
|
extern {
|
||||||
/// Kernel main function
|
/// Kernel main function
|
||||||
fn kmain() -> !;
|
fn kmain() -> !;
|
||||||
|
/// Kernel main for APs
|
||||||
|
fn kmain_ap() -> !;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The entry to Rust, all things must be initialized
|
/// 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);
|
let mut active_table = paging::init(stack_start, stack_end);
|
||||||
|
|
||||||
// Reset AP variables
|
// Reset AP variables
|
||||||
AP_COUNT.store(1, Ordering::SeqCst);
|
AP_COUNT.store(0, Ordering::SeqCst);
|
||||||
BSP_READY.store(false, Ordering::SeqCst);
|
BSP_READY.store(false, Ordering::SeqCst);
|
||||||
BSP_PAGE_TABLE.store(controlregs::cr3() as usize, 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']));
|
print!("{}", ::core::str::from_utf8_unchecked(&[b'A', b'P', b' ', ap_number as u8 + b'0', b'\n']));
|
||||||
|
|
||||||
loop {
|
kmain_ap();
|
||||||
interrupt::enable_and_halt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,14 @@ pub mod tests;
|
||||||
pub extern fn kmain() {
|
pub extern fn kmain() {
|
||||||
loop {
|
loop {
|
||||||
unsafe { interrupt::enable_and_halt(); }
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue