diff --git a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp index 40835319..e5c7dcbf 100644 --- a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp +++ b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp @@ -90,7 +90,7 @@ namespace APIC do { icr.raw = this->Read(APIC_ICRLO); - } while (icr.DeliveryStatus != 0); + } while (icr.DeliveryStatus != Idle); } void APIC::IPI(uint8_t CPU, InterruptCommandRegisterLow icr) @@ -121,7 +121,7 @@ namespace APIC { InterruptCommandRegisterLow icr; icr.DeliveryMode = INIT; - icr.Level = 1; + icr.Level = Assert; this->Write(APIC_ICRHI, (CPU << 24)); this->Write(APIC_ICRLO, icr.raw); this->WaitForIPI(); @@ -141,7 +141,7 @@ namespace APIC InterruptCommandRegisterLow icr; icr.Vector = StartupAddress >> 12; icr.DeliveryMode = Startup; - icr.Level = 1; + icr.Level = Assert; this->Write(APIC_ICRHI, (CPU << 24)); this->Write(APIC_ICRLO, icr.raw); this->WaitForIPI(); @@ -358,8 +358,8 @@ namespace APIC // Config for IRQ0 timer LVTTimer timer = {.raw = 0}; timer.Vector = IRQ0; - timer.Mask = 0; - timer.TimerMode = 1; + timer.Mask = Unmasked; + timer.TimerMode = Periodic; // Initialize APIC timer this->lapic->Write(APIC_TDCR, 0x0); diff --git a/Architecture/amd64/cpu/apic.hpp b/Architecture/amd64/cpu/apic.hpp index cfb2ff1d..d5fa169c 100644 --- a/Architecture/amd64/cpu/apic.hpp +++ b/Architecture/amd64/cpu/apic.hpp @@ -51,13 +51,71 @@ namespace APIC enum APICDeliveryMode { - Fixed = 0, - LowestPriority = 1, - SMI = 2, - NMI = 4, - INIT = 5, - Startup = 6, - ExtINT = 7 + Fixed = 0b000, + LowestPriority = 0b001, /* Reserved */ + SMI = 0b010, + APIC_DELIVERY_MODE_RESERVED0 = 0b011, /* Reserved */ + NMI = 0b100, + INIT = 0b101, + Startup = 0b110, + ExtINT = 0b111 /* Reserved */ + }; + + enum APICDestinationMode + { + Physical = 0b0, + Logical = 0b1 + }; + + enum APICDeliveryStatus + { + Idle = 0b0, + SendPending = 0b1 + }; + + enum APICLevel + { + DeAssert = 0b0, + Assert = 0b1 + }; + + enum APICTriggerMode + { + Edge = 0b0, + Level = 0b1 + }; + + enum APICDestinationShorthand + { + NoShorthand = 0b00, + Self = 0b01, + AllIncludingSelf = 0b10, + AllExcludingSelf = 0b11 + }; + + enum APICTimerDivide + { + DivideBy2 = 0b000, + DivideBy4 = 0b001, + DivideBy8 = 0b010, + DivideBy16 = 0b011, + DivideBy32 = 0b100, + DivideBy64 = 0b101, + DivideBy128 = 0b110, + DivideBy1 = 0b111 + }; + + enum LVTTimerMask + { + Unmasked = 0b0, + Masked = 0b1 + }; + + enum LVTTimerMode + { + OneShot = 0b00, + Periodic = 0b01, + TSCDeadline = 0b10 }; typedef union @@ -218,7 +276,7 @@ namespace APIC uint64_t DestinationID : 8; }; uint64_t raw; - } __attribute__((packed)) RedirectEntry; + } __attribute__((packed)) IOAPICRedirectEntry; typedef union {