/* if the register index is invalid or unsupported in current APIC mode, then ASSERT. */
VOID EFIAPI WriteLocalApicReg(IN UINTN MmioOffset, IN UINT32 Value)
/* if the register index is invalid or unsupported in current APIC mode, then ASSERT. */
VOID EFIAPI WriteLocalApicReg(IN UINTN MmioOffset, IN UINT32 Value)
{
  UINT32  MsrIndex;
  ASSERT ((MmioOffset & 0xf) == 0);
  if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) {
    MmioWrite32 (GetLocalApicBaseAddress () + MmioOffset, Value);
  } else {
    ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET);
    ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET);
    ASSERT (MmioOffset != XAPIC_ICR_LOW_OFFSET);
    MsrIndex =  (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS;
    MemoryFence ();
    LocalApicWriteMsrReg32 (MsrIndex, Value);
  }
}