Keep track of AP count, allocate bigger AP stack, stack trace function
This commit is contained in:
parent
26c86f8242
commit
0d995bfb5c
1 changed files with 57 additions and 37 deletions
|
|
@ -2,22 +2,51 @@
|
|||
|
||||
/// Clear interrupts
|
||||
#[inline(always)]
|
||||
pub unsafe fn disable_interrupts() {
|
||||
pub unsafe fn disable() {
|
||||
asm!("cli" : : : : "intel", "volatile");
|
||||
}
|
||||
|
||||
/// Set interrupts
|
||||
#[inline(always)]
|
||||
pub unsafe fn enable_interrupts() {
|
||||
pub unsafe fn enable() {
|
||||
asm!("sti" : : : : "intel", "volatile");
|
||||
}
|
||||
|
||||
/// Set interrupts and halt
|
||||
#[inline(always)]
|
||||
pub unsafe fn enable_and_halt() {
|
||||
asm!("sti
|
||||
hlt"
|
||||
: : : : "intel", "volatile");
|
||||
}
|
||||
|
||||
/// Halt instruction
|
||||
#[inline(always)]
|
||||
pub unsafe fn halt() {
|
||||
asm!("hlt" : : : : "intel", "volatile");
|
||||
}
|
||||
|
||||
/// Get a stack trace
|
||||
//TODO: Check for stack being mapped before dereferencing
|
||||
#[inline(never)]
|
||||
pub unsafe fn stack_trace() {
|
||||
let mut rbp: usize;
|
||||
asm!("xchg bx, bx" : "={rbp}"(rbp) : : : "intel", "volatile");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// x86 External Interrupts (1-16).
|
||||
pub static EXCEPTIONS: [Descriptor; 21] = [
|
||||
Descriptor::new("Division error", Kind::Fault),
|
||||
|
|
|
|||
Loading…
Reference in a new issue