/* This function reads from a local APIC register either in xAPIC or x2APIC mode. It is required that in xAPIC mode wider registers (64-bit or 256-bit) must be accessed using multiple 32-bit loads or stores, so this function only performs 32-bit read. */
UINT32 EFIAPI ReadLocalApicReg(IN UINTN MmioOffset)
/* This function reads from a local APIC register either in xAPIC or x2APIC mode. It is required that in xAPIC mode wider registers (64-bit or 256-bit) must be accessed using multiple 32-bit loads or stores, so this function only performs 32-bit read. */
UINT32 EFIAPI ReadLocalApicReg(IN UINTN MmioOffset)
{
  UINT32  MsrIndex;
  ASSERT ((MmioOffset & 0xf) == 0);
  if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) {
    return MmioRead32 (GetLocalApicBaseAddress () + MmioOffset);
  } else {
    ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET);
    ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET);
    MsrIndex = (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS;
    return LocalApicReadMsrReg32 (MsrIndex);
  }
}