Better debugging messages
This commit is contained in:
parent
f706dda8af
commit
da88cdcb61
|
@ -5,33 +5,9 @@ use x86::msr::*;
|
||||||
use memory::Frame;
|
use memory::Frame;
|
||||||
use paging::{entry, ActivePageTable, PhysicalAddress};
|
use paging::{entry, ActivePageTable, PhysicalAddress};
|
||||||
|
|
||||||
bitflags! {
|
|
||||||
pub flags LocalApicIcr: u64 {
|
|
||||||
const ICR_VECTOR = 0xFF,
|
|
||||||
|
|
||||||
const ICR_FIXED = 0b000 << 8,
|
|
||||||
const ICR_SMI = 0b010 << 8,
|
|
||||||
const ICR_NMI = 0b100 << 8,
|
|
||||||
const ICR_INIT = 0b101 << 8,
|
|
||||||
const ICR_START = 0b110 << 8,
|
|
||||||
|
|
||||||
const ICR_PHYSICAL = 0 << 11,
|
|
||||||
const ICR_LOGICAL = 1 << 11,
|
|
||||||
|
|
||||||
const ICR_DEASSERT = 0 << 14,
|
|
||||||
const ICR_ASSERT = 1 << 14,
|
|
||||||
|
|
||||||
const ICR_EDGE = 0 << 15,
|
|
||||||
const ICR_LEVEL = 1 << 15,
|
|
||||||
|
|
||||||
const ICR_DESTINATION = 0b1111 << 56,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Local APIC
|
/// Local APIC
|
||||||
#[repr(packed)]
|
|
||||||
pub struct LocalApic {
|
pub struct LocalApic {
|
||||||
address: u32,
|
pub address: u32,
|
||||||
pub x2: bool
|
pub x2: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +18,6 @@ impl LocalApic {
|
||||||
x2: false
|
x2: false
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("APIC BASE: {:>08X}", apic.address);
|
|
||||||
|
|
||||||
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) & !(1 << 11 | 1 << 10)) };
|
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) & !(1 << 11 | 1 << 10)) };
|
||||||
|
|
||||||
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 11) };
|
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 11) };
|
||||||
|
@ -51,11 +25,8 @@ impl LocalApic {
|
||||||
if CpuId::new().get_feature_info().unwrap().has_x2apic() {
|
if CpuId::new().get_feature_info().unwrap().has_x2apic() {
|
||||||
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 10) };
|
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 10) };
|
||||||
apic.x2 = true;
|
apic.x2 = true;
|
||||||
println!("X2APIC {:X}", unsafe { rdmsr(IA32_APIC_BASE) });
|
|
||||||
} else {
|
} else {
|
||||||
active_table.identity_map(Frame::containing_address(PhysicalAddress::new(apic.address as usize)), entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE);
|
active_table.identity_map(Frame::containing_address(PhysicalAddress::new(apic.address as usize)), entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE);
|
||||||
|
|
||||||
println!("XAPIC {:X}", unsafe { rdmsr(IA32_APIC_BASE) });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apic
|
apic
|
||||||
|
|
|
@ -9,7 +9,7 @@ use memory::{allocate_frame, Frame};
|
||||||
use paging::{entry, ActivePageTable, Page, PhysicalAddress, VirtualAddress};
|
use paging::{entry, ActivePageTable, Page, PhysicalAddress, VirtualAddress};
|
||||||
use start::{kstart_ap, AP_READY};
|
use start::{kstart_ap, AP_READY};
|
||||||
|
|
||||||
use self::local_apic::{LocalApic, LocalApicIcr};
|
use self::local_apic::LocalApic;
|
||||||
use self::madt::{Madt, MadtEntry};
|
use self::madt::{Madt, MadtEntry};
|
||||||
use self::rsdt::Rsdt;
|
use self::rsdt::Rsdt;
|
||||||
use self::sdt::Sdt;
|
use self::sdt::Sdt;
|
||||||
|
@ -29,15 +29,20 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
for &c in sdt.signature.iter() {
|
for &c in sdt.signature.iter() {
|
||||||
print!("{}", c as char);
|
print!("{}", c as char);
|
||||||
}
|
}
|
||||||
println!(":");
|
|
||||||
|
|
||||||
if let Some(madt) = Madt::new(sdt) {
|
if let Some(madt) = Madt::new(sdt) {
|
||||||
println!(" {:>016X}: {}", madt.local_address, madt.flags);
|
println!(": {:>08X}: {}", madt.local_address, madt.flags);
|
||||||
|
|
||||||
let mut local_apic = LocalApic::new(active_table);
|
let mut local_apic = LocalApic::new(active_table);
|
||||||
|
|
||||||
let me = local_apic.id() as u8;
|
let me = local_apic.id() as u8;
|
||||||
|
|
||||||
|
if local_apic.x2 {
|
||||||
|
println!(" X2APIC {}", me);
|
||||||
|
} else {
|
||||||
|
println!(" XAPIC {}: {:>08X}", me, local_apic.address);
|
||||||
|
}
|
||||||
|
|
||||||
for madt_entry in madt.iter() {
|
for madt_entry in madt.iter() {
|
||||||
println!(" {:?}", madt_entry);
|
println!(" {:?}", madt_entry);
|
||||||
match madt_entry {
|
match madt_entry {
|
||||||
|
@ -72,6 +77,8 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
unsafe { atomic_store(ap_code, kstart_ap as u64) };
|
unsafe { atomic_store(ap_code, kstart_ap as u64) };
|
||||||
AP_READY.store(false, Ordering::SeqCst);
|
AP_READY.store(false, Ordering::SeqCst);
|
||||||
|
|
||||||
|
print!(" AP {}:", ap_local_apic.id);
|
||||||
|
|
||||||
// Send INIT IPI
|
// Send INIT IPI
|
||||||
{
|
{
|
||||||
let mut icr = 0x4500;
|
let mut icr = 0x4500;
|
||||||
|
@ -80,7 +87,7 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
} else {
|
} else {
|
||||||
icr |= (ap_local_apic.id as u64) << 56;
|
icr |= (ap_local_apic.id as u64) << 56;
|
||||||
}
|
}
|
||||||
println!(" Sending IPI to {}: {:>016X} {:?}", ap_local_apic.id, icr, LocalApicIcr::from_bits(icr));
|
print!(" IPI...");
|
||||||
local_apic.set_icr(icr);
|
local_apic.set_icr(icr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,20 +103,20 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
icr |= (ap_local_apic.id as u64) << 56;
|
icr |= (ap_local_apic.id as u64) << 56;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(" Sending SIPI to {}: {:>016X} {:?}", ap_local_apic.id, icr, LocalApicIcr::from_bits(icr));
|
print!(" SIPI...");
|
||||||
local_apic.set_icr(icr);
|
local_apic.set_icr(icr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for trampoline ready
|
// Wait for trampoline ready
|
||||||
println!(" Waiting for AP {}", ap_local_apic.id);
|
print!(" Wait...");
|
||||||
while unsafe { atomic_load(ap_ready) } == 0 {
|
while unsafe { atomic_load(ap_ready) } == 0 {
|
||||||
interrupt::pause();
|
interrupt::pause();
|
||||||
}
|
}
|
||||||
println!(" AP {} is trampolined!", ap_local_apic.id);
|
print!(" Trampoline...");
|
||||||
while ! AP_READY.load(Ordering::SeqCst) {
|
while ! AP_READY.load(Ordering::SeqCst) {
|
||||||
interrupt::pause();
|
interrupt::pause();
|
||||||
}
|
}
|
||||||
println!(" AP {} is ready!", ap_local_apic.id);
|
println!(" Ready");
|
||||||
} else {
|
} else {
|
||||||
println!(" CPU Disabled");
|
println!(" CPU Disabled");
|
||||||
}
|
}
|
||||||
|
@ -118,7 +125,7 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!(" {:?}", sdt);
|
println!(": Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +147,6 @@ pub unsafe fn init(active_table: &mut ActivePageTable) -> Option<Acpi> {
|
||||||
|
|
||||||
// Search for RSDP
|
// Search for RSDP
|
||||||
if let Some(rsdp) = RSDP::search(start_addr, end_addr) {
|
if let Some(rsdp) = RSDP::search(start_addr, end_addr) {
|
||||||
println!("{:?}", rsdp);
|
|
||||||
|
|
||||||
let get_sdt = |sdt_address: usize, active_table: &mut ActivePageTable| -> &'static Sdt {
|
let get_sdt = |sdt_address: usize, active_table: &mut ActivePageTable| -> &'static Sdt {
|
||||||
if active_table.translate_page(Page::containing_address(VirtualAddress::new(sdt_address))).is_none() {
|
if active_table.translate_page(Page::containing_address(VirtualAddress::new(sdt_address))).is_none() {
|
||||||
let sdt_frame = Frame::containing_address(PhysicalAddress::new(sdt_address));
|
let sdt_frame = Frame::containing_address(PhysicalAddress::new(sdt_address));
|
||||||
|
|
Loading…
Reference in a new issue