47 if ((FamilyId == 0x04) || (FamilyId == 0x05)) {
77 return PcdGet32 (PcdCpuLocalApicBaseAddress);
102 ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0);
113 ApicBaseMsr.
Bits.
ApicBase = (UINT32)(BaseAddress >> 12);
138 ASSERT ((MmioOffset & 0xf) == 0);
165 ASSERT ((MmioOffset & 0xf) == 0);
187 BOOLEAN InterruptState;
190 ASSERT (ApicId <= 0xff);
258 ASSERT (ApicBaseMsr.
Bits.
EN != 0);
259 ASSERT (ApicBaseMsr.
Bits.
EXTD == 0);
303 UINT32 MaxCpuIdIndex;
321 if ((RegEbx & (BIT16 - 1)) != 0) {
389 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED;
390 IcrLow.Bits.
Level = 1;
391 IcrLow.Bits.
Vector = Vector;
392 SendIpi (IcrLow.Uint32, ApicId);
411 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED;
412 IcrLow.Bits.
Level = 1;
414 IcrLow.Bits.
Vector = Vector;
434 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI;
435 IcrLow.Bits.
Level = 1;
436 SendIpi (IcrLow.Uint32, ApicId);
453 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI;
454 IcrLow.Bits.
Level = 1;
475 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT;
476 IcrLow.Bits.
Level = 1;
477 SendIpi (IcrLow.Uint32, ApicId);
494 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT;
495 IcrLow.Bits.
Level = 1;
511 IN UINT32 StartupRoutine
516 ASSERT (StartupRoutine < 0x100000);
517 ASSERT ((StartupRoutine & 0xfff) == 0);
520 IcrLow.Bits.
Vector = (StartupRoutine >> 12);
521 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP;
522 IcrLow.Bits.
Level = 1;
543 IN UINT32 StartupRoutine
548 ASSERT (StartupRoutine < 0x100000);
549 ASSERT ((StartupRoutine & 0xfff) == 0);
554 IcrLow.Bits.
Vector = (StartupRoutine >> 12);
555 IcrLow.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP;
556 IcrLow.Bits.
Level = 1;
557 SendIpi (IcrLow.Uint32, ApicId);
560 SendIpi (IcrLow.Uint32, ApicId);
578 IN UINT32 StartupRoutine
652 Lint.Bits.
DeliveryMode = LOCAL_APIC_DELIVERY_MODE_EXTINT;
683 LvtLint.Bits.
Mask = 1;
687 LvtLint.Bits.
Mask = 1;
735 IN BOOLEAN PeriodicMode,
753 if (DivideValue != 0) {
754 ASSERT (DivideValue <= 128);
756 Divisor = (UINT32)((
HighBitSet32 ((UINT32)DivideValue) - 1) & 0x7);
774 LvtTimer.Bits.
Mask = 0;
775 LvtTimer.Bits.
Vector = Vector;
792 OUT BOOLEAN *PeriodicMode OPTIONAL,
793 OUT UINT8 *Vector OPTIONAL
807 if (DivideValue !=
NULL) {
810 Divisor = (Divisor + 1) & 0x7;
811 *DivideValue = ((
UINTN)1) << Divisor;
814 if ((PeriodicMode !=
NULL) || (Vector !=
NULL)) {
816 if (PeriodicMode !=
NULL) {
818 *PeriodicMode =
TRUE;
820 *PeriodicMode =
FALSE;
824 if (Vector !=
NULL) {
825 *Vector = (UINT8)LvtTimer.Bits.
Vector;
842 LvtTimer.Bits.
Mask = 0;
858 LvtTimer.Bits.
Mask = 1;
877 return (BOOLEAN)(LvtTimer.Bits.
Mask == 0);
910 MsiAddress.Uint32 = 0;
913 return MsiAddress.Uint32;
949 IN BOOLEAN LevelTriggered,
950 IN BOOLEAN AssertionLevel
955 ASSERT (Vector >= 0x10 && Vector <= 0xFE);
956 ASSERT (DeliveryMode < 8 && DeliveryMode != 6 && DeliveryMode != 3);
959 MsiData.Bits.
Vector = Vector;
961 if (LevelTriggered) {
963 if (AssertionLevel) {
964 MsiData.Bits.
Level = 1;
968 return MsiData.Uint64;
986 IN UINT32 InitialApicId,
987 OUT UINT32 *Package OPTIONAL,
988 OUT UINT32 *Core OPTIONAL,
989 OUT UINT32 *Thread OPTIONAL
992 BOOLEAN TopologyLeafSupported;
1002 UINT32 MaxStandardCpuIdIndex;
1003 UINT32 MaxExtendedCpuIdIndex;
1006 UINT32 MaxLogicProcessorsPerPackage;
1007 UINT32 MaxCoresPerPackage;
1015 if (VersionInfoEdx.
Bits.
HTT == 0) {
1016 if (Thread !=
NULL) {
1024 if (Package !=
NULL) {
1047 TopologyLeafSupported =
FALSE;
1052 &ExtendedTopologyEax.
Uint32,
1053 &ExtendedTopologyEbx.
Uint32,
1054 &ExtendedTopologyEcx.
Uint32,
1062 if (ExtendedTopologyEbx.
Uint32 != 0) {
1063 TopologyLeafSupported =
TRUE;
1070 ASSERT (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT);
1082 &ExtendedTopologyEax.
Uint32,
1084 &ExtendedTopologyEcx.
Uint32,
1088 if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE) {
1098 if (!TopologyLeafSupported) {
1108 MaxCoresPerPackage = 1;
1127 MaxCoresPerPackage = MaxLogicProcessorsPerPackage / (AmdProcessorTopologyEbx.
Bits.
ThreadsPerCore + 1);
1136 if (CacheParamsEax.
Uint32 != 0) {
1142 ThreadBits = (
UINTN)(
HighBitSet32 (MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1);
1146 if (Thread !=
NULL) {
1147 *Thread = InitialApicId & ((1 << ThreadBits) - 1);
1151 *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1);
1154 if (Package !=
NULL) {
1155 *Package = (InitialApicId >> (ThreadBits + CoreBits));
1178 IN UINT32 InitialApicId,
1179 OUT UINT32 *Package OPTIONAL,
1180 OUT UINT32 *Die OPTIONAL,
1181 OUT UINT32 *Tile OPTIONAL,
1182 OUT UINT32 *Module OPTIONAL,
1183 OUT UINT32 *Core OPTIONAL,
1184 OUT UINT32 *Thread OPTIONAL
1189 UINT32 MaxStandardCpuIdIndex;
1192 UINT32 Bits[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 2];
1193 UINT32 *Location[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 2];
1195 for (LevelType = 0; LevelType <
ARRAY_SIZE (Bits); LevelType++) {
1196 Bits[LevelType] = 0;
1212 if (Module !=
NULL) {
1224 for (Index = 0; ; Index++) {
1228 &ExtendedTopologyEax.
Uint32,
1230 &ExtendedTopologyEcx.
Uint32,
1239 ASSERT ((Index != 0) || (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT));
1248 for (LevelType = CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE; LevelType <
ARRAY_SIZE (Bits); LevelType++) {
1253 if (Bits[LevelType] == 0) {
1254 Bits[LevelType] = Bits[LevelType - 1];
1258 Location[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 1] = Package;
1259 Location[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE] = Die;
1260 Location[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_TILE] = Tile;
1262 Location[CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE] = Core;
1263 Location[CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT] = Thread;
1265 Bits[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 1] = 32;
1267 for ( LevelType = CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT
1268 ; LevelType <= CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 1
1272 if (Location[LevelType] !=
NULL) {
1277 *Location[LevelType] = InitialApicId >> Bits[LevelType - 1];
1282 *Location[LevelType] &= (1 << (Bits[LevelType] - Bits[LevelType - 1])) - 1;
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
#define ARRAY_SIZE(Array)
BOOLEAN EFIAPI SetInterruptState(IN BOOLEAN InterruptState)
BOOLEAN EFIAPI SaveAndDisableInterrupts(VOID)
UINT32 EFIAPI GetPowerOfTwo32(IN UINT32 Operand)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
UINT32 EFIAPI BitFieldRead32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
VOID EFIAPI SendInitSipiSipiAllExcludingSelf(IN UINT32 StartupRoutine)
VOID EFIAPI SendFixedIpiAllExcludingSelf(IN UINT8 Vector)
VOID EFIAPI InitializeLocalApicSoftwareEnable(IN BOOLEAN Enable)
UINT32 EFIAPI ReadLocalApicReg(IN UINTN MmioOffset)
VOID EFIAPI SendSmiIpi(IN UINT32 ApicId)
UINT32 EFIAPI GetApicVersion(VOID)
BOOLEAN EFIAPI GetApicTimerInterruptState(VOID)
VOID EFIAPI SetLocalApicBaseAddress(IN UINTN BaseAddress)
UINT32 EFIAPI GetApicId(VOID)
VOID EFIAPI DisableLvtInterrupts(VOID)
VOID EFIAPI GetApicTimerState(OUT UINTN *DivideValue OPTIONAL, OUT BOOLEAN *PeriodicMode OPTIONAL, OUT UINT8 *Vector OPTIONAL)
VOID EFIAPI SendInitIpi(IN UINT32 ApicId)
UINT32 EFIAPI GetInitialApicId(VOID)
VOID EFIAPI SendInitIpiAllExcludingSelf(VOID)
BOOLEAN LocalApicBaseAddressMsrSupported(VOID)
VOID EFIAPI SendSmiIpiAllExcludingSelf(VOID)
UINTN EFIAPI GetApicMode(VOID)
VOID EFIAPI ProgramVirtualWireMode(VOID)
VOID EFIAPI EnableApicTimerInterrupt(VOID)
UINT32 EFIAPI GetApicMsiAddress(VOID)
VOID SendIpi(IN UINT32 IcrLow, IN UINT32 ApicId)
VOID EFIAPI SendStartupIpiAllExcludingSelf(IN UINT32 StartupRoutine)
VOID EFIAPI SendFixedIpi(IN UINT32 ApicId, IN UINT8 Vector)
VOID EFIAPI WriteLocalApicReg(IN UINTN MmioOffset, IN UINT32 Value)
VOID EFIAPI SetApicMode(IN UINTN ApicMode)
UINT32 EFIAPI GetApicTimerInitCount(VOID)
UINTN EFIAPI GetLocalApicBaseAddress(VOID)
UINT64 EFIAPI GetApicMsiValue(IN UINT8 Vector, IN UINTN DeliveryMode, IN BOOLEAN LevelTriggered, IN BOOLEAN AssertionLevel)
VOID EFIAPI GetProcessorLocation2ByApicId(IN UINT32 InitialApicId, OUT UINT32 *Package OPTIONAL, OUT UINT32 *Die OPTIONAL, OUT UINT32 *Tile OPTIONAL, OUT UINT32 *Module OPTIONAL, OUT UINT32 *Core OPTIONAL, OUT UINT32 *Thread OPTIONAL)
VOID EFIAPI GetProcessorLocationByApicId(IN UINT32 InitialApicId, OUT UINT32 *Package OPTIONAL, OUT UINT32 *Core OPTIONAL, OUT UINT32 *Thread OPTIONAL)
VOID EFIAPI InitializeApicTimer(IN UINTN DivideValue, IN UINT32 InitCount, IN BOOLEAN PeriodicMode, IN UINT8 Vector)
VOID EFIAPI SendApicEoi(VOID)
UINT32 EFIAPI GetApicTimerCurrentCount(VOID)
VOID EFIAPI SendInitSipiSipi(IN UINT32 ApicId, IN UINT32 StartupRoutine)
VOID EFIAPI DisableApicTimerInterrupt(VOID)
UINT32 EFIAPI AsmCpuidEx(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
#define DEBUG_CODE_BEGIN()
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
UINT64 EFIAPI AsmWriteMsr64(IN UINT32 Index, IN UINT64 Value)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
#define LOCAL_APIC_MODE_XAPIC
xAPIC mode.
#define CPUID_AMD_PROCESSOR_TOPOLOGY
#define MSR_IA32_APIC_BASE
#define CPUID_CACHE_PARAMS
#define CPUID_VERSION_INFO
#define CPUID_EXTENDED_TOPOLOGY
#define CPUID_V2_EXTENDED_TOPOLOGY
#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_MODULE
#define CPUID_EXTENDED_CPU_SIG
#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
#define PcdGet32(TokenName)
BOOLEAN EFIAPI StandardSignatureIsAuthenticAMD(VOID)
struct CPUID_AMD_EXTENDED_CPU_SIG_ECX::@538 Bits
UINT32 TopologyExtensions
struct CPUID_AMD_PROCESSOR_TOPOLOGY_EBX::@544 Bits
struct CPUID_AMD_VIR_PHY_ADDRESS_SIZE_ECX::@542 Bits
UINT32 MaximumAddressableIdsForLogicalProcessors
struct CPUID_CACHE_PARAMS_EAX::@635 Bits
struct CPUID_EXTENDED_TOPOLOGY_EAX::@651 Bits
struct CPUID_EXTENDED_TOPOLOGY_ECX::@653 Bits
struct CPUID_VERSION_INFO_EBX::@631 Bits
UINT32 MaximumAddressableIdsForLogicalProcessors
struct CPUID_VERSION_INFO_EDX::@633 Bits
UINT32 DivideValue1
Low 2 bits of the divide value.
UINT32 DivideValue2
Highest 1 bit of the divide value.
UINT32 Vector
The vector number of the interrupt being sent.
UINT32 DeliveryMode
Specifies the type of IPI to be sent.
UINT32 Level
0 for the INIT level de-assert delivery mode. Otherwise 1.
UINT32 DestinationShorthand
A shorthand notation to specify the destination of the interrupt.
UINT32 DeliveryStatus
Indicates the IPI delivery status. This field is reserved in x2APIC mode.
UINT32 TriggerMode
0:edge, 1:level.
UINT32 InputPinPolarity
Interrupt Input Pin Polarity.
UINT32 DeliveryMode
Specifies the type of interrupt to be sent.
UINT32 Mask
0: Not masked, 1: Masked.
UINT32 Vector
The vector number of the interrupt being sent.
UINT32 TimerMode
0: One-shot, 1: Periodic.
UINT32 Mask
0: Not masked, 1: Masked.
UINT32 BaseAddress
Must be 0FEEH.
UINT32 DestinationId
Specifies the Destination ID.
UINT32 DeliveryMode
Specifies the type of interrupt to be sent.
UINT32 Level
0:Deassert, 1:Assert. Ignored for Edge triggered interrupts.
UINT32 TriggerMode
0:Edge, 1:Level.
UINT32 Vector
Interrupt vector in range 010h..0FEH.
UINT32 SpuriousVector
Spurious Vector.
UINT32 SoftwareEnable
APIC Software Enable/Disable.
struct MSR_IA32_APIC_BASE_REGISTER::@564 Bits