Get local APIC timer ready to run
This commit is contained in:
parent
5799f94efe
commit
9b52ae58e8
@ -9,6 +9,8 @@ import hulk.acpi;
|
|||||||
|
|
||||||
struct apic
|
struct apic
|
||||||
{
|
{
|
||||||
|
private enum uint PERIODIC_MODE = 0x2_0000u;
|
||||||
|
|
||||||
static struct ApicRegister
|
static struct ApicRegister
|
||||||
{
|
{
|
||||||
public uint value;
|
public uint value;
|
||||||
@ -49,10 +51,11 @@ struct apic
|
|||||||
ApicRegister divide_configuration;
|
ApicRegister divide_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static __gshared ApicRegisters * apic_registers;
|
||||||
|
|
||||||
public static void initialize()
|
public static void initialize()
|
||||||
{
|
{
|
||||||
ApicRegisters * apic_registers =
|
apic_registers = cast(ApicRegisters *)acpi.apic_address;
|
||||||
cast(ApicRegisters *)acpi.apic_address;
|
|
||||||
hurl.map(cast(ulong)apic_registers, cast(ulong)apic_registers,
|
hurl.map(cast(ulong)apic_registers, cast(ulong)apic_registers,
|
||||||
PT_WRITABLE | PT_WRITE_THROUGH | PT_DISABLE_CACHE | PT_NO_EXECUTE);
|
PT_WRITABLE | PT_WRITE_THROUGH | PT_DISABLE_CACHE | PT_NO_EXECUTE);
|
||||||
klog.writefln("LAPIC ID: 0x%08x", apic_registers.lapic_id.value);
|
klog.writefln("LAPIC ID: 0x%08x", apic_registers.lapic_id.value);
|
||||||
@ -60,8 +63,19 @@ struct apic
|
|||||||
/* Enable local APIC to receive interrupts and set spurious interrupt
|
/* Enable local APIC to receive interrupts and set spurious interrupt
|
||||||
* vector to 0xFF. */
|
* vector to 0xFF. */
|
||||||
apic_registers.spurious_interrupt_vector.value = 0x1FFu;
|
apic_registers.spurious_interrupt_vector.value = 0x1FFu;
|
||||||
apic_registers.lvt_timer.value = 0x70u;
|
apic_registers.lvt_timer.value = 0x70u | PERIODIC_MODE;
|
||||||
apic_registers.lvt_lint[0].value = 0x71u;
|
apic_registers.lvt_lint[0].value = 0x71u;
|
||||||
apic_registers.lvt_lint[1].value = 0x72u;
|
apic_registers.lvt_lint[1].value = 0x72u;
|
||||||
|
apic_registers.divide_configuration.value = 3u;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void eoi()
|
||||||
|
{
|
||||||
|
apic_registers.eoi.value = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isr()
|
||||||
|
{
|
||||||
|
eoi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user