Print out more useful information about AP and BSP, create kmain_ap
This commit is contained in:
		
							parent
							
								
									0d995bfb5c
								
							
						
					
					
						commit
						8ddddcec9f
					
				
					 4 changed files with 19 additions and 14 deletions
				
			
		|  | @ -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; | ||||
|  |  | |||
|  | @ -36,7 +36,6 @@ 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 { | ||||
|  | @ -45,7 +44,6 @@ pub unsafe fn stack_trace() { | |||
|         rbp = *(rbp as *const usize); | ||||
|     } | ||||
| } | ||||
| } | ||||
| 
 | ||||
| /// x86 External Interrupts (1-16).
 | ||||
| pub static EXCEPTIONS: [Descriptor; 21] = [ | ||||
|  |  | |||
|  | @ -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(); | ||||
| } | ||||
|  |  | |||
|  | @ -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"); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jeremy Soller
						Jeremy Soller