Changes to allow for detection and init of ASPs
This commit is contained in:
parent
7b2acdd79c
commit
08900d56c8
1 changed files with 343 additions and 48 deletions
51
arch/x86_64/src/acpi/local_apic.rs
Normal file
51
arch/x86_64/src/acpi/local_apic.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use x86::msr::*;
|
||||
|
||||
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;
|
||||
|
||||
impl LocalApic {
|
||||
pub fn new() -> Self {
|
||||
unsafe { wrmsr(IA32_APIC_BASE, rdmsr(IA32_APIC_BASE) | 1 << 10) }
|
||||
LocalApic
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u32 {
|
||||
unsafe { rdmsr(IA32_X2APIC_APICID) as u32 }
|
||||
}
|
||||
|
||||
pub fn version(&self) -> u32 {
|
||||
unsafe { rdmsr(IA32_X2APIC_VERSION) as u32 }
|
||||
}
|
||||
|
||||
pub fn icr(&self) -> u64 {
|
||||
unsafe { rdmsr(IA32_X2APIC_ICR) }
|
||||
}
|
||||
|
||||
pub fn set_icr(&mut self, value: u64) {
|
||||
unsafe { wrmsr(IA32_X2APIC_ICR, value) }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue