Better debugging messages
This commit is contained in:
		
							parent
							
								
									f706dda8af
								
							
						
					
					
						commit
						da88cdcb61
					
				
					 2 changed files with 19 additions and 43 deletions
				
			
		| 
						 | 
				
			
			@ -5,33 +5,9 @@ use x86::msr::*;
 | 
			
		|||
use memory::Frame;
 | 
			
		||||
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
 | 
			
		||||
#[repr(packed)]
 | 
			
		||||
pub struct LocalApic {
 | 
			
		||||
    address: u32,
 | 
			
		||||
    pub address: u32,
 | 
			
		||||
    pub x2: bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,8 +18,6 @@ impl LocalApic {
 | 
			
		|||
            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) };
 | 
			
		||||
| 
						 | 
				
			
			@ -51,11 +25,8 @@ impl LocalApic {
 | 
			
		|||
        if CpuId::new().get_feature_info().unwrap().has_x2apic() {
 | 
			
		||||
            unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 10) };
 | 
			
		||||
            apic.x2 = true;
 | 
			
		||||
            println!("X2APIC {:X}", unsafe { rdmsr(IA32_APIC_BASE) });
 | 
			
		||||
        } else {
 | 
			
		||||
            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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ use memory::{allocate_frame, Frame};
 | 
			
		|||
use paging::{entry, ActivePageTable, Page, PhysicalAddress, VirtualAddress};
 | 
			
		||||
use start::{kstart_ap, AP_READY};
 | 
			
		||||
 | 
			
		||||
use self::local_apic::{LocalApic, LocalApicIcr};
 | 
			
		||||
use self::local_apic::LocalApic;
 | 
			
		||||
use self::madt::{Madt, MadtEntry};
 | 
			
		||||
use self::rsdt::Rsdt;
 | 
			
		||||
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() {
 | 
			
		||||
        print!("{}", c as char);
 | 
			
		||||
    }
 | 
			
		||||
    println!(":");
 | 
			
		||||
 | 
			
		||||
    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 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() {
 | 
			
		||||
            println!("      {:?}", 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) };
 | 
			
		||||
                        AP_READY.store(false, Ordering::SeqCst);
 | 
			
		||||
 | 
			
		||||
                        print!("        AP {}:", ap_local_apic.id);
 | 
			
		||||
 | 
			
		||||
                        // Send INIT IPI
 | 
			
		||||
                        {
 | 
			
		||||
                            let mut icr = 0x4500;
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +87,7 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
 | 
			
		|||
                            } else {
 | 
			
		||||
                                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);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,20 +103,20 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
 | 
			
		|||
                                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);
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        // Wait for trampoline ready
 | 
			
		||||
                        println!("        Waiting for AP {}", ap_local_apic.id);
 | 
			
		||||
                        print!(" Wait...");
 | 
			
		||||
                        while unsafe { atomic_load(ap_ready) } == 0 {
 | 
			
		||||
                            interrupt::pause();
 | 
			
		||||
                        }
 | 
			
		||||
                        println!("        AP {} is trampolined!", ap_local_apic.id);
 | 
			
		||||
                        print!(" Trampoline...");
 | 
			
		||||
                        while ! AP_READY.load(Ordering::SeqCst) {
 | 
			
		||||
                            interrupt::pause();
 | 
			
		||||
                        }
 | 
			
		||||
                        println!("        AP {} is ready!", ap_local_apic.id);
 | 
			
		||||
                        println!(" Ready");
 | 
			
		||||
                    } else {
 | 
			
		||||
                        println!("        CPU Disabled");
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			@ -117,8 +124,8 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
 | 
			
		|||
                _ => ()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }else {
 | 
			
		||||
        println!("    {:?}", sdt);
 | 
			
		||||
    } else {
 | 
			
		||||
        println!(": Unknown");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -140,8 +147,6 @@ pub unsafe fn init(active_table: &mut ActivePageTable) -> Option<Acpi> {
 | 
			
		|||
 | 
			
		||||
    // Search for RSDP
 | 
			
		||||
    if let Some(rsdp) = RSDP::search(start_addr, end_addr) {
 | 
			
		||||
        println!("{:?}", rsdp);
 | 
			
		||||
 | 
			
		||||
        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() {
 | 
			
		||||
                let sdt_frame = Frame::containing_address(PhysicalAddress::new(sdt_address));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue