8 enum class Mode { Disabled, XApic, X2Apic, Invalid };
9 static constexpr uint32_t BaseMsr = 0x1B;
10 static constexpr uint64_t Enabled = 1ULL << 11;
11 static constexpr uint64_t Extended = 1ULL << 10;
12 static constexpr uint32_t X2ApicMsrBase = 0x800;
13 static constexpr uint32_t X2ApicIcrMsr = 0x830;
15 static constexpr Mode decode(uint64_t apicBase) {
16 return (apicBase & Enabled) ? ((apicBase & Extended) ? Mode::X2Apic : Mode::XApic)
17 : ((apicBase & Extended) ? Mode::Invalid : Mode::Disabled);
20 static constexpr uint32_t x2ApicMsr(uint32_t registerOffset) {
21 return X2ApicMsrBase + (registerOffset >> 4);
24 static constexpr uint64_t x2ApicIcr(uint32_t legacyHigh, uint32_t low) {
25 return (uint64_t{legacyHigh >> 24} << 32) | low;