From 38c2cbb9354d7f58e48f9f649f23eb9bd0d3cfca Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Thu, 27 Apr 2017 11:22:26 +0800 Subject: UefiCpuPkg: Move to new location Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang --- Core/UefiCpuPkg/Application/Cpuid/Cpuid.c | 1506 ++++ Core/UefiCpuPkg/Application/Cpuid/Cpuid.inf | 48 + Core/UefiCpuPkg/Application/Cpuid/Cpuid.uni | 22 + Core/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni | 22 + Core/UefiCpuPkg/Contributions.txt | 218 + Core/UefiCpuPkg/CpuDxe/CpuDxe.c | 1180 ++++ Core/UefiCpuPkg/CpuDxe/CpuDxe.h | 264 + Core/UefiCpuPkg/CpuDxe/CpuDxe.inf | 89 + Core/UefiCpuPkg/CpuDxe/CpuDxe.uni | 22 + Core/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni | 20 + Core/UefiCpuPkg/CpuDxe/CpuGdt.c | 161 + Core/UefiCpuPkg/CpuDxe/CpuGdt.h | 74 + Core/UefiCpuPkg/CpuDxe/CpuMp.c | 639 ++ Core/UefiCpuPkg/CpuDxe/CpuMp.h | 476 ++ Core/UefiCpuPkg/CpuDxe/CpuPageTable.c | 788 +++ Core/UefiCpuPkg/CpuDxe/CpuPageTable.h | 113 + Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S | 57 + Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm | 58 + Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm | 53 + Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.S | 60 + Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm | 54 + Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm | 52 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 122 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 53 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni | 22 + .../UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni | 20 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 75 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 49 + Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni | 22 + .../UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni | 20 + Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c | 588 ++ Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h | 225 + Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf | 53 + Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni | 22 + Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni | 20 + Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c | 413 ++ Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h | 162 + Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf | 52 + Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni | 21 + Core/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni | 19 + Core/UefiCpuPkg/CpuIoPei/CpuIoPei.c | 916 +++ Core/UefiCpuPkg/CpuIoPei/CpuIoPei.h | 448 ++ Core/UefiCpuPkg/CpuIoPei/CpuIoPei.inf | 51 + Core/UefiCpuPkg/CpuIoPei/CpuIoPei.uni | 22 + Core/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni | 20 + Core/UefiCpuPkg/CpuMpPei/CpuBist.c | 295 + Core/UefiCpuPkg/CpuMpPei/CpuMpPei.c | 468 ++ Core/UefiCpuPkg/CpuMpPei/CpuMpPei.h | 405 ++ Core/UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 66 + Core/UefiCpuPkg/CpuMpPei/CpuMpPei.uni | 22 + Core/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni | 20 + Core/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 292 + Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf | 70 + Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni | 40 + Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni | 20 + .../MicrocodeFlashAccessLibNull.c | 42 + .../MicrocodeFlashAccessLibNull.inf | 40 + .../MicrocodeFlashAccessLibNull.uni | 21 + .../MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc | 33 + .../MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf | 32 + .../Feature/Capsule/MicrocodeCapsulePdb/Readme.md | 20 + .../MicrocodeCapsuleTxt/Microcode/Microcode.inf | 27 + .../MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc | 39 + .../MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf | 32 + .../Feature/Capsule/MicrocodeCapsuleTxt/Readme.md | 33 + .../Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c | 748 ++ .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c | 981 +++ .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h | 494 ++ .../MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf | 71 + .../MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni | 21 + .../MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni | 20 + Core/UefiCpuPkg/Include/AcpiCpuData.h | 162 + Core/UefiCpuPkg/Include/CpuHotPlugData.h | 33 + Core/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h | 26 + Core/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h | 26 + Core/UefiCpuPkg/Include/Guid/MicrocodeFmp.h | 21 + Core/UefiCpuPkg/Include/Guid/MsegSmram.h | 30 + Core/UefiCpuPkg/Include/Library/LocalApicLib.h | 436 ++ .../Include/Library/MicrocodeFlashAccessLib.h | 39 + Core/UefiCpuPkg/Include/Library/MpInitLib.h | 353 + Core/UefiCpuPkg/Include/Library/MtrrLib.h | 387 + Core/UefiCpuPkg/Include/Library/PlatformSecLib.h | 70 + .../Include/Library/RegisterCpuFeaturesLib.h | 518 ++ .../UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h | 401 ++ .../Include/Library/SmmCpuPlatformHookLib.h | 109 + Core/UefiCpuPkg/Include/Library/UefiCpuLib.h | 38 + Core/UefiCpuPkg/Include/Protocol/SmMonitorInit.h | 141 + Core/UefiCpuPkg/Include/Protocol/SmmCpuService.h | 209 + .../UefiCpuPkg/Include/Register/ArchitecturalMsr.h | 6441 +++++++++++++++++ Core/UefiCpuPkg/Include/Register/Cpuid.h | 3536 ++++++++++ Core/UefiCpuPkg/Include/Register/LocalApic.h | 189 + Core/UefiCpuPkg/Include/Register/Microcode.h | 200 + Core/UefiCpuPkg/Include/Register/Msr.h | 49 + Core/UefiCpuPkg/Include/Register/Msr/AtomMsr.h | 790 +++ .../UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h | 306 + Core/UefiCpuPkg/Include/Register/Msr/Core2Msr.h | 1134 +++ Core/UefiCpuPkg/Include/Register/Msr/CoreMsr.h | 1110 +++ Core/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h | 2531 +++++++ Core/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h | 6352 +++++++++++++++++ Core/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h | 2637 +++++++ .../UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h | 2892 ++++++++ Core/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h | 7430 ++++++++++++++++++++ Core/UefiCpuPkg/Include/Register/Msr/P6Msr.h | 1712 +++++ Core/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h | 2730 +++++++ Core/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h | 684 ++ Core/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h | 145 + .../Include/Register/Msr/SandyBridgeMsr.h | 4796 +++++++++++++ .../Include/Register/Msr/SilvermontMsr.h | 1570 +++++ Core/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h | 2257 ++++++ Core/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h | 203 + Core/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h | 1219 ++++ Core/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h | 373 + Core/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h | 1405 ++++ .../Include/Register/SmramSaveStateMap.h | 190 + Core/UefiCpuPkg/Include/Register/StmApi.h | 954 +++ .../Include/Register/StmResourceDescriptor.h | 228 + Core/UefiCpuPkg/Include/Register/StmStatusCode.h | 78 + .../Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 48 + .../Library/BaseUefiCpuLib/BaseUefiCpuLib.uni | 22 + .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.S | 73 + .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm | 79 + .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm | 74 + .../Library/BaseUefiCpuLib/X64/InitializeFpu.S | 57 + .../Library/BaseUefiCpuLib/X64/InitializeFpu.asm | 62 + .../Library/BaseUefiCpuLib/X64/InitializeFpu.nasm | 60 + .../UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 1093 +++ .../Library/BaseXApicLib/BaseXApicLib.inf | 49 + .../Library/BaseXApicLib/BaseXApicLib.uni | 23 + .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 1188 ++++ .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 49 + .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni | 23 + .../Library/CpuCommonFeaturesLib/Aesni.c | 127 + Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c | 79 + .../Library/CpuCommonFeaturesLib/ClockModulation.c | 106 + .../CpuCommonFeaturesLib/CpuCommonFeatures.h | 867 +++ .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c | 227 + .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf | 68 + .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni | 25 + .../UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c | 81 + .../Library/CpuCommonFeaturesLib/ExecuteDisable.c | 91 + .../Library/CpuCommonFeaturesLib/FastStrings.c | 52 + .../Library/CpuCommonFeaturesLib/FeatureControl.c | 314 + .../CpuCommonFeaturesLib/LimitCpuIdMaxval.c | 82 + .../Library/CpuCommonFeaturesLib/MachineCheck.c | 231 + .../Library/CpuCommonFeaturesLib/MonitorMwait.c | 79 + .../Library/CpuCommonFeaturesLib/PendingBreak.c | 90 + .../Library/CpuCommonFeaturesLib/X2Apic.c | 81 + .../CpuExceptionHandlerLib/CpuExceptionCommon.c | 180 + .../CpuExceptionHandlerLib/CpuExceptionCommon.h | 292 + .../DxeCpuExceptionHandlerLib.inf | 63 + .../DxeCpuExceptionHandlerLib.uni | 22 + .../Library/CpuExceptionHandlerLib/DxeException.c | 199 + .../Ia32/ArchExceptionHandler.c | 230 + .../Ia32/ArchInterruptDefs.h | 44 + .../Ia32/ExceptionHandlerAsm.S | 667 ++ .../Ia32/ExceptionHandlerAsm.asm | 467 ++ .../Ia32/ExceptionHandlerAsm.nasm | 462 ++ .../CpuExceptionHandlerLib/PeiCpuException.c | 180 + .../PeiCpuExceptionHandlerLib.inf | 63 + .../PeiCpuExceptionHandlerLib.uni | 22 + .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c | 294 + .../CpuExceptionHandlerLib/SecPeiCpuException.c | 179 + .../SecPeiCpuExceptionHandlerLib.inf | 59 + .../SecPeiCpuExceptionHandlerLib.uni | 22 + .../SmmCpuExceptionHandlerLib.inf | 63 + .../SmmCpuExceptionHandlerLib.uni | 22 + .../Library/CpuExceptionHandlerLib/SmmException.c | 128 + .../X64/ArchExceptionHandler.c | 262 + .../CpuExceptionHandlerLib/X64/ArchInterruptDefs.h | 46 + .../X64/ExceptionHandlerAsm.S | 434 ++ .../X64/ExceptionHandlerAsm.asm | 389 + .../X64/ExceptionHandlerAsm.nasm | 387 + Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 75 + Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni | 22 + Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 743 ++ Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc | 43 + .../UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 339 + Core/UefiCpuPkg/Library/MpInitLib/Microcode.c | 218 + Core/UefiCpuPkg/Library/MpInitLib/MpLib.c | 2126 ++++++ Core/UefiCpuPkg/Library/MpInitLib/MpLib.h | 594 ++ Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 70 + Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni | 22 + Core/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 624 ++ Core/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc | 43 + Core/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 398 ++ Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 2441 +++++++ Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf | 46 + Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni | 22 + .../PlatformSecLibNull/PlatformSecLibNull.c | 90 + .../PlatformSecLibNull/PlatformSecLibNull.inf | 37 + .../PlatformSecLibNull/PlatformSecLibNull.uni | 20 + .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 751 ++ .../DxeRegisterCpuFeaturesLib.c | 266 + .../DxeRegisterCpuFeaturesLib.inf | 62 + .../PeiRegisterCpuFeaturesLib.c | 390 + .../PeiRegisterCpuFeaturesLib.inf | 64 + .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h | 193 + .../RegisterCpuFeaturesDxe.uni | 22 + .../RegisterCpuFeaturesLib.c | 775 ++ .../Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c | 216 + .../SecPeiDxeTimerLibUefiCpu.inf | 67 + .../SecPeiDxeTimerLibUefiCpu.uni | 31 + .../Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c | 266 + .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S | 278 + .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm | 285 + .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm | 271 + .../Library/SmmCpuFeaturesLib/Ia32/SmiException.S | 174 + .../SmmCpuFeaturesLib/Ia32/SmiException.asm | 170 + .../SmmCpuFeaturesLib/Ia32/SmiException.nasm | 176 + .../Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c | 83 + .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 630 ++ .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 40 + .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni | 18 + .../SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c | 89 + .../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 88 + Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 1299 ++++ Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h | 176 + .../Library/SmmCpuFeaturesLib/X64/SmiEntry.S | 282 + .../Library/SmmCpuFeaturesLib/X64/SmiEntry.asm | 281 + .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm | 263 + .../Library/SmmCpuFeaturesLib/X64/SmiException.S | 178 + .../Library/SmmCpuFeaturesLib/X64/SmiException.asm | 178 + .../SmmCpuFeaturesLib/X64/SmiException.nasm | 179 + .../Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c | 95 + .../SmmCpuPlatformHookLibNull.c | 108 + .../SmmCpuPlatformHookLibNull.inf | 40 + .../SmmCpuPlatformHookLibNull.uni | 18 + Core/UefiCpuPkg/License.txt | 25 + .../PiSmmCommunication/PiSmmCommunicationPei.c | 425 ++ .../PiSmmCommunication/PiSmmCommunicationPei.inf | 70 + .../PiSmmCommunication/PiSmmCommunicationPei.uni | 21 + .../PiSmmCommunicationPeiExtra.uni | 18 + .../PiSmmCommunication/PiSmmCommunicationPrivate.h | 30 + .../PiSmmCommunication/PiSmmCommunicationSmm.c | 269 + .../PiSmmCommunication/PiSmmCommunicationSmm.inf | 82 + .../PiSmmCommunication/PiSmmCommunicationSmm.uni | 23 + .../PiSmmCommunicationSmmExtra.uni | 18 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 945 +++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 372 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h | 181 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S | 165 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm | 168 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm | 159 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 232 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c | 48 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S | 214 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 223 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 209 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S | 696 ++ .../PiSmmCpuDxeSmm/Ia32/SmiException.asm | 713 ++ .../PiSmmCpuDxeSmm/Ia32/SmiException.nasm | 708 ++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 209 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S | 84 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm | 94 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm | 87 + .../PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c | 80 + .../PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h | 97 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 1390 ++++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 1340 ++++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 1070 +++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 167 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni | 21 + .../PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni | 18 + .../PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 1103 +++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 1440 ++++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h | 126 + .../UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h | 165 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 738 ++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c | 116 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S | 204 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm | 206 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm | 196 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 970 +++ Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c | 67 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S | 243 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm | 242 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 224 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S | 365 + .../UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm | 383 + .../PiSmmCpuDxeSmm/X64/SmiException.nasm | 384 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 204 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S | 141 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm | 132 + Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm | 130 + .../UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c | 319 + .../UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h | 105 + .../ResetVector/FixupVtf/ResetVector.uni | 21 + .../ResetVector/FixupVtf/ResetVectorExtra.uni | 17 + Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf | 38 + Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb | 60 + .../Vtf0/Bin/ResetVector.ia32.port80.raw | Bin 0 -> 516 bytes .../ResetVector/Vtf0/Bin/ResetVector.ia32.raw | Bin 0 -> 484 bytes .../Vtf0/Bin/ResetVector.ia32.serial.raw | Bin 0 -> 884 bytes .../ResetVector/Vtf0/Bin/ResetVector.inf | 36 + .../ResetVector/Vtf0/Bin/ResetVector.uni | 21 + .../Vtf0/Bin/ResetVector.x64.port80.raw | Bin 0 -> 28676 bytes .../ResetVector/Vtf0/Bin/ResetVector.x64.raw | Bin 0 -> 28676 bytes .../Vtf0/Bin/ResetVector.x64.serial.raw | Bin 0 -> 28676 bytes .../ResetVector/Vtf0/Bin/ResetVectorExtra.uni | 17 + Core/UefiCpuPkg/ResetVector/Vtf0/Build.py | 53 + Core/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc | 31 + Core/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm | 26 + Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm | 48 + .../ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 133 + .../ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm | 71 + .../ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm | 45 + .../ResetVector/Vtf0/Ia32/PageTables64.asm | 30 + .../ResetVector/Vtf0/Ia32/SearchForBfvBase.asm | 86 + .../ResetVector/Vtf0/Ia32/SearchForSecEntry.asm | 200 + Core/UefiCpuPkg/ResetVector/Vtf0/Main.asm | 106 + Core/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm | 28 + Core/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc | 25 + Core/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt | 41 + Core/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni | 21 + .../ResetVector/Vtf0/ResetVectorExtra.uni | 17 + Core/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm | 132 + .../ResetVector/Vtf0/Tools/FixupForRawSection.py | 26 + Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf | 36 + Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 70 + .../UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm | 78 + Core/UefiCpuPkg/SecCore/FindPeiCore.c | 198 + Core/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 | 106 + Core/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb | 103 + Core/UefiCpuPkg/SecCore/SecBist.c | 270 + Core/UefiCpuPkg/SecCore/SecCore.inf | 79 + Core/UefiCpuPkg/SecCore/SecCore.uni | 24 + Core/UefiCpuPkg/SecCore/SecCoreExtra.uni | 18 + Core/UefiCpuPkg/SecCore/SecMain.c | 310 + Core/UefiCpuPkg/SecCore/SecMain.h | 160 + Core/UefiCpuPkg/UefiCpuPkg.dec | 289 + Core/UefiCpuPkg/UefiCpuPkg.dsc | 158 + Core/UefiCpuPkg/UefiCpuPkg.uni | 196 + Core/UefiCpuPkg/UefiCpuPkgExtra.uni | 20 + .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S | 38 + .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm | 45 + .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm | 41 + .../Universal/Acpi/S3Resume2Pei/S3Resume.c | 1176 ++++ .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 101 + .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni | 26 + .../Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni | 20 + .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S | 37 + .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm | 41 + .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm | 41 + UefiCpuPkg/Application/Cpuid/Cpuid.c | 1506 ---- UefiCpuPkg/Application/Cpuid/Cpuid.inf | 48 - UefiCpuPkg/Application/Cpuid/Cpuid.uni | 22 - UefiCpuPkg/Application/Cpuid/CpuidExtra.uni | 22 - UefiCpuPkg/Contributions.txt | 218 - UefiCpuPkg/CpuDxe/CpuDxe.c | 1180 ---- UefiCpuPkg/CpuDxe/CpuDxe.h | 264 - UefiCpuPkg/CpuDxe/CpuDxe.inf | 89 - UefiCpuPkg/CpuDxe/CpuDxe.uni | 22 - UefiCpuPkg/CpuDxe/CpuDxeExtra.uni | 20 - UefiCpuPkg/CpuDxe/CpuGdt.c | 161 - UefiCpuPkg/CpuDxe/CpuGdt.h | 74 - UefiCpuPkg/CpuDxe/CpuMp.c | 639 -- UefiCpuPkg/CpuDxe/CpuMp.h | 476 -- UefiCpuPkg/CpuDxe/CpuPageTable.c | 788 --- UefiCpuPkg/CpuDxe/CpuPageTable.h | 113 - UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S | 57 - UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm | 58 - UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm | 53 - UefiCpuPkg/CpuDxe/X64/CpuAsm.S | 60 - UefiCpuPkg/CpuDxe/X64/CpuAsm.asm | 54 - UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm | 52 - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 122 - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 53 - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni | 22 - UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni | 20 - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 75 - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 49 - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni | 22 - UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni | 20 - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c | 588 -- UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h | 225 - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf | 53 - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni | 22 - UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni | 20 - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c | 413 -- UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h | 162 - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf | 52 - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni | 21 - UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni | 19 - UefiCpuPkg/CpuIoPei/CpuIoPei.c | 916 --- UefiCpuPkg/CpuIoPei/CpuIoPei.h | 448 -- UefiCpuPkg/CpuIoPei/CpuIoPei.inf | 51 - UefiCpuPkg/CpuIoPei/CpuIoPei.uni | 22 - UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni | 20 - UefiCpuPkg/CpuMpPei/CpuBist.c | 295 - UefiCpuPkg/CpuMpPei/CpuMpPei.c | 468 -- UefiCpuPkg/CpuMpPei/CpuMpPei.h | 405 -- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 66 - UefiCpuPkg/CpuMpPei/CpuMpPei.uni | 22 - UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni | 20 - UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 292 - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf | 70 - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni | 40 - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni | 20 - .../MicrocodeFlashAccessLibNull.c | 42 - .../MicrocodeFlashAccessLibNull.inf | 40 - .../MicrocodeFlashAccessLibNull.uni | 21 - .../MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc | 33 - .../MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf | 32 - .../Feature/Capsule/MicrocodeCapsulePdb/Readme.md | 20 - .../MicrocodeCapsuleTxt/Microcode/Microcode.inf | 27 - .../MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc | 39 - .../MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf | 32 - .../Feature/Capsule/MicrocodeCapsuleTxt/Readme.md | 33 - .../Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c | 748 -- .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c | 981 --- .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h | 494 -- .../MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf | 71 - .../MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni | 21 - .../MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni | 20 - UefiCpuPkg/Include/AcpiCpuData.h | 162 - UefiCpuPkg/Include/CpuHotPlugData.h | 33 - UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h | 26 - UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h | 26 - UefiCpuPkg/Include/Guid/MicrocodeFmp.h | 21 - UefiCpuPkg/Include/Guid/MsegSmram.h | 30 - UefiCpuPkg/Include/Library/LocalApicLib.h | 436 -- .../Include/Library/MicrocodeFlashAccessLib.h | 39 - UefiCpuPkg/Include/Library/MpInitLib.h | 353 - UefiCpuPkg/Include/Library/MtrrLib.h | 387 - UefiCpuPkg/Include/Library/PlatformSecLib.h | 70 - .../Include/Library/RegisterCpuFeaturesLib.h | 518 -- UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h | 401 -- UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h | 109 - UefiCpuPkg/Include/Library/UefiCpuLib.h | 38 - UefiCpuPkg/Include/Protocol/SmMonitorInit.h | 141 - UefiCpuPkg/Include/Protocol/SmmCpuService.h | 209 - UefiCpuPkg/Include/Register/ArchitecturalMsr.h | 6441 ----------------- UefiCpuPkg/Include/Register/Cpuid.h | 3536 ---------- UefiCpuPkg/Include/Register/LocalApic.h | 189 - UefiCpuPkg/Include/Register/Microcode.h | 200 - UefiCpuPkg/Include/Register/Msr.h | 49 - UefiCpuPkg/Include/Register/Msr/AtomMsr.h | 790 --- UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h | 306 - UefiCpuPkg/Include/Register/Msr/Core2Msr.h | 1134 --- UefiCpuPkg/Include/Register/Msr/CoreMsr.h | 1110 --- UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h | 2531 ------- UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h | 6352 ----------------- UefiCpuPkg/Include/Register/Msr/HaswellMsr.h | 2637 ------- UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h | 2892 -------- UefiCpuPkg/Include/Register/Msr/NehalemMsr.h | 7430 -------------------- UefiCpuPkg/Include/Register/Msr/P6Msr.h | 1712 ----- UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h | 2730 ------- UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h | 684 -- UefiCpuPkg/Include/Register/Msr/PentiumMsr.h | 145 - UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h | 4796 ------------- UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h | 1570 ----- UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h | 2257 ------ UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h | 203 - UefiCpuPkg/Include/Register/Msr/XeonDMsr.h | 1219 ---- UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h | 373 - UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h | 1405 ---- UefiCpuPkg/Include/Register/SmramSaveStateMap.h | 190 - UefiCpuPkg/Include/Register/StmApi.h | 954 --- .../Include/Register/StmResourceDescriptor.h | 228 - UefiCpuPkg/Include/Register/StmStatusCode.h | 78 - .../Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 48 - .../Library/BaseUefiCpuLib/BaseUefiCpuLib.uni | 22 - .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.S | 73 - .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm | 79 - .../Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm | 74 - .../Library/BaseUefiCpuLib/X64/InitializeFpu.S | 57 - .../Library/BaseUefiCpuLib/X64/InitializeFpu.asm | 62 - .../Library/BaseUefiCpuLib/X64/InitializeFpu.nasm | 60 - UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 1093 --- UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 49 - UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni | 23 - .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 1188 ---- .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 49 - .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni | 23 - UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c | 127 - UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c | 79 - .../Library/CpuCommonFeaturesLib/ClockModulation.c | 106 - .../CpuCommonFeaturesLib/CpuCommonFeatures.h | 867 --- .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.c | 227 - .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf | 68 - .../CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni | 25 - UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c | 81 - .../Library/CpuCommonFeaturesLib/ExecuteDisable.c | 91 - .../Library/CpuCommonFeaturesLib/FastStrings.c | 52 - .../Library/CpuCommonFeaturesLib/FeatureControl.c | 314 - .../CpuCommonFeaturesLib/LimitCpuIdMaxval.c | 82 - .../Library/CpuCommonFeaturesLib/MachineCheck.c | 231 - .../Library/CpuCommonFeaturesLib/MonitorMwait.c | 79 - .../Library/CpuCommonFeaturesLib/PendingBreak.c | 90 - UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c | 81 - .../CpuExceptionHandlerLib/CpuExceptionCommon.c | 180 - .../CpuExceptionHandlerLib/CpuExceptionCommon.h | 292 - .../DxeCpuExceptionHandlerLib.inf | 63 - .../DxeCpuExceptionHandlerLib.uni | 22 - .../Library/CpuExceptionHandlerLib/DxeException.c | 199 - .../Ia32/ArchExceptionHandler.c | 230 - .../Ia32/ArchInterruptDefs.h | 44 - .../Ia32/ExceptionHandlerAsm.S | 667 -- .../Ia32/ExceptionHandlerAsm.asm | 467 -- .../Ia32/ExceptionHandlerAsm.nasm | 462 -- .../CpuExceptionHandlerLib/PeiCpuException.c | 180 - .../PeiCpuExceptionHandlerLib.inf | 63 - .../PeiCpuExceptionHandlerLib.uni | 22 - .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c | 294 - .../CpuExceptionHandlerLib/SecPeiCpuException.c | 179 - .../SecPeiCpuExceptionHandlerLib.inf | 59 - .../SecPeiCpuExceptionHandlerLib.uni | 22 - .../SmmCpuExceptionHandlerLib.inf | 63 - .../SmmCpuExceptionHandlerLib.uni | 22 - .../Library/CpuExceptionHandlerLib/SmmException.c | 128 - .../X64/ArchExceptionHandler.c | 262 - .../CpuExceptionHandlerLib/X64/ArchInterruptDefs.h | 46 - .../X64/ExceptionHandlerAsm.S | 434 -- .../X64/ExceptionHandlerAsm.asm | 389 - .../X64/ExceptionHandlerAsm.nasm | 387 - UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 75 - UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni | 22 - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 743 -- UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc | 43 - UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 339 - UefiCpuPkg/Library/MpInitLib/Microcode.c | 218 - UefiCpuPkg/Library/MpInitLib/MpLib.c | 2126 ------ UefiCpuPkg/Library/MpInitLib/MpLib.h | 594 -- UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 70 - UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni | 22 - UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 624 -- UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc | 43 - UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 398 -- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 2441 ------- UefiCpuPkg/Library/MtrrLib/MtrrLib.inf | 46 - UefiCpuPkg/Library/MtrrLib/MtrrLib.uni | 22 - .../PlatformSecLibNull/PlatformSecLibNull.c | 90 - .../PlatformSecLibNull/PlatformSecLibNull.inf | 37 - .../PlatformSecLibNull/PlatformSecLibNull.uni | 20 - .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 751 -- .../DxeRegisterCpuFeaturesLib.c | 266 - .../DxeRegisterCpuFeaturesLib.inf | 62 - .../PeiRegisterCpuFeaturesLib.c | 390 - .../PeiRegisterCpuFeaturesLib.inf | 64 - .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h | 193 - .../RegisterCpuFeaturesDxe.uni | 22 - .../RegisterCpuFeaturesLib.c | 775 -- .../Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c | 216 - .../SecPeiDxeTimerLibUefiCpu.inf | 67 - .../SecPeiDxeTimerLibUefiCpu.uni | 31 - .../Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c | 266 - .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S | 278 - .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm | 285 - .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm | 271 - .../Library/SmmCpuFeaturesLib/Ia32/SmiException.S | 174 - .../SmmCpuFeaturesLib/Ia32/SmiException.asm | 170 - .../SmmCpuFeaturesLib/Ia32/SmiException.nasm | 176 - .../Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c | 83 - .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 630 -- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 40 - .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni | 18 - .../SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c | 89 - .../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 88 - UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 1299 ---- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h | 176 - .../Library/SmmCpuFeaturesLib/X64/SmiEntry.S | 282 - .../Library/SmmCpuFeaturesLib/X64/SmiEntry.asm | 281 - .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm | 263 - .../Library/SmmCpuFeaturesLib/X64/SmiException.S | 178 - .../Library/SmmCpuFeaturesLib/X64/SmiException.asm | 178 - .../SmmCpuFeaturesLib/X64/SmiException.nasm | 179 - .../Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c | 95 - .../SmmCpuPlatformHookLibNull.c | 108 - .../SmmCpuPlatformHookLibNull.inf | 40 - .../SmmCpuPlatformHookLibNull.uni | 18 - UefiCpuPkg/License.txt | 25 - .../PiSmmCommunication/PiSmmCommunicationPei.c | 425 -- .../PiSmmCommunication/PiSmmCommunicationPei.inf | 70 - .../PiSmmCommunication/PiSmmCommunicationPei.uni | 21 - .../PiSmmCommunicationPeiExtra.uni | 18 - .../PiSmmCommunication/PiSmmCommunicationPrivate.h | 30 - .../PiSmmCommunication/PiSmmCommunicationSmm.c | 269 - .../PiSmmCommunication/PiSmmCommunicationSmm.inf | 82 - .../PiSmmCommunication/PiSmmCommunicationSmm.uni | 23 - .../PiSmmCommunicationSmmExtra.uni | 18 - UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 945 --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 372 - UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h | 181 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S | 165 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm | 168 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm | 159 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 232 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c | 48 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S | 214 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 223 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 209 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S | 696 -- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm | 713 -- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm | 708 -- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 209 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S | 84 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm | 94 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm | 87 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c | 80 - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h | 97 - UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 1390 ---- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 1340 ---- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 1070 --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 167 - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni | 21 - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni | 18 - UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 1103 --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 1440 ---- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h | 126 - UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h | 165 - UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 738 -- UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c | 116 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S | 204 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm | 206 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm | 196 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 970 --- UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c | 67 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S | 243 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm | 242 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 224 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S | 365 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm | 383 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm | 384 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 204 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S | 141 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm | 132 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm | 130 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c | 319 - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h | 105 - UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni | 21 - .../ResetVector/FixupVtf/ResetVectorExtra.uni | 17 - UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf | 38 - UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb | 60 - .../Vtf0/Bin/ResetVector.ia32.port80.raw | Bin 516 -> 0 bytes .../ResetVector/Vtf0/Bin/ResetVector.ia32.raw | Bin 484 -> 0 bytes .../Vtf0/Bin/ResetVector.ia32.serial.raw | Bin 884 -> 0 bytes UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf | 36 - UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni | 21 - .../Vtf0/Bin/ResetVector.x64.port80.raw | Bin 28676 -> 0 bytes .../ResetVector/Vtf0/Bin/ResetVector.x64.raw | Bin 28676 -> 0 bytes .../Vtf0/Bin/ResetVector.x64.serial.raw | Bin 28676 -> 0 bytes .../ResetVector/Vtf0/Bin/ResetVectorExtra.uni | 17 - UefiCpuPkg/ResetVector/Vtf0/Build.py | 53 - UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc | 31 - UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm | 26 - UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm | 48 - .../ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 133 - .../ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm | 71 - .../ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm | 45 - UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm | 30 - .../ResetVector/Vtf0/Ia32/SearchForBfvBase.asm | 86 - .../ResetVector/Vtf0/Ia32/SearchForSecEntry.asm | 200 - UefiCpuPkg/ResetVector/Vtf0/Main.asm | 106 - UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm | 28 - UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc | 25 - UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt | 41 - UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni | 21 - UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni | 17 - UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm | 132 - .../ResetVector/Vtf0/Tools/FixupForRawSection.py | 26 - UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf | 36 - UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 70 - UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm | 78 - UefiCpuPkg/SecCore/FindPeiCore.c | 198 - UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 | 106 - UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb | 103 - UefiCpuPkg/SecCore/SecBist.c | 270 - UefiCpuPkg/SecCore/SecCore.inf | 79 - UefiCpuPkg/SecCore/SecCore.uni | 24 - UefiCpuPkg/SecCore/SecCoreExtra.uni | 18 - UefiCpuPkg/SecCore/SecMain.c | 310 - UefiCpuPkg/SecCore/SecMain.h | 160 - UefiCpuPkg/UefiCpuPkg.dec | 289 - UefiCpuPkg/UefiCpuPkg.dsc | 158 - UefiCpuPkg/UefiCpuPkg.uni | 196 - UefiCpuPkg/UefiCpuPkgExtra.uni | 20 - .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S | 38 - .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm | 45 - .../Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm | 41 - UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 1176 ---- .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 101 - .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni | 26 - .../Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni | 20 - .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S | 37 - .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm | 41 - .../Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm | 41 - 686 files changed, 121918 insertions(+), 121918 deletions(-) create mode 100644 Core/UefiCpuPkg/Application/Cpuid/Cpuid.c create mode 100644 Core/UefiCpuPkg/Application/Cpuid/Cpuid.inf create mode 100644 Core/UefiCpuPkg/Application/Cpuid/Cpuid.uni create mode 100644 Core/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni create mode 100644 Core/UefiCpuPkg/Contributions.txt create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuDxe.c create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuDxe.h create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuDxe.inf create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuDxe.uni create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuGdt.c create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuGdt.h create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuMp.c create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuMp.h create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuPageTable.c create mode 100644 Core/UefiCpuPkg/CpuDxe/CpuPageTable.h create mode 100644 Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S create mode 100644 Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm create mode 100644 Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm create mode 100644 Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.S create mode 100644 Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm create mode 100644 Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni create mode 100644 Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni create mode 100644 Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c create mode 100644 Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h create mode 100644 Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf create mode 100644 Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni create mode 100644 Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni create mode 100644 Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c create mode 100644 Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h create mode 100644 Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf create mode 100644 Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni create mode 100644 Core/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni create mode 100644 Core/UefiCpuPkg/CpuIoPei/CpuIoPei.c create mode 100644 Core/UefiCpuPkg/CpuIoPei/CpuIoPei.h create mode 100644 Core/UefiCpuPkg/CpuIoPei/CpuIoPei.inf create mode 100644 Core/UefiCpuPkg/CpuIoPei/CpuIoPei.uni create mode 100644 Core/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuBist.c create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuMpPei.c create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuMpPei.h create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuMpPei.inf create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuMpPei.uni create mode 100644 Core/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni create mode 100644 Core/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c create mode 100644 Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf create mode 100644 Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni create mode 100644 Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni create mode 100644 Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c create mode 100644 Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf create mode 100644 Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni create mode 100644 Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni create mode 100644 Core/UefiCpuPkg/Include/AcpiCpuData.h create mode 100644 Core/UefiCpuPkg/Include/CpuHotPlugData.h create mode 100644 Core/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h create mode 100644 Core/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h create mode 100644 Core/UefiCpuPkg/Include/Guid/MicrocodeFmp.h create mode 100644 Core/UefiCpuPkg/Include/Guid/MsegSmram.h create mode 100644 Core/UefiCpuPkg/Include/Library/LocalApicLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/MpInitLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/MtrrLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/PlatformSecLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h create mode 100644 Core/UefiCpuPkg/Include/Library/UefiCpuLib.h create mode 100644 Core/UefiCpuPkg/Include/Protocol/SmMonitorInit.h create mode 100644 Core/UefiCpuPkg/Include/Protocol/SmmCpuService.h create mode 100644 Core/UefiCpuPkg/Include/Register/ArchitecturalMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Cpuid.h create mode 100644 Core/UefiCpuPkg/Include/Register/LocalApic.h create mode 100644 Core/UefiCpuPkg/Include/Register/Microcode.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/AtomMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/Core2Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/CoreMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/P6Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h create mode 100644 Core/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h create mode 100644 Core/UefiCpuPkg/Include/Register/SmramSaveStateMap.h create mode 100644 Core/UefiCpuPkg/Include/Register/StmApi.h create mode 100644 Core/UefiCpuPkg/Include/Register/StmResourceDescriptor.h create mode 100644 Core/UefiCpuPkg/Include/Register/StmStatusCode.h create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm create mode 100644 Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm create mode 100644 Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c create mode 100644 Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf create mode 100644 Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni create mode 100644 Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c create mode 100644 Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf create mode 100644 Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c create mode 100644 Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm create mode 100644 Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/Microcode.c create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/MpLib.c create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/MpLib.h create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc create mode 100644 Core/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm create mode 100644 Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.c create mode 100644 Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf create mode 100644 Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni create mode 100644 Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c create mode 100644 Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf create mode 100644 Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni create mode 100644 Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c create mode 100644 Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c create mode 100644 Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf create mode 100644 Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni create mode 100644 Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm create mode 100644 Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c create mode 100644 Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf create mode 100644 Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni create mode 100644 Core/UefiCpuPkg/License.txt create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni create mode 100644 Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c create mode 100755 Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c create mode 100644 Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h create mode 100644 Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni create mode 100644 Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni create mode 100644 Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf create mode 100644 Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Build.py create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Main.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb create mode 100644 Core/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm create mode 100644 Core/UefiCpuPkg/SecCore/FindPeiCore.c create mode 100644 Core/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 create mode 100644 Core/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb create mode 100644 Core/UefiCpuPkg/SecCore/SecBist.c create mode 100644 Core/UefiCpuPkg/SecCore/SecCore.inf create mode 100644 Core/UefiCpuPkg/SecCore/SecCore.uni create mode 100644 Core/UefiCpuPkg/SecCore/SecCoreExtra.uni create mode 100644 Core/UefiCpuPkg/SecCore/SecMain.c create mode 100644 Core/UefiCpuPkg/SecCore/SecMain.h create mode 100644 Core/UefiCpuPkg/UefiCpuPkg.dec create mode 100644 Core/UefiCpuPkg/UefiCpuPkg.dsc create mode 100644 Core/UefiCpuPkg/UefiCpuPkg.uni create mode 100644 Core/UefiCpuPkg/UefiCpuPkgExtra.uni create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm create mode 100644 Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm delete mode 100644 UefiCpuPkg/Application/Cpuid/Cpuid.c delete mode 100644 UefiCpuPkg/Application/Cpuid/Cpuid.inf delete mode 100644 UefiCpuPkg/Application/Cpuid/Cpuid.uni delete mode 100644 UefiCpuPkg/Application/Cpuid/CpuidExtra.uni delete mode 100644 UefiCpuPkg/Contributions.txt delete mode 100644 UefiCpuPkg/CpuDxe/CpuDxe.c delete mode 100644 UefiCpuPkg/CpuDxe/CpuDxe.h delete mode 100644 UefiCpuPkg/CpuDxe/CpuDxe.inf delete mode 100644 UefiCpuPkg/CpuDxe/CpuDxe.uni delete mode 100644 UefiCpuPkg/CpuDxe/CpuDxeExtra.uni delete mode 100644 UefiCpuPkg/CpuDxe/CpuGdt.c delete mode 100644 UefiCpuPkg/CpuDxe/CpuGdt.h delete mode 100644 UefiCpuPkg/CpuDxe/CpuMp.c delete mode 100644 UefiCpuPkg/CpuDxe/CpuMp.h delete mode 100644 UefiCpuPkg/CpuDxe/CpuPageTable.c delete mode 100644 UefiCpuPkg/CpuDxe/CpuPageTable.h delete mode 100644 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S delete mode 100644 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm delete mode 100644 UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm delete mode 100644 UefiCpuPkg/CpuDxe/X64/CpuAsm.S delete mode 100644 UefiCpuPkg/CpuDxe/X64/CpuAsm.asm delete mode 100644 UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni delete mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni delete mode 100644 UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c delete mode 100644 UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h delete mode 100644 UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf delete mode 100644 UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni delete mode 100644 UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni delete mode 100644 UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c delete mode 100644 UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h delete mode 100644 UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf delete mode 100644 UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni delete mode 100644 UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni delete mode 100644 UefiCpuPkg/CpuIoPei/CpuIoPei.c delete mode 100644 UefiCpuPkg/CpuIoPei/CpuIoPei.h delete mode 100644 UefiCpuPkg/CpuIoPei/CpuIoPei.inf delete mode 100644 UefiCpuPkg/CpuIoPei/CpuIoPei.uni delete mode 100644 UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni delete mode 100644 UefiCpuPkg/CpuMpPei/CpuBist.c delete mode 100644 UefiCpuPkg/CpuMpPei/CpuMpPei.c delete mode 100644 UefiCpuPkg/CpuMpPei/CpuMpPei.h delete mode 100644 UefiCpuPkg/CpuMpPei/CpuMpPei.inf delete mode 100644 UefiCpuPkg/CpuMpPei/CpuMpPei.uni delete mode 100644 UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni delete mode 100644 UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c delete mode 100644 UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf delete mode 100644 UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni delete mode 100644 UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni delete mode 100644 UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c delete mode 100644 UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf delete mode 100644 UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni delete mode 100644 UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni delete mode 100644 UefiCpuPkg/Include/AcpiCpuData.h delete mode 100644 UefiCpuPkg/Include/CpuHotPlugData.h delete mode 100644 UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h delete mode 100644 UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h delete mode 100644 UefiCpuPkg/Include/Guid/MicrocodeFmp.h delete mode 100644 UefiCpuPkg/Include/Guid/MsegSmram.h delete mode 100644 UefiCpuPkg/Include/Library/LocalApicLib.h delete mode 100644 UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h delete mode 100644 UefiCpuPkg/Include/Library/MpInitLib.h delete mode 100644 UefiCpuPkg/Include/Library/MtrrLib.h delete mode 100644 UefiCpuPkg/Include/Library/PlatformSecLib.h delete mode 100644 UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h delete mode 100644 UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h delete mode 100644 UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h delete mode 100644 UefiCpuPkg/Include/Library/UefiCpuLib.h delete mode 100644 UefiCpuPkg/Include/Protocol/SmMonitorInit.h delete mode 100644 UefiCpuPkg/Include/Protocol/SmmCpuService.h delete mode 100644 UefiCpuPkg/Include/Register/ArchitecturalMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Cpuid.h delete mode 100644 UefiCpuPkg/Include/Register/LocalApic.h delete mode 100644 UefiCpuPkg/Include/Register/Microcode.h delete mode 100644 UefiCpuPkg/Include/Register/Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/AtomMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/Core2Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/CoreMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/HaswellMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/NehalemMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/P6Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/PentiumMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/XeonDMsr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h delete mode 100644 UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h delete mode 100644 UefiCpuPkg/Include/Register/SmramSaveStateMap.h delete mode 100644 UefiCpuPkg/Include/Register/StmApi.h delete mode 100644 UefiCpuPkg/Include/Register/StmResourceDescriptor.h delete mode 100644 UefiCpuPkg/Include/Register/StmStatusCode.h delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm delete mode 100644 UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm delete mode 100644 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c delete mode 100644 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf delete mode 100644 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni delete mode 100644 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c delete mode 100644 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf delete mode 100644 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c delete mode 100644 UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm delete mode 100644 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf delete mode 100644 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni delete mode 100644 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c delete mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc delete mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm delete mode 100644 UefiCpuPkg/Library/MpInitLib/Microcode.c delete mode 100644 UefiCpuPkg/Library/MpInitLib/MpLib.c delete mode 100644 UefiCpuPkg/Library/MpInitLib/MpLib.h delete mode 100644 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf delete mode 100644 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni delete mode 100644 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c delete mode 100644 UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc delete mode 100644 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm delete mode 100644 UefiCpuPkg/Library/MtrrLib/MtrrLib.c delete mode 100644 UefiCpuPkg/Library/MtrrLib/MtrrLib.inf delete mode 100644 UefiCpuPkg/Library/MtrrLib/MtrrLib.uni delete mode 100644 UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c delete mode 100644 UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf delete mode 100644 UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni delete mode 100644 UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c delete mode 100644 UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c delete mode 100644 UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf delete mode 100644 UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni delete mode 100644 UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm delete mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c delete mode 100644 UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c delete mode 100644 UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf delete mode 100644 UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni delete mode 100644 UefiCpuPkg/License.txt delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni delete mode 100644 UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c delete mode 100755 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c delete mode 100644 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h delete mode 100644 UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni delete mode 100644 UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni delete mode 100644 UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf delete mode 100644 UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Build.py delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Main.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm delete mode 100644 UefiCpuPkg/SecCore/FindPeiCore.c delete mode 100644 UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 delete mode 100644 UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb delete mode 100644 UefiCpuPkg/SecCore/SecBist.c delete mode 100644 UefiCpuPkg/SecCore/SecCore.inf delete mode 100644 UefiCpuPkg/SecCore/SecCore.uni delete mode 100644 UefiCpuPkg/SecCore/SecCoreExtra.uni delete mode 100644 UefiCpuPkg/SecCore/SecMain.c delete mode 100644 UefiCpuPkg/SecCore/SecMain.h delete mode 100644 UefiCpuPkg/UefiCpuPkg.dec delete mode 100644 UefiCpuPkg/UefiCpuPkg.dsc delete mode 100644 UefiCpuPkg/UefiCpuPkg.uni delete mode 100644 UefiCpuPkg/UefiCpuPkgExtra.uni delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm delete mode 100644 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm diff --git a/Core/UefiCpuPkg/Application/Cpuid/Cpuid.c b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.c new file mode 100644 index 0000000000..2efad68405 --- /dev/null +++ b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.c @@ -0,0 +1,1506 @@ +/** @file + UEFI Application to display CPUID leaf information. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include + +/// +/// Macro used to display the value of a bit field in a register returned by CPUID. +/// +#define PRINT_BIT_FIELD(Variable, FieldName) \ + Print (L"%5a%42a: %x\n", #Variable, #FieldName, Variable.Bits.FieldName); + +/// +/// Macro used to display the value of a register returned by CPUID. +/// +#define PRINT_VALUE(Variable, Description) \ + Print (L"%5a%42a: %x\n", #Variable, #Description, Variable); + +/// +/// Structure for cache description lookup table +/// +typedef struct { + UINT8 CacheDescriptor; + CHAR8 *Type; + CHAR8 *Description; +} CPUID_CACHE_INFO_DESCRIPTION; + +/// +/// Cache description lookup table +/// +CPUID_CACHE_INFO_DESCRIPTION mCpuidCacheInfoDescription[] = { + { 0x00 , "General" , "Null descriptor, this byte contains no information" }, + { 0x01 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries" }, + { 0x02 , "TLB" , "Instruction TLB: 4 MByte pages, fully associative, 2 entries" }, + { 0x03 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 64 entries" }, + { 0x04 , "TLB" , "Data TLB: 4 MByte pages, 4-way set associative, 8 entries" }, + { 0x05 , "TLB" , "Data TLB1: 4 MByte pages, 4-way set associative, 32 entries" }, + { 0x06 , "Cache" , "1st-level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size" }, + { 0x08 , "Cache" , "1st-level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size" }, + { 0x09 , "Cache" , "1st-level instruction cache: 32KBytes, 4-way set associative, 64 byte line size" }, + { 0x0A , "Cache" , "1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size" }, + { 0x0B , "TLB" , "Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries" }, + { 0x0C , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size" }, + { 0x0D , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size" }, + { 0x0E , "Cache" , "1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size" }, + { 0x1D , "Cache" , "2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size" }, + { 0x21 , "Cache" , "2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size" }, + { 0x22 , "Cache" , "3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x23 , "Cache" , "3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x24 , "Cache" , "2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size" }, + { 0x25 , "Cache" , "3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x29 , "Cache" , "3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x2C , "Cache" , "1st-level data cache: 32 KBytes, 8-way set associative, 64 byte line size" }, + { 0x30 , "Cache" , "1st-level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size" }, + { 0x40 , "Cache" , "No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache" }, + { 0x41 , "Cache" , "2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size" }, + { 0x42 , "Cache" , "2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size" }, + { 0x43 , "Cache" , "2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size" }, + { 0x44 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size" }, + { 0x45 , "Cache" , "2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size" }, + { 0x46 , "Cache" , "3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size" }, + { 0x47 , "Cache" , "3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size" }, + { 0x48 , "Cache" , "2nd-level cache: 3MByte, 12-way set associative, 64 byte line size" }, + { 0x49 , "Cache" , "3rd-level cache: 4MB, 16-way set associative, 64-byte line size (Intel Xeon processor MP, Family 0FH, Model 06H). 2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size" }, + { 0x4A , "Cache" , "3rd-level cache: 6MByte, 12-way set associative, 64 byte line size" }, + { 0x4B , "Cache" , "3rd-level cache: 8MByte, 16-way set associative, 64 byte line size" }, + { 0x4C , "Cache" , "3rd-level cache: 12MByte, 12-way set associative, 64 byte line size" }, + { 0x4D , "Cache" , "3rd-level cache: 16MByte, 16-way set associative, 64 byte line size" }, + { 0x4E , "Cache" , "2nd-level cache: 6MByte, 24-way set associative, 64 byte line size" }, + { 0x4F , "TLB" , "Instruction TLB: 4 KByte pages, 32 entries" }, + { 0x50 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries" }, + { 0x51 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries" }, + { 0x52 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries" }, + { 0x55 , "TLB" , "Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries" }, + { 0x56 , "TLB" , "Data TLB0: 4 MByte pages, 4-way set associative, 16 entries" }, + { 0x57 , "TLB" , "Data TLB0: 4 KByte pages, 4-way associative, 16 entries" }, + { 0x59 , "TLB" , "Data TLB0: 4 KByte pages, fully associative, 16 entries" }, + { 0x5A , "TLB" , "Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries" }, + { 0x5B , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 64 entries" }, + { 0x5C , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,128 entries" }, + { 0x5D , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,256 entries" }, + { 0x60 , "Cache" , "1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size" }, + { 0x61 , "TLB" , "Instruction TLB: 4 KByte pages, fully associative, 48 entries" }, + { 0x63 , "TLB" , "Data TLB: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries and a separate array with 1 GByte pages, 4-way set associative, 4 entries" }, + { 0x64 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 512 entries" }, + { 0x66 , "Cache" , "1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size" }, + { 0x67 , "Cache" , "1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size" }, + { 0x68 , "Cache" , "1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size" }, + { 0x6A , "Cache" , "uTLB: 4 KByte pages, 8-way set associative, 64 entries" }, + { 0x6B , "Cache" , "DTLB: 4 KByte pages, 8-way set associative, 256 entries" }, + { 0x6C , "Cache" , "DTLB: 2M/4M pages, 8-way set associative, 128 entries" }, + { 0x6D , "Cache" , "DTLB: 1 GByte pages, fully associative, 16 entries" }, + { 0x70 , "Cache" , "Trace cache: 12 K-uop, 8-way set associative" }, + { 0x71 , "Cache" , "Trace cache: 16 K-uop, 8-way set associative" }, + { 0x72 , "Cache" , "Trace cache: 32 K-uop, 8-way set associative" }, + { 0x76 , "TLB" , "Instruction TLB: 2M/4M pages, fully associative, 8 entries" }, + { 0x78 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 64byte line size" }, + { 0x79 , "Cache" , "2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x7A , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x7B , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x7C , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, + { 0x7D , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 64byte line size" }, + { 0x7F , "Cache" , "2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size" }, + { 0x80 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size" }, + { 0x82 , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size" }, + { 0x83 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size" }, + { 0x84 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size" }, + { 0x85 , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size" }, + { 0x86 , "Cache" , "2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size" }, + { 0x87 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size" }, + { 0xA0 , "DTLB" , "DTLB: 4k pages, fully associative, 32 entries" }, + { 0xB0 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries" }, + { 0xB1 , "TLB" , "Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries" }, + { 0xB2 , "TLB" , "Instruction TLB: 4KByte pages, 4-way set associative, 64 entries" }, + { 0xB3 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 128 entries" }, + { 0xB4 , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 256 entries" }, + { 0xB5 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 64 entries" }, + { 0xB6 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 128 entries" }, + { 0xBA , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 64 entries" }, + { 0xC0 , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries" }, + { 0xC1 , "STLB" , "Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries" }, + { 0xC2 , "DTLB" , "DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries" }, + { 0xC3 , "STLB" , "Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, 1536 entries. Also 1GBbyte pages, 4-way, 16 entries." }, + { 0xC4 , "DTLB" , "DTLB: 2M/4M Byte pages, 4-way associative, 32 entries" }, + { 0xCA , "STLB" , "Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries" }, + { 0xD0 , "Cache" , "3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size" }, + { 0xD1 , "Cache" , "3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size" }, + { 0xD2 , "Cache" , "3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size" }, + { 0xD6 , "Cache" , "3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size" }, + { 0xD7 , "Cache" , "3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size" }, + { 0xD8 , "Cache" , "3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size" }, + { 0xDC , "Cache" , "3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size" }, + { 0xDD , "Cache" , "3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size" }, + { 0xDE , "Cache" , "3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size" }, + { 0xE2 , "Cache" , "3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size" }, + { 0xE3 , "Cache" , "3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size" }, + { 0xE4 , "Cache" , "3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size" }, + { 0xEA , "Cache" , "3rd-level cache: 12MByte, 24-way set associative, 64 byte line size" }, + { 0xEB , "Cache" , "3rd-level cache: 18MByte, 24-way set associative, 64 byte line size" }, + { 0xEC , "Cache" , "3rd-level cache: 24MByte, 24-way set associative, 64 byte line size" }, + { 0xF0 , "Prefetch" , "64-Byte prefetching" }, + { 0xF1 , "Prefetch" , "128-Byte prefetching" }, + { 0xFF , "General" , "CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters" } +}; + +/// +/// The maximum supported CPUID leaf index starting from leaf 0x00000000. +/// +UINT32 gMaximumBasicFunction = CPUID_SIGNATURE; + +/// +/// The maximum supported CPUID leaf index starting from leaf 0x80000000. +/// +UINT32 gMaximumExtendedFunction = CPUID_EXTENDED_FUNCTION; + +/** + Display CPUID_SIGNATURE leaf. + +**/ +VOID +CpuidSignature ( + VOID + ) +{ + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + CHAR8 Signature[13]; + + AsmCpuid (CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx); + + Print (L"CPUID_SIGNATURE (Leaf %08x)\n", CPUID_SIGNATURE); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx); + PRINT_VALUE (Eax, MaximumLeaf); + *(UINT32 *)(Signature + 0) = Ebx; + *(UINT32 *)(Signature + 4) = Edx; + *(UINT32 *)(Signature + 8) = Ecx; + Signature [12] = 0; + Print (L" Signature = %a\n", Signature); + + gMaximumBasicFunction = Eax; +} + +/** + Display CPUID_VERSION_INFO leaf. + +**/ +VOID +CpuidVersionInfo ( + VOID + ) +{ + CPUID_VERSION_INFO_EAX Eax; + CPUID_VERSION_INFO_EBX Ebx; + CPUID_VERSION_INFO_ECX Ecx; + CPUID_VERSION_INFO_EDX Edx; + UINT32 DisplayFamily; + UINT32 DisplayModel; + + if (CPUID_VERSION_INFO > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + + Print (L"CPUID_VERSION_INFO (Leaf %08x)\n", CPUID_VERSION_INFO); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + + DisplayFamily = Eax.Bits.FamilyId; + if (Eax.Bits.FamilyId == 0x0F) { + DisplayFamily |= (Eax.Bits.ExtendedFamilyId << 4); + } + + DisplayModel = Eax.Bits.Model; + if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) { + DisplayModel |= (Eax.Bits.ExtendedModelId << 4); + } + + Print (L" Family = %x Model = %x Stepping = %x\n", DisplayFamily, DisplayModel, Eax.Bits.SteppingId); + + PRINT_BIT_FIELD (Eax, SteppingId); + PRINT_BIT_FIELD (Eax, Model); + PRINT_BIT_FIELD (Eax, FamilyId); + PRINT_BIT_FIELD (Eax, ProcessorType); + PRINT_BIT_FIELD (Eax, ExtendedModelId); + PRINT_BIT_FIELD (Eax, ExtendedFamilyId); + PRINT_BIT_FIELD (Ebx, BrandIndex); + PRINT_BIT_FIELD (Ebx, CacheLineSize); + PRINT_BIT_FIELD (Ebx, MaximumAddressableIdsForLogicalProcessors); + PRINT_BIT_FIELD (Ebx, InitialLocalApicId); + PRINT_BIT_FIELD (Ecx, SSE3); + PRINT_BIT_FIELD (Ecx, PCLMULQDQ); + PRINT_BIT_FIELD (Ecx, DTES64); + PRINT_BIT_FIELD (Ecx, MONITOR); + PRINT_BIT_FIELD (Ecx, DS_CPL); + PRINT_BIT_FIELD (Ecx, VMX); + PRINT_BIT_FIELD (Ecx, SMX); + PRINT_BIT_FIELD (Ecx, TM2); + PRINT_BIT_FIELD (Ecx, SSSE3); + PRINT_BIT_FIELD (Ecx, CNXT_ID); + PRINT_BIT_FIELD (Ecx, SDBG); + PRINT_BIT_FIELD (Ecx, FMA); + PRINT_BIT_FIELD (Ecx, CMPXCHG16B); + PRINT_BIT_FIELD (Ecx, xTPR_Update_Control); + PRINT_BIT_FIELD (Ecx, PDCM); + PRINT_BIT_FIELD (Ecx, PCID); + PRINT_BIT_FIELD (Ecx, DCA); + PRINT_BIT_FIELD (Ecx, SSE4_1); + PRINT_BIT_FIELD (Ecx, SSE4_2); + PRINT_BIT_FIELD (Ecx, x2APIC); + PRINT_BIT_FIELD (Ecx, MOVBE); + PRINT_BIT_FIELD (Ecx, POPCNT); + PRINT_BIT_FIELD (Ecx, TSC_Deadline); + PRINT_BIT_FIELD (Ecx, AESNI); + PRINT_BIT_FIELD (Ecx, XSAVE); + PRINT_BIT_FIELD (Ecx, OSXSAVE); + PRINT_BIT_FIELD (Ecx, AVX); + PRINT_BIT_FIELD (Ecx, F16C); + PRINT_BIT_FIELD (Ecx, RDRAND); + PRINT_BIT_FIELD (Edx, FPU); + PRINT_BIT_FIELD (Edx, VME); + PRINT_BIT_FIELD (Edx, DE); + PRINT_BIT_FIELD (Edx, PSE); + PRINT_BIT_FIELD (Edx, TSC); + PRINT_BIT_FIELD (Edx, MSR); + PRINT_BIT_FIELD (Edx, PAE); + PRINT_BIT_FIELD (Edx, MCE); + PRINT_BIT_FIELD (Edx, CX8); + PRINT_BIT_FIELD (Edx, APIC); + PRINT_BIT_FIELD (Edx, SEP); + PRINT_BIT_FIELD (Edx, MTRR); + PRINT_BIT_FIELD (Edx, PGE); + PRINT_BIT_FIELD (Edx, MCA); + PRINT_BIT_FIELD (Edx, CMOV); + PRINT_BIT_FIELD (Edx, PAT); + PRINT_BIT_FIELD (Edx, PSE_36); + PRINT_BIT_FIELD (Edx, PSN); + PRINT_BIT_FIELD (Edx, CLFSH); + PRINT_BIT_FIELD (Edx, DS); + PRINT_BIT_FIELD (Edx, ACPI); + PRINT_BIT_FIELD (Edx, MMX); + PRINT_BIT_FIELD (Edx, FXSR); + PRINT_BIT_FIELD (Edx, SSE); + PRINT_BIT_FIELD (Edx, SSE2); + PRINT_BIT_FIELD (Edx, SS); + PRINT_BIT_FIELD (Edx, HTT); + PRINT_BIT_FIELD (Edx, TM); + PRINT_BIT_FIELD (Edx, PBE); +} + +/** + Lookup a cache description string from the mCpuidCacheInfoDescription table. + + @param[in] CacheDescriptor Cache descriptor value from CPUID_CACHE_INFO. + +**/ +CPUID_CACHE_INFO_DESCRIPTION * +LookupCacheDescription ( + UINT8 CacheDescriptor + ) +{ + UINTN NumDescriptors; + UINTN Descriptor; + + if (CacheDescriptor == 0x00) { + return NULL; + } + NumDescriptors = sizeof (mCpuidCacheInfoDescription)/sizeof (mCpuidCacheInfoDescription[0]); + for (Descriptor = 0; Descriptor < NumDescriptors; Descriptor++) { + if (CacheDescriptor == mCpuidCacheInfoDescription[Descriptor].CacheDescriptor) { + return &mCpuidCacheInfoDescription[Descriptor]; + } + } + return NULL; +} + +/** + Display CPUID_CACHE_INFO leaf for each supported cache descriptor. + +**/ +VOID +CpuidCacheInfo ( + VOID + ) +{ + CPUID_CACHE_INFO_CACHE_TLB Eax; + CPUID_CACHE_INFO_CACHE_TLB Ebx; + CPUID_CACHE_INFO_CACHE_TLB Ecx; + CPUID_CACHE_INFO_CACHE_TLB Edx; + UINTN Index; + CPUID_CACHE_INFO_DESCRIPTION *CacheDescription; + + if (CPUID_CACHE_INFO > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_CACHE_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + + Print (L"CPUID_CACHE_INFO (Leaf %08x)\n", CPUID_CACHE_INFO); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + if (Eax.Bits.NotValid == 0) { + // + // Process Eax.CacheDescriptor[1..3]. Ignore Eax.CacheDescriptor[0] + // + for (Index = 1; Index < 4; Index++) { + CacheDescription = LookupCacheDescription (Eax.CacheDescriptor[Index]); + if (CacheDescription != NULL) { + Print (L" %-8a %a\n", + CacheDescription->Type, + CacheDescription->Description + ); + } + } + } + if (Ebx.Bits.NotValid == 0) { + // + // Process Ebx.CacheDescriptor[0..3] + // + for (Index = 0; Index < 4; Index++) { + CacheDescription = LookupCacheDescription (Ebx.CacheDescriptor[Index]); + if (CacheDescription != NULL) { + Print (L" %-8a %a\n", + CacheDescription->Type, + CacheDescription->Description + ); + } + } + } + if (Ecx.Bits.NotValid == 0) { + // + // Process Ecx.CacheDescriptor[0..3] + // + for (Index = 0; Index < 4; Index++) { + CacheDescription = LookupCacheDescription (Ecx.CacheDescriptor[Index]); + if (CacheDescription != NULL) { + Print (L" %-8a %a\n", + CacheDescription->Type, + CacheDescription->Description + ); + } + } + } + if (Edx.Bits.NotValid == 0) { + // + // Process Edx.CacheDescriptor[0..3] + // + for (Index = 0; Index < 4; Index++) { + CacheDescription = LookupCacheDescription (Edx.CacheDescriptor[Index]); + if (CacheDescription != NULL) { + Print (L" %-8a %a\n", + CacheDescription->Type, + CacheDescription->Description + ); + } + } + } +} + +/** + Display CPUID_SERIAL_NUMBER leaf if it is supported. + +**/ +VOID +CpuidSerialNumber ( + VOID + ) +{ + CPUID_VERSION_INFO_EDX VersionInfoEdx; + UINT32 Ecx; + UINT32 Edx; + + Print (L"CPUID_SERIAL_NUMBER (Leaf %08x)\n", CPUID_SERIAL_NUMBER); + + if (CPUID_SERIAL_NUMBER > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); + if (VersionInfoEdx.Bits.PSN == 0) { + Print (L" Not Supported\n"); + return; + } + + AsmCpuid (CPUID_SERIAL_NUMBER, NULL, NULL, &Ecx, &Edx); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx, Edx); + Print (L" Processor Serial Number = %08x%08x%08x\n", 0, Edx, Ecx); +} + +/** + Display CPUID_CACHE_PARAMS for all supported sub-leafs. + +**/ +VOID +CpuidCacheParams ( + VOID + ) +{ + UINT32 CacheLevel; + CPUID_CACHE_PARAMS_EAX Eax; + CPUID_CACHE_PARAMS_EBX Ebx; + UINT32 Ecx; + CPUID_CACHE_PARAMS_EDX Edx; + + if (CPUID_CACHE_PARAMS > gMaximumBasicFunction) { + return; + } + + CacheLevel = 0; + do { + AsmCpuidEx ( + CPUID_CACHE_PARAMS, CacheLevel, + &Eax.Uint32, &Ebx.Uint32, &Ecx, &Edx.Uint32 + ); + if (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL) { + Print (L"CPUID_CACHE_PARAMS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_CACHE_PARAMS, CacheLevel); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx, Edx.Uint32); + PRINT_BIT_FIELD (Eax, CacheType); + PRINT_BIT_FIELD (Eax, CacheLevel); + PRINT_BIT_FIELD (Eax, SelfInitializingCache); + PRINT_BIT_FIELD (Eax, FullyAssociativeCache); + PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForLogicalProcessors); + PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForProcessorCores); + PRINT_BIT_FIELD (Ebx, LineSize); + PRINT_BIT_FIELD (Ebx, LinePartitions); + PRINT_BIT_FIELD (Ebx, Ways); + PRINT_VALUE (Ecx, NumberOfSets); + PRINT_BIT_FIELD (Edx, Invalidate); + PRINT_BIT_FIELD (Edx, CacheInclusiveness); + PRINT_BIT_FIELD (Edx, ComplexCacheIndexing); + } + CacheLevel++; + } while (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL); +} + +/** + Display CPUID_MONITOR_MWAIT leaf. + +**/ +VOID +CpuidMonitorMwait ( + VOID + ) +{ + CPUID_MONITOR_MWAIT_EAX Eax; + CPUID_MONITOR_MWAIT_EBX Ebx; + CPUID_MONITOR_MWAIT_ECX Ecx; + CPUID_MONITOR_MWAIT_EDX Edx; + + if (CPUID_MONITOR_MWAIT > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_MONITOR_MWAIT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + + Print (L"CPUID_MONITOR_MWAIT (Leaf %08x)\n", CPUID_MONITOR_MWAIT); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + + PRINT_BIT_FIELD (Eax, SmallestMonitorLineSize); + PRINT_BIT_FIELD (Ebx, LargestMonitorLineSize); + PRINT_BIT_FIELD (Ecx, ExtensionsSupported); + PRINT_BIT_FIELD (Ecx, InterruptAsBreak); + PRINT_BIT_FIELD (Edx, C0States); + PRINT_BIT_FIELD (Edx, C1States); + PRINT_BIT_FIELD (Edx, C2States); + PRINT_BIT_FIELD (Edx, C3States); + PRINT_BIT_FIELD (Edx, C4States); + PRINT_BIT_FIELD (Edx, C5States); + PRINT_BIT_FIELD (Edx, C6States); + PRINT_BIT_FIELD (Edx, C7States); +} + +/** + Display CPUID_THERMAL_POWER_MANAGEMENT leaf. + +**/ +VOID +CpuidThermalPowerManagement ( + VOID + ) +{ + CPUID_THERMAL_POWER_MANAGEMENT_EAX Eax; + CPUID_THERMAL_POWER_MANAGEMENT_EBX Ebx; + CPUID_THERMAL_POWER_MANAGEMENT_ECX Ecx; + + if (CPUID_THERMAL_POWER_MANAGEMENT > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); + + Print (L"CPUID_THERMAL_POWER_MANAGEMENT (Leaf %08x)\n", CPUID_THERMAL_POWER_MANAGEMENT); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0); + + PRINT_BIT_FIELD (Eax, DigitalTemperatureSensor); + PRINT_BIT_FIELD (Eax, TurboBoostTechnology); + PRINT_BIT_FIELD (Eax, ARAT); + PRINT_BIT_FIELD (Eax, PLN); + PRINT_BIT_FIELD (Eax, ECMD); + PRINT_BIT_FIELD (Eax, PTM); + PRINT_BIT_FIELD (Eax, HWP); + PRINT_BIT_FIELD (Eax, HWP_Notification); + PRINT_BIT_FIELD (Eax, HWP_Activity_Window); + PRINT_BIT_FIELD (Eax, HWP_Energy_Performance_Preference); + PRINT_BIT_FIELD (Eax, HWP_Package_Level_Request); + PRINT_BIT_FIELD (Eax, HDC); + PRINT_BIT_FIELD (Ebx, InterruptThresholds); + PRINT_BIT_FIELD (Ecx, HardwareCoordinationFeedback); + PRINT_BIT_FIELD (Ecx, PerformanceEnergyBias); +} + +/** + Display CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS for all supported sub-leafs. + +**/ +VOID +CpuidStructuredExtendedFeatureFlags ( + VOID + ) +{ + UINT32 Eax; + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX Ecx; + UINT32 SubLeaf; + + if (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, + &Eax, NULL, NULL, NULL + ); + for (SubLeaf = 0; SubLeaf <= Eax; SubLeaf++) { + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + SubLeaf, + NULL, &Ebx.Uint32, &Ecx.Uint32, NULL + ); + if (Ebx.Uint32 != 0 || Ecx.Uint32 != 0) { + Print (L"CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, SubLeaf); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0); + PRINT_BIT_FIELD (Ebx, FSGSBASE); + PRINT_BIT_FIELD (Ebx, IA32_TSC_ADJUST); + PRINT_BIT_FIELD (Ebx, SGX); + PRINT_BIT_FIELD (Ebx, BMI1); + PRINT_BIT_FIELD (Ebx, HLE); + PRINT_BIT_FIELD (Ebx, AVX2); + PRINT_BIT_FIELD (Ebx, FDP_EXCPTN_ONLY); + PRINT_BIT_FIELD (Ebx, SMEP); + PRINT_BIT_FIELD (Ebx, BMI2); + PRINT_BIT_FIELD (Ebx, EnhancedRepMovsbStosb); + PRINT_BIT_FIELD (Ebx, INVPCID); + PRINT_BIT_FIELD (Ebx, RTM); + PRINT_BIT_FIELD (Ebx, RDT_M); + PRINT_BIT_FIELD (Ebx, DeprecateFpuCsDs); + PRINT_BIT_FIELD (Ebx, MPX); + PRINT_BIT_FIELD (Ebx, RDT_A); + PRINT_BIT_FIELD (Ebx, RDSEED); + PRINT_BIT_FIELD (Ebx, ADX); + PRINT_BIT_FIELD (Ebx, SMAP); + PRINT_BIT_FIELD (Ebx, CLFLUSHOPT); + PRINT_BIT_FIELD (Ebx, CLWB); + PRINT_BIT_FIELD (Ebx, IntelProcessorTrace); + PRINT_BIT_FIELD (Ebx, SHA); + PRINT_BIT_FIELD (Ecx, PREFETCHWT1); + PRINT_BIT_FIELD (Ecx, UMIP); + PRINT_BIT_FIELD (Ecx, PKU); + PRINT_BIT_FIELD (Ecx, OSPKE); + PRINT_BIT_FIELD (Ecx, MAWAU); + PRINT_BIT_FIELD (Ecx, RDPID); + PRINT_BIT_FIELD (Ecx, SGX_LC); + } + } +} + +/** + Display CPUID_DIRECT_CACHE_ACCESS_INFO leaf. + +**/ +VOID +CpuidDirectCacheAccessInfo ( + VOID + ) +{ + UINT32 Eax; + + if (CPUID_DIRECT_CACHE_ACCESS_INFO > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_DIRECT_CACHE_ACCESS_INFO, &Eax, NULL, NULL, NULL); + Print (L"CPUID_DIRECT_CACHE_ACCESS_INFO (Leaf %08x)\n", CPUID_DIRECT_CACHE_ACCESS_INFO); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0); +} + +/** + Display CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING leaf. + +**/ +VOID +CpuidArchitecturalPerformanceMonitoring ( + VOID + ) +{ + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX Eax; + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX Ebx; + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX Edx; + + if (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING, &Eax.Uint32, &Ebx.Uint32, NULL, &Edx.Uint32); + Print (L"CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING (Leaf %08x)\n", CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, Edx.Uint32); + PRINT_BIT_FIELD (Eax, ArchPerfMonVerID); + PRINT_BIT_FIELD (Eax, PerformanceMonitorCounters); + PRINT_BIT_FIELD (Eax, PerformanceMonitorCounterWidth); + PRINT_BIT_FIELD (Eax, EbxBitVectorLength); + PRINT_BIT_FIELD (Ebx, UnhaltedCoreCycles); + PRINT_BIT_FIELD (Ebx, InstructionsRetired); + PRINT_BIT_FIELD (Ebx, UnhaltedReferenceCycles); + PRINT_BIT_FIELD (Ebx, LastLevelCacheReferences); + PRINT_BIT_FIELD (Ebx, LastLevelCacheMisses); + PRINT_BIT_FIELD (Ebx, BranchInstructionsRetired); + PRINT_BIT_FIELD (Ebx, AllBranchMispredictRetired); + PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounters); + PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounterWidth); +} + +/** + Display CPUID_EXTENDED_TOPOLOGY leafs for all supported levels. + +**/ +VOID +CpuidExtendedTopology ( + VOID + ) +{ + CPUID_EXTENDED_TOPOLOGY_EAX Eax; + CPUID_EXTENDED_TOPOLOGY_EBX Ebx; + CPUID_EXTENDED_TOPOLOGY_ECX Ecx; + UINT32 Edx; + UINT32 LevelNumber; + + if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) { + return; + } + + LevelNumber = 0; + do { + AsmCpuidEx ( + CPUID_EXTENDED_TOPOLOGY, LevelNumber, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx + ); + if (Eax.Bits.ApicIdShift != 0) { + Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_TOPOLOGY, LevelNumber); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx); + PRINT_BIT_FIELD (Eax, ApicIdShift); + PRINT_BIT_FIELD (Ebx, LogicalProcessors); + PRINT_BIT_FIELD (Ecx, LevelNumber); + PRINT_BIT_FIELD (Ecx, LevelType); + PRINT_VALUE (Edx, x2APIC_ID); + } + LevelNumber++; + } while (Eax.Bits.ApicIdShift != 0); +} + +/** + Display CPUID_EXTENDED_STATE sub-leaf. + +**/ +VOID +CpuidExtendedStateSubLeaf ( + VOID + ) +{ + CPUID_EXTENDED_STATE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_EXTENDED_STATE_SUB_LEAF_ECX Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF, + &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx + ); + Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx); + PRINT_BIT_FIELD (Eax, XSAVEOPT); + PRINT_BIT_FIELD (Eax, XSAVEC); + PRINT_BIT_FIELD (Eax, XGETBV); + PRINT_BIT_FIELD (Eax, XSAVES); + PRINT_VALUE (Ebx, EnabledSaveStateSize_XCR0_IA32_XSS); + PRINT_BIT_FIELD (Ecx, XCR0); + PRINT_BIT_FIELD (Ecx, PT); + PRINT_BIT_FIELD (Ecx, XCR0_1); + PRINT_VALUE (Edx, IA32_XSS_Supported_32_63); +} + +/** + Display CPUID_EXTENDED_STATE size and offset information sub-leaf. + +**/ +VOID +CpuidExtendedStateSizeOffset ( + VOID + ) +{ + UINT32 Eax; + UINT32 Ebx; + CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX Ecx; + UINT32 Edx; + UINT32 SubLeaf; + + for (SubLeaf = CPUID_EXTENDED_STATE_SIZE_OFFSET; SubLeaf < 32; SubLeaf++) { + AsmCpuidEx ( + CPUID_EXTENDED_STATE, SubLeaf, + &Eax, &Ebx, &Ecx.Uint32, &Edx + ); + if (Edx != 0) { + Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, SubLeaf); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx.Uint32, Edx); + PRINT_VALUE (Eax, FeatureSaveStateSize); + PRINT_VALUE (Ebx, FeatureSaveStateOffset); + PRINT_BIT_FIELD (Ecx, XSS); + PRINT_BIT_FIELD (Ecx, Compacted); + } + } +} + +/** + Display CPUID_EXTENDED_STATE main leaf and sub-leafs. + +**/ +VOID +CpuidExtendedStateMainLeaf ( + VOID + ) +{ + CPUID_EXTENDED_STATE_MAIN_LEAF_EAX Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + if (CPUID_EXTENDED_STATE > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF, + &Eax.Uint32, &Ebx, &Ecx, &Edx + ); + Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx, Edx); + PRINT_BIT_FIELD (Eax, x87); + PRINT_BIT_FIELD (Eax, SSE); + PRINT_BIT_FIELD (Eax, AVX); + PRINT_BIT_FIELD (Eax, MPX); + PRINT_BIT_FIELD (Eax, AVX_512); + PRINT_BIT_FIELD (Eax, IA32_XSS); + PRINT_BIT_FIELD (Eax, PKRU); + PRINT_VALUE (Ebx, EnabledSaveStateSize); + PRINT_VALUE (Ecx, SupportedSaveStateSize); + PRINT_VALUE (Edx, XCR0_Supported_32_63); + + CpuidExtendedStateSubLeaf (); + CpuidExtendedStateSizeOffset (); +} + +/** + Display CPUID_INTEL_RDT_MONITORING enumeration sub-leaf. + +**/ +VOID +CpuidIntelRdtMonitoringEnumerationSubLeaf ( + VOID + ) +{ + UINT32 Ebx; + CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX Edx; + + if (CPUID_INTEL_RDT_MONITORING > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF, + NULL, &Ebx, NULL, &Edx.Uint32 + ); + Print (L"CPUID_INTEL_RDT_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, 0, Edx.Uint32); + PRINT_VALUE (Ebx, Maximum_RMID_Range); + PRINT_BIT_FIELD (Edx, L3CacheRDT_M); +} + +/** + Display CPUID_INTEL_RDT_MONITORING L3 cache capability sub-leaf. + +**/ +VOID +CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf ( + VOID + ) +{ + UINT32 Ebx; + UINT32 Ecx; + CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX Edx; + + if (CPUID_INTEL_RDT_MONITORING > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF, + NULL, &Ebx, &Ecx, &Edx.Uint32 + ); + Print (L"CPUID_INTEL_RDT_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, Ecx, Edx.Uint32); + PRINT_VALUE (Ebx, OccupancyConversionFactor); + PRINT_VALUE (Ecx, Maximum_RMID_Range); + PRINT_BIT_FIELD (Edx, L3CacheOccupancyMonitoring); + PRINT_BIT_FIELD (Edx, L3CacheTotalBandwidthMonitoring); + PRINT_BIT_FIELD (Edx, L3CacheLocalBandwidthMonitoring); +} + +/** + Display CPUID_INTEL_RDT_ALLOCATION L3 cache allocation technology enumeration + sub-leaf. + +**/ +VOID +CpuidIntelRdtAllocationL3CacheSubLeaf ( + VOID + ) +{ + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX Ecx; + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF, + &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx.Uint32 + ); + Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx.Uint32); + PRINT_BIT_FIELD (Eax, CapacityLength); + PRINT_VALUE (Ebx, AllocationUnitBitMap); + PRINT_BIT_FIELD (Ecx, CosUpdatesInfrequent); + PRINT_BIT_FIELD (Ecx, CodeDataPrioritization); + PRINT_BIT_FIELD (Edx, HighestCosNumber); +} + +/** + Display CPUID_INTEL_RDT_ALLOCATION L2 cache allocation technology enumeration + sub-leaf. + +**/ +VOID +CpuidIntelRdtAllocationL2CacheSubLeaf ( + VOID + ) +{ + CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF, + &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 + ); + Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, 0, Edx.Uint32); + PRINT_BIT_FIELD (Eax, CapacityLength); + PRINT_VALUE (Ebx, AllocationUnitBitMap); + PRINT_BIT_FIELD (Edx, HighestCosNumber); +} + +/** + Display CPUID_INTEL_RDT_ALLOCATION main leaf and sub-leaves. + +**/ +VOID +CpuidIntelRdtAllocationMainLeaf ( + VOID + ) +{ + CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX Ebx; + + if (CPUID_INTEL_RDT_ALLOCATION > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF, + NULL, &Ebx.Uint32, NULL, NULL + ); + Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx.Uint32, 0, 0); + PRINT_BIT_FIELD (Ebx, L3CacheAllocation); + PRINT_BIT_FIELD (Ebx, L2CacheAllocation); + + CpuidIntelRdtAllocationL3CacheSubLeaf (); + CpuidIntelRdtAllocationL2CacheSubLeaf (); +} + +/** + Display Sub-Leaf 0 Enumeration of Intel SGX Capabilities. + +**/ +VOID +CpuidEnumerationOfIntelSgxCapabilities0SubLeaf ( + VOID + ) +{ + CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF, + &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 + ); + Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, 0, Edx.Uint32); + PRINT_BIT_FIELD (Eax, SGX1); + PRINT_BIT_FIELD (Eax, SGX2); + PRINT_BIT_FIELD (Edx, MaxEnclaveSize_Not64); + PRINT_BIT_FIELD (Edx, MaxEnclaveSize_64); +} + +/** + Display Sub-Leaf 1 Enumeration of Intel SGX Capabilities. + +**/ +VOID +CpuidEnumerationOfIntelSgxCapabilities1SubLeaf ( + VOID + ) +{ + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF, + &Eax, &Ebx, &Ecx, &Edx + ); + Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx); +} + +/** + Display Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources. + +**/ +VOID +CpuidEnumerationOfIntelSgxResourcesSubLeaf ( + VOID + ) +{ + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX Eax; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX Ebx; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX Ecx; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX Edx; + UINT32 SubLeaf; + + SubLeaf = CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF; + do { + AsmCpuidEx ( + CPUID_INTEL_SGX, SubLeaf, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + if (Eax.Bits.SubLeafType == 0x1) { + Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, SubLeaf); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + PRINT_BIT_FIELD (Eax, SubLeafType); + PRINT_BIT_FIELD (Eax, LowAddressOfEpcSection); + PRINT_BIT_FIELD (Ebx, HighAddressOfEpcSection); + PRINT_BIT_FIELD (Ecx, EpcSection); + PRINT_BIT_FIELD (Ecx, LowSizeOfEpcSection); + PRINT_BIT_FIELD (Edx, HighSizeOfEpcSection); + } + SubLeaf++; + } while (Eax.Bits.SubLeafType == 0x1); +} + +/** + Display Intel SGX Resource Enumeration. + +**/ +VOID +CpuidEnumerationOfIntelSgx ( + VOID + ) +{ + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; + + if (CPUID_INTEL_SGX > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, + NULL, &Ebx.Uint32, NULL, NULL + ); + if (Ebx.Bits.SGX != 1) { + // + // Only if CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1, the processor has support + // for Intel SGX. + // + return; + } + + CpuidEnumerationOfIntelSgxCapabilities0SubLeaf (); + CpuidEnumerationOfIntelSgxCapabilities1SubLeaf (); + CpuidEnumerationOfIntelSgxResourcesSubLeaf (); +} + +/** + Display CPUID_INTEL_PROCESSOR_TRACE sub-leafs. + + @param[in] MaximumSubLeaf Maximum sub-leaf index for CPUID_INTEL_PROCESSOR_TRACE. + +**/ +VOID +CpuidIntelProcessorTraceSubLeaf ( + UINT32 MaximumSubLeaf + ) +{ + UINT32 SubLeaf; + CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX Eax; + CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX Ebx; + + for (SubLeaf = CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF; SubLeaf <= MaximumSubLeaf; SubLeaf++) { + AsmCpuidEx ( + CPUID_INTEL_PROCESSOR_TRACE, SubLeaf, + &Eax.Uint32, &Ebx.Uint32, NULL, NULL + ); + Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, SubLeaf); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, 0); + PRINT_BIT_FIELD (Eax, ConfigurableAddressRanges); + PRINT_BIT_FIELD (Eax, MtcPeriodEncodings); + PRINT_BIT_FIELD (Ebx, CycleThresholdEncodings); + PRINT_BIT_FIELD (Ebx, PsbFrequencyEncodings); + } +} + +/** + Display CPUID_INTEL_PROCESSOR_TRACE main leaf and sub-leafs. + +**/ +VOID +CpuidIntelProcessorTraceMainLeaf ( + VOID + ) +{ + UINT32 Eax; + CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX Ebx; + CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX Ecx; + + if (CPUID_INTEL_PROCESSOR_TRACE > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, + &Eax, &Ebx.Uint32, &Ecx.Uint32, NULL + ); + Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0); + PRINT_VALUE (Eax, MaximumSubLeaf); + PRINT_BIT_FIELD (Ebx, Cr3Filter); + PRINT_BIT_FIELD (Ebx, ConfigurablePsb); + PRINT_BIT_FIELD (Ebx, IpTraceStopFiltering); + PRINT_BIT_FIELD (Ebx, Mtc); + PRINT_BIT_FIELD (Ebx, PTWrite); + PRINT_BIT_FIELD (Ebx, PowerEventTrace); + PRINT_BIT_FIELD (Ecx, RTIT); + PRINT_BIT_FIELD (Ecx, ToPA); + PRINT_BIT_FIELD (Ecx, SingleRangeOutput); + PRINT_BIT_FIELD (Ecx, TraceTransportSubsystem); + PRINT_BIT_FIELD (Ecx, LIP); + + CpuidIntelProcessorTraceSubLeaf (Eax); +} + +/** + Display CPUID_TIME_STAMP_COUNTER leaf. + +**/ +VOID +CpuidTimeStampCounter ( + VOID + ) +{ + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + + if (CPUID_TIME_STAMP_COUNTER > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_TIME_STAMP_COUNTER, &Eax, &Ebx, &Ecx, NULL); + Print (L"CPUID_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_TIME_STAMP_COUNTER); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, 0); +} + +/** + Display CPUID_PROCESSOR_FREQUENCY leaf. + +**/ +VOID +CpuidProcessorFrequency ( + VOID + ) +{ + CPUID_PROCESSOR_FREQUENCY_EAX Eax; + CPUID_PROCESSOR_FREQUENCY_EBX Ebx; + CPUID_PROCESSOR_FREQUENCY_ECX Ecx; + + if (CPUID_PROCESSOR_FREQUENCY > gMaximumBasicFunction) { + return; + } + + AsmCpuid (CPUID_PROCESSOR_FREQUENCY, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); + Print (L"CPUID_PROCESSOR_FREQUENCY (Leaf %08x)\n", CPUID_PROCESSOR_FREQUENCY); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0); + PRINT_BIT_FIELD (Eax, ProcessorBaseFrequency); + PRINT_BIT_FIELD (Ebx, MaximumFrequency); + PRINT_BIT_FIELD (Ecx, BusFrequency); +} + +/** + Display CPUID_SOC_VENDOR sub-leafs that contain the SoC Vendor Brand String. + Also display these sub-leafs as a single SoC Vendor Brand String. + +**/ +VOID +CpuidSocVendorBrandString ( + VOID + ) +{ + CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; + // + // Array to store brand string from 3 brand string leafs with + // 4 32-bit brand string values per leaf and an extra value to + // null terminate the string. + // + UINT32 BrandString[3 * 4 + 1]; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[0] = Eax.Uint32; + BrandString[1] = Ebx.Uint32; + BrandString[2] = Ecx.Uint32; + BrandString[3] = Edx.Uint32; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[4] = Eax.Uint32; + BrandString[5] = Ebx.Uint32; + BrandString[6] = Ecx.Uint32; + BrandString[7] = Edx.Uint32; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[8] = Eax.Uint32; + BrandString[9] = Ebx.Uint32; + BrandString[10] = Ecx.Uint32; + BrandString[11] = Edx.Uint32; + + BrandString[12] = 0; + + Print (L"Vendor Brand String = %a\n", (CHAR8 *)BrandString); +} + +/** + Display CPUID_SOC_VENDOR main leaf and sub-leafs. + +**/ +VOID +CpuidSocVendor ( + VOID + ) +{ + UINT32 Eax; + CPUID_SOC_VENDOR_MAIN_LEAF_EBX Ebx; + UINT32 Ecx; + UINT32 Edx; + + if (CPUID_SOC_VENDOR > gMaximumBasicFunction) { + return; + } + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF, + &Eax, &Ebx.Uint32, &Ecx, &Edx + ); + Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx, Edx); + if (Eax < 3) { + Print (L" Not Supported\n"); + return; + } + PRINT_VALUE (Eax, MaxSOCID_Index); + PRINT_BIT_FIELD (Ebx, SocVendorId); + PRINT_BIT_FIELD (Ebx, IsVendorScheme); + PRINT_VALUE (Ecx, ProjectID); + PRINT_VALUE (Edx, SteppingID); + CpuidSocVendorBrandString (); +} + +/** + Display CPUID_EXTENDED_FUNCTION leaf. + +**/ +VOID +CpuidExtendedFunction ( + VOID + ) +{ + UINT32 Eax; + + AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); + Print (L"CPUID_EXTENDED_FUNCTION (Leaf %08x)\n", CPUID_EXTENDED_FUNCTION); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0); + PRINT_VALUE (Eax, MaximumExtendedFunction); + + gMaximumExtendedFunction = Eax; +} + +/** + Display CPUID_EXTENDED_CPU_SIG leaf. + +**/ +VOID +CpuidExtendedCpuSig ( + VOID + ) +{ + UINT32 Eax; + CPUID_EXTENDED_CPU_SIG_ECX Ecx; + CPUID_EXTENDED_CPU_SIG_EDX Edx; + + if (CPUID_EXTENDED_CPU_SIG > gMaximumExtendedFunction) { + return; + } + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, &Eax, NULL, &Ecx.Uint32, &Edx.Uint32); + Print (L"CPUID_EXTENDED_CPU_SIG (Leaf %08x)\n", CPUID_EXTENDED_CPU_SIG); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, Ecx.Uint32, Edx.Uint32); + PRINT_BIT_FIELD (Ecx, LAHF_SAHF); + PRINT_BIT_FIELD (Ecx, LZCNT); + PRINT_BIT_FIELD (Ecx, PREFETCHW); + PRINT_BIT_FIELD (Edx, SYSCALL_SYSRET); + PRINT_BIT_FIELD (Edx, NX); + PRINT_BIT_FIELD (Edx, Page1GB); + PRINT_BIT_FIELD (Edx, RDTSCP); + PRINT_BIT_FIELD (Edx, LM); +} + +/** + Display CPUID_BRAND_STRING1, CPUID_BRAND_STRING2 and CPUID_BRAND_STRING3 + leafs. Also display these three leafs as a single brand string. + +**/ +VOID +CpuidProcessorBrandString ( + VOID + ) +{ + CPUID_BRAND_STRING_DATA Eax; + CPUID_BRAND_STRING_DATA Ebx; + CPUID_BRAND_STRING_DATA Ecx; + CPUID_BRAND_STRING_DATA Edx; + // + // Array to store brand string from 3 brand string leafs with + // 4 32-bit brand string values per leaf and an extra value to + // null terminate the string. + // + UINT32 BrandString[3 * 4 + 1]; + + if (CPUID_BRAND_STRING1 <= gMaximumExtendedFunction) { + AsmCpuid (CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + Print (L"CPUID_BRAND_STRING1 (Leaf %08x)\n", CPUID_BRAND_STRING1); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[0] = Eax.Uint32; + BrandString[1] = Ebx.Uint32; + BrandString[2] = Ecx.Uint32; + BrandString[3] = Edx.Uint32; + } + + if (CPUID_BRAND_STRING2 <= gMaximumExtendedFunction) { + AsmCpuid (CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + Print (L"CPUID_BRAND_STRING2 (Leaf %08x)\n", CPUID_BRAND_STRING2); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[4] = Eax.Uint32; + BrandString[5] = Ebx.Uint32; + BrandString[6] = Ecx.Uint32; + BrandString[7] = Edx.Uint32; + } + + if (CPUID_BRAND_STRING3 <= gMaximumExtendedFunction) { + AsmCpuid (CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + Print (L"CPUID_BRAND_STRING3 (Leaf %08x)\n", CPUID_BRAND_STRING3); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); + BrandString[8] = Eax.Uint32; + BrandString[9] = Ebx.Uint32; + BrandString[10] = Ecx.Uint32; + BrandString[11] = Edx.Uint32; + } + + BrandString[12] = 0; + + Print (L"Brand String = %a\n", (CHAR8 *)BrandString); +} + +/** + Display CPUID_EXTENDED_CACHE_INFO leaf. + +**/ +VOID +CpuidExtendedCacheInfo ( + VOID + ) +{ + CPUID_EXTENDED_CACHE_INFO_ECX Ecx; + + if (CPUID_EXTENDED_CACHE_INFO > gMaximumExtendedFunction) { + return; + } + + AsmCpuid (CPUID_EXTENDED_CACHE_INFO, NULL, NULL, &Ecx.Uint32, NULL); + Print (L"CPUID_EXTENDED_CACHE_INFO (Leaf %08x)\n", CPUID_EXTENDED_CACHE_INFO); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx.Uint32, 0); + PRINT_BIT_FIELD (Ecx, CacheLineSize); + PRINT_BIT_FIELD (Ecx, L2Associativity); + PRINT_BIT_FIELD (Ecx, CacheSize); +} + +/** + Display CPUID_EXTENDED_TIME_STAMP_COUNTER leaf. + +**/ +VOID +CpuidExtendedTimeStampCounter ( + VOID + ) +{ + CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX Edx; + + if (CPUID_EXTENDED_TIME_STAMP_COUNTER > gMaximumExtendedFunction) { + return; + } + + AsmCpuid (CPUID_EXTENDED_TIME_STAMP_COUNTER, NULL, NULL, NULL, &Edx.Uint32); + Print (L"CPUID_EXTENDED_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_EXTENDED_TIME_STAMP_COUNTER); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, 0, Edx.Uint32); + PRINT_BIT_FIELD (Edx, InvariantTsc); +} + +/** + Display CPUID_VIR_PHY_ADDRESS_SIZE leaf. + +**/ +VOID +CpuidVirPhyAddressSize ( + VOID + ) +{ + CPUID_VIR_PHY_ADDRESS_SIZE_EAX Eax; + + if (CPUID_VIR_PHY_ADDRESS_SIZE > gMaximumExtendedFunction) { + return; + } + + AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Eax.Uint32, NULL, NULL, NULL); + Print (L"CPUID_VIR_PHY_ADDRESS_SIZE (Leaf %08x)\n", CPUID_VIR_PHY_ADDRESS_SIZE); + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, 0, 0, 0); + PRINT_BIT_FIELD (Eax, PhysicalAddressBits); + PRINT_BIT_FIELD (Eax, LinearAddressBits); +} + +/** + The user Entry Point for Application. The user code starts with this function + as the real entry point for the application. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +UefiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + Print (L"UEFI CPUID Version 0.5\n"); + + CpuidSignature (); + CpuidVersionInfo (); + CpuidCacheInfo (); + CpuidSerialNumber (); + CpuidCacheParams(); + CpuidMonitorMwait (); + CpuidThermalPowerManagement (); + CpuidStructuredExtendedFeatureFlags (); + CpuidDirectCacheAccessInfo(); + CpuidArchitecturalPerformanceMonitoring (); + CpuidExtendedTopology (); + CpuidExtendedStateMainLeaf (); + CpuidIntelRdtMonitoringEnumerationSubLeaf (); + CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf (); + CpuidIntelRdtAllocationMainLeaf (); + CpuidEnumerationOfIntelSgx (); + CpuidIntelProcessorTraceMainLeaf (); + CpuidTimeStampCounter (); + CpuidProcessorFrequency (); + CpuidSocVendor (); + CpuidExtendedFunction (); + CpuidExtendedCpuSig (); + CpuidProcessorBrandString (); + CpuidExtendedCacheInfo (); + CpuidExtendedTimeStampCounter (); + CpuidVirPhyAddressSize (); + + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Application/Cpuid/Cpuid.inf b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.inf new file mode 100644 index 0000000000..0d71b115d9 --- /dev/null +++ b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.inf @@ -0,0 +1,48 @@ +## @file +# UEFI Application to display CPUID leaf information. +# +# This UEFI application displays the registers values returned by CPUID for +# all the CPUID leafs and sub-leafs that a CPU supports. It also displays +# the values of all the bit fields in the registers returned by each CPUID +# leaf and sub-leaf. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Cpuid + MODULE_UNI_FILE = Cpuid.uni + FILE_GUID = 4AE7E1E8-9DFE-4e3e-85B4-A5F6ABD470FB + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 0.5 + ENTRY_POINT = UefiMain + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + Cpuid.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + BaseLib + UefiLib + +[UserExtensions.TianoCore."ExtraFiles"] + CpuidExtra.uni diff --git a/Core/UefiCpuPkg/Application/Cpuid/Cpuid.uni b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.uni new file mode 100644 index 0000000000..32dee43414 --- /dev/null +++ b/Core/UefiCpuPkg/Application/Cpuid/Cpuid.uni @@ -0,0 +1,22 @@ +// /** @file +// UEFI Application to display CPUID leaf information. +// +// This UEFI application displays the registers values returned by CPUID for +// all the CPUID leafs and sub-leafs that a CPU supports. It also displays +// the values of all the bit fields in the registers returned by each CPUID +// leaf and sub-leaf. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "UEFI Application to display CPUID leaf information" + +#string STR_MODULE_DESCRIPTION #language en-US "This UEFI application displays the registers values returned by CPUID for all the CPUID leafs and sub-leafs that a CPU supports. It also displays the values of all the bit fields in the registers returned by each CPUID leaf and sub-leaf." diff --git a/Core/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni b/Core/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni new file mode 100644 index 0000000000..b4251e23cc --- /dev/null +++ b/Core/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni @@ -0,0 +1,22 @@ +// /** @file +// UEFI Application to display CPUID leaf information. +// +// This UEFI application displays the registers values returned by CPUID for +// all the CPUID leafs and sub-leafs that a CPU supports. It also displays +// the values of all the bit fields in the registers returned by each CPUID +// leaf and sub-leaf. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPUID Application" diff --git a/Core/UefiCpuPkg/Contributions.txt b/Core/UefiCpuPkg/Contributions.txt new file mode 100644 index 0000000000..f87cbd73c6 --- /dev/null +++ b/Core/UefiCpuPkg/Contributions.txt @@ -0,0 +1,218 @@ + +====================== += Code Contributions = +====================== + +To make a contribution to a TianoCore project, follow these steps. +1. Create a change description in the format specified below to + use in the source control commit log. +2. Your commit message must include your "Signed-off-by" signature, + and "Contributed-under" message. +3. Your "Contributed-under" message explicitly states that the + contribution is made under the terms of the specified + contribution agreement. Your "Contributed-under" message + must include the name of contribution agreement and version. + For example: Contributed-under: TianoCore Contribution Agreement 1.0 + The "TianoCore Contribution Agreement" is included below in + this document. +4. Submit your code to the TianoCore project using the process + that the project documents on its web page. If the process is + not documented, then submit the code on development email list + for the project. +5. It is preferred that contributions are submitted using the same + copyright license as the base project. When that is not possible, + then contributions using the following licenses can be accepted: + * BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause + * BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause + * MIT: http://opensource.org/licenses/MIT + * Python-2.0: http://opensource.org/licenses/Python-2.0 + * Zlib: http://opensource.org/licenses/Zlib + + Contributions of code put into the public domain can also be + accepted. + + Contributions using other licenses might be accepted, but further + review will be required. + +===================================================== += Change Description / Commit Message / Patch Email = +===================================================== + +Your change description should use the standard format for a +commit message, and must include your "Signed-off-by" signature +and the "Contributed-under" message. + +== Sample Change Description / Commit Message = + +=== Start of sample patch email message === + +From: Contributor Name +Subject: [PATCH] CodeModule: Brief-single-line-summary + +Full-commit-message + +Contributed-under: TianoCore Contribution Agreement 1.0 +Signed-off-by: Contributor Name +--- + +An extra message for the patch email which will not be considered part +of the commit message can be added here. + +Patch content inline or attached + +=== End of sample patch email message === + +=== Notes for sample patch email === + +* The first line of commit message is taken from the email's subject + line following [PATCH]. The remaining portion of the commit message + is the email's content until the '---' line. +* git format-patch is one way to create this format + +=== Definitions for sample patch email === + +* "CodeModule" is a short idenfier for the affected code. For + example MdePkg, or MdeModulePkg UsbBusDxe. +* "Brief-single-line-summary" is a short summary of the change. +* The entire first line should be less than ~70 characters. +* "Full-commit-message" a verbose multiple line comment describing + the change. Each line should be less than ~70 characters. +* "Contributed-under" explicitely states that the contribution is + made under the terms of the contribtion agreement. This + agreement is included below in this document. +* "Signed-off-by" is the contributor's signature identifying them + by their real/legal name and their email address. + +======================================== += TianoCore Contribution Agreement 1.0 = +======================================== + +INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION, +INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE +PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE +TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE +TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR +REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE +CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS +OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED +BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS +AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE +AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT +USE THE CONTENT. + +Unless otherwise indicated, all Content made available on the TianoCore +site is provided to you under the terms and conditions of the BSD +License ("BSD"). A copy of the BSD License is available at +http://opensource.org/licenses/bsd-license.php +or when applicable, in the associated License.txt file. + +Certain other content may be made available under other licenses as +indicated in or with such Content. (For example, in a License.txt file.) + +You accept and agree to the following terms and conditions for Your +present and future Contributions submitted to TianoCore site. Except +for the license granted to Intel hereunder, You reserve all right, +title, and interest in and to Your Contributions. + +== SECTION 1: Definitions == +* "You" or "Contributor" shall mean the copyright owner or legal + entity authorized by the copyright owner that is making a + Contribution hereunder. All other entities that control, are + controlled by, or are under common control with that entity are + considered to be a single Contributor. For the purposes of this + definition, "control" means (i) the power, direct or indirect, to + cause the direction or management of such entity, whether by + contract or otherwise, or (ii) ownership of fifty percent (50%) + or more of the outstanding shares, or (iii) beneficial ownership + of such entity. +* "Contribution" shall mean any original work of authorship, + including any modifications or additions to an existing work, + that is intentionally submitted by You to the TinaoCore site for + inclusion in, or documentation of, any of the Content. For the + purposes of this definition, "submitted" means any form of + electronic, verbal, or written communication sent to the + TianoCore site or its representatives, including but not limited + to communication on electronic mailing lists, source code + control systems, and issue tracking systems that are managed by, + or on behalf of, the TianoCore site for the purpose of + discussing and improving the Content, but excluding + communication that is conspicuously marked or otherwise + designated in writing by You as "Not a Contribution." + +== SECTION 2: License for Contributions == +* Contributor hereby agrees that redistribution and use of the + Contribution in source and binary forms, with or without + modification, are permitted provided that the following + conditions are met: +** Redistributions of source code must retain the Contributor's + copyright notice, this list of conditions and the following + disclaimer. +** Redistributions in binary form must reproduce the Contributor's + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. +* Disclaimer. None of the names of Contributor, Intel, or the names + of their respective contributors may be used to endorse or + promote products derived from this software without specific + prior written permission. +* Contributor grants a license (with the right to sublicense) under + claims of Contributor's patents that Contributor can license that + are infringed by the Contribution (as delivered by Contributor) to + make, use, distribute, sell, offer for sale, and import the + Contribution and derivative works thereof solely to the minimum + extent necessary for licensee to exercise the granted copyright + license; this patent license applies solely to those portions of + the Contribution that are unmodified. No hardware per se is + licensed. +* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE + CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +== SECTION 3: Representations == +* You represent that You are legally entitled to grant the above + license. If your employer(s) has rights to intellectual property + that You create that includes Your Contributions, You represent + that You have received permission to make Contributions on behalf + of that employer, that Your employer has waived such rights for + Your Contributions. +* You represent that each of Your Contributions is Your original + creation (see Section 4 for submissions on behalf of others). + You represent that Your Contribution submissions include complete + details of any third-party license or other restriction + (including, but not limited to, related patents and trademarks) + of which You are personally aware and which are associated with + any part of Your Contributions. + +== SECTION 4: Third Party Contributions == +* Should You wish to submit work that is not Your original creation, + You may submit it to TianoCore site separately from any + Contribution, identifying the complete details of its source + and of any license or other restriction (including, but not + limited to, related patents, trademarks, and license agreements) + of which You are personally aware, and conspicuously marking the + work as "Submitted on behalf of a third-party: [named here]". + +== SECTION 5: Miscellaneous == +* Applicable Laws. Any claims arising under or relating to this + Agreement shall be governed by the internal substantive laws of + the State of Delaware or federal courts located in Delaware, + without regard to principles of conflict of laws. +* Language. This Agreement is in the English language only, which + language shall be controlling in all respects, and all versions + of this Agreement in any other language shall be for accommodation + only and shall not be binding. All communications and notices made + or given pursuant to this Agreement, and all documentation and + support to be provided, unless otherwise noted, shall be in the + English language. + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuDxe.c b/Core/UefiCpuPkg/CpuDxe/CpuDxe.c new file mode 100644 index 0000000000..4a5e282741 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -0,0 +1,1180 @@ +/** @file + CPU DXE Module to produce CPU ARCH Protocol. + + Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuDxe.h" +#include "CpuMp.h" +#include "CpuPageTable.h" + +#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) +#define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY_RO) + +// +// Global Variables +// +BOOLEAN InterruptState = FALSE; +EFI_HANDLE mCpuHandle = NULL; +BOOLEAN mIsFlushingGCD; +UINT64 mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; +UINT64 mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; +UINT64 mTimerPeriod = 0; + +FIXED_MTRR mFixedMtrrTable[] = { + { + MTRR_LIB_IA32_MTRR_FIX64K_00000, + 0, + 0x10000 + }, + { + MTRR_LIB_IA32_MTRR_FIX16K_80000, + 0x80000, + 0x4000 + }, + { + MTRR_LIB_IA32_MTRR_FIX16K_A0000, + 0xA0000, + 0x4000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_C0000, + 0xC0000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_C8000, + 0xC8000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_D0000, + 0xD0000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_D8000, + 0xD8000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_E0000, + 0xE0000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_E8000, + 0xE8000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_F0000, + 0xF0000, + 0x1000 + }, + { + MTRR_LIB_IA32_MTRR_FIX4K_F8000, + 0xF8000, + 0x1000 + }, +}; + + +EFI_CPU_ARCH_PROTOCOL gCpu = { + CpuFlushCpuDataCache, + CpuEnableInterrupt, + CpuDisableInterrupt, + CpuGetInterruptState, + CpuInit, + CpuRegisterInterruptHandler, + CpuGetTimerValue, + CpuSetMemoryAttributes, + 1, // NumberOfTimers + 4 // DmaBufferAlignment +}; + +// +// CPU Arch Protocol Functions +// + +/** + Flush CPU data cache. If the instruction cache is fully coherent + with all DMA operations then function can just return EFI_SUCCESS. + + @param This Protocol instance structure + @param Start Physical address to start flushing from. + @param Length Number of bytes to flush. Round up to chipset + granularity. + @param FlushType Specifies the type of flush operation to perform. + + @retval EFI_SUCCESS If cache was flushed + @retval EFI_UNSUPPORTED If flush type is not supported. + @retval EFI_DEVICE_ERROR If requested range could not be flushed. + +**/ +EFI_STATUS +EFIAPI +CpuFlushCpuDataCache ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length, + IN EFI_CPU_FLUSH_TYPE FlushType + ) +{ + if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) { + AsmWbinvd (); + return EFI_SUCCESS; + } else if (FlushType == EfiCpuFlushTypeInvalidate) { + AsmInvd (); + return EFI_SUCCESS; + } else { + return EFI_UNSUPPORTED; + } +} + + +/** + Enables CPU interrupts. + + @param This Protocol instance structure + + @retval EFI_SUCCESS If interrupts were enabled in the CPU + @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU. + +**/ +EFI_STATUS +EFIAPI +CpuEnableInterrupt ( + IN EFI_CPU_ARCH_PROTOCOL *This + ) +{ + EnableInterrupts (); + + InterruptState = TRUE; + return EFI_SUCCESS; +} + + +/** + Disables CPU interrupts. + + @param This Protocol instance structure + + @retval EFI_SUCCESS If interrupts were disabled in the CPU. + @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU. + +**/ +EFI_STATUS +EFIAPI +CpuDisableInterrupt ( + IN EFI_CPU_ARCH_PROTOCOL *This + ) +{ + DisableInterrupts (); + + InterruptState = FALSE; + return EFI_SUCCESS; +} + + +/** + Return the state of interrupts. + + @param This Protocol instance structure + @param State Pointer to the CPU's current interrupt state + + @retval EFI_SUCCESS If interrupts were disabled in the CPU. + @retval EFI_INVALID_PARAMETER State is NULL. + +**/ +EFI_STATUS +EFIAPI +CpuGetInterruptState ( + IN EFI_CPU_ARCH_PROTOCOL *This, + OUT BOOLEAN *State + ) +{ + if (State == NULL) { + return EFI_INVALID_PARAMETER; + } + + *State = InterruptState; + return EFI_SUCCESS; +} + + +/** + Generates an INIT to the CPU. + + @param This Protocol instance structure + @param InitType Type of CPU INIT to perform + + @retval EFI_SUCCESS If CPU INIT occurred. This value should never be + seen. + @retval EFI_DEVICE_ERROR If CPU INIT failed. + @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported. + +**/ +EFI_STATUS +EFIAPI +CpuInit ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_CPU_INIT_TYPE InitType + ) +{ + return EFI_UNSUPPORTED; +} + + +/** + Registers a function to be called from the CPU interrupt handler. + + @param This Protocol instance structure + @param InterruptType Defines which interrupt to hook. IA-32 + valid range is 0x00 through 0xFF + @param InterruptHandler A pointer to a function of type + EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. A null + pointer is an error condition. + + @retval EFI_SUCCESS If handler installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler + for InterruptType was previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for + InterruptType was not previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType + is not supported. + +**/ +EFI_STATUS +EFIAPI +CpuRegisterInterruptHandler ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return RegisterCpuInterruptHandler (InterruptType, InterruptHandler); +} + + +/** + Returns a timer value from one of the CPU's internal timers. There is no + inherent time interval between ticks but is a function of the CPU frequency. + + @param This - Protocol instance structure. + @param TimerIndex - Specifies which CPU timer is requested. + @param TimerValue - Pointer to the returned timer value. + @param TimerPeriod - A pointer to the amount of time that passes + in femtoseconds (10-15) for each increment + of TimerValue. If TimerValue does not + increment at a predictable rate, then 0 is + returned. The amount of time that has + passed between two calls to GetTimerValue() + can be calculated with the formula + (TimerValue2 - TimerValue1) * TimerPeriod. + This parameter is optional and may be NULL. + + @retval EFI_SUCCESS - If the CPU timer count was returned. + @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers. + @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer. + @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL. + +**/ +EFI_STATUS +EFIAPI +CpuGetTimerValue ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN UINT32 TimerIndex, + OUT UINT64 *TimerValue, + OUT UINT64 *TimerPeriod OPTIONAL + ) +{ + UINT64 BeginValue; + UINT64 EndValue; + + if (TimerValue == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (TimerIndex != 0) { + return EFI_INVALID_PARAMETER; + } + + *TimerValue = AsmReadTsc (); + + if (TimerPeriod != NULL) { + if (mTimerPeriod == 0) { + // + // Read time stamp counter before and after delay of 100 microseconds + // + BeginValue = AsmReadTsc (); + MicroSecondDelay (100); + EndValue = AsmReadTsc (); + // + // Calculate the actual frequency + // + mTimerPeriod = DivU64x64Remainder ( + MultU64x32 ( + 1000 * 1000 * 1000, + 100 + ), + EndValue - BeginValue, + NULL + ); + } + *TimerPeriod = mTimerPeriod; + } + + return EFI_SUCCESS; +} + +/** + A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to + EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure. + + @param[in] Buffer Pointer to an MTRR_SETTINGS object, to be passed to + MtrrSetAllMtrrs(). +**/ +VOID +EFIAPI +SetMtrrsFromBuffer ( + IN VOID *Buffer + ) +{ + MtrrSetAllMtrrs (Buffer); +} + +/** + Implementation of SetMemoryAttributes() service of CPU Architecture Protocol. + + This function modifies the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param This The EFI_CPU_ARCH_PROTOCOL instance. + @param BaseAddress The physical address that is the start address of a memory region. + @param Length The size in bytes of the memory region. + @param Attributes The bit mask of attributes to set for the memory region. + + @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +CpuSetMemoryAttributes ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ) +{ + RETURN_STATUS Status; + MTRR_MEMORY_CACHE_TYPE CacheType; + EFI_STATUS MpStatus; + EFI_MP_SERVICES_PROTOCOL *MpService; + MTRR_SETTINGS MtrrSettings; + UINT64 CacheAttributes; + UINT64 MemoryAttributes; + MTRR_MEMORY_CACHE_TYPE CurrentCacheType; + + // + // If this function is called because GCD SetMemorySpaceAttributes () is called + // by RefreshGcdMemoryAttributes (), then we are just synchronzing GCD memory + // map with MTRR values. So there is no need to modify MTRRs, just return immediately + // to avoid unnecessary computing. + // + if (mIsFlushingGCD) { + DEBUG((DEBUG_INFO, " Flushing GCD\n")); + return EFI_SUCCESS; + } + + + CacheAttributes = Attributes & CACHE_ATTRIBUTE_MASK; + MemoryAttributes = Attributes & MEMORY_ATTRIBUTE_MASK; + + if (Attributes != (CacheAttributes | MemoryAttributes)) { + return EFI_INVALID_PARAMETER; + } + + if (CacheAttributes != 0) { + if (!IsMtrrSupported ()) { + return EFI_UNSUPPORTED; + } + + switch (CacheAttributes) { + case EFI_MEMORY_UC: + CacheType = CacheUncacheable; + break; + + case EFI_MEMORY_WC: + CacheType = CacheWriteCombining; + break; + + case EFI_MEMORY_WT: + CacheType = CacheWriteThrough; + break; + + case EFI_MEMORY_WP: + CacheType = CacheWriteProtected; + break; + + case EFI_MEMORY_WB: + CacheType = CacheWriteBack; + break; + + default: + return EFI_INVALID_PARAMETER; + } + CurrentCacheType = MtrrGetMemoryAttribute(BaseAddress); + if (CurrentCacheType != CacheType) { + // + // call MTRR libary function + // + Status = MtrrSetMemoryAttribute ( + BaseAddress, + Length, + CacheType + ); + + if (!RETURN_ERROR (Status)) { + MpStatus = gBS->LocateProtocol ( + &gEfiMpServiceProtocolGuid, + NULL, + (VOID **)&MpService + ); + // + // Synchronize the update with all APs + // + if (!EFI_ERROR (MpStatus)) { + MtrrGetAllMtrrs (&MtrrSettings); + MpStatus = MpService->StartupAllAPs ( + MpService, // This + SetMtrrsFromBuffer, // Procedure + FALSE, // SingleThread + NULL, // WaitEvent + 0, // TimeoutInMicrosecsond + &MtrrSettings, // ProcedureArgument + NULL // FailedCpuList + ); + ASSERT (MpStatus == EFI_SUCCESS || MpStatus == EFI_NOT_STARTED); + } + } + if (EFI_ERROR(Status)) { + return Status; + } + } + } + + // + // Set memory attribute by page table + // + return AssignMemoryPageAttributes (NULL, BaseAddress, Length, MemoryAttributes, AllocatePages); +} + +/** + Initializes the valid bits mask and valid address mask for MTRRs. + + This function initializes the valid bits mask and valid address mask for MTRRs. + +**/ +VOID +InitializeMtrrMask ( + VOID + ) +{ + UINT32 RegEax; + UINT8 PhysicalAddressBits; + + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + + PhysicalAddressBits = (UINT8) RegEax; + + mValidMtrrBitsMask = LShiftU64 (1, PhysicalAddressBits) - 1; + mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL; + } else { + mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; + mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; + } +} + +/** + Gets GCD Mem Space type from MTRR Type. + + This function gets GCD Mem Space type from MTRR Type. + + @param MtrrAttributes MTRR memory type + + @return GCD Mem Space type + +**/ +UINT64 +GetMemorySpaceAttributeFromMtrrType ( + IN UINT8 MtrrAttributes + ) +{ + switch (MtrrAttributes) { + case MTRR_CACHE_UNCACHEABLE: + return EFI_MEMORY_UC; + case MTRR_CACHE_WRITE_COMBINING: + return EFI_MEMORY_WC; + case MTRR_CACHE_WRITE_THROUGH: + return EFI_MEMORY_WT; + case MTRR_CACHE_WRITE_PROTECTED: + return EFI_MEMORY_WP; + case MTRR_CACHE_WRITE_BACK: + return EFI_MEMORY_WB; + default: + return 0; + } +} + +/** + Searches memory descriptors covered by given memory range. + + This function searches into the Gcd Memory Space for descriptors + (from StartIndex to EndIndex) that contains the memory range + specified by BaseAddress and Length. + + @param MemorySpaceMap Gcd Memory Space Map as array. + @param NumberOfDescriptors Number of descriptors in map. + @param BaseAddress BaseAddress for the requested range. + @param Length Length for the requested range. + @param StartIndex Start index into the Gcd Memory Space Map. + @param EndIndex End index into the Gcd Memory Space Map. + + @retval EFI_SUCCESS Search successfully. + @retval EFI_NOT_FOUND The requested descriptors does not exist. + +**/ +EFI_STATUS +SearchGcdMemorySpaces ( + IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, + IN UINTN NumberOfDescriptors, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + OUT UINTN *StartIndex, + OUT UINTN *EndIndex + ) +{ + UINTN Index; + + *StartIndex = 0; + *EndIndex = 0; + for (Index = 0; Index < NumberOfDescriptors; Index++) { + if (BaseAddress >= MemorySpaceMap[Index].BaseAddress && + BaseAddress < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { + *StartIndex = Index; + } + if (BaseAddress + Length - 1 >= MemorySpaceMap[Index].BaseAddress && + BaseAddress + Length - 1 < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { + *EndIndex = Index; + return EFI_SUCCESS; + } + } + return EFI_NOT_FOUND; +} + +/** + Sets the attributes for a specified range in Gcd Memory Space Map. + + This function sets the attributes for a specified range in + Gcd Memory Space Map. + + @param MemorySpaceMap Gcd Memory Space Map as array + @param NumberOfDescriptors Number of descriptors in map + @param BaseAddress BaseAddress for the range + @param Length Length for the range + @param Attributes Attributes to set + + @retval EFI_SUCCESS Memory attributes set successfully + @retval EFI_NOT_FOUND The specified range does not exist in Gcd Memory Space + +**/ +EFI_STATUS +SetGcdMemorySpaceAttributes ( + IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, + IN UINTN NumberOfDescriptors, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN StartIndex; + UINTN EndIndex; + EFI_PHYSICAL_ADDRESS RegionStart; + UINT64 RegionLength; + + // + // Get all memory descriptors covered by the memory range + // + Status = SearchGcdMemorySpaces ( + MemorySpaceMap, + NumberOfDescriptors, + BaseAddress, + Length, + &StartIndex, + &EndIndex + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Go through all related descriptors and set attributes accordingly + // + for (Index = StartIndex; Index <= EndIndex; Index++) { + if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) { + continue; + } + // + // Calculate the start and end address of the overlapping range + // + if (BaseAddress >= MemorySpaceMap[Index].BaseAddress) { + RegionStart = BaseAddress; + } else { + RegionStart = MemorySpaceMap[Index].BaseAddress; + } + if (BaseAddress + Length - 1 < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { + RegionLength = BaseAddress + Length - RegionStart; + } else { + RegionLength = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - RegionStart; + } + // + // Set memory attributes according to MTRR attribute and the original attribute of descriptor + // + gDS->SetMemorySpaceAttributes ( + RegionStart, + RegionLength, + (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK) | (MemorySpaceMap[Index].Capabilities & Attributes) + ); + } + + return EFI_SUCCESS; +} + + +/** + Refreshes the GCD Memory Space attributes according to MTRRs. + + This function refreshes the GCD Memory Space attributes according to MTRRs. + +**/ +VOID +RefreshGcdMemoryAttributes ( + VOID + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN SubIndex; + UINT64 RegValue; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; + UINT64 Attributes; + UINT64 CurrentAttributes; + UINT8 MtrrType; + UINTN NumberOfDescriptors; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; + UINT64 DefaultAttributes; + VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; + MTRR_FIXED_SETTINGS MtrrFixedSettings; + UINT32 FirmwareVariableMtrrCount; + UINT8 DefaultMemoryType; + + if (!IsMtrrSupported ()) { + return; + } + + FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount (); + ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); + + mIsFlushingGCD = TRUE; + MemorySpaceMap = NULL; + + // + // Initialize the valid bits mask and valid address mask for MTRRs + // + InitializeMtrrMask (); + + // + // Get the memory attribute of variable MTRRs + // + MtrrGetMemoryAttributeInVariableMtrr ( + mValidMtrrBitsMask, + mValidMtrrAddressMask, + VariableMtrr + ); + + // + // Get the memory space map from GCD + // + Status = gDS->GetMemorySpaceMap ( + &NumberOfDescriptors, + &MemorySpaceMap + ); + ASSERT_EFI_ERROR (Status); + + DefaultMemoryType = (UINT8) MtrrGetDefaultMemoryType (); + DefaultAttributes = GetMemorySpaceAttributeFromMtrrType (DefaultMemoryType); + + // + // Set default attributes to all spaces. + // + for (Index = 0; Index < NumberOfDescriptors; Index++) { + if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) { + continue; + } + gDS->SetMemorySpaceAttributes ( + MemorySpaceMap[Index].BaseAddress, + MemorySpaceMap[Index].Length, + (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK) | + (MemorySpaceMap[Index].Capabilities & DefaultAttributes) + ); + } + + // + // Go for variable MTRRs with WB attribute + // + for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && + VariableMtrr[Index].Type == MTRR_CACHE_WRITE_BACK) { + SetGcdMemorySpaceAttributes ( + MemorySpaceMap, + NumberOfDescriptors, + VariableMtrr[Index].BaseAddress, + VariableMtrr[Index].Length, + EFI_MEMORY_WB + ); + } + } + + // + // Go for variable MTRRs with the attribute except for WB and UC attributes + // + for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && + VariableMtrr[Index].Type != MTRR_CACHE_WRITE_BACK && + VariableMtrr[Index].Type != MTRR_CACHE_UNCACHEABLE) { + Attributes = GetMemorySpaceAttributeFromMtrrType ((UINT8) VariableMtrr[Index].Type); + SetGcdMemorySpaceAttributes ( + MemorySpaceMap, + NumberOfDescriptors, + VariableMtrr[Index].BaseAddress, + VariableMtrr[Index].Length, + Attributes + ); + } + } + + // + // Go for variable MTRRs with UC attribute + // + for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && + VariableMtrr[Index].Type == MTRR_CACHE_UNCACHEABLE) { + SetGcdMemorySpaceAttributes ( + MemorySpaceMap, + NumberOfDescriptors, + VariableMtrr[Index].BaseAddress, + VariableMtrr[Index].Length, + EFI_MEMORY_UC + ); + } + } + + // + // Go for fixed MTRRs + // + Attributes = 0; + BaseAddress = 0; + Length = 0; + MtrrGetFixedMtrr (&MtrrFixedSettings); + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + RegValue = MtrrFixedSettings.Mtrr[Index]; + // + // Check for continuous fixed MTRR sections + // + for (SubIndex = 0; SubIndex < 8; SubIndex++) { + MtrrType = (UINT8) RShiftU64 (RegValue, SubIndex * 8); + CurrentAttributes = GetMemorySpaceAttributeFromMtrrType (MtrrType); + if (Length == 0) { + // + // A new MTRR attribute begins + // + Attributes = CurrentAttributes; + } else { + // + // If fixed MTRR attribute changed, then set memory attribute for previous atrribute + // + if (CurrentAttributes != Attributes) { + SetGcdMemorySpaceAttributes ( + MemorySpaceMap, + NumberOfDescriptors, + BaseAddress, + Length, + Attributes + ); + BaseAddress = mFixedMtrrTable[Index].BaseAddress + mFixedMtrrTable[Index].Length * SubIndex; + Length = 0; + Attributes = CurrentAttributes; + } + } + Length += mFixedMtrrTable[Index].Length; + } + } + // + // Handle the last fixed MTRR region + // + SetGcdMemorySpaceAttributes ( + MemorySpaceMap, + NumberOfDescriptors, + BaseAddress, + Length, + Attributes + ); + + // + // Free memory space map allocated by GCD service GetMemorySpaceMap () + // + if (MemorySpaceMap != NULL) { + FreePool (MemorySpaceMap); + } + + mIsFlushingGCD = FALSE; +} + +/** + Initialize Interrupt Descriptor Table for interrupt handling. + +**/ +VOID +InitInterruptDescriptorTable ( + VOID + ) +{ + EFI_STATUS Status; + EFI_VECTOR_HANDOFF_INFO *VectorInfoList; + EFI_VECTOR_HANDOFF_INFO *VectorInfo; + + VectorInfo = NULL; + Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **) &VectorInfoList); + if (Status == EFI_SUCCESS && VectorInfoList != NULL) { + VectorInfo = VectorInfoList; + } + Status = InitializeCpuInterruptHandlers (VectorInfo); + ASSERT_EFI_ERROR (Status); +} + + +/** + Callback function for idle events. + + @param Event Event whose notification function is being invoked. + @param Context The pointer to the notification function's context, + which is implementation-dependent. + +**/ +VOID +EFIAPI +IdleLoopEventCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + CpuSleep (); +} + +/** + Ensure the compatibility of a memory space descriptor with the MMIO aperture. + + The memory space descriptor can come from the GCD memory space map, or it can + represent a gap between two neighboring memory space descriptors. In the + latter case, the GcdMemoryType field is expected to be + EfiGcdMemoryTypeNonExistent. + + If the memory space descriptor already has type + EfiGcdMemoryTypeMemoryMappedIo, and its capabilities are a superset of the + required capabilities, then no action is taken -- it is by definition + compatible with the aperture. + + Otherwise, the intersection of the memory space descriptor is calculated with + the aperture. If the intersection is the empty set (no overlap), no action is + taken; the memory space descriptor is compatible with the aperture. + + Otherwise, the type of the descriptor is investigated again. If the type is + EfiGcdMemoryTypeNonExistent (representing a gap, or a genuine descriptor with + such a type), then an attempt is made to add the intersection as MMIO space + to the GCD memory space map, with the specified capabilities. This ensures + continuity for the aperture, and the descriptor is deemed compatible with the + aperture. + + Otherwise, the memory space descriptor is incompatible with the MMIO + aperture. + + @param[in] Base Base address of the aperture. + @param[in] Length Length of the aperture. + @param[in] Capabilities Capabilities required by the aperture. + @param[in] Descriptor The descriptor to ensure compatibility with the + aperture for. + + @retval EFI_SUCCESS The descriptor is compatible. The GCD memory + space map may have been updated, for + continuity within the aperture. + @retval EFI_INVALID_PARAMETER The descriptor is incompatible. + @return Error codes from gDS->AddMemorySpace(). +**/ +EFI_STATUS +IntersectMemoryDescriptor ( + IN UINT64 Base, + IN UINT64 Length, + IN UINT64 Capabilities, + IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor + ) +{ + UINT64 IntersectionBase; + UINT64 IntersectionEnd; + EFI_STATUS Status; + + if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo && + (Descriptor->Capabilities & Capabilities) == Capabilities) { + return EFI_SUCCESS; + } + + IntersectionBase = MAX (Base, Descriptor->BaseAddress); + IntersectionEnd = MIN (Base + Length, + Descriptor->BaseAddress + Descriptor->Length); + if (IntersectionBase >= IntersectionEnd) { + // + // The descriptor and the aperture don't overlap. + // + return EFI_SUCCESS; + } + + if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, + IntersectionBase, IntersectionEnd - IntersectionBase, + Capabilities); + + DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, + "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__, + IntersectionBase, IntersectionEnd, Status)); + return Status; + } + + DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts " + "with aperture [%Lx, %Lx) cap %Lx\n", gEfiCallerBaseName, __FUNCTION__, + Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length, + (UINT32)Descriptor->GcdMemoryType, Descriptor->Capabilities, + Base, Base + Length, Capabilities)); + return EFI_INVALID_PARAMETER; +} + +/** + Add MMIO space to GCD. + The routine checks the GCD database and only adds those which are + not added in the specified range to GCD. + + @param Base Base address of the MMIO space. + @param Length Length of the MMIO space. + @param Capabilities Capabilities of the MMIO space. + + @retval EFI_SUCCES The MMIO space was added successfully. +**/ +EFI_STATUS +AddMemoryMappedIoSpace ( + IN UINT64 Base, + IN UINT64 Length, + IN UINT64 Capabilities + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN NumberOfDescriptors; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; + + Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n", + gEfiCallerBaseName, __FUNCTION__, Status)); + return Status; + } + + for (Index = 0; Index < NumberOfDescriptors; Index++) { + Status = IntersectMemoryDescriptor (Base, Length, Capabilities, + &MemorySpaceMap[Index]); + if (EFI_ERROR (Status)) { + goto FreeMemorySpaceMap; + } + } + + DEBUG_CODE ( + // + // Make sure there are adjacent descriptors covering [Base, Base + Length). + // It is possible that they have not been merged; merging can be prevented + // by allocation and different capabilities. + // + UINT64 CheckBase; + EFI_STATUS CheckStatus; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; + + for (CheckBase = Base; + CheckBase < Base + Length; + CheckBase = Descriptor.BaseAddress + Descriptor.Length) { + CheckStatus = gDS->GetMemorySpaceDescriptor (CheckBase, &Descriptor); + ASSERT_EFI_ERROR (CheckStatus); + ASSERT (Descriptor.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo); + ASSERT ((Descriptor.Capabilities & Capabilities) == Capabilities); + } + ); + +FreeMemorySpaceMap: + FreePool (MemorySpaceMap); + + return Status; +} + +/** + Add and allocate CPU local APIC memory mapped space. + + @param[in]ImageHandle Image handle this driver. + +**/ +VOID +AddLocalApicMemorySpace ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS BaseAddress; + + BaseAddress = (EFI_PHYSICAL_ADDRESS) GetLocalApicBaseAddress(); + Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC); + ASSERT_EFI_ERROR (Status); + + // + // Try to allocate APIC memory mapped space, does not check return + // status because it may be allocated by other driver, or DXE Core if + // this range is built into Memory Allocation HOB. + // + Status = gDS->AllocateMemorySpace ( + EfiGcdAllocateAddress, + EfiGcdMemoryTypeMemoryMappedIo, + 0, + SIZE_4KB, + &BaseAddress, + ImageHandle, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: %a: AllocateMemorySpace() Status - %r\n", + gEfiCallerBaseName, __FUNCTION__, Status)); + } +} + +/** + Initialize the state information for the CPU Architectural Protocol. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS Thread can be successfully created + @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure + @retval EFI_DEVICE_ERROR Cannot create the thread + +**/ +EFI_STATUS +EFIAPI +InitializeCpu ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_EVENT IdleLoopEvent; + + InitializePageTableLib(); + + InitializeFloatingPointUnits (); + + // + // Make sure interrupts are disabled + // + DisableInterrupts (); + + // + // Init GDT for DXE + // + InitGlobalDescriptorTable (); + + // + // Setup IDT pointer, IDT and interrupt entry points + // + InitInterruptDescriptorTable (); + + // + // Enable the local APIC for Virtual Wire Mode. + // + ProgramVirtualWireMode (); + + // + // Install CPU Architectural Protocol + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &mCpuHandle, + &gEfiCpuArchProtocolGuid, &gCpu, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // + // Refresh GCD memory space map according to MTRR value. + // + RefreshGcdMemoryAttributes (); + + // + // Add and allocate local APIC memory mapped space + // + AddLocalApicMemorySpace (ImageHandle); + + // + // Setup a callback for idle events + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + IdleLoopEventCallback, + NULL, + &gIdleLoopEventGuid, + &IdleLoopEvent + ); + ASSERT_EFI_ERROR (Status); + + InitializeMpSupport (); + + return Status; +} + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuDxe.h b/Core/UefiCpuPkg/CpuDxe/CpuDxe.h new file mode 100644 index 0000000000..27ad45bf9b --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuDxe.h @@ -0,0 +1,264 @@ +/** @file + CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol. + + Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_DXE_H_ +#define _CPU_DXE_H_ + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \ + EFI_MEMORY_WC | \ + EFI_MEMORY_WT | \ + EFI_MEMORY_WB | \ + EFI_MEMORY_UCE \ + ) + + +/** + Flush CPU data cache. If the instruction cache is fully coherent + with all DMA operations then function can just return EFI_SUCCESS. + + @param This Protocol instance structure + @param Start Physical address to start flushing from. + @param Length Number of bytes to flush. Round up to chipset + granularity. + @param FlushType Specifies the type of flush operation to perform. + + @retval EFI_SUCCESS If cache was flushed + @retval EFI_UNSUPPORTED If flush type is not supported. + @retval EFI_DEVICE_ERROR If requested range could not be flushed. + +**/ +EFI_STATUS +EFIAPI +CpuFlushCpuDataCache ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length, + IN EFI_CPU_FLUSH_TYPE FlushType + ); + +/** + Enables CPU interrupts. + + @param This Protocol instance structure + + @retval EFI_SUCCESS If interrupts were enabled in the CPU + @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU. + +**/ +EFI_STATUS +EFIAPI +CpuEnableInterrupt ( + IN EFI_CPU_ARCH_PROTOCOL *This + ); + +/** + Disables CPU interrupts. + + @param This Protocol instance structure + + @retval EFI_SUCCESS If interrupts were disabled in the CPU. + @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU. + +**/ +EFI_STATUS +EFIAPI +CpuDisableInterrupt ( + IN EFI_CPU_ARCH_PROTOCOL *This + ); + +/** + Return the state of interrupts. + + @param This Protocol instance structure + @param State Pointer to the CPU's current interrupt state + + @retval EFI_SUCCESS If interrupts were disabled in the CPU. + @retval EFI_INVALID_PARAMETER State is NULL. + +**/ +EFI_STATUS +EFIAPI +CpuGetInterruptState ( + IN EFI_CPU_ARCH_PROTOCOL *This, + OUT BOOLEAN *State + ); + +/** + Generates an INIT to the CPU. + + @param This Protocol instance structure + @param InitType Type of CPU INIT to perform + + @retval EFI_SUCCESS If CPU INIT occurred. This value should never be + seen. + @retval EFI_DEVICE_ERROR If CPU INIT failed. + @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported. + +**/ +EFI_STATUS +EFIAPI +CpuInit ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_CPU_INIT_TYPE InitType + ); + +/** + Registers a function to be called from the CPU interrupt handler. + + @param This Protocol instance structure + @param InterruptType Defines which interrupt to hook. IA-32 + valid range is 0x00 through 0xFF + @param InterruptHandler A pointer to a function of type + EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. A null + pointer is an error condition. + + @retval EFI_SUCCESS If handler installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler + for InterruptType was previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for + InterruptType was not previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType + is not supported. + +**/ +EFI_STATUS +EFIAPI +CpuRegisterInterruptHandler ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ); + +/** + Returns a timer value from one of the CPU's internal timers. There is no + inherent time interval between ticks but is a function of the CPU frequency. + + @param This - Protocol instance structure. + @param TimerIndex - Specifies which CPU timer is requested. + @param TimerValue - Pointer to the returned timer value. + @param TimerPeriod - A pointer to the amount of time that passes + in femtoseconds (10-15) for each increment + of TimerValue. If TimerValue does not + increment at a predictable rate, then 0 is + returned. The amount of time that has + passed between two calls to GetTimerValue() + can be calculated with the formula + (TimerValue2 - TimerValue1) * TimerPeriod. + This parameter is optional and may be NULL. + + @retval EFI_SUCCESS - If the CPU timer count was returned. + @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers. + @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer. + @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL. + +**/ +EFI_STATUS +EFIAPI +CpuGetTimerValue ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN UINT32 TimerIndex, + OUT UINT64 *TimerValue, + OUT UINT64 *TimerPeriod OPTIONAL + ); + +/** + Set memory cacheability attributes for given range of memeory. + + @param This Protocol instance structure + @param BaseAddress Specifies the start address of the + memory range + @param Length Specifies the length of the memory range + @param Attributes The memory cacheability for the memory range + + @retval EFI_SUCCESS If the cacheability of that memory range is + set successfully + @retval EFI_UNSUPPORTED If the desired operation cannot be done + @retval EFI_INVALID_PARAMETER The input parameter is not correct, + such as Length = 0 + +**/ +EFI_STATUS +EFIAPI +CpuSetMemoryAttributes ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ); + +/** + Initialize Global Descriptor Table. + +**/ +VOID +InitGlobalDescriptorTable ( + VOID + ); + +/** + Sets the code selector (CS). + + @param Selector Value of code selector. + +**/ +VOID +EFIAPI +SetCodeSelector ( + UINT16 Selector + ); + +/** + Sets the data selector (DS). + + @param Selector Value of data selector. + +**/ +VOID +EFIAPI +SetDataSelectors ( + UINT16 Selector + ); + +#endif + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuDxe.inf b/Core/UefiCpuPkg/CpuDxe/CpuDxe.inf new file mode 100644 index 0000000000..3e8d196739 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuDxe.inf @@ -0,0 +1,89 @@ +## @file +# CPU driver installs CPU Architecture Protocol and CPU MP protocol. +# +# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuDxe + MODULE_UNI_FILE = CpuDxe.uni + FILE_GUID = 1A1E4886-9517-440e-9FDE-3BE44CEE2136 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeCpu + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + CpuLib + DebugLib + DxeServicesTableLib + MemoryAllocationLib + MtrrLib + UefiBootServicesTableLib + UefiDriverEntryPoint + LocalApicLib + UefiCpuLib + UefiLib + CpuExceptionHandlerLib + HobLib + ReportStatusCodeLib + MpInitLib + TimerLib + +[Sources] + CpuDxe.c + CpuDxe.h + CpuGdt.c + CpuGdt.h + CpuMp.c + CpuMp.h + CpuPageTable.h + CpuPageTable.c + +[Sources.IA32] + Ia32/CpuAsm.asm + Ia32/CpuAsm.nasm + Ia32/CpuAsm.S + +[Sources.X64] + X64/CpuAsm.asm + X64/CpuAsm.nasm + X64/CpuAsm.S + +[Protocols] + gEfiCpuArchProtocolGuid ## PRODUCES + gEfiMpServiceProtocolGuid ## PRODUCES + +[Guids] + gIdleLoopEventGuid ## CONSUMES ## Event + gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable + +[Ppis] + gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB + gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuDxeExtra.uni diff --git a/Core/UefiCpuPkg/CpuDxe/CpuDxe.uni b/Core/UefiCpuPkg/CpuDxe/CpuDxe.uni new file mode 100644 index 0000000000..caf01dcbf5 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuDxe.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU driver installs CPU Architecture Protocol and CPU MP Protocol. +// +// CPU driver installs CPU Architecture Protocol and CPU MP Protocol. +// +// Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni b/Core/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni new file mode 100644 index 0000000000..c1d201911c --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuDxe Localized Strings and Content +// +// Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Architectural and CPU Multi-processor DXE Driver" + + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuGdt.c b/Core/UefiCpuPkg/CpuDxe/CpuGdt.c new file mode 100644 index 0000000000..9ef2fdfefb --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuGdt.c @@ -0,0 +1,161 @@ +/** @file + C based implemention of IA32 interrupt handling only + requiring a minimal assembly interrupt entry point. + + Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuDxe.h" +#include "CpuGdt.h" + +// +// Global descriptor table (GDT) Template +// +STATIC GDT_ENTRIES GdtTemplate = { + // + // NULL_SEL + // + { + 0x0, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x0, // type + 0x0, // limit 19:16, flags + 0x0, // base 31:24 + }, + // + // LINEAR_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x092, // present, ring 0, data, read/write + 0x0CF, // page-granular, 32-bit + 0x0, + }, + // + // LINEAR_CODE_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x09F, // present, ring 0, code, execute/read, conforming, accessed + 0x0CF, // page-granular, 32-bit + 0x0, + }, + // + // SYS_DATA_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x093, // present, ring 0, data, read/write, accessed + 0x0CF, // page-granular, 32-bit + 0x0, + }, + // + // SYS_CODE_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x09A, // present, ring 0, code, execute/read + 0x0CF, // page-granular, 32-bit + 0x0, + }, + // + // SPARE4_SEL + // + { + 0x0, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x0, // type + 0x0, // limit 19:16, flags + 0x0, // base 31:24 + }, + // + // LINEAR_DATA64_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x092, // present, ring 0, data, read/write + 0x0CF, // page-granular, 32-bit + 0x0, + }, + // + // LINEAR_CODE64_SEL + // + { + 0x0FFFF, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x09A, // present, ring 0, code, execute/read + 0x0AF, // page-granular, 64-bit code + 0x0, // base (high) + }, + // + // SPARE5_SEL + // + { + 0x0, // limit 15:0 + 0x0, // base 15:0 + 0x0, // base 23:16 + 0x0, // type + 0x0, // limit 19:16, flags + 0x0, // base 31:24 + }, +}; + +/** + Initialize Global Descriptor Table. + +**/ +VOID +InitGlobalDescriptorTable ( + VOID + ) +{ + GDT_ENTRIES *gdt; + IA32_DESCRIPTOR gdtPtr; + + // + // Allocate Runtime Data for the GDT + // + gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); + ASSERT (gdt != NULL); + gdt = ALIGN_POINTER (gdt, 8); + + // + // Initialize all GDT entries + // + CopyMem (gdt, &GdtTemplate, sizeof (GdtTemplate)); + + // + // Write GDT register + // + gdtPtr.Base = (UINT32)(UINTN)(VOID*) gdt; + gdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1); + AsmWriteGdtr (&gdtPtr); + + // + // Update selector (segment) registers base on new GDT + // + SetCodeSelector ((UINT16)CPU_CODE_SEL); + SetDataSelectors ((UINT16)CPU_DATA_SEL); +} + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuGdt.h b/Core/UefiCpuPkg/CpuDxe/CpuGdt.h new file mode 100644 index 0000000000..2a00751602 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuGdt.h @@ -0,0 +1,74 @@ +/** @file + C based implemention of IA32 interrupt handling only + requiring a minimal assembly interrupt entry point. + + Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_GDT_H_ +#define _CPU_GDT_H_ + +// +// Local structure definitions +// + +#pragma pack (1) + +// +// Global Descriptor Entry structures +// + +typedef struct _GDT_ENTRY { + UINT16 Limit15_0; + UINT16 Base15_0; + UINT8 Base23_16; + UINT8 Type; + UINT8 Limit19_16_and_flags; + UINT8 Base31_24; +} GDT_ENTRY; + +typedef +struct _GDT_ENTRIES { + GDT_ENTRY Null; + GDT_ENTRY Linear; + GDT_ENTRY LinearCode; + GDT_ENTRY SysData; + GDT_ENTRY SysCode; + GDT_ENTRY Spare4; + GDT_ENTRY LinearData64; + GDT_ENTRY LinearCode64; + GDT_ENTRY Spare5; +} GDT_ENTRIES; + +#pragma pack () + +#define NULL_SEL OFFSET_OF (GDT_ENTRIES, Null) +#define LINEAR_SEL OFFSET_OF (GDT_ENTRIES, Linear) +#define LINEAR_CODE_SEL OFFSET_OF (GDT_ENTRIES, LinearCode) +#define SYS_DATA_SEL OFFSET_OF (GDT_ENTRIES, SysData) +#define SYS_CODE_SEL OFFSET_OF (GDT_ENTRIES, SysCode) +#define SPARE4_SEL OFFSET_OF (GDT_ENTRIES, Spare4) +#define LINEAR_DATA64_SEL OFFSET_OF (GDT_ENTRIES, LinearData64) +#define LINEAR_CODE64_SEL OFFSET_OF (GDT_ENTRIES, LinearCode64) +#define SPARE5_SEL OFFSET_OF (GDT_ENTRIES, Spare5) + +#if defined (MDE_CPU_IA32) +#define CPU_CODE_SEL LINEAR_CODE_SEL +#define CPU_DATA_SEL LINEAR_SEL +#elif defined (MDE_CPU_X64) +#define CPU_CODE_SEL LINEAR_CODE64_SEL +#define CPU_DATA_SEL LINEAR_DATA64_SEL +#else +#error CPU type not supported for CPU GDT initialization! +#endif + +#endif // _CPU_GDT_H_ + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuMp.c b/Core/UefiCpuPkg/CpuDxe/CpuMp.c new file mode 100644 index 0000000000..44569466d3 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuMp.c @@ -0,0 +1,639 @@ +/** @file + CPU DXE Module to produce CPU MP Protocol. + + Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuDxe.h" +#include "CpuMp.h" + +EFI_HANDLE mMpServiceHandle = NULL; +UINTN mNumberOfProcessors = 1; + +EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { + GetNumberOfProcessors, + GetProcessorInfo, + StartupAllAPs, + StartupThisAP, + SwitchBSP, + EnableDisableAP, + WhoAmI +}; + +/** + This service retrieves the number of logical processor in the platform + and the number of those logical processors that are enabled on this boot. + This service may only be called from the BSP. + + This function is used to retrieve the following information: + - The number of logical processors that are present in the system. + - The number of enabled logical processors in the system at the instant + this call is made. + + Because MP Service Protocol provides services to enable and disable processors + dynamically, the number of enabled logical processors may vary during the + course of a boot session. + + If this service is called from an AP, then EFI_DEVICE_ERROR is returned. + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors + is returned in NumberOfProcessors, the number of currently enabled processor + is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[out] NumberOfProcessors Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL. + +**/ +EFI_STATUS +EFIAPI +GetNumberOfProcessors ( + IN EFI_MP_SERVICES_PROTOCOL *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ) +{ + if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) { + return EFI_INVALID_PARAMETER; + } + + return MpInitLibGetNumberOfProcessors ( + NumberOfProcessors, + NumberOfEnabledProcessors + ); +} + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + This service retrieves detailed MP-related information about any processor + on the platform. Note the following: + - The processor information may change during the course of a boot session. + - The information presented here is entirely MP related. + + Information regarding the number of caches and their sizes, frequency of operation, + slot numbers is all considered platform-related information and is not provided + by this service. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + +**/ +EFI_STATUS +EFIAPI +GetProcessorInfo ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL); +} + +/** + This service executes a caller provided function on all enabled APs. APs can + run either simultaneously or one at a time in sequence. This service supports + both blocking and non-blocking requests. The non-blocking requests use EFI + events so the BSP can detect when the APs have finished. This service may only + be called from the BSP. + + This function is used to dispatch all the enabled APs to the function specified + by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned + immediately and Procedure is not started on any AP. + + If SingleThread is TRUE, all the enabled APs execute the function specified by + Procedure one by one, in ascending order of processor handle number. Otherwise, + all the enabled APs execute the function specified by Procedure simultaneously. + + If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all + APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking + mode, and the BSP returns from this service without waiting for APs. If a + non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT + is signaled, then EFI_UNSUPPORTED must be returned. + + If the timeout specified by TimeoutInMicroseconds expires before all APs return + from Procedure, then Procedure on the failed APs is terminated. All enabled APs + are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its + content points to the list of processor handle numbers in which Procedure was + terminated. + + Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + to make sure that the nature of the code that is executed on the BSP and the + dispatched APs is well controlled. The MP Services Protocol does not guarantee + that the Procedure function is MP-safe. Hence, the tasks that can be run in + parallel are limited to certain independent tasks and well-controlled exclusive + code. EFI services and protocols may not be called by APs unless otherwise + specified. + + In blocking execution mode, BSP waits until all APs finish or + TimeoutInMicroseconds expires. + + In non-blocking execution mode, BSP is freed to return to the caller and then + proceed to the next task without having to wait for APs. The following + sequence needs to occur in a non-blocking execution mode: + + -# The caller that intends to use this MP Services Protocol in non-blocking + mode creates WaitEvent by calling the EFI CreateEvent() service. The caller + invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent + is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests + the function specified by Procedure to be started on all the enabled APs, + and releases the BSP to continue with other tasks. + -# The caller can use the CheckEvent() and WaitForEvent() services to check + the state of the WaitEvent created in step 1. + -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP + Service signals WaitEvent by calling the EFI SignalEvent() function. If + FailedCpuList is not NULL, its content is available when WaitEvent is + signaled. If all APs returned from Procedure prior to the timeout, then + FailedCpuList is set to NULL. If not all APs return from Procedure before + the timeout, then FailedCpuList is filled in with the list of the failed + APs. The buffer is allocated by MP Service Protocol using AllocatePool(). + It is the caller's responsibility to free the buffer with FreePool() service. + -# This invocation of SignalEvent() function informs the caller that invoked + EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed + the specified task or a timeout occurred. The contents of FailedCpuList + can be examined to determine which APs did not complete the specified task + prior to the timeout. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroseconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure, or TimeoutInMicroseconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, + if all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + The buffer is allocated by MP Service Protocol, + and it's the caller's responsibility to + free the buffer with FreePool() service. + In blocking mode, it is ready for consumption + when the call returns. In non-blocking mode, + it is ready when WaitEvent is signaled. The + list of failed CPU is terminated by + END_OF_CPU_LIST. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +StartupAllAPs ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ) +{ + return MpInitLibStartupAllAPs ( + Procedure, + SingleThread, + WaitEvent, + TimeoutInMicroseconds, + ProcedureArgument, + FailedCpuList + ); +} + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. The caller can request the BSP to either wait for the completion + of the AP or just proceed with the next task by using the EFI event mechanism. + See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking + execution support. This service may only be called from the BSP. + + This function is used to dispatch one enabled AP to the function specified by + Procedure passing in the argument specified by ProcedureArgument. If WaitEvent + is NULL, execution is in blocking mode. The BSP waits until the AP finishes or + TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. + BSP proceeds to the next task without waiting for the AP. If a non-blocking mode + is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, + then EFI_UNSUPPORTED must be returned. + + If the timeout specified by TimeoutInMicroseconds expires before the AP returns + from Procedure, then execution of Procedure by the AP is terminated. The AP is + available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and + EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] Procedure A pointer to the function to be run on the + designated AP of the system. See type + EFI_AP_PROCEDURE. + @param[in] ProcessorNumber The handle number of the AP. The range is + from 0 to the total number of logical + processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until this AP finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on this AP, + and go on executing immediately. If this AP + return from Procedure or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + this AP to finish this Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + this AP returns from Procedure, then Procedure + on the AP is terminated. The + AP is available for next function assigned + by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure on the + specified AP. + @param[out] Finished If NULL, this parameter is ignored. In + blocking mode, this parameter is ignored. + In non-blocking mode, if AP returns from + Procedure before the timeout expires, its + content is set to TRUE. Otherwise, the + value is set to FALSE. The caller can + determine if the AP returned from Procedure + by evaluating this value. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval EFI_SUCCESS In non-blocking mode, the function has been + dispatched to specified AP. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + the specified AP has finished. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +StartupThisAP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ) +{ + return MpInitLibStartupThisAP ( + Procedure, + ProcessorNumber, + WaitEvent, + TimeoutInMicroseconds, + ProcedureArgument, + Finished + ); +} + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. The new BSP can take over the + execution of the old BSP and continue seamlessly from where the old one left + off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT + is signaled. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_SUCCESS The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + +**/ +EFI_STATUS +EFIAPI +SwitchBSP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); +} + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + This service allows the caller enable or disable an AP from this point onward. + The caller can optionally specify the health status of the AP by Health. If + an AP is being disabled, then the state of the disabled AP is implementation + dependent. If an AP is enabled, then the implementation must guarantee that a + complete initialization sequence is performed on the AP, so the AP is in a state + that is compatible with an MP operating system. This service may not be supported + after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. + + If the enable or disable AP operation cannot be completed prior to the return + from this service, then EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. This flag + corresponds to StatusFlag defined in + EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only + the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter + is ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed + prior to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. + +**/ +EFI_STATUS +EFIAPI +EnableDisableAP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); +} + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + This service returns the processor handle number for the calling processor. + The returned value is in the range from 0 to the total number of logical + processors minus 1. The total number of logical processors can be retrieved + with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be + called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER + is returned. Otherwise, the current processors handle number is returned in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[out] ProcessorNumber Pointer to the handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + +**/ +EFI_STATUS +EFIAPI +WhoAmI ( + IN EFI_MP_SERVICES_PROTOCOL *This, + OUT UINTN *ProcessorNumber + ) +{ + return MpInitLibWhoAmI (ProcessorNumber);; +} + +/** + Collects BIST data from HOB. + + This function collects BIST data from HOB built from Sec Platform Information + PPI or SEC Platform Information2 PPI. + +**/ +VOID +CollectBistDataFromHob ( + VOID + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; + EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation; + UINTN NumberOfData; + EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; + EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance; + UINTN ProcessorNumber; + EFI_PROCESSOR_INFORMATION ProcessorInfo; + EFI_HEALTH_FLAGS BistData; + UINTN CpuInstanceNumber; + + SecPlatformInformation2 = NULL; + SecPlatformInformation = NULL; + + // + // Get gEfiSecPlatformInformation2PpiGuid Guided HOB firstly + // + GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); + if (GuidHob != NULL) { + // + // Sec Platform Information2 PPI includes BSP/APs' BIST information + // + SecPlatformInformation2 = GET_GUID_HOB_DATA (GuidHob); + NumberOfData = SecPlatformInformation2->NumberOfCpus; + CpuInstance = SecPlatformInformation2->CpuInstance; + } else { + // + // Otherwise, get gEfiSecPlatformInformationPpiGuid Guided HOB + // + GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid); + if (GuidHob != NULL) { + SecPlatformInformation = GET_GUID_HOB_DATA (GuidHob); + NumberOfData = 1; + // + // SEC Platform Information only includes BSP's BIST information + // does not have BSP's APIC ID + // + BspCpuInstance.CpuLocation = GetApicId (); + BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32; + CpuInstance = &BspCpuInstance; + } else { + DEBUG ((DEBUG_INFO, "Does not find any HOB stored CPU BIST information!\n")); + // + // Does not find any HOB stored BIST information + // + return; + } + } + + for (ProcessorNumber = 0; ProcessorNumber < mNumberOfProcessors; ProcessorNumber++) { + MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData); + for (CpuInstanceNumber = 0; CpuInstanceNumber < NumberOfData; CpuInstanceNumber++) { + if (ProcessorInfo.ProcessorId == CpuInstance[CpuInstanceNumber].CpuLocation) { + // + // Update CPU health status for MP Services Protocol according to BIST data. + // + BistData = CpuInstance[CpuInstanceNumber].InfoRecord.IA32HealthFlags; + } + } + if (BistData.Uint32 != 0) { + // + // Report Status Code that self test is failed + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST) + ); + } + } +} + +/** + Initialize Multi-processor support. + +**/ +VOID +InitializeMpSupport ( + VOID + ) +{ + EFI_STATUS Status; + UINTN NumberOfProcessors; + UINTN NumberOfEnabledProcessors; + + // + // Wakeup APs to do initialization + // + Status = MpInitLibInitialize (); + ASSERT_EFI_ERROR (Status); + + MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); + mNumberOfProcessors = NumberOfProcessors; + DEBUG ((DEBUG_ERROR, "Detect CPU count: %d\n", mNumberOfProcessors)); + + // + // Update CPU healthy information from Guided HOB + // + CollectBistDataFromHob (); + + Status = gBS->InstallMultipleProtocolInterfaces ( + &mMpServiceHandle, + &gEfiMpServiceProtocolGuid, &mMpServicesTemplate, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuMp.h b/Core/UefiCpuPkg/CpuDxe/CpuMp.h new file mode 100644 index 0000000000..43ec3bdd0b --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuMp.h @@ -0,0 +1,476 @@ +/** @file + CPU DXE MP support + + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_MP_H_ +#define _CPU_MP_H_ + +/** + Initialize Multi-processor support. + +**/ +VOID +InitializeMpSupport ( + VOID + ); + +/** + This service retrieves the number of logical processor in the platform + and the number of those logical processors that are enabled on this boot. + This service may only be called from the BSP. + + This function is used to retrieve the following information: + - The number of logical processors that are present in the system. + - The number of enabled logical processors in the system at the instant + this call is made. + + Because MP Service Protocol provides services to enable and disable processors + dynamically, the number of enabled logical processors may vary during the + course of a boot session. + + If this service is called from an AP, then EFI_DEVICE_ERROR is returned. + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors + is returned in NumberOfProcessors, the number of currently enabled processor + is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[out] NumberOfProcessors Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL. + +**/ +EFI_STATUS +EFIAPI +GetNumberOfProcessors ( + IN EFI_MP_SERVICES_PROTOCOL *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ); + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + This service retrieves detailed MP-related information about any processor + on the platform. Note the following: + - The processor information may change during the course of a boot session. + - The information presented here is entirely MP related. + + Information regarding the number of caches and their sizes, frequency of operation, + slot numbers is all considered platform-related information and is not provided + by this service. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + +**/ +EFI_STATUS +EFIAPI +GetProcessorInfo ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + This service executes a caller provided function on all enabled APs. APs can + run either simultaneously or one at a time in sequence. This service supports + both blocking and non-blocking requests. The non-blocking requests use EFI + events so the BSP can detect when the APs have finished. This service may only + be called from the BSP. + + This function is used to dispatch all the enabled APs to the function specified + by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned + immediately and Procedure is not started on any AP. + + If SingleThread is TRUE, all the enabled APs execute the function specified by + Procedure one by one, in ascending order of processor handle number. Otherwise, + all the enabled APs execute the function specified by Procedure simultaneously. + + If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all + APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking + mode, and the BSP returns from this service without waiting for APs. If a + non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT + is signaled, then EFI_UNSUPPORTED must be returned. + + If the timeout specified by TimeoutInMicroseconds expires before all APs return + from Procedure, then Procedure on the failed APs is terminated. All enabled APs + are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its + content points to the list of processor handle numbers in which Procedure was + terminated. + + Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + to make sure that the nature of the code that is executed on the BSP and the + dispatched APs is well controlled. The MP Services Protocol does not guarantee + that the Procedure function is MP-safe. Hence, the tasks that can be run in + parallel are limited to certain independent tasks and well-controlled exclusive + code. EFI services and protocols may not be called by APs unless otherwise + specified. + + In blocking execution mode, BSP waits until all APs finish or + TimeoutInMicroseconds expires. + + In non-blocking execution mode, BSP is freed to return to the caller and then + proceed to the next task without having to wait for APs. The following + sequence needs to occur in a non-blocking execution mode: + + -# The caller that intends to use this MP Services Protocol in non-blocking + mode creates WaitEvent by calling the EFI CreateEvent() service. The caller + invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent + is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests + the function specified by Procedure to be started on all the enabled APs, + and releases the BSP to continue with other tasks. + -# The caller can use the CheckEvent() and WaitForEvent() services to check + the state of the WaitEvent created in step 1. + -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP + Service signals WaitEvent by calling the EFI SignalEvent() function. If + FailedCpuList is not NULL, its content is available when WaitEvent is + signaled. If all APs returned from Procedure prior to the timeout, then + FailedCpuList is set to NULL. If not all APs return from Procedure before + the timeout, then FailedCpuList is filled in with the list of the failed + APs. The buffer is allocated by MP Service Protocol using AllocatePool(). + It is the caller's responsibility to free the buffer with FreePool() service. + -# This invocation of SignalEvent() function informs the caller that invoked + EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed + the specified task or a timeout occurred. The contents of FailedCpuList + can be examined to determine which APs did not complete the specified task + prior to the timeout. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroseconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure, or TimeoutInMicroseconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, + if all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + The buffer is allocated by MP Service Protocol, + and it's the caller's responsibility to + free the buffer with FreePool() service. + In blocking mode, it is ready for consumption + when the call returns. In non-blocking mode, + it is ready when WaitEvent is signaled. The + list of failed CPU is terminated by + END_OF_CPU_LIST. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +StartupAllAPs ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ); + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. The caller can request the BSP to either wait for the completion + of the AP or just proceed with the next task by using the EFI event mechanism. + See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking + execution support. This service may only be called from the BSP. + + This function is used to dispatch one enabled AP to the function specified by + Procedure passing in the argument specified by ProcedureArgument. If WaitEvent + is NULL, execution is in blocking mode. The BSP waits until the AP finishes or + TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. + BSP proceeds to the next task without waiting for the AP. If a non-blocking mode + is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, + then EFI_UNSUPPORTED must be returned. + + If the timeout specified by TimeoutInMicroseconds expires before the AP returns + from Procedure, then execution of Procedure by the AP is terminated. The AP is + available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and + EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL + instance. + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] ProcessorNumber The handle number of the AP. The range is + from 0 to the total number of logical + processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroseconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure or TimeoutInMicroseconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() + or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] Finished If NULL, this parameter is ignored. In + blocking mode, this parameter is ignored. + In non-blocking mode, if AP returns from + Procedure before the timeout expires, its + content is set to TRUE. Otherwise, the + value is set to FALSE. The caller can + determine if the AP returned from Procedure + by evaluating this value. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval EFI_SUCCESS In non-blocking mode, the function has been + dispatched to specified AP. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + the specified AP has finished. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +StartupThisAP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ); + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. The new BSP can take over the + execution of the old BSP and continue seamlessly from where the old one left + off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT + is signaled. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_SUCCESS The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + +**/ +EFI_STATUS +EFIAPI +SwitchBSP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ); + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + This service allows the caller enable or disable an AP from this point onward. + The caller can optionally specify the health status of the AP by Health. If + an AP is being disabled, then the state of the disabled AP is implementation + dependent. If an AP is enabled, then the implementation must guarantee that a + complete initialization sequence is performed on the AP, so the AP is in a state + that is compatible with an MP operating system. This service may not be supported + after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. + + If the enable or disable AP operation cannot be completed prior to the return + from this service, then EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. This flag + corresponds to StatusFlag defined in + EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only + the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter + is ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed + prior to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. + +**/ +EFI_STATUS +EFIAPI +EnableDisableAP ( + IN EFI_MP_SERVICES_PROTOCOL *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ); + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + This service returns the processor handle number for the calling processor. + The returned value is in the range from 0 to the total number of logical + processors minus 1. The total number of logical processors can be retrieved + with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be + called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER + is returned. Otherwise, the current processors handle number is returned in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. + @param[out] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + +**/ +EFI_STATUS +EFIAPI +WhoAmI ( + IN EFI_MP_SERVICES_PROTOCOL *This, + OUT UINTN *ProcessorNumber + ); + +#endif // _CPU_MP_H_ + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuPageTable.c b/Core/UefiCpuPkg/CpuDxe/CpuPageTable.c new file mode 100644 index 0000000000..2c61e7503e --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -0,0 +1,788 @@ +/** @file + Page table management support. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "CpuPageTable.h" + +/// +/// Page Table Entry +/// +#define IA32_PG_P BIT0 +#define IA32_PG_RW BIT1 +#define IA32_PG_U BIT2 +#define IA32_PG_WT BIT3 +#define IA32_PG_CD BIT4 +#define IA32_PG_A BIT5 +#define IA32_PG_D BIT6 +#define IA32_PG_PS BIT7 +#define IA32_PG_PAT_2M BIT12 +#define IA32_PG_PAT_4K IA32_PG_PS +#define IA32_PG_PMNT BIT62 +#define IA32_PG_NX BIT63 + +#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P) +// +// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE +// X64 PAE PDPTE does not have such restriction +// +#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) + +#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS) + +#define PAGING_4K_MASK 0xFFF +#define PAGING_2M_MASK 0x1FFFFF +#define PAGING_1G_MASK 0x3FFFFFFF + +#define PAGING_PAE_INDEX_MASK 0x1FF + +#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull +#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull +#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull + +typedef enum { + PageNone, + Page4K, + Page2M, + Page1G, +} PAGE_ATTRIBUTE; + +typedef struct { + PAGE_ATTRIBUTE Attribute; + UINT64 Length; + UINT64 AddressMask; +} PAGE_ATTRIBUTE_TABLE; + +typedef enum { + PageActionAssign, + PageActionSet, + PageActionClear, +} PAGE_ACTION; + +PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = { + {Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64}, + {Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64}, + {Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64}, +}; + +/** + Enable write protection function for AP. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +SyncCpuEnableWriteProtection ( + IN OUT VOID *Buffer + ) +{ + AsmWriteCr0 (AsmReadCr0 () | BIT16); +} + +/** + CpuFlushTlb function for AP. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +SyncCpuFlushTlb ( + IN OUT VOID *Buffer + ) +{ + CpuFlushTlb(); +} + +/** + Sync memory page attributes for AP. + + @param[in] Procedure A pointer to the function to be run on enabled APs of + the system. +**/ +VOID +SyncMemoryPageAttributesAp ( + IN EFI_AP_PROCEDURE Procedure + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpService; + + Status = gBS->LocateProtocol ( + &gEfiMpServiceProtocolGuid, + NULL, + (VOID **)&MpService + ); + // + // Synchronize the update with all APs + // + if (!EFI_ERROR (Status)) { + Status = MpService->StartupAllAPs ( + MpService, // This + Procedure, // Procedure + FALSE, // SingleThread + NULL, // WaitEvent + 0, // TimeoutInMicrosecsond + NULL, // ProcedureArgument + NULL // FailedCpuList + ); + ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_STARTED || Status == EFI_NOT_READY); + } +} + +/** + Return current paging context. + + @param[in,out] PagingContext The paging context. +**/ +VOID +GetCurrentPagingContext ( + IN OUT PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext + ) +{ + UINT32 RegEax; + UINT32 RegEdx; + + ZeroMem(PagingContext, sizeof(*PagingContext)); + if (sizeof(UINTN) == sizeof(UINT64)) { + PagingContext->MachineType = IMAGE_FILE_MACHINE_X64; + } else { + PagingContext->MachineType = IMAGE_FILE_MACHINE_I386; + } + if ((AsmReadCr0 () & BIT31) != 0) { + PagingContext->ContextData.X64.PageTableBase = (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64); + if ((AsmReadCr0 () & BIT16) == 0) { + AsmWriteCr0 (AsmReadCr0 () | BIT16); + SyncMemoryPageAttributesAp (SyncCpuEnableWriteProtection); + } + } else { + PagingContext->ContextData.X64.PageTableBase = 0; + } + + if ((AsmReadCr4 () & BIT4) != 0) { + PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE; + } + if ((AsmReadCr4 () & BIT5) != 0) { + PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE; + } + if ((AsmReadCr0 () & BIT16) != 0) { + PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE; + } + + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax > 0x80000000) { + AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & BIT20) != 0) { + // XD supported + if ((AsmReadMsr64 (0xC0000080) & BIT11) != 0) { + // XD activated + PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED; + } + } + if ((RegEdx & BIT26) != 0) { + PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT; + } + } +} + +/** + Return length according to page attributes. + + @param[in] PageAttributes The page attribute of the page entry. + + @return The length of page entry. +**/ +UINTN +PageAttributeToLength ( + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINTN Index; + for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { + if (PageAttribute == mPageAttributeTable[Index].Attribute) { + return (UINTN)mPageAttributeTable[Index].Length; + } + } + return 0; +} + +/** + Return address mask according to page attributes. + + @param[in] PageAttributes The page attribute of the page entry. + + @return The address mask of page entry. +**/ +UINTN +PageAttributeToMask ( + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINTN Index; + for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { + if (PageAttribute == mPageAttributeTable[Index].Attribute) { + return (UINTN)mPageAttributeTable[Index].AddressMask; + } + } + return 0; +} + +/** + Return page table entry to match the address. + + @param[in] PagingContext The paging context. + @param[in] Address The address to be checked. + @param[out] PageAttributes The page attribute of the page entry. + + @return The page entry. +**/ +VOID * +GetPageTableEntry ( + IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, + IN PHYSICAL_ADDRESS Address, + OUT PAGE_ATTRIBUTE *PageAttribute + ) +{ + UINTN Index1; + UINTN Index2; + UINTN Index3; + UINTN Index4; + UINT64 *L1PageTable; + UINT64 *L2PageTable; + UINT64 *L3PageTable; + UINT64 *L4PageTable; + UINT64 AddressEncMask; + + ASSERT (PagingContext != NULL); + + Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK; + Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK; + Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK; + Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK; + + // Make sure AddressEncMask is contained to smallest supported address field. + // + AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + + if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) { + L4PageTable = (UINT64 *)(UINTN)PagingContext->ContextData.X64.PageTableBase; + if (L4PageTable[Index4] == 0) { + *PageAttribute = PageNone; + return NULL; + } + + L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); + } else { + ASSERT((PagingContext->ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) != 0); + L3PageTable = (UINT64 *)(UINTN)PagingContext->ContextData.Ia32.PageTableBase; + } + if (L3PageTable[Index3] == 0) { + *PageAttribute = PageNone; + return NULL; + } + if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { + // 1G + *PageAttribute = Page1G; + return &L3PageTable[Index3]; + } + + L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L2PageTable[Index2] == 0) { + *PageAttribute = PageNone; + return NULL; + } + if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { + // 2M + *PageAttribute = Page2M; + return &L2PageTable[Index2]; + } + + // 4k + L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if ((L1PageTable[Index1] == 0) && (Address != 0)) { + *PageAttribute = PageNone; + return NULL; + } + *PageAttribute = Page4K; + return &L1PageTable[Index1]; +} + +/** + Return memory attributes of page entry. + + @param[in] PageEntry The page entry. + + @return Memory attributes of page entry. +**/ +UINT64 +GetAttributesFromPageEntry ( + IN UINT64 *PageEntry + ) +{ + UINT64 Attributes; + Attributes = 0; + if ((*PageEntry & IA32_PG_P) == 0) { + Attributes |= EFI_MEMORY_RP; + } + if ((*PageEntry & IA32_PG_RW) == 0) { + Attributes |= EFI_MEMORY_RO; + } + if ((*PageEntry & IA32_PG_NX) != 0) { + Attributes |= EFI_MEMORY_XP; + } + return Attributes; +} + +/** + Modify memory attributes of page entry. + + @param[in] PagingContext The paging context. + @param[in] PageEntry The page entry. + @param[in] Attributes The bit mask of attributes to modify for the memory region. + @param[in] PageAction The page action. + @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. +**/ +VOID +ConvertPageEntryAttribute ( + IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, + IN UINT64 *PageEntry, + IN UINT64 Attributes, + IN PAGE_ACTION PageAction, + OUT BOOLEAN *IsModified + ) +{ + UINT64 CurrentPageEntry; + UINT64 NewPageEntry; + + CurrentPageEntry = *PageEntry; + NewPageEntry = CurrentPageEntry; + if ((Attributes & EFI_MEMORY_RP) != 0) { + switch (PageAction) { + case PageActionAssign: + case PageActionSet: + NewPageEntry &= ~(UINT64)IA32_PG_P; + break; + case PageActionClear: + NewPageEntry |= IA32_PG_P; + break; + } + } else { + switch (PageAction) { + case PageActionAssign: + NewPageEntry |= IA32_PG_P; + break; + case PageActionSet: + case PageActionClear: + break; + } + } + if ((Attributes & EFI_MEMORY_RO) != 0) { + switch (PageAction) { + case PageActionAssign: + case PageActionSet: + NewPageEntry &= ~(UINT64)IA32_PG_RW; + break; + case PageActionClear: + NewPageEntry |= IA32_PG_RW; + break; + } + } else { + switch (PageAction) { + case PageActionAssign: + NewPageEntry |= IA32_PG_RW; + break; + case PageActionSet: + case PageActionClear: + break; + } + } + if ((PagingContext->ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED) != 0) { + if ((Attributes & EFI_MEMORY_XP) != 0) { + switch (PageAction) { + case PageActionAssign: + case PageActionSet: + NewPageEntry |= IA32_PG_NX; + break; + case PageActionClear: + NewPageEntry &= ~IA32_PG_NX; + break; + } + } else { + switch (PageAction) { + case PageActionAssign: + NewPageEntry &= ~IA32_PG_NX; + break; + case PageActionSet: + case PageActionClear: + break; + } + } + } + *PageEntry = NewPageEntry; + if (CurrentPageEntry != NewPageEntry) { + *IsModified = TRUE; + DEBUG ((DEBUG_INFO, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry)); + DEBUG ((DEBUG_INFO, "->0x%lx\n", NewPageEntry)); + } else { + *IsModified = FALSE; + } +} + +/** + This function returns if there is need to split page entry. + + @param[in] BaseAddress The base address to be checked. + @param[in] Length The length to be checked. + @param[in] PageEntry The page entry to be checked. + @param[in] PageAttribute The page attribute of the page entry. + + @retval SplitAttributes on if there is need to split page entry. +**/ +PAGE_ATTRIBUTE +NeedSplitPage ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 *PageEntry, + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINT64 PageEntryLength; + + PageEntryLength = PageAttributeToLength (PageAttribute); + + if (((BaseAddress & (PageEntryLength - 1)) == 0) && (Length >= PageEntryLength)) { + return PageNone; + } + + if (((BaseAddress & PAGING_2M_MASK) != 0) || (Length < SIZE_2MB)) { + return Page4K; + } + + return Page2M; +} + +/** + This function splits one page entry to small page entries. + + @param[in] PageEntry The page entry to be splitted. + @param[in] PageAttribute The page attribute of the page entry. + @param[in] SplitAttribute How to split the page entry. + @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. + + @retval RETURN_SUCCESS The page entry is splitted. + @retval RETURN_UNSUPPORTED The page entry does not support to be splitted. + @retval RETURN_OUT_OF_RESOURCES No resource to split page entry. +**/ +RETURN_STATUS +SplitPage ( + IN UINT64 *PageEntry, + IN PAGE_ATTRIBUTE PageAttribute, + IN PAGE_ATTRIBUTE SplitAttribute, + IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc + ) +{ + UINT64 BaseAddress; + UINT64 *NewPageEntry; + UINTN Index; + UINT64 AddressEncMask; + + ASSERT (PageAttribute == Page2M || PageAttribute == Page1G); + + ASSERT (AllocatePagesFunc != NULL); + + // Make sure AddressEncMask is contained to smallest supported address field. + // + AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + + if (PageAttribute == Page2M) { + // + // Split 2M to 4K + // + ASSERT (SplitAttribute == Page4K); + if (SplitAttribute == Page4K) { + NewPageEntry = AllocatePagesFunc (1); + DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry)); + if (NewPageEntry == NULL) { + return RETURN_OUT_OF_RESOURCES; + } + BaseAddress = *PageEntry & ~AddressEncMask & PAGING_2M_ADDRESS_MASK_64; + for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { + NewPageEntry[Index] = (BaseAddress + SIZE_4KB * Index) | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); + } + (*PageEntry) = (UINT64)(UINTN)NewPageEntry | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); + return RETURN_SUCCESS; + } else { + return RETURN_UNSUPPORTED; + } + } else if (PageAttribute == Page1G) { + // + // Split 1G to 2M + // No need support 1G->4K directly, we should use 1G->2M, then 2M->4K to get more compact page table. + // + ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K); + if ((SplitAttribute == Page2M || SplitAttribute == Page4K)) { + NewPageEntry = AllocatePagesFunc (1); + DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry)); + if (NewPageEntry == NULL) { + return RETURN_OUT_OF_RESOURCES; + } + BaseAddress = *PageEntry & ~AddressEncMask & PAGING_1G_ADDRESS_MASK_64; + for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { + NewPageEntry[Index] = (BaseAddress + SIZE_2MB * Index) | AddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS); + } + (*PageEntry) = (UINT64)(UINTN)NewPageEntry | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); + return RETURN_SUCCESS; + } else { + return RETURN_UNSUPPORTED; + } + } else { + return RETURN_UNSUPPORTED; + } +} + +/** + This function modifies the page attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + Caller should make sure BaseAddress and Length is at page boundary. + + @param[in] PagingContext The paging context. NULL means get page table from current CPU context. + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to modify for the memory region. + @param[in] PageAction The page action. + @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. + NULL mean page split is unsupported. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. + + @retval RETURN_SUCCESS The attributes were modified for the memory region. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. +**/ +RETURN_STATUS +ConvertMemoryPageAttributes ( + IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN PAGE_ACTION PageAction, + IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL, + OUT BOOLEAN *IsSplitted, OPTIONAL + OUT BOOLEAN *IsModified OPTIONAL + ) +{ + PAGE_TABLE_LIB_PAGING_CONTEXT CurrentPagingContext; + UINT64 *PageEntry; + PAGE_ATTRIBUTE PageAttribute; + UINTN PageEntryLength; + PAGE_ATTRIBUTE SplitAttribute; + RETURN_STATUS Status; + BOOLEAN IsEntryModified; + + if ((BaseAddress & (SIZE_4KB - 1)) != 0) { + DEBUG ((DEBUG_ERROR, "BaseAddress(0x%lx) is not aligned!\n", BaseAddress)); + return EFI_UNSUPPORTED; + } + if ((Length & (SIZE_4KB - 1)) != 0) { + DEBUG ((DEBUG_ERROR, "Length(0x%lx) is not aligned!\n", Length)); + return EFI_UNSUPPORTED; + } + if (Length == 0) { + DEBUG ((DEBUG_ERROR, "Length is 0!\n")); + return RETURN_INVALID_PARAMETER; + } + + if ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) != 0) { + DEBUG ((DEBUG_ERROR, "Attributes(0x%lx) has unsupported bit\n", Attributes)); + return EFI_UNSUPPORTED; + } + + if (PagingContext == NULL) { + GetCurrentPagingContext (&CurrentPagingContext); + } else { + CopyMem (&CurrentPagingContext, PagingContext, sizeof(CurrentPagingContext)); + } + switch(CurrentPagingContext.MachineType) { + case IMAGE_FILE_MACHINE_I386: + if (CurrentPagingContext.ContextData.Ia32.PageTableBase == 0) { + if (Attributes == 0) { + return EFI_SUCCESS; + } else { + DEBUG ((DEBUG_ERROR, "PageTable is 0!\n")); + return EFI_UNSUPPORTED; + } + } + if ((CurrentPagingContext.ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) == 0) { + DEBUG ((DEBUG_ERROR, "Non-PAE Paging!\n")); + return EFI_UNSUPPORTED; + } + break; + case IMAGE_FILE_MACHINE_X64: + ASSERT (CurrentPagingContext.ContextData.X64.PageTableBase != 0); + break; + default: + ASSERT(FALSE); + return EFI_UNSUPPORTED; + break; + } + +// DEBUG ((DEBUG_ERROR, "ConvertMemoryPageAttributes(%x) - %016lx, %016lx, %02lx\n", IsSet, BaseAddress, Length, Attributes)); + + if (IsSplitted != NULL) { + *IsSplitted = FALSE; + } + if (IsModified != NULL) { + *IsModified = FALSE; + } + + // + // Below logic is to check 2M/4K page to make sure we donot waist memory. + // + while (Length != 0) { + PageEntry = GetPageTableEntry (&CurrentPagingContext, BaseAddress, &PageAttribute); + if (PageEntry == NULL) { + return RETURN_UNSUPPORTED; + } + PageEntryLength = PageAttributeToLength (PageAttribute); + SplitAttribute = NeedSplitPage (BaseAddress, Length, PageEntry, PageAttribute); + if (SplitAttribute == PageNone) { + ConvertPageEntryAttribute (&CurrentPagingContext, PageEntry, Attributes, PageAction, &IsEntryModified); + if (IsEntryModified) { + if (IsModified != NULL) { + *IsModified = TRUE; + } + } + // + // Convert success, move to next + // + BaseAddress += PageEntryLength; + Length -= PageEntryLength; + } else { + if (AllocatePagesFunc == NULL) { + return RETURN_UNSUPPORTED; + } + Status = SplitPage (PageEntry, PageAttribute, SplitAttribute, AllocatePagesFunc); + if (RETURN_ERROR (Status)) { + return RETURN_UNSUPPORTED; + } + if (IsSplitted != NULL) { + *IsSplitted = TRUE; + } + if (IsModified != NULL) { + *IsModified = TRUE; + } + // + // Just split current page + // Convert success in next around + // + } + } + + return RETURN_SUCCESS; +} + +/** + This function assigns the page attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + Caller should make sure BaseAddress and Length is at page boundary. + + Caller need guarentee the TPL <= TPL_NOTIFY, if there is split page request. + + @param[in] PagingContext The paging context. NULL means get page table from current CPU context. + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to set for the memory region. + @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. + NULL mean page split is unsupported. + + @retval RETURN_SUCCESS The attributes were cleared for the memory region. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. +**/ +RETURN_STATUS +EFIAPI +AssignMemoryPageAttributes ( + IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL + ) +{ + RETURN_STATUS Status; + BOOLEAN IsModified; + BOOLEAN IsSplitted; + +// DEBUG((DEBUG_INFO, "AssignMemoryPageAttributes: 0x%lx - 0x%lx (0x%lx)\n", BaseAddress, Length, Attributes)); + Status = ConvertMemoryPageAttributes (PagingContext, BaseAddress, Length, Attributes, PageActionAssign, AllocatePagesFunc, &IsSplitted, &IsModified); + if (!EFI_ERROR(Status)) { + if ((PagingContext == NULL) && IsModified) { + // + // Flush TLB as last step + // + CpuFlushTlb(); + SyncMemoryPageAttributesAp (SyncCpuFlushTlb); + } + } + + return Status; +} + +/** + Initialize the Page Table lib. +**/ +VOID +InitializePageTableLib ( + VOID + ) +{ + PAGE_TABLE_LIB_PAGING_CONTEXT CurrentPagingContext; + + GetCurrentPagingContext (&CurrentPagingContext); + DEBUG ((DEBUG_INFO, "CurrentPagingContext:\n", CurrentPagingContext.MachineType)); + DEBUG ((DEBUG_INFO, " MachineType - 0x%x\n", CurrentPagingContext.MachineType)); + DEBUG ((DEBUG_INFO, " PageTableBase - 0x%x\n", CurrentPagingContext.ContextData.X64.PageTableBase)); + DEBUG ((DEBUG_INFO, " Attributes - 0x%x\n", CurrentPagingContext.ContextData.X64.Attributes)); + + return ; +} + diff --git a/Core/UefiCpuPkg/CpuDxe/CpuPageTable.h b/Core/UefiCpuPkg/CpuDxe/CpuPageTable.h new file mode 100644 index 0000000000..eaff595b4c --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/CpuPageTable.h @@ -0,0 +1,113 @@ +/** @file + Page table management header file. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _PAGE_TABLE_LIB_H_ +#define _PAGE_TABLE_LIB_H_ + +#include + +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE BIT0 +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE BIT1 +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT BIT2 +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE BIT30 +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED BIT31 +// Other bits are reserved for future use +typedef struct { + UINT32 PageTableBase; + UINT32 Reserved; + UINT32 Attributes; +} PAGE_TABLE_LIB_PAGING_CONTEXT_IA32; + +typedef struct { + UINT64 PageTableBase; + UINT32 Attributes; +} PAGE_TABLE_LIB_PAGING_CONTEXT_X64; + +typedef union { + PAGE_TABLE_LIB_PAGING_CONTEXT_IA32 Ia32; + PAGE_TABLE_LIB_PAGING_CONTEXT_X64 X64; +} PAGE_TABLE_LIB_PAGING_CONTEXT_DATA; + +typedef struct { + // + // PE32+ Machine type for EFI images + // + // #define IMAGE_FILE_MACHINE_I386 0x014c + // #define IMAGE_FILE_MACHINE_X64 0x8664 + // + UINT16 MachineType; + PAGE_TABLE_LIB_PAGING_CONTEXT_DATA ContextData; +} PAGE_TABLE_LIB_PAGING_CONTEXT; + +/** + Allocates one or more 4KB pages for page table. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +typedef +VOID * +(EFIAPI *PAGE_TABLE_LIB_ALLOCATE_PAGES) ( + IN UINTN Pages + ); + +/** + This function assigns the page attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + Caller should make sure BaseAddress and Length is at page boundary. + + Caller need guarentee the TPL <= TPL_NOTIFY, if there is split page request. + + @param PagingContext The paging context. NULL means get page table from current CPU context. + @param BaseAddress The physical address that is the start address of a memory region. + @param Length The size in bytes of the memory region. + @param Attributes The bit mask of attributes to set for the memory region. + @param AllocatePagesFunc If page split is needed, this function is used to allocate more pages. + NULL mean page split is unsupported. + + @retval RETURN_SUCCESS The attributes were cleared for the memory region. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. +**/ +RETURN_STATUS +EFIAPI +AssignMemoryPageAttributes ( + IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL + ); + +/** + Initialize the Page Table lib. +**/ +VOID +InitializePageTableLib ( + VOID + ); + +#endif diff --git a/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S new file mode 100644 index 0000000000..e034bc2e2e --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S @@ -0,0 +1,57 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* CpuAsm.S +#* +#* Abstract: +#* +#------------------------------------------------------------------------------ + + +#.MMX +#.XMM + +#------------------------------------------------------------------------------ +# VOID +# SetCodeSelector ( +# UINT16 Selector +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(SetCodeSelector) +ASM_PFX(SetCodeSelector): + movl 4(%esp), %ecx + subl $0x10, %esp + leal setCodeSelectorLongJump, %eax + movl %eax, (%esp) + movw %cx, 4(%esp) + .byte 0xFF, 0x2C, 0x24 # jmp *(%esp) note:(FWORD jmp) +setCodeSelectorLongJump: + addl $0x10, %esp + ret + +#------------------------------------------------------------------------------ +# VOID +# SetDataSelectors ( +# UINT16 Selector +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(SetDataSelectors) +ASM_PFX(SetDataSelectors): + movl 4(%esp), %ecx + movw %cx, %ss + movw %cx, %ds + movw %cx, %es + movw %cx, %fs + movw %cx, %gs + ret + +#END + diff --git a/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm new file mode 100644 index 0000000000..7f8f0d6f3a --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm @@ -0,0 +1,58 @@ + TITLE CpuAsm.asm: +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* CpuAsm.asm +;* +;* Abstract: +;* +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; SetCodeSelector ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +SetCodeSelector PROC PUBLIC + mov ecx, [esp+4] + sub esp, 0x10 + lea eax, setCodeSelectorLongJump + mov [esp], eax + mov [esp+4], cx + jmp fword ptr [esp] +setCodeSelectorLongJump: + add esp, 0x10 + ret +SetCodeSelector ENDP + +;------------------------------------------------------------------------------ +; VOID +; SetDataSelectors ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +SetDataSelectors PROC PUBLIC + mov ecx, [esp+4] + mov ss, cx + mov ds, cx + mov es, cx + mov fs, cx + mov gs, cx + ret +SetDataSelectors ENDP + + +END diff --git a/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm new file mode 100644 index 0000000000..c67ddfb010 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm @@ -0,0 +1,53 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2016, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* CpuAsm.nasm +;* +;* Abstract: +;* +;------------------------------------------------------------------------------ + + SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; SetCodeSelector ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(SetCodeSelector) +ASM_PFX(SetCodeSelector): + mov ecx, [esp+4] + sub esp, 0x10 + lea eax, [setCodeSelectorLongJump] + mov [esp], eax + mov [esp+4], cx + jmp dword far [esp] +setCodeSelectorLongJump: + add esp, 0x10 + ret + +;------------------------------------------------------------------------------ +; VOID +; SetDataSelectors ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(SetDataSelectors) +ASM_PFX(SetDataSelectors): + mov ecx, [esp+4] +o16 mov ss, cx +o16 mov ds, cx +o16 mov es, cx +o16 mov fs, cx +o16 mov gs, cx + ret + diff --git a/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.S b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.S new file mode 100644 index 0000000000..e82cadf369 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.S @@ -0,0 +1,60 @@ +# TITLE CpuAsm.S: + +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* CpuAsm.S +#* +#* Abstract: +#* +#------------------------------------------------------------------------------ + + +#text SEGMENT + + +#------------------------------------------------------------------------------ +# VOID +# SetCodeSelector ( +# UINT16 Selector +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(SetCodeSelector) +ASM_PFX(SetCodeSelector): + subq $0x10, %rsp + leaq L_setCodeSelectorLongJump(%rip), %rax + movq %rax, (%rsp) + movw %cx, 4(%rsp) + .byte 0xFF, 0x2C, 0x24 # jmp (%rsp) note:fword jmp +L_setCodeSelectorLongJump: + addq $0x10, %rsp + ret + +#------------------------------------------------------------------------------ +# VOID +# SetDataSelectors ( +# UINT16 Selector +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(SetDataSelectors) +ASM_PFX(SetDataSelectors): + movw %cx, %ss + movw %cx, %ds + movw %cx, %es + movw %cx, %fs + movw %cx, %gs + ret + +#text ENDS + +#END + + diff --git a/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm new file mode 100644 index 0000000000..c71b06a81e --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm @@ -0,0 +1,54 @@ + TITLE CpuAsm.asm: +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* CpuAsm.asm +;* +;* Abstract: +;* +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; SetCodeSelector ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +SetCodeSelector PROC PUBLIC + sub rsp, 0x10 + lea rax, setCodeSelectorLongJump + mov [rsp], rax + mov [rsp+4], cx + jmp fword ptr [rsp] +setCodeSelectorLongJump: + add rsp, 0x10 + ret +SetCodeSelector ENDP + +;------------------------------------------------------------------------------ +; VOID +; SetDataSelectors ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +SetDataSelectors PROC PUBLIC + mov ss, cx + mov ds, cx + mov es, cx + mov fs, cx + mov gs, cx + ret +SetDataSelectors ENDP + +END + diff --git a/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm new file mode 100644 index 0000000000..77ecfb3404 --- /dev/null +++ b/Core/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm @@ -0,0 +1,52 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2016, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* CpuAsm.nasm +;* +;* Abstract: +;* +;------------------------------------------------------------------------------ + + DEFAULT REL + SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; SetCodeSelector ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(SetCodeSelector) +ASM_PFX(SetCodeSelector): + sub rsp, 0x10 + lea rax, [setCodeSelectorLongJump] + mov [rsp], rax + mov [rsp+4], cx + jmp dword far [rsp] +setCodeSelectorLongJump: + add rsp, 0x10 + ret + +;------------------------------------------------------------------------------ +; VOID +; SetDataSelectors ( +; UINT16 Selector +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(SetDataSelectors) +ASM_PFX(SetDataSelectors): +o16 mov ss, cx +o16 mov ds, cx +o16 mov es, cx +o16 mov fs, cx +o16 mov gs, cx + ret + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c new file mode 100644 index 0000000000..b0b186d36d --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c @@ -0,0 +1,122 @@ +/** @file + CPU Features DXE driver to initialize CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +/** + Worker function to perform CPU feature initialization. + +**/ +VOID +CpuFeaturesInitializeWorker ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done Protocol + // + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs. + + @param[in] Event The Event that is being processed, not used. + @param[in] Context Event Context, not used. +**/ +VOID +EFIAPI +SmmConfigurationEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration; + + // + // Make sure this notification is for this handler + // + Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration); + if (EFI_ERROR (Status)) { + return; + } + + CpuFeaturesInitializeWorker (); +} + +/** + CPU Features driver entry point function. + + If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one + SMM Configuration Protocol notify function to perform CPU features + initialization. Otherwise, it will perform CPU features initialization + directly. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Registration; + + if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { + // + // Install notification callback on SMM Configuration Protocol + // + EfiCreateProtocolNotifyEvent ( + &gEfiSmmConfigurationProtocolGuid, + TPL_CALLBACK, + SmmConfigurationEventNotify, + NULL, + &Registration + ); + } else { + CpuFeaturesInitializeWorker (); + } + + return EFI_SUCCESS; +} + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf new file mode 100644 index 0000000000..175e8a9797 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf @@ -0,0 +1,53 @@ +## @file +# CPU Features DXE driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuFeaturesDxe + MODULE_UNI_FILE = CpuFeaturesDxe.uni + FILE_GUID = 63EB1B62-10C9-4693-88AC-AE0999EA87F8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + + ENTRY_POINT = CpuFeaturesDxeInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + RegisterCpuFeaturesLib + +[Sources] + CpuFeaturesDxe.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # protocol GUID installed + +[Protocols] + gEfiSmmConfigurationProtocolGuid ## NOTIFY + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesDxeExtra.uni diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni new file mode 100644 index 0000000000..c42e4daf43 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Features DXE driver. +// +// CPU Features DXE driver. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Features DXE driver to initialize CPU features." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Features DXE driver to initialize CPU features." + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni new file mode 100644 index 0000000000..39a943e5a9 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuFeaturesDxe Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Features DXE Driver" + + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c new file mode 100644 index 0000000000..b052d554a9 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c @@ -0,0 +1,75 @@ +/** @file + CPU Features PEIM driver to initialize CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include + +#include + +EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEdkiiCpuFeaturesInitDoneGuid, + NULL +}; + +/** + CPU Features driver entry point function. + + It will perform CPU features initialization, except for + PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesPeimInitialize ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + if (BootMode == BOOT_ON_S3_RESUME && + !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) { + // + // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE + // on S3 boot mode + // + return EFI_SUCCESS; + } + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done PPI + // + Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf new file mode 100644 index 0000000000..dd4b388c9a --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf @@ -0,0 +1,49 @@ +## @file +# CPU Features PEIM driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuFeaturesPei + MODULE_UNI_FILE = CpuFeaturesPei.uni + FILE_GUID = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + + ENTRY_POINT = CpuFeaturesPeimInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PeimEntryPoint + PeiServicesLib + RegisterCpuFeaturesLib + +[Sources] + CpuFeaturesPei.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # PPI GUID installed + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesPeiExtra.uni diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni new file mode 100644 index 0000000000..b03754aee6 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Features PEIM driver. +// +// CPU Features PEIM driver. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Features PEIM driver to initialize CPU features." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Features PEIM driver to initialize CPU features." + diff --git a/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni new file mode 100644 index 0000000000..43dbe96197 --- /dev/null +++ b/Core/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuFeaturesPei Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Features PEIM Driver" + + diff --git a/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c new file mode 100644 index 0000000000..d19349d4b0 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c @@ -0,0 +1,588 @@ +/** @file + Produces the CPU I/O 2 Protocol. + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuIo2Dxe.h" + +// +// Handle for the CPU I/O 2 Protocol +// +EFI_HANDLE mHandle = NULL; + +// +// CPU I/O 2 Protocol instance +// +EFI_CPU_IO2_PROTOCOL mCpuIo2 = { + { + CpuMemoryServiceRead, + CpuMemoryServiceWrite + }, + { + CpuIoServiceRead, + CpuIoServiceWrite + } +}; + +// +// Lookup table for increment values based on transfer widths +// +UINT8 mInStride[] = { + 1, // EfiCpuIoWidthUint8 + 2, // EfiCpuIoWidthUint16 + 4, // EfiCpuIoWidthUint32 + 8, // EfiCpuIoWidthUint64 + 0, // EfiCpuIoWidthFifoUint8 + 0, // EfiCpuIoWidthFifoUint16 + 0, // EfiCpuIoWidthFifoUint32 + 0, // EfiCpuIoWidthFifoUint64 + 1, // EfiCpuIoWidthFillUint8 + 2, // EfiCpuIoWidthFillUint16 + 4, // EfiCpuIoWidthFillUint32 + 8 // EfiCpuIoWidthFillUint64 +}; + +// +// Lookup table for increment values based on transfer widths +// +UINT8 mOutStride[] = { + 1, // EfiCpuIoWidthUint8 + 2, // EfiCpuIoWidthUint16 + 4, // EfiCpuIoWidthUint32 + 8, // EfiCpuIoWidthUint64 + 1, // EfiCpuIoWidthFifoUint8 + 2, // EfiCpuIoWidthFifoUint16 + 4, // EfiCpuIoWidthFifoUint32 + 8, // EfiCpuIoWidthFifoUint64 + 0, // EfiCpuIoWidthFillUint8 + 0, // EfiCpuIoWidthFillUint16 + 0, // EfiCpuIoWidthFillUint32 + 0 // EfiCpuIoWidthFillUint64 +}; + +/** + Check parameters to a CPU I/O 2 Protocol service request. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The parameters for this request pass the checks. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +CpuIoCheckParameter ( + IN BOOLEAN MmioOperation, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + UINT64 MaxCount; + UINT64 Limit; + + // + // Check to see if Buffer is NULL + // + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Width is in the valid range + // + if ((UINT32)Width >= EfiCpuIoWidthMaximum) { + return EFI_INVALID_PARAMETER; + } + + // + // For FIFO type, the target address won't increase during the access, + // so treat Count as 1 + // + if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) { + Count = 1; + } + + // + // Check to see if Width is in the valid range for I/O Port operations + // + Width = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + if (!MmioOperation && (Width == EfiCpuIoWidthUint64)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Address is aligned + // + if ((Address & ((UINT64)mInStride[Width] - 1)) != 0) { + return EFI_UNSUPPORTED; + } + + // + // Check to see if any address associated with this transfer exceeds the maximum + // allowed address. The maximum address implied by the parameters passed in is + // Address + Size * Count. If the following condition is met, then the transfer + // is not supported. + // + // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 + // + // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count + // can also be the maximum integer value supported by the CPU, this range + // check must be adjusted to avoid all oveflow conditions. + // + // The following form of the range check is equivalent but assumes that + // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). + // + Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); + if (Count == 0) { + if (Address > Limit) { + return EFI_UNSUPPORTED; + } + } else { + MaxCount = RShiftU64 (Limit, Width); + if (MaxCount < (Count - 1)) { + return EFI_UNSUPPORTED; + } + if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { + return EFI_UNSUPPORTED; + } + } + + // + // Check to see if Buffer is aligned + // (IA-32 allows UINT64 and INT64 data types to be 32-bit aligned.) + // + if (((UINTN)Buffer & ((MIN (sizeof (UINTN), mInStride[Width]) - 1))) != 0) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Reads memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + *Uint8Buffer = MmioRead8 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint64) { + *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); + } + } + return EFI_SUCCESS; +} + +/** + Writes memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + MmioWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint64) { + MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); + } + } + return EFI_SUCCESS; +} + +/** + Reads I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + + // + // Fifo operations supported for (mInStride[Width] == 0) + // + if (InStride == 0) { + switch (OperationWidth) { + case EfiCpuIoWidthUint8: + IoReadFifo8 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiCpuIoWidthUint16: + IoReadFifo16 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiCpuIoWidthUint32: + IoReadFifo32 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + default: + // + // The CpuIoCheckParameter call above will ensure that this + // path is not taken. + // + ASSERT (FALSE); + break; + } + } + + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + *Uint8Buffer = IoRead8 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); + } + } + + return EFI_SUCCESS; +} + +/** + Write I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; + UINT8 *Uint8Buffer; + + // + // Make sure the parameters are valid + // + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); + + // + // Fifo operations supported for (mInStride[Width] == 0) + // + if (InStride == 0) { + switch (OperationWidth) { + case EfiCpuIoWidthUint8: + IoWriteFifo8 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiCpuIoWidthUint16: + IoWriteFifo16 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiCpuIoWidthUint32: + IoWriteFifo32 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + default: + // + // The CpuIoCheckParameter call above will ensure that this + // path is not taken. + // + ASSERT (FALSE); + break; + } + } + + for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiCpuIoWidthUint8) { + IoWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiCpuIoWidthUint16) { + IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (OperationWidth == EfiCpuIoWidthUint32) { + IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } + } + + return EFI_SUCCESS; +} + +/** + The user Entry Point for module CpuIo2Dxe. The user code starts with this function. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +CpuIo2Initialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIo2ProtocolGuid); + Status = gBS->InstallMultipleProtocolInterfaces ( + &mHandle, + &gEfiCpuIo2ProtocolGuid, &mCpuIo2, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h new file mode 100644 index 0000000000..7d00da16f4 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h @@ -0,0 +1,225 @@ +/** @file + Internal include file for the CPU I/O 2 Protocol. + +Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_IO2_DXE_H_ +#define _CPU_IO2_DXE_H_ + +#include + +#include + +#include +#include +#include +#include + +#define MAX_IO_PORT_ADDRESS 0xFFFF + +/** + Reads memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +/** + Reads I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[out] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Write I/O registers. + + The I/O operations are carried out exactly as requested. The caller is responsible + for satisfying any alignment and I/O width restrictions that a PI System on a + platform might require. For example on some platforms, width requests of + EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will + be handled by the driver. + + If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, + or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for + each of the Count operations that is performed. + + If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times on the same Address. + + If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is + incremented for each of the Count operations that is performed. The read or + write operation is performed Count times from the first element of Buffer. + + @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O or Memory operation. + @param[in] Address The base address of the I/O operation. + @param[in] Count The number of I/O operations to perform. The number of + bytes moved is Width size * Count, starting at Address. + @param[in] Buffer For read operations, the destination buffer to store the results. + For write operations, the source buffer from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the PI system. + @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this PI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN EFI_CPU_IO2_PROTOCOL *This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +#endif diff --git a/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf new file mode 100644 index 0000000000..55036622ca --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf @@ -0,0 +1,53 @@ +## @file +# Produces the CPU I/O 2 Protocol by using the services of the I/O Library. +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuIo2Dxe + MODULE_UNI_FILE = CpuIo2Dxe.uni + FILE_GUID = A19B1FE7-C1BC-49F8-875F-54A5D542443F + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = CpuIo2Initialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + CpuIo2Dxe.c + CpuIo2Dxe.h + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + BaseLib + DebugLib + IoLib + UefiBootServicesTableLib + +[Protocols] + gEfiCpuIo2ProtocolGuid ## PRODUCES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuIo2DxeExtra.uni diff --git a/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni new file mode 100644 index 0000000000..59456fb3e5 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni @@ -0,0 +1,22 @@ +// /** @file +// Produces the CPU I/O 2 Protocol by using the services of the I/O Library. +// +// Produces the CPU I/O 2 Protocol by using the services of the I/O Library. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Produces the CPU I/O 2 Protocol by using the services of the I/O Library" + +#string STR_MODULE_DESCRIPTION #language en-US "Produces the CPU I/O 2 Protocol by using the services of the I/O Library." + diff --git a/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni new file mode 100644 index 0000000000..655da485df --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuIo2Dxe Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU I/O v2 DXE Driver" + + diff --git a/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c new file mode 100644 index 0000000000..20b8350fe4 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c @@ -0,0 +1,413 @@ +/** @file + Produces the SMM CPU I/O Protocol. + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuIo2Smm.h" + +// +// Handle for the SMM CPU I/O Protocol +// +EFI_HANDLE mHandle = NULL; + +// +// SMM CPU I/O Protocol instance +// +EFI_SMM_CPU_IO2_PROTOCOL mSmmCpuIo2 = { + { + CpuMemoryServiceRead, + CpuMemoryServiceWrite + }, + { + CpuIoServiceRead, + CpuIoServiceWrite + } +}; + +// +// Lookup table for increment values based on transfer widths +// +UINT8 mStride[] = { + 1, // SMM_IO_UINT8 + 2, // SMM_IO_UINT16 + 4, // SMM_IO_UINT32 + 8 // SMM_IO_UINT64 +}; + +/** + Check parameters to a SMM CPU I/O Protocol service request. + + @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + +**/ +EFI_STATUS +CpuIoCheckParameter ( + IN BOOLEAN MmioOperation, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + UINT64 MaxCount; + UINT64 Limit; + + // + // Check to see if Buffer is NULL + // + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Width is in the valid range + // + if ((UINT32)Width > SMM_IO_UINT64) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Width is in the valid range for I/O Port operations + // + if (!MmioOperation && (Width == SMM_IO_UINT64)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if any address associated with this transfer exceeds the maximum + // allowed address. The maximum address implied by the parameters passed in is + // Address + Size * Count. If the following condition is met, then the transfer + // is not supported. + // + // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 + // + // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count + // can also be the maximum integer value supported by the CPU, this range + // check must be adjusted to avoid all overflow conditions. + // + // The following form of the range check is equivalent but assumes that + // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). + // + Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); + if (Count == 0) { + if (Address > Limit) { + return EFI_UNSUPPORTED; + } + } else { + MaxCount = RShiftU64 (Limit, Width); + if (MaxCount < (Count - 1)) { + return EFI_UNSUPPORTED; + } + if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { + return EFI_UNSUPPORTED; + } + } + + // + // Check to see if Address is aligned + // + if ((Address & ((UINT64)mStride[Width] - 1)) != 0) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Reads memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[out] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 Stride; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + Stride = mStride[Width]; + for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { + if (Width == SMM_IO_UINT8) { + *Uint8Buffer = MmioRead8 ((UINTN)Address); + } else if (Width == SMM_IO_UINT16) { + *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); + } else if (Width == SMM_IO_UINT32) { + *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); + } else if (Width == SMM_IO_UINT64) { + *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); + } + } + return EFI_SUCCESS; +} + +/** + Writes memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 Stride; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + Stride = mStride[Width]; + for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { + if (Width == SMM_IO_UINT8) { + MmioWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (Width == SMM_IO_UINT16) { + MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (Width == SMM_IO_UINT32) { + MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } else if (Width == SMM_IO_UINT64) { + MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); + } + } + return EFI_SUCCESS; +} + +/** + Reads I/O registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[out] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 Stride; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + Stride = mStride[Width]; + for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { + if (Width == SMM_IO_UINT8) { + *Uint8Buffer = IoRead8 ((UINTN)Address); + } else if (Width == SMM_IO_UINT16) { + *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); + } else if (Width == SMM_IO_UINT32) { + *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); + } + } + + return EFI_SUCCESS; +} + +/** + Write I/O registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 Stride; + UINT8 *Uint8Buffer; + + // + // Make sure the parameters are valid + // + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + Stride = mStride[Width]; + for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { + if (Width == SMM_IO_UINT8) { + IoWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (Width == SMM_IO_UINT16) { + IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else if (Width == SMM_IO_UINT32) { + IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } + } + + return EFI_SUCCESS; +} + +/** + The module Entry Point SmmCpuIoProtocol driver + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +SmmCpuIo2Initialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Copy the SMM CPU I/O Protocol instance into the System Management System Table + // + CopyMem (&gSmst->SmmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); + + // + // Install the SMM CPU I/O Protocol into the SMM protocol database + // + Status = gSmst->SmmInstallProtocolInterface ( + &mHandle, + &gEfiSmmCpuIo2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mSmmCpuIo2 + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h new file mode 100644 index 0000000000..5a092594d7 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h @@ -0,0 +1,162 @@ +/** @file + Internal include file for the SMM CPU I/O Protocol. + +Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_IO2_SMM_H_ +#define _CPU_IO2_SMM_H_ + +#include + +#include + +#include +#include +#include +#include +#include + +#define MAX_IO_PORT_ADDRESS 0xFFFF + +/** + Reads memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[out] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes memory-mapped registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +/** + Reads I/O registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[out] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Write I/O registers. + + The I/O operations are carried out exactly as requested. The caller is + responsible for any alignment and I/O width issues that the bus, device, + platform, or type of I/O might require. + + @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. + @param[in] Width Signifies the width of the I/O operations. + @param[in] Address The base address of the I/O operations. The caller is + responsible for aligning the Address if required. + @param[in] Count The number of I/O operations to perform. + @param[in] Buffer For read operations, the destination buffer to store + the results. For write operations, the source buffer + from which to write data. + + @retval EFI_SUCCESS The data was read from or written to the device. + @retval EFI_UNSUPPORTED The Address is not valid for this system. + @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a + lack of resources + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +#endif diff --git a/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf new file mode 100644 index 0000000000..d7c98f67c0 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf @@ -0,0 +1,52 @@ +## @file +# Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. +# +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuIo2Smm + MODULE_UNI_FILE = CpuIo2Smm.uni + FILE_GUID = A47EE2D8-F60E-42fd-8E58-7BD65EE4C29B + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x0001000A + ENTRY_POINT = SmmCpuIo2Initialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + CpuIo2Smm.c + CpuIo2Smm.h + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + BaseLib + DebugLib + IoLib + SmmServicesTableLib + BaseMemoryLib + +[Protocols] + gEfiSmmCpuIo2ProtocolGuid ## PRODUCES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuIo2SmmExtra.uni diff --git a/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni new file mode 100644 index 0000000000..c3a212b1e7 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni @@ -0,0 +1,21 @@ +// /** @file +// Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. +// +// Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library" + +#string STR_MODULE_DESCRIPTION #language en-US "Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library." + diff --git a/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni new file mode 100644 index 0000000000..b1b82b03b7 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni @@ -0,0 +1,19 @@ +// /** @file +// CpuIo2Smm Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU I/O v2 SMM Driver" + + diff --git a/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.c b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.c new file mode 100644 index 0000000000..b6d538b166 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.c @@ -0,0 +1,916 @@ +/** @file + Produces the CPU I/O PPI. + +Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuIoPei.h" + +// +// Instance of CPU I/O PPI +// +EFI_PEI_CPU_IO_PPI gCpuIoPpi = { + { + CpuMemoryServiceRead, + CpuMemoryServiceWrite + }, + { + CpuIoServiceRead, + CpuIoServiceWrite + }, + CpuIoRead8, + CpuIoRead16, + CpuIoRead32, + CpuIoRead64, + CpuIoWrite8, + CpuIoWrite16, + CpuIoWrite32, + CpuIoWrite64, + CpuMemRead8, + CpuMemRead16, + CpuMemRead32, + CpuMemRead64, + CpuMemWrite8, + CpuMemWrite16, + CpuMemWrite32, + CpuMemWrite64 +}; + +// +// PPI Descriptor used to install the CPU I/O PPI +// +EFI_PEI_PPI_DESCRIPTOR gPpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiCpuIoPpiInstalledGuid, + NULL +}; + +// +// Lookup table for increment values based on transfer widths +// +UINT8 mInStride[] = { + 1, // EfiPeiCpuIoWidthUint8 + 2, // EfiPeiCpuIoWidthUint16 + 4, // EfiPeiCpuIoWidthUint32 + 8, // EfiPeiCpuIoWidthUint64 + 0, // EfiPeiCpuIoWidthFifoUint8 + 0, // EfiPeiCpuIoWidthFifoUint16 + 0, // EfiPeiCpuIoWidthFifoUint32 + 0, // EfiPeiCpuIoWidthFifoUint64 + 1, // EfiPeiCpuIoWidthFillUint8 + 2, // EfiPeiCpuIoWidthFillUint16 + 4, // EfiPeiCpuIoWidthFillUint32 + 8 // EfiPeiCpuIoWidthFillUint64 +}; + +// +// Lookup table for increment values based on transfer widths +// +UINT8 mOutStride[] = { + 1, // EfiPeiCpuIoWidthUint8 + 2, // EfiPeiCpuIoWidthUint16 + 4, // EfiPeiCpuIoWidthUint32 + 8, // EfiPeiCpuIoWidthUint64 + 1, // EfiPeiCpuIoWidthFifoUint8 + 2, // EfiPeiCpuIoWidthFifoUint16 + 4, // EfiPeiCpuIoWidthFifoUint32 + 8, // EfiPeiCpuIoWidthFifoUint64 + 0, // EfiPeiCpuIoWidthFillUint8 + 0, // EfiPeiCpuIoWidthFillUint16 + 0, // EfiPeiCpuIoWidthFillUint32 + 0 // EfiPeiCpuIoWidthFillUint64 +}; + +/** + Check parameters to a CPU I/O PPI service request. + + @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[in] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The parameters for this request pass the checks. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +CpuIoCheckParameter ( + IN BOOLEAN MmioOperation, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + UINT64 MaxCount; + UINT64 Limit; + + // + // Check to see if Buffer is NULL + // + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if Width is in the valid range + // + if ((UINT32)Width >= EfiPeiCpuIoWidthMaximum) { + return EFI_INVALID_PARAMETER; + } + + // + // For FIFO type, the target address won't increase during the access, + // so treat Count as 1 + // + if (Width >= EfiPeiCpuIoWidthFifoUint8 && Width <= EfiPeiCpuIoWidthFifoUint64) { + Count = 1; + } + + // + // Check to see if Width is in the valid range for I/O Port operations + // + Width = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); + if (!MmioOperation && (Width == EfiPeiCpuIoWidthUint64)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if any address associated with this transfer exceeds the maximum + // allowed address. The maximum address implied by the parameters passed in is + // Address + Size * Count. If the following condition is met, then the transfer + // is not supported. + // + // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 + // + // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count + // can also be the maximum integer value supported by the CPU, this range + // check must be adjusted to avoid all overflow conditions. + // + // The following form of the range check is equivalent but assumes that + // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). + // + Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); + if (Count == 0) { + if (Address > Limit) { + return EFI_UNSUPPORTED; + } + } else { + MaxCount = RShiftU64 (Limit, Width); + if (MaxCount < (Count - 1)) { + return EFI_UNSUPPORTED; + } + if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { + return EFI_UNSUPPORTED; + } + } + + return EFI_SUCCESS; +} + +/** + Reads memory-mapped registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[out] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; + BOOLEAN Aligned; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); + Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiPeiCpuIoWidthUint8) { + *Uint8Buffer = MmioRead8 ((UINTN)Address); + } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { + if (Aligned) { + *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); + } else { + WriteUnaligned16 ((UINT16 *)Uint8Buffer, MmioRead16 ((UINTN)Address)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { + if (Aligned) { + *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); + } else { + WriteUnaligned32 ((UINT32 *)Uint8Buffer, MmioRead32 ((UINTN)Address)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint64) { + if (Aligned) { + *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); + } else { + WriteUnaligned64 ((UINT64 *)Uint8Buffer, MmioRead64 ((UINTN)Address)); + } + } + } + return EFI_SUCCESS; +} + +/** + Writes memory-mapped registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[in] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; + BOOLEAN Aligned; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); + Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiPeiCpuIoWidthUint8) { + MmioWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { + if (Aligned) { + MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else { + MmioWrite16 ((UINTN)Address, ReadUnaligned16 ((UINT16 *)Uint8Buffer)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { + if (Aligned) { + MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } else { + MmioWrite32 ((UINTN)Address, ReadUnaligned32 ((UINT32 *)Uint8Buffer)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint64) { + if (Aligned) { + MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); + } else { + MmioWrite64 ((UINTN)Address, ReadUnaligned64 ((UINT64 *)Uint8Buffer)); + } + } + } + return EFI_SUCCESS; +} + +/** + Reads I/O registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[out] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; + BOOLEAN Aligned; + UINT8 *Uint8Buffer; + + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); + + // + // Fifo operations supported for (mInStride[Width] == 0) + // + if (InStride == 0) { + switch (OperationWidth) { + case EfiPeiCpuIoWidthUint8: + IoReadFifo8 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiPeiCpuIoWidthUint16: + IoReadFifo16 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiPeiCpuIoWidthUint32: + IoReadFifo32 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + default: + // + // The CpuIoCheckParameter call above will ensure that this + // path is not taken. + // + ASSERT (FALSE); + break; + } + } + + Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); + for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiPeiCpuIoWidthUint8) { + *Uint8Buffer = IoRead8 ((UINTN)Address); + } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { + if (Aligned) { + *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); + } else { + WriteUnaligned16 ((UINT16 *)Uint8Buffer, IoRead16 ((UINTN)Address)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { + if (Aligned) { + *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); + } else { + WriteUnaligned32 ((UINT32 *)Uint8Buffer, IoRead32 ((UINTN)Address)); + } + } + } + + return EFI_SUCCESS; +} + +/** + Write I/O registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[in] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 InStride; + UINT8 OutStride; + EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; + BOOLEAN Aligned; + UINT8 *Uint8Buffer; + + // + // Make sure the parameters are valid + // + Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Select loop based on the width of the transfer + // + InStride = mInStride[Width]; + OutStride = mOutStride[Width]; + OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); + + // + // Fifo operations supported for (mInStride[Width] == 0) + // + if (InStride == 0) { + switch (OperationWidth) { + case EfiPeiCpuIoWidthUint8: + IoWriteFifo8 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiPeiCpuIoWidthUint16: + IoWriteFifo16 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + case EfiPeiCpuIoWidthUint32: + IoWriteFifo32 ((UINTN)Address, Count, Buffer); + return EFI_SUCCESS; + default: + // + // The CpuIoCheckParameter call above will ensure that this + // path is not taken. + // + ASSERT (FALSE); + break; + } + } + + Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); + for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { + if (OperationWidth == EfiPeiCpuIoWidthUint8) { + IoWrite8 ((UINTN)Address, *Uint8Buffer); + } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { + if (Aligned) { + IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); + } else { + IoWrite16 ((UINTN)Address, ReadUnaligned16 ((UINT16 *)Uint8Buffer)); + } + } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { + if (Aligned) { + IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); + } else { + IoWrite32 ((UINTN)Address, ReadUnaligned32 ((UINT32 *)Uint8Buffer)); + } + } + } + + return EFI_SUCCESS; +} + +/** + 8-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return An 8-bit value returned from the I/O space. +**/ +UINT8 +EFIAPI +CpuIoRead8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return IoRead8 ((UINTN)Address); +} + +/** + 16-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 16-bit value returned from the I/O space. + +**/ +UINT16 +EFIAPI +CpuIoRead16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return IoRead16 ((UINTN)Address); +} + +/** + 32-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 32-bit value returned from the I/O space. + +**/ +UINT32 +EFIAPI +CpuIoRead32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return IoRead32 ((UINTN)Address); +} + +/** + 64-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 64-bit value returned from the I/O space. + +**/ +UINT64 +EFIAPI +CpuIoRead64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return IoRead64 ((UINTN)Address); +} + +/** + 8-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT8 Data + ) +{ + IoWrite8 ((UINTN)Address, Data); +} + +/** + 16-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT16 Data + ) +{ + IoWrite16 ((UINTN)Address, Data); +} + +/** + 32-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT32 Data + ) +{ + IoWrite32 ((UINTN)Address, Data); +} + +/** + 64-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT64 Data + ) +{ + IoWrite64 ((UINTN)Address, Data); +} + +/** + 8-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return An 8-bit value returned from the memory space. + +**/ +UINT8 +EFIAPI +CpuMemRead8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return MmioRead8 ((UINTN)Address); +} + +/** + 16-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 16-bit value returned from the memory space. + +**/ +UINT16 +EFIAPI +CpuMemRead16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return MmioRead16 ((UINTN)Address); +} + +/** + 32-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 32-bit value returned from the memory space. + +**/ +UINT32 +EFIAPI +CpuMemRead32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return MmioRead32 ((UINTN)Address); +} + +/** + 64-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 64-bit value returned from the memory space. + +**/ +UINT64 +EFIAPI +CpuMemRead64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ) +{ + return MmioRead64 ((UINTN)Address); +} + +/** + 8-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT8 Data + ) +{ + MmioWrite8 ((UINTN)Address, Data); +} + +/** + 16-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT16 Data + ) +{ + MmioWrite16 ((UINTN)Address, Data); +} + +/** + 32-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT32 Data + ) +{ + MmioWrite32 ((UINTN)Address, Data); +} + +/** + 64-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT64 Data + ) +{ + MmioWrite64 ((UINTN)Address, Data); +} + +/** + The Entry point of the CPU I/O PEIM + + This function is the Entry point of the CPU I/O PEIM which installs CpuIoPpi. + + @param[in] FileHandle Pointer to image file handle. + @param[in] PeiServices Pointer to PEI Services Table + + @retval EFI_SUCCESS CPU I/O PPI successfully installed + +**/ +EFI_STATUS +EFIAPI +CpuIoInitialize ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + + // + // Register so it will be automatically shadowed to memory + // + Status = PeiServicesRegisterForShadow (FileHandle); + + // + // Make CpuIo pointer in PeiService table point to gCpuIoPpi + // + (*((EFI_PEI_SERVICES **)PeiServices))->CpuIo = &gCpuIoPpi; + + if (Status == EFI_ALREADY_STARTED) { + // + // Shadow completed and running from memory + // + DEBUG ((EFI_D_INFO, "CpuIO PPI has been loaded into memory. Reinstalled PPI=0x%x\n", &gCpuIoPpi)); + } else { + Status = PeiServicesInstallPpi (&gPpiList); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.h b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.h new file mode 100644 index 0000000000..052f0e3d0e --- /dev/null +++ b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.h @@ -0,0 +1,448 @@ +/** @file + Internal include file for the CPU I/O PPI. + +Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_IO2_PEI_H_ +#define _CPU_IO2_PEI_H_ + +#include + +#include + +#include +#include +#include +#include + +#define MAX_IO_PORT_ADDRESS 0xFFFF + +/** + Reads memory-mapped registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[out] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceRead ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Writes memory-mapped registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[in] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuMemoryServiceWrite ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +/** + Reads I/O registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[out] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceRead ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + OUT VOID *Buffer + ); + +/** + Write I/O registers. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Width The width of the access. Enumerated in bytes. + @param[in] Address The physical address of the access. + @param[in] Count The number of accesses to perform. + @param[in] Buffer A pointer to the buffer of data. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + @retval EFI_UNSUPPORTED The address range specified by Address, Width, + and Count is not valid for this EFI system. + +**/ +EFI_STATUS +EFIAPI +CpuIoServiceWrite ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN EFI_PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ); + +/** + 8-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return An 8-bit value returned from the I/O space. +**/ +UINT8 +EFIAPI +CpuIoRead8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 16-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 16-bit value returned from the I/O space. + +**/ +UINT16 +EFIAPI +CpuIoRead16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 32-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 32-bit value returned from the I/O space. + +**/ +UINT32 +EFIAPI +CpuIoRead32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 64-bit I/O read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 64-bit value returned from the I/O space. + +**/ +UINT64 +EFIAPI +CpuIoRead64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 8-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT8 Data + ); + +/** + 16-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT16 Data + ); + +/** + 32-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT32 Data + ); + +/** + 64-bit I/O write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuIoWrite64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT64 Data + ); + +/** + 8-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return An 8-bit value returned from the memory space. + +**/ +UINT8 +EFIAPI +CpuMemRead8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 16-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 16-bit value returned from the memory space. + +**/ +UINT16 +EFIAPI +CpuMemRead16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 32-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 32-bit value returned from the memory space. + +**/ +UINT32 +EFIAPI +CpuMemRead32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 64-bit memory read operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + + @return A 64-bit value returned from the memory space. + +**/ +UINT64 +EFIAPI +CpuMemRead64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address + ); + +/** + 8-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite8 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT8 Data + ); + +/** + 16-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite16 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT16 Data + ); + +/** + 32-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite32 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT32 Data + ); + +/** + 64-bit memory write operations. + + @param[in] PeiServices An indirect pointer to the PEI Services Table published + by the PEI Foundation. + @param[in] This Pointer to local data for the interface. + @param[in] Address The physical address of the access. + @param[in] Data The data to write. + +**/ +VOID +EFIAPI +CpuMemWrite64 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_CPU_IO_PPI *This, + IN UINT64 Address, + IN UINT64 Data + ); + +#endif diff --git a/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.inf b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.inf new file mode 100644 index 0000000000..b72ad6bfaf --- /dev/null +++ b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.inf @@ -0,0 +1,51 @@ +## @file +# Produces the CPU I/O PPI by using the services of the I/O Library. +# +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuIoPei + MODULE_UNI_FILE = CpuIoPei.uni + FILE_GUID = AE265864-CF5D-41a8-913D-71C155E76442 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = CpuIoInitialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + CpuIoPei.c + CpuIoPei.h + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + PeimEntryPoint + BaseLib + DebugLib + IoLib + PeiServicesLib + +[Ppis] + gEfiPeiCpuIoPpiInstalledGuid ## PRODUCES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuIoPeiExtra.uni diff --git a/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.uni b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.uni new file mode 100644 index 0000000000..0d8a14ef12 --- /dev/null +++ b/Core/UefiCpuPkg/CpuIoPei/CpuIoPei.uni @@ -0,0 +1,22 @@ +// /** @file +// Produces the CPU I/O PPI by using the services of the I/O Library. +// +// Produces the CPU I/O PPI by using the services of the I/O Library. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Produces the CPU I/O PPI by using the services of the I/O Library" + +#string STR_MODULE_DESCRIPTION #language en-US "Produces the CPU I/O PPI by using the services of the I/O Library." + diff --git a/Core/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni b/Core/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni new file mode 100644 index 0000000000..cd1f53a0cc --- /dev/null +++ b/Core/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuIoPei Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU I/O PEI Module" + + diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuBist.c b/Core/UefiCpuPkg/CpuMpPei/CpuBist.c new file mode 100644 index 0000000000..bf18ca4556 --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuBist.c @@ -0,0 +1,295 @@ +/** @file + Update and publish processors' BIST information. + + Copyright (c) 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuMpPei.h" + +EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2Ppi = { + SecPlatformInformation2 +}; + +EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2Ppi = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiSecPlatformInformation2PpiGuid, + &mSecPlatformInformation2Ppi +}; + +/** + Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. + + @param PeiServices The pointer to the PEI Services Table. + @param StructureSize The pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to + hold the record is returned in StructureSize. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation2 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + UINTN DataSize; + + GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); + if (GuidHob == NULL) { + *StructureSize = 0; + return EFI_SUCCESS; + } + + DataInHob = GET_GUID_HOB_DATA (GuidHob); + DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); + + // + // return the information from BistHob + // + if ((*StructureSize) < (UINT64) DataSize) { + *StructureSize = (UINT64) DataSize; + return EFI_BUFFER_TOO_SMALL; + } + + *StructureSize = (UINT64) DataSize; + CopyMem (PlatformInformationRecord2, DataInHob, DataSize); + return EFI_SUCCESS; +} + +/** + Worker function to get CPUs' BIST by calling SecPlatformInformationPpi + or SecPlatformInformation2Ppi. + + @param PeiServices Pointer to PEI Services Table + @param Guid PPI Guid + @param PpiDescriptor Return a pointer to instance of the + EFI_PEI_PPI_DESCRIPTOR + @param BistInformationData Pointer to BIST information data + @param BistInformationSize Return the size in bytes of BIST information + + @retval EFI_SUCCESS Retrieve of the BIST data successfully + @retval EFI_NOT_FOUND No sec platform information(2) ppi export + @retval EFI_DEVICE_ERROR Failed to get CPU Information + +**/ +EFI_STATUS +GetBistInfoFromPpi ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_GUID *Guid, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + OUT VOID **BistInformationData, + OUT UINT64 *BistInformationSize OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; + UINT64 InformationSize; + + Status = PeiServicesLocatePpi ( + Guid, // GUID + 0, // INSTANCE + PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR + (VOID **)&SecPlatformInformation2Ppi // PPI + ); + if (Status == EFI_NOT_FOUND) { + return EFI_NOT_FOUND; + } + + if (Status == EFI_SUCCESS) { + // + // Get the size of the sec platform information2(BSP/APs' BIST data) + // + InformationSize = 0; + SecPlatformInformation2 = NULL; + Status = SecPlatformInformation2Ppi->PlatformInformation2 ( + PeiServices, + &InformationSize, + SecPlatformInformation2 + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = PeiServicesAllocatePool ( + (UINTN) InformationSize, + (VOID **) &SecPlatformInformation2 + ); + if (Status == EFI_SUCCESS) { + // + // Retrieve BIST data + // + Status = SecPlatformInformation2Ppi->PlatformInformation2 ( + PeiServices, + &InformationSize, + SecPlatformInformation2 + ); + if (Status == EFI_SUCCESS) { + *BistInformationData = SecPlatformInformation2; + if (BistInformationSize != NULL) { + *BistInformationSize = InformationSize; + } + return EFI_SUCCESS; + } + } + } + } + + return EFI_DEVICE_ERROR; +} + +/** + Collects BIST data from PPI. + + This function collects BIST data from Sec Platform Information2 PPI + or SEC Platform Information PPI. + + @param PeiServices Pointer to PEI Services Table + +**/ +VOID +CollectBistDataFromPpi ( + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; + EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation; + UINTN NumberOfData; + EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; + EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance; + UINTN ProcessorNumber; + UINTN CpuIndex; + EFI_PROCESSOR_INFORMATION ProcessorInfo; + EFI_HEALTH_FLAGS BistData; + UINTN NumberOfProcessors; + UINTN NumberOfEnabledProcessors; + UINTN BistInformationSize; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2; + EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob; + + + MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors); + + BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + + sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors; + Status = PeiServicesAllocatePool ( + (UINTN) BistInformationSize, + (VOID **) &PlatformInformationRecord2 + ); + ASSERT_EFI_ERROR (Status); + PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors; + + SecPlatformInformation2 = NULL; + SecPlatformInformation = NULL; + NumberOfData = 0; + CpuInstance = NULL; + // + // Get BIST information from Sec Platform Information2 Ppi firstly + // + Status = GetBistInfoFromPpi ( + PeiServices, + &gEfiSecPlatformInformation2PpiGuid, + &SecInformationDescriptor, + (VOID *) &SecPlatformInformation2, + NULL + ); + if (Status == EFI_SUCCESS) { + // + // Sec Platform Information2 PPI includes BSP/APs' BIST information + // + NumberOfData = SecPlatformInformation2->NumberOfCpus; + CpuInstance = SecPlatformInformation2->CpuInstance; + } else { + // + // Otherwise, get BIST information from Sec Platform Information Ppi + // + Status = GetBistInfoFromPpi ( + PeiServices, + &gEfiSecPlatformInformationPpiGuid, + &SecInformationDescriptor, + (VOID *) &SecPlatformInformation, + NULL + ); + if (Status == EFI_SUCCESS) { + NumberOfData = 1; + // + // SEC Platform Information only includes BSP's BIST information + // and does not have BSP's APIC ID + // + BspCpuInstance.CpuLocation = GetInitialApicId (); + BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32; + CpuInstance = &BspCpuInstance; + } else { + DEBUG ((EFI_D_INFO, "Does not find any stored CPU BIST information from PPI!\n")); + } + } + for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber ++) { + MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData); + for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex ++) { + ASSERT (CpuInstance != NULL); + if (ProcessorInfo.ProcessorId == CpuInstance[CpuIndex].CpuLocation) { + // + // Update processor's BIST data if it is already stored before + // + BistData = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags; + } + } + if (BistData.Uint32 != 0) { + // + // Report Status Code that self test is failed + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST) + ); + } + DEBUG ((EFI_D_INFO, " APICID - 0x%08x, BIST - 0x%08x\n", + (UINT32) ProcessorInfo.ProcessorId, + BistData + )); + CpuInstanceInHob = PlatformInformationRecord2->CpuInstance; + CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId; + CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData; + } + + // + // Build SecPlatformInformation2 PPI GUIDed HOB that also could be consumed + // by CPU MP driver to get CPU BIST data + // + BuildGuidDataHob ( + &gEfiSecPlatformInformation2PpiGuid, + PlatformInformationRecord2, + (UINTN) BistInformationSize + ); + + if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) { + // + // Reinstall SecPlatformInformation2 PPI to include new BIST information + // + Status = PeiServicesReInstallPpi ( + SecInformationDescriptor, + &mPeiSecPlatformInformation2Ppi + ); + ASSERT_EFI_ERROR (Status); + } else { + // + // Install SecPlatformInformation2 PPI to include new BIST information + // + Status = PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi); + ASSERT_EFI_ERROR(Status); + } +} + diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.c new file mode 100644 index 0000000000..eaf99c73cd --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -0,0 +1,468 @@ +/** @file + CPU PEI Module installs CPU Multiple Processor PPI. + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuMpPei.h" + +// +// CPU MP PPI to be installed +// +EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = { + PeiGetNumberOfProcessors, + PeiGetProcessorInfo, + PeiStartupAllAPs, + PeiStartupThisAP, + PeiSwitchBSP, + PeiEnableDisableAP, + PeiWhoAmI, +}; + +EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMpServicesPpiGuid, + &mMpServicesPpi +}; + +/** + This service retrieves the number of logical processor in the platform + and the number of those logical processors that are enabled on this boot. + This service may only be called from the BSP. + + This function is used to retrieve the following information: + - The number of logical processors that are present in the system. + - The number of enabled logical processors in the system at the instant + this call is made. + + Because MP Service Ppi provides services to enable and disable processors + dynamically, the number of enabled logical processors may vary during the + course of a boot session. + + If this service is called from an AP, then EFI_DEVICE_ERROR is returned. + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors + is returned in NumberOfProcessors, the number of currently enabled processor + is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to this instance of the PPI. + @param[out] NumberOfProcessors Pointer to the total number of logical processors in + the system, including the BSP and disabled APs. + @param[out] NumberOfEnabledProcessors + Number of processors in the system that are enabled. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + NumberOfEnabledProcessors is NULL. +**/ +EFI_STATUS +EFIAPI +PeiGetNumberOfProcessors ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ) +{ + if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) { + return EFI_INVALID_PARAMETER; + } + + return MpInitLibGetNumberOfProcessors ( + NumberOfProcessors, + NumberOfEnabledProcessors + ); +} + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + This service retrieves detailed MP-related information about any processor + on the platform. Note the following: + - The processor information may change during the course of a boot session. + - The information presented here is entirely MP related. + + Information regarding the number of caches and their sizes, frequency of operation, + slot numbers is all considered platform-related information and is not provided + by this service. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to this instance of the PPI. + @param[in] ProcessorNumber Pointer to the total number of logical processors in + the system, including the BSP and disabled APs. + @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. +**/ +EFI_STATUS +EFIAPI +PeiGetProcessorInfo ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL); +} + +/** + This service executes a caller provided function on all enabled APs. APs can + run either simultaneously or one at a time in sequence. This service supports + both blocking requests only. This service may only + be called from the BSP. + + This function is used to dispatch all the enabled APs to the function specified + by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned + immediately and Procedure is not started on any AP. + + If SingleThread is TRUE, all the enabled APs execute the function specified by + Procedure one by one, in ascending order of processor handle number. Otherwise, + all the enabled APs execute the function specified by Procedure simultaneously. + + If the timeout specified by TimeoutInMicroSeconds expires before all APs return + from Procedure, then Procedure on the failed APs is terminated. All enabled APs + are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its + content points to the list of processor handle numbers in which Procedure was + terminated. + + Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + to make sure that the nature of the code that is executed on the BSP and the + dispatched APs is well controlled. The MP Services Ppi does not guarantee + that the Procedure function is MP-safe. Hence, the tasks that can be run in + parallel are limited to certain independent tasks and well-controlled exclusive + code. PEI services and Ppis may not be called by APs unless otherwise + specified. + + In blocking execution mode, BSP waits until all APs finish or + TimeoutInMicroSeconds expires. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] Procedure A pointer to the function to be run on enabled APs of + the system. + @param[in] SingleThread If TRUE, then all the enabled APs execute the function + specified by Procedure one by one, in ascending order + of processor handle number. If FALSE, then all the + enabled APs execute the function specified by Procedure + simultaneously. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds for APs to + return from Procedure, for blocking mode only. Zero + means infinity. If the timeout expires before all APs + return from Procedure, then Procedure on the failed APs + is terminated. All enabled APs are available for next + function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the + timeout expires in blocking mode, BSP returns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for all APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +PeiStartupAllAPs ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return MpInitLibStartupAllAPs ( + Procedure, + SingleThread, + NULL, + TimeoutInMicroSeconds, + ProcedureArgument, + NULL + ); +} + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. The caller can request the BSP to wait for the completion + of the AP. This service may only be called from the BSP. + + This function is used to dispatch one enabled AP to the function specified by + Procedure passing in the argument specified by ProcedureArgument. + The execution is in blocking mode. The BSP waits until the AP finishes or + TimeoutInMicroSecondss expires. + + If the timeout specified by TimeoutInMicroseconds expires before the AP returns + from Procedure, then execution of Procedure by the AP is terminated. The AP is + available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and + EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] Procedure A pointer to the function to be run on enabled APs of + the system. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] TimeoutInMicroseconds + Indicates the time limit in microseconds for APs to + return from Procedure, for blocking mode only. Zero + means infinity. If the timeout expires before all APs + return from Procedure, then Procedure on the failed APs + is terminated. All enabled APs are available for next + function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the + timeout expires in blocking mode, BSP returns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for all APs. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before the + timeout expires. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before the + specified AP has finished. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +PeiStartupThisAP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return MpInitLibStartupThisAP ( + Procedure, + ProcessorNumber, + NULL, + TimeoutInMicroseconds, + ProcedureArgument, + NULL + ); +} + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. The new BSP can take over the + execution of the old BSP and continue seamlessly from where the old one left + off. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled + AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this + service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_SUCCESS The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled + AP. + @retval EFI_NOT_READY The specified AP is busy. +**/ +EFI_STATUS +EFIAPI +PeiSwitchBSP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); +} + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + This service allows the caller enable or disable an AP from this point onward. + The caller can optionally specify the health status of the AP by Health. If + an AP is being disabled, then the state of the disabled AP is implementation + dependent. If an AP is enabled, then the implementation must guarantee that a + complete initialization sequence is performed on the AP, so the AP is in a state + that is compatible with an MP operating system. + + If the enable or disable AP operation cannot be completed prior to the return + from this service, then EFI_UNSUPPORTED must be returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for enabled, + FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies the + new health status of the AP. This flag corresponds to + StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo(). + Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter is + ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior + to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. +**/ +EFI_STATUS +EFIAPI +PeiEnableDisableAP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); +} + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + This service returns the processor handle number for the calling processor. + The returned value is in the range from 0 to the total number of logical + processors minus 1. The total number of logical processors can be retrieved + with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be + called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER + is returned. Otherwise, the current processors handle number is returned in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned in + ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. +**/ +EFI_STATUS +EFIAPI +PeiWhoAmI ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + OUT UINTN *ProcessorNumber + ) +{ + return MpInitLibWhoAmI (ProcessorNumber); +} + +/** + The Entry point of the MP CPU PEIM. + + This function will wakeup APs and collect CPU AP count and install the + Mp Service Ppi. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS MpServicePpi is installed successfully. + +**/ +EFI_STATUS +EFIAPI +CpuMpPeimInit ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_VECTOR_HANDOFF_INFO *VectorInfo; + EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi; + + // + // Get Vector Hand-off Info PPI + // + VectorInfo = NULL; + Status = PeiServicesLocatePpi ( + &gEfiVectorHandoffInfoPpiGuid, + 0, + NULL, + (VOID **)&VectorHandoffInfoPpi + ); + if (Status == EFI_SUCCESS) { + VectorInfo = VectorHandoffInfoPpi->Info; + } + Status = InitializeCpuExceptionHandlers (VectorInfo); + ASSERT_EFI_ERROR (Status); + + // + // Wakeup APs to do initialization + // + Status = MpInitLibInitialize (); + ASSERT_EFI_ERROR (Status); + + // + // Update and publish CPU BIST information + // + CollectBistDataFromPpi (PeiServices); + + // + // Install CPU MP PPI + // + Status = PeiServicesInstallPpi(&mPeiCpuMpPpiDesc); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.h new file mode 100644 index 0000000000..0836593efc --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -0,0 +1,405 @@ +/** @file + Definitions to install Multiple Processor PPI. + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_MP_PEI_H_ +#define _CPU_MP_PEI_H_ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; + +/** + This service retrieves the number of logical processor in the platform + and the number of those logical processors that are enabled on this boot. + This service may only be called from the BSP. + + This function is used to retrieve the following information: + - The number of logical processors that are present in the system. + - The number of enabled logical processors in the system at the instant + this call is made. + + Because MP Service Ppi provides services to enable and disable processors + dynamically, the number of enabled logical processors may vary during the + course of a boot session. + + If this service is called from an AP, then EFI_DEVICE_ERROR is returned. + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors + is returned in NumberOfProcessors, the number of currently enabled processor + is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to this instance of the PPI. + @param[out] NumberOfProcessors Pointer to the total number of logical processors in + the system, including the BSP and disabled APs. + @param[out] NumberOfEnabledProcessors + Number of processors in the system that are enabled. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + NumberOfEnabledProcessors is NULL. +**/ +EFI_STATUS +EFIAPI +PeiGetNumberOfProcessors ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ); + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + This service retrieves detailed MP-related information about any processor + on the platform. Note the following: + - The processor information may change during the course of a boot session. + - The information presented here is entirely MP related. + + Information regarding the number of caches and their sizes, frequency of operation, + slot numbers is all considered platform-related information and is not provided + by this service. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This Pointer to this instance of the PPI. + @param[in] ProcessorNumber Pointer to the total number of logical processors in + the system, including the BSP and disabled APs. + @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. +**/ +EFI_STATUS +EFIAPI +PeiGetProcessorInfo ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + This service executes a caller provided function on all enabled APs. APs can + run either simultaneously or one at a time in sequence. This service supports + both blocking requests only. This service may only + be called from the BSP. + + This function is used to dispatch all the enabled APs to the function specified + by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned + immediately and Procedure is not started on any AP. + + If SingleThread is TRUE, all the enabled APs execute the function specified by + Procedure one by one, in ascending order of processor handle number. Otherwise, + all the enabled APs execute the function specified by Procedure simultaneously. + + If the timeout specified by TimeoutInMicroSeconds expires before all APs return + from Procedure, then Procedure on the failed APs is terminated. All enabled APs + are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its + content points to the list of processor handle numbers in which Procedure was + terminated. + + Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + to make sure that the nature of the code that is executed on the BSP and the + dispatched APs is well controlled. The MP Services Ppi does not guarantee + that the Procedure function is MP-safe. Hence, the tasks that can be run in + parallel are limited to certain independent tasks and well-controlled exclusive + code. PEI services and Ppis may not be called by APs unless otherwise + specified. + + In blocking execution mode, BSP waits until all APs finish or + TimeoutInMicroSeconds expires. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] Procedure A pointer to the function to be run on enabled APs of + the system. + @param[in] SingleThread If TRUE, then all the enabled APs execute the function + specified by Procedure one by one, in ascending order + of processor handle number. If FALSE, then all the + enabled APs execute the function specified by Procedure + simultaneously. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds for APs to + return from Procedure, for blocking mode only. Zero + means infinity. If the timeout expires before all APs + return from Procedure, then Procedure on the failed APs + is terminated. All enabled APs are available for next + function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the + timeout expires in blocking mode, BSP returns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for all APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +PeiStartupAllAPs ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ); + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. The caller can request the BSP to wait for the completion + of the AP. This service may only be called from the BSP. + + This function is used to dispatch one enabled AP to the function specified by + Procedure passing in the argument specified by ProcedureArgument. + The execution is in blocking mode. The BSP waits until the AP finishes or + TimeoutInMicroSecondss expires. + + If the timeout specified by TimeoutInMicroseconds expires before the AP returns + from Procedure, then execution of Procedure by the AP is terminated. The AP is + available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and + EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] Procedure A pointer to the function to be run on enabled APs of + the system. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] TimeoutInMicroseconds + Indicates the time limit in microseconds for APs to + return from Procedure, for blocking mode only. Zero + means infinity. If the timeout expires before all APs + return from Procedure, then Procedure on the failed APs + is terminated. All enabled APs are available for next + function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the + timeout expires in blocking mode, BSP returns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for all APs. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before the + timeout expires. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before the + specified AP has finished. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +PeiStartupThisAP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ); + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. The new BSP can take over the + execution of the old BSP and continue seamlessly from where the old one left + off. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled + AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this + service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_SUCCESS The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled + AP. + @retval EFI_NOT_READY The specified AP is busy. +**/ +EFI_STATUS +EFIAPI +PeiSwitchBSP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ); + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + This service allows the caller enable or disable an AP from this point onward. + The caller can optionally specify the health status of the AP by Health. If + an AP is being disabled, then the state of the disabled AP is implementation + dependent. If an AP is enabled, then the implementation must guarantee that a + complete initialization sequence is performed on the AP, so the AP is in a state + that is compatible with an MP operating system. + + If the enable or disable AP operation cannot be completed prior to the return + from this service, then EFI_UNSUPPORTED must be returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for enabled, + FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies the + new health status of the AP. This flag corresponds to + StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo(). + Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter is + ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior + to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. +**/ +EFI_STATUS +EFIAPI +PeiEnableDisableAP ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ); + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + This service returns the processor handle number for the calling processor. + The returned value is in the range from 0 to the total number of logical + processors minus 1. The total number of logical processors can be retrieved + with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be + called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER + is returned. Otherwise, the current processors handle number is returned in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. + @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the + total number of logical processors minus 1. The total + number of logical processors can be retrieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned in + ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. +**/ +EFI_STATUS +EFIAPI +PeiWhoAmI ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_MP_SERVICES_PPI *This, + OUT UINTN *ProcessorNumber + ); + +/** + Collects BIST data from PPI. + + This function collects BIST data from Sec Platform Information2 PPI + or SEC Platform Information PPI. + + @param PeiServices Pointer to PEI Services Table + +**/ +VOID +CollectBistDataFromPpi ( + IN CONST EFI_PEI_SERVICES **PeiServices + ); + +/** + Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. + + @param PeiServices The pointer to the PEI Services Table. + @param StructureSize The pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to + hold the record is returned in StructureSize. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation2 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 + ); + +#endif diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.inf new file mode 100644 index 0000000000..3b40d88201 --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -0,0 +1,66 @@ +## @file +# CPU driver installs CPU PI Multi-processor PPI. +# +# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuMpPei + MODULE_UNI_FILE = CpuMpPei.uni + FILE_GUID = EDADEB9D-DDBA-48BD-9D22-C1C169C8C5C6 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = CpuMpPeimInit + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + CpuMpPei.h + CpuMpPei.c + CpuBist.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + HobLib + LocalApicLib + PeimEntryPoint + PeiServicesLib + ReportStatusCodeLib + CpuExceptionHandlerLib + MpInitLib + BaseMemoryLib + +[Ppis] + gEfiPeiMpServicesPpiGuid ## PRODUCES + gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES + ## SOMETIMES_CONSUMES + ## PRODUCES + ## UNDEFINED # HOB + gEfiSecPlatformInformation2PpiGuid + gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES + +[Depex] + gEfiPeiMemoryDiscoveredPpiGuid + +[UserExtensions.TianoCore."ExtraFiles"] + CpuMpPeiExtra.uni + diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.uni b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.uni new file mode 100644 index 0000000000..d458d0d624 --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuMpPei.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU driver installs CPU PI Multi-processor PPI. +// +// CPU driver installs CPU PI Multi-processor PPI. +// +// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Installs CPU PI Multi-processor PPI" + +#string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU PI Multi-processor PPI." + diff --git a/Core/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni b/Core/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni new file mode 100644 index 0000000000..cf832fb80b --- /dev/null +++ b/Core/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuMpPei Localized Strings and Content +// +// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Multi-processor PEIM Driver" + + diff --git a/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c new file mode 100644 index 0000000000..dccb406b8d --- /dev/null +++ b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c @@ -0,0 +1,292 @@ +/** @file +ACPI CPU Data initialization module + +This module initializes the ACPI_CPU_DATA structure and registers the address +of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple +version of this module. It does not provide a machine check handler or CPU +register initialization tables for ACPI S3 resume. It also only supports the +number of CPUs reported by the MP Services Protocol, so this module does not +support hot plug CPUs. This module can be copied into a CPU specific package +and customized if these additional features are required. + +Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015, Red Hat, Inc. + +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +// +// Data structure used to allocate ACPI_CPU_DATA and its supporting structures +// +typedef struct { + ACPI_CPU_DATA AcpiCpuData; + MTRR_SETTINGS MtrrTable; + IA32_DESCRIPTOR GdtrProfile; + IA32_DESCRIPTOR IdtrProfile; +} ACPI_CPU_DATA_EX; + +/** + Allocate EfiACPIMemoryNVS below 4G memory address. + + This function allocates EfiACPIMemoryNVS below 4G memory address. + + @param[in] Size Size of memory to allocate. + + @return Allocated address for output. + +**/ +VOID * +AllocateAcpiNvsMemoryBelow4G ( + IN UINTN Size + ) +{ + EFI_PHYSICAL_ADDRESS Address; + EFI_STATUS Status; + VOID *Buffer; + + Address = BASE_4GB - 1; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (Size), + &Address + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Buffer = (VOID *)(UINTN)Address; + ZeroMem (Buffer, Size); + + return Buffer; +} + +/** + Callback function executed when the EndOfDxe event group is signaled. + + We delay allocating StartupVector and saving the MTRR settings until BDS signals EndOfDxe. + + @param[in] Event Event whose notification function is being invoked. + @param[out] Context Pointer to the MTRR_SETTINGS buffer to fill in. +**/ +VOID +EFIAPI +CpuS3DataOnEndOfDxe ( + IN EFI_EVENT Event, + OUT VOID *Context + ) +{ + EFI_STATUS Status; + ACPI_CPU_DATA_EX *AcpiCpuDataEx; + + AcpiCpuDataEx = (ACPI_CPU_DATA_EX *) Context; + // + // Allocate a 4KB reserved page below 1MB + // + AcpiCpuDataEx->AcpiCpuData.StartupVector = BASE_1MB - 1; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiReservedMemoryType, + 1, + &AcpiCpuDataEx->AcpiCpuData.StartupVector + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((EFI_D_VERBOSE, "%a\n", __FUNCTION__)); + MtrrGetAllMtrrs (&AcpiCpuDataEx->MtrrTable); + + // + // Close event, so it will not be invoked again. + // + gBS->CloseEvent (Event); +} + +/** + The entry function of the CpuS3Data driver. + + Allocate and initialize all fields of the ACPI_CPU_DATA structure except the + MTRR settings. Register an event notification on gEfiEndOfDxeEventGroupGuid + to capture the ACPI_CPU_DATA MTRR settings. The PcdCpuS3DataAddress is set + to the address that ACPI_CPU_DATA is allocated at. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval EFI_UNSUPPORTED Do not support ACPI S3. + @retval other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +CpuS3DataInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + ACPI_CPU_DATA_EX *AcpiCpuDataEx; + ACPI_CPU_DATA *AcpiCpuData; + EFI_MP_SERVICES_PROTOCOL *MpServices; + UINTN NumberOfCpus; + UINTN NumberOfEnabledProcessors; + VOID *Stack; + UINTN TableSize; + CPU_REGISTER_TABLE *RegisterTable; + UINTN Index; + EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; + UINTN GdtSize; + UINTN IdtSize; + VOID *Gdt; + VOID *Idt; + EFI_EVENT Event; + ACPI_CPU_DATA *OldAcpiCpuData; + + if (!PcdGetBool (PcdAcpiS3Enable)) { + return EFI_UNSUPPORTED; + } + + // + // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure + // + OldAcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress); + + // + // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume. + // + AcpiCpuDataEx = AllocateAcpiNvsMemoryBelow4G (sizeof (ACPI_CPU_DATA_EX)); + ASSERT (AcpiCpuDataEx != NULL); + AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData; + + // + // Get MP Services Protocol + // + Status = gBS->LocateProtocol ( + &gEfiMpServiceProtocolGuid, + NULL, + (VOID **)&MpServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Get the number of CPUs + // + Status = MpServices->GetNumberOfProcessors ( + MpServices, + &NumberOfCpus, + &NumberOfEnabledProcessors + ); + ASSERT_EFI_ERROR (Status); + AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; + + // + // Initialize ACPI_CPU_DATA fields + // + AcpiCpuData->StackSize = PcdGet32 (PcdCpuApStackSize); + AcpiCpuData->ApMachineCheckHandlerBase = 0; + AcpiCpuData->ApMachineCheckHandlerSize = 0; + AcpiCpuData->GdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->GdtrProfile; + AcpiCpuData->IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->IdtrProfile; + AcpiCpuData->MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable; + + // + // Allocate stack space for all CPUs + // + Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize); + ASSERT (Stack != NULL); + AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; + + // + // Get the boot processor's GDT and IDT + // + AsmReadGdtr (&AcpiCpuDataEx->GdtrProfile); + AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile); + + // + // Allocate GDT and IDT in ACPI NVS and copy current GDT and IDT contents + // + GdtSize = AcpiCpuDataEx->GdtrProfile.Limit + 1; + IdtSize = AcpiCpuDataEx->IdtrProfile.Limit + 1; + Gdt = AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize); + ASSERT (Gdt != NULL); + Idt = (VOID *)((UINTN)Gdt + GdtSize); + CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize); + CopyMem (Idt, (VOID *)AcpiCpuDataEx->IdtrProfile.Base, IdtSize); + AcpiCpuDataEx->GdtrProfile.Base = (UINTN)Gdt; + AcpiCpuDataEx->IdtrProfile.Base = (UINTN)Idt; + + if (OldAcpiCpuData != NULL) { + AcpiCpuData->RegisterTable = OldAcpiCpuData->RegisterTable; + AcpiCpuData->PreSmmInitRegisterTable = OldAcpiCpuData->PreSmmInitRegisterTable; + } else { + // + // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs + // + TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); + RegisterTable = (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G (TableSize); + ASSERT (RegisterTable != NULL); + + for (Index = 0; Index < NumberOfCpus; Index++) { + Status = MpServices->GetProcessorInfo ( + MpServices, + Index, + &ProcessorInfoBuffer + ); + ASSERT_EFI_ERROR (Status); + + RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; + RegisterTable[Index].TableLength = 0; + RegisterTable[Index].AllocatedSize = 0; + RegisterTable[Index].RegisterTableEntry = 0; + + RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; + RegisterTable[NumberOfCpus + Index].TableLength = 0; + RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; + RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; + } + AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; + AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); + } + + // + // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure + // + Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData); + ASSERT_EFI_ERROR (Status); + + // + // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. + // The notification function allocates StartupVector and saves MTRRs for ACPI_CPU_DATA + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + CpuS3DataOnEndOfDxe, + AcpiCpuData, + &gEfiEndOfDxeEventGroupGuid, + &Event + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf new file mode 100644 index 0000000000..480c98ebcd --- /dev/null +++ b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf @@ -0,0 +1,70 @@ +## @file +# ACPI CPU Data initialization module +# +# This module initializes the ACPI_CPU_DATA structure and registers the address +# of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple +# version of this module. It does not provide a machine check handler or CPU +# register initialization tables for ACPI S3 resume. It also only supports the +# number of CPUs reported by the MP Services Protocol, so this module does not +# support hot plug CPUs. This module can be copied into a CPU specific package +# and customized if these additional features are required. +# +# Copyright (c) 2013-2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2015, Red Hat, Inc. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuS3DataDxe + MODULE_UNI_FILE = CpuS3DataDxe.uni + FILE_GUID = 4D2E57EE-0E3F-44DD-93C4-D3B57E96945D + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = CpuS3DataInitialize + +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = IA32 X64 + +[Sources] + CpuS3Data.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + UefiBootServicesTableLib + BaseMemoryLib + DebugLib + BaseLib + MtrrLib + +[Guids] + gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event + +[Protocols] + gEfiMpServiceProtocolGuid ## CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## PRODUCES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES + +[Depex] + gEfiMpServiceProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + CpuS3DataDxeExtra.uni diff --git a/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni new file mode 100644 index 0000000000..4a0218f180 --- /dev/null +++ b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni @@ -0,0 +1,40 @@ +// /** @file +// ACPI CPU Data initialization module +// +// This module initializes the ACPI_CPU_DATA structure and registers the address +// of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple +// version of this module. It does not provide a machine check handler or CPU +// register initialization tables for ACPI S3 resume. It also only supports the +// number of CPUs reported by the MP Services Protocol, so this module does not +// support hot plug CPUs. This module can be copied into a CPU specific package +// and customized if these additional features are required. +// +// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// +// Copyright (c) 2015, Red Hat, Inc. +// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT +#language en-US +"ACPI CPU Data initialization module" + +#string STR_MODULE_DESCRIPTION +#language en-US +"This module initializes the ACPI_CPU_DATA structure and registers the address " +"of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple " +"version of this module. It does not provide a machine check handler or CPU " +"register initialization tables for ACPI S3 resume. It also only supports the " +"number of CPUs reported by the MP Services Protocol, so this module does not " +"support hot plug CPUs. This module can be copied into a CPU specific package " +"and customized if these additional features are required." + + diff --git a/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni new file mode 100644 index 0000000000..050f25f843 --- /dev/null +++ b/Core/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuS3DataDxe Localized Strings and Content +// +// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// +// Copyright (c) 2015, Red Hat, Inc. +// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME #language en-US "CpuS3DataDxe module" + + diff --git a/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c new file mode 100644 index 0000000000..7a5ec152d7 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c @@ -0,0 +1,42 @@ +/** @file + Microcode flash device access library NULL instance. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include + +/** + Perform microcode write opreation. + + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +MicrocodeFlashWrite ( + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN VOID *Buffer, + IN UINTN Length + ) +{ + CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length); + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf new file mode 100644 index 0000000000..a4a47e0737 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf @@ -0,0 +1,40 @@ +## @file +# Microcode flash device access library. +# +# Microcode flash device access library NULL instance. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MicrocodeFlashAccessLibNull + MODULE_UNI_FILE = MicrocodeFlashAccessLibNull.uni + FILE_GUID = 6F871ADD-9D86-4676-8BAD-68E2E451FC5B + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = MicrocodeFlashAccessLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + MicrocodeFlashAccessLibNull.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseMemoryLib diff --git a/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni new file mode 100644 index 0000000000..cc4195c412 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni @@ -0,0 +1,21 @@ +// /** @file +// Microcode flash device access library. +// +// Microcode flash device access library NULL instance. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Microcode flash device access library." + +#string STR_MODULE_DESCRIPTION #language en-US "Microcode flash device access library NULL instance." + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc new file mode 100644 index 0000000000..1b22c55117 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc @@ -0,0 +1,33 @@ +## @file +# MicrocodeCapsulePdb +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] +# +# Uncomment the following line and update with your platform pkg name +# +# PLATFORM_NAME = + PLATFORM_GUID = 6875FD33-602E-4EF9-9DF2-8BA7D8B7A7AF + PLATFORM_VERSION = 0.1 +# +# Uncomment the following line and update with your platform pkg name +# +# FLASH_DEFINITION = /MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf +# +# Uncomment the following line and update with your platform pkg name +# +# OUTPUT_DIRECTORY = Build/ + SUPPORTED_ARCHITECTURES = IA32|X64 + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf new file mode 100644 index 0000000000..f171604d4f --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf @@ -0,0 +1,32 @@ +## @file +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[FmpPayload.FmpPayloadMicrocode1] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = 96d4fdcd-1502-424d-9d4c-9b12d2dcae5c # Microcode GUID (do not change it) +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 + +# +# Uncomment the following line and update with path to Microcode PDB file +# +#FILE DATA = $(WORKSPACE)//Microcode/Microcode.pdb + +[Capsule.MicrocodeCapsule] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # FMP special Guid (do not change it) +CAPSULE_FLAGS = PersistAcrossReset,InitiateReset +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + +FMP_PAYLOAD = FmpPayloadMicrocode1 diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md new file mode 100644 index 0000000000..9f81373fda --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md @@ -0,0 +1,20 @@ +# How to generate Microcode FMP from Microcode PDB file + +1) Copy directory `UefiCpuPkg/Feature/Capsule/MicrocodeUpdatePdb` to `/MicrocodeUpdatePdb`. + +2) Uncomment and update `FILE DATA` statement in `/MicrocodeUpdatePdb/MicrocodeCapsulePdb.fdf` with path to a Microcode PDB file. The PDB file can placed in `/MicrocodeUpdatePdb` or any other path. + +`FILE DATA = ` + +Uncomment and update `PLATFORM_NAME`, `FLASH_DEFINITION`, `OUTPUT_DIRECTORY` section in `/MicrocodeUpdatePdb/MicrocodeCapsulePdb.dsc` with . + + PLATFORM_NAME = + FLASH_DEFINITION = /MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf + OUTPUT_DIRECTORY = Build/ + +3) Use EDK II build tools to generate the Microcode FMP Capsule + +`build -p /MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc` + +4) The Microcode FMP Capsule is generated at `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/MicrocodeCapsule.Cap` + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf new file mode 100644 index 0000000000..81af841f2c --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf @@ -0,0 +1,27 @@ +## @file +# Microcode text file to binary +# +# Convert text format microcode to binary format. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] +BASE_NAME = Microcode +FILE_GUID = ABC36AAC-2031-4422-896E-0A3B899AD0B4 +COMPONENT_TYPE = Microcode +FFS_EXT = .ffs + +[Sources] +# +# Uncomment the following line and update with name of Microcode TXT file +# +#Microcode.txt diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc new file mode 100644 index 0000000000..a66f89b4e2 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc @@ -0,0 +1,39 @@ +## @file +# MicrocodeCapsuleTxt +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] +# +# Uncomment the following line and update with your platform pkg name +# +# PLATFORM_NAME = + PLATFORM_GUID = 6875FD33-602E-4EF9-9DF2-8BA7D8B7A7AF + PLATFORM_VERSION = 0.1 +# +# Uncomment the following line and update with your platform pkg name +# +# FLASH_DEFINITION = /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf +# +# Uncomment the following line and update with your platform pkg name +# +# OUTPUT_DIRECTORY = Build/ + SUPPORTED_ARCHITECTURES = IA32|X64 + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + +[Components] +# +# Uncomment the following line and update with path to Microcode INF file +# +# /MicrocodeCapsuleTxt/Microcode/Microcode.inf diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf new file mode 100644 index 0000000000..113693b1df --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf @@ -0,0 +1,32 @@ +## @file +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[FmpPayload.FmpPayloadMicrocode1] +IMAGE_HEADER_INIT_VERSION = 0x02 +IMAGE_TYPE_ID = 96d4fdcd-1502-424d-9d4c-9b12d2dcae5c # Microcode GUID (do not change it) +IMAGE_INDEX = 0x1 +HARDWARE_INSTANCE = 0x0 + +# +# Uncomment the following line and update with path to Microcode MCB file +# +#FILE DATA = $(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/IA32/PlatformPkg/MicrocodeCapsuleTxt/Microcode/Microcode/OUTPUT/Microcode.mcb + +[Capsule.MicrocodeCapsule] +CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # FMP special Guid (do not change it) +CAPSULE_FLAGS = PersistAcrossReset,InitiateReset +CAPSULE_HEADER_SIZE = 0x20 +CAPSULE_HEADER_INIT_VERSION = 0x1 + +FMP_PAYLOAD = FmpPayloadMicrocode1 diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md new file mode 100644 index 0000000000..f7d7040fcb --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md @@ -0,0 +1,33 @@ +# How to generate Microcode FMP from Microcode TXT file + +1) Copy directory `UefiCpuPkg/Feature/Capsule/MicrocodeUpdateTxt` to `/MicrocodeUpdateTxt` + +2) Copy microcode TXT file to`/MicrocodeUpdateTxt/Microcode` + +3) Uncomment and update statement in `[Sources]` section of `/MicrocodeUpdateTxt/Microcode/Microcode.inf` with name of Microcode TXT file copied in previous step. + + [Sources] + + +Uncomment and update `FILE DATA` statement in `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.fdf` with path to a Microcode MCB file. The MCB file is placed in `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/IA32//MicrocodeUpdateTxt/Microcode/Microcode/OUTPUT/`. + +`FILE DATA = ` + +Uncomment and update `PLATFORM_NAME`, `FLASH_DEFINITION`, `OUTPUT_DIRECTORY` section in `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.dsc` with . + + PLATFORM_NAME = + FLASH_DEFINITION = /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf + OUTPUT_DIRECTORY = Build/ + +Uncomment and update statement in `Components` section of `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.dsc` with path to a Microcode INF file. + + [Components] + + +4) Use EDK II build tools to generate the Microcode FMP Capsule + +`build -p /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc` + +5) The generated Microcode FMP Capsule is found at `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/MicrocodeCapsule.Cap` + + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c new file mode 100644 index 0000000000..ebde93a91e --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c @@ -0,0 +1,748 @@ +/** @file + Produce FMP instance for Microcode. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MicrocodeUpdate.h" + +// +// MicrocodeFmp driver private data +// +MICROCODE_FMP_PRIVATE_DATA *mMicrocodeFmpPrivate = NULL; + +EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = { + FmpGetImageInfo, + FmpGetImage, + FmpSetImage, + FmpCheckImage, + FmpGetPackageInfo, + FmpSetPackageInfo +}; + +/** + Initialize Microcode Descriptor. + + @param[in] MicrocodeFmpPrivate private data structure to be initialized. + + @return EFI_SUCCESS Microcode Descriptor is initialized. +**/ +EFI_STATUS +InitializeMicrocodeDescriptor ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ); + +/** + Returns information about the current firmware image(s) of the device. + + This function allows a copy of the current firmware image to be created and saved. + The saved copy could later been used, for example, in firmware image recovery or rollback. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer. + On input, this is the size of the buffer allocated by the caller. + On output, it is the size of the buffer returned by the firmware + if the buffer was large enough, or the size of the buffer needed + to contain the image(s) information if the buffer was too small. + @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s) + information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs. + @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number + associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] DescriptorCount A pointer to the location in which firmware returns the number of + descriptors or firmware images within this device. + @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes, + of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] PackageVersion A version number that represents all the firmware images in the device. + The format is vendor specific and new version must have a greater value + than the old version. If PackageVersion is not supported, the value is + 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison + is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates + that package version update is in progress. + @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the + package version name. The buffer is allocated by this function with + AllocatePool(), and it is the caller's responsibility to free it with a call + to FreePool(). + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size + needed to hold the image(s) information is returned in ImageInfoSize. + @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL. + @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image. + +**/ +EFI_STATUS +EFIAPI +FmpGetImageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN OUT UINTN *ImageInfoSize, + IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, + OUT UINT32 *DescriptorVersion, + OUT UINT8 *DescriptorCount, + OUT UINTN *DescriptorSize, + OUT UINT32 *PackageVersion, + OUT CHAR16 **PackageVersionName + ) +{ + MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; + UINTN Index; + + MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); + + if(ImageInfoSize == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (*ImageInfoSize < sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount) { + *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount; + return EFI_BUFFER_TOO_SMALL; + } + + if (ImageInfo == NULL || + DescriptorVersion == NULL || + DescriptorCount == NULL || + DescriptorSize == NULL || + PackageVersion == NULL || + PackageVersionName == NULL) { + return EFI_INVALID_PARAMETER; + } + + *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount; + *DescriptorSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR); + *DescriptorCount = MicrocodeFmpPrivate->DescriptorCount; + *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; + + // + // supports 1 ImageInfo descriptor + // + CopyMem(&ImageInfo[0], MicrocodeFmpPrivate->ImageDescriptor, sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount); + for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { + if ((ImageInfo[Index].AttributesSetting & IMAGE_ATTRIBUTE_IN_USE) != 0) { + ImageInfo[Index].LastAttemptVersion = MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion; + ImageInfo[Index].LastAttemptStatus = MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus; + } + } + + // + // package version + // + *PackageVersion = MicrocodeFmpPrivate->PackageVersion; + if (MicrocodeFmpPrivate->PackageVersionName != NULL) { + *PackageVersionName = AllocateCopyPool(StrSize(MicrocodeFmpPrivate->PackageVersionName), MicrocodeFmpPrivate->PackageVersionName); + } + + return EFI_SUCCESS; +} + +/** + Retrieves a copy of the current firmware image of the device. + + This function allows a copy of the current firmware image to be created and saved. + The saved copy could later been used, for example, in firmware image recovery or rollback. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in,out] Image Points to the buffer where the current image is copied to. + @param[in,out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes. + On return, points to the length of the image, in bytes. + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the + image. The current buffer size needed to hold the image is returned + in ImageSize. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_NOT_FOUND The current image is not copied to the buffer. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpGetImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN OUT VOID *Image, + IN OUT UINTN *ImageSize + ) +{ + MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; + MICROCODE_INFO *MicrocodeInfo; + + if (Image == NULL || ImageSize == NULL) { + return EFI_INVALID_PARAMETER; + } + + MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); + + if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || ImageSize == NULL || Image == NULL) { + return EFI_INVALID_PARAMETER; + } + + MicrocodeInfo = &MicrocodeFmpPrivate->MicrocodeInfo[ImageIndex - 1]; + + if (*ImageSize < MicrocodeInfo->TotalSize) { + *ImageSize = MicrocodeInfo->TotalSize; + return EFI_BUFFER_TOO_SMALL; + } + + *ImageSize = MicrocodeInfo->TotalSize; + CopyMem (Image, MicrocodeInfo->MicrocodeEntryPoint, MicrocodeInfo->TotalSize); + return EFI_SUCCESS; +} + +/** + Updates the firmware image of the device. + + This function updates the hardware with the new firmware image. + This function returns EFI_UNSUPPORTED if the firmware image is not updatable. + If the firmware image is updatable, the function should perform the following minimal validations + before proceeding to do the firmware image update. + - Validate the image authentication if image has attribute + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns + EFI_SECURITY_VIOLATION if the validation fails. + - Validate the image is a supported image for this device. The function returns EFI_ABORTED if + the image is unsupported. The function can optionally provide more detailed information on + why the image is not a supported image. + - Validate the data from VendorCode if not null. Image validation must be performed before + VendorCode data validation. VendorCode data is ignored or considered invalid if image + validation failed. The function returns EFI_ABORTED if the data is invalid. + + VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if + the caller did not specify the policy or use the default policy. As an example, vendor can implement + a policy to allow an option to force a firmware image update when the abort reason is due to the new + firmware image version is older than the current firmware image version or bad image checksum. + Sensitive operations such as those wiping the entire firmware image and render the device to be + non-functional should be encoded in the image itself rather than passed with the VendorCode. + AbortReason enables vendor to have the option to provide a more detailed description of the abort + reason to the caller. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in] Image Points to the new image. + @param[in] ImageSize Size of the new image in bytes. + @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy. + Null indicates the caller did not specify the policy or use the default policy. + @param[in] Progress A function used by the driver to report the progress of the firmware update. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_ABORTED The operation is aborted. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpSetImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN CONST VOID *Image, + IN UINTN ImageSize, + IN CONST VOID *VendorCode, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, + OUT CHAR16 **AbortReason + ) +{ + EFI_STATUS Status; + EFI_STATUS VarStatus; + MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; + + if (Image == NULL || AbortReason == NULL) { + return EFI_INVALID_PARAMETER; + } + + MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); + *AbortReason = NULL; + + if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || Image == NULL) { + return EFI_INVALID_PARAMETER; + } + + Status = MicrocodeWrite(MicrocodeFmpPrivate, (VOID *)Image, ImageSize, &MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, &MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus, AbortReason); + DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus)); + VarStatus = gRT->SetVariable( + MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME, + &gEfiCallerIdGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(MicrocodeFmpPrivate->LastAttempt), + &MicrocodeFmpPrivate->LastAttempt + ); + DEBUG((DEBUG_INFO, "SetLastAttemp - %r\n", VarStatus)); + + if (!EFI_ERROR(Status)) { + InitializeMicrocodeDescriptor(MicrocodeFmpPrivate); + DumpPrivateInfo (MicrocodeFmpPrivate); + } + + return Status; +} + +/** + Checks if the firmware image is valid for the device. + + This function allows firmware update application to validate the firmware image without + invoking the SetImage() first. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in] Image Points to the new image. + @param[in] ImageSize Size of the new image in bytes. + @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides, + if available, additional information if the image is invalid. + + @retval EFI_SUCCESS The image was successfully checked. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpCheckImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN CONST VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *ImageUpdatable + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Returns information about the firmware package. + + This function returns package information. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[out] PackageVersion A version number that represents all the firmware images in the device. + The format is vendor specific and new version must have a greater value + than the old version. If PackageVersion is not supported, the value is + 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version + comparison is to be performed using PackageVersionName. A value of + 0xFFFFFFFD indicates that package version update is in progress. + @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing + the package version name. The buffer is allocated by this function with + AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of + package version name. A value of 0 indicates the device does not support + update of package version name. Length is the number of Unicode characters, + including the terminating null character. + @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute + Definitions' for possible returned values of this parameter. A value of 1 + indicates the attribute is supported and the current setting value is + indicated in AttributesSetting. A value of 0 indicates the attribute is not + supported and the current setting value in AttributesSetting is meaningless. + @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned + values of this parameter + + @retval EFI_SUCCESS The package information was successfully returned. + @retval EFI_UNSUPPORTED The operation is not supported. + +**/ +EFI_STATUS +EFIAPI +FmpGetPackageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + OUT UINT32 *PackageVersion, + OUT CHAR16 **PackageVersionName, + OUT UINT32 *PackageVersionNameMaxLen, + OUT UINT64 *AttributesSupported, + OUT UINT64 *AttributesSetting + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Updates information about the firmware package. + + This function updates package information. + This function returns EFI_UNSUPPORTED if the package information is not updatable. + VendorCode enables vendor to implement vendor-specific package information update policy. + Null if the caller did not specify this policy or use the default policy. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] Image Points to the authentication image. + Null if authentication is not required. + @param[in] ImageSize Size of the authentication image in bytes. + 0 if authentication is not required. + @param[in] VendorCode This enables vendor to implement vendor-specific firmware + image update policy. + Null indicates the caller did not specify this policy or use + the default policy. + @param[in] PackageVersion The new package version. + @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing + the package version name. + The string length is equal to or less than the value returned in + PackageVersionNameMaxLen. + + @retval EFI_SUCCESS The device was successfully updated with the new package + information. + @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value + returned in PackageVersionNameMaxLen. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpSetPackageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN CONST VOID *Image, + IN UINTN ImageSize, + IN CONST VOID *VendorCode, + IN UINT32 PackageVersion, + IN CONST CHAR16 *PackageVersionName + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Initialize Processor Microcode Index. + + @param[in] MicrocodeFmpPrivate private data structure to be initialized. +**/ +VOID +InitializedProcessorMicrocodeIndex ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + UINTN CpuIndex; + UINTN MicrocodeIndex; + UINTN TargetCpuIndex; + UINT32 AttemptStatus; + EFI_STATUS Status; + + for (CpuIndex = 0; CpuIndex < MicrocodeFmpPrivate->ProcessorCount; CpuIndex++) { + if (MicrocodeFmpPrivate->ProcessorInfo[CpuIndex].MicrocodeIndex != (UINTN)-1) { + continue; + } + for (MicrocodeIndex = 0; MicrocodeIndex < MicrocodeFmpPrivate->DescriptorCount; MicrocodeIndex++) { + if (!MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].InUse) { + continue; + } + TargetCpuIndex = CpuIndex; + Status = VerifyMicrocode( + MicrocodeFmpPrivate, + MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].MicrocodeEntryPoint, + MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].TotalSize, + FALSE, + &AttemptStatus, + NULL, + &TargetCpuIndex + ); + if (!EFI_ERROR(Status)) { + MicrocodeFmpPrivate->ProcessorInfo[CpuIndex].MicrocodeIndex = MicrocodeIndex; + } + } + } +} + +/** + Initialize Microcode Descriptor. + + @param[in] MicrocodeFmpPrivate private data structure to be initialized. + + @return EFI_SUCCESS Microcode Descriptor is initialized. +**/ +EFI_STATUS +InitializeMicrocodeDescriptor ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + UINT8 CurrentMicrocodeCount; + + CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo (MicrocodeFmpPrivate, 0, NULL, NULL); + + if (CurrentMicrocodeCount > MicrocodeFmpPrivate->DescriptorCount) { + if (MicrocodeFmpPrivate->ImageDescriptor != NULL) { + FreePool(MicrocodeFmpPrivate->ImageDescriptor); + MicrocodeFmpPrivate->ImageDescriptor = NULL; + } + if (MicrocodeFmpPrivate->MicrocodeInfo != NULL) { + FreePool(MicrocodeFmpPrivate->MicrocodeInfo); + MicrocodeFmpPrivate->MicrocodeInfo = NULL; + } + } else { + ZeroMem(MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR)); + ZeroMem(MicrocodeFmpPrivate->MicrocodeInfo, MicrocodeFmpPrivate->DescriptorCount * sizeof(MICROCODE_INFO)); + } + + MicrocodeFmpPrivate->DescriptorCount = CurrentMicrocodeCount; + + if (MicrocodeFmpPrivate->ImageDescriptor == NULL) { + MicrocodeFmpPrivate->ImageDescriptor = AllocateZeroPool(MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR)); + if (MicrocodeFmpPrivate->ImageDescriptor == NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + if (MicrocodeFmpPrivate->MicrocodeInfo == NULL) { + MicrocodeFmpPrivate->MicrocodeInfo = AllocateZeroPool(MicrocodeFmpPrivate->DescriptorCount * sizeof(MICROCODE_INFO)); + if (MicrocodeFmpPrivate->MicrocodeInfo == NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + + CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo (MicrocodeFmpPrivate, MicrocodeFmpPrivate->DescriptorCount, MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->MicrocodeInfo); + ASSERT(CurrentMicrocodeCount == MicrocodeFmpPrivate->DescriptorCount); + + InitializedProcessorMicrocodeIndex (MicrocodeFmpPrivate); + + return EFI_SUCCESS; +} + +/** + Initialize MicrocodeFmpDriver multiprocessor information. + + @param[in] MicrocodeFmpPrivate private data structure to be initialized. + + @return EFI_SUCCESS private data is initialized. +**/ +EFI_STATUS +InitializeProcessorInfo ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpService; + UINTN NumberOfProcessors; + UINTN NumberOfEnabledProcessors; + UINTN Index; + UINTN BspIndex; + + Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService); + ASSERT_EFI_ERROR(Status); + + MicrocodeFmpPrivate->MpService = MpService; + MicrocodeFmpPrivate->ProcessorCount = 0; + MicrocodeFmpPrivate->ProcessorInfo = NULL; + + Status = MpService->GetNumberOfProcessors (MpService, &NumberOfProcessors, &NumberOfEnabledProcessors); + ASSERT_EFI_ERROR(Status); + MicrocodeFmpPrivate->ProcessorCount = NumberOfProcessors; + + Status = MpService->WhoAmI (MpService, &BspIndex); + ASSERT_EFI_ERROR(Status); + MicrocodeFmpPrivate->BspIndex = BspIndex; + + MicrocodeFmpPrivate->ProcessorInfo = AllocateZeroPool (sizeof(PROCESSOR_INFO) * MicrocodeFmpPrivate->ProcessorCount); + if (MicrocodeFmpPrivate->ProcessorInfo == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (Index = 0; Index < NumberOfProcessors; Index++) { + MicrocodeFmpPrivate->ProcessorInfo[Index].CpuIndex = Index; + MicrocodeFmpPrivate->ProcessorInfo[Index].MicrocodeIndex = (UINTN)-1; + if (Index == BspIndex) { + CollectProcessorInfo (&MicrocodeFmpPrivate->ProcessorInfo[Index]); + } else { + Status = MpService->StartupThisAP ( + MpService, + CollectProcessorInfo, + Index, + NULL, + 0, + &MicrocodeFmpPrivate->ProcessorInfo[Index], + NULL + ); + ASSERT_EFI_ERROR(Status); + } + } + + return EFI_SUCCESS; +} + +/** + Dump private information. + + @param[in] MicrocodeFmpPrivate private data structure. +**/ +VOID +DumpPrivateInfo ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + UINTN Index; + PROCESSOR_INFO *ProcessorInfo; + MICROCODE_INFO *MicrocodeInfo; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor; + + DEBUG ((DEBUG_INFO, "ProcessorInfo:\n")); + DEBUG ((DEBUG_INFO, " ProcessorCount - 0x%x\n", MicrocodeFmpPrivate->ProcessorCount)); + DEBUG ((DEBUG_INFO, " BspIndex - 0x%x\n", MicrocodeFmpPrivate->BspIndex)); + + ProcessorInfo = MicrocodeFmpPrivate->ProcessorInfo; + for (Index = 0; Index < MicrocodeFmpPrivate->ProcessorCount; Index++) { + DEBUG (( + DEBUG_INFO, + " ProcessorInfo[0x%x] - 0x%08x, 0x%02x, 0x%08x, (0x%x)\n", + ProcessorInfo[Index].CpuIndex, + ProcessorInfo[Index].ProcessorSignature, + ProcessorInfo[Index].PlatformId, + ProcessorInfo[Index].MicrocodeRevision, + ProcessorInfo[Index].MicrocodeIndex + )); + } + + DEBUG ((DEBUG_INFO, "MicrocodeInfo:\n")); + MicrocodeInfo = MicrocodeFmpPrivate->MicrocodeInfo; + DEBUG ((DEBUG_INFO, " MicrocodeRegion - 0x%x - 0x%x\n", MicrocodeFmpPrivate->MicrocodePatchAddress, MicrocodeFmpPrivate->MicrocodePatchRegionSize)); + DEBUG ((DEBUG_INFO, " MicrocodeCount - 0x%x\n", MicrocodeFmpPrivate->DescriptorCount)); + for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { + DEBUG (( + DEBUG_INFO, + " MicrocodeInfo[0x%x] - 0x%08x, 0x%08x, (0x%x)\n", + Index, + MicrocodeInfo[Index].MicrocodeEntryPoint, + MicrocodeInfo[Index].TotalSize, + MicrocodeInfo[Index].InUse + )); + } + + ImageDescriptor = MicrocodeFmpPrivate->ImageDescriptor; + DEBUG ((DEBUG_VERBOSE, "ImageDescriptor:\n")); + for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { + DEBUG((DEBUG_VERBOSE, " ImageDescriptor (%d)\n", Index)); + DEBUG((DEBUG_VERBOSE, " ImageIndex - 0x%x\n", ImageDescriptor[Index].ImageIndex)); + DEBUG((DEBUG_VERBOSE, " ImageTypeId - %g\n", &ImageDescriptor[Index].ImageTypeId)); + DEBUG((DEBUG_VERBOSE, " ImageId - 0x%lx\n", ImageDescriptor[Index].ImageId)); + DEBUG((DEBUG_VERBOSE, " ImageIdName - %s\n", ImageDescriptor[Index].ImageIdName)); + DEBUG((DEBUG_VERBOSE, " Version - 0x%x\n", ImageDescriptor[Index].Version)); + DEBUG((DEBUG_VERBOSE, " VersionName - %s\n", ImageDescriptor[Index].VersionName)); + DEBUG((DEBUG_VERBOSE, " Size - 0x%x\n", ImageDescriptor[Index].Size)); + DEBUG((DEBUG_VERBOSE, " AttributesSupported - 0x%lx\n", ImageDescriptor[Index].AttributesSupported)); + DEBUG((DEBUG_VERBOSE, " AttributesSetting - 0x%lx\n", ImageDescriptor[Index].AttributesSetting)); + DEBUG((DEBUG_VERBOSE, " Compatibilities - 0x%lx\n", ImageDescriptor[Index].Compatibilities)); + DEBUG((DEBUG_VERBOSE, " LowestSupportedImageVersion - 0x%x\n", ImageDescriptor[Index].LowestSupportedImageVersion)); + DEBUG((DEBUG_VERBOSE, " LastAttemptVersion - 0x%x\n", ImageDescriptor[Index].LastAttemptVersion)); + DEBUG((DEBUG_VERBOSE, " LastAttemptStatus - 0x%x\n", ImageDescriptor[Index].LastAttemptStatus)); + DEBUG((DEBUG_VERBOSE, " HardwareInstance - 0x%lx\n", ImageDescriptor[Index].HardwareInstance)); + } +} + +/** + Initialize MicrocodeFmpDriver private data structure. + + @param[in] MicrocodeFmpPrivate private data structure to be initialized. + + @return EFI_SUCCESS private data is initialized. +**/ +EFI_STATUS +InitializePrivateData ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + EFI_STATUS Status; + EFI_STATUS VarStatus; + UINTN VarSize; + BOOLEAN Result; + + MicrocodeFmpPrivate->Signature = MICROCODE_FMP_PRIVATE_DATA_SIGNATURE; + MicrocodeFmpPrivate->Handle = NULL; + CopyMem(&MicrocodeFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof(EFI_FIRMWARE_MANAGEMENT_PROTOCOL)); + + MicrocodeFmpPrivate->PackageVersion = 0x1; + MicrocodeFmpPrivate->PackageVersionName = L"Microcode"; + + MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion = 0x0; + MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus = 0x0; + VarSize = sizeof(MicrocodeFmpPrivate->LastAttempt); + VarStatus = gRT->GetVariable( + MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME, + &gEfiCallerIdGuid, + NULL, + &VarSize, + &MicrocodeFmpPrivate->LastAttempt + ); + DEBUG((DEBUG_INFO, "GetLastAttemp - %r\n", VarStatus)); + DEBUG((DEBUG_INFO, "GetLastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus)); + + Result = GetMicrocodeRegion(&MicrocodeFmpPrivate->MicrocodePatchAddress, &MicrocodeFmpPrivate->MicrocodePatchRegionSize); + if (!Result) { + DEBUG((DEBUG_ERROR, "Fail to get Microcode Region\n")); + return EFI_NOT_FOUND; + } + + Status = InitializeProcessorInfo (MicrocodeFmpPrivate); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "InitializeProcessorInfo - %r\n", Status)); + return Status; + } + + Status = InitializeMicrocodeDescriptor(MicrocodeFmpPrivate); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "InitializeMicrocodeDescriptor - %r\n", Status)); + return Status; + } + + DumpPrivateInfo (MicrocodeFmpPrivate); + + return Status; +} + +/** + Microcode FMP module entrypoint + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @return EFI_SUCCESS Microcode FMP module is initialized. +**/ +EFI_STATUS +EFIAPI +MicrocodeFmpMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Initialize MicrocodeFmpPrivateData + // + mMicrocodeFmpPrivate = AllocateZeroPool (sizeof(MICROCODE_FMP_PRIVATE_DATA)); + if (mMicrocodeFmpPrivate == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = InitializePrivateData(mMicrocodeFmpPrivate); + if (EFI_ERROR(Status)) { + FreePool(mMicrocodeFmpPrivate); + mMicrocodeFmpPrivate = NULL; + return Status; + } + + // + // Install FMP protocol. + // + Status = gBS->InstallProtocolInterface ( + &mMicrocodeFmpPrivate->Handle, + &gEfiFirmwareManagementProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMicrocodeFmpPrivate->Fmp + ); + if (EFI_ERROR (Status)) { + FreePool(mMicrocodeFmpPrivate); + mMicrocodeFmpPrivate = NULL; + return Status; + } + + return Status; +} diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c new file mode 100644 index 0000000000..4e8f1d5fd8 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c @@ -0,0 +1,981 @@ +/** @file + SetImage instance to update Microcode. + + Caution: This module requires additional review when modified. + This module will have external input - capsule image. + This external input must be validated carefully to avoid security issue like + buffer overflow, integer overflow. + + MicrocodeWrite() and VerifyMicrocode() will receive untrusted input and do basic validation. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MicrocodeUpdate.h" + +/** + Get Microcode Region. + + @param[out] MicrocodePatchAddress The address of Microcode + @param[out] MicrocodePatchRegionSize The region size of Microcode + + @retval TRUE The Microcode region is returned. + @retval FALSE No Microcode region. +**/ +BOOLEAN +GetMicrocodeRegion ( + OUT VOID **MicrocodePatchAddress, + OUT UINTN *MicrocodePatchRegionSize + ) +{ + *MicrocodePatchAddress = (VOID *)(UINTN)PcdGet64(PcdCpuMicrocodePatchAddress); + *MicrocodePatchRegionSize = (UINTN)PcdGet64(PcdCpuMicrocodePatchRegionSize); + + if ((*MicrocodePatchAddress == NULL) || (*MicrocodePatchRegionSize == 0)) { + return FALSE; + } + + return TRUE; +} + +/** + Get Microcode update signature of currently loaded Microcode update. + + @return Microcode signature. + +**/ +UINT32 +GetCurrentMicrocodeSignature ( + VOID + ) +{ + UINT64 Signature; + + AsmWriteMsr64(MSR_IA32_BIOS_SIGN_ID, 0); + AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, NULL); + Signature = AsmReadMsr64(MSR_IA32_BIOS_SIGN_ID); + return (UINT32)RShiftU64(Signature, 32); +} + +/** + Get current processor signature. + + @return current processor signature. +**/ +UINT32 +GetCurrentProcessorSignature ( + VOID + ) +{ + UINT32 RegEax; + AsmCpuid(CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL); + return RegEax; +} + +/** + Get current platform ID. + + @return current platform ID. +**/ +UINT8 +GetCurrentPlatformId ( + VOID + ) +{ + UINT8 PlatformId; + + PlatformId = (UINT8)AsmMsrBitFieldRead64(MSR_IA32_PLATFORM_ID, 50, 52); + return PlatformId; +} + +/** + Load new Microcode. + + @param[in] Address The address of new Microcode. + + @return Loaded Microcode signature. + +**/ +UINT32 +LoadMicrocode ( + IN UINT64 Address + ) +{ + AsmWriteMsr64(MSR_IA32_BIOS_UPDT_TRIG, Address); + return GetCurrentMicrocodeSignature(); +} + +/** + Load Microcode on an Application Processor. + The function prototype for invoking a function on an Application Processor. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +MicrocodeLoadAp ( + IN OUT VOID *Buffer + ) +{ + MICROCODE_LOAD_BUFFER *MicrocodeLoadBuffer; + + MicrocodeLoadBuffer = Buffer; + MicrocodeLoadBuffer->Revision = LoadMicrocode (MicrocodeLoadBuffer->Address); +} + +/** + Load new Microcode on this processor + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] CpuIndex The index of the processor. + @param[in] Address The address of new Microcode. + + @return Loaded Microcode signature. + +**/ +UINT32 +LoadMicrocodeOnThis ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN UINTN CpuIndex, + IN UINT64 Address + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpService; + MICROCODE_LOAD_BUFFER MicrocodeLoadBuffer; + + if (CpuIndex == MicrocodeFmpPrivate->BspIndex) { + return LoadMicrocode (Address); + } else { + MpService = MicrocodeFmpPrivate->MpService; + MicrocodeLoadBuffer.Address = Address; + MicrocodeLoadBuffer.Revision = 0; + Status = MpService->StartupThisAP ( + MpService, + MicrocodeLoadAp, + CpuIndex, + NULL, + 0, + &MicrocodeLoadBuffer, + NULL + ); + ASSERT_EFI_ERROR(Status); + return MicrocodeLoadBuffer.Revision; + } +} + +/** + Collect processor information. + The function prototype for invoking a function on an Application Processor. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +CollectProcessorInfo ( + IN OUT VOID *Buffer + ) +{ + PROCESSOR_INFO *ProcessorInfo; + + ProcessorInfo = Buffer; + ProcessorInfo->ProcessorSignature = GetCurrentProcessorSignature(); + ProcessorInfo->PlatformId = GetCurrentPlatformId(); + ProcessorInfo->MicrocodeRevision = GetCurrentMicrocodeSignature(); +} + +/** + Get current Microcode information. + + The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo) + in MicrocodeFmpPrivate must be initialized. + + The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo) + in MicrocodeFmpPrivate may not be avaiable in this function. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] DescriptorCount The count of Microcode ImageDescriptor allocated. + @param[out] ImageDescriptor Microcode ImageDescriptor + @param[out] MicrocodeInfo Microcode information + + @return Microcode count +**/ +UINTN +GetMicrocodeInfo ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN UINTN DescriptorCount, OPTIONAL + OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor, OPTIONAL + OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL + ) +{ + VOID *MicrocodePatchAddress; + UINTN MicrocodePatchRegionSize; + CPU_MICROCODE_HEADER *MicrocodeEntryPoint; + UINTN MicrocodeEnd; + UINTN TotalSize; + UINTN Count; + UINT64 ImageAttributes; + BOOLEAN IsInUse; + EFI_STATUS Status; + UINT32 AttemptStatus; + UINTN TargetCpuIndex; + + MicrocodePatchAddress = MicrocodeFmpPrivate->MicrocodePatchAddress; + MicrocodePatchRegionSize = MicrocodeFmpPrivate->MicrocodePatchRegionSize; + + DEBUG((DEBUG_INFO, "Microcode Region - 0x%x - 0x%x\n", MicrocodePatchAddress, MicrocodePatchRegionSize)); + + Count = 0; + + MicrocodeEnd = (UINTN)MicrocodePatchAddress + MicrocodePatchRegionSize; + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) MicrocodePatchAddress; + do { + if (MicrocodeEntryPoint->HeaderVersion == 0x1 && MicrocodeEntryPoint->LoaderRevision == 0x1) { + // + // It is the microcode header. It is not the padding data between microcode patches + // becasue the padding data should not include 0x00000001 and it should be the repeated + // byte format (like 0xXYXYXYXY....). + // + if (MicrocodeEntryPoint->DataSize == 0) { + TotalSize = 2048; + } else { + TotalSize = MicrocodeEntryPoint->TotalSize; + } + + TargetCpuIndex = (UINTN)-1; + Status = VerifyMicrocode(MicrocodeFmpPrivate, MicrocodeEntryPoint, TotalSize, FALSE, &AttemptStatus, NULL, &TargetCpuIndex); + if (!EFI_ERROR(Status)) { + IsInUse = TRUE; + ASSERT (TargetCpuIndex < MicrocodeFmpPrivate->ProcessorCount); + MicrocodeFmpPrivate->ProcessorInfo[TargetCpuIndex].MicrocodeIndex = Count; + } else { + IsInUse = FALSE; + } + + if (ImageDescriptor != NULL && DescriptorCount > Count) { + ImageDescriptor[Count].ImageIndex = (UINT8)(Count + 1); + CopyGuid (&ImageDescriptor[Count].ImageTypeId, &gMicrocodeFmpImageTypeIdGuid); + ImageDescriptor[Count].ImageId = LShiftU64(MicrocodeEntryPoint->ProcessorFlags, 32) + MicrocodeEntryPoint->ProcessorSignature.Uint32; + ImageDescriptor[Count].ImageIdName = NULL; + ImageDescriptor[Count].Version = MicrocodeEntryPoint->UpdateRevision; + ImageDescriptor[Count].VersionName = NULL; + ImageDescriptor[Count].Size = TotalSize; + ImageAttributes = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | IMAGE_ATTRIBUTE_RESET_REQUIRED; + if (IsInUse) { + ImageAttributes |= IMAGE_ATTRIBUTE_IN_USE; + } + ImageDescriptor[Count].AttributesSupported = ImageAttributes | IMAGE_ATTRIBUTE_IN_USE; + ImageDescriptor[Count].AttributesSetting = ImageAttributes; + ImageDescriptor[Count].Compatibilities = 0; + ImageDescriptor[Count].LowestSupportedImageVersion = MicrocodeEntryPoint->UpdateRevision; // do not support rollback + ImageDescriptor[Count].LastAttemptVersion = 0; + ImageDescriptor[Count].LastAttemptStatus = 0; + ImageDescriptor[Count].HardwareInstance = 0; + } + if (MicrocodeInfo != NULL && DescriptorCount > Count) { + MicrocodeInfo[Count].MicrocodeEntryPoint = MicrocodeEntryPoint; + MicrocodeInfo[Count].TotalSize = TotalSize; + MicrocodeInfo[Count].InUse = IsInUse; + } + } else { + // + // It is the padding data between the microcode patches for microcode patches alignment. + // Because the microcode patch is the multiple of 1-KByte, the padding data should not + // exist if the microcode patch alignment value is not larger than 1-KByte. So, the microcode + // alignment value should be larger than 1-KByte. We could skip SIZE_1KB padding data to + // find the next possible microcode patch header. + // + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + SIZE_1KB); + continue; + } + + Count++; + ASSERT(Count < 0xFF); + + // + // Get the next patch. + // + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + TotalSize); + } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd)); + + return Count; +} + +/** + Return matched processor information. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] ProcessorSignature The processor signature to be matched + @param[in] ProcessorFlags The processor flags to be matched + @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. + On output, the index of target CPU which matches the Microcode. + + @return matched processor information. +**/ +PROCESSOR_INFO * +GetMatchedProcessor ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN UINT32 ProcessorSignature, + IN UINT32 ProcessorFlags, + IN OUT UINTN *TargetCpuIndex + ) +{ + UINTN Index; + + if (*TargetCpuIndex != (UINTN)-1) { + Index = *TargetCpuIndex; + if ((ProcessorSignature == MicrocodeFmpPrivate->ProcessorInfo[Index].ProcessorSignature) && + ((ProcessorFlags & (1 << MicrocodeFmpPrivate->ProcessorInfo[Index].PlatformId)) != 0)) { + return &MicrocodeFmpPrivate->ProcessorInfo[Index]; + } else { + return NULL; + } + } + + for (Index = 0; Index < MicrocodeFmpPrivate->ProcessorCount; Index++) { + if ((ProcessorSignature == MicrocodeFmpPrivate->ProcessorInfo[Index].ProcessorSignature) && + ((ProcessorFlags & (1 << MicrocodeFmpPrivate->ProcessorInfo[Index].PlatformId)) != 0)) { + *TargetCpuIndex = Index; + return &MicrocodeFmpPrivate->ProcessorInfo[Index]; + } + } + return NULL; +} + +/** + Verify Microcode. + + Caution: This function may receive untrusted input. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[in] TryLoad Try to load Microcode or not. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. + On output, the index of target CPU which matches the Microcode. + + @retval EFI_SUCCESS The Microcode image passes verification. + @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. + @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. + @retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect. + @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. +**/ +EFI_STATUS +VerifyMicrocode ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN VOID *Image, + IN UINTN ImageSize, + IN BOOLEAN TryLoad, + OUT UINT32 *LastAttemptStatus, + OUT CHAR16 **AbortReason, OPTIONAL + IN OUT UINTN *TargetCpuIndex + ) +{ + UINTN Index; + CPU_MICROCODE_HEADER *MicrocodeEntryPoint; + UINTN TotalSize; + UINTN DataSize; + UINT32 CurrentRevision; + PROCESSOR_INFO *ProcessorInfo; + UINT32 CheckSum32; + UINTN ExtendedTableLength; + UINT32 ExtendedTableCount; + CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; + CPU_MICROCODE_EXTENDED_TABLE_HEADER *ExtendedTableHeader; + BOOLEAN CorrectMicrocode; + + // + // Check HeaderVersion + // + MicrocodeEntryPoint = Image; + if (MicrocodeEntryPoint->HeaderVersion != 0x1) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on HeaderVersion\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidHeaderVersion"), L"InvalidHeaderVersion"); + } + return EFI_INCOMPATIBLE_VERSION; + } + // + // Check LoaderRevision + // + if (MicrocodeEntryPoint->LoaderRevision != 0x1) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on LoaderRevision\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidLoaderVersion"), L"InvalidLoaderVersion"); + } + return EFI_INCOMPATIBLE_VERSION; + } + // + // Check Size + // + if (MicrocodeEntryPoint->DataSize == 0) { + TotalSize = 2048; + } else { + TotalSize = MicrocodeEntryPoint->TotalSize; + } + if (TotalSize <= sizeof(CPU_MICROCODE_HEADER)) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize too small\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize"); + } + return EFI_VOLUME_CORRUPTED; + } + if (TotalSize != ImageSize) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize"); + } + return EFI_VOLUME_CORRUPTED; + } + // + // Check CheckSum32 + // + if (MicrocodeEntryPoint->DataSize == 0) { + DataSize = 2048 - sizeof(CPU_MICROCODE_HEADER); + } else { + DataSize = MicrocodeEntryPoint->DataSize; + } + if (DataSize > TotalSize - sizeof(CPU_MICROCODE_HEADER)) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize too big\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidDataSize"), L"InvalidDataSize"); + } + return EFI_VOLUME_CORRUPTED; + } + if ((DataSize & 0x3) != 0) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize not aligned\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidDataSize"), L"InvalidDataSize"); + } + return EFI_VOLUME_CORRUPTED; + } + CheckSum32 = CalculateSum32((UINT32 *)MicrocodeEntryPoint, DataSize + sizeof(CPU_MICROCODE_HEADER)); + if (CheckSum32 != 0) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CheckSum32\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidChecksum"), L"InvalidChecksum"); + } + return EFI_VOLUME_CORRUPTED; + } + + // + // Check ProcessorSignature/ProcessorFlags + // + + ProcessorInfo = GetMatchedProcessor (MicrocodeFmpPrivate, MicrocodeEntryPoint->ProcessorSignature.Uint32, MicrocodeEntryPoint->ProcessorFlags, TargetCpuIndex); + if (ProcessorInfo == NULL) { + CorrectMicrocode = FALSE; + ExtendedTableLength = TotalSize - (DataSize + sizeof(CPU_MICROCODE_HEADER)); + if (ExtendedTableLength != 0) { + // + // Extended Table exist, check if the CPU in support list + // + ExtendedTableHeader = (CPU_MICROCODE_EXTENDED_TABLE_HEADER *)((UINT8 *)(MicrocodeEntryPoint) + DataSize + sizeof(CPU_MICROCODE_HEADER)); + // + // Calculate Extended Checksum + // + if ((ExtendedTableLength > sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) && ((ExtendedTableLength & 0x3) != 0)) { + CheckSum32 = CalculateSum32((UINT32 *)ExtendedTableHeader, ExtendedTableLength); + if (CheckSum32 == 0) { + // + // Checksum correct + // + ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; + if (ExtendedTableCount <= (ExtendedTableLength - sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) / sizeof(CPU_MICROCODE_EXTENDED_TABLE)) { + ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *)(ExtendedTableHeader + 1); + for (Index = 0; Index < ExtendedTableCount; Index++) { + CheckSum32 = CalculateSum32((UINT32 *)ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); + if (CheckSum32 == 0) { + // + // Verify Header + // + ProcessorInfo = GetMatchedProcessor (MicrocodeFmpPrivate, ExtendedTable->ProcessorSignature.Uint32, ExtendedTable->ProcessorFlag, TargetCpuIndex); + if (ProcessorInfo != NULL) { + // + // Find one + // + CorrectMicrocode = TRUE; + break; + } + } + ExtendedTable++; + } + } + } + } + } + if (!CorrectMicrocode) { + if (TryLoad) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CurrentProcessorSignature/ProcessorFlags\n")); + } + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"UnsupportedProcessSignature/ProcessorFlags"), L"UnsupportedProcessSignature/ProcessorFlags"); + } + return EFI_UNSUPPORTED; + } + } + + // + // Check UpdateRevision + // + CurrentRevision = ProcessorInfo->MicrocodeRevision; + if ((MicrocodeEntryPoint->UpdateRevision < CurrentRevision) || + (TryLoad && (MicrocodeEntryPoint->UpdateRevision == CurrentRevision))) { + if (TryLoad) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on UpdateRevision\n")); + } + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"IncorrectRevision"), L"IncorrectRevision"); + } + return EFI_INCOMPATIBLE_VERSION; + } + + // + // try load MCU + // + if (TryLoad) { + CurrentRevision = LoadMicrocodeOnThis(MicrocodeFmpPrivate, ProcessorInfo->CpuIndex, (UINTN)MicrocodeEntryPoint + sizeof(CPU_MICROCODE_HEADER)); + if (MicrocodeEntryPoint->UpdateRevision != CurrentRevision) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on LoadMicrocode\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR; + if (AbortReason != NULL) { + *AbortReason = AllocateCopyPool(sizeof(L"InvalidData"), L"InvalidData"); + } + return EFI_SECURITY_VIOLATION; + } + } + + return EFI_SUCCESS; +} + +/** + Get next Microcode entrypoint. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] MicrocodeEntryPoint Current Microcode entrypoint + + @return next Microcode entrypoint. +**/ +CPU_MICROCODE_HEADER * +GetNextMicrocode ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN CPU_MICROCODE_HEADER *MicrocodeEntryPoint + ) +{ + UINTN Index; + + for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { + if (MicrocodeEntryPoint == MicrocodeFmpPrivate->MicrocodeInfo[Index].MicrocodeEntryPoint) { + if (Index == (UINTN)MicrocodeFmpPrivate->DescriptorCount - 1) { + // it is last one + return NULL; + } else { + // return next one + return MicrocodeFmpPrivate->MicrocodeInfo[Index + 1].MicrocodeEntryPoint; + } + } + } + + ASSERT(FALSE); + return NULL; +} + +/** + Get current Microcode used region size. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + + @return current Microcode used region size. +**/ +UINTN +GetCurrentMicrocodeUsedRegionSize ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ) +{ + if (MicrocodeFmpPrivate->DescriptorCount == 0) { + return 0; + } + + return (UINTN)MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeFmpPrivate->DescriptorCount - 1].MicrocodeEntryPoint + + (UINTN)MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeFmpPrivate->DescriptorCount - 1].TotalSize + - (UINTN)MicrocodeFmpPrivate->MicrocodePatchAddress; +} + +/** + Update Microcode. + + @param[in] Address The flash address of Microcode. + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + + @retval EFI_SUCCESS The Microcode image is updated. + @retval EFI_WRITE_PROTECTED The flash device is read only. +**/ +EFI_STATUS +UpdateMicrocode ( + IN UINT64 Address, + IN VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *LastAttemptStatus + ) +{ + EFI_STATUS Status; + + DEBUG((DEBUG_INFO, "PlatformUpdate:")); + DEBUG((DEBUG_INFO, " Address - 0x%lx,", Address)); + DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ImageSize)); + + Status = MicrocodeFlashWrite ( + Address, + Image, + ImageSize + ); + if (!EFI_ERROR(Status)) { + *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS; + } else { + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; + } + return Status; +} + +/** + Update Microcode flash region. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] TargetMicrocodeEntryPoint Target Microcode entrypoint to be updated + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + + @retval EFI_SUCCESS The Microcode image is written. + @retval EFI_WRITE_PROTECTED The flash device is read only. +**/ +EFI_STATUS +UpdateMicrocodeFlashRegion ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN CPU_MICROCODE_HEADER *TargetMicrocodeEntryPoint, + IN VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *LastAttemptStatus + ) +{ + VOID *MicrocodePatchAddress; + UINTN MicrocodePatchRegionSize; + UINTN TargetTotalSize; + UINTN UsedRegionSize; + EFI_STATUS Status; + VOID *MicrocodePatchScratchBuffer; + UINT8 *ScratchBufferPtr; + UINTN ScratchBufferSize; + UINTN RestSize; + UINTN AvailableSize; + VOID *NextMicrocodeEntryPoint; + MICROCODE_INFO *MicrocodeInfo; + UINTN MicrocodeCount; + UINTN Index; + + DEBUG((DEBUG_INFO, "UpdateMicrocodeFlashRegion: Image - 0x%x, size - 0x%x\n", Image, ImageSize)); + + MicrocodePatchAddress = MicrocodeFmpPrivate->MicrocodePatchAddress; + MicrocodePatchRegionSize = MicrocodeFmpPrivate->MicrocodePatchRegionSize; + + MicrocodePatchScratchBuffer = AllocateZeroPool (MicrocodePatchRegionSize); + if (MicrocodePatchScratchBuffer == NULL) { + DEBUG((DEBUG_ERROR, "Fail to allocate Microcode Scratch buffer\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; + return EFI_OUT_OF_RESOURCES; + } + ScratchBufferPtr = MicrocodePatchScratchBuffer; + ScratchBufferSize = 0; + + // + // Target data collection + // + TargetTotalSize = 0; + AvailableSize = 0; + NextMicrocodeEntryPoint = NULL; + if (TargetMicrocodeEntryPoint != NULL) { + if (TargetMicrocodeEntryPoint->DataSize == 0) { + TargetTotalSize = 2048; + } else { + TargetTotalSize = TargetMicrocodeEntryPoint->TotalSize; + } + DEBUG((DEBUG_INFO, " TargetTotalSize - 0x%x\n", TargetTotalSize)); + NextMicrocodeEntryPoint = GetNextMicrocode(MicrocodeFmpPrivate, TargetMicrocodeEntryPoint); + DEBUG((DEBUG_INFO, " NextMicrocodeEntryPoint - 0x%x\n", NextMicrocodeEntryPoint)); + if (NextMicrocodeEntryPoint != NULL) { + ASSERT ((UINTN)NextMicrocodeEntryPoint >= ((UINTN)TargetMicrocodeEntryPoint + TargetTotalSize)); + AvailableSize = (UINTN)NextMicrocodeEntryPoint - (UINTN)TargetMicrocodeEntryPoint; + } else { + AvailableSize = (UINTN)MicrocodePatchAddress + MicrocodePatchRegionSize - (UINTN)TargetMicrocodeEntryPoint; + } + DEBUG((DEBUG_INFO, " AvailableSize - 0x%x\n", AvailableSize)); + } + ASSERT (AvailableSize >= TargetTotalSize); + UsedRegionSize = GetCurrentMicrocodeUsedRegionSize(MicrocodeFmpPrivate); + DEBUG((DEBUG_INFO, " UsedRegionSize - 0x%x\n", UsedRegionSize)); + ASSERT (UsedRegionSize >= TargetTotalSize); + if (TargetMicrocodeEntryPoint != NULL) { + ASSERT ((UINTN)MicrocodePatchAddress + UsedRegionSize >= ((UINTN)TargetMicrocodeEntryPoint + TargetTotalSize)); + } + // + // Total Size means the Microcode data size. + // Available Size means the Microcode data size plus the pad till (1) next Microcode or (2) the end. + // + // (1) + // +------+-----------+-----+------+===================+ + // | MCU1 | Microcode | PAD | MCU2 | Empty | + // +------+-----------+-----+------+===================+ + // | TotalSize | + // |<-AvailableSize->| + // |<- UsedRegionSize ->| + // + // (2) + // +------+-----------+===================+ + // | MCU | Microcode | Empty | + // +------+-----------+===================+ + // | TotalSize | + // |<- AvailableSize ->| + // |<-UsedRegionSize->| + // + + // + // Update based on policy + // + + // + // 1. If there is enough space to update old one in situ, replace old microcode in situ. + // + if (AvailableSize >= ImageSize) { + DEBUG((DEBUG_INFO, "Replace old microcode in situ\n")); + // + // +------+------------+------+===================+ + // |Other1| Old Image |Other2| Empty | + // +------+------------+------+===================+ + // + // +------+---------+--+------+===================+ + // |Other1|New Image|FF|Other2| Empty | + // +------+---------+--+------+===================+ + // + // 1.1. Copy new image + CopyMem (ScratchBufferPtr, Image, ImageSize); + ScratchBufferSize += ImageSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + // 1.2. Pad 0xFF + RestSize = AvailableSize - ImageSize; + if (RestSize > 0) { + SetMem (ScratchBufferPtr, RestSize, 0xFF); + ScratchBufferSize += RestSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + } + Status = UpdateMicrocode((UINTN)TargetMicrocodeEntryPoint, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); + return Status; + } + + // + // 2. If there is enough space to remove old one and add new one, reorg and replace old microcode. + // + if (MicrocodePatchRegionSize - (UsedRegionSize - TargetTotalSize) >= ImageSize) { + if (TargetMicrocodeEntryPoint == NULL) { + DEBUG((DEBUG_INFO, "Append new microcode\n")); + // + // +------+------------+------+===================+ + // |Other1| Other |Other2| Empty | + // +------+------------+------+===================+ + // + // +------+------------+------+-----------+=======+ + // |Other1| Other |Other2| New Image | Empty | + // +------+------------+------+-----------+=======+ + // + Status = UpdateMicrocode((UINTN)MicrocodePatchAddress + UsedRegionSize, Image, ImageSize, LastAttemptStatus); + } else { + DEBUG((DEBUG_INFO, "Reorg and replace old microcode\n")); + // + // +------+------------+------+===================+ + // |Other1| Old Image |Other2| Empty | + // +------+------------+------+===================+ + // + // +------+---------------+------+================+ + // |Other1| New Image |Other2| Empty | + // +------+---------------+------+================+ + // + // 2.1. Copy new image + CopyMem (ScratchBufferPtr, Image, ImageSize); + ScratchBufferSize += ImageSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + // 2.2. Copy rest images after the old image. + if (NextMicrocodeEntryPoint != 0) { + RestSize = (UINTN)MicrocodePatchAddress + UsedRegionSize - ((UINTN)NextMicrocodeEntryPoint); + CopyMem (ScratchBufferPtr, (UINT8 *)TargetMicrocodeEntryPoint + TargetTotalSize, RestSize); + ScratchBufferSize += RestSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + } + Status = UpdateMicrocode((UINTN)TargetMicrocodeEntryPoint, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); + } + return Status; + } + + // + // 3. The new image can be put in MCU region, but not all others can be put. + // So all the unused MCU is removed. + // + if (MicrocodePatchRegionSize >= ImageSize) { + // + // +------+------------+------+===================+ + // |Other1| Old Image |Other2| Empty | + // +------+------------+------+===================+ + // + // +-------------------------------------+--------+ + // | New Image | Other | + // +-------------------------------------+--------+ + // + DEBUG((DEBUG_INFO, "Add new microcode from beginning\n")); + + MicrocodeCount = MicrocodeFmpPrivate->DescriptorCount; + MicrocodeInfo = MicrocodeFmpPrivate->MicrocodeInfo; + + // 3.1. Copy new image + CopyMem (ScratchBufferPtr, Image, ImageSize); + ScratchBufferSize += ImageSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + // 3.2. Copy some others to rest buffer + for (Index = 0; Index < MicrocodeCount; Index++) { + if (!MicrocodeInfo[Index].InUse) { + continue; + } + if (MicrocodeInfo[Index].MicrocodeEntryPoint == TargetMicrocodeEntryPoint) { + continue; + } + if (MicrocodeInfo[Index].TotalSize <= MicrocodePatchRegionSize - ScratchBufferSize) { + CopyMem (ScratchBufferPtr, MicrocodeInfo[Index].MicrocodeEntryPoint, MicrocodeInfo[Index].TotalSize); + ScratchBufferSize += MicrocodeInfo[Index].TotalSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + } + } + // 3.3. Pad 0xFF + RestSize = MicrocodePatchRegionSize - ScratchBufferSize; + if (RestSize > 0) { + SetMem (ScratchBufferPtr, RestSize, 0xFF); + ScratchBufferSize += RestSize; + ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; + } + Status = UpdateMicrocode((UINTN)MicrocodePatchAddress, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); + return Status; + } + + // + // 4. The new image size is bigger than the whole MCU region. + // + DEBUG((DEBUG_ERROR, "Microcode too big\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + + return Status; +} + +/** + Write Microcode. + + Caution: This function may receive untrusted input. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + + @retval EFI_SUCCESS The Microcode image is written. + @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. + @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. + @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. + @retval EFI_WRITE_PROTECTED The flash device is read only. +**/ +EFI_STATUS +MicrocodeWrite ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *LastAttemptVersion, + OUT UINT32 *LastAttemptStatus, + OUT CHAR16 **AbortReason + ) +{ + EFI_STATUS Status; + VOID *AlignedImage; + CPU_MICROCODE_HEADER *TargetMicrocodeEntryPoint; + UINTN TargetCpuIndex; + UINTN TargetMicrcodeIndex; + + // + // MCU must be 16 bytes aligned + // + AlignedImage = AllocateCopyPool(ImageSize, Image); + if (AlignedImage == NULL) { + DEBUG((DEBUG_ERROR, "Fail to allocate aligned image\n")); + *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; + return EFI_OUT_OF_RESOURCES; + } + + *LastAttemptVersion = ((CPU_MICROCODE_HEADER *)Image)->UpdateRevision; + TargetCpuIndex = (UINTN)-1; + Status = VerifyMicrocode(MicrocodeFmpPrivate, AlignedImage, ImageSize, TRUE, LastAttemptStatus, AbortReason, &TargetCpuIndex); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "Fail to verify Microcode Region\n")); + FreePool(AlignedImage); + return Status; + } + DEBUG((DEBUG_INFO, "Pass VerifyMicrocode\n")); + + DEBUG((DEBUG_INFO, " TargetCpuIndex - 0x%x\n", TargetCpuIndex)); + ASSERT (TargetCpuIndex < MicrocodeFmpPrivate->ProcessorCount); + TargetMicrcodeIndex = MicrocodeFmpPrivate->ProcessorInfo[TargetCpuIndex].MicrocodeIndex; + DEBUG((DEBUG_INFO, " TargetMicrcodeIndex - 0x%x\n", TargetMicrcodeIndex)); + if (TargetMicrcodeIndex != (UINTN)-1) { + ASSERT (TargetMicrcodeIndex < MicrocodeFmpPrivate->DescriptorCount); + TargetMicrocodeEntryPoint = MicrocodeFmpPrivate->MicrocodeInfo[TargetMicrcodeIndex].MicrocodeEntryPoint; + } else { + TargetMicrocodeEntryPoint = NULL; + } + DEBUG((DEBUG_INFO, " TargetMicrocodeEntryPoint - 0x%x\n", TargetMicrocodeEntryPoint)); + + Status = UpdateMicrocodeFlashRegion( + MicrocodeFmpPrivate, + TargetMicrocodeEntryPoint, + AlignedImage, + ImageSize, + LastAttemptStatus + ); + + FreePool(AlignedImage); + + return Status; +} + + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h new file mode 100644 index 0000000000..9dc306324e --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h @@ -0,0 +1,494 @@ +/** @file + Microcode update header file. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _MICROCODE_FMP_H_ +#define _MICROCODE_FMP_H_ + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define MICROCODE_FMP_PRIVATE_DATA_SIGNATURE SIGNATURE_32('M', 'C', 'U', 'F') + +// +// Microcode FMP private data structure. +// + +typedef struct { + UINT32 LastAttemptVersion; + UINT32 LastAttemptStatus; +} MICROCODE_FMP_LAST_ATTEMPT_VARIABLE; + +typedef struct { + CPU_MICROCODE_HEADER *MicrocodeEntryPoint; + UINTN TotalSize; + BOOLEAN InUse; +} MICROCODE_INFO; + +typedef struct { + UINTN CpuIndex; + UINT32 ProcessorSignature; + UINT8 PlatformId; + UINT32 MicrocodeRevision; + UINTN MicrocodeIndex; +} PROCESSOR_INFO; + +typedef struct { + UINT64 Address; + UINT32 Revision; +} MICROCODE_LOAD_BUFFER; + +struct _MICROCODE_FMP_PRIVATE_DATA { + UINT32 Signature; + EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp; + EFI_HANDLE Handle; + VOID *MicrocodePatchAddress; + UINTN MicrocodePatchRegionSize; + UINT8 DescriptorCount; + EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor; + MICROCODE_INFO *MicrocodeInfo; + UINT32 PackageVersion; + CHAR16 *PackageVersionName; + MICROCODE_FMP_LAST_ATTEMPT_VARIABLE LastAttempt; + EFI_MP_SERVICES_PROTOCOL *MpService; + UINTN BspIndex; + UINTN ProcessorCount; + PROCESSOR_INFO *ProcessorInfo; +}; + +typedef struct _MICROCODE_FMP_PRIVATE_DATA MICROCODE_FMP_PRIVATE_DATA; + +#define MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME L"MicrocodeLastAttempVar" + +/** + Returns a pointer to the MICROCODE_FMP_PRIVATE_DATA structure from the input a as Fmp. + + If the signatures matches, then a pointer to the data structure that contains + a specified field of that data structure is returned. + + @param a Pointer to the field specified by ServiceBinding within + a data structure of type MICROCODE_FMP_PRIVATE_DATA. + +**/ +#define MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(a) \ + CR ( \ + (a), \ + MICROCODE_FMP_PRIVATE_DATA, \ + Fmp, \ + MICROCODE_FMP_PRIVATE_DATA_SIGNATURE \ + ) + +/** + Get Microcode Region. + + @param[out] MicrocodePatchAddress The address of Microcode + @param[out] MicrocodePatchRegionSize The region size of Microcode + + @retval TRUE The Microcode region is returned. + @retval FALSE No Microcode region. +**/ +BOOLEAN +GetMicrocodeRegion ( + OUT VOID **MicrocodePatchAddress, + OUT UINTN *MicrocodePatchRegionSize + ); + +/** + Collect processor information. + The function prototype for invoking a function on an Application Processor. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +CollectProcessorInfo ( + IN OUT VOID *Buffer + ); + +/** + Get current Microcode information. + + The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo) + in MicrocodeFmpPrivate must be initialized. + + The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo) + in MicrocodeFmpPrivate may not be avaiable in this function. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] DescriptorCount The count of Microcode ImageDescriptor allocated. + @param[out] ImageDescriptor Microcode ImageDescriptor + @param[out] MicrocodeInfo Microcode information + + @return Microcode count +**/ +UINTN +GetMicrocodeInfo ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN UINTN DescriptorCount, OPTIONAL + OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor, OPTIONAL + OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL + ); + +/** + Verify Microcode. + + Caution: This function may receive untrusted input. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[in] TryLoad Try to load Microcode or not. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. + On output, the index of target CPU which matches the Microcode. + + @retval EFI_SUCCESS The Microcode image passes verification. + @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. + @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. + @retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect. + @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. +**/ +EFI_STATUS +VerifyMicrocode ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN VOID *Image, + IN UINTN ImageSize, + IN BOOLEAN TryLoad, + OUT UINT32 *LastAttemptStatus, + OUT CHAR16 **AbortReason, OPTIONAL + IN OUT UINTN *TargetCpuIndex OPTIONAL + ); + +/** + Write Microcode. + + @param[in] MicrocodeFmpPrivate The Microcode driver private data + @param[in] Image The Microcode image buffer. + @param[in] ImageSize The size of Microcode image buffer in bytes. + @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + + @retval EFI_SUCCESS The Microcode image is written. + @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. + @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. + @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. + @retval EFI_WRITE_PROTECTED The flash device is read only. +**/ +EFI_STATUS +MicrocodeWrite ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, + IN VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *LastAttemptVersion, + OUT UINT32 *LastAttemptStatus, + OUT CHAR16 **AbortReason + ); + +/** + Dump private information. + + @param[in] MicrocodeFmpPrivate private data structure. +**/ +VOID +DumpPrivateInfo ( + IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate + ); + +/** + Returns information about the current firmware image(s) of the device. + + This function allows a copy of the current firmware image to be created and saved. + The saved copy could later been used, for example, in firmware image recovery or rollback. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer. + On input, this is the size of the buffer allocated by the caller. + On output, it is the size of the buffer returned by the firmware + if the buffer was large enough, or the size of the buffer needed + to contain the image(s) information if the buffer was too small. + @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s) + information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs. + @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number + associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] DescriptorCount A pointer to the location in which firmware returns the number of + descriptors or firmware images within this device. + @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes, + of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] PackageVersion A version number that represents all the firmware images in the device. + The format is vendor specific and new version must have a greater value + than the old version. If PackageVersion is not supported, the value is + 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison + is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates + that package version update is in progress. + @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the + package version name. The buffer is allocated by this function with + AllocatePool(), and it is the caller's responsibility to free it with a call + to FreePool(). + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size + needed to hold the image(s) information is returned in ImageInfoSize. + @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL. + @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image. + +**/ +EFI_STATUS +EFIAPI +FmpGetImageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN OUT UINTN *ImageInfoSize, + IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, + OUT UINT32 *DescriptorVersion, + OUT UINT8 *DescriptorCount, + OUT UINTN *DescriptorSize, + OUT UINT32 *PackageVersion, + OUT CHAR16 **PackageVersionName + ); + +/** + Retrieves a copy of the current firmware image of the device. + + This function allows a copy of the current firmware image to be created and saved. + The saved copy could later been used, for example, in firmware image recovery or rollback. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in,out] Image Points to the buffer where the current image is copied to. + @param[in,out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes. + On return, points to the length of the image, in bytes. + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the + image. The current buffer size needed to hold the image is returned + in ImageSize. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_NOT_FOUND The current image is not copied to the buffer. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpGetImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN OUT VOID *Image, + IN OUT UINTN *ImageSize + ); + +/** + Updates the firmware image of the device. + + This function updates the hardware with the new firmware image. + This function returns EFI_UNSUPPORTED if the firmware image is not updatable. + If the firmware image is updatable, the function should perform the following minimal validations + before proceeding to do the firmware image update. + - Validate the image authentication if image has attribute + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns + EFI_SECURITY_VIOLATION if the validation fails. + - Validate the image is a supported image for this device. The function returns EFI_ABORTED if + the image is unsupported. The function can optionally provide more detailed information on + why the image is not a supported image. + - Validate the data from VendorCode if not null. Image validation must be performed before + VendorCode data validation. VendorCode data is ignored or considered invalid if image + validation failed. The function returns EFI_ABORTED if the data is invalid. + + VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if + the caller did not specify the policy or use the default policy. As an example, vendor can implement + a policy to allow an option to force a firmware image update when the abort reason is due to the new + firmware image version is older than the current firmware image version or bad image checksum. + Sensitive operations such as those wiping the entire firmware image and render the device to be + non-functional should be encoded in the image itself rather than passed with the VendorCode. + AbortReason enables vendor to have the option to provide a more detailed description of the abort + reason to the caller. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in] Image Points to the new image. + @param[in] ImageSize Size of the new image in bytes. + @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy. + Null indicates the caller did not specify the policy or use the default policy. + @param[in] Progress A function used by the driver to report the progress of the firmware update. + @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more + details for the aborted operation. The buffer is allocated by this function + with AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + + @retval EFI_SUCCESS The device was successfully updated with the new image. + @retval EFI_ABORTED The operation is aborted. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpSetImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN CONST VOID *Image, + IN UINTN ImageSize, + IN CONST VOID *VendorCode, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, + OUT CHAR16 **AbortReason + ); + +/** + Checks if the firmware image is valid for the device. + + This function allows firmware update application to validate the firmware image without + invoking the SetImage() first. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. + The number is between 1 and DescriptorCount. + @param[in] Image Points to the new image. + @param[in] ImageSize Size of the new image in bytes. + @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides, + if available, additional information if the image is invalid. + + @retval EFI_SUCCESS The image was successfully checked. + @retval EFI_INVALID_PARAMETER The Image was NULL. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpCheckImage ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN UINT8 ImageIndex, + IN CONST VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *ImageUpdatable + ); + +/** + Returns information about the firmware package. + + This function returns package information. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[out] PackageVersion A version number that represents all the firmware images in the device. + The format is vendor specific and new version must have a greater value + than the old version. If PackageVersion is not supported, the value is + 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version + comparison is to be performed using PackageVersionName. A value of + 0xFFFFFFFD indicates that package version update is in progress. + @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing + the package version name. The buffer is allocated by this function with + AllocatePool(), and it is the caller's responsibility to free it with a + call to FreePool(). + @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of + package version name. A value of 0 indicates the device does not support + update of package version name. Length is the number of Unicode characters, + including the terminating null character. + @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute + Definitions' for possible returned values of this parameter. A value of 1 + indicates the attribute is supported and the current setting value is + indicated in AttributesSetting. A value of 0 indicates the attribute is not + supported and the current setting value in AttributesSetting is meaningless. + @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned + values of this parameter + + @retval EFI_SUCCESS The package information was successfully returned. + @retval EFI_UNSUPPORTED The operation is not supported. + +**/ +EFI_STATUS +EFIAPI +FmpGetPackageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + OUT UINT32 *PackageVersion, + OUT CHAR16 **PackageVersionName, + OUT UINT32 *PackageVersionNameMaxLen, + OUT UINT64 *AttributesSupported, + OUT UINT64 *AttributesSetting + ); + +/** + Updates information about the firmware package. + + This function updates package information. + This function returns EFI_UNSUPPORTED if the package information is not updatable. + VendorCode enables vendor to implement vendor-specific package information update policy. + Null if the caller did not specify this policy or use the default policy. + + @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. + @param[in] Image Points to the authentication image. + Null if authentication is not required. + @param[in] ImageSize Size of the authentication image in bytes. + 0 if authentication is not required. + @param[in] VendorCode This enables vendor to implement vendor-specific firmware + image update policy. + Null indicates the caller did not specify this policy or use + the default policy. + @param[in] PackageVersion The new package version. + @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing + the package version name. + The string length is equal to or less than the value returned in + PackageVersionNameMaxLen. + + @retval EFI_SUCCESS The device was successfully updated with the new package + information. + @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value + returned in PackageVersionNameMaxLen. + @retval EFI_UNSUPPORTED The operation is not supported. + @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + +**/ +EFI_STATUS +EFIAPI +FmpSetPackageInfo ( + IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, + IN CONST VOID *Image, + IN UINTN ImageSize, + IN CONST VOID *VendorCode, + IN UINT32 PackageVersion, + IN CONST CHAR16 *PackageVersionName + ); + +#endif + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf new file mode 100644 index 0000000000..55797cf132 --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf @@ -0,0 +1,71 @@ +## @file +# Microcode FMP update driver. +# +# Produce FMP instance to update Microcode. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MicrocodeUpdateDxe + MODULE_UNI_FILE = MicrocodeUpdateDxe.uni + FILE_GUID = 0565365C-2FE1-4F88-B3BE-624C04623A20 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = MicrocodeFmpMain + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = X64 +# + +[Sources] + MicrocodeUpdate.h + MicrocodeFmp.c + MicrocodeUpdate.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + UefiLib + BaseMemoryLib + DebugLib + PcdLib + MemoryAllocationLib + UefiBootServicesTableLib + HobLib + UefiRuntimeServicesTableLib + UefiDriverEntryPoint + MicrocodeFlashAccessLib + +[Guids] + gMicrocodeFmpImageTypeIdGuid ## CONSUMES ## GUID + +[Protocols] + gEfiFirmwareManagementProtocolGuid ## PRODUCES + gEfiMpServiceProtocolGuid ## CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES + +[Depex] + gEfiVariableArchProtocolGuid AND + gEfiMpServiceProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + MicrocodeUpdateDxeExtra.uni + diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni new file mode 100644 index 0000000000..1b0d4941dc --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni @@ -0,0 +1,21 @@ +// /** @file +// Microcode FMP update driver. +// +// Produce FMP instance to update Microcode. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Microcode FMP update driver." + +#string STR_MODULE_DESCRIPTION #language en-US "Produce FMP instance to update Microcode." diff --git a/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni new file mode 100644 index 0000000000..b667f12f5c --- /dev/null +++ b/Core/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// MicrocodeUpdateDxe Localized Strings and Content +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"MicrocodeUpdate DXE Driver" + + diff --git a/Core/UefiCpuPkg/Include/AcpiCpuData.h b/Core/UefiCpuPkg/Include/AcpiCpuData.h new file mode 100644 index 0000000000..ec092074ce --- /dev/null +++ b/Core/UefiCpuPkg/Include/AcpiCpuData.h @@ -0,0 +1,162 @@ +/** @file +Definitions for CPU S3 data. + +Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _ACPI_CPU_DATA_H_ +#define _ACPI_CPU_DATA_H_ + +// +// Register types in register table +// +typedef enum { + Msr, + ControlRegister, + MemoryMapped, + CacheControl +} REGISTER_TYPE; + +// +// Element of register table entry +// +typedef struct { + REGISTER_TYPE RegisterType; // offset 0 - 3 + UINT32 Index; // offset 4 - 7 + UINT8 ValidBitStart; // offset 8 + UINT8 ValidBitLength; // offset 9 + UINT16 Reserved; // offset 10 - 11 + UINT32 HighIndex; // offset 12-15, only valid for MemoryMapped + UINT64 Value; // offset 16-23 +} CPU_REGISTER_TABLE_ENTRY; + +// +// Register table definition, including current table length, +// allocated size of this table, and pointer to the list of table entries. +// +typedef struct { + // + // The number of valid entries in the RegisterTableEntry buffer + // + UINT32 TableLength; + UINT32 NumberBeforeReset; + // + // The size, in bytes, of the RegisterTableEntry buffer + // + UINT32 AllocatedSize; + // + // The initial APIC ID of the CPU this register table applies to + // + UINT32 InitialApicId; + // + // Physical address of CPU_REGISTER_TABLE_ENTRY structures. This buffer must be + // allocated below 4GB from memory of type EfiACPIMemoryNVS. + // + EFI_PHYSICAL_ADDRESS RegisterTableEntry; +} CPU_REGISTER_TABLE; + +// +// Data structure that is required for ACPI S3 resume. This structure must be +// allocated below 4GB from memory of type EfiACPIMemoryNVS. The PCD +// PcdCpuS3DataAddress must be set to the physical address where this structure +// is allocated +// +typedef struct { + // + // Physical address of 4KB buffer allocated below 1MB from memory of type + // EfiReservedMemoryType. The buffer is not required to be initialized, but + // it is recommended that the buffer be zero-filled. This buffer is used to + // wake APs during an ACPI S3 resume. + // + EFI_PHYSICAL_ADDRESS StartupVector; + // + // Physical address of structure of type IA32_DESCRIPTOR. This structure must + // be allocated below 4GB from memory of type EfiACPIMemoryNVS. The + // IA32_DESCRIPTOR structure provides the base address and length of a GDT + // The buffer for GDT must also be allocated below 4GB from memory of type + // EfiACPIMemoryNVS. The GDT must be filled in with the GDT contents that are + // used during an ACPI S3 resume. This is typically the contents of the GDT + // used by the boot processor when the platform is booted. + // + EFI_PHYSICAL_ADDRESS GdtrProfile; + // + // Physical address of structure of type IA32_DESCRIPTOR. This structure must + // be allocated below 4GB from memory of type EfiACPIMemoryNVS. The + // IA32_DESCRIPTOR structure provides the base address and length of an IDT. + // The buffer for IDT must also be allocated below 4GB from memory of type + // EfiACPIMemoryNVS. The IDT must be filled in with the IDT contents that are + // used during an ACPI S3 resume. This is typically the contents of the IDT + // used by the boot processor when the platform is booted. + // + EFI_PHYSICAL_ADDRESS IdtrProfile; + // + // Physical address of a buffer that is used as stacks during ACPI S3 resume. + // The total size of this buffer, in bytes, is NumberOfCpus * StackSize. This + // structure must be allocated below 4GB from memory of type EfiACPIMemoryNVS. + // + EFI_PHYSICAL_ADDRESS StackAddress; + // + // The size, in bytes, of the stack provided to each CPU during ACPI S3 resume. + // + UINT32 StackSize; + // + // The number of CPUs. If a platform does not support hot plug CPUs, then + // this is the number of CPUs detected when the platform is booted, regardless + // of being enabled or disabled. If a platform does support hot plug CPUs, + // then this is the maximum number of CPUs that the platform supports. + // + UINT32 NumberOfCpus; + // + // Physical address of structure of type MTRR_SETTINGS that contains a copy + // of the MTRR settings that are compatible with the MTRR settings used by + // the boot processor when the platform was booted. These MTRR settings are + // used during an ACPI S3 resume. This structure must be allocated below 4GB + // from memory of type EfiACPIMemoryNVS. + // + EFI_PHYSICAL_ADDRESS MtrrTable; + // + // Physical address of an array of CPU_REGISTER_TABLE structures, with + // NumberOfCpus entries. This array must be allocated below 4GB from memory + // of type EfiACPIMemoryNVS. If a register table is not required, then the + // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to 0. + // If TableLength is > 0, then elements of RegisterTableEntry are used to + // initialize the CPU that matches InitialApicId, during an ACPI S3 resume, + // before SMBASE relocation is performed. + // + EFI_PHYSICAL_ADDRESS PreSmmInitRegisterTable; + // + // Physical address of an array of CPU_REGISTER_TABLE structures, with + // NumberOfCpus entries. This array must be allocated below 4GB from memory + // of type EfiACPIMemoryNVS. If a register table is not required, then the + // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to 0. + // If TableLength is > 0, then elements of RegisterTableEntry are used to + // initialize the CPU that matches InitialApicId, during an ACPI S3 resume, + // after SMBASE relocation is performed. + // + EFI_PHYSICAL_ADDRESS RegisterTable; + // + // Physical address of a buffer that contains the machine check handler that + // is used during an ACPI S3 Resume. This buffer must be allocated below 4GB + // from memory of type EfiACPIMemoryNVS. In order for this machine check + // handler to be active on an AP during an ACPI S3 resume, the machine check + // vector in the IDT provided by IdtrProfile must be initialized to transfer + // control to this physical address. + // + EFI_PHYSICAL_ADDRESS ApMachineCheckHandlerBase; + // + // The size, in bytes, of the machine check handler that is used during an + // ACPI S3 Resume. If this field is 0, then a machine check handler is not + // provided. + // + UINT32 ApMachineCheckHandlerSize; +} ACPI_CPU_DATA; + +#endif diff --git a/Core/UefiCpuPkg/Include/CpuHotPlugData.h b/Core/UefiCpuPkg/Include/CpuHotPlugData.h new file mode 100644 index 0000000000..2a0d9fabd5 --- /dev/null +++ b/Core/UefiCpuPkg/Include/CpuHotPlugData.h @@ -0,0 +1,33 @@ +/** @file +Definition for a structure sharing information for CPU hot plug. + +Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_HOT_PLUG_DATA_H_ +#define _CPU_HOT_PLUG_DATA_H_ + +#define CPU_HOT_PLUG_DATA_REVISION_1 0x00000001 + +typedef struct { + UINT32 Revision; // Used for version identification for this structure + UINT32 ArrayLength; // The entries number of the following ApicId array and SmBase array + // + // Data required for SMBASE relocation + // + UINT64 *ApicId; // Pointer to ApicId array + UINTN *SmBase; // Pointer to SmBase array + UINT32 Reserved; + UINT32 SmrrBase; + UINT32 SmrrSize; +} CPU_HOT_PLUG_DATA; + +#endif diff --git a/Core/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h b/Core/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h new file mode 100644 index 0000000000..70b5c704d5 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h @@ -0,0 +1,26 @@ +/** @file + CPU Features Init Done PPI/Protocol should be installed after CPU features + are initialized. + +Copyright (c) 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_FEATURES_INIT_DONE_H_ +#define _CPU_FEATURES_INIT_DONE_H_ + +#define EDKII_CPU_FEATURES_INIT_DONE_GUID \ + { \ + { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \ + } + +extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid; + +#endif diff --git a/Core/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h b/Core/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h new file mode 100644 index 0000000000..bf085c726c --- /dev/null +++ b/Core/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h @@ -0,0 +1,26 @@ +/** @file + CPU Features Set Done PPI/Protocol should be installed after CPU features + configuration are set. + +Copyright (c) 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_FEATURES_INIT_DONE_H_ +#define _CPU_FEATURES_INIT_DONE_H_ + +#define EDKII_CPU_FEATURES_SET_DONE_GUID \ + { \ + { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \ + } + +extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid; + +#endif diff --git a/Core/UefiCpuPkg/Include/Guid/MicrocodeFmp.h b/Core/UefiCpuPkg/Include/Guid/MicrocodeFmp.h new file mode 100644 index 0000000000..88a19538c8 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Guid/MicrocodeFmp.h @@ -0,0 +1,21 @@ +/** @file + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __MICROCODE_FMP_GUID_H__ +#define __MICROCODE_FMP_GUID_H__ + +#define MICROCODE_FMP_IMAGE_TYPE_ID_GUID { 0x96d4fdcd, 0x1502, 0x424d, { 0x9d, 0x4c, 0x9b, 0x12, 0xd2, 0xdc, 0xae, 0x5c } } + +extern EFI_GUID gMicrocodeFmpImageTypeIdGuid; + +#endif diff --git a/Core/UefiCpuPkg/Include/Guid/MsegSmram.h b/Core/UefiCpuPkg/Include/Guid/MsegSmram.h new file mode 100644 index 0000000000..ab337c4ccb --- /dev/null +++ b/Core/UefiCpuPkg/Include/Guid/MsegSmram.h @@ -0,0 +1,30 @@ +/** @file + + Defines the HOB GUID used to describe the MSEG memory region allocated in PEI. + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _MSEG_SMRAM_H_ +#define _MSEG_SMRAM_H_ + +#define MSEG_SMRAM_GUID \ + { \ + 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 } \ + } + +extern EFI_GUID gMsegSmramGuid; + +// +// The data portion of this HOB is type EFI_SMRAM_DESCRIPTOR +// + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/LocalApicLib.h b/Core/UefiCpuPkg/Include/Library/LocalApicLib.h new file mode 100644 index 0000000000..fc980bc1f2 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/LocalApicLib.h @@ -0,0 +1,436 @@ +/** @file + Public include file for Local APIC library. + + Local APIC library assumes local APIC is enabled. It does not + handles cases where local APIC is disabled. + + Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __LOCAL_APIC_LIB_H__ +#define __LOCAL_APIC_LIB_H__ + +#define LOCAL_APIC_MODE_XAPIC 0x1 ///< xAPIC mode. +#define LOCAL_APIC_MODE_X2APIC 0x2 ///< x2APIC mode. + +/** + Retrieve the base address of local APIC. + + @return The base address of local APIC. + +**/ +UINTN +EFIAPI +GetLocalApicBaseAddress ( + VOID + ); + +/** + Set the base address of local APIC. + + If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). + + @param[in] BaseAddress Local APIC base address to be set. + +**/ +VOID +EFIAPI +SetLocalApicBaseAddress ( + IN UINTN BaseAddress + ); + +/** + Get the current local APIC mode. + + If local APIC is disabled, then ASSERT. + + @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. + @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. +**/ +UINTN +EFIAPI +GetApicMode ( + VOID + ); + +/** + Set the current local APIC mode. + + If the specified local APIC mode is not valid, then ASSERT. + If the specified local APIC mode can't be set as current, then ASSERT. + + @param ApicMode APIC mode to be set. + + @note This API must not be called from an interrupt handler or SMI handler. + It may result in unpredictable behavior. +**/ +VOID +EFIAPI +SetApicMode ( + IN UINTN ApicMode + ); + +/** + Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. + + In xAPIC mode, the initial local APIC ID may be different from current APIC ID. + In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, + the 32-bit local APIC ID is returned as initial APIC ID. + + @return 32-bit initial local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetInitialApicId ( + VOID + ); + +/** + Get the local APIC ID of the executing processor. + + @return 32-bit local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetApicId ( + VOID + ); + +/** + Get the value of the local APIC version register. + + @return the value of the local APIC version register. +**/ +UINT32 +EFIAPI +GetApicVersion ( + VOID + ); + +/** + Send a Fixed IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId The local APIC ID of the target processor. + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpi ( + IN UINT32 ApicId, + IN UINT8 Vector + ); + +/** + Send a Fixed IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpiAllExcludingSelf ( + IN UINT8 Vector + ); + +/** + Send a SMI IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendSmiIpi ( + IN UINT32 ApicId + ); + +/** + Send a SMI IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendSmiIpiAllExcludingSelf ( + VOID + ); + +/** + Send an INIT IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendInitIpi ( + IN UINT32 ApicId + ); + +/** + Send an INIT IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendInitIpiAllExcludingSelf ( + VOID + ); + +/** + Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param ApicId Specify the local APIC ID of the target processor. + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipi ( + IN UINT32 ApicId, + IN UINT32 StartupRoutine + ); + +/** + Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipiAllExcludingSelf ( + IN UINT32 StartupRoutine + ); + +/** + Initialize the state of the SoftwareEnable bit in the Local APIC + Spurious Interrupt Vector register. + + @param Enable If TRUE, then set SoftwareEnable to 1 + If FALSE, then set SoftwareEnable to 0. + +**/ +VOID +EFIAPI +InitializeLocalApicSoftwareEnable ( + IN BOOLEAN Enable + ); + +/** + Programming Virtual Wire Mode. + + This function programs the local APIC for virtual wire mode following + the example described in chapter A.3 of the MP 1.4 spec. + + IOxAPIC is not involved in this type of virtual wire mode. +**/ +VOID +EFIAPI +ProgramVirtualWireMode ( + VOID + ); + +/** + Disable LINT0 & LINT1 interrupts. + + This function sets the mask flag in the LVT LINT0 & LINT1 registers. +**/ +VOID +EFIAPI +DisableLvtInterrupts ( + VOID + ); + +/** + Read the initial count value from the init-count register. + + @return The initial count value read from the init-count register. +**/ +UINT32 +EFIAPI +GetApicTimerInitCount ( + VOID + ); + +/** + Read the current count value from the current-count register. + + @return The current count value read from the current-count register. +**/ +UINT32 +EFIAPI +GetApicTimerCurrentCount ( + VOID + ); + +/** + Initialize the local APIC timer. + + The local APIC timer is initialized and enabled. + + @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + If it is 0, then use the current divide value in the DCR. + @param InitCount The initial count value. + @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector The timer interrupt vector number. +**/ +VOID +EFIAPI +InitializeApicTimer ( + IN UINTN DivideValue, + IN UINT32 InitCount, + IN BOOLEAN PeriodicMode, + IN UINT8 Vector + ); + +/** + Get the state of the local APIC timer. + + @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector Return the timer interrupt vector number. +**/ +VOID +EFIAPI +GetApicTimerState ( + OUT UINTN *DivideValue OPTIONAL, + OUT BOOLEAN *PeriodicMode OPTIONAL, + OUT UINT8 *Vector OPTIONAL + ); + +/** + Enable the local APIC timer interrupt. +**/ +VOID +EFIAPI +EnableApicTimerInterrupt ( + VOID + ); + +/** + Disable the local APIC timer interrupt. +**/ +VOID +EFIAPI +DisableApicTimerInterrupt ( + VOID + ); + +/** + Get the local APIC timer interrupt state. + + @retval TRUE The local APIC timer interrupt is enabled. + @retval FALSE The local APIC timer interrupt is disabled. +**/ +BOOLEAN +EFIAPI +GetApicTimerInterruptState ( + VOID + ); + +/** + Send EOI to the local APIC. +**/ +VOID +EFIAPI +SendApicEoi ( + VOID + ); + +/** + Get the 32-bit address that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + @return 32-bit address used to send an MSI to the Local APIC. +**/ +UINT32 +EFIAPI +GetApicMsiAddress ( + VOID + ); + +/** + Get the 64-bit data value that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + If Vector is not in range 0x10..0xFE, then ASSERT(). + If DeliveryMode is not supported, then ASSERT(). + + @param Vector The 8-bit interrupt vector associated with the MSI. + Must be in the range 0x10..0xFE + @param DeliveryMode A 3-bit value that specifies how the recept of the MSI + is handled. The only supported values are: + 0: LOCAL_APIC_DELIVERY_MODE_FIXED + 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY + 2: LOCAL_APIC_DELIVERY_MODE_SMI + 4: LOCAL_APIC_DELIVERY_MODE_NMI + 5: LOCAL_APIC_DELIVERY_MODE_INIT + 7: LOCAL_APIC_DELIVERY_MODE_EXTINT + + @param LevelTriggered TRUE specifies a level triggered interrupt. + FALSE specifies an edge triggered interrupt. + @param AssertionLevel Ignored if LevelTriggered is FALSE. + TRUE specifies a level triggered interrupt that active + when the interrupt line is asserted. + FALSE specifies a level triggered interrupt that active + when the interrupt line is deasserted. + + @return 64-bit data value used to send an MSI to the Local APIC. +**/ +UINT64 +EFIAPI +GetApicMsiValue ( + IN UINT8 Vector, + IN UINTN DeliveryMode, + IN BOOLEAN LevelTriggered, + IN BOOLEAN AssertionLevel + ); + +/** + Get Package ID/Core ID/Thread ID of a processor. + + The algorithm assumes the target system has symmetry across physical + package boundaries with respect to the number of logical processors + per package, number of cores per package. + + @param[in] InitialApicId Initial APIC ID of the target logical processor. + @param[out] Package Returns the processor package ID. + @param[out] Core Returns the processor core ID. + @param[out] Thread Returns the processor thread ID. +**/ +VOID +EFIAPI +GetProcessorLocationByApicId ( + IN UINT32 InitialApicId, + OUT UINT32 *Package OPTIONAL, + OUT UINT32 *Core OPTIONAL, + OUT UINT32 *Thread OPTIONAL + ); + +#endif + diff --git a/Core/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h b/Core/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h new file mode 100644 index 0000000000..0dfc3ef376 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h @@ -0,0 +1,39 @@ +/** @file + Microcode flash device access library. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + + +#ifndef __MICROCODE_FLASH_ACCESS_LIB_H__ +#define __MICROCODE_FLASH_ACCESS_LIB_H__ + +/** + Perform microcode write opreation. + + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +MicrocodeFlashWrite ( + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN VOID *Buffer, + IN UINTN Length + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/MpInitLib.h b/Core/UefiCpuPkg/Include/Library/MpInitLib.h new file mode 100644 index 0000000000..05e9c6b3e6 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/MpInitLib.h @@ -0,0 +1,353 @@ +/** @file + Multiple-Processor initialization Library. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __MP_INIT_LIB_H__ +#define __MP_INIT_LIB_H__ + +#include +#include + +/** + MP Initialize Library initialization. + + This service will allocate AP reset vector and wakeup all APs to do APs + initialization. + + This service must be invoked before all other MP Initialize Library + service are invoked. + + @retval EFI_SUCCESS MP initialization succeeds. + @retval Others MP initialization fails. + +**/ +EFI_STATUS +EFIAPI +MpInitLibInitialize ( + VOID + ); + +/** + Retrieves the number of logical processor in the platform and the number of + those logical processors that are enabled on this boot. This service may only + be called from the BSP. + + @param[out] NumberOfProcessors Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors + is NULL. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibGetNumberOfProcessors ( + OUT UINTN *NumberOfProcessors, OPTIONAL + OUT UINTN *NumberOfEnabledProcessors OPTIONAL + ); + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + @param[out] HealthData Return processor health data. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibGetProcessorInfo ( + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, + OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL + ); + +/** + This service executes a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure, or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by MpInitLibStartupAllAPs() or + MPInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, + if all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + The buffer is allocated by MP Initialization + library, and it's the caller's responsibility to + free the buffer with FreePool() service. + In blocking mode, it is ready for consumption + when the call returns. In non-blocking mode, + it is ready when WaitEvent is signaled. The + list of failed CPU is terminated by + END_OF_CPU_LIST. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllAPs ( + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ); + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. + + @param[in] Procedure A pointer to the function to be run on the + designated AP of the system. See type + EFI_AP_PROCEDURE. + @param[in] ProcessorNumber The handle number of the AP. The range is + from 0 to the total number of logical + processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until this AP finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on this AP, + and go on executing immediately. If this AP + return from Procedure or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + this AP to finish this Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + this AP returns from Procedure, then Procedure + on the AP is terminated. The + AP is available for next function assigned + by MpInitLibStartupAllAPs() or + MpInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure on the + specified AP. + @param[out] Finished If NULL, this parameter is ignored. In + blocking mode, this parameter is ignored. + In non-blocking mode, if AP returns from + Procedure before the timeout expires, its + content is set to TRUE. Otherwise, the + value is set to FALSE. The caller can + determine if the AP returned from Procedure + by evaluating this value. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval EFI_SUCCESS In non-blocking mode, the function has been + dispatched to specified AP. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + the specified AP has finished. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupThisAP ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ); + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibSwitchBSP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ); + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. This flag + corresponds to StatusFlag defined in + EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only + the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter + is ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed + prior to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibEnableDisableAP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ); + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + @param[out] ProcessorNumber Pointer to the handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibWhoAmI ( + OUT UINTN *ProcessorNumber + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/MtrrLib.h b/Core/UefiCpuPkg/Include/Library/MtrrLib.h new file mode 100644 index 0000000000..a63da4d1f5 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/MtrrLib.h @@ -0,0 +1,387 @@ +/** @file + MTRR setting library + + Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _MTRR_LIB_H_ +#define _MTRR_LIB_H_ + +// +// According to IA32 SDM, MTRRs number and MSR offset are always consistent +// for IA32 processor family +// + +// +// The semantics of below macro is MAX_MTRR_NUMBER_OF_VARIABLE_MTRR, the real number can be read out from MTRR_CAP register. +// +#define MTRR_NUMBER_OF_VARIABLE_MTRR 32 +// +// Firmware need reserve 2 MTRR for OS +// Note: It is replaced by PCD PcdCpuNumberOfReservedVariableMtrrs +// +#define RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER 2 + +#define MTRR_NUMBER_OF_FIXED_MTRR 11 +// +// Below macro is deprecated, and should not be used. +// +#define FIRMWARE_VARIABLE_MTRR_NUMBER 6 +#define MTRR_LIB_IA32_MTRR_CAP 0x0FE +#define MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK 0x0FF +#define MTRR_LIB_IA32_MTRR_FIX64K_00000 0x250 +#define MTRR_LIB_IA32_MTRR_FIX16K_80000 0x258 +#define MTRR_LIB_IA32_MTRR_FIX16K_A0000 0x259 +#define MTRR_LIB_IA32_MTRR_FIX4K_C0000 0x268 +#define MTRR_LIB_IA32_MTRR_FIX4K_C8000 0x269 +#define MTRR_LIB_IA32_MTRR_FIX4K_D0000 0x26A +#define MTRR_LIB_IA32_MTRR_FIX4K_D8000 0x26B +#define MTRR_LIB_IA32_MTRR_FIX4K_E0000 0x26C +#define MTRR_LIB_IA32_MTRR_FIX4K_E8000 0x26D +#define MTRR_LIB_IA32_MTRR_FIX4K_F0000 0x26E +#define MTRR_LIB_IA32_MTRR_FIX4K_F8000 0x26F +#define MTRR_LIB_IA32_VARIABLE_MTRR_BASE 0x200 +// +// Below macro is deprecated, and should not be used. +// +#define MTRR_LIB_IA32_VARIABLE_MTRR_END 0x20F +#define MTRR_LIB_IA32_MTRR_DEF_TYPE 0x2FF +#define MTRR_LIB_MSR_VALID_MASK 0xFFFFFFFFFULL +#define MTRR_LIB_CACHE_VALID_ADDRESS 0xFFFFFF000ULL +#define MTRR_LIB_CACHE_MTRR_ENABLED 0x800 +#define MTRR_LIB_CACHE_FIXED_MTRR_ENABLED 0x400 + +// +// Structure to describe a fixed MTRR +// +typedef struct { + UINT32 Msr; + UINT32 BaseAddress; + UINT32 Length; +} FIXED_MTRR; + +// +// Structure to describe a variable MTRR +// +typedef struct { + UINT64 BaseAddress; + UINT64 Length; + UINT64 Type; + UINT32 Msr; + BOOLEAN Valid; + BOOLEAN Used; +} VARIABLE_MTRR; + +// +// Structure to hold base and mask pair for variable MTRR register +// +typedef struct _MTRR_VARIABLE_SETTING_ { + UINT64 Base; + UINT64 Mask; +} MTRR_VARIABLE_SETTING; + +// +// Array for variable MTRRs +// +typedef struct _MTRR_VARIABLE_SETTINGS_ { + MTRR_VARIABLE_SETTING Mtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; +} MTRR_VARIABLE_SETTINGS; + +// +// Array for fixed MTRRs +// +typedef struct _MTRR_FIXED_SETTINGS_ { + UINT64 Mtrr[MTRR_NUMBER_OF_FIXED_MTRR]; +} MTRR_FIXED_SETTINGS; + +// +// Structure to hold all MTRRs +// +typedef struct _MTRR_SETTINGS_ { + MTRR_FIXED_SETTINGS Fixed; + MTRR_VARIABLE_SETTINGS Variables; + UINT64 MtrrDefType; +} MTRR_SETTINGS; + +// +// Memory cache types +// +typedef enum { + CacheUncacheable = 0, + CacheWriteCombining = 1, + CacheWriteThrough = 4, + CacheWriteProtected = 5, + CacheWriteBack = 6, + CacheInvalid = 7 +} MTRR_MEMORY_CACHE_TYPE; + +#define MTRR_CACHE_UNCACHEABLE 0 +#define MTRR_CACHE_WRITE_COMBINING 1 +#define MTRR_CACHE_WRITE_THROUGH 4 +#define MTRR_CACHE_WRITE_PROTECTED 5 +#define MTRR_CACHE_WRITE_BACK 6 +#define MTRR_CACHE_INVALID_TYPE 7 + +/** + Returns the variable MTRR count for the CPU. + + @return Variable MTRR count + +**/ +UINT32 +EFIAPI +GetVariableMtrrCount ( + VOID + ); + +/** + Returns the firmware usable variable MTRR count for the CPU. + + @return Firmware usable variable MTRR count + +**/ +UINT32 +EFIAPI +GetFirmwareVariableMtrrCount ( + VOID + ); + +/** + This function attempts to set the attributes for a memory range. + + @param[in] BaseAddress The physical address that is the start + address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attribute The bit mask of attributes to set for the + memory region. + + @retval RETURN_SUCCESS The attributes were set for the memory + region. + @retval RETURN_INVALID_PARAMETER Length is zero. + @retval RETURN_UNSUPPORTED The processor does not support one or + more bytes of the memory resource range + specified by BaseAddress and Length. + @retval RETURN_UNSUPPORTED The bit mask of attributes is not support + for the memory resource range specified + by BaseAddress and Length. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource + range specified by BaseAddress and Length + cannot be modified. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to + modify the attributes of the memory + resource range. + +**/ +RETURN_STATUS +EFIAPI +MtrrSetMemoryAttribute ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Attribute + ); + + +/** + This function will get the memory cache type of the specific address. + This function is mainly for debugging purposes. + + @param[in] Address The specific address + + @return The memory cache type of the specific address + +**/ +MTRR_MEMORY_CACHE_TYPE +EFIAPI +MtrrGetMemoryAttribute ( + IN PHYSICAL_ADDRESS Address + ); + + +/** + This function will get the raw value in variable MTRRs + + @param[out] VariableSettings A buffer to hold variable MTRRs content. + + @return The buffer point to MTRR_VARIABLE_SETTINGS in which holds the content of the variable MTRR + +**/ +MTRR_VARIABLE_SETTINGS* +EFIAPI +MtrrGetVariableMtrr ( + OUT MTRR_VARIABLE_SETTINGS *VariableSettings + ); + + +/** + This function sets variable MTRRs + + @param[in] VariableSettings A buffer to hold variable MTRRs content. + + @return The pointer of VariableSettings + +**/ +MTRR_VARIABLE_SETTINGS* +EFIAPI +MtrrSetVariableMtrr ( + IN MTRR_VARIABLE_SETTINGS *VariableSettings + ); + + +/** + This function gets the content in fixed MTRRs + + @param[out] FixedSettings A buffer to hold fixed MTRRs content. + + @return The pointer of FixedSettings + +**/ +MTRR_FIXED_SETTINGS* +EFIAPI +MtrrGetFixedMtrr ( + OUT MTRR_FIXED_SETTINGS *FixedSettings + ); + + +/** + This function sets fixed MTRRs + + @param[in] FixedSettings A buffer holding fixed MTRRs content. + + @return The pointer of FixedSettings + +**/ +MTRR_FIXED_SETTINGS* +EFIAPI +MtrrSetFixedMtrr ( + IN MTRR_FIXED_SETTINGS *FixedSettings + ); + + +/** + This function gets the content in all MTRRs (variable and fixed) + + @param[out] MtrrSetting A buffer to hold all MTRRs content. + + @return The pointer of MtrrSetting + +**/ +MTRR_SETTINGS * +EFIAPI +MtrrGetAllMtrrs ( + OUT MTRR_SETTINGS *MtrrSetting + ); + + +/** + This function sets all MTRRs (variable and fixed) + + @param[in] MtrrSetting A buffer to hold all MTRRs content. + + @return The pointer of MtrrSetting + +**/ +MTRR_SETTINGS * +EFIAPI +MtrrSetAllMtrrs ( + IN MTRR_SETTINGS *MtrrSetting + ); + + +/** + Get the attribute of variable MTRRs. + + This function shadows the content of variable MTRRs into + an internal array: VariableMtrr + + @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[in] MtrrValidAddressMask The valid address mask for MTRR since the base address in + MTRR must align to 4K, so valid address mask equal to + MtrrValidBitsMask & 0xfffffffffffff000ULL + @param[out] VariableMtrr The array to shadow variable MTRRs content + + @return The return value of this parameter indicates the number of + MTRRs which has been used. +**/ +UINT32 +EFIAPI +MtrrGetMemoryAttributeInVariableMtrr ( + IN UINT64 MtrrValidBitsMask, + IN UINT64 MtrrValidAddressMask, + OUT VARIABLE_MTRR *VariableMtrr + ); + + +/** + This function prints all MTRRs for debugging. +**/ +VOID +EFIAPI +MtrrDebugPrintAllMtrrs ( + VOID + ); + +/** + Checks if MTRR is supported. + + @retval TRUE MTRR is supported. + @retval FALSE MTRR is not supported. + +**/ +BOOLEAN +EFIAPI +IsMtrrSupported ( + VOID + ); + +/** + Returns the default MTRR cache type for the system. + + @return The default MTRR cache type. + +**/ +MTRR_MEMORY_CACHE_TYPE +EFIAPI +MtrrGetDefaultMemoryType ( + VOID + ); + +/** + This function attempts to set the attributes into MTRR setting buffer for a memory range. + + @param[in, out] MtrrSetting MTRR setting buffer to be set. + @param[in] BaseAddress The physical address that is the start address + of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attribute The bit mask of attributes to set for the + memory region. + + @retval RETURN_SUCCESS The attributes were set for the memory region. + @retval RETURN_INVALID_PARAMETER Length is zero. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the + memory resource range specified by BaseAddress and Length. + @retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + +**/ +RETURN_STATUS +EFIAPI +MtrrSetMemoryAttributeInMtrrSettings ( + IN OUT MTRR_SETTINGS *MtrrSetting, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Attribute + ); + +#endif // _MTRR_LIB_H_ diff --git a/Core/UefiCpuPkg/Include/Library/PlatformSecLib.h b/Core/UefiCpuPkg/Include/Library/PlatformSecLib.h new file mode 100644 index 0000000000..0af7781771 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/PlatformSecLib.h @@ -0,0 +1,70 @@ +/** @file +This library class defines interface for platform to perform platform +specific initialization in SEC phase. + +Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __PLATFORM_SEC_LIB_H__ +#define __PLATFORM_SEC_LIB_H__ + +/** + A developer supplied function to perform platform specific operations. + + It's a developer supplied function to perform any operations appropriate to a + given platform. It's invoked just before passing control to PEI core by SEC + core. Platform developer may modify the SecCoreData passed to PEI Core. + It returns a platform specific PPI list that platform wishes to pass to PEI core. + The Generic SEC core module will merge this list to join the final list passed to + PEI core. + + @param SecCoreData The same parameter as passing to PEI core. It + could be overridden by this function. + + @return The platform specific PPI list to be passed to PEI core or + NULL if there is no need of such platform specific PPI list. + +**/ +EFI_PEI_PPI_DESCRIPTOR * +EFIAPI +SecPlatformMain ( + IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData + ); + +/** + This interface conveys state information out of the Security (SEC) phase into PEI. + + @param PeiServices Pointer to the PEI Services Table. + @param StructureSize Pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ); + +/** + This interface disables temporary memory in SEC Phase. +**/ +VOID +EFIAPI +SecPlatformDisableTemporaryMemory ( + VOID + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h b/Core/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h new file mode 100644 index 0000000000..4aa3529eb7 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h @@ -0,0 +1,518 @@ +/** @file + Register CPU Features Library to register and manage CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __REGISTER_CPU_FEATURES_LIB_H__ +#define __REGISTER_CPU_FEATURES_LIB_H__ + +#include +#include +#include + +/// +/// Defines used to identify a CPU feature. The lower 16-bits are used to +/// identify a unique CPU feature and the value represents a bit number in +/// a bit mask. The upper 16-bits are bit mask values that are used as +/// modifiers of a CPU feature. When used in a list, the define value +/// CPU_FEATURE_END is used to terminate a list of CPU feature values. +/// @{ +#define CPU_FEATURE_AESNI 0 +#define CPU_FEATURE_TURBO_MODE 1 +#define CPU_FEATURE_MWAIT 2 +#define CPU_FEATURE_ACPI 3 +#define CPU_FEATURE_EIST 4 +#define CPU_FEATURE_XD 5 +#define CPU_FEATURE_FASTSTRINGS 6 +#define CPU_FEATURE_VMX 7 +#define CPU_FEATURE_SMX 8 +#define CPU_FEATURE_SENTER 9 +#define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER 10 +#define CPU_FEATURE_LIMIT_CPUID_MAX_VAL 11 +#define CPU_FEATURE_MCE 12 +#define CPU_FEATURE_MCA 13 +#define CPU_FEATURE_MCG_CTL 14 +#define CPU_FEATURE_PENDING_BREAK 15 +#define CPU_FEATURE_C1E 16 +#define CPU_FEATURE_C1_AUTO_DEMOTION 17 +#define CPU_FEATURE_C3_AUTO_DEMOTION 18 +#define CPU_FEATURE_C1_UNDEMOTION 19 +#define CPU_FEATURE_C3_UNDEMOTION 20 +#define CPU_FEATURE_C_STATE 21 +#define CPU_FEATURE_TM 22 +#define CPU_FEATURE_TM2 23 +#define CPU_FEATURE_X2APIC 24 +#define CPU_FEATURE_RESERVED_25 25 +#define CPU_FEATURE_RESERVED_26 26 +#define CPU_FEATURE_RESERVED_27 27 +#define CPU_FEATURE_RESERVED_28 28 +#define CPU_FEATURE_RESERVED_29 29 +#define CPU_FEATURE_RESERVED_30 30 +#define CPU_FEATURE_RESERVED_31 31 + +#define CPU_FEATURE_L2_PREFETCHER (32+0) +#define CPU_FEATURE_L1_DATA_PREFETCHER (32+1) +#define CPU_FEATURE_HARDWARE_PREFETCHER (32+2) +#define CPU_FEATURE_ADJACENT_CACHE_LINE_PREFETCH (32+3) +#define CPU_FEATURE_DCU_PREFETCHER (32+4) +#define CPU_FEATURE_IP_PREFETCHER (32+5) +#define CPU_FEATURE_MLC_STREAMER_PREFETCHER (32+6) +#define CPU_FEATURE_MLC_SPATIAL_PREFETCHER (32+7) +#define CPU_FEATURE_THREE_STRICK_COUNTER (32+8) +#define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9) +#define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10) + +#define CPU_FEATURE_BEFORE_ALL BIT27 +#define CPU_FEATURE_AFTER_ALL BIT28 +#define CPU_FEATURE_BEFORE BIT29 +#define CPU_FEATURE_AFTER BIT30 +#define CPU_FEATURE_END MAX_UINT32 +/// @} + +/// +/// CPU Information passed into the SupportFunc and InitializeFunc of the +/// RegisterCpuFeature() library function. This structure contains information +/// that is commonly used during CPU feature detection and initialization. +/// +typedef struct { + /// + /// The package that the CPU resides + /// + EFI_PROCESSOR_INFORMATION ProcessorInfo; + /// + /// The Display Family of the CPU computed from CPUID leaf CPUID_VERSION_INFO + /// + UINT32 DisplayFamily; + /// + /// The Display Model of the CPU computed from CPUID leaf CPUID_VERSION_INFO + /// + UINT32 DisplayModel; + /// + /// The Stepping ID of the CPU computed from CPUID leaf CPUID_VERSION_INFO + /// + UINT32 SteppingId; + /// + /// The Processor Type of the CPU computed from CPUID leaf CPUID_VERSION_INFO + /// + UINT32 ProcessorType; + /// + /// Bit field structured returned in ECX from CPUID leaf CPUID_VERSION_INFO + /// + CPUID_VERSION_INFO_ECX CpuIdVersionInfoEcx; + /// + /// Bit field structured returned in EDX from CPUID leaf CPUID_VERSION_INFO + /// + CPUID_VERSION_INFO_EDX CpuIdVersionInfoEdx; +} REGISTER_CPU_FEATURE_INFORMATION; + +/** + Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask. + If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data + associated with that feature should be optimized away if compiler + optimizations are enabled. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesSupport. + + @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureSupported ( + IN UINT32 Feature + ); + +/** + Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesSetting. + + @retval TRUE The CPU feature is set in PcdCpuFeaturesSetting. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesSetting. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureInSetting ( + IN UINT32 Feature + ); + +/** + Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesCapability. + + @retval TRUE The CPU feature is set in PcdCpuFeaturesCapability. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesCapability. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureCapability ( + IN UINT32 Feature + ); + +/** + Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesUserConfiguration. + + @retval TRUE The CPU feature is set in PcdCpuFeaturesUserConfiguration. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesUserConfiguration. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureUserConfiguration ( + IN UINT32 Feature + ); + +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +typedef +VOID * +(EFIAPI *CPU_FEATURE_GET_CONFIG_DATA)( + IN UINTN NumberOfProcessors + ); + +/** + Detects if CPU feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE CPU feature is supported. + @retval FALSE CPU feature is not supported. + + @note This service could be called by BSP/APs. +**/ +typedef +BOOLEAN +(EFIAPI *CPU_FEATURE_SUPPORT)( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes CPU feature to specific state. + + This service does not initialize hardware and only produces entries in the + Register Table for specified processor. Hardware initialization on BSP/APs + will be done in CpuFeaturesInitialize(). + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the CPU feature must be enabled. + If FALSE, then the CPU feature must be disabled. + + @retval RETURN_SUCCESS CPU feature is initialized. + + @note This service could be called by BSP only. +**/ +typedef +RETURN_STATUS +(EFIAPI *CPU_FEATURE_INITIALIZE)( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Registers a CPU Feature. + + @param[in] FeatureName A Null-terminated Ascii string indicates CPU feature + name. + @param[in] GetConfigDataFunc CPU feature get configuration data function. This + is an optional parameter that may be NULL. If NULL, + then the most recently registered function for the + CPU feature is used. If no functions are registered + for a CPU feature, then the CPU configuration data + for the registered feature is NULL. + @param[in] SupportFunc CPU feature support function. This is an optional + parameter that may be NULL. If NULL, then the most + recently registered function for the CPU feature is + used. If no functions are registered for a CPU + feature, then the CPU feature is assumed to be + supported by all CPUs. + @param[in] InitializeFunc CPU feature initialize function. This is an optional + parameter that may be NULL. If NULL, then the most + recently registered function for the CPU feature is + used. If no functions are registered for a CPU + feature, then the CPU feature initialization is + skipped. + @param[in] ... Variable argument list of UINT32 CPU feature value. + Values with no modifiers are the features provided + by the registered functions. + Values with CPU_FEATURE_BEFORE modifier are features + that must be initialized after the features provided + by the registered functions are used. + Values with CPU_FEATURE_AFTER modifier are features + that must be initialized before the features provided + by the registered functions are used. + The last argument in this variable argument list must + always be CPU_FEATURE_END. + + @retval RETURN_SUCCESS The CPU feature was successfully registered. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register + the CPU feature. + @retval RETURN_UNSUPPORTED Registration of the CPU feature is not + supported due to a circular dependency between + BEFORE and AFTER features. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +RegisterCpuFeature ( + IN CHAR8 *FeatureName, OPTIONAL + IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc, OPTIONAL + IN CPU_FEATURE_SUPPORT SupportFunc, OPTIONAL + IN CPU_FEATURE_INITIALIZE InitializeFunc, OPTIONAL + ... + ); + +/** + Performs CPU features detection. + + This service will invoke MP service to check CPU features' + capabilities on BSP/APs. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuFeaturesDetect ( + VOID + ); + +/** + Performs CPU features Initialization. + + This service will invoke MP service to perform CPU features + initialization on BSP/APs per user configuration. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuFeaturesInitialize ( + VOID + ); + +/** + Switches to assigned BSP after CPU features initialization. + + @param[in] ProcessorNumber The index of the CPU executing this function. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +SwitchBspAfterFeaturesInitialize ( + IN UINTN ProcessorNumber + ); + +/** + Adds an entry in specified register table. + + This function adds an entry in specified register table, with given register type, + register index, bit section and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] ValueMask Mask of bits in register to write + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuRegisterTableWrite ( + IN UINTN ProcessorNumber, + IN REGISTER_TYPE RegisterType, + IN UINT64 Index, + IN UINT64 ValueMask, + IN UINT64 Value + ); + +/** + Adds an entry in specified Pre-SMM register table. + + This function adds an entry in specified register table, with given register type, + register index, bit section and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] ValueMask Mask of bits in register to write + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +PreSmmCpuRegisterTableWrite ( + IN UINTN ProcessorNumber, + IN REGISTER_TYPE RegisterType, + IN UINT64 Index, + IN UINT64 ValueMask, + IN UINT64 Value + ); + +/** + Adds a 32-bit register write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +#define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \ + do { \ + CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \ + } while(FALSE); + +/** + Adds a 64-bit register write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \ + do { \ + CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \ + } while(FALSE); + +/** + Adds a bit field write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, bit field section, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program. + @param[in] Index Index of the register to program. + @param[in] Type The data type name of a register structure. + @param[in] Field The bit fiel name in register structure to write. + @param[in] Value Value to write to the bit field. + + @note This service could be called by BSP only. +**/ +#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \ + do { \ + UINT64 ValueMask; \ + ValueMask = MAX_UINT64; \ + ((Type *)(&ValueMask))->Field = 0; \ + CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \ + } while(FALSE); + +/** + Adds a 32-bit register write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +#define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \ + do { \ + PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \ + } while(FALSE); + +/** + Adds a 64-bit register write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +#define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \ + do { \ + PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \ + } while(FALSE); + +/** + Adds a bit field write entry in specified register table. + + This macro adds an entry in specified register table, with given register type, + register index, bit field section, and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program. + @param[in] Index Index of the register to program. + @param[in] Type The data type name of a register structure. + @param[in] Field The bit fiel name in register structure to write. + @param[in] Value Value to write to the bit field. + + @note This service could be called by BSP only. +**/ +#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \ + do { \ + UINT64 ValueMask; \ + ValueMask = MAX_UINT64; \ + ((Type *)(&ValueMask))->Field = 0; \ + PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \ + } while(FALSE); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h b/Core/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h new file mode 100644 index 0000000000..4478003467 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h @@ -0,0 +1,401 @@ +/** @file +Library that provides CPU specific functions to support the PiSmmCpuDxeSmm module. + +Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __SMM_FEATURES_LIB_H__ +#define __SMM_FEATURES_LIB_H__ + +#include +#include +#include +#include + +/// +/// Enumeration of SMM registers that are accessed using the library functions +/// SmmCpuFeaturesIsSmmRegisterSupported (), SmmCpuFeaturesGetSmmRegister (), +/// and SmmCpuFeaturesSetSmmRegister (). +/// +typedef enum { + /// + /// Read-write register to provides access to MSR_SMM_FEATURE_CONTROL if the + /// CPU supports this MSR. + /// + SmmRegFeatureControl, + /// + /// Read-only register that returns a non-zero value if the CPU is able to + /// respond to SMIs. + /// + SmmRegSmmEnable, + /// + /// Read-only register that returns a non-zero value if the CPU is able to + /// respond to SMIs, but is busy with other actions that are causing a delay + /// in responding to an SMI. This register abstracts access to MSR_SMM_DELAYED + /// if the CPU supports this MSR. + /// + SmmRegSmmDelayed, + /// + /// Read-only register that returns a non-zero value if the CPU is able to + /// respond to SMIs, but is busy with other actions that are blocking its + /// ability to respond to an SMI. This register abstracts access to + /// MSR_SMM_BLOCKED if the CPU supports this MSR. + /// + SmmRegSmmBlocked +} SMM_REG_NAME; + +/** + Called during the very first SMI into System Management Mode to initialize + CPU features, including SMBASE, for the currently executing CPU. Since this + is the first SMI, the SMRAM Save State Map is at the default address of + SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executing + CPU is specified by CpuIndex and CpuIndex can be used to access information + about the currently executing CPU in the ProcessorInfo array and the + HotPlugCpuData data structure. + + @param[in] CpuIndex The index of the CPU to initialize. The value + must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU that + was elected as monarch during System Management + Mode initialization. + FALSE if the CpuIndex is not the index of the CPU + that was elected as monarch during System + Management Mode initialization. + @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMATION + structures. ProcessorInfo[CpuIndex] contains the + information for the currently executing CPU. + @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure that + contains the ApidId and SmBase arrays. +**/ +VOID +EFIAPI +SmmCpuFeaturesInitializeProcessor ( + IN UINTN CpuIndex, + IN BOOLEAN IsMonarch, + IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, + IN CPU_HOT_PLUG_DATA *CpuHotPlugData + ); + +/** + This function updates the SMRAM save state on the currently executing CPU + to resume execution at a specific address after an RSM instruction. This + function must evaluate the SMRAM save state to determine the execution mode + the RSM instruction resumes and update the resume execution address with + either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart + flag in the SMRAM save state must always be cleared. This function returns + the value of the instruction pointer from the SMRAM save state that was + replaced. If this function returns 0, then the SMRAM save state was not + modified. + + This function is called during the very first SMI on each CPU after + SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode + to signal that the SMBASE of each CPU has been updated before the default + SMBASE address is used for the first SMI to the next CPU. + + @param[in] CpuIndex The index of the CPU to hook. The value + must be between 0 and the NumberOfCpus + field in the System Management System Table + (SMST). + @param[in] CpuState Pointer to SMRAM Save State Map for the + currently executing CPU. + @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to + 32-bit execution mode from 64-bit SMM. + @param[in] NewInstructionPointer Instruction pointer to use if resuming to + same execution mode as SMM. + + @retval 0 This function did modify the SMRAM save state. + @retval > 0 The original instruction pointer value from the SMRAM save state + before it was replaced. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesHookReturnFromSmm ( + IN UINTN CpuIndex, + IN SMRAM_SAVE_STATE_MAP *CpuState, + IN UINT64 NewInstructionPointer32, + IN UINT64 NewInstructionPointer + ); + +/** + Hook point in normal execution mode that allows the one CPU that was elected + as monarch during System Management Mode initialization to perform additional + initialization actions immediately after all of the CPUs have processed their + first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE + into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). +**/ +VOID +EFIAPI +SmmCpuFeaturesSmmRelocationComplete ( + VOID + ); + +/** + Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is + returned, then a custom SMI handler is not provided by this library, + and the default SMI handler must be used. + + @retval 0 Use the default SMI handler. + @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() + The caller is required to allocate enough SMRAM for each CPU to + support the size of the custom SMI handler. +**/ +UINTN +EFIAPI +SmmCpuFeaturesGetSmiHandlerSize ( + VOID + ); + +/** + Install a custom SMI handler for the CPU specified by CpuIndex. This function + is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater + than zero and is called by the CPU that was elected as monarch during System + Management Mode initialization. + + @param[in] CpuIndex The index of the CPU to install the custom SMI handler. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. + @param[in] SmiStack The stack to use when an SMI is processed by the + the CPU specified by CpuIndex. + @param[in] StackSize The size, in bytes, if the stack used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtBase The base address of the GDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtBase The base address of the IDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] Cr3 The base address of the page tables to use when an SMI + is processed by the CPU specified by CpuIndex. +**/ +VOID +EFIAPI +SmmCpuFeaturesInstallSmiHandler ( + IN UINTN CpuIndex, + IN UINT32 SmBase, + IN VOID *SmiStack, + IN UINTN StackSize, + IN UINTN GdtBase, + IN UINTN GdtSize, + IN UINTN IdtBase, + IN UINTN IdtSize, + IN UINT32 Cr3 + ); + +/** + Determines if MTRR registers must be configured to set SMRAM cache-ability + when executing in System Management Mode. + + @retval TRUE MTRR registers must be configured to set SMRAM cache-ability. + @retval FALSE MTRR registers do not need to be configured to set SMRAM + cache-ability. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesNeedConfigureMtrrs ( + VOID + ); + +/** + Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesDisableSmrr ( + VOID + ); + +/** + Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesReenableSmrr ( + VOID + ); + +/** + Processor specific hook point each time a CPU enters System Management Mode. + + @param[in] CpuIndex The index of the CPU that has entered SMM. The value + must be between 0 and the NumberOfCpus field in the + System Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousEntry ( + IN UINTN CpuIndex + ); + +/** + Processor specific hook point each time a CPU exits System Management Mode. + + @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must + be between 0 and the NumberOfCpus field in the System + Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousExit ( + IN UINTN CpuIndex + ); + +/** + Check to see if an SMM register is supported by a specified CPU. + + @param[in] CpuIndex The index of the CPU to check for SMM register support. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to check for support. + + @retval TRUE The SMM register specified by RegName is supported by the CPU + specified by CpuIndex. + @retval FALSE The SMM register specified by RegName is not supported by the + CPU specified by CpuIndex. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesIsSmmRegisterSupported ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ); + +/** + Returns the current value of the SMM register for the specified CPU. + If the SMM register is not supported, then 0 is returned. + + @param[in] CpuIndex The index of the CPU to read the SMM register. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to read. + + @return The value of the SMM register specified by RegName from the CPU + specified by CpuIndex. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesGetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ); + +/** + Sets the value of an SMM register on a specified CPU. + If the SMM register is not supported, then no action is performed. + + @param[in] CpuIndex The index of the CPU to write the SMM register. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to write. + registers are read-only. + @param[in] Value The value to write to the SMM register. +**/ +VOID +EFIAPI +SmmCpuFeaturesSetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName, + IN UINT64 Value + ); + +/** + Read an SMM Save State register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for reading the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to read the SMM Save State. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to read. + @param[in] Width The number of bytes to read from the CPU save state. + @param[out] Buffer Upon return, this holds the CPU register value read + from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support reading Register. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesReadSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ); + +/** + Writes an SMM Save State register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for writing the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to write the SMM Save State. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to write. + @param[in] Width The number of bytes to write to the CPU save state. + @param[in] Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written to Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support writing Register. +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesWriteSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ); + +/** + This function is hook point called after the gEfiSmmReadyToLockProtocolGuid + notification is completely processed. +**/ +VOID +EFIAPI +SmmCpuFeaturesCompleteSmmReadyToLock ( + VOID + ); + +/** + This API provides a method for a CPU to allocate a specific region for storing page tables. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer for page tables. + @retval NULL Fail to allocate a specific region for storing page tables, + Or there is no preference on where the page tables are allocated in SMRAM. + +**/ +VOID * +EFIAPI +SmmCpuFeaturesAllocatePageTableMemory ( + IN UINTN Pages + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h b/Core/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h new file mode 100644 index 0000000000..e40084edf9 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h @@ -0,0 +1,109 @@ +/** @file + Public include file for the SMM CPU Platform Hook Library. + + Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __SMM_CPU_PLATFORM_HOOK_LIB_H__ +#define __SMM_CPU_PLATFORM_HOOK_LIB_H__ + +/// +/// SMM Page Size Type +/// +typedef enum { + SmmPageSize4K, + SmmPageSize2M, + SmmPageSize1G, + MaxSmmPageSizeType +} SMM_PAGE_SIZE_TYPE; + +/** + Checks if platform produces a valid SMI. + + This function checks if platform produces a valid SMI. This function is + called at SMM entry to detect if this is a spurious SMI. This function + must be implemented in an MP safe way because it is called by multiple CPU + threads. + + @retval TRUE There is a valid SMI + @retval FALSE There is no valid SMI + +**/ +BOOLEAN +EFIAPI +PlatformValidSmi ( + VOID + ); + +/** + Clears platform top level SMI status bit. + + This function clears platform top level SMI status bit. + + @retval TRUE The platform top level SMI status is cleared. + @retval FALSE The platform top level SMI status cannot be cleared. + +**/ +BOOLEAN +EFIAPI +ClearTopLevelSmiStatus ( + VOID + ); + +/** + Performs platform specific way of SMM BSP election. + + This function performs platform specific way of SMM BSP election. + + @param IsBsp Output parameter. TRUE: the CPU this function executes + on is elected to be the SMM BSP. FALSE: the CPU this + function executes on is to be SMM AP. + + @retval EFI_SUCCESS The function executes successfully. + @retval EFI_NOT_READY The function does not determine whether this CPU should be + BSP or AP. This may occur if hardware init sequence to + enable the determination is yet to be done, or the function + chooses not to do BSP election and will let SMM CPU driver to + use its default BSP election process. + @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU should be + BSP or AP due to hardware error. + +**/ +EFI_STATUS +EFIAPI +PlatformSmmBspElection ( + OUT BOOLEAN *IsBsp + ); + +/** + Get platform page table attribute . + + This function gets page table attribute of platform. + + @param Address Input parameter. Obtain the page table entries attribute on this address. + @param PageSize Output parameter. The size of the page. + @param NumOfPages Output parameter. Number of page. + @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc). + + @retval EFI_SUCCESS The platform page table attribute from the address is determined. + @retval EFI_UNSUPPORTED The platform does not support getting page table attribute for the address. + +**/ +EFI_STATUS +EFIAPI +GetPlatformPageTableAttribute ( + IN UINT64 Address, + OUT SMM_PAGE_SIZE_TYPE *PageSize, + OUT UINTN *NumOfPages, + OUT UINTN *PageAttribute + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Library/UefiCpuLib.h b/Core/UefiCpuPkg/Include/Library/UefiCpuLib.h new file mode 100644 index 0000000000..561d579968 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -0,0 +1,38 @@ +/** @file + Public header file for UEFI CPU library class. + + This library class defines some routines that are generic for IA32 family CPU + to be UEFI specification compliant. + + Copyright (c) 2009, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __UEFI_CPU_LIB_H__ +#define __UEFI_CPU_LIB_H__ + + + +/** + Initializes floating point units for requirement of UEFI specification. + + This function initializes floating-point control word to 0x027F (all exceptions + masked,double-precision, round-to-nearest) and multimedia-extensions control word + (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero + for masked underflow). + +**/ +VOID +EFIAPI +InitializeFloatingPointUnits ( + VOID + ); + +#endif diff --git a/Core/UefiCpuPkg/Include/Protocol/SmMonitorInit.h b/Core/UefiCpuPkg/Include/Protocol/SmMonitorInit.h new file mode 100644 index 0000000000..7b0aab0a6d --- /dev/null +++ b/Core/UefiCpuPkg/Include/Protocol/SmMonitorInit.h @@ -0,0 +1,141 @@ +/** @file + STM service protocol definition + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SM_MONITOR_INIT_PROTOCOL_H_ +#define _SM_MONITOR_INIT_PROTOCOL_H_ + +#include +#include + +#define EFI_SM_MONITOR_INIT_PROTOCOL_GUID \ + { 0x228f344d, 0xb3de, 0x43bb, 0xa4, 0xd7, 0xea, 0x20, 0xb, 0x1b, 0x14, 0x82} + +// +// STM service +// + +/** + + Load STM image to MSEG. + + @param StmImage STM image + @param StmImageSize STM image size + + @retval EFI_SUCCESS Load STM to MSEG successfully + @retval EFI_ALREADY_STARTED STM image is already loaded to MSEG + @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image + @retval EFI_UNSUPPORTED MSEG is not enabled + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SM_MONITOR_LOAD_MONITOR) ( + IN EFI_PHYSICAL_ADDRESS StmImage, + IN UINTN StmImageSize + ); + +/** + + Add resources in list to database. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are added + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SM_MONITOR_ADD_PI_RESOURCE) ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ); + +/** + + Delete resources in list to database. + + @param ResourceList A pointer to resource list to be deleted + NULL means delete all resources. + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are deleted + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SM_MONITOR_DELETE_PI_RESOURCE) ( + IN STM_RSC *ResourceList OPTIONAL, + IN UINT32 NumEntries OPTIONAL + ); + +/** + + Get BIOS resources. + + @param ResourceList A pointer to resource list to be filled + @param ResourceSize On input it means size of resource list input. + On output it means size of resource list filled, + or the size of resource list to be filled if size of too small. + + @retval EFI_SUCCESS If resources are returned. + @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SM_MONITOR_GET_PI_RESOURCE) ( + OUT STM_RSC *ResourceList, + IN OUT UINT32 *ResourceSize + ); + +typedef UINT32 EFI_SM_MONITOR_STATE; +#define EFI_SM_MONITOR_STATE_ENABLED 0x1 +#define EFI_SM_MONITOR_STATE_ACTIVATED 0x2 + +/** + + Get STM state + + @return STM state + +**/ +typedef +EFI_SM_MONITOR_STATE +(EFIAPI *EFI_SM_MONITOR_GET_MONITOR_STATE) ( + VOID + ); + +typedef struct _EFI_SM_MONITOR_INIT_PROTOCOL { + // + // Valid at boot-time only + // + EFI_SM_MONITOR_LOAD_MONITOR LoadMonitor; + EFI_SM_MONITOR_ADD_PI_RESOURCE AddPiResource; + EFI_SM_MONITOR_DELETE_PI_RESOURCE DeletePiResource; + EFI_SM_MONITOR_GET_PI_RESOURCE GetPiResource; + // + // Valid at runtime + // + EFI_SM_MONITOR_GET_MONITOR_STATE GetMonitorState; +} EFI_SM_MONITOR_INIT_PROTOCOL; + +extern EFI_GUID gEfiSmMonitorInitProtocolGuid; + +#endif diff --git a/Core/UefiCpuPkg/Include/Protocol/SmmCpuService.h b/Core/UefiCpuPkg/Include/Protocol/SmmCpuService.h new file mode 100644 index 0000000000..9aced54f4d --- /dev/null +++ b/Core/UefiCpuPkg/Include/Protocol/SmmCpuService.h @@ -0,0 +1,209 @@ +/** @file +SMM CPU Service protocol definition. + +Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_CPU_SERVICE_PROTOCOL_H_ +#define _SMM_CPU_SERVICE_PROTOCOL_H_ + +// +// Share some definitions with MP Services and CPU Arch Protocol +// +#include +#include + +#define EFI_SMM_CPU_SERVICE_PROTOCOL_GUID \ + { \ + 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 } \ + } + +typedef struct _EFI_SMM_CPU_SERVICE_PROTOCOL EFI_SMM_CPU_SERVICE_PROTOCOL; + +// +// Protocol functions +// + +/** + Gets processor information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL + instance. + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. +**/ +typedef +EFI_STATUS +(EFIAPI * EFI_SMM_GET_PROCESSOR_INFO) ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. The new BSP can take over the + execution of the old BSP and continue seamlessly from where the old one left + off. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_SUCCESS The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + +**/ +typedef +EFI_STATUS +(EFIAPI * EFI_SMM_SWITCH_BSP) ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ); + +/** + Notify that a new processor has been added to the system. + + The SMM CPU driver should add the processor to the SMM CPU list. + + If the processor is disabled it won't participate any SMI handler during subsequent SMIs. + + @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param ProcessorId The hardware ID of the processor. + @param ProcessorNumber The handle number of processor. + @param ProcessorResource A pointer to EFI_SMM_PROCESSOR_RESOURCE which holds the assigned resources. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_ALREADY_STARTED Processor already present. + @retval EFI_NOT_READY Space for a new handle could not be allocated. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_ADD_PROCESSOR) ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINT64 ProcessorId, + OUT UINTN *ProcessorNumber + ); + +/** + Notify that a processor is hot-removed. + + Remove a processor from the CPU list of the SMM CPU driver. After this API is called, the removed processor + must not respond to SMIs in the coherence domain. + + @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param ProcessorId The hardware ID of the processor. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND Processor with the hardware ID specified by ProcessorId does not exist. + @retval EFI_NOT_READY Specified AP is busy. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_REMOVE_PROCESSOR) ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ); + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + This service returns the processor handle number for the calling processor. + The returned value is in the range from 0 to the total number of logical + processors minus 1. This service may be called from the BSP and APs. + If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER + is returned. Otherwise, the current processors handle number is returned in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI * EFI_SMM_WHOAMI) ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + OUT UINTN *ProcessorNumber + ); + +/** + Register exception handler. + + @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. + @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and + the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL + of the UEFI 2.0 specification. + @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER + that is called when a processor interrupt occurs. + If this parameter is NULL, then the handler will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_REGISTER_EXCEPTION_HANDLER) ( + IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ); + +// +// This protocol provides CPU services from SMM. +// +struct _EFI_SMM_CPU_SERVICE_PROTOCOL { + EFI_SMM_GET_PROCESSOR_INFO GetProcessorInfo; + EFI_SMM_SWITCH_BSP SwitchBsp; + EFI_SMM_ADD_PROCESSOR AddProcessor; + EFI_SMM_REMOVE_PROCESSOR RemoveProcessor; + EFI_SMM_WHOAMI WhoAmI; + EFI_SMM_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler; +}; + +extern EFI_GUID gEfiSmmCpuServiceProtocolGuid; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/ArchitecturalMsr.h b/Core/UefiCpuPkg/Include/Register/ArchitecturalMsr.h new file mode 100644 index 0000000000..4f9c1033f3 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/ArchitecturalMsr.h @@ -0,0 +1,6441 @@ +/** @file + Architectural MSR Definitions. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.1. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Appendix A VMX Capability Reporting Facility, Section A.1. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Appendix A VMX Capability Reporting Facility, Section A.6. + +**/ + +#ifndef __ARCHITECTURAL_MSR_H__ +#define __ARCHITECTURAL_MSR_H__ + +/** + See Section 35.22, "MSRs in Pentium Processors.". Pentium Processor (05_01H). + + @param ECX MSR_IA32_P5_MC_ADDR (0x00000000) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_P5_MC_ADDR); + AsmWriteMsr64 (MSR_IA32_P5_MC_ADDR, Msr); + @endcode + @note MSR_IA32_P5_MC_ADDR is defined as IA32_P5_MC_ADDR in SDM. +**/ +#define MSR_IA32_P5_MC_ADDR 0x00000000 + + +/** + See Section 35.22, "MSRs in Pentium Processors.". DF_DM = 05_01H. + + @param ECX MSR_IA32_P5_MC_TYPE (0x00000001) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_P5_MC_TYPE); + AsmWriteMsr64 (MSR_IA32_P5_MC_TYPE, Msr); + @endcode + @note MSR_IA32_P5_MC_TYPE is defined as IA32_P5_MC_TYPE in SDM. +**/ +#define MSR_IA32_P5_MC_TYPE 0x00000001 + + +/** + See Section 8.10.5, "Monitor/Mwait Address Range Determination.". Introduced + at Display Family / Display Model 0F_03H. + + @param ECX MSR_IA32_MONITOR_FILTER_SIZE (0x00000006) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MONITOR_FILTER_SIZE); + AsmWriteMsr64 (MSR_IA32_MONITOR_FILTER_SIZE, Msr); + @endcode + @note MSR_IA32_MONITOR_FILTER_SIZE is defined as IA32_MONITOR_FILTER_SIZE in SDM. +**/ +#define MSR_IA32_MONITOR_FILTER_SIZE 0x00000006 + + +/** + See Section 17.15, "Time-Stamp Counter.". Introduced at Display Family / + Display Model 05_01H. + + @param ECX MSR_IA32_TIME_STAMP_COUNTER (0x00000010) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_TIME_STAMP_COUNTER); + AsmWriteMsr64 (MSR_IA32_TIME_STAMP_COUNTER, Msr); + @endcode + @note MSR_IA32_TIME_STAMP_COUNTER is defined as IA32_TIME_STAMP_COUNTER in SDM. +**/ +#define MSR_IA32_TIME_STAMP_COUNTER 0x00000010 + + +/** + Platform ID (RO) The operating system can use this MSR to determine "slot" + information for the processor and the proper microcode update to load. + Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_IA32_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); + @endcode + @note MSR_IA32_PLATFORM_ID is defined as IA32_PLATFORM_ID in SDM. +**/ +#define MSR_IA32_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_IA32_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:18; + /// + /// [Bits 52:50] Platform Id (RO) Contains information concerning the + /// intended platform for the processor. + /// 52 51 50 + /// -- -- -- + /// 0 0 0 Processor Flag 0. + /// 0 0 1 Processor Flag 1 + /// 0 1 0 Processor Flag 2 + /// 0 1 1 Processor Flag 3 + /// 1 0 0 Processor Flag 4 + /// 1 0 1 Processor Flag 5 + /// 1 1 0 Processor Flag 6 + /// 1 1 1 Processor Flag 7 + /// + UINT32 PlatformId:3; + UINT32 Reserved3:11; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PLATFORM_ID_REGISTER; + + +/** + 06_01H. + + @param ECX MSR_IA32_APIC_BASE (0x0000001B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_APIC_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_APIC_BASE_REGISTER. + + Example usage + @code + MSR_IA32_APIC_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + AsmWriteMsr64 (MSR_IA32_APIC_BASE, Msr.Uint64); + @endcode + @note MSR_IA32_APIC_BASE is defined as IA32_APIC_BASE in SDM. +**/ +#define MSR_IA32_APIC_BASE 0x0000001B + +/** + MSR information returned for MSR index #MSR_IA32_APIC_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bit 8] BSP flag (R/W). + /// + UINT32 BSP:1; + UINT32 Reserved2:1; + /// + /// [Bit 10] Enable x2APIC mode. Introduced at Display Family / Display + /// Model 06_1AH. + /// + UINT32 EXTD:1; + /// + /// [Bit 11] APIC Global Enable (R/W). + /// + UINT32 EN:1; + /// + /// [Bits 31:12] APIC Base (R/W). + /// + UINT32 ApicBase:20; + /// + /// [Bits 63:32] APIC Base (R/W). + /// + UINT32 ApicBaseHi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_APIC_BASE_REGISTER; + + +/** + Control Features in Intel 64 Processor (R/W). If any one enumeration + condition for defined bit field holds. + + @param ECX MSR_IA32_FEATURE_CONTROL (0x0000003A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_IA32_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_IA32_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. +**/ +#define MSR_IA32_FEATURE_CONTROL 0x0000003A + +/** + MSR information returned for MSR index #MSR_IA32_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock bit (R/WO): (1 = locked). When set, locks this MSR from + /// being written, writes to this bit will result in GP(0). Note: Once the + /// Lock bit is set, the contents of this register cannot be modified. + /// Therefore the lock bit must be set after configuring support for Intel + /// Virtualization Technology and prior to transferring control to an + /// option ROM or the OS. Hence, once the Lock bit is set, the entire + /// IA32_FEATURE_CONTROL contents are preserved across RESET when PWRGOOD + /// is not deasserted. If any one enumeration condition for defined bit + /// field position greater than bit 0 holds. + /// + UINT32 Lock:1; + /// + /// [Bit 1] Enable VMX inside SMX operation (R/WL): This bit enables a + /// system executive to use VMX in conjunction with SMX to support + /// Intel(R) Trusted Execution Technology. BIOS must set this bit only + /// when the CPUID function 1 returns VMX feature flag and SMX feature + /// flag set (ECX bits 5 and 6 respectively). If CPUID.01H:ECX[5] = 1 && + /// CPUID.01H:ECX[6] = 1. + /// + UINT32 EnableVmxInsideSmx:1; + /// + /// [Bit 2] Enable VMX outside SMX operation (R/WL): This bit enables VMX + /// for system executive that do not require SMX. BIOS must set this bit + /// only when the CPUID function 1 returns VMX feature flag set (ECX bit + /// 5). If CPUID.01H:ECX[5] = 1. + /// + UINT32 EnableVmxOutsideSmx:1; + UINT32 Reserved1:5; + /// + /// [Bits 14:8] SENTER Local Function Enables (R/WL): When set, each bit + /// in the field represents an enable control for a corresponding SENTER + /// function. This bit is supported only if CPUID.1:ECX.[bit 6] is set. If + /// CPUID.01H:ECX[6] = 1. + /// + UINT32 SenterLocalFunctionEnables:7; + /// + /// [Bit 15] SENTER Global Enable (R/WL): This bit must be set to enable + /// SENTER leaf functions. This bit is supported only if CPUID.1:ECX.[bit + /// 6] is set. If CPUID.01H:ECX[6] = 1. + /// + UINT32 SenterGlobalEnable:1; + UINT32 Reserved2:1; + /// + /// [Bit 17] SGX Launch Control Enable (R/WL): This bit must be set to + /// enable runtime reconfiguration of SGX Launch Control via + /// IA32_SGXLEPUBKEYHASHn MSR. If CPUID.(EAX=07H, ECX=0H): ECX[30] = 1. + /// + UINT32 SgxLaunchControlEnable:1; + /// + /// [Bit 18] SGX Global Enable (R/WL): This bit must be set to enable SGX + /// leaf functions. If CPUID.(EAX=07H, ECX=0H): EBX[2] = 1. + /// + UINT32 SgxEnable:1; + UINT32 Reserved3:1; + /// + /// [Bit 20] LMCE On (R/WL): When set, system software can program the + /// MSRs associated with LMCE to configure delivery of some machine check + /// exceptions to a single logical processor. If IA32_MCG_CAP[27] = 1. + /// + UINT32 LmceOn:1; + UINT32 Reserved4:11; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_FEATURE_CONTROL_REGISTER; + + +/** + Per Logical Processor TSC Adjust (R/Write to clear). If CPUID.(EAX=07H, + ECX=0H): EBX[1] = 1. THREAD_ADJUST: Local offset value of the IA32_TSC for + a logical processor. Reset value is Zero. A write to IA32_TSC will modify + the local offset in IA32_TSC_ADJUST and the content of IA32_TSC, but does + not affect the internal invariant TSC hardware. + + @param ECX MSR_IA32_TSC_ADJUST (0x0000003B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_TSC_ADJUST); + AsmWriteMsr64 (MSR_IA32_TSC_ADJUST, Msr); + @endcode + @note MSR_IA32_TSC_ADJUST is defined as IA32_TSC_ADJUST in SDM. +**/ +#define MSR_IA32_TSC_ADJUST 0x0000003B + + +/** + BIOS Update Trigger (W) Executing a WRMSR instruction to this MSR causes a + microcode update to be loaded into the processor. See Section 9.11.6, + "Microcode Update Loader." A processor may prevent writing to this MSR when + loading guest states on VM entries or saving guest states on VM exits. + Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_BIOS_UPDT_TRIG (0x00000079) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = 0; + AsmWriteMsr64 (MSR_IA32_BIOS_UPDT_TRIG, Msr); + @endcode + @note MSR_IA32_BIOS_UPDT_TRIG is defined as IA32_BIOS_UPDT_TRIG in SDM. +**/ +#define MSR_IA32_BIOS_UPDT_TRIG 0x00000079 + + +/** + BIOS Update Signature (RO) Returns the microcode update signature following + the execution of CPUID.01H. A processor may prevent writing to this MSR when + loading guest states on VM entries or saving guest states on VM exits. + Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_BIOS_SIGN_ID (0x0000008B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_BIOS_SIGN_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_BIOS_SIGN_ID_REGISTER. + + Example usage + @code + MSR_IA32_BIOS_SIGN_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_BIOS_SIGN_ID); + @endcode + @note MSR_IA32_BIOS_SIGN_ID is defined as IA32_BIOS_SIGN_ID in SDM. +**/ +#define MSR_IA32_BIOS_SIGN_ID 0x0000008B + +/** + MSR information returned for MSR index #MSR_IA32_BIOS_SIGN_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:32; + /// + /// [Bits 63:32] Microcode update signature. This field contains the + /// signature of the currently loaded microcode update when read following + /// the execution of the CPUID instruction, function 1. It is required + /// that this register field be pre-loaded with zero prior to executing + /// the CPUID, function 1. If the field remains equal to zero, then there + /// is no microcode update loaded. Another nonzero value will be the + /// signature. + /// + UINT32 MicrocodeUpdateSignature:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_BIOS_SIGN_ID_REGISTER; + + +/** + IA32_SGXLEPUBKEYHASH[(64*n+63):(64*n)] (R/W) Bits (64*n+63):(64*n) of the + SHA256 digest of the SIGSTRUCT.MODULUS for SGX Launch Enclave. On reset, the + default value is the digest of Intel's signing key. Read permitted If + CPUID.(EAX=12H,ECX=0H):EAX[0]=1, Write permitted if CPUID.(EAX=12H,ECX=0H): + EAX[0]=1 && IA32_FEATURE_CONTROL[17] = 1 && IA32_FEATURE_CONTROL[0] = 1. + + @param ECX MSR_IA32_SGXLEPUBKEYHASHn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_SGXLEPUBKEYHASHn); + AsmWriteMsr64 (MSR_IA32_SGXLEPUBKEYHASHn, Msr); + @endcode + @note MSR_IA32_SGXLEPUBKEYHASH0 is defined as IA32_SGXLEPUBKEYHASH0 in SDM. + MSR_IA32_SGXLEPUBKEYHASH1 is defined as IA32_SGXLEPUBKEYHASH1 in SDM. + MSR_IA32_SGXLEPUBKEYHASH2 is defined as IA32_SGXLEPUBKEYHASH2 in SDM. + MSR_IA32_SGXLEPUBKEYHASH3 is defined as IA32_SGXLEPUBKEYHASH3 in SDM. + @{ +**/ +#define MSR_IA32_SGXLEPUBKEYHASH0 0x0000008C +#define MSR_IA32_SGXLEPUBKEYHASH1 0x0000008D +#define MSR_IA32_SGXLEPUBKEYHASH2 0x0000008E +#define MSR_IA32_SGXLEPUBKEYHASH3 0x0000008F +/// @} + + +/** + SMM Monitor Configuration (R/W). If CPUID.01H: ECX[5]=1 or CPUID.01H: ECX[6] = + 1. + + @param ECX MSR_IA32_SMM_MONITOR_CTL (0x0000009B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_SMM_MONITOR_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_SMM_MONITOR_CTL_REGISTER. + + Example usage + @code + MSR_IA32_SMM_MONITOR_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); + AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, Msr.Uint64); + @endcode + @note MSR_IA32_SMM_MONITOR_CTL is defined as IA32_SMM_MONITOR_CTL in SDM. +**/ +#define MSR_IA32_SMM_MONITOR_CTL 0x0000009B + +/** + MSR information returned for MSR index #MSR_IA32_SMM_MONITOR_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Valid (R/W). The STM may be invoked using VMCALL only if this + /// bit is 1. Because VMCALL is used to activate the dual-monitor treatment + /// (see Section 34.15.6), the dual-monitor treatment cannot be activated + /// if the bit is 0. This bit is cleared when the logical processor is + /// reset. + /// + UINT32 Valid:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Determines whether executions of VMXOFF unblock SMIs under the + /// default treatment of SMIs and SMM. Executions of VMXOFF unblock SMIs + /// unless bit 2 is 1 (the value of bit 0 is irrelevant). + /// + UINT32 BlockSmi:1; + UINT32 Reserved2:9; + /// + /// [Bits 31:12] MSEG Base (R/W). + /// + UINT32 MsegBase:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_SMM_MONITOR_CTL_REGISTER; + +/** + MSEG header that is located at the physical address specified by the MsegBase + field of #MSR_IA32_SMM_MONITOR_CTL_REGISTER. +**/ +typedef struct { + /// + /// Different processors may use different MSEG revision identifiers. These + /// identifiers enable software to avoid using an MSEG header formatted for + /// one processor on a processor that uses a different format. Software can + /// discover the MSEG revision identifier that a processor uses by reading + /// the VMX capability MSR IA32_VMX_MISC. + // + UINT32 MsegHeaderRevision; + /// + /// Bits 31:1 of this field are reserved and must be zero. Bit 0 of the field + /// is the IA-32e mode SMM feature bit. It indicates whether the logical + /// processor will be in IA-32e mode after the STM is activated. + /// + UINT32 MonitorFeatures; + UINT32 GdtrLimit; + UINT32 GdtrBaseOffset; + UINT32 CsSelector; + UINT32 EipOffset; + UINT32 EspOffset; + UINT32 Cr3Offset; + /// + /// Pad header so total size is 2KB + /// + UINT8 Reserved[SIZE_2KB - 8 * sizeof (UINT32)]; +} MSEG_HEADER; + +/// +/// @{ Define values for the MonitorFeatures field of #MSEG_HEADER +/// +#define STM_FEATURES_IA32E 0x1 +/// +/// @} +/// + +/** + Base address of the logical processor's SMRAM image (RO, SMM only). If + IA32_VMX_MISC[15]. + + @param ECX MSR_IA32_SMBASE (0x0000009E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_SMBASE); + @endcode + @note MSR_IA32_SMBASE is defined as IA32_SMBASE in SDM. +**/ +#define MSR_IA32_SMBASE 0x0000009E + + +/** + General Performance Counters (R/W). + MSR_IA32_PMCn is supported if CPUID.0AH: EAX[15:8] > n. + + @param ECX MSR_IA32_PMCn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_PMC0); + AsmWriteMsr64 (MSR_IA32_PMC0, Msr); + @endcode + @note MSR_IA32_PMC0 is defined as IA32_PMC0 in SDM. + MSR_IA32_PMC1 is defined as IA32_PMC1 in SDM. + MSR_IA32_PMC2 is defined as IA32_PMC2 in SDM. + MSR_IA32_PMC3 is defined as IA32_PMC3 in SDM. + MSR_IA32_PMC4 is defined as IA32_PMC4 in SDM. + MSR_IA32_PMC5 is defined as IA32_PMC5 in SDM. + MSR_IA32_PMC6 is defined as IA32_PMC6 in SDM. + MSR_IA32_PMC7 is defined as IA32_PMC7 in SDM. + @{ +**/ +#define MSR_IA32_PMC0 0x000000C1 +#define MSR_IA32_PMC1 0x000000C2 +#define MSR_IA32_PMC2 0x000000C3 +#define MSR_IA32_PMC3 0x000000C4 +#define MSR_IA32_PMC4 0x000000C5 +#define MSR_IA32_PMC5 0x000000C6 +#define MSR_IA32_PMC6 0x000000C7 +#define MSR_IA32_PMC7 0x000000C8 +/// @} + + +/** + TSC Frequency Clock Counter (R/Write to clear). If CPUID.06H: ECX[0] = 1. + C0_MCNT: C0 TSC Frequency Clock Count Increments at fixed interval (relative + to TSC freq.) when the logical processor is in C0. Cleared upon overflow / + wrap-around of IA32_APERF. + + @param ECX MSR_IA32_MPERF (0x000000E7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MPERF); + AsmWriteMsr64 (MSR_IA32_MPERF, Msr); + @endcode + @note MSR_IA32_MPERF is defined as IA32_MPERF in SDM. +**/ +#define MSR_IA32_MPERF 0x000000E7 + + +/** + Actual Performance Clock Counter (R/Write to clear). If CPUID.06H: ECX[0] = + 1. C0_ACNT: C0 Actual Frequency Clock Count Accumulates core clock counts at + the coordinated clock frequency, when the logical processor is in C0. + Cleared upon overflow / wrap-around of IA32_MPERF. + + @param ECX MSR_IA32_APERF (0x000000E8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_APERF); + AsmWriteMsr64 (MSR_IA32_APERF, Msr); + @endcode + @note MSR_IA32_APERF is defined as IA32_APERF in SDM. +**/ +#define MSR_IA32_APERF 0x000000E8 + + +/** + MTRR Capability (RO) Section 11.11.2.1, "IA32_MTRR_DEF_TYPE MSR.". + Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_MTRRCAP (0x000000FE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MTRRCAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MTRRCAP_REGISTER. + + Example usage + @code + MSR_IA32_MTRRCAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); + @endcode + @note MSR_IA32_MTRRCAP is defined as IA32_MTRRCAP in SDM. +**/ +#define MSR_IA32_MTRRCAP 0x000000FE + +/** + MSR information returned for MSR index #MSR_IA32_MTRRCAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] VCNT: The number of variable memory type ranges in the + /// processor. + /// + UINT32 VCNT:8; + /// + /// [Bit 8] Fixed range MTRRs are supported when set. + /// + UINT32 FIX:1; + UINT32 Reserved1:1; + /// + /// [Bit 10] WC Supported when set. + /// + UINT32 WC:1; + /// + /// [Bit 11] SMRR Supported when set. + /// + UINT32 SMRR:1; + UINT32 Reserved2:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MTRRCAP_REGISTER; + + +/** + SYSENTER_CS_MSR (R/W). Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_SYSENTER_CS (0x00000174) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_SYSENTER_CS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_SYSENTER_CS_REGISTER. + + Example usage + @code + MSR_IA32_SYSENTER_CS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SYSENTER_CS); + AsmWriteMsr64 (MSR_IA32_SYSENTER_CS, Msr.Uint64); + @endcode + @note MSR_IA32_SYSENTER_CS is defined as IA32_SYSENTER_CS in SDM. +**/ +#define MSR_IA32_SYSENTER_CS 0x00000174 + +/** + MSR information returned for MSR index #MSR_IA32_SYSENTER_CS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] CS Selector. + /// + UINT32 CS:16; + UINT32 Reserved1:16; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_SYSENTER_CS_REGISTER; + + +/** + SYSENTER_ESP_MSR (R/W). Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_SYSENTER_ESP (0x00000175) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_SYSENTER_ESP); + AsmWriteMsr64 (MSR_IA32_SYSENTER_ESP, Msr); + @endcode + @note MSR_IA32_SYSENTER_ESP is defined as IA32_SYSENTER_ESP in SDM. +**/ +#define MSR_IA32_SYSENTER_ESP 0x00000175 + + +/** + SYSENTER_EIP_MSR (R/W). Introduced at Display Family / Display Model 06_01H. + + @param ECX MSR_IA32_SYSENTER_EIP (0x00000176) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_SYSENTER_EIP); + AsmWriteMsr64 (MSR_IA32_SYSENTER_EIP, Msr); + @endcode + @note MSR_IA32_SYSENTER_EIP is defined as IA32_SYSENTER_EIP in SDM. +**/ +#define MSR_IA32_SYSENTER_EIP 0x00000176 + + +/** + Global Machine Check Capability (RO). Introduced at Display Family / Display + Model 06_01H. + + @param ECX MSR_IA32_MCG_CAP (0x00000179) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MCG_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MCG_CAP_REGISTER. + + Example usage + @code + MSR_IA32_MCG_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); + @endcode + @note MSR_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. +**/ +#define MSR_IA32_MCG_CAP 0x00000179 + +/** + MSR information returned for MSR index #MSR_IA32_MCG_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Count: Number of reporting banks. + /// + UINT32 Count:8; + /// + /// [Bit 8] MCG_CTL_P: IA32_MCG_CTL is present if this bit is set. + /// + UINT32 MCG_CTL_P:1; + /// + /// [Bit 9] MCG_EXT_P: Extended machine check state registers are present + /// if this bit is set. + /// + UINT32 MCG_EXT_P:1; + /// + /// [Bit 10] MCP_CMCI_P: Support for corrected MC error event is present. + /// Introduced at Display Family / Display Model 06_01H. + /// + UINT32 MCP_CMCI_P:1; + /// + /// [Bit 11] MCG_TES_P: Threshold-based error status register are present + /// if this bit is set. + /// + UINT32 MCG_TES_P:1; + UINT32 Reserved1:4; + /// + /// [Bits 23:16] MCG_EXT_CNT: Number of extended machine check state + /// registers present. + /// + UINT32 MCG_EXT_CNT:8; + /// + /// [Bit 24] MCG_SER_P: The processor supports software error recovery if + /// this bit is set. + /// + UINT32 MCG_SER_P:1; + UINT32 Reserved2:1; + /// + /// [Bit 26] MCG_ELOG_P: Indicates that the processor allows platform + /// firmware to be invoked when an error is detected so that it may + /// provide additional platform specific information in an ACPI format + /// "Generic Error Data Entry" that augments the data included in machine + /// check bank registers. Introduced at Display Family / Display Model + /// 06_3EH. + /// + UINT32 MCG_ELOG_P:1; + /// + /// [Bit 27] MCG_LMCE_P: Indicates that the processor support extended + /// state in IA32_MCG_STATUS and associated MSR necessary to configure + /// Local Machine Check Exception (LMCE). Introduced at Display Family / + /// Display Model 06_3EH. + /// + UINT32 MCG_LMCE_P:1; + UINT32 Reserved3:4; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MCG_CAP_REGISTER; + + +/** + Global Machine Check Status (R/W0). Introduced at Display Family / Display + Model 06_01H. + + @param ECX MSR_IA32_MCG_STATUS (0x0000017A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MCG_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MCG_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_MCG_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_STATUS); + AsmWriteMsr64 (MSR_IA32_MCG_STATUS, Msr.Uint64); + @endcode + @note MSR_IA32_MCG_STATUS is defined as IA32_MCG_STATUS in SDM. +**/ +#define MSR_IA32_MCG_STATUS 0x0000017A + +/** + MSR information returned for MSR index #MSR_IA32_MCG_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] RIPV. Restart IP valid. Introduced at Display Family / Display + /// Model 06_01H. + /// + UINT32 RIPV:1; + /// + /// [Bit 1] EIPV. Error IP valid. Introduced at Display Family / Display + /// Model 06_01H. + /// + UINT32 EIPV:1; + /// + /// [Bit 2] MCIP. Machine check in progress. Introduced at Display Family + /// / Display Model 06_01H. + /// + UINT32 MCIP:1; + /// + /// [Bit 3] LMCE_S. If IA32_MCG_CAP.LMCE_P[2 7] =1. + /// + UINT32 LMCE_S:1; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MCG_STATUS_REGISTER; + + +/** + Global Machine Check Control (R/W). If IA32_MCG_CAP.CTL_P[8] =1. + + @param ECX MSR_IA32_MCG_CTL (0x0000017B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MCG_CTL); + AsmWriteMsr64 (MSR_IA32_MCG_CTL, Msr); + @endcode + @note MSR_IA32_MCG_CTL is defined as IA32_MCG_CTL in SDM. +**/ +#define MSR_IA32_MCG_CTL 0x0000017B + + +/** + Performance Event Select Register n (R/W). If CPUID.0AH: EAX[15:8] > n. + + @param ECX MSR_IA32_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERFEVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERFEVTSEL_REGISTER. + + Example usage + @code + MSR_IA32_PERFEVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERFEVTSEL0); + AsmWriteMsr64 (MSR_IA32_PERFEVTSEL0, Msr.Uint64); + @endcode + @note MSR_IA32_PERFEVTSEL0 is defined as IA32_PERFEVTSEL0 in SDM. + MSR_IA32_PERFEVTSEL1 is defined as IA32_PERFEVTSEL1 in SDM. + MSR_IA32_PERFEVTSEL2 is defined as IA32_PERFEVTSEL2 in SDM. + MSR_IA32_PERFEVTSEL3 is defined as IA32_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_IA32_PERFEVTSEL0 0x00000186 +#define MSR_IA32_PERFEVTSEL1 0x00000187 +#define MSR_IA32_PERFEVTSEL2 0x00000188 +#define MSR_IA32_PERFEVTSEL3 0x00000189 +/// @} + +/** + MSR information returned for MSR indexes #MSR_IA32_PERFEVTSEL0 to + #MSR_IA32_PERFEVTSEL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Event Select: Selects a performance event logic unit. + /// + UINT32 EventSelect:8; + /// + /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to + /// detect on the selected event logic. + /// + UINT32 UMASK:8; + /// + /// [Bit 16] USR: Counts while in privilege level is not ring 0. + /// + UINT32 USR:1; + /// + /// [Bit 17] OS: Counts while in privilege level is ring 0. + /// + UINT32 OS:1; + /// + /// [Bit 18] Edge: Enables edge detection if set. + /// + UINT32 E:1; + /// + /// [Bit 19] PC: enables pin control. + /// + UINT32 PC:1; + /// + /// [Bit 20] INT: enables interrupt on counter overflow. + /// + UINT32 INT:1; + /// + /// [Bit 21] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. + /// + UINT32 ANY:1; + /// + /// [Bit 22] EN: enables the corresponding performance counter to commence + /// counting when this bit is set. + /// + UINT32 EN:1; + /// + /// [Bit 23] INV: invert the CMASK. + /// + UINT32 INV:1; + /// + /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding + /// performance counter increments each cycle if the event count is + /// greater than or equal to the CMASK. + /// + UINT32 CMASK:8; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERFEVTSEL_REGISTER; + + +/** + Current performance state(P-State) operating point (RO). Introduced at + Display Family / Display Model 0F_03H. + + @param ECX MSR_IA32_PERF_STATUS (0x00000198) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_PERF_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_STATUS); + @endcode + @note MSR_IA32_PERF_STATUS is defined as IA32_PERF_STATUS in SDM. +**/ +#define MSR_IA32_PERF_STATUS 0x00000198 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Current performance State Value. + /// + UINT32 State:16; + UINT32 Reserved1:16; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_STATUS_REGISTER; + + +/** + (R/W). Introduced at Display Family / Display Model 0F_03H. + + @param ECX MSR_IA32_PERF_CTL (0x00000199) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_CTL_REGISTER. + + Example usage + @code + MSR_IA32_PERF_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_CTL); + AsmWriteMsr64 (MSR_IA32_PERF_CTL, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_CTL is defined as IA32_PERF_CTL in SDM. +**/ +#define MSR_IA32_PERF_CTL 0x00000199 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Target performance State Value. + /// + UINT32 TargetState:16; + UINT32 Reserved1:16; + /// + /// [Bit 32] IDA Engage. (R/W) When set to 1: disengages IDA. 06_0FH + /// (Mobile only). + /// + UINT32 IDA:1; + UINT32 Reserved2:31; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_CTL_REGISTER; + + +/** + Clock Modulation Control (R/W) See Section 14.7.3, "Software Controlled + Clock Modulation.". If CPUID.01H:EDX[22] = 1. + + @param ECX MSR_IA32_CLOCK_MODULATION (0x0000019A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_CLOCK_MODULATION_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_CLOCK_MODULATION_REGISTER. + + Example usage + @code + MSR_IA32_CLOCK_MODULATION_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_CLOCK_MODULATION); + AsmWriteMsr64 (MSR_IA32_CLOCK_MODULATION, Msr.Uint64); + @endcode + @note MSR_IA32_CLOCK_MODULATION is defined as IA32_CLOCK_MODULATION in SDM. +**/ +#define MSR_IA32_CLOCK_MODULATION 0x0000019A + +/** + MSR information returned for MSR index #MSR_IA32_CLOCK_MODULATION +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Extended On-Demand Clock Modulation Duty Cycle:. If + /// CPUID.06H:EAX[5] = 1. + /// + UINT32 ExtendedOnDemandClockModulationDutyCycle:1; + /// + /// [Bits 3:1] On-Demand Clock Modulation Duty Cycle: Specific encoded + /// values for target duty cycle modulation. If CPUID.01H:EDX[22] = 1. + /// + UINT32 OnDemandClockModulationDutyCycle:3; + /// + /// [Bit 4] On-Demand Clock Modulation Enable: Set 1 to enable modulation. + /// If CPUID.01H:EDX[22] = 1. + /// + UINT32 OnDemandClockModulationEnable:1; + UINT32 Reserved1:27; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_CLOCK_MODULATION_REGISTER; + + +/** + Thermal Interrupt Control (R/W) Enables and disables the generation of an + interrupt on temperature transitions detected with the processor's thermal + sensors and thermal monitor. See Section 14.7.2, "Thermal Monitor.". + If CPUID.01H:EDX[22] = 1 + + @param ECX MSR_IA32_THERM_INTERRUPT (0x0000019B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_THERM_INTERRUPT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_THERM_INTERRUPT_REGISTER. + + Example usage + @code + MSR_IA32_THERM_INTERRUPT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_THERM_INTERRUPT); + AsmWriteMsr64 (MSR_IA32_THERM_INTERRUPT, Msr.Uint64); + @endcode + @note MSR_IA32_THERM_INTERRUPT is defined as IA32_THERM_INTERRUPT in SDM. +**/ +#define MSR_IA32_THERM_INTERRUPT 0x0000019B + +/** + MSR information returned for MSR index #MSR_IA32_THERM_INTERRUPT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] High-Temperature Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 HighTempEnable:1; + /// + /// [Bit 1] Low-Temperature Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 LowTempEnable:1; + /// + /// [Bit 2] PROCHOT# Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 PROCHOT_Enable:1; + /// + /// [Bit 3] FORCEPR# Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 FORCEPR_Enable:1; + /// + /// [Bit 4] Critical Temperature Interrupt Enable. + /// If CPUID.01H:EDX[22] = 1. + /// + UINT32 CriticalTempEnable:1; + UINT32 Reserved1:3; + /// + /// [Bits 14:8] Threshold #1 Value. If CPUID.01H:EDX[22] = 1. + /// + UINT32 Threshold1:7; + /// + /// [Bit 15] Threshold #1 Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 Threshold1Enable:1; + /// + /// [Bits 22:16] Threshold #2 Value. If CPUID.01H:EDX[22] = 1. + /// + UINT32 Threshold2:7; + /// + /// [Bit 23] Threshold #2 Interrupt Enable. If CPUID.01H:EDX[22] = 1. + /// + UINT32 Threshold2Enable:1; + /// + /// [Bit 24] Power Limit Notification Enable. If CPUID.06H:EAX[4] = 1. + /// + UINT32 PowerLimitNotificationEnable:1; + UINT32 Reserved2:7; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_THERM_INTERRUPT_REGISTER; + + +/** + Thermal Status Information (RO) Contains status information about the + processor's thermal sensor and automatic thermal monitoring facilities. See + Section 14.7.2, "Thermal Monitor". If CPUID.01H:EDX[22] = 1. + + @param ECX MSR_IA32_THERM_STATUS (0x0000019C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_THERM_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_THERM_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_THERM_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_THERM_STATUS); + @endcode + @note MSR_IA32_THERM_STATUS is defined as IA32_THERM_STATUS in SDM. +**/ +#define MSR_IA32_THERM_STATUS 0x0000019C + +/** + MSR information returned for MSR index #MSR_IA32_THERM_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thermal Status (RO):. If CPUID.01H:EDX[22] = 1. + /// + UINT32 ThermalStatus:1; + /// + /// [Bit 1] Thermal Status Log (R/W):. If CPUID.01H:EDX[22] = 1. + /// + UINT32 ThermalStatusLog:1; + /// + /// [Bit 2] PROCHOT # or FORCEPR# event (RO). If CPUID.01H:EDX[22] = 1. + /// + UINT32 PROCHOT_FORCEPR_Event:1; + /// + /// [Bit 3] PROCHOT # or FORCEPR# log (R/WC0). If CPUID.01H:EDX[22] = 1. + /// + UINT32 PROCHOT_FORCEPR_Log:1; + /// + /// [Bit 4] Critical Temperature Status (RO). If CPUID.01H:EDX[22] = 1. + /// + UINT32 CriticalTempStatus:1; + /// + /// [Bit 5] Critical Temperature Status log (R/WC0). + /// If CPUID.01H:EDX[22] = 1. + /// + UINT32 CriticalTempStatusLog:1; + /// + /// [Bit 6] Thermal Threshold #1 Status (RO). If CPUID.01H:ECX[8] = 1. + /// + UINT32 ThermalThreshold1Status:1; + /// + /// [Bit 7] Thermal Threshold #1 log (R/WC0). If CPUID.01H:ECX[8] = 1. + /// + UINT32 ThermalThreshold1Log:1; + /// + /// [Bit 8] Thermal Threshold #2 Status (RO). If CPUID.01H:ECX[8] = 1. + /// + UINT32 ThermalThreshold2Status:1; + /// + /// [Bit 9] Thermal Threshold #2 log (R/WC0). If CPUID.01H:ECX[8] = 1. + /// + UINT32 ThermalThreshold2Log:1; + /// + /// [Bit 10] Power Limitation Status (RO). If CPUID.06H:EAX[4] = 1. + /// + UINT32 PowerLimitStatus:1; + /// + /// [Bit 11] Power Limitation log (R/WC0). If CPUID.06H:EAX[4] = 1. + /// + UINT32 PowerLimitLog:1; + /// + /// [Bit 12] Current Limit Status (RO). If CPUID.06H:EAX[7] = 1. + /// + UINT32 CurrentLimitStatus:1; + /// + /// [Bit 13] Current Limit log (R/WC0). If CPUID.06H:EAX[7] = 1. + /// + UINT32 CurrentLimitLog:1; + /// + /// [Bit 14] Cross Domain Limit Status (RO). If CPUID.06H:EAX[7] = 1. + /// + UINT32 CrossDomainLimitStatus:1; + /// + /// [Bit 15] Cross Domain Limit log (R/WC0). If CPUID.06H:EAX[7] = 1. + /// + UINT32 CrossDomainLimitLog:1; + /// + /// [Bits 22:16] Digital Readout (RO). If CPUID.06H:EAX[0] = 1. + /// + UINT32 DigitalReadout:7; + UINT32 Reserved1:4; + /// + /// [Bits 30:27] Resolution in Degrees Celsius (RO). If CPUID.06H:EAX[0] = + /// 1. + /// + UINT32 ResolutionInDegreesCelsius:4; + /// + /// [Bit 31] Reading Valid (RO). If CPUID.06H:EAX[0] = 1. + /// + UINT32 ReadingValid:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_THERM_STATUS_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fast-Strings Enable When set, the fast-strings feature (for + /// REP MOVS and REP STORS) is enabled (default); when clear, fast-strings + /// are disabled. Introduced at Display Family / Display Model 0F_0H. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) 1 = Setting + /// this bit enables the thermal control circuit (TCC) portion of the + /// Intel Thermal Monitor feature. This allows the processor to + /// automatically reduce power consumption in response to TCC activation. + /// 0 = Disabled. Note: In some products clearing this bit might be + /// ignored in critical thermal conditions, and TM1, TM2 and adaptive + /// thermal throttling will still be activated. The default value of this + /// field varies with product. See respective tables where default value is + /// listed. Introduced at Display Family / Display Model 0F_0H. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Performance Monitoring Available (R) 1 = Performance + /// monitoring enabled 0 = Performance monitoring disabled. Introduced at + /// Display Family / Display Model 0F_0H. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:3; + /// + /// [Bit 11] Branch Trace Storage Unavailable (RO) 1 = Processor doesn't + /// support branch trace storage (BTS) 0 = BTS is supported. Introduced at + /// Display Family / Display Model 0F_0H. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Processor Event Based Sampling (PEBS) Unavailable (RO) 1 = + /// PEBS is not supported; 0 = PEBS is supported. Introduced at Display + /// Family / Display Model 06_0FH. + /// + UINT32 PEBS:1; + UINT32 Reserved4:3; + /// + /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W) 0= Enhanced + /// Intel SpeedStep Technology disabled 1 = Enhanced Intel SpeedStep + /// Technology enabled. If CPUID.01H: ECX[7] =1. + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] ENABLE MONITOR FSM (R/W) When this bit is set to 0, the + /// MONITOR feature flag is not set (CPUID.01H:ECX[bit 3] = 0). This + /// indicates that MONITOR/MWAIT are not supported. Software attempts to + /// execute MONITOR/MWAIT will cause #UD when this bit is 0. When this bit + /// is set to 1 (default), MONITOR/MWAIT are supported (CPUID.01H:ECX[bit + /// 3] = 1). If the SSE3 feature flag ECX[0] is not set (CPUID.01H:ECX[bit + /// 0] = 0), the OS must not attempt to alter this bit. BIOS must leave it + /// in the default state. Writing this bit when the SSE3 feature flag is + /// set to 0 may generate a #GP exception. Introduced at Display Family / + /// Display Model 0F_03H. + /// + UINT32 MONITOR:1; + UINT32 Reserved6:3; + /// + /// [Bit 22] Limit CPUID Maxval (R/W) When this bit is set to 1, CPUID.00H + /// returns a maximum value in EAX[7:0] of 2. BIOS should contain a setup + /// question that allows users to specify when the installed OS does not + /// support CPUID functions greater than 2. Before setting this bit, BIOS + /// must execute the CPUID.0H and examine the maximum value returned in + /// EAX[7:0]. If the maximum value is greater than 2, this bit is + /// supported. Otherwise, this bit is not supported. Setting this bit when + /// the maximum value is not greater than 2 may generate a #GP exception. + /// Setting this bit may cause unexpected behavior in software that + /// depends on the availability of CPUID leaves greater than 2. Introduced + /// at Display Family / Display Model 0F_03H. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] xTPR Message Disable (R/W) When set to 1, xTPR messages are + /// disabled. xTPR messages are optional messages that allow the processor + /// to inform the chipset of its priority. if CPUID.01H:ECX[14] = 1. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] XD Bit Disable (R/W) When set to 1, the Execute Disable Bit + /// feature (XD Bit) is disabled and the XD Bit extended feature flag will + /// be clear (CPUID.80000001H: EDX[20]=0). When set to a 0 (default), the + /// Execute Disable Bit feature (if available) allows the OS to enable PAE + /// paging and take advantage of data only pages. BIOS must not alter the + /// contents of this bit location, if XD bit is not supported. Writing + /// this bit to 1 when the XD Bit extended feature flag is set to 0 may + /// generate a #GP exception. if CPUID.80000001H:EDX[2 0] = 1. + /// + UINT32 XD:1; + UINT32 Reserved9:29; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MISC_ENABLE_REGISTER; + + +/** + Performance Energy Bias Hint (R/W). if CPUID.6H:ECX[3] = 1. + + @param ECX MSR_IA32_ENERGY_PERF_BIAS (0x000001B0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_ENERGY_PERF_BIAS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_ENERGY_PERF_BIAS_REGISTER. + + Example usage + @code + MSR_IA32_ENERGY_PERF_BIAS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_ENERGY_PERF_BIAS); + AsmWriteMsr64 (MSR_IA32_ENERGY_PERF_BIAS, Msr.Uint64); + @endcode + @note MSR_IA32_ENERGY_PERF_BIAS is defined as IA32_ENERGY_PERF_BIAS in SDM. +**/ +#define MSR_IA32_ENERGY_PERF_BIAS 0x000001B0 + +/** + MSR information returned for MSR index #MSR_IA32_ENERGY_PERF_BIAS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Power Policy Preference: 0 indicates preference to highest + /// performance. 15 indicates preference to maximize energy saving. + /// + UINT32 PowerPolicyPreference:4; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_ENERGY_PERF_BIAS_REGISTER; + + +/** + Package Thermal Status Information (RO) Contains status information about + the package's thermal sensor. See Section 14.8, "Package Level Thermal + Management.". If CPUID.06H: EAX[6] = 1. + + @param ECX MSR_IA32_PACKAGE_THERM_STATUS (0x000001B1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PACKAGE_THERM_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PACKAGE_THERM_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_PACKAGE_THERM_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PACKAGE_THERM_STATUS); + @endcode + @note MSR_IA32_PACKAGE_THERM_STATUS is defined as IA32_PACKAGE_THERM_STATUS in SDM. +**/ +#define MSR_IA32_PACKAGE_THERM_STATUS 0x000001B1 + +/** + MSR information returned for MSR index #MSR_IA32_PACKAGE_THERM_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Pkg Thermal Status (RO):. + /// + UINT32 ThermalStatus:1; + /// + /// [Bit 1] Pkg Thermal Status Log (R/W):. + /// + UINT32 ThermalStatusLog:1; + /// + /// [Bit 2] Pkg PROCHOT # event (RO). + /// + UINT32 PROCHOT_Event:1; + /// + /// [Bit 3] Pkg PROCHOT # log (R/WC0). + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 4] Pkg Critical Temperature Status (RO). + /// + UINT32 CriticalTempStatus:1; + /// + /// [Bit 5] Pkg Critical Temperature Status log (R/WC0). + /// + UINT32 CriticalTempStatusLog:1; + /// + /// [Bit 6] Pkg Thermal Threshold #1 Status (RO). + /// + UINT32 ThermalThreshold1Status:1; + /// + /// [Bit 7] Pkg Thermal Threshold #1 log (R/WC0). + /// + UINT32 ThermalThreshold1Log:1; + /// + /// [Bit 8] Pkg Thermal Threshold #2 Status (RO). + /// + UINT32 ThermalThreshold2Status:1; + /// + /// [Bit 9] Pkg Thermal Threshold #1 log (R/WC0). + /// + UINT32 ThermalThreshold2Log:1; + /// + /// [Bit 10] Pkg Power Limitation Status (RO). + /// + UINT32 PowerLimitStatus:1; + /// + /// [Bit 11] Pkg Power Limitation log (R/WC0). + /// + UINT32 PowerLimitLog:1; + UINT32 Reserved1:4; + /// + /// [Bits 22:16] Pkg Digital Readout (RO). + /// + UINT32 DigitalReadout:7; + UINT32 Reserved2:9; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PACKAGE_THERM_STATUS_REGISTER; + + +/** + Pkg Thermal Interrupt Control (R/W) Enables and disables the generation of + an interrupt on temperature transitions detected with the package's thermal + sensor. See Section 14.8, "Package Level Thermal Management.". If CPUID.06H: + EAX[6] = 1. + + @param ECX MSR_IA32_PACKAGE_THERM_INTERRUPT (0x000001B2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER. + + Example usage + @code + MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PACKAGE_THERM_INTERRUPT); + AsmWriteMsr64 (MSR_IA32_PACKAGE_THERM_INTERRUPT, Msr.Uint64); + @endcode + @note MSR_IA32_PACKAGE_THERM_INTERRUPT is defined as IA32_PACKAGE_THERM_INTERRUPT in SDM. +**/ +#define MSR_IA32_PACKAGE_THERM_INTERRUPT 0x000001B2 + +/** + MSR information returned for MSR index #MSR_IA32_PACKAGE_THERM_INTERRUPT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Pkg High-Temperature Interrupt Enable. + /// + UINT32 HighTempEnable:1; + /// + /// [Bit 1] Pkg Low-Temperature Interrupt Enable. + /// + UINT32 LowTempEnable:1; + /// + /// [Bit 2] Pkg PROCHOT# Interrupt Enable. + /// + UINT32 PROCHOT_Enable:1; + UINT32 Reserved1:1; + /// + /// [Bit 4] Pkg Overheat Interrupt Enable. + /// + UINT32 OverheatEnable:1; + UINT32 Reserved2:3; + /// + /// [Bits 14:8] Pkg Threshold #1 Value. + /// + UINT32 Threshold1:7; + /// + /// [Bit 15] Pkg Threshold #1 Interrupt Enable. + /// + UINT32 Threshold1Enable:1; + /// + /// [Bits 22:16] Pkg Threshold #2 Value. + /// + UINT32 Threshold2:7; + /// + /// [Bit 23] Pkg Threshold #2 Interrupt Enable. + /// + UINT32 Threshold2Enable:1; + /// + /// [Bit 24] Pkg Power Limit Notification Enable. + /// + UINT32 PowerLimitNotificationEnable:1; + UINT32 Reserved3:7; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER; + + +/** + Trace/Profile Resource Control (R/W). Introduced at Display Family / Display + Model 06_0EH. + + @param ECX MSR_IA32_DEBUGCTL (0x000001D9) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_DEBUGCTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_DEBUGCTL_REGISTER. + + Example usage + @code + MSR_IA32_DEBUGCTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DEBUGCTL); + AsmWriteMsr64 (MSR_IA32_DEBUGCTL, Msr.Uint64); + @endcode + @note MSR_IA32_DEBUGCTL is defined as IA32_DEBUGCTL in SDM. +**/ +#define MSR_IA32_DEBUGCTL 0x000001D9 + +/** + MSR information returned for MSR index #MSR_IA32_DEBUGCTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LBR: Setting this bit to 1 enables the processor to record a + /// running trace of the most recent branches taken by the processor in + /// the LBR stack. Introduced at Display Family / Display Model 06_01H. + /// + UINT32 LBR:1; + /// + /// [Bit 1] BTF: Setting this bit to 1 enables the processor to treat + /// EFLAGS.TF as single-step on branches instead of single-step on + /// instructions. Introduced at Display Family / Display Model 06_01H. + /// + UINT32 BTF:1; + UINT32 Reserved1:4; + /// + /// [Bit 6] TR: Setting this bit to 1 enables branch trace messages to be + /// sent. Introduced at Display Family / Display Model 06_0EH. + /// + UINT32 TR:1; + /// + /// [Bit 7] BTS: Setting this bit enables branch trace messages (BTMs) to + /// be logged in a BTS buffer. Introduced at Display Family / Display + /// Model 06_0EH. + /// + UINT32 BTS:1; + /// + /// [Bit 8] BTINT: When clear, BTMs are logged in a BTS buffer in circular + /// fashion. When this bit is set, an interrupt is generated by the BTS + /// facility when the BTS buffer is full. Introduced at Display Family / + /// Display Model 06_0EH. + /// + UINT32 BTINT:1; + /// + /// [Bit 9] BTS_OFF_OS: When set, BTS or BTM is skipped if CPL = 0. + /// Introduced at Display Family / Display Model 06_0FH. + /// + UINT32 BTS_OFF_OS:1; + /// + /// [Bit 10] BTS_OFF_USR: When set, BTS or BTM is skipped if CPL > 0. + /// Introduced at Display Family / Display Model 06_0FH. + /// + UINT32 BTS_OFF_USR:1; + /// + /// [Bit 11] FREEZE_LBRS_ON_PMI: When set, the LBR stack is frozen on a + /// PMI request. If CPUID.01H: ECX[15] = 1 && CPUID.0AH: EAX[7:0] > 1. + /// + UINT32 FREEZE_LBRS_ON_PMI:1; + /// + /// [Bit 12] FREEZE_PERFMON_ON_PMI: When set, each ENABLE bit of the + /// global counter control MSR are frozen (address 38FH) on a PMI request. + /// If CPUID.01H: ECX[15] = 1 && CPUID.0AH: EAX[7:0] > 1. + /// + UINT32 FREEZE_PERFMON_ON_PMI:1; + /// + /// [Bit 13] ENABLE_UNCORE_PMI: When set, enables the logical processor to + /// receive and generate PMI on behalf of the uncore. Introduced at + /// Display Family / Display Model 06_1AH. + /// + UINT32 ENABLE_UNCORE_PMI:1; + /// + /// [Bit 14] FREEZE_WHILE_SMM: When set, freezes perfmon and trace + /// messages while in SMM. If IA32_PERF_CAPABILITIES[ 12] = 1. + /// + UINT32 FREEZE_WHILE_SMM:1; + /// + /// [Bit 15] RTM_DEBUG: When set, enables DR7 debug bit on XBEGIN. If + /// (CPUID.(EAX=07H, ECX=0):EBX[11] = 1). + /// + UINT32 RTM_DEBUG:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_DEBUGCTL_REGISTER; + + +/** + SMRR Base Address (Writeable only in SMM) Base address of SMM memory range. + If IA32_MTRRCAP.SMRR[11] = 1. + + @param ECX MSR_IA32_SMRR_PHYSBASE (0x000001F2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_SMRR_PHYSBASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_SMRR_PHYSBASE_REGISTER. + + Example usage + @code + MSR_IA32_SMRR_PHYSBASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMRR_PHYSBASE); + AsmWriteMsr64 (MSR_IA32_SMRR_PHYSBASE, Msr.Uint64); + @endcode + @note MSR_IA32_SMRR_PHYSBASE is defined as IA32_SMRR_PHYSBASE in SDM. +**/ +#define MSR_IA32_SMRR_PHYSBASE 0x000001F2 + +/** + MSR information returned for MSR index #MSR_IA32_SMRR_PHYSBASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Type. Specifies memory type of the range. + /// + UINT32 Type:8; + UINT32 Reserved1:4; + /// + /// [Bits 31:12] PhysBase. SMRR physical Base Address. + /// + UINT32 PhysBase:20; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_SMRR_PHYSBASE_REGISTER; + + +/** + SMRR Range Mask. (Writeable only in SMM) Range Mask of SMM memory range. If + IA32_MTRRCAP[SMRR] = 1. + + @param ECX MSR_IA32_SMRR_PHYSMASK (0x000001F3) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_SMRR_PHYSMASK_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_SMRR_PHYSMASK_REGISTER. + + Example usage + @code + MSR_IA32_SMRR_PHYSMASK_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMRR_PHYSMASK); + AsmWriteMsr64 (MSR_IA32_SMRR_PHYSMASK, Msr.Uint64); + @endcode + @note MSR_IA32_SMRR_PHYSMASK is defined as IA32_SMRR_PHYSMASK in SDM. +**/ +#define MSR_IA32_SMRR_PHYSMASK 0x000001F3 + +/** + MSR information returned for MSR index #MSR_IA32_SMRR_PHYSMASK +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:11; + /// + /// [Bit 11] Valid Enable range mask. + /// + UINT32 Valid:1; + /// + /// [Bits 31:12] PhysMask SMRR address range mask. + /// + UINT32 PhysMask:20; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_SMRR_PHYSMASK_REGISTER; + + +/** + DCA Capability (R). If CPUID.01H: ECX[18] = 1. + + @param ECX MSR_IA32_PLATFORM_DCA_CAP (0x000001F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_PLATFORM_DCA_CAP); + @endcode + @note MSR_IA32_PLATFORM_DCA_CAP is defined as IA32_PLATFORM_DCA_CAP in SDM. +**/ +#define MSR_IA32_PLATFORM_DCA_CAP 0x000001F8 + + +/** + If set, CPU supports Prefetch-Hint type. If CPUID.01H: ECX[18] = 1. + + @param ECX MSR_IA32_CPU_DCA_CAP (0x000001F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_CPU_DCA_CAP); + AsmWriteMsr64 (MSR_IA32_CPU_DCA_CAP, Msr); + @endcode + @note MSR_IA32_CPU_DCA_CAP is defined as IA32_CPU_DCA_CAP in SDM. +**/ +#define MSR_IA32_CPU_DCA_CAP 0x000001F9 + + +/** + DCA type 0 Status and Control register. If CPUID.01H: ECX[18] = 1. + + @param ECX MSR_IA32_DCA_0_CAP (0x000001FA) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_DCA_0_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_DCA_0_CAP_REGISTER. + + Example usage + @code + MSR_IA32_DCA_0_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DCA_0_CAP); + AsmWriteMsr64 (MSR_IA32_DCA_0_CAP, Msr.Uint64); + @endcode + @note MSR_IA32_DCA_0_CAP is defined as IA32_DCA_0_CAP in SDM. +**/ +#define MSR_IA32_DCA_0_CAP 0x000001FA + +/** + MSR information returned for MSR index #MSR_IA32_DCA_0_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] DCA_ACTIVE: Set by HW when DCA is fuseenabled and no + /// defeatures are set. + /// + UINT32 DCA_ACTIVE:1; + /// + /// [Bits 2:1] TRANSACTION. + /// + UINT32 TRANSACTION:2; + /// + /// [Bits 6:3] DCA_TYPE. + /// + UINT32 DCA_TYPE:4; + /// + /// [Bits 10:7] DCA_QUEUE_SIZE. + /// + UINT32 DCA_QUEUE_SIZE:4; + UINT32 Reserved1:2; + /// + /// [Bits 16:13] DCA_DELAY: Writes will update the register but have no HW + /// side-effect. + /// + UINT32 DCA_DELAY:4; + UINT32 Reserved2:7; + /// + /// [Bit 24] SW_BLOCK: SW can request DCA block by setting this bit. + /// + UINT32 SW_BLOCK:1; + UINT32 Reserved3:1; + /// + /// [Bit 26] HW_BLOCK: Set when DCA is blocked by HW (e.g. CR0.CD = 1). + /// + UINT32 HW_BLOCK:1; + UINT32 Reserved4:5; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_DCA_0_CAP_REGISTER; + + +/** + MTRRphysBasen. See Section 11.11.2.3, "Variable Range MTRRs". + If CPUID.01H: EDX.MTRR[12] = 1 and IA32_MTRRCAP[7:0] > n. + + @param ECX MSR_IA32_MTRR_PHYSBASEn + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_PHYSBASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_PHYSBASE_REGISTER. + + Example usage + @code + MSR_IA32_MTRR_PHYSBASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0); + AsmWriteMsr64 (MSR_IA32_MTRR_PHYSBASE0, Msr.Uint64); + @endcode + @note MSR_IA32_MTRR_PHYSBASE0 is defined as IA32_MTRR_PHYSBASE0 in SDM. + MSR_IA32_MTRR_PHYSBASE1 is defined as IA32_MTRR_PHYSBASE1 in SDM. + MSR_IA32_MTRR_PHYSBASE2 is defined as IA32_MTRR_PHYSBASE2 in SDM. + MSR_IA32_MTRR_PHYSBASE3 is defined as IA32_MTRR_PHYSBASE3 in SDM. + MSR_IA32_MTRR_PHYSBASE4 is defined as IA32_MTRR_PHYSBASE4 in SDM. + MSR_IA32_MTRR_PHYSBASE5 is defined as IA32_MTRR_PHYSBASE5 in SDM. + MSR_IA32_MTRR_PHYSBASE6 is defined as IA32_MTRR_PHYSBASE6 in SDM. + MSR_IA32_MTRR_PHYSBASE7 is defined as IA32_MTRR_PHYSBASE7 in SDM. + MSR_IA32_MTRR_PHYSBASE8 is defined as IA32_MTRR_PHYSBASE8 in SDM. + MSR_IA32_MTRR_PHYSBASE9 is defined as IA32_MTRR_PHYSBASE9 in SDM. + @{ +**/ +#define MSR_IA32_MTRR_PHYSBASE0 0x00000200 +#define MSR_IA32_MTRR_PHYSBASE1 0x00000202 +#define MSR_IA32_MTRR_PHYSBASE2 0x00000204 +#define MSR_IA32_MTRR_PHYSBASE3 0x00000206 +#define MSR_IA32_MTRR_PHYSBASE4 0x00000208 +#define MSR_IA32_MTRR_PHYSBASE5 0x0000020A +#define MSR_IA32_MTRR_PHYSBASE6 0x0000020C +#define MSR_IA32_MTRR_PHYSBASE7 0x0000020E +#define MSR_IA32_MTRR_PHYSBASE8 0x00000210 +#define MSR_IA32_MTRR_PHYSBASE9 0x00000212 +/// @} + +/** + MSR information returned for MSR indexes #MSR_IA32_MTRR_PHYSBASE0 to + #MSR_IA32_MTRR_PHYSBASE9 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Type. Specifies memory type of the range. + /// + UINT32 Type:8; + UINT32 Reserved1:4; + /// + /// [Bits 31:12] PhysBase. MTRR physical Base Address. + /// + UINT32 PhysBase:20; + /// + /// [Bits MAXPHYSADDR:32] PhysBase. Upper bits of MTRR physical Base Address. + /// MAXPHYADDR: The bit position indicated by MAXPHYADDR depends on the + /// maximum physical address range supported by the processor. It is + /// reported by CPUID leaf function 80000008H. If CPUID does not support + /// leaf 80000008H, the processor supports 36-bit physical address size, + /// then bit PhysMask consists of bits 35:12, and bits 63:36 are reserved. + /// + UINT32 PhysBaseHi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MTRR_PHYSBASE_REGISTER; + + +/** + MTRRphysMaskn. See Section 11.11.2.3, "Variable Range MTRRs". + If CPUID.01H: EDX.MTRR[12] = 1 and IA32_MTRRCAP[7:0] > n. + + @param ECX MSR_IA32_MTRR_PHYSMASKn + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_PHYSMASK_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_PHYSMASK_REGISTER. + + Example usage + @code + MSR_IA32_MTRR_PHYSMASK_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0); + AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0, Msr.Uint64); + @endcode + @note MSR_IA32_MTRR_PHYSMASK0 is defined as IA32_MTRR_PHYSMASK0 in SDM. + MSR_IA32_MTRR_PHYSMASK1 is defined as IA32_MTRR_PHYSMASK1 in SDM. + MSR_IA32_MTRR_PHYSMASK2 is defined as IA32_MTRR_PHYSMASK2 in SDM. + MSR_IA32_MTRR_PHYSMASK3 is defined as IA32_MTRR_PHYSMASK3 in SDM. + MSR_IA32_MTRR_PHYSMASK4 is defined as IA32_MTRR_PHYSMASK4 in SDM. + MSR_IA32_MTRR_PHYSMASK5 is defined as IA32_MTRR_PHYSMASK5 in SDM. + MSR_IA32_MTRR_PHYSMASK6 is defined as IA32_MTRR_PHYSMASK6 in SDM. + MSR_IA32_MTRR_PHYSMASK7 is defined as IA32_MTRR_PHYSMASK7 in SDM. + MSR_IA32_MTRR_PHYSMASK8 is defined as IA32_MTRR_PHYSMASK8 in SDM. + MSR_IA32_MTRR_PHYSMASK9 is defined as IA32_MTRR_PHYSMASK9 in SDM. + @{ +**/ +#define MSR_IA32_MTRR_PHYSMASK0 0x00000201 +#define MSR_IA32_MTRR_PHYSMASK1 0x00000203 +#define MSR_IA32_MTRR_PHYSMASK2 0x00000205 +#define MSR_IA32_MTRR_PHYSMASK3 0x00000207 +#define MSR_IA32_MTRR_PHYSMASK4 0x00000209 +#define MSR_IA32_MTRR_PHYSMASK5 0x0000020B +#define MSR_IA32_MTRR_PHYSMASK6 0x0000020D +#define MSR_IA32_MTRR_PHYSMASK7 0x0000020F +#define MSR_IA32_MTRR_PHYSMASK8 0x00000211 +#define MSR_IA32_MTRR_PHYSMASK9 0x00000213 +/// @} + +/** + MSR information returned for MSR indexes #MSR_IA32_MTRR_PHYSMASK0 to + #MSR_IA32_MTRR_PHYSMASK9 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:11; + /// + /// [Bit 11] Valid Enable range mask. + /// + UINT32 V:1; + /// + /// [Bits 31:12] PhysMask. MTRR address range mask. + /// + UINT32 PhysMask:20; + /// + /// [Bits MAXPHYSADDR:32] PhysMask. Upper bits of MTRR address range mask. + /// MAXPHYADDR: The bit position indicated by MAXPHYADDR depends on the + /// maximum physical address range supported by the processor. It is + /// reported by CPUID leaf function 80000008H. If CPUID does not support + /// leaf 80000008H, the processor supports 36-bit physical address size, + /// then bit PhysMask consists of bits 35:12, and bits 63:36 are reserved. + /// + UINT32 PhysMaskHi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MTRR_PHYSMASK_REGISTER; + + +/** + MTRRfix64K_00000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX64K_00000 (0x00000250) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX64K_00000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX64K_00000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX64K_00000 is defined as IA32_MTRR_FIX64K_00000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX64K_00000 0x00000250 + + +/** + MTRRfix16K_80000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX16K_80000 (0x00000258) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX16K_80000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX16K_80000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX16K_80000 is defined as IA32_MTRR_FIX16K_80000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX16K_80000 0x00000258 + + +/** + MTRRfix16K_A0000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX16K_A0000 (0x00000259) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX16K_A0000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX16K_A0000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX16K_A0000 is defined as IA32_MTRR_FIX16K_A0000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX16K_A0000 0x00000259 + + +/** + See Section 11.11.2.2, "Fixed Range MTRRs.". If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_C0000 (0x00000268) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_C0000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_C0000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_C0000 is defined as IA32_MTRR_FIX4K_C0000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_C0000 0x00000268 + + +/** + MTRRfix4K_C8000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_C8000 (0x00000269) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_C8000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_C8000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_C8000 is defined as IA32_MTRR_FIX4K_C8000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_C8000 0x00000269 + + +/** + MTRRfix4K_D0000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_D0000 (0x0000026A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_D0000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_D0000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_D0000 is defined as IA32_MTRR_FIX4K_D0000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_D0000 0x0000026A + + +/** + MTRRfix4K_D8000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_D8000 (0x0000026B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_D8000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_D8000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_D8000 is defined as IA32_MTRR_FIX4K_D8000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_D8000 0x0000026B + + +/** + MTRRfix4K_E0000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_E0000 (0x0000026C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_E0000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_E0000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_E0000 is defined as IA32_MTRR_FIX4K_E0000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_E0000 0x0000026C + + +/** + MTRRfix4K_E8000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_E8000 (0x0000026D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_E8000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_E8000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_E8000 is defined as IA32_MTRR_FIX4K_E8000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_E8000 0x0000026D + + +/** + MTRRfix4K_F0000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_F0000 (0x0000026E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_F0000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_F0000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_F0000 is defined as IA32_MTRR_FIX4K_F0000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_F0000 0x0000026E + + +/** + MTRRfix4K_F8000. If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_FIX4K_F8000 (0x0000026F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_F8000); + AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_F8000, Msr); + @endcode + @note MSR_IA32_MTRR_FIX4K_F8000 is defined as IA32_MTRR_FIX4K_F8000 in SDM. +**/ +#define MSR_IA32_MTRR_FIX4K_F8000 0x0000026F + + +/** + IA32_PAT (R/W). If CPUID.01H: EDX.MTRR[16] =1. + + @param ECX MSR_IA32_PAT (0x00000277) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PAT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PAT_REGISTER. + + Example usage + @code + MSR_IA32_PAT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PAT); + AsmWriteMsr64 (MSR_IA32_PAT, Msr.Uint64); + @endcode + @note MSR_IA32_PAT is defined as IA32_PAT in SDM. +**/ +#define MSR_IA32_PAT 0x00000277 + +/** + MSR information returned for MSR index #MSR_IA32_PAT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] PA0. + /// + UINT32 PA0:3; + UINT32 Reserved1:5; + /// + /// [Bits 10:8] PA1. + /// + UINT32 PA1:3; + UINT32 Reserved2:5; + /// + /// [Bits 18:16] PA2. + /// + UINT32 PA2:3; + UINT32 Reserved3:5; + /// + /// [Bits 26:24] PA3. + /// + UINT32 PA3:3; + UINT32 Reserved4:5; + /// + /// [Bits 34:32] PA4. + /// + UINT32 PA4:3; + UINT32 Reserved5:5; + /// + /// [Bits 42:40] PA5. + /// + UINT32 PA5:3; + UINT32 Reserved6:5; + /// + /// [Bits 50:48] PA6. + /// + UINT32 PA6:3; + UINT32 Reserved7:5; + /// + /// [Bits 58:56] PA7. + /// + UINT32 PA7:3; + UINT32 Reserved8:5; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PAT_REGISTER; + + +/** + Provides the programming interface to use corrected MC error signaling + capability (R/W). If IA32_MCG_CAP[10] = 1 && IA32_MCG_CAP[7:0] > n. + + @param ECX MSR_IA32_MCn_CTL2 + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MC_CTL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MC_CTL2_REGISTER. + + Example usage + @code + MSR_IA32_MC_CTL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MC0_CTL2); + AsmWriteMsr64 (MSR_IA32_MC0_CTL2, Msr.Uint64); + @endcode + @note MSR_IA32_MC0_CTL2 is defined as IA32_MC0_CTL2 in SDM. + MSR_IA32_MC1_CTL2 is defined as IA32_MC1_CTL2 in SDM. + MSR_IA32_MC2_CTL2 is defined as IA32_MC2_CTL2 in SDM. + MSR_IA32_MC3_CTL2 is defined as IA32_MC3_CTL2 in SDM. + MSR_IA32_MC4_CTL2 is defined as IA32_MC4_CTL2 in SDM. + MSR_IA32_MC5_CTL2 is defined as IA32_MC5_CTL2 in SDM. + MSR_IA32_MC6_CTL2 is defined as IA32_MC6_CTL2 in SDM. + MSR_IA32_MC7_CTL2 is defined as IA32_MC7_CTL2 in SDM. + MSR_IA32_MC8_CTL2 is defined as IA32_MC8_CTL2 in SDM. + MSR_IA32_MC9_CTL2 is defined as IA32_MC9_CTL2 in SDM. + MSR_IA32_MC10_CTL2 is defined as IA32_MC10_CTL2 in SDM. + MSR_IA32_MC11_CTL2 is defined as IA32_MC11_CTL2 in SDM. + MSR_IA32_MC12_CTL2 is defined as IA32_MC12_CTL2 in SDM. + MSR_IA32_MC13_CTL2 is defined as IA32_MC13_CTL2 in SDM. + MSR_IA32_MC14_CTL2 is defined as IA32_MC14_CTL2 in SDM. + MSR_IA32_MC15_CTL2 is defined as IA32_MC15_CTL2 in SDM. + MSR_IA32_MC16_CTL2 is defined as IA32_MC16_CTL2 in SDM. + MSR_IA32_MC17_CTL2 is defined as IA32_MC17_CTL2 in SDM. + MSR_IA32_MC18_CTL2 is defined as IA32_MC18_CTL2 in SDM. + MSR_IA32_MC19_CTL2 is defined as IA32_MC19_CTL2 in SDM. + MSR_IA32_MC20_CTL2 is defined as IA32_MC20_CTL2 in SDM. + MSR_IA32_MC21_CTL2 is defined as IA32_MC21_CTL2 in SDM. + MSR_IA32_MC22_CTL2 is defined as IA32_MC22_CTL2 in SDM. + MSR_IA32_MC23_CTL2 is defined as IA32_MC23_CTL2 in SDM. + MSR_IA32_MC24_CTL2 is defined as IA32_MC24_CTL2 in SDM. + MSR_IA32_MC25_CTL2 is defined as IA32_MC25_CTL2 in SDM. + MSR_IA32_MC26_CTL2 is defined as IA32_MC26_CTL2 in SDM. + MSR_IA32_MC27_CTL2 is defined as IA32_MC27_CTL2 in SDM. + MSR_IA32_MC28_CTL2 is defined as IA32_MC28_CTL2 in SDM. + MSR_IA32_MC29_CTL2 is defined as IA32_MC29_CTL2 in SDM. + MSR_IA32_MC30_CTL2 is defined as IA32_MC30_CTL2 in SDM. + MSR_IA32_MC31_CTL2 is defined as IA32_MC31_CTL2 in SDM. + @{ +**/ +#define MSR_IA32_MC0_CTL2 0x00000280 +#define MSR_IA32_MC1_CTL2 0x00000281 +#define MSR_IA32_MC2_CTL2 0x00000282 +#define MSR_IA32_MC3_CTL2 0x00000283 +#define MSR_IA32_MC4_CTL2 0x00000284 +#define MSR_IA32_MC5_CTL2 0x00000285 +#define MSR_IA32_MC6_CTL2 0x00000286 +#define MSR_IA32_MC7_CTL2 0x00000287 +#define MSR_IA32_MC8_CTL2 0x00000288 +#define MSR_IA32_MC9_CTL2 0x00000289 +#define MSR_IA32_MC10_CTL2 0x0000028A +#define MSR_IA32_MC11_CTL2 0x0000028B +#define MSR_IA32_MC12_CTL2 0x0000028C +#define MSR_IA32_MC13_CTL2 0x0000028D +#define MSR_IA32_MC14_CTL2 0x0000028E +#define MSR_IA32_MC15_CTL2 0x0000028F +#define MSR_IA32_MC16_CTL2 0x00000290 +#define MSR_IA32_MC17_CTL2 0x00000291 +#define MSR_IA32_MC18_CTL2 0x00000292 +#define MSR_IA32_MC19_CTL2 0x00000293 +#define MSR_IA32_MC20_CTL2 0x00000294 +#define MSR_IA32_MC21_CTL2 0x00000295 +#define MSR_IA32_MC22_CTL2 0x00000296 +#define MSR_IA32_MC23_CTL2 0x00000297 +#define MSR_IA32_MC24_CTL2 0x00000298 +#define MSR_IA32_MC25_CTL2 0x00000299 +#define MSR_IA32_MC26_CTL2 0x0000029A +#define MSR_IA32_MC27_CTL2 0x0000029B +#define MSR_IA32_MC28_CTL2 0x0000029C +#define MSR_IA32_MC29_CTL2 0x0000029D +#define MSR_IA32_MC30_CTL2 0x0000029E +#define MSR_IA32_MC31_CTL2 0x0000029F +/// @} + +/** + MSR information returned for MSR indexes #MSR_IA32_MC0_CTL2 + to #MSR_IA32_MC31_CTL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Corrected error count threshold. + /// + UINT32 CorrectedErrorCountThreshold:15; + UINT32 Reserved1:15; + /// + /// [Bit 30] CMCI_EN. + /// + UINT32 CMCI_EN:1; + UINT32 Reserved2:1; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MC_CTL2_REGISTER; + + +/** + MTRRdefType (R/W). If CPUID.01H: EDX.MTRR[12] =1. + + @param ECX MSR_IA32_MTRR_DEF_TYPE (0x000002FF) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_DEF_TYPE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MTRR_DEF_TYPE_REGISTER. + + Example usage + @code + MSR_IA32_MTRR_DEF_TYPE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, Msr.Uint64); + @endcode + @note MSR_IA32_MTRR_DEF_TYPE is defined as IA32_MTRR_DEF_TYPE in SDM. +**/ +#define MSR_IA32_MTRR_DEF_TYPE 0x000002FF + +/** + MSR information returned for MSR index #MSR_IA32_MTRR_DEF_TYPE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Default Memory Type. + /// + UINT32 Type:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] Fixed Range MTRR Enable. + /// + UINT32 FE:1; + /// + /// [Bit 11] MTRR Enable. + /// + UINT32 E:1; + UINT32 Reserved2:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MTRR_DEF_TYPE_REGISTER; + + +/** + Fixed-Function Performance Counter 0 (R/W): Counts Instr_Retired.Any. If + CPUID.0AH: EDX[4:0] > 0. + + @param ECX MSR_IA32_FIXED_CTR0 (0x00000309) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR0); + AsmWriteMsr64 (MSR_IA32_FIXED_CTR0, Msr); + @endcode + @note MSR_IA32_FIXED_CTR0 is defined as IA32_FIXED_CTR0 in SDM. +**/ +#define MSR_IA32_FIXED_CTR0 0x00000309 + + +/** + Fixed-Function Performance Counter 1 (R/W): Counts CPU_CLK_Unhalted.Core. If + CPUID.0AH: EDX[4:0] > 1. + + @param ECX MSR_IA32_FIXED_CTR1 (0x0000030A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR1); + AsmWriteMsr64 (MSR_IA32_FIXED_CTR1, Msr); + @endcode + @note MSR_IA32_FIXED_CTR1 is defined as IA32_FIXED_CTR1 in SDM. +**/ +#define MSR_IA32_FIXED_CTR1 0x0000030A + + +/** + Fixed-Function Performance Counter 2 (R/W): Counts CPU_CLK_Unhalted.Ref. If + CPUID.0AH: EDX[4:0] > 2. + + @param ECX MSR_IA32_FIXED_CTR2 (0x0000030B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR2); + AsmWriteMsr64 (MSR_IA32_FIXED_CTR2, Msr); + @endcode + @note MSR_IA32_FIXED_CTR2 is defined as IA32_FIXED_CTR2 in SDM. +**/ +#define MSR_IA32_FIXED_CTR2 0x0000030B + + +/** + RO. If CPUID.01H: ECX[15] = 1. + + @param ECX MSR_IA32_PERF_CAPABILITIES (0x00000345) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_CAPABILITIES_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_CAPABILITIES_REGISTER. + + Example usage + @code + MSR_IA32_PERF_CAPABILITIES_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_CAPABILITIES); + AsmWriteMsr64 (MSR_IA32_PERF_CAPABILITIES, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_CAPABILITIES is defined as IA32_PERF_CAPABILITIES in SDM. +**/ +#define MSR_IA32_PERF_CAPABILITIES 0x00000345 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_CAPABILITIES +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 5:0] LBR format. + /// + UINT32 LBR_FMT:6; + /// + /// [Bit 6] PEBS Trap. + /// + UINT32 PEBS_TRAP:1; + /// + /// [Bit 7] PEBSSaveArchRegs. + /// + UINT32 PEBS_ARCH_REG:1; + /// + /// [Bits 11:8] PEBS Record Format. + /// + UINT32 PEBS_REC_FMT:4; + /// + /// [Bit 12] 1: Freeze while SMM is supported. + /// + UINT32 SMM_FREEZE:1; + /// + /// [Bit 13] 1: Full width of counter writable via IA32_A_PMCx. + /// + UINT32 FW_WRITE:1; + UINT32 Reserved1:18; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_CAPABILITIES_REGISTER; + + +/** + Fixed-Function Performance Counter Control (R/W) Counter increments while + the results of ANDing respective enable bit in IA32_PERF_GLOBAL_CTRL with + the corresponding OS or USR bits in this MSR is true. If CPUID.0AH: EAX[7:0] + > 1. + + @param ECX MSR_IA32_FIXED_CTR_CTRL (0x0000038D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_FIXED_CTR_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_FIXED_CTR_CTRL_REGISTER. + + Example usage + @code + MSR_IA32_FIXED_CTR_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_FIXED_CTR_CTRL); + AsmWriteMsr64 (MSR_IA32_FIXED_CTR_CTRL, Msr.Uint64); + @endcode + @note MSR_IA32_FIXED_CTR_CTRL is defined as IA32_FIXED_CTR_CTRL in SDM. +**/ +#define MSR_IA32_FIXED_CTR_CTRL 0x0000038D + +/** + MSR information returned for MSR index #MSR_IA32_FIXED_CTR_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] EN0_OS: Enable Fixed Counter 0 to count while CPL = 0. + /// + UINT32 EN0_OS:1; + /// + /// [Bit 1] EN0_Usr: Enable Fixed Counter 0 to count while CPL > 0. + /// + UINT32 EN0_Usr:1; + /// + /// [Bit 2] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. + /// + UINT32 AnyThread0:1; + /// + /// [Bit 3] EN0_PMI: Enable PMI when fixed counter 0 overflows. + /// + UINT32 EN0_PMI:1; + /// + /// [Bit 4] EN1_OS: Enable Fixed Counter 1 to count while CPL = 0. + /// + UINT32 EN1_OS:1; + /// + /// [Bit 5] EN1_Usr: Enable Fixed Counter 1 to count while CPL > 0. + /// + UINT32 EN1_Usr:1; + /// + /// [Bit 6] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. + /// + UINT32 AnyThread1:1; + /// + /// [Bit 7] EN1_PMI: Enable PMI when fixed counter 1 overflows. + /// + UINT32 EN1_PMI:1; + /// + /// [Bit 8] EN2_OS: Enable Fixed Counter 2 to count while CPL = 0. + /// + UINT32 EN2_OS:1; + /// + /// [Bit 9] EN2_Usr: Enable Fixed Counter 2 to count while CPL > 0. + /// + UINT32 EN2_Usr:1; + /// + /// [Bit 10] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. + /// + UINT32 AnyThread2:1; + /// + /// [Bit 11] EN2_PMI: Enable PMI when fixed counter 2 overflows. + /// + UINT32 EN2_PMI:1; + UINT32 Reserved1:20; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_FIXED_CTR_CTRL_REGISTER; + + +/** + Global Performance Counter Status (RO). If CPUID.0AH: EAX[7:0] > 0. + + @param ECX MSR_IA32_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS); + @endcode + @note MSR_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_STATUS 0x0000038E + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Ovf_PMC0: Overflow status of IA32_PMC0. If CPUID.0AH: + /// EAX[15:8] > 0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Ovf_PMC1: Overflow status of IA32_PMC1. If CPUID.0AH: + /// EAX[15:8] > 1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Ovf_PMC2: Overflow status of IA32_PMC2. If CPUID.0AH: + /// EAX[15:8] > 2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Ovf_PMC3: Overflow status of IA32_PMC3. If CPUID.0AH: + /// EAX[15:8] > 3. + /// + UINT32 Ovf_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Ovf_FixedCtr0: Overflow status of IA32_FIXED_CTR0. If + /// CPUID.0AH: EAX[7:0] > 1. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Ovf_FixedCtr1: Overflow status of IA32_FIXED_CTR1. If + /// CPUID.0AH: EAX[7:0] > 1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Ovf_FixedCtr2: Overflow status of IA32_FIXED_CTR2. If + /// CPUID.0AH: EAX[7:0] > 1. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Trace_ToPA_PMI: A PMI occurred due to a ToPA entry memory + /// buffer was completely filled. If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1) + /// && IA32_RTIT_CTL.ToPA = 1. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] LBR_Frz: LBRs are frozen due to - + /// IA32_DEBUGCTL.FREEZE_LBR_ON_PMI=1, - The LBR stack overflowed. If + /// CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] CTR_Frz: Performance counters in the core PMU are frozen due + /// to - IA32_DEBUGCTL.FREEZE_PERFMON_ON_ PMI=1, - one or more core PMU + /// counters overflowed. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] ASCI: Data in the performance counters in the core PMU may + /// include contributions from the direct or indirect operation intel SGX + /// to protect an enclave. If CPUID.(EAX=07H, ECX=0):EBX[2] = 1. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Ovf_Uncore: Uncore counter overflow status. If CPUID.0AH: + /// EAX[7:0] > 2. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] OvfBuf: DS SAVE area Buffer overflow status. If CPUID.0AH: + /// EAX[7:0] > 0. + /// + UINT32 OvfBuf:1; + /// + /// [Bit 63] CondChgd: status bits of this register has changed. If + /// CPUID.0AH: EAX[7:0] > 0. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Global Performance Counter Control (R/W) Counter increments while the result + of ANDing respective enable bit in this MSR with the corresponding OS or USR + bits in the general-purpose or fixed counter control MSR is true. If + CPUID.0AH: EAX[7:0] > 0. + + @param ECX MSR_IA32_PERF_GLOBAL_CTRL (0x0000038F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_CTRL_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_CTRL, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_GLOBAL_CTRL is defined as IA32_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_CTRL 0x0000038F + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_CTRL +**/ +typedef union { + /// + /// Individual bit fields +/// + struct { + /// + /// [Bits 31:0] EN_PMCn. If CPUID.0AH: EAX[15:8] > n. + /// Enable bitmask. Only the first n-1 bits are valid. + /// Bits n..31 are reserved. + /// + UINT32 EN_PMCn:32; + /// + /// [Bits 63:32] EN_FIXED_CTRn. If CPUID.0AH: EDX[4:0] > n. + /// Enable bitmask. Only the first n-1 bits are valid. + /// Bits 31:n are reserved. + /// + UINT32 EN_FIXED_CTRn:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_CTRL_REGISTER; + + +/** + Global Performance Counter Overflow Control (R/W). If CPUID.0AH: EAX[7:0] > + 0 && CPUID.0AH: EAX[7:0] <= 3. + + @param ECX MSR_IA32_PERF_GLOBAL_OVF_CTRL (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_GLOBAL_OVF_CTRL is defined as IA32_PERF_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_OVF_CTRL 0x00000390 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_OVF_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Set 1 to Clear Ovf_PMC0 bit. If CPUID.0AH: EAX[15:8] > n. + /// Clear bitmask. Only the first n-1 bits are valid. + /// Bits 31:n are reserved. + /// + UINT32 Ovf_PMCn:32; + /// + /// [Bits 54:32] Set 1 to Clear Ovf_FIXED_CTR0 bit. + /// If CPUID.0AH: EDX[4:0] > n. + /// Clear bitmask. Only the first n-1 bits are valid. + /// Bits 22:n are reserved. + /// + UINT32 Ovf_FIXED_CTRn:23; + /// + /// [Bit 55] Set 1 to Clear Trace_ToPA_PMI bit. If (CPUID.(EAX=07H, + /// ECX=0):EBX[25] = 1) && IA32_RTIT_CTL.ToPA = 1. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved2:5; + /// + /// [Bit 61] Set 1 to Clear Ovf_Uncore bit. Introduced at Display Family / + /// Display Model 06_2EH. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Set 1 to Clear OvfBuf: bit. If CPUID.0AH: EAX[7:0] > 0. + /// + UINT32 OvfBuf:1; + /// + /// [Bit 63] Set to 1to clear CondChgd: bit. If CPUID.0AH: EAX[7:0] > 0. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER; + + +/** + Global Performance Counter Overflow Reset Control (R/W). If CPUID.0AH: + EAX[7:0] > 3. + + @param ECX MSR_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_RESET); + AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS_RESET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Set 1 to Clear Ovf_PMC0 bit. If CPUID.0AH: EAX[15:8] > n. + /// Clear bitmask. Only the first n-1 bits are valid. + /// Bits 31:n are reserved. + /// + UINT32 Ovf_PMCn:32; + /// + /// [Bits 54:32] Set 1 to Clear Ovf_FIXED_CTR0 bit. + /// If CPUID.0AH: EDX[4:0] > n. + /// Clear bitmask. Only the first n-1 bits are valid. + /// Bits 22:n are reserved. + /// + UINT32 Ovf_FIXED_CTRn:23; + /// + /// [Bit 55] Set 1 to Clear Trace_ToPA_PMI bit. If (CPUID.(EAX=07H, + /// ECX=0):EBX[25] = 1) && IA32_RTIT_CTL.ToPA[8] = 1. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved2:2; + /// + /// [Bit 58] Set 1 to Clear LBR_Frz bit. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Set 1 to Clear CTR_Frz bit. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Set 1 to Clear ASCI bit. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Set 1 to Clear Ovf_Uncore bit. Introduced at Display Family / + /// Display Model 06_2EH. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Set 1 to Clear OvfBuf: bit. If CPUID.0AH: EAX[7:0] > 0. + /// + UINT32 OvfBuf:1; + /// + /// [Bit 63] Set to 1to clear CondChgd: bit. If CPUID.0AH: EAX[7:0] > 0. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; + + +/** + Global Performance Counter Overflow Set Control (R/W). If CPUID.0AH: + EAX[7:0] > 3. + + @param ECX MSR_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_SET); + AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); + @endcode + @note MSR_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS_SET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Set 1 to cause Ovf_PMCn = 1. If CPUID.0AH: EAX[7:0] > n. + /// Set bitmask. Only the first n-1 bits are valid. + /// Bits 31:n are reserved. + /// + UINT32 Ovf_PMCn:32; + /// + /// [Bits 54:32] Set 1 to cause Ovf_FIXED_CTRn = 1. + /// If CPUID.0AH: EAX[7:0] > n. + /// Set bitmask. Only the first n-1 bits are valid. + /// Bits 22:n are reserved. + /// + UINT32 Ovf_FIXED_CTRn:23; + /// + /// [Bit 55] Set 1 to cause Trace_ToPA_PMI = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved2:2; + /// + /// [Bit 58] Set 1 to cause LBR_Frz = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Set 1 to cause CTR_Frz = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Set 1 to cause ASCI = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Set 1 to cause Ovf_Uncore = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Set 1 to cause OvfBuf = 1. If CPUID.0AH: EAX[7:0] > 3. + /// + UINT32 OvfBuf:1; + UINT32 Reserved3:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; + + +/** + Indicator of core perfmon interface is in use (RO). If CPUID.0AH: EAX[7:0] > + 3. + + @param ECX MSR_IA32_PERF_GLOBAL_INUSE (0x00000392) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_INUSE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PERF_GLOBAL_INUSE_REGISTER. + + Example usage + @code + MSR_IA32_PERF_GLOBAL_INUSE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_INUSE); + @endcode + @note MSR_IA32_PERF_GLOBAL_INUSE is defined as IA32_PERF_GLOBAL_INUSE in SDM. +**/ +#define MSR_IA32_PERF_GLOBAL_INUSE 0x00000392 + +/** + MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_INUSE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] IA32_PERFEVTSELn in use. If CPUID.0AH: EAX[7:0] > n. + /// Status bitmask. Only the first n-1 bits are valid. + /// Bits 31:n are reserved. + /// + UINT32 IA32_PERFEVTSELn:32; + /// + /// [Bits 62:32] IA32_FIXED_CTRn in use. + /// If CPUID.0AH: EAX[7:0] > n. + /// Status bitmask. Only the first n-1 bits are valid. + /// Bits 30:n are reserved. + /// + UINT32 IA32_FIXED_CTRn:31; + /// + /// [Bit 63] PMI in use. + /// + UINT32 PMI:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PERF_GLOBAL_INUSE_REGISTER; + + +/** + PEBS Control (R/W). + + @param ECX MSR_IA32_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_IA32_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PEBS_ENABLE); + AsmWriteMsr64 (MSR_IA32_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_IA32_PEBS_ENABLE is defined as IA32_PEBS_ENABLE in SDM. +**/ +#define MSR_IA32_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_IA32_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. Introduced at Display Family / + /// Display Model 06_0FH. + /// + UINT32 Enable:1; + /// + /// [Bits 3:1] Reserved or Model specific. + /// + UINT32 Reserved1:3; + UINT32 Reserved2:28; + /// + /// [Bits 35:32] Reserved or Model specific. + /// + UINT32 Reserved3:4; + UINT32 Reserved4:28; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PEBS_ENABLE_REGISTER; + + +/** + MCn_CTL. If IA32_MCG_CAP.CNT > n. + + @param ECX MSR_IA32_MCn_CTL + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MC0_CTL); + AsmWriteMsr64 (MSR_IA32_MC0_CTL, Msr); + @endcode + @note MSR_IA32_MC0_CTL is defined as IA32_MC0_CTL in SDM. + MSR_IA32_MC1_CTL is defined as IA32_MC1_CTL in SDM. + MSR_IA32_MC2_CTL is defined as IA32_MC2_CTL in SDM. + MSR_IA32_MC3_CTL is defined as IA32_MC3_CTL in SDM. + MSR_IA32_MC4_CTL is defined as IA32_MC4_CTL in SDM. + MSR_IA32_MC5_CTL is defined as IA32_MC5_CTL in SDM. + MSR_IA32_MC6_CTL is defined as IA32_MC6_CTL in SDM. + MSR_IA32_MC7_CTL is defined as IA32_MC7_CTL in SDM. + MSR_IA32_MC8_CTL is defined as IA32_MC8_CTL in SDM. + MSR_IA32_MC9_CTL is defined as IA32_MC9_CTL in SDM. + MSR_IA32_MC10_CTL is defined as IA32_MC10_CTL in SDM. + MSR_IA32_MC11_CTL is defined as IA32_MC11_CTL in SDM. + MSR_IA32_MC12_CTL is defined as IA32_MC12_CTL in SDM. + MSR_IA32_MC13_CTL is defined as IA32_MC13_CTL in SDM. + MSR_IA32_MC14_CTL is defined as IA32_MC14_CTL in SDM. + MSR_IA32_MC15_CTL is defined as IA32_MC15_CTL in SDM. + MSR_IA32_MC16_CTL is defined as IA32_MC16_CTL in SDM. + MSR_IA32_MC17_CTL is defined as IA32_MC17_CTL in SDM. + MSR_IA32_MC18_CTL is defined as IA32_MC18_CTL in SDM. + MSR_IA32_MC19_CTL is defined as IA32_MC19_CTL in SDM. + MSR_IA32_MC20_CTL is defined as IA32_MC20_CTL in SDM. + MSR_IA32_MC21_CTL is defined as IA32_MC21_CTL in SDM. + MSR_IA32_MC22_CTL is defined as IA32_MC22_CTL in SDM. + MSR_IA32_MC23_CTL is defined as IA32_MC23_CTL in SDM. + MSR_IA32_MC24_CTL is defined as IA32_MC24_CTL in SDM. + MSR_IA32_MC25_CTL is defined as IA32_MC25_CTL in SDM. + MSR_IA32_MC26_CTL is defined as IA32_MC26_CTL in SDM. + MSR_IA32_MC27_CTL is defined as IA32_MC27_CTL in SDM. + MSR_IA32_MC28_CTL is defined as IA32_MC28_CTL in SDM. + @{ +**/ +#define MSR_IA32_MC0_CTL 0x00000400 +#define MSR_IA32_MC1_CTL 0x00000404 +#define MSR_IA32_MC2_CTL 0x00000408 +#define MSR_IA32_MC3_CTL 0x0000040C +#define MSR_IA32_MC4_CTL 0x00000410 +#define MSR_IA32_MC5_CTL 0x00000414 +#define MSR_IA32_MC6_CTL 0x00000418 +#define MSR_IA32_MC7_CTL 0x0000041C +#define MSR_IA32_MC8_CTL 0x00000420 +#define MSR_IA32_MC9_CTL 0x00000424 +#define MSR_IA32_MC10_CTL 0x00000428 +#define MSR_IA32_MC11_CTL 0x0000042C +#define MSR_IA32_MC12_CTL 0x00000430 +#define MSR_IA32_MC13_CTL 0x00000434 +#define MSR_IA32_MC14_CTL 0x00000438 +#define MSR_IA32_MC15_CTL 0x0000043C +#define MSR_IA32_MC16_CTL 0x00000440 +#define MSR_IA32_MC17_CTL 0x00000444 +#define MSR_IA32_MC18_CTL 0x00000448 +#define MSR_IA32_MC19_CTL 0x0000044C +#define MSR_IA32_MC20_CTL 0x00000450 +#define MSR_IA32_MC21_CTL 0x00000454 +#define MSR_IA32_MC22_CTL 0x00000458 +#define MSR_IA32_MC23_CTL 0x0000045C +#define MSR_IA32_MC24_CTL 0x00000460 +#define MSR_IA32_MC25_CTL 0x00000464 +#define MSR_IA32_MC26_CTL 0x00000468 +#define MSR_IA32_MC27_CTL 0x0000046C +#define MSR_IA32_MC28_CTL 0x00000470 +/// @} + + +/** + MCn_STATUS. If IA32_MCG_CAP.CNT > n. + + @param ECX MSR_IA32_MCn_STATUS + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MC0_STATUS); + AsmWriteMsr64 (MSR_IA32_MC0_STATUS, Msr); + @endcode + @note MSR_IA32_MC0_STATUS is defined as IA32_MC0_STATUS in SDM. + MSR_IA32_MC1_STATUS is defined as IA32_MC1_STATUS in SDM. + MSR_IA32_MC2_STATUS is defined as IA32_MC2_STATUS in SDM. + MSR_IA32_MC3_STATUS is defined as IA32_MC3_STATUS in SDM. + MSR_IA32_MC4_STATUS is defined as IA32_MC4_STATUS in SDM. + MSR_IA32_MC5_STATUS is defined as IA32_MC5_STATUS in SDM. + MSR_IA32_MC6_STATUS is defined as IA32_MC6_STATUS in SDM. + MSR_IA32_MC7_STATUS is defined as IA32_MC7_STATUS in SDM. + MSR_IA32_MC8_STATUS is defined as IA32_MC8_STATUS in SDM. + MSR_IA32_MC9_STATUS is defined as IA32_MC9_STATUS in SDM. + MSR_IA32_MC10_STATUS is defined as IA32_MC10_STATUS in SDM. + MSR_IA32_MC11_STATUS is defined as IA32_MC11_STATUS in SDM. + MSR_IA32_MC12_STATUS is defined as IA32_MC12_STATUS in SDM. + MSR_IA32_MC13_STATUS is defined as IA32_MC13_STATUS in SDM. + MSR_IA32_MC14_STATUS is defined as IA32_MC14_STATUS in SDM. + MSR_IA32_MC15_STATUS is defined as IA32_MC15_STATUS in SDM. + MSR_IA32_MC16_STATUS is defined as IA32_MC16_STATUS in SDM. + MSR_IA32_MC17_STATUS is defined as IA32_MC17_STATUS in SDM. + MSR_IA32_MC18_STATUS is defined as IA32_MC18_STATUS in SDM. + MSR_IA32_MC19_STATUS is defined as IA32_MC19_STATUS in SDM. + MSR_IA32_MC20_STATUS is defined as IA32_MC20_STATUS in SDM. + MSR_IA32_MC21_STATUS is defined as IA32_MC21_STATUS in SDM. + MSR_IA32_MC22_STATUS is defined as IA32_MC22_STATUS in SDM. + MSR_IA32_MC23_STATUS is defined as IA32_MC23_STATUS in SDM. + MSR_IA32_MC24_STATUS is defined as IA32_MC24_STATUS in SDM. + MSR_IA32_MC25_STATUS is defined as IA32_MC25_STATUS in SDM. + MSR_IA32_MC26_STATUS is defined as IA32_MC26_STATUS in SDM. + MSR_IA32_MC27_STATUS is defined as IA32_MC27_STATUS in SDM. + MSR_IA32_MC28_STATUS is defined as IA32_MC28_STATUS in SDM. + @{ +**/ +#define MSR_IA32_MC0_STATUS 0x00000401 +#define MSR_IA32_MC1_STATUS 0x00000405 +#define MSR_IA32_MC2_STATUS 0x00000409 +#define MSR_IA32_MC3_STATUS 0x0000040D +#define MSR_IA32_MC4_STATUS 0x00000411 +#define MSR_IA32_MC5_STATUS 0x00000415 +#define MSR_IA32_MC6_STATUS 0x00000419 +#define MSR_IA32_MC7_STATUS 0x0000041D +#define MSR_IA32_MC8_STATUS 0x00000421 +#define MSR_IA32_MC9_STATUS 0x00000425 +#define MSR_IA32_MC10_STATUS 0x00000429 +#define MSR_IA32_MC11_STATUS 0x0000042D +#define MSR_IA32_MC12_STATUS 0x00000431 +#define MSR_IA32_MC13_STATUS 0x00000435 +#define MSR_IA32_MC14_STATUS 0x00000439 +#define MSR_IA32_MC15_STATUS 0x0000043D +#define MSR_IA32_MC16_STATUS 0x00000441 +#define MSR_IA32_MC17_STATUS 0x00000445 +#define MSR_IA32_MC18_STATUS 0x00000449 +#define MSR_IA32_MC19_STATUS 0x0000044D +#define MSR_IA32_MC20_STATUS 0x00000451 +#define MSR_IA32_MC21_STATUS 0x00000455 +#define MSR_IA32_MC22_STATUS 0x00000459 +#define MSR_IA32_MC23_STATUS 0x0000045D +#define MSR_IA32_MC24_STATUS 0x00000461 +#define MSR_IA32_MC25_STATUS 0x00000465 +#define MSR_IA32_MC26_STATUS 0x00000469 +#define MSR_IA32_MC27_STATUS 0x0000046D +#define MSR_IA32_MC28_STATUS 0x00000471 +/// @} + + +/** + MCn_ADDR. If IA32_MCG_CAP.CNT > n. + + @param ECX MSR_IA32_MCn_ADDR + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MC0_ADDR); + AsmWriteMsr64 (MSR_IA32_MC0_ADDR, Msr); + @endcode + @note MSR_IA32_MC0_ADDR is defined as IA32_MC0_ADDR in SDM. + MSR_IA32_MC1_ADDR is defined as IA32_MC1_ADDR in SDM. + MSR_IA32_MC2_ADDR is defined as IA32_MC2_ADDR in SDM. + MSR_IA32_MC3_ADDR is defined as IA32_MC3_ADDR in SDM. + MSR_IA32_MC4_ADDR is defined as IA32_MC4_ADDR in SDM. + MSR_IA32_MC5_ADDR is defined as IA32_MC5_ADDR in SDM. + MSR_IA32_MC6_ADDR is defined as IA32_MC6_ADDR in SDM. + MSR_IA32_MC7_ADDR is defined as IA32_MC7_ADDR in SDM. + MSR_IA32_MC8_ADDR is defined as IA32_MC8_ADDR in SDM. + MSR_IA32_MC9_ADDR is defined as IA32_MC9_ADDR in SDM. + MSR_IA32_MC10_ADDR is defined as IA32_MC10_ADDR in SDM. + MSR_IA32_MC11_ADDR is defined as IA32_MC11_ADDR in SDM. + MSR_IA32_MC12_ADDR is defined as IA32_MC12_ADDR in SDM. + MSR_IA32_MC13_ADDR is defined as IA32_MC13_ADDR in SDM. + MSR_IA32_MC14_ADDR is defined as IA32_MC14_ADDR in SDM. + MSR_IA32_MC15_ADDR is defined as IA32_MC15_ADDR in SDM. + MSR_IA32_MC16_ADDR is defined as IA32_MC16_ADDR in SDM. + MSR_IA32_MC17_ADDR is defined as IA32_MC17_ADDR in SDM. + MSR_IA32_MC18_ADDR is defined as IA32_MC18_ADDR in SDM. + MSR_IA32_MC19_ADDR is defined as IA32_MC19_ADDR in SDM. + MSR_IA32_MC20_ADDR is defined as IA32_MC20_ADDR in SDM. + MSR_IA32_MC21_ADDR is defined as IA32_MC21_ADDR in SDM. + MSR_IA32_MC22_ADDR is defined as IA32_MC22_ADDR in SDM. + MSR_IA32_MC23_ADDR is defined as IA32_MC23_ADDR in SDM. + MSR_IA32_MC24_ADDR is defined as IA32_MC24_ADDR in SDM. + MSR_IA32_MC25_ADDR is defined as IA32_MC25_ADDR in SDM. + MSR_IA32_MC26_ADDR is defined as IA32_MC26_ADDR in SDM. + MSR_IA32_MC27_ADDR is defined as IA32_MC27_ADDR in SDM. + MSR_IA32_MC28_ADDR is defined as IA32_MC28_ADDR in SDM. + @{ +**/ +#define MSR_IA32_MC0_ADDR 0x00000402 +#define MSR_IA32_MC1_ADDR 0x00000406 +#define MSR_IA32_MC2_ADDR 0x0000040A +#define MSR_IA32_MC3_ADDR 0x0000040E +#define MSR_IA32_MC4_ADDR 0x00000412 +#define MSR_IA32_MC5_ADDR 0x00000416 +#define MSR_IA32_MC6_ADDR 0x0000041A +#define MSR_IA32_MC7_ADDR 0x0000041E +#define MSR_IA32_MC8_ADDR 0x00000422 +#define MSR_IA32_MC9_ADDR 0x00000426 +#define MSR_IA32_MC10_ADDR 0x0000042A +#define MSR_IA32_MC11_ADDR 0x0000042E +#define MSR_IA32_MC12_ADDR 0x00000432 +#define MSR_IA32_MC13_ADDR 0x00000436 +#define MSR_IA32_MC14_ADDR 0x0000043A +#define MSR_IA32_MC15_ADDR 0x0000043E +#define MSR_IA32_MC16_ADDR 0x00000442 +#define MSR_IA32_MC17_ADDR 0x00000446 +#define MSR_IA32_MC18_ADDR 0x0000044A +#define MSR_IA32_MC19_ADDR 0x0000044E +#define MSR_IA32_MC20_ADDR 0x00000452 +#define MSR_IA32_MC21_ADDR 0x00000456 +#define MSR_IA32_MC22_ADDR 0x0000045A +#define MSR_IA32_MC23_ADDR 0x0000045E +#define MSR_IA32_MC24_ADDR 0x00000462 +#define MSR_IA32_MC25_ADDR 0x00000466 +#define MSR_IA32_MC26_ADDR 0x0000046A +#define MSR_IA32_MC27_ADDR 0x0000046E +#define MSR_IA32_MC28_ADDR 0x00000472 +/// @} + + +/** + MCn_MISC. If IA32_MCG_CAP.CNT > n. + + @param ECX MSR_IA32_MCn_MISC + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_MC0_MISC); + AsmWriteMsr64 (MSR_IA32_MC0_MISC, Msr); + @endcode + @note MSR_IA32_MC0_MISC is defined as IA32_MC0_MISC in SDM. + MSR_IA32_MC1_MISC is defined as IA32_MC1_MISC in SDM. + MSR_IA32_MC2_MISC is defined as IA32_MC2_MISC in SDM. + MSR_IA32_MC3_MISC is defined as IA32_MC3_MISC in SDM. + MSR_IA32_MC4_MISC is defined as IA32_MC4_MISC in SDM. + MSR_IA32_MC5_MISC is defined as IA32_MC5_MISC in SDM. + MSR_IA32_MC6_MISC is defined as IA32_MC6_MISC in SDM. + MSR_IA32_MC7_MISC is defined as IA32_MC7_MISC in SDM. + MSR_IA32_MC8_MISC is defined as IA32_MC8_MISC in SDM. + MSR_IA32_MC9_MISC is defined as IA32_MC9_MISC in SDM. + MSR_IA32_MC10_MISC is defined as IA32_MC10_MISC in SDM. + MSR_IA32_MC11_MISC is defined as IA32_MC11_MISC in SDM. + MSR_IA32_MC12_MISC is defined as IA32_MC12_MISC in SDM. + MSR_IA32_MC13_MISC is defined as IA32_MC13_MISC in SDM. + MSR_IA32_MC14_MISC is defined as IA32_MC14_MISC in SDM. + MSR_IA32_MC15_MISC is defined as IA32_MC15_MISC in SDM. + MSR_IA32_MC16_MISC is defined as IA32_MC16_MISC in SDM. + MSR_IA32_MC17_MISC is defined as IA32_MC17_MISC in SDM. + MSR_IA32_MC18_MISC is defined as IA32_MC18_MISC in SDM. + MSR_IA32_MC19_MISC is defined as IA32_MC19_MISC in SDM. + MSR_IA32_MC20_MISC is defined as IA32_MC20_MISC in SDM. + MSR_IA32_MC21_MISC is defined as IA32_MC21_MISC in SDM. + MSR_IA32_MC22_MISC is defined as IA32_MC22_MISC in SDM. + MSR_IA32_MC23_MISC is defined as IA32_MC23_MISC in SDM. + MSR_IA32_MC24_MISC is defined as IA32_MC24_MISC in SDM. + MSR_IA32_MC25_MISC is defined as IA32_MC25_MISC in SDM. + MSR_IA32_MC26_MISC is defined as IA32_MC26_MISC in SDM. + MSR_IA32_MC27_MISC is defined as IA32_MC27_MISC in SDM. + MSR_IA32_MC28_MISC is defined as IA32_MC28_MISC in SDM. + @{ +**/ +#define MSR_IA32_MC0_MISC 0x00000403 +#define MSR_IA32_MC1_MISC 0x00000407 +#define MSR_IA32_MC2_MISC 0x0000040B +#define MSR_IA32_MC3_MISC 0x0000040F +#define MSR_IA32_MC4_MISC 0x00000413 +#define MSR_IA32_MC5_MISC 0x00000417 +#define MSR_IA32_MC6_MISC 0x0000041B +#define MSR_IA32_MC7_MISC 0x0000041F +#define MSR_IA32_MC8_MISC 0x00000423 +#define MSR_IA32_MC9_MISC 0x00000427 +#define MSR_IA32_MC10_MISC 0x0000042B +#define MSR_IA32_MC11_MISC 0x0000042F +#define MSR_IA32_MC12_MISC 0x00000433 +#define MSR_IA32_MC13_MISC 0x00000437 +#define MSR_IA32_MC14_MISC 0x0000043B +#define MSR_IA32_MC15_MISC 0x0000043F +#define MSR_IA32_MC16_MISC 0x00000443 +#define MSR_IA32_MC17_MISC 0x00000447 +#define MSR_IA32_MC18_MISC 0x0000044B +#define MSR_IA32_MC19_MISC 0x0000044F +#define MSR_IA32_MC20_MISC 0x00000453 +#define MSR_IA32_MC21_MISC 0x00000457 +#define MSR_IA32_MC22_MISC 0x0000045B +#define MSR_IA32_MC23_MISC 0x0000045F +#define MSR_IA32_MC24_MISC 0x00000463 +#define MSR_IA32_MC25_MISC 0x00000467 +#define MSR_IA32_MC26_MISC 0x0000046B +#define MSR_IA32_MC27_MISC 0x0000046F +#define MSR_IA32_MC28_MISC 0x00000473 +/// @} + + +/** + Reporting Register of Basic VMX Capabilities (R/O) See Appendix A.1, "Basic + VMX Information.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_BASIC (0x00000480) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + MSR_IA32_VMX_BASIC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_BASIC); + @endcode + @note MSR_IA32_VMX_BASIC is defined as IA32_VMX_BASIC in SDM. +**/ +#define MSR_IA32_VMX_BASIC 0x00000480 + +/** + MSR information returned for MSR index #MSR_IA32_VMX_BASIC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 30:0] VMCS revision identifier used by the processor. Processors + /// that use the same VMCS revision identifier use the same size for VMCS + /// regions (see subsequent item on bits 44:32). + /// + /// @note Earlier versions of this manual specified that the VMCS revision + /// identifier was a 32-bit field in bits 31:0 of this MSR. For all + /// processors produced prior to this change, bit 31 of this MSR was read + /// as 0. + /// + UINT32 VmcsRevisonId:31; + UINT32 MustBeZero:1; + /// + /// [Bit 44:32] Reports the number of bytes that software should allocate + /// for the VMXON region and any VMCS region. It is a value greater than + /// 0 and at most 4096(bit 44 is set if and only if bits 43:32 are clear). + /// + UINT32 VmcsSize:13; + UINT32 Reserved1:3; + /// + /// [Bit 48] Indicates the width of the physical addresses that may be used + /// for the VMXON region, each VMCS, and data structures referenced by + /// pointers in a VMCS (I/O bitmaps, virtual-APIC page, MSR areas for VMX + /// transitions). If the bit is 0, these addresses are limited to the + /// processor's physical-address width. If the bit is 1, these addresses + /// are limited to 32 bits. This bit is always 0 for processors that + /// support Intel 64 architecture. + /// + /// @note On processors that support Intel 64 architecture, the pointer + /// must not set bits beyond the processor's physical address width. + /// + UINT32 VmcsAddressWidth:1; + /// + /// [Bit 49] If bit 49 is read as 1, the logical processor supports the + /// dual-monitor treatment of system-management interrupts and + /// system-management mode. See Section 34.15 for details of this treatment. + /// + UINT32 DualMonitor:1; + /// + /// [Bit 53:50] report the memory type that should be used for the VMCS, + /// for data structures referenced by pointers in the VMCS (I/O bitmaps, + /// virtual-APIC page, MSR areas for VMX transitions), and for the MSEG + /// header. If software needs to access these data structures (e.g., to + /// modify the contents of the MSR bitmaps), it can configure the paging + /// structures to map them into the linear-address space. If it does so, + /// it should establish mappings that use the memory type reported bits + /// 53:50 in this MSR. + /// + /// As of this writing, all processors that support VMX operation indicate + /// the write-back type. + /// + /// If software needs to access these data structures (e.g., to modify + /// the contents of the MSR bitmaps), it can configure the paging + /// structures to map them into the linear-address space. If it does so, + /// it should establish mappings that use the memory type reported in this + /// MSR. + /// + /// @note Alternatively, software may map any of these regions or + /// structures with the UC memory type. (This may be necessary for the MSEG + /// header.) Doing so is discouraged unless necessary as it will cause the + /// performance of software accesses to those structures to suffer. + /// + /// + UINT32 MemoryType:4; + /// + /// [Bit 54] If bit 54 is read as 1, the processor reports information in + /// the VM-exit instruction-information field on VM exitsdue to execution + /// of the INS and OUTS instructions (see Section 27.2.4). This reporting + /// is done only if this bit is read as 1. + /// + UINT32 InsOutsReporting:1; + /// + /// [Bit 55] Bit 55 is read as 1 if any VMX controls that default to 1 may + /// be cleared to 0. See Appendix A.2 for details. It also reports support + /// for the VMX capability MSRs IA32_VMX_TRUE_PINBASED_CTLS, + /// IA32_VMX_TRUE_PROCBASED_CTLS, IA32_VMX_TRUE_EXIT_CTLS, and + /// IA32_VMX_TRUE_ENTRY_CTLS. See Appendix A.3.1, Appendix A.3.2, + /// Appendix A.4, and Appendix A.5 for details. + /// + UINT32 VmxControls:1; + UINT32 Reserved2:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_VMX_BASIC_REGISTER; + +/// +/// @{ Define value for bit field MSR_IA32_VMX_BASIC_REGISTER.MemoryType +/// +#define MSR_IA32_VMX_BASIC_REGISTER_MEMORY_TYPE_UNCACHEABLE 0x00 +#define MSR_IA32_VMX_BASIC_REGISTER_MEMORY_TYPE_WRITE_BACK 0x06 +/// +/// @} +/// + + +/** + Capability Reporting Register of Pinbased VM-execution Controls (R/O) See + Appendix A.3.1, "Pin-Based VMExecution Controls.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_PINBASED_CTLS (0x00000481) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_PINBASED_CTLS); + @endcode + @note MSR_IA32_VMX_PINBASED_CTLS is defined as IA32_VMX_PINBASED_CTLS in SDM. +**/ +#define MSR_IA32_VMX_PINBASED_CTLS 0x00000481 + + +/** + Capability Reporting Register of Primary Processor-based VM-execution + Controls (R/O) See Appendix A.3.2, "Primary Processor- Based VM-Execution + Controls.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_PROCBASED_CTLS (0x00000482) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_PROCBASED_CTLS); + @endcode + @note MSR_IA32_VMX_PROCBASED_CTLS is defined as IA32_VMX_PROCBASED_CTLS in SDM. +**/ +#define MSR_IA32_VMX_PROCBASED_CTLS 0x00000482 + + +/** + Capability Reporting Register of VM-exit Controls (R/O) See Appendix A.4, + "VM-Exit Controls.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_EXIT_CTLS (0x00000483) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_EXIT_CTLS); + @endcode + @note MSR_IA32_VMX_EXIT_CTLS is defined as IA32_VMX_EXIT_CTLS in SDM. +**/ +#define MSR_IA32_VMX_EXIT_CTLS 0x00000483 + + +/** + Capability Reporting Register of VMentry Controls (R/O) See Appendix A.5, + "VM-Entry Controls.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_ENTRY_CTLS (0x00000484) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_ENTRY_CTLS); + @endcode + @note MSR_IA32_VMX_ENTRY_CTLS is defined as IA32_VMX_ENTRY_CTLS in SDM. +**/ +#define MSR_IA32_VMX_ENTRY_CTLS 0x00000484 + + +/** + Reporting Register of Miscellaneous VMX Capabilities (R/O) See Appendix A.6, + "Miscellaneous Data.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_MISC (0x00000485) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + IA32_VMX_MISC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_MISC); + @endcode + @note MSR_IA32_VMX_MISC is defined as IA32_VMX_MISC in SDM. +**/ +#define MSR_IA32_VMX_MISC 0x00000485 + +/** + MSR information returned for MSR index #IA32_VMX_MISC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Reports a value X that specifies the relationship between the + /// rate of the VMX-preemption timer and that of the timestamp counter (TSC). + /// Specifically, the VMX-preemption timer (if it is active) counts down by + /// 1 every time bit X in the TSC changes due to a TSC increment. + /// + UINT32 VmxTimerRatio:5; + /// + /// [Bit 5] If bit 5 is read as 1, VM exits store the value of IA32_EFER.LMA + /// into the "IA-32e mode guest" VM-entry control;see Section 27.2 for more + /// details. This bit is read as 1 on any logical processor that supports + /// the 1-setting of the "unrestricted guest" VM-execution control. + /// + UINT32 VmExitEferLma:1; + /// + /// [Bit 6] reports (if set) the support for activity state 1 (HLT). + /// + UINT32 HltActivityStateSupported:1; + /// + /// [Bit 7] reports (if set) the support for activity state 2 (shutdown). + /// + UINT32 ShutdownActivityStateSupported:1; + /// + /// [Bit 8] reports (if set) the support for activity state 3 (wait-for-SIPI). + /// + UINT32 WaitForSipiActivityStateSupported:1; + UINT32 Reserved1:5; + /// + /// [Bit 14] If read as 1, Intel(R) Processor Trace (Intel PT) can be used + /// in VMX operation. If the processor supports Intel PT but does not allow + /// it to be used in VMX operation, execution of VMXON clears + /// IA32_RTIT_CTL.TraceEn (see "VMXON-Enter VMX Operation" in Chapter 30); + /// any attempt to set that bit while in VMX operation (including VMX root + /// operation) using the WRMSR instruction causes a general-protection + /// exception. + /// + UINT32 ProcessorTraceSupported:1; + /// + /// [Bit 15] If read as 1, the RDMSR instruction can be used in system- + /// management mode (SMM) to read the IA32_SMBASE MSR (MSR address 9EH). + /// See Section 34.15.6.3. + /// + UINT32 SmBaseMsrSupported:1; + /// + /// [Bits 24:16] Indicate the number of CR3-target values supported by the + /// processor. This number is a value between 0 and 256, inclusive (bit 24 + /// is set if and only if bits 23:16 are clear). + /// + UINT32 NumberOfCr3TargetValues:9; + /// + /// [Bit 27:25] Bits 27:25 is used to compute the recommended maximum + /// number of MSRs that should appear in the VM-exit MSR-store list, the + /// VM-exit MSR-load list, or the VM-entry MSR-load list. Specifically, if + /// the value bits 27:25 of IA32_VMX_MISC is N, then 512 * (N + 1) is the + /// recommended maximum number of MSRs to be included in each list. If the + /// limit is exceeded, undefined processor behavior may result (including a + /// machine check during the VMX transition). + /// + UINT32 MsrStoreListMaximum:3; + /// + /// [Bit 28] If read as 1, bit 2 of the IA32_SMM_MONITOR_CTL can be set + /// to 1. VMXOFF unblocks SMIs unless IA32_SMM_MONITOR_CTL[bit 2] is 1 + /// (see Section 34.14.4). + /// + UINT32 BlockSmiSupported:1; + /// + /// [Bit 29] read as 1, software can use VMWRITE to write to any supported + /// field in the VMCS; otherwise, VMWRITE cannot be used to modify VM-exit + /// information fields. + /// + UINT32 VmWriteSupported:1; + /// + /// [Bit 30] If read as 1, VM entry allows injection of a software + /// interrupt, software exception, or privileged software exception with an + /// instruction length of 0. + /// + UINT32 VmInjectSupported:1; + UINT32 Reserved2:1; + /// + /// [Bits 63:32] Reports the 32-bit MSEG revision identifier used by the + /// processor. + /// + UINT32 MsegRevisionIdentifier:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} IA32_VMX_MISC_REGISTER; + + +/** + Capability Reporting Register of CR0 Bits Fixed to 0 (R/O) See Appendix A.7, + "VMX-Fixed Bits in CR0.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_CR0_FIXED0 (0x00000486) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_CR0_FIXED0); + @endcode + @note MSR_IA32_VMX_CR0_FIXED0 is defined as IA32_VMX_CR0_FIXED0 in SDM. +**/ +#define MSR_IA32_VMX_CR0_FIXED0 0x00000486 + + +/** + Capability Reporting Register of CR0 Bits Fixed to 1 (R/O) See Appendix A.7, + "VMX-Fixed Bits in CR0.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_CR0_FIXED1 (0x00000487) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_CR0_FIXED1); + @endcode + @note MSR_IA32_VMX_CR0_FIXED1 is defined as IA32_VMX_CR0_FIXED1 in SDM. +**/ +#define MSR_IA32_VMX_CR0_FIXED1 0x00000487 + + +/** + Capability Reporting Register of CR4 Bits Fixed to 0 (R/O) See Appendix A.8, + "VMX-Fixed Bits in CR4.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_CR4_FIXED0 (0x00000488) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_CR4_FIXED0); + @endcode + @note MSR_IA32_VMX_CR4_FIXED0 is defined as IA32_VMX_CR4_FIXED0 in SDM. +**/ +#define MSR_IA32_VMX_CR4_FIXED0 0x00000488 + + +/** + Capability Reporting Register of CR4 Bits Fixed to 1 (R/O) See Appendix A.8, + "VMX-Fixed Bits in CR4.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_CR4_FIXED1 (0x00000489) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_CR4_FIXED1); + @endcode + @note MSR_IA32_VMX_CR4_FIXED1 is defined as IA32_VMX_CR4_FIXED1 in SDM. +**/ +#define MSR_IA32_VMX_CR4_FIXED1 0x00000489 + + +/** + Capability Reporting Register of VMCS Field Enumeration (R/O) See Appendix + A.9, "VMCS Enumeration.". If CPUID.01H:ECX.[5] = 1. + + @param ECX MSR_IA32_VMX_VMCS_ENUM (0x0000048A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_VMCS_ENUM); + @endcode + @note MSR_IA32_VMX_VMCS_ENUM is defined as IA32_VMX_VMCS_ENUM in SDM. +**/ +#define MSR_IA32_VMX_VMCS_ENUM 0x0000048A + + +/** + Capability Reporting Register of Secondary Processor-based VM-execution + Controls (R/O) See Appendix A.3.3, "Secondary Processor- Based VM-Execution + Controls.". If ( CPUID.01H:ECX.[5] && IA32_VMX_PROCBASED_C TLS[63]). + + @param ECX MSR_IA32_VMX_PROCBASED_CTLS2 (0x0000048B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_PROCBASED_CTLS2); + @endcode + @note MSR_IA32_VMX_PROCBASED_CTLS2 is defined as IA32_VMX_PROCBASED_CTLS2 in SDM. +**/ +#define MSR_IA32_VMX_PROCBASED_CTLS2 0x0000048B + + +/** + Capability Reporting Register of EPT and VPID (R/O) See Appendix A.10, + "VPID and EPT Capabilities.". If ( CPUID.01H:ECX.[5] && IA32_VMX_PROCBASED_C + TLS[63] && ( IA32_VMX_PROCBASED_C TLS2[33] IA32_VMX_PROCBASED_C TLS2[37]) ). + + @param ECX MSR_IA32_VMX_EPT_VPID_CAP (0x0000048C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_EPT_VPID_CAP); + @endcode + @note MSR_IA32_VMX_EPT_VPID_CAP is defined as IA32_VMX_EPT_VPID_CAP in SDM. +**/ +#define MSR_IA32_VMX_EPT_VPID_CAP 0x0000048C + + +/** + Capability Reporting Register of Pinbased VM-execution Flex Controls (R/O) + See Appendix A.3.1, "Pin-Based VMExecution Controls.". If ( + CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). + + @param ECX MSR_IA32_VMX_TRUE_PINBASED_CTLS (0x0000048D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_PINBASED_CTLS); + @endcode + @note MSR_IA32_VMX_TRUE_PINBASED_CTLS is defined as IA32_VMX_TRUE_PINBASED_CTLS in SDM. +**/ +#define MSR_IA32_VMX_TRUE_PINBASED_CTLS 0x0000048D + + +/** + Capability Reporting Register of Primary Processor-based VM-execution Flex + Controls (R/O) See Appendix A.3.2, "Primary Processor- Based VM-Execution + Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). + + @param ECX MSR_IA32_VMX_TRUE_PROCBASED_CTLS (0x0000048E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_PROCBASED_CTLS); + @endcode + @note MSR_IA32_VMX_TRUE_PROCBASED_CTLS is defined as IA32_VMX_TRUE_PROCBASED_CTLS in SDM. +**/ +#define MSR_IA32_VMX_TRUE_PROCBASED_CTLS 0x0000048E + + +/** + Capability Reporting Register of VM-exit Flex Controls (R/O) See Appendix + A.4, "VM-Exit Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). + + @param ECX MSR_IA32_VMX_TRUE_EXIT_CTLS (0x0000048F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_EXIT_CTLS); + @endcode + @note MSR_IA32_VMX_TRUE_EXIT_CTLS is defined as IA32_VMX_TRUE_EXIT_CTLS in SDM. +**/ +#define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048F + + +/** + Capability Reporting Register of VMentry Flex Controls (R/O) See Appendix + A.5, "VM-Entry Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). + + @param ECX MSR_IA32_VMX_TRUE_ENTRY_CTLS (0x00000490) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_ENTRY_CTLS); + @endcode + @note MSR_IA32_VMX_TRUE_ENTRY_CTLS is defined as IA32_VMX_TRUE_ENTRY_CTLS in SDM. +**/ +#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 + + +/** + Capability Reporting Register of VMfunction Controls (R/O). If( + CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). + + @param ECX MSR_IA32_VMX_VMFUNC (0x00000491) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_VMX_VMFUNC); + @endcode + @note MSR_IA32_VMX_VMFUNC is defined as IA32_VMX_VMFUNC in SDM. +**/ +#define MSR_IA32_VMX_VMFUNC 0x00000491 + + +/** + Full Width Writable IA32_PMCn Alias (R/W). (If CPUID.0AH: EAX[15:8] > n) && + IA32_PERF_CAPABILITIES[ 13] = 1. + + @param ECX MSR_IA32_A_PMCn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_A_PMC0); + AsmWriteMsr64 (MSR_IA32_A_PMC0, Msr); + @endcode + @note MSR_IA32_A_PMC0 is defined as IA32_A_PMC0 in SDM. + MSR_IA32_A_PMC1 is defined as IA32_A_PMC1 in SDM. + MSR_IA32_A_PMC2 is defined as IA32_A_PMC2 in SDM. + MSR_IA32_A_PMC3 is defined as IA32_A_PMC3 in SDM. + MSR_IA32_A_PMC4 is defined as IA32_A_PMC4 in SDM. + MSR_IA32_A_PMC5 is defined as IA32_A_PMC5 in SDM. + MSR_IA32_A_PMC6 is defined as IA32_A_PMC6 in SDM. + MSR_IA32_A_PMC7 is defined as IA32_A_PMC7 in SDM. + @{ +**/ +#define MSR_IA32_A_PMC0 0x000004C1 +#define MSR_IA32_A_PMC1 0x000004C2 +#define MSR_IA32_A_PMC2 0x000004C3 +#define MSR_IA32_A_PMC3 0x000004C4 +#define MSR_IA32_A_PMC4 0x000004C5 +#define MSR_IA32_A_PMC5 0x000004C6 +#define MSR_IA32_A_PMC6 0x000004C7 +#define MSR_IA32_A_PMC7 0x000004C8 +/// @} + + +/** + (R/W). If IA32_MCG_CAP.LMCE_P =1. + + @param ECX MSR_IA32_MCG_EXT_CTL (0x000004D0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_MCG_EXT_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_MCG_EXT_CTL_REGISTER. + + Example usage + @code + MSR_IA32_MCG_EXT_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_EXT_CTL); + AsmWriteMsr64 (MSR_IA32_MCG_EXT_CTL, Msr.Uint64); + @endcode + @note MSR_IA32_MCG_EXT_CTL is defined as IA32_MCG_EXT_CTL in SDM. +**/ +#define MSR_IA32_MCG_EXT_CTL 0x000004D0 + +/** + MSR information returned for MSR index #MSR_IA32_MCG_EXT_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LMCE_EN. + /// + UINT32 LMCE_EN:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_MCG_EXT_CTL_REGISTER; + + +/** + Status and SVN Threshold of SGX Support for ACM (RO). If CPUID.(EAX=07H, + ECX=0H): EBX[2] = 1. + + @param ECX MSR_IA32_SGX_SVN_STATUS (0x00000500) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_SGX_SVN_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_SGX_SVN_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_SGX_SVN_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SGX_SVN_STATUS); + @endcode + @note MSR_IA32_SGX_SVN_STATUS is defined as IA32_SGX_SVN_STATUS in SDM. +**/ +#define MSR_IA32_SGX_SVN_STATUS 0x00000500 + +/** + MSR information returned for MSR index #MSR_IA32_SGX_SVN_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock. See Section 42.11.3, "Interactions with Authenticated + /// Code Modules (ACMs)". + /// + UINT32 Lock:1; + UINT32 Reserved1:15; + /// + /// [Bits 23:16] SGX_SVN_SINIT. See Section 42.11.3, "Interactions with + /// Authenticated Code Modules (ACMs)". + /// + UINT32 SGX_SVN_SINIT:8; + UINT32 Reserved2:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_SGX_SVN_STATUS_REGISTER; + + +/** + Trace Output Base Register (R/W). If ((CPUID.(EAX=07H, ECX=0):EBX[25] = 1) + && ( (CPUID.(EAX=14H,ECX=0): ECX[0] = 1) (CPUID.(EAX=14H,ECX=0): ECX[2] = 1) + ) ). + + @param ECX MSR_IA32_RTIT_OUTPUT_BASE (0x00000560) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_OUTPUT_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_OUTPUT_BASE_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_OUTPUT_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_OUTPUT_BASE); + AsmWriteMsr64 (MSR_IA32_RTIT_OUTPUT_BASE, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_OUTPUT_BASE is defined as IA32_RTIT_OUTPUT_BASE in SDM. +**/ +#define MSR_IA32_RTIT_OUTPUT_BASE 0x00000560 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_OUTPUT_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:7; + /// + /// [Bits 31:7] Base physical address. + /// + UINT32 Base:25; + /// + /// [Bits 63:32] Base physical address. + /// + UINT32 BaseHi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_OUTPUT_BASE_REGISTER; + + +/** + Trace Output Mask Pointers Register (R/W). If ((CPUID.(EAX=07H, + ECX=0):EBX[25] = 1) && ( (CPUID.(EAX=14H,ECX=0): ECX[0] = 1) + (CPUID.(EAX=14H,ECX=0): ECX[2] = 1) ) ). + + @param ECX MSR_IA32_RTIT_OUTPUT_MASK_PTRS (0x00000561) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_OUTPUT_MASK_PTRS); + AsmWriteMsr64 (MSR_IA32_RTIT_OUTPUT_MASK_PTRS, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_OUTPUT_MASK_PTRS is defined as IA32_RTIT_OUTPUT_MASK_PTRS in SDM. +**/ +#define MSR_IA32_RTIT_OUTPUT_MASK_PTRS 0x00000561 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_OUTPUT_MASK_PTRS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:7; + /// + /// [Bits 31:7] MaskOrTableOffset. + /// + UINT32 MaskOrTableOffset:25; + /// + /// [Bits 63:32] Output Offset. + /// + UINT32 OutputOffset:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER; + + +/** + Trace Control Register (R/W). If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). + + @param ECX MSR_IA32_RTIT_CTL (0x00000570) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_CTL_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_CTL); + AsmWriteMsr64 (MSR_IA32_RTIT_CTL, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_CTL is defined as IA32_RTIT_CTL in SDM. +**/ +#define MSR_IA32_RTIT_CTL 0x00000570 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] TraceEn. + /// + UINT32 TraceEn:1; + /// + /// [Bit 1] CYCEn. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). + /// + UINT32 CYCEn:1; + /// + /// [Bit 2] OS. + /// + UINT32 OS:1; + /// + /// [Bit 3] User. + /// + UINT32 User:1; + UINT32 Reserved1:2; + /// + /// [Bit 6] FabricEn. If (CPUID.(EAX=07H, ECX=0):ECX[3] = 1). + /// + UINT32 FabricEn:1; + /// + /// [Bit 7] CR3 filter. + /// + UINT32 CR3:1; + /// + /// [Bit 8] ToPA. + /// + UINT32 ToPA:1; + /// + /// [Bit 9] MTCEn. If (CPUID.(EAX=07H, ECX=0):EBX[3] = 1). + /// + UINT32 MTCEn:1; + /// + /// [Bit 10] TSCEn. + /// + UINT32 TSCEn:1; + /// + /// [Bit 11] DisRETC. + /// + UINT32 DisRETC:1; + UINT32 Reserved2:1; + /// + /// [Bit 13] BranchEn. + /// + UINT32 BranchEn:1; + /// + /// [Bits 17:14] MTCFreq. If (CPUID.(EAX=07H, ECX=0):EBX[3] = 1). + /// + UINT32 MTCFreq:4; + UINT32 Reserved3:1; + /// + /// [Bits 22:19] CYCThresh. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). + /// + UINT32 CYCThresh:4; + UINT32 Reserved4:1; + /// + /// [Bits 27:24] PSBFreq. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). + /// + UINT32 PSBFreq:4; + UINT32 Reserved5:4; + /// + /// [Bits 35:32] ADDR0_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 0). + /// + UINT32 ADDR0_CFG:4; + /// + /// [Bits 39:36] ADDR1_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 1). + /// + UINT32 ADDR1_CFG:4; + /// + /// [Bits 43:40] ADDR2_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 2). + /// + UINT32 ADDR2_CFG:4; + /// + /// [Bits 47:44] ADDR3_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 3). + /// + UINT32 ADDR3_CFG:4; + UINT32 Reserved6:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_CTL_REGISTER; + + +/** + Tracing Status Register (R/W). If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). + + @param ECX MSR_IA32_RTIT_STATUS (0x00000571) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_STATUS); + AsmWriteMsr64 (MSR_IA32_RTIT_STATUS, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_STATUS is defined as IA32_RTIT_STATUS in SDM. +**/ +#define MSR_IA32_RTIT_STATUS 0x00000571 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] FilterEn, (writes ignored). + /// If (CPUID.(EAX=07H, ECX=0):EBX[2] = 1). + /// + UINT32 FilterEn:1; + /// + /// [Bit 1] ContexEn, (writes ignored). + /// + UINT32 ContexEn:1; + /// + /// [Bit 2] TriggerEn, (writes ignored). + /// + UINT32 TriggerEn:1; + UINT32 Reserved1:1; + /// + /// [Bit 4] Error. + /// + UINT32 Error:1; + /// + /// [Bit 5] Stopped. + /// + UINT32 Stopped:1; + UINT32 Reserved2:26; + /// + /// [Bits 48:32] PacketByteCnt. If (CPUID.(EAX=07H, ECX=0):EBX[1] > 3). + /// + UINT32 PacketByteCnt:17; + UINT32 Reserved3:15; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_STATUS_REGISTER; + + +/** + Trace Filter CR3 Match Register (R/W). + If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). + + @param ECX MSR_IA32_RTIT_CR3_MATCH (0x00000572) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_CR3_MATCH_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_CR3_MATCH_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_CR3_MATCH_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_CR3_MATCH); + AsmWriteMsr64 (MSR_IA32_RTIT_CR3_MATCH, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_CR3_MATCH is defined as IA32_RTIT_CR3_MATCH in SDM. +**/ +#define MSR_IA32_RTIT_CR3_MATCH 0x00000572 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_CR3_MATCH +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:5; + /// + /// [Bits 31:5] CR3[63:5] value to match. + /// + UINT32 Cr3:27; + /// + /// [Bits 63:32] CR3[63:5] value to match. + /// + UINT32 Cr3Hi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_CR3_MATCH_REGISTER; + + +/** + Region n Start Address (R/W). If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > n). + + @param ECX MSR_IA32_RTIT_ADDRn_A + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_ADDR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_ADDR_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_ADDR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_ADDR0_A); + AsmWriteMsr64 (MSR_IA32_RTIT_ADDR0_A, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_ADDR0_A is defined as IA32_RTIT_ADDR0_A in SDM. + MSR_IA32_RTIT_ADDR1_A is defined as IA32_RTIT_ADDR1_A in SDM. + MSR_IA32_RTIT_ADDR2_A is defined as IA32_RTIT_ADDR2_A in SDM. + MSR_IA32_RTIT_ADDR3_A is defined as IA32_RTIT_ADDR3_A in SDM. + @{ +**/ +#define MSR_IA32_RTIT_ADDR0_A 0x00000580 +#define MSR_IA32_RTIT_ADDR1_A 0x00000582 +#define MSR_IA32_RTIT_ADDR2_A 0x00000584 +#define MSR_IA32_RTIT_ADDR3_A 0x00000586 +/// @} + + +/** + Region n End Address (R/W). If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > n). + + @param ECX MSR_IA32_RTIT_ADDRn_B + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_ADDR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_RTIT_ADDR_REGISTER. + + Example usage + @code + MSR_IA32_RTIT_ADDR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_ADDR0_B); + AsmWriteMsr64 (MSR_IA32_RTIT_ADDR0_B, Msr.Uint64); + @endcode + @note MSR_IA32_RTIT_ADDR0_B is defined as IA32_RTIT_ADDR0_B in SDM. + MSR_IA32_RTIT_ADDR1_B is defined as IA32_RTIT_ADDR1_B in SDM. + MSR_IA32_RTIT_ADDR2_B is defined as IA32_RTIT_ADDR2_B in SDM. + MSR_IA32_RTIT_ADDR3_B is defined as IA32_RTIT_ADDR3_B in SDM. + @{ +**/ +#define MSR_IA32_RTIT_ADDR0_B 0x00000581 +#define MSR_IA32_RTIT_ADDR1_B 0x00000583 +#define MSR_IA32_RTIT_ADDR2_B 0x00000585 +#define MSR_IA32_RTIT_ADDR3_B 0x00000587 +/// @} + + +/** + MSR information returned for MSR indexes + #MSR_IA32_RTIT_ADDR0_A to #MSR_IA32_RTIT_ADDR3_A and + #MSR_IA32_RTIT_ADDR0_B to #MSR_IA32_RTIT_ADDR3_B +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Virtual Address. + /// + UINT32 VirtualAddress:32; + /// + /// [Bits 47:32] Virtual Address. + /// + UINT32 VirtualAddressHi:16; + /// + /// [Bits 63:48] SignExt_VA. + /// + UINT32 SignExt_VA:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_RTIT_ADDR_REGISTER; + + +/** + DS Save Area (R/W) Points to the linear address of the first byte of the DS + buffer management area, which is used to manage the BTS and PEBS buffers. + See Section 18.15.4, "Debug Store (DS) Mechanism.". If( CPUID.01H:EDX.DS[21] + = 1. + + [Bits 31..0] The linear address of the first byte of the DS buffer + management area, if not in IA-32e mode. + + [Bits 63..0] The linear address of the first byte of the DS buffer + management area, if IA-32e mode is active. + + @param ECX MSR_IA32_DS_AREA (0x00000600) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_DS_AREA_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_DS_AREA_REGISTER. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_DS_AREA); + AsmWriteMsr64 (MSR_IA32_DS_AREA, Msr); + @endcode + @note MSR_IA32_DS_AREA is defined as IA32_DS_AREA in SDM. +**/ +#define MSR_IA32_DS_AREA 0x00000600 + + +/** + TSC Target of Local APIC's TSC Deadline Mode (R/W). If CPUID.01H:ECX.[24] = + 1. + + @param ECX MSR_IA32_TSC_DEADLINE (0x000006E0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_TSC_DEADLINE); + AsmWriteMsr64 (MSR_IA32_TSC_DEADLINE, Msr); + @endcode + @note MSR_IA32_TSC_DEADLINE is defined as IA32_TSC_DEADLINE in SDM. +**/ +#define MSR_IA32_TSC_DEADLINE 0x000006E0 + + +/** + Enable/disable HWP (R/W). If CPUID.06H:EAX.[7] = 1. + + @param ECX MSR_IA32_PM_ENABLE (0x00000770) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PM_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PM_ENABLE_REGISTER. + + Example usage + @code + MSR_IA32_PM_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PM_ENABLE); + AsmWriteMsr64 (MSR_IA32_PM_ENABLE, Msr.Uint64); + @endcode + @note MSR_IA32_PM_ENABLE is defined as IA32_PM_ENABLE in SDM. +**/ +#define MSR_IA32_PM_ENABLE 0x00000770 + +/** + MSR information returned for MSR index #MSR_IA32_PM_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] HWP_ENABLE (R/W1-Once). See Section 14.4.2, "Enabling HWP". If + /// CPUID.06H:EAX.[7] = 1. + /// + UINT32 HWP_ENABLE:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PM_ENABLE_REGISTER; + + +/** + HWP Performance Range Enumeration (RO). If CPUID.06H:EAX.[7] = 1. + + @param ECX MSR_IA32_HWP_CAPABILITIES (0x00000771) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_HWP_CAPABILITIES_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_HWP_CAPABILITIES_REGISTER. + + Example usage + @code + MSR_IA32_HWP_CAPABILITIES_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_CAPABILITIES); + @endcode + @note MSR_IA32_HWP_CAPABILITIES is defined as IA32_HWP_CAPABILITIES in SDM. +**/ +#define MSR_IA32_HWP_CAPABILITIES 0x00000771 + +/** + MSR information returned for MSR index #MSR_IA32_HWP_CAPABILITIES +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Highest_Performance See Section 14.4.3, "HWP Performance + /// Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Highest_Performance:8; + /// + /// [Bits 15:8] Guaranteed_Performance See Section 14.4.3, "HWP + /// Performance Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Guaranteed_Performance:8; + /// + /// [Bits 23:16] Most_Efficient_Performance See Section 14.4.3, "HWP + /// Performance Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Most_Efficient_Performance:8; + /// + /// [Bits 31:24] Lowest_Performance See Section 14.4.3, "HWP Performance + /// Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Lowest_Performance:8; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_HWP_CAPABILITIES_REGISTER; + + +/** + Power Management Control Hints for All Logical Processors in a Package + (R/W). If CPUID.06H:EAX.[11] = 1. + + @param ECX MSR_IA32_HWP_REQUEST_PKG (0x00000772) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_HWP_REQUEST_PKG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_HWP_REQUEST_PKG_REGISTER. + + Example usage + @code + MSR_IA32_HWP_REQUEST_PKG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_REQUEST_PKG); + AsmWriteMsr64 (MSR_IA32_HWP_REQUEST_PKG, Msr.Uint64); + @endcode + @note MSR_IA32_HWP_REQUEST_PKG is defined as IA32_HWP_REQUEST_PKG in SDM. +**/ +#define MSR_IA32_HWP_REQUEST_PKG 0x00000772 + +/** + MSR information returned for MSR index #MSR_IA32_HWP_REQUEST_PKG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Minimum_Performance See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[11] = 1. + /// + UINT32 Minimum_Performance:8; + /// + /// [Bits 15:8] Maximum_Performance See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[11] = 1. + /// + UINT32 Maximum_Performance:8; + /// + /// [Bits 23:16] Desired_Performance See Section 14.4.4, "Managing HWP". + /// If CPUID.06H:EAX.[11] = 1. + /// + UINT32 Desired_Performance:8; + /// + /// [Bits 31:24] Energy_Performance_Preference See Section 14.4.4, + /// "Managing HWP". If CPUID.06H:EAX.[11] = 1 && CPUID.06H:EAX.[10] = 1. + /// + UINT32 Energy_Performance_Preference:8; + /// + /// [Bits 41:32] Activity_Window See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[11] = 1 && CPUID.06H:EAX.[9] = 1. + /// + UINT32 Activity_Window:10; + UINT32 Reserved:22; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_HWP_REQUEST_PKG_REGISTER; + + +/** + Control HWP Native Interrupts (R/W). If CPUID.06H:EAX.[8] = 1. + + @param ECX MSR_IA32_HWP_INTERRUPT (0x00000773) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_HWP_INTERRUPT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_HWP_INTERRUPT_REGISTER. + + Example usage + @code + MSR_IA32_HWP_INTERRUPT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_INTERRUPT); + AsmWriteMsr64 (MSR_IA32_HWP_INTERRUPT, Msr.Uint64); + @endcode + @note MSR_IA32_HWP_INTERRUPT is defined as IA32_HWP_INTERRUPT in SDM. +**/ +#define MSR_IA32_HWP_INTERRUPT 0x00000773 + +/** + MSR information returned for MSR index #MSR_IA32_HWP_INTERRUPT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] EN_Guaranteed_Performance_Change. See Section 14.4.6, "HWP + /// Notifications". If CPUID.06H:EAX.[8] = 1. + /// + UINT32 EN_Guaranteed_Performance_Change:1; + /// + /// [Bit 1] EN_Excursion_Minimum. See Section 14.4.6, "HWP Notifications". + /// If CPUID.06H:EAX.[8] = 1. + /// + UINT32 EN_Excursion_Minimum:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_HWP_INTERRUPT_REGISTER; + + +/** + Power Management Control Hints to a Logical Processor (R/W). If + CPUID.06H:EAX.[7] = 1. + + @param ECX MSR_IA32_HWP_REQUEST (0x00000774) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_HWP_REQUEST_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_HWP_REQUEST_REGISTER. + + Example usage + @code + MSR_IA32_HWP_REQUEST_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_REQUEST); + AsmWriteMsr64 (MSR_IA32_HWP_REQUEST, Msr.Uint64); + @endcode + @note MSR_IA32_HWP_REQUEST is defined as IA32_HWP_REQUEST in SDM. +**/ +#define MSR_IA32_HWP_REQUEST 0x00000774 + +/** + MSR information returned for MSR index #MSR_IA32_HWP_REQUEST +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Minimum_Performance See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[7] = 1. + /// + UINT32 Minimum_Performance:8; + /// + /// [Bits 15:8] Maximum_Performance See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[7] = 1. + /// + UINT32 Maximum_Performance:8; + /// + /// [Bits 23:16] Desired_Performance See Section 14.4.4, "Managing HWP". + /// If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Desired_Performance:8; + /// + /// [Bits 31:24] Energy_Performance_Preference See Section 14.4.4, + /// "Managing HWP". If CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[10] = 1. + /// + UINT32 Energy_Performance_Preference:8; + /// + /// [Bits 41:32] Activity_Window See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[9] = 1. + /// + UINT32 Activity_Window:10; + /// + /// [Bit 42] Package_Control See Section 14.4.4, "Managing HWP". If + /// CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[11] = 1. + /// + UINT32 Package_Control:1; + UINT32 Reserved:21; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_HWP_REQUEST_REGISTER; + + +/** + Log bits indicating changes to Guaranteed & excursions to Minimum (R/W). If + CPUID.06H:EAX.[7] = 1. + + @param ECX MSR_IA32_HWP_STATUS (0x00000777) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_HWP_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_HWP_STATUS_REGISTER. + + Example usage + @code + MSR_IA32_HWP_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_STATUS); + AsmWriteMsr64 (MSR_IA32_HWP_STATUS, Msr.Uint64); + @endcode + @note MSR_IA32_HWP_STATUS is defined as IA32_HWP_STATUS in SDM. +**/ +#define MSR_IA32_HWP_STATUS 0x00000777 + +/** + MSR information returned for MSR index #MSR_IA32_HWP_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Guaranteed_Performance_Change (R/WC0). See Section 14.4.5, + /// "HWP Feedback". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Guaranteed_Performance_Change:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Excursion_To_Minimum (R/WC0). See Section 14.4.5, "HWP + /// Feedback". If CPUID.06H:EAX.[7] = 1. + /// + UINT32 Excursion_To_Minimum:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_HWP_STATUS_REGISTER; + + +/** + x2APIC ID Register (R/O) See x2APIC Specification. If CPUID.01H:ECX[21] = 1 + && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_APICID (0x00000802) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_APICID); + @endcode + @note MSR_IA32_X2APIC_APICID is defined as IA32_X2APIC_APICID in SDM. +**/ +#define MSR_IA32_X2APIC_APICID 0x00000802 + + +/** + x2APIC Version Register (R/O). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_VERSION (0x00000803) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_VERSION); + @endcode + @note MSR_IA32_X2APIC_VERSION is defined as IA32_X2APIC_VERSION in SDM. +**/ +#define MSR_IA32_X2APIC_VERSION 0x00000803 + + +/** + x2APIC Task Priority Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_TPR (0x00000808) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_TPR); + AsmWriteMsr64 (MSR_IA32_X2APIC_TPR, Msr); + @endcode + @note MSR_IA32_X2APIC_TPR is defined as IA32_X2APIC_TPR in SDM. +**/ +#define MSR_IA32_X2APIC_TPR 0x00000808 + + +/** + x2APIC Processor Priority Register (R/O). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_PPR (0x0000080A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_PPR); + @endcode + @note MSR_IA32_X2APIC_PPR is defined as IA32_X2APIC_PPR in SDM. +**/ +#define MSR_IA32_X2APIC_PPR 0x0000080A + + +/** + x2APIC EOI Register (W/O). If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] + = 1. + + @param ECX MSR_IA32_X2APIC_EOI (0x0000080B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = 0; + AsmWriteMsr64 (MSR_IA32_X2APIC_EOI, Msr); + @endcode + @note MSR_IA32_X2APIC_EOI is defined as IA32_X2APIC_EOI in SDM. +**/ +#define MSR_IA32_X2APIC_EOI 0x0000080B + + +/** + x2APIC Logical Destination Register (R/O). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LDR (0x0000080D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LDR); + @endcode + @note MSR_IA32_X2APIC_LDR is defined as IA32_X2APIC_LDR in SDM. +**/ +#define MSR_IA32_X2APIC_LDR 0x0000080D + + +/** + x2APIC Spurious Interrupt Vector Register (R/W). If CPUID.01H:ECX.[21] = 1 + && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_SIVR (0x0000080F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_SIVR); + AsmWriteMsr64 (MSR_IA32_X2APIC_SIVR, Msr); + @endcode + @note MSR_IA32_X2APIC_SIVR is defined as IA32_X2APIC_SIVR in SDM. +**/ +#define MSR_IA32_X2APIC_SIVR 0x0000080F + + +/** + x2APIC In-Service Register Bits (n * 32 + 31):(n * 32) (R/O). + If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_ISRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ISR0); + @endcode + @note MSR_IA32_X2APIC_ISR0 is defined as IA32_X2APIC_ISR0 in SDM. + MSR_IA32_X2APIC_ISR1 is defined as IA32_X2APIC_ISR1 in SDM. + MSR_IA32_X2APIC_ISR2 is defined as IA32_X2APIC_ISR2 in SDM. + MSR_IA32_X2APIC_ISR3 is defined as IA32_X2APIC_ISR3 in SDM. + MSR_IA32_X2APIC_ISR4 is defined as IA32_X2APIC_ISR4 in SDM. + MSR_IA32_X2APIC_ISR5 is defined as IA32_X2APIC_ISR5 in SDM. + MSR_IA32_X2APIC_ISR6 is defined as IA32_X2APIC_ISR6 in SDM. + MSR_IA32_X2APIC_ISR7 is defined as IA32_X2APIC_ISR7 in SDM. + @{ +**/ +#define MSR_IA32_X2APIC_ISR0 0x00000810 +#define MSR_IA32_X2APIC_ISR1 0x00000811 +#define MSR_IA32_X2APIC_ISR2 0x00000812 +#define MSR_IA32_X2APIC_ISR3 0x00000813 +#define MSR_IA32_X2APIC_ISR4 0x00000814 +#define MSR_IA32_X2APIC_ISR5 0x00000815 +#define MSR_IA32_X2APIC_ISR6 0x00000816 +#define MSR_IA32_X2APIC_ISR7 0x00000817 +/// @} + + +/** + x2APIC Trigger Mode Register Bits (n * 32 + ):(n * 32) (R/O). + If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_TMRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_TMR0); + @endcode + @note MSR_IA32_X2APIC_TMR0 is defined as IA32_X2APIC_TMR0 in SDM. + MSR_IA32_X2APIC_TMR1 is defined as IA32_X2APIC_TMR1 in SDM. + MSR_IA32_X2APIC_TMR2 is defined as IA32_X2APIC_TMR2 in SDM. + MSR_IA32_X2APIC_TMR3 is defined as IA32_X2APIC_TMR3 in SDM. + MSR_IA32_X2APIC_TMR4 is defined as IA32_X2APIC_TMR4 in SDM. + MSR_IA32_X2APIC_TMR5 is defined as IA32_X2APIC_TMR5 in SDM. + MSR_IA32_X2APIC_TMR6 is defined as IA32_X2APIC_TMR6 in SDM. + MSR_IA32_X2APIC_TMR7 is defined as IA32_X2APIC_TMR7 in SDM. + @{ +**/ +#define MSR_IA32_X2APIC_TMR0 0x00000818 +#define MSR_IA32_X2APIC_TMR1 0x00000819 +#define MSR_IA32_X2APIC_TMR2 0x0000081A +#define MSR_IA32_X2APIC_TMR3 0x0000081B +#define MSR_IA32_X2APIC_TMR4 0x0000081C +#define MSR_IA32_X2APIC_TMR5 0x0000081D +#define MSR_IA32_X2APIC_TMR6 0x0000081E +#define MSR_IA32_X2APIC_TMR7 0x0000081F +/// @} + + +/** + x2APIC Interrupt Request Register Bits (n* 32 + 31):(n * 32) (R/O). + If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_IRRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_IRR0); + @endcode + @note MSR_IA32_X2APIC_IRR0 is defined as IA32_X2APIC_IRR0 in SDM. + MSR_IA32_X2APIC_IRR1 is defined as IA32_X2APIC_IRR1 in SDM. + MSR_IA32_X2APIC_IRR2 is defined as IA32_X2APIC_IRR2 in SDM. + MSR_IA32_X2APIC_IRR3 is defined as IA32_X2APIC_IRR3 in SDM. + MSR_IA32_X2APIC_IRR4 is defined as IA32_X2APIC_IRR4 in SDM. + MSR_IA32_X2APIC_IRR5 is defined as IA32_X2APIC_IRR5 in SDM. + MSR_IA32_X2APIC_IRR6 is defined as IA32_X2APIC_IRR6 in SDM. + MSR_IA32_X2APIC_IRR7 is defined as IA32_X2APIC_IRR7 in SDM. + @{ +**/ +#define MSR_IA32_X2APIC_IRR0 0x00000820 +#define MSR_IA32_X2APIC_IRR1 0x00000821 +#define MSR_IA32_X2APIC_IRR2 0x00000822 +#define MSR_IA32_X2APIC_IRR3 0x00000823 +#define MSR_IA32_X2APIC_IRR4 0x00000824 +#define MSR_IA32_X2APIC_IRR5 0x00000825 +#define MSR_IA32_X2APIC_IRR6 0x00000826 +#define MSR_IA32_X2APIC_IRR7 0x00000827 +/// @} + + +/** + x2APIC Error Status Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_ESR (0x00000828) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ESR); + AsmWriteMsr64 (MSR_IA32_X2APIC_ESR, Msr); + @endcode + @note MSR_IA32_X2APIC_ESR is defined as IA32_X2APIC_ESR in SDM. +**/ +#define MSR_IA32_X2APIC_ESR 0x00000828 + + +/** + x2APIC LVT Corrected Machine Check Interrupt Register (R/W). If + CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_CMCI (0x0000082F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_CMCI); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_CMCI, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_CMCI is defined as IA32_X2APIC_LVT_CMCI in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_CMCI 0x0000082F + + +/** + x2APIC Interrupt Command Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_ICR (0x00000830) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ICR); + AsmWriteMsr64 (MSR_IA32_X2APIC_ICR, Msr); + @endcode + @note MSR_IA32_X2APIC_ICR is defined as IA32_X2APIC_ICR in SDM. +**/ +#define MSR_IA32_X2APIC_ICR 0x00000830 + + +/** + x2APIC LVT Timer Interrupt Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_TIMER (0x00000832) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_TIMER); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_TIMER, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_TIMER is defined as IA32_X2APIC_LVT_TIMER in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_TIMER 0x00000832 + + +/** + x2APIC LVT Thermal Sensor Interrupt Register (R/W). If CPUID.01H:ECX.[21] = + 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_THERMAL (0x00000833) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_THERMAL); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_THERMAL, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_THERMAL is defined as IA32_X2APIC_LVT_THERMAL in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_THERMAL 0x00000833 + + +/** + x2APIC LVT Performance Monitor Interrupt Register (R/W). If + CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_PMI (0x00000834) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_PMI); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_PMI, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_PMI is defined as IA32_X2APIC_LVT_PMI in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_PMI 0x00000834 + + +/** + x2APIC LVT LINT0 Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_LINT0 (0x00000835) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_LINT0); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_LINT0, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_LINT0 is defined as IA32_X2APIC_LVT_LINT0 in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_LINT0 0x00000835 + + +/** + x2APIC LVT LINT1 Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_LINT1 (0x00000836) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_LINT1); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_LINT1, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_LINT1 is defined as IA32_X2APIC_LVT_LINT1 in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_LINT1 0x00000836 + + +/** + x2APIC LVT Error Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_LVT_ERROR (0x00000837) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_ERROR); + AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_ERROR, Msr); + @endcode + @note MSR_IA32_X2APIC_LVT_ERROR is defined as IA32_X2APIC_LVT_ERROR in SDM. +**/ +#define MSR_IA32_X2APIC_LVT_ERROR 0x00000837 + + +/** + x2APIC Initial Count Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_INIT_COUNT (0x00000838) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_INIT_COUNT); + AsmWriteMsr64 (MSR_IA32_X2APIC_INIT_COUNT, Msr); + @endcode + @note MSR_IA32_X2APIC_INIT_COUNT is defined as IA32_X2APIC_INIT_COUNT in SDM. +**/ +#define MSR_IA32_X2APIC_INIT_COUNT 0x00000838 + + +/** + x2APIC Current Count Register (R/O). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_CUR_COUNT (0x00000839) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_CUR_COUNT); + @endcode + @note MSR_IA32_X2APIC_CUR_COUNT is defined as IA32_X2APIC_CUR_COUNT in SDM. +**/ +#define MSR_IA32_X2APIC_CUR_COUNT 0x00000839 + + +/** + x2APIC Divide Configuration Register (R/W). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_DIV_CONF (0x0000083E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_X2APIC_DIV_CONF); + AsmWriteMsr64 (MSR_IA32_X2APIC_DIV_CONF, Msr); + @endcode + @note MSR_IA32_X2APIC_DIV_CONF is defined as IA32_X2APIC_DIV_CONF in SDM. +**/ +#define MSR_IA32_X2APIC_DIV_CONF 0x0000083E + + +/** + x2APIC Self IPI Register (W/O). If CPUID.01H:ECX.[21] = 1 && + IA32_APIC_BASE.[10] = 1. + + @param ECX MSR_IA32_X2APIC_SELF_IPI (0x0000083F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = 0; + AsmWriteMsr64 (MSR_IA32_X2APIC_SELF_IPI, Msr); + @endcode + @note MSR_IA32_X2APIC_SELF_IPI is defined as IA32_X2APIC_SELF_IPI in SDM. +**/ +#define MSR_IA32_X2APIC_SELF_IPI 0x0000083F + + +/** + Silicon Debug Feature Control (R/W). If CPUID.01H:ECX.[11] = 1. + + @param ECX MSR_IA32_DEBUG_INTERFACE (0x00000C80) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_DEBUG_INTERFACE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_DEBUG_INTERFACE_REGISTER. + + Example usage + @code + MSR_IA32_DEBUG_INTERFACE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DEBUG_INTERFACE); + AsmWriteMsr64 (MSR_IA32_DEBUG_INTERFACE, Msr.Uint64); + @endcode + @note MSR_IA32_DEBUG_INTERFACE is defined as IA32_DEBUG_INTERFACE in SDM. +**/ +#define MSR_IA32_DEBUG_INTERFACE 0x00000C80 + +/** + MSR information returned for MSR index #MSR_IA32_DEBUG_INTERFACE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable (R/W) BIOS set 1 to enable Silicon debug features. + /// Default is 0. If CPUID.01H:ECX.[11] = 1. + /// + UINT32 Enable:1; + UINT32 Reserved1:29; + /// + /// [Bit 30] Lock (R/W): If 1, locks any further change to the MSR. The + /// lock bit is set automatically on the first SMI assertion even if not + /// explicitly set by BIOS. Default is 0. If CPUID.01H:ECX.[11] = 1. + /// + UINT32 Lock:1; + /// + /// [Bit 31] Debug Occurred (R/O): This "sticky bit" is set by hardware to + /// indicate the status of bit 0. Default is 0. If CPUID.01H:ECX.[11] = 1. + /// + UINT32 DebugOccurred:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_DEBUG_INTERFACE_REGISTER; + + +/** + L3 QOS Configuration (R/W). If ( CPUID.(EAX=10H, ECX=1):ECX.[2] = 1 ). + + @param ECX MSR_IA32_L3_QOS_CFG (0x00000C81) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_L3_QOS_CFG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_L3_QOS_CFG_REGISTER. + + Example usage + @code + MSR_IA32_L3_QOS_CFG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_L3_QOS_CFG); + AsmWriteMsr64 (MSR_IA32_L3_QOS_CFG, Msr.Uint64); + @endcode + @note MSR_IA32_L3_QOS_CFG is defined as IA32_L3_QOS_CFG in SDM. +**/ +#define MSR_IA32_L3_QOS_CFG 0x00000C81 + +/** + MSR information returned for MSR index #MSR_IA32_L3_QOS_CFG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable (R/W) Set 1 to enable L3 CAT masks and COS to operate + /// in Code and Data Prioritization (CDP) mode. + /// + UINT32 Enable:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_L3_QOS_CFG_REGISTER; + + +/** + Monitoring Event Select Register (R/W). If ( CPUID.(EAX=07H, ECX=0):EBX.[12] + = 1 ). + + @param ECX MSR_IA32_QM_EVTSEL (0x00000C8D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_QM_EVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_QM_EVTSEL_REGISTER. + + Example usage + @code + MSR_IA32_QM_EVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_QM_EVTSEL); + AsmWriteMsr64 (MSR_IA32_QM_EVTSEL, Msr.Uint64); + @endcode + @note MSR_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. +**/ +#define MSR_IA32_QM_EVTSEL 0x00000C8D + +/** + MSR information returned for MSR index #MSR_IA32_QM_EVTSEL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Event ID: ID of a supported monitoring event to report via + /// IA32_QM_CTR. + /// + UINT32 EventID:8; + UINT32 Reserved:24; + /// + /// [Bits 63:32] Resource Monitoring ID: ID for monitoring hardware to + /// report monitored data via IA32_QM_CTR. N = Ceil (Log:sub:`2` ( + /// CPUID.(EAX= 0FH, ECX=0H).EBX[31:0] +1)). + /// + UINT32 ResourceMonitoringID:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_QM_EVTSEL_REGISTER; + + +/** + Monitoring Counter Register (R/O). If ( CPUID.(EAX=07H, ECX=0):EBX.[12] = 1 + ). + + @param ECX MSR_IA32_QM_CTR (0x00000C8E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_QM_CTR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_QM_CTR_REGISTER. + + Example usage + @code + MSR_IA32_QM_CTR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_QM_CTR); + @endcode + @note MSR_IA32_QM_CTR is defined as IA32_QM_CTR in SDM. +**/ +#define MSR_IA32_QM_CTR 0x00000C8E + +/** + MSR information returned for MSR index #MSR_IA32_QM_CTR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Resource Monitored Data. + /// + UINT32 ResourceMonitoredData:32; + /// + /// [Bits 61:32] Resource Monitored Data. + /// + UINT32 ResourceMonitoredDataHi:30; + /// + /// [Bit 62] Unavailable: If 1, indicates data for this RMID is not + /// available or not monitored for this resource or RMID. + /// + UINT32 Unavailable:1; + /// + /// [Bit 63] Error: If 1, indicates and unsupported RMID or event type was + /// written to IA32_PQR_QM_EVTSEL. + /// + UINT32 Error:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_QM_CTR_REGISTER; + + +/** + Resource Association Register (R/W). If ( (CPUID.(EAX=07H, ECX=0):EBX[12] + =1) or (CPUID.(EAX=07H, ECX=0):EBX[15] =1 ) ). + + @param ECX MSR_IA32_PQR_ASSOC (0x00000C8F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PQR_ASSOC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PQR_ASSOC_REGISTER. + + Example usage + @code + MSR_IA32_PQR_ASSOC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PQR_ASSOC); + AsmWriteMsr64 (MSR_IA32_PQR_ASSOC, Msr.Uint64); + @endcode + @note MSR_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. +**/ +#define MSR_IA32_PQR_ASSOC 0x00000C8F + +/** + MSR information returned for MSR index #MSR_IA32_PQR_ASSOC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Resource Monitoring ID (R/W): ID for monitoring hardware + /// to track internal operation, e.g. memory access. N = Ceil (Log:sub:`2` + /// ( CPUID.(EAX= 0FH, ECX=0H).EBX[31:0] +1)). + /// + UINT32 ResourceMonitoringID:32; + /// + /// [Bits 63:32] COS (R/W). The class of service (COS) to enforce (on + /// writes); returns the current COS when read. If ( CPUID.(EAX=07H, + /// ECX=0):EBX.[15] = 1 ). + /// + UINT32 COS:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PQR_ASSOC_REGISTER; + + +/** + Supervisor State of MPX Configuration. (R/W). If (CPUID.(EAX=07H, + ECX=0H):EBX[14] = 1). + + @param ECX MSR_IA32_BNDCFGS (0x00000D90) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_BNDCFGS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_BNDCFGS_REGISTER. + + Example usage + @code + MSR_IA32_BNDCFGS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_BNDCFGS); + AsmWriteMsr64 (MSR_IA32_BNDCFGS, Msr.Uint64); + @endcode + @note MSR_IA32_BNDCFGS is defined as IA32_BNDCFGS in SDM. +**/ +#define MSR_IA32_BNDCFGS 0x00000D90 + +/** + MSR information returned for MSR index #MSR_IA32_BNDCFGS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] EN: Enable Intel MPX in supervisor mode. + /// + UINT32 EN:1; + /// + /// [Bit 1] BNDPRESERVE: Preserve the bounds registers for near branch + /// instructions in the absence of the BND prefix. + /// + UINT32 BNDPRESERVE:1; + UINT32 Reserved:10; + /// + /// [Bits 31:12] Base Address of Bound Directory. + /// + UINT32 Base:20; + /// + /// [Bits 63:32] Base Address of Bound Directory. + /// + UINT32 BaseHi:32; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_BNDCFGS_REGISTER; + + +/** + Extended Supervisor State Mask (R/W). If( CPUID.(0DH, 1):EAX.[3] = 1. + + @param ECX MSR_IA32_XSS (0x00000DA0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_XSS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_XSS_REGISTER. + + Example usage + @code + MSR_IA32_XSS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_XSS); + AsmWriteMsr64 (MSR_IA32_XSS, Msr.Uint64); + @endcode + @note MSR_IA32_XSS is defined as IA32_XSS in SDM. +**/ +#define MSR_IA32_XSS 0x00000DA0 + +/** + MSR information returned for MSR index #MSR_IA32_XSS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bit 8] Trace Packet Configuration State (R/W). + /// + UINT32 TracePacketConfigurationState:1; + UINT32 Reserved2:23; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_XSS_REGISTER; + + +/** + Package Level Enable/disable HDC (R/W). If CPUID.06H:EAX.[13] = 1. + + @param ECX MSR_IA32_PKG_HDC_CTL (0x00000DB0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PKG_HDC_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PKG_HDC_CTL_REGISTER. + + Example usage + @code + MSR_IA32_PKG_HDC_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PKG_HDC_CTL); + AsmWriteMsr64 (MSR_IA32_PKG_HDC_CTL, Msr.Uint64); + @endcode + @note MSR_IA32_PKG_HDC_CTL is defined as IA32_PKG_HDC_CTL in SDM. +**/ +#define MSR_IA32_PKG_HDC_CTL 0x00000DB0 + +/** + MSR information returned for MSR index #MSR_IA32_PKG_HDC_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] HDC_Pkg_Enable (R/W) Force HDC idling or wake up HDC-idled + /// logical processors in the package. See Section 14.5.2, "Package level + /// Enabling HDC". If CPUID.06H:EAX.[13] = 1. + /// + UINT32 HDC_Pkg_Enable:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PKG_HDC_CTL_REGISTER; + + +/** + Enable/disable HWP (R/W). If CPUID.06H:EAX.[13] = 1. + + @param ECX MSR_IA32_PM_CTL1 (0x00000DB1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_PM_CTL1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_PM_CTL1_REGISTER. + + Example usage + @code + MSR_IA32_PM_CTL1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PM_CTL1); + AsmWriteMsr64 (MSR_IA32_PM_CTL1, Msr.Uint64); + @endcode + @note MSR_IA32_PM_CTL1 is defined as IA32_PM_CTL1 in SDM. +**/ +#define MSR_IA32_PM_CTL1 0x00000DB1 + +/** + MSR information returned for MSR index #MSR_IA32_PM_CTL1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] HDC_Allow_Block (R/W) Allow/Block this logical processor for + /// package level HDC control. See Section 14.5.3. + /// If CPUID.06H:EAX.[13] = 1. + /// + UINT32 HDC_Allow_Block:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_PM_CTL1_REGISTER; + + +/** + Per-Logical_Processor HDC Idle Residency (R/0). If CPUID.06H:EAX.[13] = 1. + Stall_Cycle_Cnt (R/W) Stalled cycles due to HDC forced idle on this logical + processor. See Section 14.5.4.1. If CPUID.06H:EAX.[13] = 1. + + @param ECX MSR_IA32_THREAD_STALL (0x00000DB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_THREAD_STALL); + @endcode + @note MSR_IA32_THREAD_STALL is defined as IA32_THREAD_STALL in SDM. +**/ +#define MSR_IA32_THREAD_STALL 0x00000DB2 + + +/** + Extended Feature Enables. If ( CPUID.80000001H:EDX.[2 0] + CPUID.80000001H:EDX.[2 9]). + + @param ECX MSR_IA32_EFER (0xC0000080) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_EFER_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_EFER_REGISTER. + + Example usage + @code + MSR_IA32_EFER_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER); + AsmWriteMsr64 (MSR_IA32_EFER, Msr.Uint64); + @endcode + @note MSR_IA32_EFER is defined as IA32_EFER in SDM. +**/ +#define MSR_IA32_EFER 0xC0000080 + +/** + MSR information returned for MSR index #MSR_IA32_EFER +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] SYSCALL Enable: IA32_EFER.SCE (R/W) Enables SYSCALL/SYSRET + /// instructions in 64-bit mode. + /// + UINT32 SCE:1; + UINT32 Reserved1:7; + /// + /// [Bit 8] IA-32e Mode Enable: IA32_EFER.LME (R/W) Enables IA-32e mode + /// operation. + /// + UINT32 LME:1; + UINT32 Reserved2:1; + /// + /// [Bit 10] IA-32e Mode Active: IA32_EFER.LMA (R) Indicates IA-32e mode + /// is active when set. + /// + UINT32 LMA:1; + /// + /// [Bit 11] Execute Disable Bit Enable: IA32_EFER.NXE (R/W). + /// + UINT32 NXE:1; + UINT32 Reserved3:20; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_EFER_REGISTER; + + +/** + System Call Target Address (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_STAR (0xC0000081) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_STAR); + AsmWriteMsr64 (MSR_IA32_STAR, Msr); + @endcode + @note MSR_IA32_STAR is defined as IA32_STAR in SDM. +**/ +#define MSR_IA32_STAR 0xC0000081 + + +/** + IA-32e Mode System Call Target Address (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_LSTAR (0xC0000082) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_LSTAR); + AsmWriteMsr64 (MSR_IA32_LSTAR, Msr); + @endcode + @note MSR_IA32_LSTAR is defined as IA32_LSTAR in SDM. +**/ +#define MSR_IA32_LSTAR 0xC0000082 + + +/** + System Call Flag Mask (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_FMASK (0xC0000084) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_FMASK); + AsmWriteMsr64 (MSR_IA32_FMASK, Msr); + @endcode + @note MSR_IA32_FMASK is defined as IA32_FMASK in SDM. +**/ +#define MSR_IA32_FMASK 0xC0000084 + + +/** + Map of BASE Address of FS (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_FS_BASE (0xC0000100) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_FS_BASE); + AsmWriteMsr64 (MSR_IA32_FS_BASE, Msr); + @endcode + @note MSR_IA32_FS_BASE is defined as IA32_FS_BASE in SDM. +**/ +#define MSR_IA32_FS_BASE 0xC0000100 + + +/** + Map of BASE Address of GS (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_GS_BASE (0xC0000101) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_GS_BASE); + AsmWriteMsr64 (MSR_IA32_GS_BASE, Msr); + @endcode + @note MSR_IA32_GS_BASE is defined as IA32_GS_BASE in SDM. +**/ +#define MSR_IA32_GS_BASE 0xC0000101 + + +/** + Swap Target of BASE Address of GS (R/W). If CPUID.80000001:EDX.[29] = 1. + + @param ECX MSR_IA32_KERNEL_GS_BASE (0xC0000102) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IA32_KERNEL_GS_BASE); + AsmWriteMsr64 (MSR_IA32_KERNEL_GS_BASE, Msr); + @endcode + @note MSR_IA32_KERNEL_GS_BASE is defined as IA32_KERNEL_GS_BASE in SDM. +**/ +#define MSR_IA32_KERNEL_GS_BASE 0xC0000102 + + +/** + Auxiliary TSC (RW). If CPUID.80000001H: EDX[27] = 1. + + @param ECX MSR_IA32_TSC_AUX (0xC0000103) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IA32_TSC_AUX_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IA32_TSC_AUX_REGISTER. + + Example usage + @code + MSR_IA32_TSC_AUX_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IA32_TSC_AUX); + AsmWriteMsr64 (MSR_IA32_TSC_AUX, Msr.Uint64); + @endcode + @note MSR_IA32_TSC_AUX is defined as IA32_TSC_AUX in SDM. +**/ +#define MSR_IA32_TSC_AUX 0xC0000103 + +/** + MSR information returned for MSR index #MSR_IA32_TSC_AUX +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] AUX: Auxiliary signature of TSC. + /// + UINT32 AUX:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IA32_TSC_AUX_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Cpuid.h b/Core/UefiCpuPkg/Include/Register/Cpuid.h new file mode 100644 index 0000000000..5eb9650553 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Cpuid.h @@ -0,0 +1,3536 @@ +/** @file + CPUID leaf definitions. + + Provides defines for CPUID leaf indexes. Data structures are provided for + registers returned by a CPUID leaf that contain one or more bit fields. + If a register returned is a single 32-bit value, then a data structure is + not provided for that register. + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under + the terms and conditions of the BSD License which accompanies this distribution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 2A, + September 2016, CPUID instruction. + +**/ + +#ifndef __CPUID_H__ +#define __CPUID_H__ + +/** + CPUID Signature Information + + @param EAX CPUID_SIGNATURE (0x00) + + @retval EAX Returns the highest value the CPUID instruction recognizes for + returning basic processor information. The value is returned is + processor specific. + @retval EBX First 4 characters of a vendor identification string. + @retval ECX Last 4 characters of a vendor identification string. + @retval EDX Middle 4 characters of a vendor identification string. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuid (CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx); + @endcode +**/ +#define CPUID_SIGNATURE 0x00 + +/// +/// @{ CPUID signature values returned by Intel processors +/// +#define CPUID_SIGNATURE_GENUINE_INTEL_EBX SIGNATURE_32 ('G', 'e', 'n', 'u') +#define CPUID_SIGNATURE_GENUINE_INTEL_EDX SIGNATURE_32 ('i', 'n', 'e', 'I') +#define CPUID_SIGNATURE_GENUINE_INTEL_ECX SIGNATURE_32 ('n', 't', 'e', 'l') +/// +/// @} +/// + + +/** + CPUID Version Information + + @param EAX CPUID_VERSION_INFO (0x01) + + @retval EAX Returns Model, Family, Stepping Information described by the + type CPUID_VERSION_INFO_EAX. + @retval EBX Returns Brand, Cache Line Size, and Initial APIC ID described by + the type CPUID_VERSION_INFO_EBX. + @retval ECX CPU Feature Information described by the type + CPUID_VERSION_INFO_ECX. + @retval EDX CPU Feature Information described by the type + CPUID_VERSION_INFO_EDX. + + Example usage + @code + CPUID_VERSION_INFO_EAX Eax; + CPUID_VERSION_INFO_EBX Ebx; + CPUID_VERSION_INFO_ECX Ecx; + CPUID_VERSION_INFO_EDX Edx; + + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_VERSION_INFO 0x01 + +/** + CPUID Version Information returned in EAX for CPUID leaf + #CPUID_VERSION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 SteppingId:4; ///< [Bits 3:0] Stepping ID + UINT32 Model:4; ///< [Bits 7:4] Model + UINT32 FamilyId:4; ///< [Bits 11:8] Family + UINT32 ProcessorType:2; ///< [Bits 13:12] Processor Type + UINT32 Reserved1:2; ///< [Bits 15:14] Reserved + UINT32 ExtendedModelId:4; ///< [Bits 19:16] Extended Model ID + UINT32 ExtendedFamilyId:8; ///< [Bits 27:20] Extended Family ID + UINT32 Reserved2:4; ///< Reserved + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_VERSION_INFO_EAX; + +/// +/// @{ Define value for bit field CPUID_VERSION_INFO_EAX.ProcessorType +/// +#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_ORIGINAL_OEM_PROCESSOR 0x00 +#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_INTEL_OVERDRIVE_PROCESSOR 0x01 +#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_DUAL_PROCESSOR 0x02 +/// +/// @} +/// + +/** + CPUID Version Information returned in EBX for CPUID leaf + #CPUID_VERSION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Provides an entry into a brand string table that contains + /// brand strings for IA-32 processors. + /// + UINT32 BrandIndex:8; + /// + /// [Bits 15:8] Indicates the size of the cache line flushed by the CLFLUSH + /// and CLFLUSHOPT instructions in 8-byte increments. This field was + /// introduced in the Pentium 4 processor. + /// + UINT32 CacheLineSize:8; + /// + /// [Bits 23:16] Maximum number of addressable IDs for logical processors + /// in this physical package. + /// + /// @note + /// The nearest power-of-2 integer that is not smaller than EBX[23:16] is + /// the number of unique initial APICIDs reserved for addressing different + /// logical processors in a physical package. This field is only valid if + /// CPUID.1.EDX.HTT[bit 28]= 1. + /// + UINT32 MaximumAddressableIdsForLogicalProcessors:8; + /// + /// [Bits 31:24] The 8-bit ID that is assigned to the local APIC on the + /// processor during power up. This field was introduced in the Pentium 4 + /// processor. + /// + UINT32 InitialLocalApicId:8; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_VERSION_INFO_EBX; + +/** + CPUID Version Information returned in ECX for CPUID leaf + #CPUID_VERSION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Streaming SIMD Extensions 3 (SSE3). A value of 1 indicates the + /// processor supports this technology + /// + UINT32 SSE3:1; + /// + /// [Bit 1] A value of 1 indicates the processor supports the PCLMULQDQ + /// instruction. Carryless Multiplication + /// + UINT32 PCLMULQDQ:1; + /// + /// [Bit 2] 64-bit DS Area. A value of 1 indicates the processor supports + /// DS area using 64-bit layout. + /// + UINT32 DTES64:1; + /// + /// [Bit 3] MONITOR/MWAIT. A value of 1 indicates the processor supports + /// this feature. + /// + UINT32 MONITOR:1; + /// + /// [Bit 4] CPL Qualified Debug Store. A value of 1 indicates the processor + /// supports the extensions to the Debug Store feature to allow for branch + /// message storage qualified by CPL + /// + UINT32 DS_CPL:1; + /// + /// [Bit 5] Virtual Machine Extensions. A value of 1 indicates that the + /// processor supports this technology. + /// + UINT32 VMX:1; + /// + /// [Bit 6] Safer Mode Extensions. A value of 1 indicates that the processor + /// supports this technology + /// + UINT32 SMX:1; + /// + /// [Bit 7] Enhanced Intel SpeedStep(R) technology. A value of 1 indicates + /// that the processor supports this technology + /// + UINT32 EIST:1; + /// + /// [Bit 8] Thermal Monitor 2. A value of 1 indicates whether the processor + /// supports this technology + /// + UINT32 TM2:1; + /// + /// [Bit 9] A value of 1 indicates the presence of the Supplemental Streaming + /// SIMD Extensions 3 (SSSE3). A value of 0 indicates the instruction + /// extensions are not present in the processor. + /// + UINT32 SSSE3:1; + /// + /// [Bit 10] L1 Context ID. A value of 1 indicates the L1 data cache mode + /// can be set to either adaptive mode or shared mode. A value of 0 indicates + /// this feature is not supported. See definition of the IA32_MISC_ENABLE MSR + /// Bit 24 (L1 Data Cache Context Mode) for details + /// + UINT32 CNXT_ID:1; + /// + /// [Bit 11] A value of 1 indicates the processor supports IA32_DEBUG_INTERFACE + /// MSR for silicon debug + /// + UINT32 SDBG:1; + /// + /// [Bit 12] A value of 1 indicates the processor supports FMA (Fused Multiple + /// Add) extensions using YMM state. + /// + UINT32 FMA:1; + /// + /// [Bit 13] CMPXCHG16B Available. A value of 1 indicates that the feature + /// is available. + /// + UINT32 CMPXCHG16B:1; + /// + /// [Bit 14] xTPR Update Control. A value of 1 indicates that the processor + /// supports changing IA32_MISC_ENABLE[Bit 23]. + /// + UINT32 xTPR_Update_Control:1; + /// + /// [Bit 15] Perfmon and Debug Capability: A value of 1 indicates the + /// processor supports the performance and debug feature indication MSR + /// IA32_PERF_CAPABILITIES. + /// + UINT32 PDCM:1; + UINT32 Reserved:1; + /// + /// [Bit 17] Process-context identifiers. A value of 1 indicates that the + /// processor supports PCIDs and that software may set CR4.PCIDE to 1. + /// + UINT32 PCID:1; + /// + /// [Bit 18] A value of 1 indicates the processor supports the ability to + /// prefetch data from a memory mapped device. Direct Cache Access. + /// + UINT32 DCA:1; + /// + /// [Bit 19] A value of 1 indicates that the processor supports SSE4.1. + /// + UINT32 SSE4_1:1; + /// + /// [Bit 20] A value of 1 indicates that the processor supports SSE4.2. + /// + UINT32 SSE4_2:1; + /// + /// [Bit 21] A value of 1 indicates that the processor supports x2APIC + /// feature. + /// + UINT32 x2APIC:1; + /// + /// [Bit 22] A value of 1 indicates that the processor supports MOVBE + /// instruction. + /// + UINT32 MOVBE:1; + /// + /// [Bit 23] A value of 1 indicates that the processor supports the POPCNT + /// instruction. + /// + UINT32 POPCNT:1; + /// + /// [Bit 24] A value of 1 indicates that the processor's local APIC timer + /// supports one-shot operation using a TSC deadline value. + /// + UINT32 TSC_Deadline:1; + /// + /// [Bit 25] A value of 1 indicates that the processor supports the AESNI + /// instruction extensions. + /// + UINT32 AESNI:1; + /// + /// [Bit 26] A value of 1 indicates that the processor supports the + /// XSAVE/XRSTOR processor extended states feature, the XSETBV/XGETBV + /// instructions, and XCR0. + /// + UINT32 XSAVE:1; + /// + /// [Bit 27] A value of 1 indicates that the OS has set CR4.OSXSAVE[Bit 18] + /// to enable XSETBV/XGETBV instructions to access XCR0 and to support + /// processor extended state management using XSAVE/XRSTOR. + /// + UINT32 OSXSAVE:1; + /// + /// [Bit 28] A value of 1 indicates the processor supports the AVX instruction + /// extensions. + /// + UINT32 AVX:1; + /// + /// [Bit 29] A value of 1 indicates that processor supports 16-bit + /// floating-point conversion instructions. + /// + UINT32 F16C:1; + /// + /// [Bit 30] A value of 1 indicates that processor supports RDRAND instruction. + /// + UINT32 RDRAND:1; + /// + /// [Bit 31] Always returns 0. + /// + UINT32 NotUsed:1; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_VERSION_INFO_ECX; + +/** + CPUID Version Information returned in EDX for CPUID leaf + #CPUID_VERSION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Floating Point Unit On-Chip. The processor contains an x87 FPU. + /// + UINT32 FPU:1; + /// + /// [Bit 1] Virtual 8086 Mode Enhancements. Virtual 8086 mode enhancements, + /// including CR4.VME for controlling the feature, CR4.PVI for protected + /// mode virtual interrupts, software interrupt indirection, expansion of + /// the TSS with the software indirection bitmap, and EFLAGS.VIF and + /// EFLAGS.VIP flags. + /// + UINT32 VME:1; + /// + /// [Bit 2] Debugging Extensions. Support for I/O breakpoints, including + /// CR4.DE for controlling the feature, and optional trapping of accesses to + /// DR4 and DR5. + /// + UINT32 DE:1; + /// + /// [Bit 3] Page Size Extension. Large pages of size 4 MByte are supported, + /// including CR4.PSE for controlling the feature, the defined dirty bit in + /// PDE (Page Directory Entries), optional reserved bit trapping in CR3, + /// PDEs, and PTEs. + /// + UINT32 PSE:1; + /// + /// [Bit 4] Time Stamp Counter. The RDTSC instruction is supported, + /// including CR4.TSD for controlling privilege. + /// + UINT32 TSC:1; + /// + /// [Bit 5] Model Specific Registers RDMSR and WRMSR Instructions. The + /// RDMSR and WRMSR instructions are supported. Some of the MSRs are + /// implementation dependent. + /// + UINT32 MSR:1; + /// + /// [Bit 6] Physical Address Extension. Physical addresses greater than 32 + /// bits are supported: extended page table entry formats, an extra level in + /// the page translation tables is defined, 2-MByte pages are supported + /// instead of 4 Mbyte pages if PAE bit is 1. + /// + UINT32 PAE:1; + /// + /// [Bit 7] Machine Check Exception. Exception 18 is defined for Machine + /// Checks, including CR4.MCE for controlling the feature. This feature does + /// not define the model-specific implementations of machine-check error + /// logging, reporting, and processor shutdowns. Machine Check exception + /// handlers may have to depend on processor version to do model specific + /// processing of the exception, or test for the presence of the Machine + /// Check feature. + /// + UINT32 MCE:1; + /// + /// [Bit 8] CMPXCHG8B Instruction. The compare-and-exchange 8 bytes(64 bits) + /// instruction is supported (implicitly locked and atomic). + /// + UINT32 CX8:1; + /// + /// [Bit 9] APIC On-Chip. The processor contains an Advanced Programmable + /// Interrupt Controller (APIC), responding to memory mapped commands in the + /// physical address range FFFE0000H to FFFE0FFFH (by default - some + /// processors permit the APIC to be relocated). + /// + UINT32 APIC:1; + UINT32 Reserved1:1; + /// + /// [Bit 11] SYSENTER and SYSEXIT Instructions. The SYSENTER and SYSEXIT + /// and associated MSRs are supported. + /// + UINT32 SEP:1; + /// + /// [Bit 12] Memory Type Range Registers. MTRRs are supported. The MTRRcap + /// MSR contains feature bits that describe what memory types are supported, + /// how many variable MTRRs are supported, and whether fixed MTRRs are + /// supported. + /// + UINT32 MTRR:1; + /// + /// [Bit 13] Page Global Bit. The global bit is supported in paging-structure + /// entries that map a page, indicating TLB entries that are common to + /// different processes and need not be flushed. The CR4.PGE bit controls + /// this feature. + /// + UINT32 PGE:1; + /// + /// [Bit 14] Machine Check Architecture. A value of 1 indicates the Machine + /// Check Architecture of reporting machine errors is supported. The MCG_CAP + /// MSR contains feature bits describing how many banks of error reporting + /// MSRs are supported. + /// + UINT32 MCA:1; + /// + /// [Bit 15] Conditional Move Instructions. The conditional move instruction + /// CMOV is supported. In addition, if x87 FPU is present as indicated by the + /// CPUID.FPU feature bit, then the FCOMI and FCMOV instructions are supported. + /// + UINT32 CMOV:1; + /// + /// [Bit 16] Page Attribute Table. Page Attribute Table is supported. This + /// feature augments the Memory Type Range Registers (MTRRs), allowing an + /// operating system to specify attributes of memory accessed through a + /// linear address on a 4KB granularity. + /// + UINT32 PAT:1; + /// + /// [Bit 17] 36-Bit Page Size Extension. 4-MByte pages addressing physical + /// memory beyond 4 GBytes are supported with 32-bit paging. This feature + /// indicates that upper bits of the physical address of a 4-MByte page are + /// encoded in bits 20:13 of the page-directory entry. Such physical + /// addresses are limited by MAXPHYADDR and may be up to 40 bits in size. + /// + UINT32 PSE_36:1; + /// + /// [Bit 18] Processor Serial Number. The processor supports the 96-bit + /// processor identification number feature and the feature is enabled. + /// + UINT32 PSN:1; + /// + /// [Bit 19] CLFLUSH Instruction. CLFLUSH Instruction is supported. + /// + UINT32 CLFSH:1; + UINT32 Reserved2:1; + /// + /// [Bit 21] Debug Store. The processor supports the ability to write debug + /// information into a memory resident buffer. This feature is used by the + /// branch trace store (BTS) and precise event-based sampling (PEBS) + /// facilities. + /// + UINT32 DS:1; + /// + /// [Bit 22] Thermal Monitor and Software Controlled Clock Facilities. The + /// processor implements internal MSRs that allow processor temperature to + /// be monitored and processor performance to be modulated in predefined + /// duty cycles under software control. + /// + UINT32 ACPI:1; + /// + /// [Bit 23] Intel MMX Technology. The processor supports the Intel MMX + /// technology. + /// + UINT32 MMX:1; + /// + /// [Bit 24] FXSAVE and FXRSTOR Instructions. The FXSAVE and FXRSTOR + /// instructions are supported for fast save and restore of the floating + /// point context. Presence of this bit also indicates that CR4.OSFXSR is + /// available for an operating system to indicate that it supports the + /// FXSAVE and FXRSTOR instructions. + /// + UINT32 FXSR:1; + /// + /// [Bit 25] SSE. The processor supports the SSE extensions. + /// + UINT32 SSE:1; + /// + /// [Bit 26] SSE2. The processor supports the SSE2 extensions. + /// + UINT32 SSE2:1; + /// + /// [Bit 27] Self Snoop. The processor supports the management of + /// conflicting memory types by performing a snoop of its own cache + /// structure for transactions issued to the bus. + /// + UINT32 SS:1; + /// + /// [Bit 28] Max APIC IDs reserved field is Valid. A value of 0 for HTT + /// indicates there is only a single logical processor in the package and + /// software should assume only a single APIC ID is reserved. A value of 1 + /// for HTT indicates the value in CPUID.1.EBX[23:16] (the Maximum number of + /// addressable IDs for logical processors in this package) is valid for the + /// package. + /// + UINT32 HTT:1; + /// + /// [Bit 29] Thermal Monitor. The processor implements the thermal monitor + /// automatic thermal control circuitry (TCC). + /// + UINT32 TM:1; + UINT32 Reserved3:1; + /// + /// [Bit 31] Pending Break Enable. The processor supports the use of the + /// FERR#/PBE# pin when the processor is in the stop-clock state (STPCLK# is + /// asserted) to signal the processor that an interrupt is pending and that + /// the processor should return to normal operation to handle the interrupt. + /// Bit 10 (PBE enable) in the IA32_MISC_ENABLE MSR enables this capability. + /// + UINT32 PBE:1; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_VERSION_INFO_EDX; + + +/** + CPUID Cache and TLB Information + + @param EAX CPUID_CACHE_INFO (0x02) + + @retval EAX Cache and TLB Information described by the type + CPUID_CACHE_INFO_CACHE_TLB. + CPUID_CACHE_INFO_CACHE_TLB.CacheDescriptor[0] always returns + 0x01 and must be ignored. Only valid if + CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. + @retval EBX Cache and TLB Information described by the type + CPUID_CACHE_INFO_CACHE_TLB. Only valid if + CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. + @retval ECX Cache and TLB Information described by the type + CPUID_CACHE_INFO_CACHE_TLB. Only valid if + CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. + @retval EDX Cache and TLB Information described by the type + CPUID_CACHE_INFO_CACHE_TLB. Only valid if + CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. + + Example usage + @code + CPUID_CACHE_INFO_CACHE_TLB Eax; + CPUID_CACHE_INFO_CACHE_TLB Ebx; + CPUID_CACHE_INFO_CACHE_TLB Ecx; + CPUID_CACHE_INFO_CACHE_TLB Edx; + + AsmCpuid (CPUID_CACHE_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode + + Cache Descriptor values + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Value Type Description
0x00 General Null descriptor, this byte contains no information
0x01 TLB Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries
0x02 TLB Instruction TLB: 4 MByte pages, fully associative, 2 entries
0x03 TLB Data TLB: 4 KByte pages, 4-way set associative, 64 entries
0x04 TLB Data TLB: 4 MByte pages, 4-way set associative, 8 entries
0x05 TLB Data TLB1: 4 MByte pages, 4-way set associative, 32 entries
0x06 Cache 1st-level instruction cache: 8 KBytes, 4-way set associative, + 32 byte line size
0x08 Cache 1st-level instruction cache: 16 KBytes, 4-way set associative, + 32 byte line size
0x09 Cache 1st-level instruction cache: 32KBytes, 4-way set associative, + 64 byte line size
0x0A Cache 1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size
0x0B TLB Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries
0x0C Cache 1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size
0x0D Cache 1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size
0x0E Cache 1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size
0x1D Cache 2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size
0x21 Cache 2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size
0x22 Cache 3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, + 2 lines per sector
0x23 Cache 3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, + 2 lines per sector
0x24 Cache 2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size
0x25 Cache 3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, + 2 lines per sector
0x29 Cache 3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, + 2 lines per sector
0x2C Cache 1st-level data cache: 32 KBytes, 8-way set associative, + 64 byte line size
0x30 Cache 1st-level instruction cache: 32 KBytes, 8-way set associative, + 64 byte line size
0x40 Cache No 2nd-level cache or, if processor contains a valid 2nd-level cache, + no 3rd-level cache
0x41 Cache 2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size
0x42 Cache 2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size
0x43 Cache 2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size
0x44 Cache 2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size
0x45 Cache 2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size
0x46 Cache 3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size
0x47 Cache 3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size
0x48 Cache 2nd-level cache: 3MByte, 12-way set associative, 64 byte line size
0x49 Cache 3rd-level cache: 4MB, 16-way set associative, 64-byte line size + (Intel Xeon processor MP, Family 0FH, Model 06H)
+ 2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size
0x4A Cache 3rd-level cache: 6MByte, 12-way set associative, 64 byte line size
0x4B Cache 3rd-level cache: 8MByte, 16-way set associative, 64 byte line size
0x4C Cache 3rd-level cache: 12MByte, 12-way set associative, 64 byte line size
0x4D Cache 3rd-level cache: 16MByte, 16-way set associative, 64 byte line size
0x4E Cache 2nd-level cache: 6MByte, 24-way set associative, 64 byte line size
0x4F TLB Instruction TLB: 4 KByte pages, 32 entries
0x50 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries
0x51 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries
0x52 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries
0x55 TLB Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries
0x56 TLB Data TLB0: 4 MByte pages, 4-way set associative, 16 entries
0x57 TLB Data TLB0: 4 KByte pages, 4-way associative, 16 entries
0x59 TLB Data TLB0: 4 KByte pages, fully associative, 16 entries
0x5A TLB Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries
0x5B TLB Data TLB: 4 KByte and 4 MByte pages, 64 entries
0x5C TLB Data TLB: 4 KByte and 4 MByte pages,128 entries
0x5D TLB Data TLB: 4 KByte and 4 MByte pages,256 entries
0x60 Cache 1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size
0x61 TLB Instruction TLB: 4 KByte pages, fully associative, 48 entries
0x63 TLB Data TLB: 2 MByte or 4 MByte pages, 4-way set associative, + 32 entries and a separate array with 1 GByte pages, 4-way set associative, + 4 entries
0x64 TLB Data TLB: 4 KByte pages, 4-way set associative, 512 entries
0x66 Cache 1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size
0x67 Cache 1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size
0x68 Cache 1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size
0x6A Cache uTLB: 4 KByte pages, 8-way set associative, 64 entries
0x6B Cache DTLB: 4 KByte pages, 8-way set associative, 256 entries
0x6C Cache DTLB: 2M/4M pages, 8-way set associative, 128 entries
0x6D Cache DTLB: 1 GByte pages, fully associative, 16 entries
0x70 Cache Trace cache: 12 K-uop, 8-way set associative
0x71 Cache Trace cache: 16 K-uop, 8-way set associative
0x72 Cache Trace cache: 32 K-uop, 8-way set associative
0x76 TLB Instruction TLB: 2M/4M pages, fully associative, 8 entries
0x78 Cache 2nd-level cache: 1 MByte, 4-way set associative, 64byte line size
0x79 Cache 2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, + 2 lines per sector
0x7A Cache 2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, + 2 lines per sector
0x7B Cache 2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, + 2 lines per sector
0x7C Cache 2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, + 2 lines per sector
0x7D Cache 2nd-level cache: 2 MByte, 8-way set associative, 64byte line size
0x7F Cache 2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size
0x80 Cache 2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size
0x82 Cache 2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size
0x83 Cache 2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size
0x84 Cache 2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size
0x85 Cache 2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size
0x86 Cache 2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size
0x87 Cache 2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size
0xA0 DTLB DTLB: 4k pages, fully associative, 32 entries
0xB0 TLB Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries
0xB1 TLB Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries
0xB2 TLB Instruction TLB: 4KByte pages, 4-way set associative, 64 entries
0xB3 TLB Data TLB: 4 KByte pages, 4-way set associative, 128 entries
0xB4 TLB Data TLB1: 4 KByte pages, 4-way associative, 256 entries
0xB5 TLB Instruction TLB: 4KByte pages, 8-way set associative, 64 entries
0xB6 TLB Instruction TLB: 4KByte pages, 8-way set associative, + 128 entries
0xBA TLB Data TLB1: 4 KByte pages, 4-way associative, 64 entries
0xC0 TLB Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries
0xC1 STLB Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, + 1024 entries
0xC2 DTLB DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries
0xC3 STLB Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, + 1536 entries. Also 1GBbyte pages, 4-way, 16 entries.
0xC4 DTLB DTLB: 2M/4M Byte pages, 4-way associative, 32 entries
0xCA STLB Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries
0xD0 Cache 3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size
0xD1 Cache 3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size
0xD2 Cache 3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size
0xD6 Cache 3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size
0xD7 Cache 3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size
0xD8 Cache 3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size
0xDC Cache 3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size
0xDD Cache 3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size
0xDE Cache 3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size
0xE2 Cache 3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size
0xE3 Cache 3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size
0xE4 Cache 3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size
0xEA Cache 3rd-level cache: 12MByte, 24-way set associative, 64 byte line size
0xEB Cache 3rd-level cache: 18MByte, 24-way set associative, 64 byte line size
0xEC Cache 3rd-level cache: 24MByte, 24-way set associative, 64 byte line size
0xF0 Prefetch 64-Byte prefetching
0xF1 Prefetch 128-Byte prefetching
0xFF General CPUID leaf 2 does not report cache descriptor information, + use CPUID leaf 4 to query cache parameters
+**/ +#define CPUID_CACHE_INFO 0x02 + +/** + CPUID Cache and TLB Information returned in EAX, EBX, ECX, and EDX for CPUID + leaf #CPUID_CACHE_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:31; + /// + /// [Bit 31] If 0, then the cache descriptor bytes in the register are valid. + /// if 1, then none of the cache descriptor bytes in the register are valid. + /// + UINT32 NotValid:1; + } Bits; + /// + /// Array of Cache and TLB descriptor bytes + /// + UINT8 CacheDescriptor[4]; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_CACHE_INFO_CACHE_TLB; + + +/** + CPUID Processor Serial Number + + Processor serial number (PSN) is not supported in the Pentium 4 processor + or later. On all models, use the PSN flag (returned using CPUID) to check + for PSN support before accessing the feature. + + @param EAX CPUID_SERIAL_NUMBER (0x03) + + @retval EAX Reserved. + @retval EBX Reserved. + @retval ECX Bits 31:0 of 96 bit processor serial number. (Available in + Pentium III processor only; otherwise, the value in this + register is reserved.) + @retval EDX Bits 63:32 of 96 bit processor serial number. (Available in + Pentium III processor only; otherwise, the value in this + register is reserved.) + + Example usage + @code + UINT32 Ecx; + UINT32 Edx; + + AsmCpuid (CPUID_SERIAL_NUMBER, NULL, NULL, &Ecx, &Edx); + @endcode +**/ +#define CPUID_SERIAL_NUMBER 0x03 + + +/** + CPUID Cache Parameters + + @param EAX CPUID_CACHE_PARAMS (0x04) + @param ECX Cache Level. Valid values start at 0. Software can enumerate + the deterministic cache parameters for each level of the cache + hierarchy starting with an index value of 0, until the + parameters report the value associated with the CacheType + field in CPUID_CACHE_PARAMS_EAX is 0. + + @retval EAX Returns cache type information described by the type + CPUID_CACHE_PARAMS_EAX. + @retval EBX Returns cache line and associativity information described by + the type CPUID_CACHE_PARAMS_EBX. + @retval ECX Returns the number of sets in the cache. + @retval EDX Returns cache WINVD/INVD behavior described by the type + CPUID_CACHE_PARAMS_EDX. + + Example usage + @code + UINT32 CacheLevel; + CPUID_CACHE_PARAMS_EAX Eax; + CPUID_CACHE_PARAMS_EBX Ebx; + UINT32 Ecx; + CPUID_CACHE_PARAMS_EDX Edx; + + CacheLevel = 0; + do { + AsmCpuidEx ( + CPUID_CACHE_PARAMS, CacheLevel, + &Eax.Uint32, &Ebx.Uint32, &Ecx, &Edx.Uint32 + ); + CacheLevel++; + } while (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL); + @endcode +**/ +#define CPUID_CACHE_PARAMS 0x04 + +/** + CPUID Cache Parameters Information returned in EAX for CPUID leaf + #CPUID_CACHE_PARAMS. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Cache type field. If #CPUID_CACHE_PARAMS_CACHE_TYPE_NULL, + /// then there is no information for the requested cache level. + /// + UINT32 CacheType:5; + /// + /// [Bits 7:5] Cache level (Starts at 1). + /// + UINT32 CacheLevel:3; + /// + /// [Bit 8] Self Initializing cache level (does not need SW initialization). + /// + UINT32 SelfInitializingCache:1; + /// + /// [Bit 9] Fully Associative cache. + /// + UINT32 FullyAssociativeCache:1; + /// + /// [Bits 13:10] Reserved. + /// + UINT32 Reserved:4; + /// + /// [Bits 25:14] Maximum number of addressable IDs for logical processors + /// sharing this cache. + /// + /// Add one to the return value to get the result. + /// The nearest power-of-2 integer that is not smaller than (1 + EAX[25:14]) + /// is the number of unique initial APIC IDs reserved for addressing + /// different logical processors sharing this cache. + /// + UINT32 MaximumAddressableIdsForLogicalProcessors:12; + /// + /// [Bits 31:26] Maximum number of addressable IDs for processor cores in + /// the physical package. + /// + /// The nearest power-of-2 integer that is not smaller than (1 + EAX[31:26]) + /// is the number of unique Core_IDs reserved for addressing different + /// processor cores in a physical package. Core ID is a subset of bits of + /// the initial APIC ID. + /// The returned value is constant for valid initial values in ECX. Valid + /// ECX values start from 0. + /// + UINT32 MaximumAddressableIdsForProcessorCores:6; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_CACHE_PARAMS_EAX; + +/// +/// @{ Define value for bit field CPUID_CACHE_PARAMS_EAX.CacheType +/// +#define CPUID_CACHE_PARAMS_CACHE_TYPE_NULL 0x00 +#define CPUID_CACHE_PARAMS_CACHE_TYPE_DATA 0x01 +#define CPUID_CACHE_PARAMS_CACHE_TYPE_INSTRUCTION 0x02 +#define CPUID_CACHE_PARAMS_CACHE_TYPE_UNIFIED 0x03 +/// +/// @} +/// + +/** + CPUID Cache Parameters Information returned in EBX for CPUID leaf + #CPUID_CACHE_PARAMS. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 11:0] System Coherency Line Size. Add one to the return value to + /// get the result. + /// + UINT32 LineSize:12; + /// + /// [Bits 21:12] Physical Line Partitions. Add one to the return value to + /// get the result. + /// + UINT32 LinePartitions:10; + /// + /// [Bits 31:22] Ways of associativity. Add one to the return value to get + /// the result. + /// + UINT32 Ways:10; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_CACHE_PARAMS_EBX; + +/** + CPUID Cache Parameters Information returned in EDX for CPUID leaf + #CPUID_CACHE_PARAMS. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Write-Back Invalidate/Invalidate. + /// 0 = WBINVD/INVD from threads sharing this cache acts upon lower level + /// caches for threads sharing this cache. + /// 1 = WBINVD/INVD is not guaranteed to act upon lower level caches of + /// non-originating threads sharing this cache. + /// + UINT32 Invalidate:1; + /// + /// [Bit 1] Cache Inclusiveness. + /// 0 = Cache is not inclusive of lower cache levels. + /// 1 = Cache is inclusive of lower cache levels. + /// + UINT32 CacheInclusiveness:1; + /// + /// [Bit 2] Complex Cache Indexing. + /// 0 = Direct mapped cache. + /// 1 = A complex function is used to index the cache, potentially using all + /// address bits. + /// + UINT32 ComplexCacheIndexing:1; + UINT32 Reserved:29; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_CACHE_PARAMS_EDX; + + +/** + CPUID MONITOR/MWAIT Information + + @param EAX CPUID_MONITOR_MWAIT (0x05) + + @retval EAX Smallest monitor-line size in bytes described by the type + CPUID_MONITOR_MWAIT_EAX. + @retval EBX Largest monitor-line size in bytes described by the type + CPUID_MONITOR_MWAIT_EBX. + @retval ECX Enumeration of Monitor-Mwait extensions support described by + the type CPUID_MONITOR_MWAIT_ECX. + @retval EDX Sub C-states supported described by the type + CPUID_MONITOR_MWAIT_EDX. + + Example usage + @code + CPUID_MONITOR_MWAIT_EAX Eax; + CPUID_MONITOR_MWAIT_EBX Ebx; + CPUID_MONITOR_MWAIT_ECX Ecx; + CPUID_MONITOR_MWAIT_EDX Edx; + + AsmCpuid (CPUID_MONITOR_MWAIT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_MONITOR_MWAIT 0x05 + +/** + CPUID MONITOR/MWAIT Information returned in EAX for CPUID leaf + #CPUID_MONITOR_MWAIT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Smallest monitor-line size in bytes (default is processor's + /// monitor granularity). + /// + UINT32 SmallestMonitorLineSize:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MONITOR_MWAIT_EAX; + +/** + CPUID MONITOR/MWAIT Information returned in EBX for CPUID leaf + #CPUID_MONITOR_MWAIT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Largest monitor-line size in bytes (default is processor's + /// monitor granularity). + /// + UINT32 LargestMonitorLineSize:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MONITOR_MWAIT_EBX; + +/** + CPUID MONITOR/MWAIT Information returned in ECX for CPUID leaf + #CPUID_MONITOR_MWAIT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] If 0, then only EAX and EBX are valid. If 1, then EAX, EBX, ECX, + /// and EDX are valid. + /// + UINT32 ExtensionsSupported:1; + /// + /// [Bit 1] Supports treating interrupts as break-event for MWAIT, even when + /// interrupts disabled. + /// + UINT32 InterruptAsBreak:1; + UINT32 Reserved:30; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MONITOR_MWAIT_ECX; + +/** + CPUID MONITOR/MWAIT Information returned in EDX for CPUID leaf + #CPUID_MONITOR_MWAIT. + + @note + The definition of C0 through C7 states for MWAIT extension are + processor-specific C-states, not ACPI C-states. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Number of C0 sub C-states supported using MWAIT. + /// + UINT32 C0States:4; + /// + /// [Bits 7:4] Number of C1 sub C-states supported using MWAIT. + /// + UINT32 C1States:4; + /// + /// [Bits 11:8] Number of C2 sub C-states supported using MWAIT. + /// + UINT32 C2States:4; + /// + /// [Bits 15:12] Number of C3 sub C-states supported using MWAIT. + /// + UINT32 C3States:4; + /// + /// [Bits 19:16] Number of C4 sub C-states supported using MWAIT. + /// + UINT32 C4States:4; + /// + /// [Bits 23:20] Number of C5 sub C-states supported using MWAIT. + /// + UINT32 C5States:4; + /// + /// [Bits 27:24] Number of C6 sub C-states supported using MWAIT. + /// + UINT32 C6States:4; + /// + /// [Bits 31:28] Number of C7 sub C-states supported using MWAIT. + /// + UINT32 C7States:4; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MONITOR_MWAIT_EDX; + + +/** + CPUID Thermal and Power Management + + @param EAX CPUID_THERMAL_POWER_MANAGEMENT (0x06) + + @retval EAX Thermal and power management features described by the type + CPUID_THERMAL_POWER_MANAGEMENT_EAX. + @retval EBX Number of Interrupt Thresholds in Digital Thermal Sensor + described by the type CPUID_THERMAL_POWER_MANAGEMENT_EBX. + @retval ECX Performance features described by the type + CPUID_THERMAL_POWER_MANAGEMENT_ECX. + @retval EDX Reserved. + + Example usage + @code + CPUID_THERMAL_POWER_MANAGEMENT_EAX Eax; + CPUID_THERMAL_POWER_MANAGEMENT_EBX Ebx; + CPUID_THERMAL_POWER_MANAGEMENT_ECX Ecx; + + AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); + @endcode +**/ +#define CPUID_THERMAL_POWER_MANAGEMENT 0x06 + +/** + CPUID Thermal and Power Management Information returned in EAX for CPUID leaf + #CPUID_THERMAL_POWER_MANAGEMENT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Digital temperature sensor is supported if set. + /// + UINT32 DigitalTemperatureSensor:1; + /// + /// [Bit 1] Intel Turbo Boost Technology Available (see IA32_MISC_ENABLE[38]). + /// + UINT32 TurboBoostTechnology:1; + /// + /// [Bit 2] APIC-Timer-always-running feature is supported if set. + /// + UINT32 ARAT:1; + UINT32 Reserved1:1; + /// + /// [Bit 4] Power limit notification controls are supported if set. + /// + UINT32 PLN:1; + /// + /// [Bit 5] Clock modulation duty cycle extension is supported if set. + /// + UINT32 ECMD:1; + /// + /// [Bit 6] Package thermal management is supported if set. + /// + UINT32 PTM:1; + /// + /// [Bit 7] HWP base registers (IA32_PM_ENABLE[Bit 0], IA32_HWP_CAPABILITIES, + /// IA32_HWP_REQUEST, IA32_HWP_STATUS) are supported if set. + /// + UINT32 HWP:1; + /// + /// [Bit 8] IA32_HWP_INTERRUPT MSR is supported if set. + /// + UINT32 HWP_Notification:1; + /// + /// [Bit 9] IA32_HWP_REQUEST[Bits 41:32] is supported if set. + /// + UINT32 HWP_Activity_Window:1; + /// + /// [Bit 10] IA32_HWP_REQUEST[Bits 31:24] is supported if set. + /// + UINT32 HWP_Energy_Performance_Preference:1; + /// + /// [Bit 11] IA32_HWP_REQUEST_PKG MSR is supported if set. + /// + UINT32 HWP_Package_Level_Request:1; + UINT32 Reserved2:1; + /// + /// [Bit 13] HDC base registers IA32_PKG_HDC_CTL, IA32_PM_CTL1, + /// IA32_THREAD_STALL MSRs are supported if set. + /// + UINT32 HDC:1; + UINT32 Reserved3:18; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_THERMAL_POWER_MANAGEMENT_EAX; + +/** + CPUID Thermal and Power Management Information returned in EBX for CPUID leaf + #CPUID_THERMAL_POWER_MANAGEMENT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// {Bits 3:0] Number of Interrupt Thresholds in Digital Thermal Sensor. + /// + UINT32 InterruptThresholds:4; + UINT32 Reserved:28; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_THERMAL_POWER_MANAGEMENT_EBX; + +/** + CPUID Thermal and Power Management Information returned in ECX for CPUID leaf + #CPUID_THERMAL_POWER_MANAGEMENT. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Hardware Coordination Feedback Capability (Presence of IA32_MPERF + /// and IA32_APERF). The capability to provide a measure of delivered + /// processor performance (since last reset of the counters), as a percentage + /// of the expected processor performance when running at the TSC frequency. + /// + UINT32 HardwareCoordinationFeedback:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] If this bit is set, then the processor supports performance-energy + /// bias preference and the architectural MSR called IA32_ENERGY_PERF_BIAS + /// (1B0H). + /// + UINT32 PerformanceEnergyBias:1; + UINT32 Reserved2:28; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_THERMAL_POWER_MANAGEMENT_ECX; + + +/** + CPUID Structured Extended Feature Flags Enumeration + + @param EAX CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS (0x07) + @param ECX CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO (0x00). + + @note + If ECX contains an invalid sub-leaf index, EAX/EBX/ECX/EDX return 0. Sub-leaf + index n is invalid if n exceeds the value that sub-leaf 0 returns in EAX. + + @retval EAX The maximum input value for ECX to retrieve sub-leaf information. + @retval EBX Structured Extended Feature Flags described by the type + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX. + @retval EBX Structured Extended Feature Flags described by the type + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX. + @retval EDX Reserved. + + Example usage + @code + UINT32 Eax; + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX Ecx; + UINT32 SubLeaf; + + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, + &Eax, NULL, NULL, NULL + ); + for (SubLeaf = 0; SubLeaf <= Eax; SubLeaf++) { + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + SubLeaf, + NULL, &Ebx.Uint32, &Ecx.Uint32, NULL + ); + } + @endcode +**/ +#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS 0x07 + +/// +/// CPUID Structured Extended Feature Flags Enumeration sub-leaf +/// +#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO 0x00 + +/** + CPUID Structured Extended Feature Flags Enumeration in EBX for CPUID leaf + #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS sub leaf + #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Supports RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE if 1. + /// + UINT32 FSGSBASE:1; + /// + /// [Bit 1] IA32_TSC_ADJUST MSR is supported if 1. + /// + UINT32 IA32_TSC_ADJUST:1; + /// + /// [Bit 2] Intel SGX is supported if 1. See section 37.7 "DISCOVERING SUPPORT + /// FOR INTEL(R) SGX AND ENABLING ENCLAVE INSTRUCTIONS". + /// + UINT32 SGX:1; + /// + /// [Bit 3] If 1 indicates the processor supports the first group of advanced + /// bit manipulation extensions (ANDN, BEXTR, BLSI, BLSMSK, BLSR, TZCNT) + /// + UINT32 BMI1:1; + /// + /// [Bit 4] Hardware Lock Elision + /// + UINT32 HLE:1; + /// + /// [Bit 5] If 1 indicates the processor supports AVX2 instruction extensions. + /// + UINT32 AVX2:1; + /// + /// [Bit 6] x87 FPU Data Pointer updated only on x87 exceptions if 1. + /// + UINT32 FDP_EXCPTN_ONLY:1; + /// + /// [Bit 7] Supports Supervisor-Mode Execution Prevention if 1. + /// + UINT32 SMEP:1; + /// + /// [Bit 8] If 1 indicates the processor supports the second group of + /// advanced bit manipulation extensions (BZHI, MULX, PDEP, PEXT, RORX, + /// SARX, SHLX, SHRX) + /// + UINT32 BMI2:1; + /// + /// [Bit 9] Supports Enhanced REP MOVSB/STOSB if 1. + /// + UINT32 EnhancedRepMovsbStosb:1; + /// + /// [Bit 10] If 1, supports INVPCID instruction for system software that + /// manages process-context identifiers. + /// + UINT32 INVPCID:1; + /// + /// [Bit 11] Restricted Transactional Memory + /// + UINT32 RTM:1; + /// + /// [Bit 12] Supports Intel(R) Resource Director Technology (Intel(R) RDT) + /// Monitoring capability if 1. + /// + UINT32 RDT_M:1; + /// + /// [Bit 13] Deprecates FPU CS and FPU DS values if 1. + /// + UINT32 DeprecateFpuCsDs:1; + /// + /// [Bit 14] Supports Intel(R) Memory Protection Extensions if 1. + /// + UINT32 MPX:1; + /// + /// [Bit 15] Supports Intel(R) Resource Director Technology (Intel(R) RDT) + /// Allocation capability if 1. + /// + UINT32 RDT_A:1; + UINT32 Reserved2:2; + /// + /// [Bit 18] If 1 indicates the processor supports the RDSEED instruction. + /// + UINT32 RDSEED:1; + /// + /// [Bit 19] If 1 indicates the processor supports the ADCX and ADOX + /// instructions. + /// + UINT32 ADX:1; + /// + /// [Bit 20] Supports Supervisor-Mode Access Prevention (and the CLAC/STAC + /// instructions) if 1. + /// + UINT32 SMAP:1; + UINT32 Reserved3:2; + /// + /// [Bit 23] If 1 indicates the processor supports the CLFLUSHOPT instruction. + /// + UINT32 CLFLUSHOPT:1; + /// + /// [Bit 24] If 1 indicates the processor supports the CLWB instruction. + /// + UINT32 CLWB:1; + /// + /// [Bit 25] If 1 indicates the processor supports the Intel Processor Trace + /// extensions. + /// + UINT32 IntelProcessorTrace:1; + UINT32 Reserved4:3; + /// + /// [Bit 29] Supports Intel(R) Secure Hash Algorithm Extensions (Intel(R) + /// SHA Extensions) if 1. + /// + UINT32 SHA:1; + UINT32 Reserved5:2; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX; + +/** + CPUID Structured Extended Feature Flags Enumeration in ECX for CPUID leaf + #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS sub leaf + #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] If 1 indicates the processor supports the PREFETCHWT1 instruction. + /// + UINT32 PREFETCHWT1:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Supports user-mode instruction prevention if 1. + /// + UINT32 UMIP:1; + /// + /// [Bit 3] Supports protection keys for user-mode pages if 1. + /// + UINT32 PKU:1; + /// + /// [Bit 4] If 1, OS has set CR4.PKE to enable protection keys (and the + /// RDPKRU/WRPKRU instructions). + /// + UINT32 OSPKE:1; + UINT32 Reserved2:12; + /// + /// [Bits 21:17] The value of MAWAU used by the BNDLDX and BNDSTX instructions + /// in 64-bit mode. + /// + UINT32 MAWAU:5; + /// + /// [Bit 22] Supports Read Processor ID if 1. + /// + UINT32 RDPID:1; + UINT32 Reserved3:7; + /// + /// [Bit 30] Supports SGX Launch Configuration if 1. + /// + UINT32 SGX_LC:1; + UINT32 Reserved4:1; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX; + + +/** + CPUID Direct Cache Access Information + + @param EAX CPUID_DIRECT_CACHE_ACCESS_INFO (0x09) + + @retval EAX Value of bits [31:0] of IA32_PLATFORM_DCA_CAP MSR (address 1F8H). + @retval EBX Reserved. + @retval ECX Reserved. + @retval EDX Reserved. + + Example usage + @code + UINT32 Eax; + + AsmCpuid (CPUID_DIRECT_CACHE_ACCESS_INFO, &Eax, NULL, NULL, NULL); + @endcode +**/ +#define CPUID_DIRECT_CACHE_ACCESS_INFO 0x09 + + +/** + CPUID Architectural Performance Monitoring + + @param EAX CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING (0x0A) + + @retval EAX Architectural Performance Monitoring information described by + the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX. + @retval EBX Architectural Performance Monitoring information described by + the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX. + @retval ECX Reserved. + @retval EDX Architectural Performance Monitoring information described by + the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX. + + Example usage + @code + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX Eax; + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX Ebx; + CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX Edx; + + AsmCpuid (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING, &Eax.Uint32, &Ebx.Uint32, NULL, &Edx.Uint32); + @endcode +**/ +#define CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING 0x0A + +/** + CPUID Architectural Performance Monitoring EAX for CPUID leaf + #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 7:0] Version ID of architectural performance monitoring. + /// + UINT32 ArchPerfMonVerID:8; + /// + /// [Bits 15:8] Number of general-purpose performance monitoring counter + /// per logical processor. + /// + /// IA32_PERFEVTSELx MSRs start at address 186H and occupy a contiguous + /// block of MSR address space. Each performance event select register is + /// paired with a corresponding performance counter in the 0C1H address + /// block. + /// + UINT32 PerformanceMonitorCounters:8; + /// + /// [Bits 23:16] Bit width of general-purpose, performance monitoring counter. + /// + /// The bit width of an IA32_PMCx MSR. This the number of valid bits for + /// read operation. On write operations, the lower-order 32 bits of the MSR + /// may be written with any value, and the high-order bits are sign-extended + /// from the value of bit 31. + /// + UINT32 PerformanceMonitorCounterWidth:8; + /// + /// [Bits 31:24] Length of EBX bit vector to enumerate architectural + /// performance monitoring events. + /// + UINT32 EbxBitVectorLength:8; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX; + +/** + CPUID Architectural Performance Monitoring EBX for CPUID leaf + #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core cycle event not available if 1. + /// + UINT32 UnhaltedCoreCycles:1; + /// + /// [Bit 1] Instruction retired event not available if 1. + /// + UINT32 InstructionsRetired:1; + /// + /// [Bit 2] Reference cycles event not available if 1. + /// + UINT32 UnhaltedReferenceCycles:1; + /// + /// [Bit 3] Last-level cache reference event not available if 1. + /// + UINT32 LastLevelCacheReferences:1; + /// + /// [Bit 4] Last-level cache misses event not available if 1. + /// + UINT32 LastLevelCacheMisses:1; + /// + /// [Bit 5] Branch instruction retired event not available if 1. + /// + UINT32 BranchInstructionsRetired:1; + /// + /// [Bit 6] Branch mispredict retired event not available if 1. + /// + UINT32 AllBranchMispredictRetired:1; + UINT32 Reserved:25; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX; + +/** + CPUID Architectural Performance Monitoring EDX for CPUID leaf + #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Number of fixed-function performance counters + /// (if Version ID > 1). + /// + UINT32 FixedFunctionPerformanceCounters:5; + /// + /// [Bits 12:5] Bit width of fixed-function performance counters + /// (if Version ID > 1). + /// + UINT32 FixedFunctionPerformanceCounterWidth:8; + UINT32 Reserved:19; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX; + + +/** + CPUID Extended Topology Information + + @note + Most of Leaf 0BH output depends on the initial value in ECX. The EDX output + of leaf 0BH is always valid and does not vary with input value in ECX. Output + value in ECX[7:0] always equals input value in ECX[7:0]. For sub-leaves that + return an invalid level-type of 0 in ECX[15:8]; EAX and EBX will return 0. If + an input value n in ECX returns the invalid level-type of 0 in ECX[15:8], + other input values with ECX > n also return 0 in ECX[15:8]. + + @param EAX CPUID_EXTENDED_TOPOLOGY (0x0B) + @param ECX Level number + + @retval EAX Extended topology information described by the type + CPUID_EXTENDED_TOPOLOGY_EAX. + @retval EBX Extended topology information described by the type + CPUID_EXTENDED_TOPOLOGY_EBX. + @retval ECX Extended topology information described by the type + CPUID_EXTENDED_TOPOLOGY_ECX. + @retval EDX x2APIC ID the current logical processor. + + Example usage + @code + CPUID_EXTENDED_TOPOLOGY_EAX Eax; + CPUID_EXTENDED_TOPOLOGY_EBX Ebx; + CPUID_EXTENDED_TOPOLOGY_ECX Ecx; + UINT32 Edx; + UINT32 LevelNumber; + + LevelNumber = 0; + do { + AsmCpuidEx ( + CPUID_EXTENDED_TOPOLOGY, LevelNumber, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx + ); + LevelNumber++; + } while (Eax.Bits.ApicIdShift != 0); + @endcode +**/ +#define CPUID_EXTENDED_TOPOLOGY 0x0B + +/** + CPUID Extended Topology Information EAX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Number of bits to shift right on x2APIC ID to get a unique + /// topology ID of the next level type. All logical processors with the + /// same next level ID share current level. + /// + /// @note + /// Software should use this field (EAX[4:0]) to enumerate processor + /// topology of the system. + /// + UINT32 ApicIdShift:5; + UINT32 Reserved:27; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_TOPOLOGY_EAX; + +/** + CPUID Extended Topology Information EBX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Number of logical processors at this level type. The number + /// reflects configuration as shipped by Intel. + /// + /// @note + /// Software must not use EBX[15:0] to enumerate processor topology of the + /// system. This value in this field (EBX[15:0]) is only intended for + /// display/diagnostic purposes. The actual number of logical processors + /// available to BIOS/OS/Applications may be different from the value of + /// EBX[15:0], depending on software and platform hardware configurations. + /// + UINT32 LogicalProcessors:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_TOPOLOGY_EBX; + +/** + CPUID Extended Topology Information ECX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Level number. Same value in ECX input. + /// + UINT32 LevelNumber:8; + /// + /// [Bits 15:8] Level type. + /// + /// @note + /// The value of the "level type" field is not related to level numbers in + /// any way, higher "level type" values do not mean higher levels. + /// + UINT32 LevelType:8; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_TOPOLOGY_ECX; + +/// +/// @{ Define value for CPUID_EXTENDED_TOPOLOGY_ECX.LevelType +/// +#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID 0x00 +#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT 0x01 +#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE 0x02 +/// +/// @} +/// + + +/** + CPUID Extended State Information + + @param EAX CPUID_EXTENDED_STATE (0x0D) + @param ECX CPUID_EXTENDED_STATE_MAIN_LEAF (0x00). + CPUID_EXTENDED_STATE_SUB_LEAF (0x01). + CPUID_EXTENDED_STATE_SIZE_OFFSET (0x02). + Sub leafs 2..n based on supported bits in XCR0 or IA32_XSS_MSR. +**/ +#define CPUID_EXTENDED_STATE 0x0D + +/** + CPUID Extended State Information Main Leaf + + @param EAX CPUID_EXTENDED_STATE (0x0D) + @param ECX CPUID_EXTENDED_STATE_MAIN_LEAF (0x00) + + @retval EAX Reports the supported bits of the lower 32 bits of XCR0. XCR0[n] + can be set to 1 only if EAX[n] is 1. The format of the extended + state main leaf is described by the type + CPUID_EXTENDED_STATE_MAIN_LEAF_EAX. + @retval EBX Maximum size (bytes, from the beginning of the XSAVE/XRSTOR save + area) required by enabled features in XCR0. May be different than + ECX if some features at the end of the XSAVE save area are not + enabled. + @retval ECX Maximum size (bytes, from the beginning of the XSAVE/XRSTOR save + area) of the XSAVE/XRSTOR save area required by all supported + features in the processor, i.e., all the valid bit fields in XCR0. + @retval EDX Reports the supported bits of the upper 32 bits of XCR0. + XCR0[n+32] can be set to 1 only if EDX[n] is 1. + + Example usage + @code + CPUID_EXTENDED_STATE_MAIN_LEAF_EAX Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF, + &Eax.Uint32, &Ebx, &Ecx, &Edx + ); + @endcode +**/ +#define CPUID_EXTENDED_STATE_MAIN_LEAF 0x00 + +/** + CPUID Extended State Information EAX for CPUID leaf #CPUID_EXTENDED_STATE, + sub-leaf #CPUID_EXTENDED_STATE_MAIN_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] x87 state. + /// + UINT32 x87:1; + /// + /// [Bit 1] SSE state. + /// + UINT32 SSE:1; + /// + /// [Bit 2] AVX state. + /// + UINT32 AVX:1; + /// + /// [Bits 4:3] MPX state. + /// + UINT32 MPX:2; + /// + /// [Bits 7:5] AVX-512 state. + /// + UINT32 AVX_512:3; + /// + /// [Bit 8] Used for IA32_XSS. + /// + UINT32 IA32_XSS:1; + /// + /// [Bit 9] PKRU state. + /// + UINT32 PKRU:1; + UINT32 Reserved:22; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_STATE_MAIN_LEAF_EAX; + +/** + CPUID Extended State Information Sub Leaf + + @param EAX CPUID_EXTENDED_STATE (0x0D) + @param ECX CPUID_EXTENDED_STATE_SUB_LEAF (0x01) + + @retval EAX The format of the extended state sub-leaf is described by the + type CPUID_EXTENDED_STATE_SUB_LEAF_EAX. + @retval EBX The size in bytes of the XSAVE area containing all states + enabled by XCRO | IA32_XSS. + @retval ECX The format of the extended state sub-leaf is described by the + type CPUID_EXTENDED_STATE_SUB_LEAF_ECX. + @retval EDX Reports the supported bits of the upper 32 bits of the + IA32_XSS MSR. IA32_XSS[n+32] can be set to 1 only if EDX[n] is 1. + + Example usage + @code + CPUID_EXTENDED_STATE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_EXTENDED_STATE_SUB_LEAF_ECX Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF, + &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx + ); + @endcode +**/ +#define CPUID_EXTENDED_STATE_SUB_LEAF 0x01 + +/** + CPUID Extended State Information EAX for CPUID leaf #CPUID_EXTENDED_STATE, + sub-leaf #CPUID_EXTENDED_STATE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] XSAVEOPT is available. + /// + UINT32 XSAVEOPT:1; + /// + /// [Bit 1] Supports XSAVEC and the compacted form of XRSTOR if set. + /// + UINT32 XSAVEC:1; + /// + /// [Bit 2] Supports XGETBV with ECX = 1 if set. + /// + UINT32 XGETBV:1; + /// + /// [Bit 3] Supports XSAVES/XRSTORS and IA32_XSS if set. + /// + UINT32 XSAVES:1; + UINT32 Reserved:28; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_STATE_SUB_LEAF_EAX; + +/** + CPUID Extended State Information ECX for CPUID leaf #CPUID_EXTENDED_STATE, + sub-leaf #CPUID_EXTENDED_STATE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Used for XCR0. + /// + UINT32 XCR0:1; + /// + /// [Bit 8] PT STate. + /// + UINT32 PT:1; + /// + /// [Bit 9] Used for XCR0. + /// + UINT32 XCR0_1:1; + UINT32 Reserved:22; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_STATE_SUB_LEAF_ECX; + +/** + CPUID Extended State Information Size and Offset Sub Leaf + + @note + Leaf 0DH output depends on the initial value in ECX. + Each sub-leaf index (starting at position 2) is supported if it corresponds to + a supported bit in either the XCR0 register or the IA32_XSS MSR. + If ECX contains an invalid sub-leaf index, EAX/EBX/ECX/EDX return 0. Sub-leaf + n (0 <= n <= 31) is invalid if sub-leaf 0 returns 0 in EAX[n] and sub-leaf 1 + returns 0 in ECX[n]. Sub-leaf n (32 <= n <= 63) is invalid if sub-leaf 0 + returns 0 in EDX[n-32] and sub-leaf 1 returns 0 in EDX[n-32]. + + @param EAX CPUID_EXTENDED_STATE (0x0D) + @param ECX CPUID_EXTENDED_STATE_SIZE_OFFSET (0x02). Sub leafs 2..n based + on supported bits in XCR0 or IA32_XSS_MSR. + + @retval EAX The size in bytes (from the offset specified in EBX) of the save + area for an extended state feature associated with a valid + sub-leaf index, n. + @retval EBX The offset in bytes of this extended state component's save area + from the beginning of the XSAVE/XRSTOR area. This field reports + 0 if the sub-leaf index, n, does not map to a valid bit in the + XCR0 register. + @retval ECX The format of the extended state components's save area as + described by the type CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX. + This field reports 0 if the sub-leaf index, n, is invalid. + @retval EDX This field reports 0 if the sub-leaf index, n, is invalid; + otherwise it is reserved. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX Ecx; + UINT32 Edx; + UINTN SubLeaf; + + for (SubLeaf = CPUID_EXTENDED_STATE_SIZE_OFFSET; SubLeaf < 32; SubLeaf++) { + AsmCpuidEx ( + CPUID_EXTENDED_STATE, SubLeaf, + &Eax, &Ebx, &Ecx.Uint32, &Edx + ); + } + @endcode +**/ +#define CPUID_EXTENDED_STATE_SIZE_OFFSET 0x02 + +/** + CPUID Extended State Information ECX for CPUID leaf #CPUID_EXTENDED_STATE, + sub-leaf #CPUID_EXTENDED_STATE_SIZE_OFFSET. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Is set if the bit n (corresponding to the sub-leaf index) is + /// supported in the IA32_XSS MSR; it is clear if bit n is instead supported + /// in XCR0. + /// + UINT32 XSS:1; + /// + /// [Bit 1] is set if, when the compacted format of an XSAVE area is used, + /// this extended state component located on the next 64-byte boundary + /// following the preceding state component (otherwise, it is located + /// immediately following the preceding state component). + /// + UINT32 Compacted:1; + UINT32 Reserved:30; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX; + + +/** + CPUID Intel Resource Director Technology (Intel RDT) Monitoring Information + + @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) + @param ECX CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF (0x00). + CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF (0x01). + +**/ +#define CPUID_INTEL_RDT_MONITORING 0x0F + +/** + CPUID Intel Resource Director Technology (Intel RDT) Monitoring Information + Enumeration Sub-leaf + + @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) + @param ECX CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF (0x00) + + @retval EAX Reserved. + @retval EBX Maximum range (zero-based) of RMID within this physical + processor of all types. + @retval ECX Reserved. + @retval EDX L3 Cache Intel RDT Monitoring Information Enumeration described by + the type CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX. + + Example usage + @code + UINT32 Ebx; + CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF, + NULL, &Ebx, NULL, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF 0x00 + +/** + CPUID Intel RDT Monitoring Information EDX for CPUID leaf + #CPUID_INTEL_RDT_MONITORING, sub-leaf + #CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Supports L3 Cache Intel RDT Monitoring if 1. + /// + UINT32 L3CacheRDT_M:1; + UINT32 Reserved2:30; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX; + +/** + CPUID L3 Cache Intel RDT Monitoring Capability Enumeration Sub-leaf + + @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) + @param ECX CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF (0x01) + + @retval EAX Reserved. + @retval EBX Conversion factor from reported IA32_QM_CTR value to occupancy metric (bytes). + @retval ECX Maximum range (zero-based) of RMID of this resource type. + @retval EDX L3 Cache Intel RDT Monitoring Capability information described by the + type CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX. + + Example usage + @code + UINT32 Ebx; + UINT32 Ecx; + CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF, + NULL, &Ebx, &Ecx, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF 0x01 + +/** + CPUID L3 Cache Intel RDT Monitoring Capability Information EDX for CPUID leaf + #CPUID_INTEL_RDT_MONITORING, sub-leaf + #CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Supports L3 occupancy monitoring if 1. + /// + UINT32 L3CacheOccupancyMonitoring:1; + /// + /// [Bit 1] Supports L3 Total Bandwidth monitoring if 1. + /// + UINT32 L3CacheTotalBandwidthMonitoring:1; + /// + /// [Bit 2] Supports L3 Local Bandwidth monitoring if 1. + /// + UINT32 L3CacheLocalBandwidthMonitoring:1; + UINT32 Reserved:29; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX; + + +/** + CPUID Intel Resource Director Technology (Intel RDT) Allocation Information + + @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10). + @param ECX CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF (0x00). + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF (0x01). + CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF (0x02). +**/ +#define CPUID_INTEL_RDT_ALLOCATION 0x10 + +/** + Intel Resource Director Technology (Intel RDT) Allocation Enumeration Sub-leaf + + @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) + @param ECX CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF (0x00). + + @retval EAX Reserved. + @retval EBX L3 and L2 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX. + @retval ECX Reserved. + @retval EDX Reserved. + + Example usage + @code + CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX Ebx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF, + NULL, &Ebx.Uint32, NULL, NULL + ); + @endcode +**/ +#define CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF 0x00 + +/** + CPUID L3 and L2 Cache Allocation Support Information EBX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Supports L3 Cache Allocation Technology if 1. + /// + UINT32 L3CacheAllocation:1; + /// + /// [Bit 2] Supports L2 Cache Allocation Technology if 1. + /// + UINT32 L2CacheAllocation:1; + UINT32 Reserved2:29; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX; + + +/** + L3 Cache Allocation Technology Enumeration Sub-leaf + + @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) + @param ECX CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF (0x01) + + @retval EAX RESID L3 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX. + @retval EBX Bit-granular map of isolation/contention of allocation units. + @retval ECX RESID L3 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX. + @retval EDX RESID L3 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX. + + Example usage + @code + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX Ecx; + CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF, + &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF 0x01 + +/** + CPUID L3 Cache Allocation Technology Information EAX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Length of the capacity bit mask for the corresponding ResID + /// using minus-one notation. + /// + UINT32 CapacityLength:5; + UINT32 Reserved:27; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX; + +/** + CPUID L3 Cache Allocation Technology Information ECX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Updates of COS should be infrequent if 1. + /// + UINT32 CosUpdatesInfrequent:1; + /// + /// [Bit 2] Code and Data Prioritization Technology supported if 1. + /// + UINT32 CodeDataPrioritization:1; + UINT32 Reserved2:29; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX; + +/** + CPUID L3 Cache Allocation Technology Information EDX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Highest COS number supported for this ResID. + /// + UINT32 HighestCosNumber:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX; + +/** + L2 Cache Allocation Technology Enumeration Sub-leaf + + @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) + @param ECX CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF (0x02) + + @retval EAX RESID L2 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX. + @retval EBX Bit-granular map of isolation/contention of allocation units. + @retval ECX Reserved. + @retval EDX RESID L2 Cache Allocation Technology information described by + the type CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX. + + Example usage + @code + CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF, + &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF 0x02 + +/** + CPUID L2 Cache Allocation Technology Information EAX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] Length of the capacity bit mask for the corresponding ResID + /// using minus-one notation. + /// + UINT32 CapacityLength:5; + UINT32 Reserved:27; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX; + +/** + CPUID L2 Cache Allocation Technology Information EDX for CPUID leaf + #CPUID_INTEL_RDT_ALLOCATION, sub-leaf + #CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Highest COS number supported for this ResID. + /// + UINT32 HighestCosNumber:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX; + + +/** + Intel SGX resource capability and configuration. + See Section 37.7.2 "Intel(R) SGX Resource Enumeration Leaves". + + If CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1, the processor also supports querying + CPUID with EAX=12H on Intel SGX resource capability and configuration. + + @param EAX CPUID_INTEL_SGX (0x12) + @param ECX CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF (0x00). + CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF (0x01). + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF (0x02). + Sub leafs 2..n based on the sub-leaf-type encoding (returned in EAX[3:0]) + until the sub-leaf type is invalid. + +**/ +#define CPUID_INTEL_SGX 0x12 + +/** + Sub-Leaf 0 Enumeration of Intel SGX Capabilities. + Enumerates Intel SGX capability, including enclave instruction opcode support. + + @param EAX CPUID_INTEL_SGX (0x12) + @param ECX CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF (0x00) + + @retval EAX The format of Sub-Leaf 0 Enumeration of Intel SGX Capabilities is + described by the type CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX. + @retval EBX MISCSELECT: Reports the bit vector of supported extended features + that can be written to the MISC region of the SSA. + @retval ECX Reserved. + @retval EDX The format of Sub-Leaf 0 Enumeration of Intel SGX Capabilities is + described by the type CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX. + + Example usage + @code + CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX Eax; + UINT32 Ebx; + CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF, + &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF 0x00 + +/** + Sub-Leaf 0 Enumeration of Intel SGX Capabilities EAX for CPUID leaf #CPUID_INTEL_SGX, + sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] If 1, indicates leaf functions of SGX1 instruction are supported. + /// + UINT32 SGX1:1; + /// + /// [Bit 1] If 1, indicates leaf functions of SGX2 instruction are supported. + /// + UINT32 SGX2:1; + UINT32 Reserved:30; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX; + +/** + Sub-Leaf 0 Enumeration of Intel SGX Capabilities EDX for CPUID leaf #CPUID_INTEL_SGX, + sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 7:0] The maximum supported enclave size is 2^(EDX[7:0]) bytes + /// when not in 64-bit mode. + /// + UINT32 MaxEnclaveSize_Not64:8; + /// + /// [Bit 15:8] The maximum supported enclave size is 2^(EDX[15:8]) bytes + /// when operating in 64-bit mode. + /// + UINT32 MaxEnclaveSize_64:8; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX; + + +/** + Sub-Leaf 1 Enumeration of Intel SGX Capabilities. + Enumerates Intel SGX capability of processor state configuration and enclave + configuration in the SECS structure. + + @param EAX CPUID_INTEL_SGX (0x12) + @param ECX CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF (0x01) + + @retval EAX Report the valid bits of SECS.ATTRIBUTES[31:0] that software can + set with ECREATE. SECS.ATTRIBUTES[n] can be set to 1 using ECREATE + only if EAX[n] is 1, where n < 32. + @retval EBX Report the valid bits of SECS.ATTRIBUTES[63:32] that software can + set with ECREATE. SECS.ATTRIBUTES[n+32] can be set to 1 using ECREATE + only if EBX[n] is 1, where n < 32. + @retval ECX Report the valid bits of SECS.ATTRIBUTES[95:64] that software can + set with ECREATE. SECS.ATTRIBUTES[n+64] can be set to 1 using ECREATE + only if ECX[n] is 1, where n < 32. + @retval EDX Report the valid bits of SECS.ATTRIBUTES[127:96] that software can + set with ECREATE. SECS.ATTRIBUTES[n+96] can be set to 1 using ECREATE + only if EDX[n] is 1, where n < 32. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF, + &Eax, &Ebx, &Ecx, &Edx + ); + @endcode +**/ +#define CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF 0x01 + + +/** + Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources. + Enumerates available EPC resources. + + @param EAX CPUID_INTEL_SGX (0x12) + @param ECX CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF (0x02) + + @retval EAX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX + Resources is described by the type + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX. + @retval EBX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX + Resources is described by the type + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX. + @retval EDX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX + Resources is described by the type + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX. + @retval EDX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX + Resources is described by the type + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX. + + Example usage + @code + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX Eax; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX Ebx; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX Ecx; + CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX Edx; + + AsmCpuidEx ( + CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF 0x02 + +/** + Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EAX for CPUID + leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 3:0] Sub-leaf-type encoding. + /// 0000b: This sub-leaf is invalid, EBX:EAX and EDX:ECX report 0. + /// 0001b: This sub-leaf provides information on the Enclave Page Cache (EPC) + /// in EBX:EAX and EDX:ECX. + /// All other encoding are reserved. + /// + UINT32 SubLeafType:4; + UINT32 Reserved:8; + /// + /// [Bit 31:12] If EAX[3:0] = 0001b, these are bits 31:12 of the physical address of + /// the base of the EPC section. + /// + UINT32 LowAddressOfEpcSection:20; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX; + +/** + Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EBX for CPUID + leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 19:0] If EAX[3:0] = 0001b, these are bits 51:32 of the physical address of + /// the base of the EPC section. + /// + UINT32 HighAddressOfEpcSection:20; + UINT32 Reserved:12; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX; + +/** + Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources ECX for CPUID + leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 3:0] The EPC section encoding. + /// 0000b: Not valid. + /// 0001b: The EPC section is confidentiality, integrity and replay protected. + /// All other encoding are reserved. + /// + UINT32 EpcSection:4; + UINT32 Reserved:8; + /// + /// [Bit 31:12] If EAX[3:0] = 0001b, these are bits 31:12 of the size of the + /// corresponding EPC section within the Processor Reserved Memory. + /// + UINT32 LowSizeOfEpcSection:20; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX; + +/** + Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EDX for CPUID + leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 19:0] If EAX[3:0] = 0001b, these are bits 51:32 of the size of the + /// corresponding EPC section within the Processor Reserved Memory. + /// + UINT32 HighSizeOfEpcSection:20; + UINT32 Reserved:12; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX; + + +/** + CPUID Intel Processor Trace Information + + @param EAX CPUID_INTEL_PROCESSOR_TRACE (0x14) + @param ECX CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF (0x00). + CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF (0x01). + +**/ +#define CPUID_INTEL_PROCESSOR_TRACE 0x14 + +/** + CPUID Intel Processor Trace Information Main Leaf + + @param EAX CPUID_INTEL_PROCEDSSOR_TRACE (0x14) + @param ECX CPUID_INTEL_PROCEDSSOR_TRACE_MAIN_LEAF (0x00) + + @retval EAX Reports the maximum sub-leaf supported in leaf 14H. + @retval EBX Returns Intel processor trace information described by the + type CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX. + @retval ECX Returns Intel processor trace information described by the + type CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX. + @retval EDX Reserved. + + Example usage + @code + UINT32 Eax; + CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX Ebx; + CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX Ecx; + + AsmCpuidEx ( + CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, + &Eax, &Ebx.Uint32, &Ecx.Uint32, NULL + ); + @endcode +**/ +#define CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF 0x00 + +/** + CPUID Intel Processor Trace EBX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, + sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] If 1, indicates that IA32_RTIT_CTL.CR3Filter can be set to 1, + /// and that IA32_RTIT_CR3_MATCH MSR can be accessed. + /// + UINT32 Cr3Filter:1; + /// + /// [Bit 1] If 1, indicates support of Configurable PSB and Cycle-Accurate + /// Mode. + /// + UINT32 ConfigurablePsb:1; + /// + /// [Bit 2] If 1, indicates support of IP Filtering, TraceStop filtering, + /// and preservation of Intel PT MSRs across warm reset. + /// + UINT32 IpTraceStopFiltering:1; + /// + /// [Bit 3] If 1, indicates support of MTC timing packet and suppression of + /// COFI-based packets. + /// + UINT32 Mtc:1; + /// + /// [Bit 4] If 1, indicates support of PTWRITE. Writes can set + /// IA32_RTIT_CTL[12] (PTWEn) and IA32_RTIT_CTL[5] (FUPonPTW), and PTWRITE + /// can generate packets. + /// + UINT32 PTWrite:1; + /// + /// [Bit 5] If 1, indicates support of Power Event Trace. Writes can set + /// IA32_RTIT_CTL[4] (PwrEvtEn), enabling Power Event Trace packet + /// generation. + /// + UINT32 PowerEventTrace:1; + UINT32 Reserved:26; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX; + +/** + CPUID Intel Processor Trace ECX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, + sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] If 1, Tracing can be enabled with IA32_RTIT_CTL.ToPA = 1, hence + /// utilizing the ToPA output scheme; IA32_RTIT_OUTPUT_BASE and + /// IA32_RTIT_OUTPUT_MASK_PTRS MSRs can be accessed. + /// + UINT32 RTIT:1; + /// + /// [Bit 1] If 1, ToPA tables can hold any number of output entries, up to + /// the maximum allowed by the MaskOrTableOffset field of + /// IA32_RTIT_OUTPUT_MASK_PTRS. + /// + UINT32 ToPA:1; + /// + /// [Bit 2] If 1, indicates support of Single-Range Output scheme. + /// + UINT32 SingleRangeOutput:1; + /// + /// [Bit 3] If 1, indicates support of output to Trace Transport subsystem. + /// + UINT32 TraceTransportSubsystem:1; + UINT32 Reserved:27; + /// + /// [Bit 31] If 1, generated packets which contain IP payloads have LIP + /// values, which include the CS base component. + /// + UINT32 LIP:1; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX; + + +/** + CPUID Intel Processor Trace Information Sub-leaf + + @param EAX CPUID_INTEL_PROCEDSSOR_TRACE (0x14) + @param ECX CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF (0x01) + + @retval EAX Returns Intel processor trace information described by the + type CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX. + @retval EBX Returns Intel processor trace information described by the + type CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX. + @retval ECX Reserved. + @retval EDX Reserved. + + Example usage + @code + UINT32 MaximumSubLeaf; + UINT32 SubLeaf; + CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX Eax; + CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX Ebx; + + AsmCpuidEx ( + CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, + &MaximumSubLeaf, NULL, NULL, NULL + ); + + for (SubLeaf = CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF; SubLeaf <= MaximumSubLeaf; SubLeaf++) { + AsmCpuidEx ( + CPUID_INTEL_PROCESSOR_TRACE, SubLeaf, + &Eax.Uint32, &Ebx.Uint32, NULL, NULL + ); + } + @endcode +**/ +#define CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF 0x01 + +/** + CPUID Intel Processor Trace EAX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, + sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Number of configurable Address Ranges for filtering. + /// + UINT32 ConfigurableAddressRanges:3; + UINT32 Reserved:13; + /// + /// [Bits 31:16] Bitmap of supported MTC period encodings + /// + UINT32 MtcPeriodEncodings:16; + + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX; + +/** + CPUID Intel Processor Trace EBX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, + sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Bitmap of supported Cycle Threshold value encodings. + /// + UINT32 CycleThresholdEncodings:16; + /// + /// [Bits 31:16] Bitmap of supported Configurable PSB frequency encodings. + /// + UINT32 PsbFrequencyEncodings:16; + + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX; + + +/** + CPUID Time Stamp Counter and Nominal Core Crystal Clock Information + + @note + If EBX[31:0] is 0, the TSC/"core crystal clock" ratio is not enumerated. + EBX[31:0]/EAX[31:0] indicates the ratio of the TSC frequency and the core + crystal clock frequency. + If ECX is 0, the nominal core crystal clock frequency is not enumerated. + "TSC frequency" = "core crystal clock frequency" * EBX/EAX. + The core crystal clock may differ from the reference clock, bus clock, or core + clock frequencies. + + @param EAX CPUID_TIME_STAMP_COUNTER (0x15) + + @retval EAX An unsigned integer which is the denominator of the + TSC/"core crystal clock" ratio + @retval EBX An unsigned integer which is the numerator of the + TSC/"core crystal clock" ratio. + @retval ECX An unsigned integer which is the nominal frequency + of the core crystal clock in Hz. + @retval EDX Reserved. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + + AsmCpuid (CPUID_TIME_STAMP_COUNTER, &Eax, &Ebx, &Ecx, NULL); + @endcode +**/ +#define CPUID_TIME_STAMP_COUNTER 0x15 + + +/** + CPUID Processor Frequency Information + + @note + Data is returned from this interface in accordance with the processor's + specification and does not reflect actual values. Suitable use of this data + includes the display of processor information in like manner to the processor + brand string and for determining the appropriate range to use when displaying + processor information e.g. frequency history graphs. The returned information + should not be used for any other purpose as the returned information does not + accurately correlate to information / counters returned by other processor + interfaces. While a processor may support the Processor Frequency Information + leaf, fields that return a value of zero are not supported. + + @param EAX CPUID_TIME_STAMP_COUNTER (0x16) + + @retval EAX Returns processor base frequency information described by the + type CPUID_PROCESSOR_FREQUENCY_EAX. + @retval EBX Returns maximum frequency information described by the type + CPUID_PROCESSOR_FREQUENCY_EBX. + @retval ECX Returns bus frequency information described by the type + CPUID_PROCESSOR_FREQUENCY_ECX. + @retval EDX Reserved. + + Example usage + @code + CPUID_PROCESSOR_FREQUENCY_EAX Eax; + CPUID_PROCESSOR_FREQUENCY_EBX Ebx; + CPUID_PROCESSOR_FREQUENCY_ECX Ecx; + + AsmCpuid (CPUID_PROCESSOR_FREQUENCY, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); + @endcode +**/ +#define CPUID_PROCESSOR_FREQUENCY 0x16 + +/** + CPUID Processor Frequency Information EAX for CPUID leaf + #CPUID_PROCESSOR_FREQUENCY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Processor Base Frequency (in MHz). + /// + UINT32 ProcessorBaseFrequency:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_PROCESSOR_FREQUENCY_EAX; + +/** + CPUID Processor Frequency Information EBX for CPUID leaf + #CPUID_PROCESSOR_FREQUENCY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Maximum Frequency (in MHz). + /// + UINT32 MaximumFrequency:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_PROCESSOR_FREQUENCY_EBX; + +/** + CPUID Processor Frequency Information ECX for CPUID leaf + #CPUID_PROCESSOR_FREQUENCY. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Bus (Reference) Frequency (in MHz). + /// + UINT32 BusFrequency:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_PROCESSOR_FREQUENCY_ECX; + + +/** + CPUID SoC Vendor Information + + @param EAX CPUID_SOC_VENDOR (0x17) + @param ECX CPUID_SOC_VENDOR_MAIN_LEAF (0x00) + CPUID_SOC_VENDOR_BRAND_STRING1 (0x01) + CPUID_SOC_VENDOR_BRAND_STRING1 (0x02) + CPUID_SOC_VENDOR_BRAND_STRING1 (0x03) + + @note + Leaf 17H output depends on the initial value in ECX. SOC Vendor Brand String + is a UTF-8 encoded string padded with trailing bytes of 00H. The complete SOC + Vendor Brand String is constructed by concatenating in ascending order of + EAX:EBX:ECX:EDX and from the sub-leaf 1 fragment towards sub-leaf 3. + +**/ +#define CPUID_SOC_VENDOR 0x17 + +/** + CPUID SoC Vendor Information + + @param EAX CPUID_SOC_VENDOR (0x17) + @param ECX CPUID_SOC_VENDOR_MAIN_LEAF (0x00) + + @retval EAX MaxSOCID_Index. Reports the maximum input value of supported + sub-leaf in leaf 17H. + @retval EBX Returns SoC Vendor information described by the type + CPUID_SOC_VENDOR_MAIN_LEAF_EBX. + @retval ECX Project ID. A unique number an SOC vendor assigns to its SOC + projects. + @retval EDX Stepping ID. A unique number within an SOC project that an SOC + vendor assigns. + + Example usage + @code + UINT32 Eax; + CPUID_SOC_VENDOR_MAIN_LEAF_EBX Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF, + &Eax, &Ebx.Uint32, &Ecx, &Edx + ); + @endcode +**/ +#define CPUID_SOC_VENDOR_MAIN_LEAF 0x00 + +/** + CPUID SoC Vendor Information EBX for CPUID leaf #CPUID_SOC_VENDOR sub-leaf + #CPUID_SOC_VENDOR_MAIN_LEAF. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] SOC Vendor ID. + /// + UINT32 SocVendorId:16; + /// + /// [Bit 16] If 1, the SOC Vendor ID field is assigned via an industry + /// standard enumeration scheme. Otherwise, the SOC Vendor ID field is + /// assigned by Intel. + /// + UINT32 IsVendorScheme:1; + UINT32 Reserved:15; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_SOC_VENDOR_MAIN_LEAF_EBX; + +/** + CPUID SoC Vendor Information + + @param EAX CPUID_SOC_VENDOR (0x17) + @param ECX CPUID_SOC_VENDOR_BRAND_STRING1 (0x01) + + @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + + Example usage + @code + CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_SOC_VENDOR_BRAND_STRING1 0x01 + +/** + CPUID SoC Vendor Brand String for CPUID leafs #CPUID_SOC_VENDOR_BRAND_STRING1, + #CPUID_SOC_VENDOR_BRAND_STRING2, and #CPUID_SOC_VENDOR_BRAND_STRING3. +**/ +typedef union { + /// + /// 4 UTF-8 characters of Soc Vendor Brand String + /// + CHAR8 BrandString[4]; + /// + /// All fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_SOC_VENDOR_BRAND_STRING_DATA; + +/** + CPUID SoC Vendor Information + + @param EAX CPUID_SOC_VENDOR (0x17) + @param ECX CPUID_SOC_VENDOR_BRAND_STRING2 (0x02) + + @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + + Example usage + @code + CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_SOC_VENDOR_BRAND_STRING2 0x02 + +/** + CPUID SoC Vendor Information + + @param EAX CPUID_SOC_VENDOR (0x17) + @param ECX CPUID_SOC_VENDOR_BRAND_STRING3 (0x03) + + @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type + CPUID_SOC_VENDOR_BRAND_STRING_DATA. + + Example usage + @code + CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; + CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; + + AsmCpuidEx ( + CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3, + &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 + ); + @endcode +**/ +#define CPUID_SOC_VENDOR_BRAND_STRING3 0x03 + + +/** + CPUID Extended Function + + @param EAX CPUID_EXTENDED_FUNCTION (0x80000000) + + @retval EAX Maximum Input Value for Extended Function CPUID Information. + @retval EBX Reserved. + @retval ECX Reserved. + @retval EDX Reserved. + + Example usage + @code + UINT32 Eax; + + AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); + @endcode +**/ +#define CPUID_EXTENDED_FUNCTION 0x80000000 + + +/** + CPUID Extended Processor Signature and Feature Bits + + @param EAX CPUID_EXTENDED_CPU_SIG (0x80000001) + + @retval EAX CPUID_EXTENDED_CPU_SIG. + @retval EBX Reserved. + @retval ECX Extended Processor Signature and Feature Bits information + described by the type CPUID_EXTENDED_CPU_SIG_ECX. + @retval EDX Extended Processor Signature and Feature Bits information + described by the type CPUID_EXTENDED_CPU_SIG_EDX. + + Example usage + @code + UINT32 Eax; + CPUID_EXTENDED_CPU_SIG_ECX Ecx; + CPUID_EXTENDED_CPU_SIG_EDX Edx; + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, &Eax, NULL, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_EXTENDED_CPU_SIG 0x80000001 + +/** + CPUID Extended Processor Signature and Feature Bits ECX for CPUID leaf + #CPUID_EXTENDED_CPU_SIG. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LAHF/SAHF available in 64-bit mode. + /// + UINT32 LAHF_SAHF:1; + UINT32 Reserved1:4; + /// + /// [Bit 5] LZCNT. + /// + UINT32 LZCNT:1; + UINT32 Reserved2:2; + /// + /// [Bit 8] PREFETCHW. + /// + UINT32 PREFETCHW:1; + UINT32 Reserved3:23; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_CPU_SIG_ECX; + +/** + CPUID Extended Processor Signature and Feature Bits EDX for CPUID leaf + #CPUID_EXTENDED_CPU_SIG. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:11; + /// + /// [Bit 11] SYSCALL/SYSRET available in 64-bit mode. + /// + UINT32 SYSCALL_SYSRET:1; + UINT32 Reserved2:8; + /// + /// [Bit 20] Execute Disable Bit available. + /// + UINT32 NX:1; + UINT32 Reserved3:5; + /// + /// [Bit 26] 1-GByte pages are available if 1. + /// + UINT32 Page1GB:1; + /// + /// [Bit 27] RDTSCP and IA32_TSC_AUX are available if 1. + /// + UINT32 RDTSCP:1; + UINT32 Reserved4:1; + /// + /// [Bit 29] Intel(R) 64 Architecture available if 1. + /// + UINT32 LM:1; + UINT32 Reserved5:2; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_CPU_SIG_EDX; + + +/** + CPUID Processor Brand String + + @param EAX CPUID_BRAND_STRING1 (0x80000002) + + @retval EAX Processor Brand String in type CPUID_BRAND_STRING_DATA. + @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + + Example usage + @code + CPUID_BRAND_STRING_DATA Eax; + CPUID_BRAND_STRING_DATA Ebx; + CPUID_BRAND_STRING_DATA Ecx; + CPUID_BRAND_STRING_DATA Edx; + + AsmCpuid (CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_BRAND_STRING1 0x80000002 + +/** + CPUID Processor Brand String for CPUID leafs #CPUID_BRAND_STRING1, + #CPUID_BRAND_STRING2, and #CPUID_BRAND_STRING3. +**/ +typedef union { + /// + /// 4 ASCII characters of Processor Brand String + /// + CHAR8 BrandString[4]; + /// + /// All fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_BRAND_STRING_DATA; + +/** + CPUID Processor Brand String + + @param EAX CPUID_BRAND_STRING2 (0x80000003) + + @retval EAX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + + Example usage + @code + CPUID_BRAND_STRING_DATA Eax; + CPUID_BRAND_STRING_DATA Ebx; + CPUID_BRAND_STRING_DATA Ecx; + CPUID_BRAND_STRING_DATA Edx; + + AsmCpuid (CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_BRAND_STRING2 0x80000003 + +/** + CPUID Processor Brand String + + @param EAX CPUID_BRAND_STRING3 (0x80000004) + + @retval EAX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. + + Example usage + @code + CPUID_BRAND_STRING_DATA Eax; + CPUID_BRAND_STRING_DATA Ebx; + CPUID_BRAND_STRING_DATA Ecx; + CPUID_BRAND_STRING_DATA Edx; + + AsmCpuid (CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); + @endcode +**/ +#define CPUID_BRAND_STRING3 0x80000004 + + +/** + CPUID Extended Cache information + + @param EAX CPUID_EXTENDED_CACHE_INFO (0x80000006) + + @retval EAX Reserved. + @retval EBX Reserved. + @retval ECX Extended cache information described by the type + CPUID_EXTENDED_CACHE_INFO_ECX. + @retval EDX Reserved. + + Example usage + @code + CPUID_EXTENDED_CACHE_INFO_ECX Ecx; + + AsmCpuid (CPUID_EXTENDED_CACHE_INFO, NULL, NULL, &Ecx.Uint32, NULL); + @endcode +**/ +#define CPUID_EXTENDED_CACHE_INFO 0x80000006 + +/** + CPUID Extended Cache information ECX for CPUID leaf #CPUID_EXTENDED_CACHE_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Cache line size in bytes. + /// + UINT32 CacheLineSize:8; + UINT32 Reserved:4; + /// + /// [Bits 15:12] L2 Associativity field. Supported values are in the range + /// #CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DISABLED to + /// #CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_FULL + /// + UINT32 L2Associativity:4; + /// + /// [Bits 31:16] Cache size in 1K units. + /// + UINT32 CacheSize:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_CACHE_INFO_ECX; + +/// +/// @{ Define value for bit field CPUID_EXTENDED_CACHE_INFO_ECX.L2Associativity +/// +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DISABLED 0x00 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DIRECT_MAPPED 0x01 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_2_WAY 0x02 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_4_WAY 0x04 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_8_WAY 0x06 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_16_WAY 0x08 +#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_FULL 0x0F +/// +/// @} +/// + +/** + CPUID Extended Time Stamp Counter information + + @param EAX CPUID_EXTENDED_TIME_STAMP_COUNTER (0x80000007) + + @retval EAX Reserved. + @retval EBX Reserved. + @retval ECX Reserved. + @retval EDX Extended time stamp counter (TSC) information described by the + type CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX. + + Example usage + @code + CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX Edx; + + AsmCpuid (CPUID_EXTENDED_TIME_STAMP_COUNTER, NULL, NULL, NULL, &Edx.Uint32); + @endcode +**/ +#define CPUID_EXTENDED_TIME_STAMP_COUNTER 0x80000007 + +/** + CPUID Extended Time Stamp Counter information EDX for CPUID leaf + #CPUID_EXTENDED_TIME_STAMP_COUNTER. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bit 8] Invariant TSC available if 1. + /// + UINT32 InvariantTsc:1; + UINT32 Reserved2:23; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX; + + +/** + CPUID Linear Physical Address Size + + @param EAX CPUID_VIR_PHY_ADDRESS_SIZE (0x80000008) + + @retval EAX Linear/Physical Address Size described by the type + CPUID_VIR_PHY_ADDRESS_SIZE_EAX. + @retval EBX Reserved. + @retval ECX Reserved. + @retval EDX Reserved. + + Example usage + @code + CPUID_VIR_PHY_ADDRESS_SIZE_EAX Eax; + + AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Eax.Uint32, NULL, NULL, NULL); + @endcode +**/ +#define CPUID_VIR_PHY_ADDRESS_SIZE 0x80000008 + +/** + CPUID Linear Physical Address Size EAX for CPUID leaf + #CPUID_VIR_PHY_ADDRESS_SIZE. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Number of physical address bits. + /// + /// @note + /// If CPUID.80000008H:EAX[7:0] is supported, the maximum physical address + /// number supported should come from this field. + /// + UINT32 PhysicalAddressBits:8; + /// + /// [Bits 15:8] Number of linear address bits. + /// + UINT32 LinearAddressBits:8; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_VIR_PHY_ADDRESS_SIZE_EAX; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/LocalApic.h b/Core/UefiCpuPkg/Include/Register/LocalApic.h new file mode 100644 index 0000000000..cfb6d76d8b --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/LocalApic.h @@ -0,0 +1,189 @@ +/** @file + IA32 Local APIC Definitions. + + Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __LOCAL_APIC_H__ +#define __LOCAL_APIC_H__ + +// +// Definition for Local APIC registers and related values +// +#define XAPIC_ID_OFFSET 0x20 +#define XAPIC_VERSION_OFFSET 0x30 +#define XAPIC_EOI_OFFSET 0x0b0 +#define XAPIC_ICR_DFR_OFFSET 0x0e0 +#define XAPIC_SPURIOUS_VECTOR_OFFSET 0x0f0 +#define XAPIC_ICR_LOW_OFFSET 0x300 +#define XAPIC_ICR_HIGH_OFFSET 0x310 +#define XAPIC_LVT_TIMER_OFFSET 0x320 +#define XAPIC_LVT_LINT0_OFFSET 0x350 +#define XAPIC_LVT_LINT1_OFFSET 0x360 +#define XAPIC_TIMER_INIT_COUNT_OFFSET 0x380 +#define XAPIC_TIMER_CURRENT_COUNT_OFFSET 0x390 +#define XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET 0x3E0 + +#define X2APIC_MSR_BASE_ADDRESS 0x800 +#define X2APIC_MSR_ICR_ADDRESS 0x830 + +#define LOCAL_APIC_DELIVERY_MODE_FIXED 0 +#define LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY 1 +#define LOCAL_APIC_DELIVERY_MODE_SMI 2 +#define LOCAL_APIC_DELIVERY_MODE_NMI 4 +#define LOCAL_APIC_DELIVERY_MODE_INIT 5 +#define LOCAL_APIC_DELIVERY_MODE_STARTUP 6 +#define LOCAL_APIC_DELIVERY_MODE_EXTINT 7 + +#define LOCAL_APIC_DESTINATION_SHORTHAND_NO_SHORTHAND 0 +#define LOCAL_APIC_DESTINATION_SHORTHAND_SELF 1 +#define LOCAL_APIC_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF 2 +#define LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF 3 + +// +// Local APIC Version Register. +// +typedef union { + struct { + UINT32 Version:8; ///< The version numbers of the local APIC. + UINT32 Reserved0:8; ///< Reserved. + UINT32 MaxLvtEntry:8; ///< Number of LVT entries minus 1. + UINT32 EoiBroadcastSuppression:1; ///< 1 if EOI-broadcast suppression supported. + UINT32 Reserved1:7; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_VERSION; + +// +// Low half of Interrupt Command Register (ICR). +// +typedef union { + struct { + UINT32 Vector:8; ///< The vector number of the interrupt being sent. + UINT32 DeliveryMode:3; ///< Specifies the type of IPI to be sent. + UINT32 DestinationMode:1; ///< 0: physical destination mode, 1: logical destination mode. + UINT32 DeliveryStatus:1; ///< Indicates the IPI delivery status. This field is reserved in x2APIC mode. + UINT32 Reserved0:1; ///< Reserved. + UINT32 Level:1; ///< 0 for the INIT level de-assert delivery mode. Otherwise 1. + UINT32 TriggerMode:1; ///< 0: edge, 1: level when using the INIT level de-assert delivery mode. + UINT32 Reserved1:2; ///< Reserved. + UINT32 DestinationShorthand:2; ///< A shorthand notation to specify the destination of the interrupt. + UINT32 Reserved2:12; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_ICR_LOW; + +// +// High half of Interrupt Command Register (ICR) +// +typedef union { + struct { + UINT32 Reserved0:24; ///< Reserved. + UINT32 Destination:8; ///< Specifies the target processor or processors in xAPIC mode. + } Bits; + UINT32 Uint32; ///< Destination field expanded to 32-bit in x2APIC mode. +} LOCAL_APIC_ICR_HIGH; + +// +// Spurious-Interrupt Vector Register (SVR) +// +typedef union { + struct { + UINT32 SpuriousVector:8; ///< Spurious Vector. + UINT32 SoftwareEnable:1; ///< APIC Software Enable/Disable. + UINT32 FocusProcessorChecking:1; ///< Focus Processor Checking. + UINT32 Reserved0:2; ///< Reserved. + UINT32 EoiBroadcastSuppression:1; ///< EOI-Broadcast Suppression. + UINT32 Reserved1:19; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_SVR; + +// +// Divide Configuration Register (DCR) +// +typedef union { + struct { + UINT32 DivideValue1:2; ///< Low 2 bits of the divide value. + UINT32 Reserved0:1; ///< Always 0. + UINT32 DivideValue2:1; ///< Highest 1 bit of the divide value. + UINT32 Reserved1:28; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_DCR; + +// +// LVT Timer Register +// +typedef union { + struct { + UINT32 Vector:8; ///< The vector number of the interrupt being sent. + UINT32 Reserved0:4; ///< Reserved. + UINT32 DeliveryStatus:1; ///< 0: Idle, 1: send pending. + UINT32 Reserved1:3; ///< Reserved. + UINT32 Mask:1; ///< 0: Not masked, 1: Masked. + UINT32 TimerMode:1; ///< 0: One-shot, 1: Periodic. + UINT32 Reserved2:14; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_LVT_TIMER; + +// +// LVT LINT0/LINT1 Register +// +typedef union { + struct { + UINT32 Vector:8; ///< The vector number of the interrupt being sent. + UINT32 DeliveryMode:3; ///< Specifies the type of interrupt to be sent. + UINT32 Reserved0:1; ///< Reserved. + UINT32 DeliveryStatus:1; ///< 0: Idle, 1: send pending. + UINT32 InputPinPolarity:1; ///< Interrupt Input Pin Polarity. + UINT32 RemoteIrr:1; ///< RO. Set when the local APIC accepts the interrupt and reset when an EOI is received. + UINT32 TriggerMode:1; ///< 0:edge, 1:level. + UINT32 Mask:1; ///< 0: Not masked, 1: Masked. + UINT32 Reserved1:15; ///< Reserved. + } Bits; + UINT32 Uint32; +} LOCAL_APIC_LVT_LINT; + +// +// MSI Address Register +// +typedef union { + struct { + UINT32 Reserved0:2; ///< Reserved + UINT32 DestinationMode:1; ///< Specifies the Destination Mode. + UINT32 RedirectionHint:1; ///< Specifies the Redirection Hint. + UINT32 Reserved1:8; ///< Reserved. + UINT32 DestinationId:8; ///< Specifies the Destination ID. + UINT32 BaseAddress:12; ///< Must be 0FEEH + } Bits; + UINT32 Uint32; +} LOCAL_APIC_MSI_ADDRESS; + +// +// MSI Address Register +// +typedef union { + struct { + UINT32 Vector:8; ///< Interrupt vector in range 010h..0FEH + UINT32 DeliveryMode:3; ///< Specifies the type of interrupt to be sent. + UINT32 Reserved0:3; ///< Reserved. + UINT32 Level:1; ///< 0:Deassert, 1:Assert. Ignored for Edge triggered interrupts. + UINT32 TriggerMode:1; ///< 0:Edge, 1:Level. + UINT32 Reserved1:16; ///< Reserved. + UINT32 Reserved2:32; ///< Reserved. + } Bits; + UINT64 Uint64; +} LOCAL_APIC_MSI_DATA; + +#endif + diff --git a/Core/UefiCpuPkg/Include/Register/Microcode.h b/Core/UefiCpuPkg/Include/Register/Microcode.h new file mode 100644 index 0000000000..94529a1ca2 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Microcode.h @@ -0,0 +1,200 @@ +/** @file + Microcode Definitions. + + Microcode Definitions based on contents of the + Intel(R) 64 and IA-32 Architectures Software Developer's Manual + Volume 3A, Section 9.11 Microcode Definitions + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, + June 2016, Chapter 9 Processor Management and Initialization, Section 9-11. + +**/ + +#ifndef __MICROCODE_H__ +#define __MICROCODE_H__ + +/// +/// CPU Microcode Date in BCD format +/// +typedef union { + struct { + UINT32 Year:16; + UINT32 Day:8; + UINT32 Month:8; + } Bits; + UINT32 Uint32; +} CPU_MICROCODE_DATE; + +/// +/// CPU Microcode Processor Signature format +/// +typedef union { + struct { + UINT32 Stepping:4; + UINT32 Model:4; + UINT32 Family:4; + UINT32 Type:2; + UINT32 Reserved1:2; + UINT32 ExtendedModel:4; + UINT32 ExtendedFamily:8; + UINT32 Reserved2:4; + } Bits; + UINT32 Uint32; +} CPU_MICROCODE_PROCESSOR_SIGNATURE; + +#pragma pack (1) + +/// +/// Microcode Update Format definition +/// +typedef struct { + /// + /// Version number of the update header + /// + UINT32 HeaderVersion; + /// + /// Unique version number for the update, the basis for the update + /// signature provided by the processor to indicate the current update + /// functioning within the processor. Used by the BIOS to authenticate + /// the update and verify that the processor loads successfully. The + /// value in this field cannot be used for processor stepping identification + /// alone. This is a signed 32-bit number. + /// + UINT32 UpdateRevision; + /// + /// Date of the update creation in binary format: mmddyyyy (e.g. + /// 07/18/98 is 07181998H). + /// + CPU_MICROCODE_DATE Date; + /// + /// Extended family, extended model, type, family, model, and stepping + /// of processor that requires this particular update revision (e.g., + /// 00000650H). Each microcode update is designed specifically for a + /// given extended family, extended model, type, family, model, and + /// stepping of the processor. + /// The BIOS uses the processor signature field in conjunction with the + /// CPUID instruction to determine whether or not an update is + /// appropriate to load on a processor. The information encoded within + /// this field exactly corresponds to the bit representations returned by + /// the CPUID instruction. + /// + CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature; + /// + /// Checksum of Update Data and Header. Used to verify the integrity of + /// the update header and data. Checksum is correct when the + /// summation of all the DWORDs (including the extended Processor + /// Signature Table) that comprise the microcode update result in + /// 00000000H. + /// + UINT32 Checksum; + /// + /// Version number of the loader program needed to correctly load this + /// update. The initial version is 00000001H + /// + UINT32 LoaderRevision; + /// + /// Platform type information is encoded in the lower 8 bits of this 4- + /// byte field. Each bit represents a particular platform type for a given + /// CPUID. The BIOS uses the processor flags field in conjunction with + /// the platform Id bits in MSR (17H) to determine whether or not an + /// update is appropriate to load on a processor. Multiple bits may be set + /// representing support for multiple platform IDs. + /// + UINT32 ProcessorFlags; + /// + /// Specifies the size of the encrypted data in bytes, and must be a + /// multiple of DWORDs. If this value is 00000000H, then the microcode + /// update encrypted data is 2000 bytes (or 500 DWORDs). + /// + UINT32 DataSize; + /// + /// Specifies the total size of the microcode update in bytes. It is the + /// summation of the header size, the encrypted data size and the size of + /// the optional extended signature table. This value is always a multiple + /// of 1024. + /// + UINT32 TotalSize; + /// + /// Reserved fields for future expansion. + /// + UINT8 Reserved[12]; +} CPU_MICROCODE_HEADER; + +/// +/// Extended Signature Table Header Field Definitions +/// +typedef struct { + /// + /// Specifies the number of extended signature structures (Processor + /// Signature[n], processor flags[n] and checksum[n]) that exist in this + /// microcode update + /// + UINT32 ExtendedSignatureCount; + /// + /// Checksum of update extended processor signature table. Used to + /// verify the integrity of the extended processor signature table. + /// Checksum is correct when the summation of the DWORDs that + /// comprise the extended processor signature table results in + /// 00000000H. + /// + UINT32 ExtendedChecksum; + /// + /// Reserved fields. + /// + UINT8 Reserved[12]; +} CPU_MICROCODE_EXTENDED_TABLE_HEADER; + +/// +/// Extended Signature Table Field Definitions +/// +typedef struct { + /// + /// Extended family, extended model, type, family, model, and stepping + /// of processor that requires this particular update revision (e.g., + /// 00000650H). Each microcode update is designed specifically for a + /// given extended family, extended model, type, family, model, and + /// stepping of the processor. + /// The BIOS uses the processor signature field in conjunction with the + /// CPUID instruction to determine whether or not an update is + /// appropriate to load on a processor. The information encoded within + /// this field exactly corresponds to the bit representations returned by + /// the CPUID instruction. + /// + CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature; + /// + /// Platform type information is encoded in the lower 8 bits of this 4- + /// byte field. Each bit represents a particular platform type for a given + /// CPUID. The BIOS uses the processor flags field in conjunction with + /// the platform Id bits in MSR (17H) to determine whether or not an + /// update is appropriate to load on a processor. Multiple bits may be set + /// representing support for multiple platform IDs. + /// + UINT32 ProcessorFlag; + /// + /// Used by utility software to decompose a microcode update into + /// multiple microcode updates where each of the new updates is + /// constructed without the optional Extended Processor Signature + /// Table. + /// To calculate the Checksum, substitute the Primary Processor + /// Signature entry and the Processor Flags entry with the + /// corresponding Extended Patch entry. Delete the Extended Processor + /// Signature Table entries. The Checksum is correct when the + /// summation of all DWORDs that comprise the created Extended + /// Processor Patch results in 00000000H. + /// + UINT32 Checksum; +} CPU_MICROCODE_EXTENDED_TABLE; + +#pragma pack () + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr.h b/Core/UefiCpuPkg/Include/Register/Msr.h new file mode 100644 index 0000000000..0ac8d5bdfd --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr.h @@ -0,0 +1,49 @@ +/** @file + MSR Definitions. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Chapter 35. + +**/ + +#ifndef __MSR_H__ +#define __MSR_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/AtomMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/AtomMsr.h new file mode 100644 index 0000000000..b2764690f5 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/AtomMsr.h @@ -0,0 +1,790 @@ +/** @file + MSR Definitions for the Intel(R) Atom(TM) Processor Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.3. + +**/ + +#ifndef __ATOM_MSR_H__ +#define __ATOM_MSR_H__ + +#include + +/** + Is Intel(R) Atom(TM) Processor Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_ATOM_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x1C || \ + DisplayModel == 0x26 || \ + DisplayModel == 0x27 || \ + DisplayModel == 0x35 || \ + DisplayModel == 0x36 \ + ) \ + ) + +/** + Shared. Model Specific Platform ID (R). + + @param ECX MSR_ATOM_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_ATOM_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PLATFORM_ID); + @endcode + @note MSR_ATOM_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. +**/ +#define MSR_ATOM_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_ATOM_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. + /// + UINT32 MaximumQualifiedRatio:5; + UINT32 Reserved2:19; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_PLATFORM_ID_REGISTER; + + +/** + Shared. Processor Hard Power-On Configuration (R/W) Enables and disables + processor features; (R) indicates current processor configuration. + + @param ECX MSR_ATOM_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_ATOM_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_ATOM_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_ATOM_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. +**/ +#define MSR_ATOM_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_ATOM_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Always 0. + /// + UINT32 DataErrorCheckingEnable:1; + /// + /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Always 0. + /// + UINT32 ResponseErrorCheckingEnable:1; + /// + /// [Bit 3] AERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Always 0. + /// + UINT32 AERR_DriveEnable:1; + /// + /// [Bit 4] BERR# Enable for initiator bus requests (R/W) 1 = Enabled; 0 = + /// Disabled Always 0. + /// + UINT32 BERR_Enable:1; + UINT32 Reserved2:1; + UINT32 Reserved3:1; + /// + /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Always 0. + /// + UINT32 BINIT_DriverEnable:1; + UINT32 Reserved4:1; + /// + /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 10] AERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled + /// Always 0. + /// + UINT32 AERR_ObservationEnabled:1; + UINT32 Reserved5:1; + /// + /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled + /// Always 0. + /// + UINT32 BINIT_ObservationEnabled:1; + UINT32 Reserved6:1; + /// + /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. + /// + UINT32 ResetVector:1; + UINT32 Reserved7:1; + /// + /// [Bits 17:16] APIC Cluster ID (R/O) Always 00B. + /// + UINT32 APICClusterID:2; + UINT32 Reserved8:2; + /// + /// [Bits 21:20] Symmetric Arbitration ID (R/O) Always 00B. + /// + UINT32 SymmetricArbitrationID:2; + /// + /// [Bits 26:22] Integer Bus Frequency Ratio (R/O). + /// + UINT32 IntegerBusFrequencyRatio:5; + UINT32 Reserved9:5; + UINT32 Reserved10:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_EBL_CR_POWERON_REGISTER; + + +/** + Unique. Last Branch Record n From IP (R/W) One of eight pairs of last branch + record registers on the last branch record stack. The From_IP part of the + stack contains pointers to the source instruction . See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.5. + + @param ECX MSR_ATOM_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_ATOM_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_ATOM_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + @{ +**/ +#define MSR_ATOM_LASTBRANCH_0_FROM_IP 0x00000040 +#define MSR_ATOM_LASTBRANCH_1_FROM_IP 0x00000041 +#define MSR_ATOM_LASTBRANCH_2_FROM_IP 0x00000042 +#define MSR_ATOM_LASTBRANCH_3_FROM_IP 0x00000043 +#define MSR_ATOM_LASTBRANCH_4_FROM_IP 0x00000044 +#define MSR_ATOM_LASTBRANCH_5_FROM_IP 0x00000045 +#define MSR_ATOM_LASTBRANCH_6_FROM_IP 0x00000046 +#define MSR_ATOM_LASTBRANCH_7_FROM_IP 0x00000047 +/// @} + + +/** + Unique. Last Branch Record n To IP (R/W) One of eight pairs of last branch + record registers on the last branch record stack. The To_IP part of the + stack contains pointers to the destination instruction. + + @param ECX MSR_ATOM_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_ATOM_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_ATOM_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + @{ +**/ +#define MSR_ATOM_LASTBRANCH_0_TO_IP 0x00000060 +#define MSR_ATOM_LASTBRANCH_1_TO_IP 0x00000061 +#define MSR_ATOM_LASTBRANCH_2_TO_IP 0x00000062 +#define MSR_ATOM_LASTBRANCH_3_TO_IP 0x00000063 +#define MSR_ATOM_LASTBRANCH_4_TO_IP 0x00000064 +#define MSR_ATOM_LASTBRANCH_5_TO_IP 0x00000065 +#define MSR_ATOM_LASTBRANCH_6_TO_IP 0x00000066 +#define MSR_ATOM_LASTBRANCH_7_TO_IP 0x00000067 +/// @} + + +/** + Shared. Scalable Bus Speed(RO) This field indicates the intended scalable + bus clock speed for processors based on Intel Atom microarchitecture:. + + @param ECX MSR_ATOM_FSB_FREQ (0x000000CD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_FSB_FREQ_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_FSB_FREQ_REGISTER. + + Example usage + @code + MSR_ATOM_FSB_FREQ_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_FSB_FREQ); + @endcode + @note MSR_ATOM_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. +**/ +#define MSR_ATOM_FSB_FREQ 0x000000CD + +/** + MSR information returned for MSR index #MSR_ATOM_FSB_FREQ +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] - Scalable Bus Speed + /// + /// Atom Processor Family + /// --------------------- + /// 111B: 083 MHz (FSB 333) + /// 101B: 100 MHz (FSB 400) + /// 001B: 133 MHz (FSB 533) + /// 011B: 167 MHz (FSB 667) + /// + /// 133.33 MHz should be utilized if performing calculation with + /// System Bus Speed when encoding is 001B. + /// 166.67 MHz should be utilized if performing calculation with + /// System Bus Speed when + /// encoding is 011B. + /// + UINT32 ScalableBusSpeed:3; + UINT32 Reserved1:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_FSB_FREQ_REGISTER; + + +/** + Shared. + + @param ECX MSR_ATOM_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_ATOM_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_ATOM_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_ATOM_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. +**/ +#define MSR_ATOM_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_ATOM_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = + /// Indicates if the L2 is hardware-disabled. + /// + UINT32 L2HardwareEnabled:1; + UINT32 Reserved1:7; + /// + /// [Bit 8] L2 Enabled. (R/W) 1 = L2 cache has been initialized 0 = + /// Disabled (default) Until this bit is set the processor will not + /// respond to the WBINVD instruction or the assertion of the FLUSH# input. + /// + UINT32 L2Enabled:1; + UINT32 Reserved2:14; + /// + /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. + /// + UINT32 L2NotPresent:1; + UINT32 Reserved3:8; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_BBL_CR_CTL3_REGISTER; + + +/** + Shared. + + @param ECX MSR_ATOM_PERF_STATUS (0x00000198) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_PERF_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_PERF_STATUS_REGISTER. + + Example usage + @code + MSR_ATOM_PERF_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PERF_STATUS); + AsmWriteMsr64 (MSR_ATOM_PERF_STATUS, Msr.Uint64); + @endcode + @note MSR_ATOM_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. +**/ +#define MSR_ATOM_PERF_STATUS 0x00000198 + +/** + MSR information returned for MSR index #MSR_ATOM_PERF_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Current Performance State Value. + /// + UINT32 CurrentPerformanceStateValue:16; + UINT32 Reserved1:16; + UINT32 Reserved2:8; + /// + /// [Bits 44:40] Maximum Bus Ratio (R/O) Indicates maximum bus ratio + /// configured for the processor. + /// + UINT32 MaximumBusRatio:5; + UINT32 Reserved3:19; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_PERF_STATUS_REGISTER; + + +/** + Shared. + + @param ECX MSR_ATOM_THERM2_CTL (0x0000019D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_THERM2_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_THERM2_CTL_REGISTER. + + Example usage + @code + MSR_ATOM_THERM2_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_THERM2_CTL); + AsmWriteMsr64 (MSR_ATOM_THERM2_CTL, Msr.Uint64); + @endcode + @note MSR_ATOM_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. +**/ +#define MSR_ATOM_THERM2_CTL 0x0000019D + +/** + MSR information returned for MSR index #MSR_ATOM_THERM2_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = + /// Thermal Monitor 1 (thermally-initiated on-die modulation of the + /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated + /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is + /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 are enabled. + /// + UINT32 TM_SELECT:1; + UINT32 Reserved2:15; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_THERM2_CTL_REGISTER; + + +/** + Unique. Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_ATOM_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_ATOM_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_ATOM_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_ATOM_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_ATOM_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_ATOM_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. Default value is 0. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:1; + UINT32 Reserved4:1; + /// + /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by + /// the processor to indicate a pending break event within the processor 0 + /// = Indicates compatible FERR# signaling behavior This bit must be set + /// to 1 to support XAPIC interrupt model usage. + /// + UINT32 FERR:1; + /// + /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Shared. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + /// + /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the + /// thermal sensor indicates that the die temperature is at the + /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. + /// TM2 will reduce the bus to core ratio and voltage according to the + /// value last written to MSR_THERM2_CTL bits 15:0. + /// When this bit is clear (0, default), the processor does not change + /// the VID signals or the bus to core ratio when the processor enters a + /// thermally managed state. The BIOS must enable this feature if the + /// TM2 feature flag (CPUID.1:ECX[8]) is set; if the TM2 feature flag is + /// not set, this feature is not supported and BIOS must not alter the + /// contents of the TM2 bit location. The processor is operating out of + /// specification if both this bit and the TM1 bit are set to 0. + /// + UINT32 TM2:1; + UINT32 Reserved5:2; + /// + /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved6:1; + /// + /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved7:1; + /// + /// [Bit 20] Shared. Enhanced Intel SpeedStep Technology Select Lock + /// (R/WO) When set, this bit causes the following bits to become + /// read-only: - Enhanced Intel SpeedStep Technology Select Lock (this + /// bit), - Enhanced Intel SpeedStep Technology Enable bit. The bit must + /// be set before an Enhanced Intel SpeedStep Technology transition is + /// requested. This bit is cleared on reset. + /// + UINT32 EISTLock:1; + UINT32 Reserved8:1; + /// + /// [Bit 22] Unique. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved9:8; + UINT32 Reserved10:2; + /// + /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved11:29; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_IA32_MISC_ENABLE_REGISTER; + + +/** + Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-2) + that points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP (at 40H). + + @param ECX MSR_ATOM_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_ATOM_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_ATOM_LASTBRANCH_TOS 0x000001C9 + + +/** + Unique. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_ATOM_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_LER_FROM_LIP); + @endcode + @note MSR_ATOM_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_ATOM_LER_FROM_LIP 0x000001DD + + +/** + Unique. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_ATOM_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_LER_TO_LIP); + @endcode + @note MSR_ATOM_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_ATOM_LER_TO_LIP 0x000001DE + + +/** + Unique. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling + (PEBS).". + + @param ECX MSR_ATOM_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_ATOM_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_ATOM_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_ATOM_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PEBS_ENABLE); + AsmWriteMsr64 (MSR_ATOM_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_ATOM_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_ATOM_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_ATOM_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). + /// + UINT32 Enable:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_ATOM_PEBS_ENABLE_REGISTER; + + +/** + Package. Package C2 Residency Note: C-state values are processor specific + C-state code names, unrelated to MWAIT extension C-state parameters or ACPI + C-States. Package. Package C2 Residency Counter. (R/O) Time that this + package is in processor-specific C2 states since last reset. Counts at 1 Mhz + frequency. + + @param ECX MSR_ATOM_PKG_C2_RESIDENCY (0x000003F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_PKG_C2_RESIDENCY); + AsmWriteMsr64 (MSR_ATOM_PKG_C2_RESIDENCY, Msr); + @endcode + @note MSR_ATOM_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. +**/ +#define MSR_ATOM_PKG_C2_RESIDENCY 0x000003F8 + + +/** + Package. Package C4 Residency Note: C-state values are processor specific + C-state code names, unrelated to MWAIT extension C-state parameters or ACPI + C-States. Package. Package C4 Residency Counter. (R/O) Time that this + package is in processor-specific C4 states since last reset. Counts at 1 Mhz + frequency. + + @param ECX MSR_ATOM_PKG_C4_RESIDENCY (0x000003F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_PKG_C4_RESIDENCY); + AsmWriteMsr64 (MSR_ATOM_PKG_C4_RESIDENCY, Msr); + @endcode + @note MSR_ATOM_PKG_C4_RESIDENCY is defined as MSR_PKG_C4_RESIDENCY in SDM. +**/ +#define MSR_ATOM_PKG_C4_RESIDENCY 0x000003F9 + + +/** + Package. Package C6 Residency Note: C-state values are processor specific + C-state code names, unrelated to MWAIT extension C-state parameters or ACPI + C-States. Package. Package C6 Residency Counter. (R/O) Time that this + package is in processor-specific C6 states since last reset. Counts at 1 Mhz + frequency. + + @param ECX MSR_ATOM_PKG_C6_RESIDENCY (0x000003FA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_ATOM_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_ATOM_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_ATOM_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_ATOM_PKG_C6_RESIDENCY 0x000003FA + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h new file mode 100644 index 0000000000..90bd523c99 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h @@ -0,0 +1,306 @@ +/** @file + MSR Definitions for Intel processors based on the Broadwell microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.13. + +**/ + +#ifndef __BROADWELL_MSR_H__ +#define __BROADWELL_MSR_H__ + +#include + +/** + Is Intel processors based on the Broadwell microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_BROADWELL_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x3D || \ + DisplayModel == 0x47 || \ + DisplayModel == 0x4F || \ + DisplayModel == 0x56 \ + ) \ + ) + +/** + Thread. See Table 35-2. See Section 18.4.2, "Global Counter Control + Facilities.". + + @param ECX MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS 0x0000038E + +/** + MSR information returned for MSR index #MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Trace_ToPA_PMI. See Section 36.2.6.2, "Table of Physical + /// Addresses (ToPA).". + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:5; + /// + /// [Bit 61] Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Ovf_BufDSSAVE. + /// + UINT32 OvfBuf:1; + /// + /// [Bit 63] CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are processor + specific C-state code names, unrelated to MWAIT extension C-state parameters + or ACPI C-states. `See http://biosbits.org. `__. + + @param ECX MSR_BROADWELL_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_BROADWELL_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_BROADWELL_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_BROADWELL_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_BROADWELL_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power) for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 0000b: + /// C0/C1 (no package C-state support) 0001b: C2 0010b: C3 0011b: C6 + /// 0100b: C7 0101b: C7s 0110b: C8 0111b: C9 1000b: C10. + /// + UINT32 Limit:4; + UINT32 Reserved1:6; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W). + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO). + /// + UINT32 CFGLock:1; + UINT32 Reserved3:9; + /// + /// [Bit 25] C3 State Auto Demotion Enable (R/W). + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 State Auto Demotion Enable (R/W). + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 Undemotion (R/W). + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 Undemotion (R/W). + /// + UINT32 C1Undemotion:1; + /// + /// [Bit 29] Enable Package C-State Auto-demotion (R/W). + /// + UINT32 CStateAutoDemotion:1; + /// + /// [Bit 30] Enable Package C-State Undemotion (R/W). + /// + UINT32 CStateUndemotion:1; + UINT32 Reserved4:1; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_BROADWELL_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_TURBO_RATIO_LIMIT); + @endcode + @note MSR_BROADWELL_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_BROADWELL_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_BROADWELL_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio + /// limit of 5core active. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio + /// limit of 6core active. + /// + UINT32 Maximum6C:8; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_BROADWELL_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_BROADWELL_PP0_ENERGY_STATUS); + @endcode + @note MSR_BROADWELL_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_BROADWELL_PP0_ENERGY_STATUS 0x00000639 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/Core2Msr.h b/Core/UefiCpuPkg/Include/Register/Msr/Core2Msr.h new file mode 100644 index 0000000000..9ebca5e9b5 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/Core2Msr.h @@ -0,0 +1,1134 @@ +/** @file + MSR Definitions for the Intel(R) Core(TM) 2 Processor Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.2. + +**/ + +#ifndef __CORE2_MSR_H__ +#define __CORE2_MSR_H__ + +#include + +/** + Is Intel(R) Core(TM) 2 Processor Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_CORE2_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x0F || \ + DisplayModel == 0x17 \ + ) \ + ) + +/** + Shared. Model Specific Platform ID (R). + + @param ECX MSR_CORE2_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_CORE2_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PLATFORM_ID); + @endcode + @note MSR_CORE2_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. +**/ +#define MSR_CORE2_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_CORE2_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. + /// + UINT32 MaximumQualifiedRatio:5; + UINT32 Reserved2:19; + UINT32 Reserved3:18; + /// + /// [Bits 52:50] See Table 35-2. + /// + UINT32 PlatformId:3; + UINT32 Reserved4:11; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_PLATFORM_ID_REGISTER; + + +/** + Shared. Processor Hard Power-On Configuration (R/W) Enables and disables + processor features; (R) indicates current processor configuration. + + @param ECX MSR_CORE2_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_CORE2_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_CORE2_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_CORE2_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. +**/ +#define MSR_CORE2_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_CORE2_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Note: Not all processor implements R/W. + /// + UINT32 DataErrorCheckingEnable:1; + /// + /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Note: Not all processor implements R/W. + /// + UINT32 ResponseErrorCheckingEnable:1; + /// + /// [Bit 3] MCERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not + /// all processor implements R/W. + /// + UINT32 MCERR_DriveEnable:1; + /// + /// [Bit 4] Address Parity Enable (R/W) 1 = Enabled; 0 = Disabled Note: + /// Not all processor implements R/W. + /// + UINT32 AddressParityEnable:1; + UINT32 Reserved2:1; + UINT32 Reserved3:1; + /// + /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not + /// all processor implements R/W. + /// + UINT32 BINIT_DriverEnable:1; + /// + /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 OutputTriStateEnable:1; + /// + /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 MCERR_ObservationEnabled:1; + /// + /// [Bit 11] Intel TXT Capable Chipset. (R/O) 1 = Present; 0 = Not Present. + /// + UINT32 IntelTXTCapableChipset:1; + /// + /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 BINIT_ObservationEnabled:1; + UINT32 Reserved4:1; + /// + /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. + /// + UINT32 ResetVector:1; + UINT32 Reserved5:1; + /// + /// [Bits 17:16] APIC Cluster ID (R/O). + /// + UINT32 APICClusterID:2; + /// + /// [Bit 18] N/2 Non-Integer Bus Ratio (R/O) 0 = Integer ratio; 1 = + /// Non-integer ratio. + /// + UINT32 NonIntegerBusRatio:1; + UINT32 Reserved6:1; + /// + /// [Bits 21:20] Symmetric Arbitration ID (R/O). + /// + UINT32 SymmetricArbitrationID:2; + /// + /// [Bits 26:22] Integer Bus Frequency Ratio (R/O). + /// + UINT32 IntegerBusFrequencyRatio:5; + UINT32 Reserved7:5; + UINT32 Reserved8:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_EBL_CR_POWERON_REGISTER; + + +/** + Unique. Control Features in Intel 64Processor (R/W) See Table 35-2. + + @param ECX MSR_CORE2_FEATURE_CONTROL (0x0000003A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_CORE2_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_CORE2_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_CORE2_FEATURE_CONTROL is defined as MSR_FEATURE_CONTROL in SDM. +**/ +#define MSR_CORE2_FEATURE_CONTROL 0x0000003A + +/** + MSR information returned for MSR index #MSR_CORE2_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:3; + /// + /// [Bit 3] Unique. SMRR Enable (R/WL) When this bit is set and the lock + /// bit is set makes the SMRR_PHYS_BASE and SMRR_PHYS_MASK registers read + /// visible and writeable while in SMM. + /// + UINT32 SMRREnable:1; + UINT32 Reserved2:28; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_FEATURE_CONTROL_REGISTER; + + +/** + Unique. Last Branch Record n From IP (R/W) One of four pairs of last branch + record registers on the last branch record stack. The From_IP part of the + stack contains pointers to the source instruction. See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.5. + + @param ECX MSR_CORE2_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_CORE2_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_CORE2_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_CORE2_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_CORE2_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + @{ +**/ +#define MSR_CORE2_LASTBRANCH_0_FROM_IP 0x00000040 +#define MSR_CORE2_LASTBRANCH_1_FROM_IP 0x00000041 +#define MSR_CORE2_LASTBRANCH_2_FROM_IP 0x00000042 +#define MSR_CORE2_LASTBRANCH_3_FROM_IP 0x00000043 +/// @} + + +/** + Unique. Last Branch Record n To IP (R/W) One of four pairs of last branch + record registers on the last branch record stack. This To_IP part of the + stack contains pointers to the destination instruction. + + @param ECX MSR_CORE2_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_CORE2_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_CORE2_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_CORE2_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_CORE2_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + @{ +**/ +#define MSR_CORE2_LASTBRANCH_0_TO_IP 0x00000060 +#define MSR_CORE2_LASTBRANCH_1_TO_IP 0x00000061 +#define MSR_CORE2_LASTBRANCH_2_TO_IP 0x00000062 +#define MSR_CORE2_LASTBRANCH_3_TO_IP 0x00000063 +/// @} + + +/** + Unique. System Management Mode Base Address register (WO in SMM) + Model-specific implementation of SMRR-like interface, read visible and write + only in SMM. + + @param ECX MSR_CORE2_SMRR_PHYSBASE (0x000000A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_SMRR_PHYSBASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_SMRR_PHYSBASE_REGISTER. + + Example usage + @code + MSR_CORE2_SMRR_PHYSBASE_REGISTER Msr; + + Msr.Uint64 = 0; + AsmWriteMsr64 (MSR_CORE2_SMRR_PHYSBASE, Msr.Uint64); + @endcode + @note MSR_CORE2_SMRR_PHYSBASE is defined as MSR_SMRR_PHYSBASE in SDM. +**/ +#define MSR_CORE2_SMRR_PHYSBASE 0x000000A0 + +/** + MSR information returned for MSR index #MSR_CORE2_SMRR_PHYSBASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:12; + /// + /// [Bits 31:12] PhysBase. SMRR physical Base Address. + /// + UINT32 PhysBase:20; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_SMRR_PHYSBASE_REGISTER; + + +/** + Unique. System Management Mode Physical Address Mask register (WO in SMM) + Model-specific implementation of SMRR-like interface, read visible and write + only in SMM. + + @param ECX MSR_CORE2_SMRR_PHYSMASK (0x000000A1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_SMRR_PHYSMASK_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_SMRR_PHYSMASK_REGISTER. + + Example usage + @code + MSR_CORE2_SMRR_PHYSMASK_REGISTER Msr; + + Msr.Uint64 = 0; + AsmWriteMsr64 (MSR_CORE2_SMRR_PHYSMASK, Msr.Uint64); + @endcode + @note MSR_CORE2_SMRR_PHYSMASK is defined as MSR_SMRR_PHYSMASK in SDM. +**/ +#define MSR_CORE2_SMRR_PHYSMASK 0x000000A1 + +/** + MSR information returned for MSR index #MSR_CORE2_SMRR_PHYSMASK +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:11; + /// + /// [Bit 11] Valid. Physical address base and range mask are valid. + /// + UINT32 Valid:1; + /// + /// [Bits 31:12] PhysMask. SMRR physical address range mask. + /// + UINT32 PhysMask:20; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_SMRR_PHYSMASK_REGISTER; + + +/** + Shared. Scalable Bus Speed(RO) This field indicates the intended scalable + bus clock speed for processors based on Intel Core microarchitecture:. + + @param ECX MSR_CORE2_FSB_FREQ (0x000000CD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_FSB_FREQ_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_FSB_FREQ_REGISTER. + + Example usage + @code + MSR_CORE2_FSB_FREQ_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_FSB_FREQ); + @endcode + @note MSR_CORE2_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. +**/ +#define MSR_CORE2_FSB_FREQ 0x000000CD + +/** + MSR information returned for MSR index #MSR_CORE2_FSB_FREQ +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] - Scalable Bus Speed + /// 101B: 100 MHz (FSB 400) + /// 001B: 133 MHz (FSB 533) + /// 011B: 167 MHz (FSB 667) + /// 010B: 200 MHz (FSB 800) + /// 000B: 267 MHz (FSB 1067) + /// 100B: 333 MHz (FSB 1333) + /// + /// 133.33 MHz should be utilized if performing calculation with System + /// Bus Speed when encoding is 001B. 166.67 MHz should be utilized if + /// performing calculation with System Bus Speed when encoding is 011B. + /// 266.67 MHz should be utilized if performing calculation with System + /// Bus Speed when encoding is 000B. 333.33 MHz should be utilized if + /// performing calculation with System Bus Speed when encoding is 100B. + /// + UINT32 ScalableBusSpeed:3; + UINT32 Reserved1:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_FSB_FREQ_REGISTER; + + +/** + Shared. + + @param ECX MSR_CORE2_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_CORE2_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_CORE2_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_CORE2_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. +**/ +#define MSR_CORE2_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_CORE2_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = + /// Indicates if the L2 is hardware-disabled. + /// + UINT32 L2HardwareEnabled:1; + UINT32 Reserved1:7; + /// + /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = + /// Disabled (default) Until this bit is set the processor will not + /// respond to the WBINVD instruction or the assertion of the FLUSH# input. + /// + UINT32 L2Enabled:1; + UINT32 Reserved2:14; + /// + /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. + /// + UINT32 L2NotPresent:1; + UINT32 Reserved3:8; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_BBL_CR_CTL3_REGISTER; + + +/** + Shared. + + @param ECX MSR_CORE2_PERF_STATUS (0x00000198) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_PERF_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_PERF_STATUS_REGISTER. + + Example usage + @code + MSR_CORE2_PERF_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PERF_STATUS); + AsmWriteMsr64 (MSR_CORE2_PERF_STATUS, Msr.Uint64); + @endcode + @note MSR_CORE2_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. +**/ +#define MSR_CORE2_PERF_STATUS 0x00000198 + +/** + MSR information returned for MSR index #MSR_CORE2_PERF_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Current Performance State Value. + /// + UINT32 CurrentPerformanceStateValue:16; + UINT32 Reserved1:15; + /// + /// [Bit 31] XE Operation (R/O). If set, XE operation is enabled. Default + /// is cleared. + /// + UINT32 XEOperation:1; + UINT32 Reserved2:8; + /// + /// [Bits 44:40] Maximum Bus Ratio (R/O) Indicates maximum bus ratio + /// configured for the processor. + /// + UINT32 MaximumBusRatio:5; + UINT32 Reserved3:1; + /// + /// [Bit 46] Non-Integer Bus Ratio (R/O) Indicates non-integer bus ratio + /// is enabled. Applies processors based on Enhanced Intel Core + /// microarchitecture. + /// + UINT32 NonIntegerBusRatio:1; + UINT32 Reserved4:17; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_PERF_STATUS_REGISTER; + + +/** + Unique. + + @param ECX MSR_CORE2_THERM2_CTL (0x0000019D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_THERM2_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_THERM2_CTL_REGISTER. + + Example usage + @code + MSR_CORE2_THERM2_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_THERM2_CTL); + AsmWriteMsr64 (MSR_CORE2_THERM2_CTL, Msr.Uint64); + @endcode + @note MSR_CORE2_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. +**/ +#define MSR_CORE2_THERM2_CTL 0x0000019D + +/** + MSR information returned for MSR index #MSR_CORE2_THERM2_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = + /// Thermal Monitor 1 (thermally-initiated on-die modulation of the + /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated + /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is + /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 are enabled. + /// + UINT32 TM_SELECT:1; + UINT32 Reserved2:15; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_THERM2_CTL_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_CORE2_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_CORE2_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_CORE2_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_CORE2_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_CORE2_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_CORE2_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:1; + /// + /// [Bit 9] Hardware Prefetcher Disable (R/W) When set, disables the + /// hardware prefetcher operation on streams of data. When clear + /// (default), enables the prefetch queue. Disabling of the hardware + /// prefetcher may impact processor performance. + /// + UINT32 HardwarePrefetcherDisable:1; + /// + /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by + /// the processor to indicate a pending break event within the processor 0 + /// = Indicates compatible FERR# signaling behavior This bit must be set + /// to 1 to support XAPIC interrupt model usage. + /// + UINT32 FERR:1; + /// + /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Shared. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + /// + /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the + /// thermal sensor indicates that the die temperature is at the + /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. + /// TM2 will reduce the bus to core ratio and voltage according to the + /// value last written to MSR_THERM2_CTL bits 15:0. + /// When this bit is clear (0, default), the processor does not change + /// the VID signals or the bus to core ratio when the processor enters a + /// thermally managed state. The BIOS must enable this feature if the + /// TM2 feature flag (CPUID.1:ECX[8]) is set; if the TM2 feature flag is + /// not set, this feature is not supported and BIOS must not alter the + /// contents of the TM2 bit location. The processor is operating out of + /// specification if both this bit and the TM1 bit are set to 0. + /// + UINT32 TM2:1; + UINT32 Reserved4:2; + /// + /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + /// + /// [Bit 19] Shared. Adjacent Cache Line Prefetch Disable (R/W) When set + /// to 1, the processor fetches the cache line that contains data + /// currently required by the processor. When set to 0, the processor + /// fetches cache lines that comprise a cache line pair (128 bytes). + /// Single processor platforms should not set this bit. Server platforms + /// should set or clear this bit based on platform performance observed in + /// validation and testing. BIOS may contain a setup option that controls + /// the setting of this bit. + /// + UINT32 AdjacentCacheLinePrefetchDisable:1; + /// + /// [Bit 20] Shared. Enhanced Intel SpeedStep Technology Select Lock + /// (R/WO) When set, this bit causes the following bits to become + /// read-only: - Enhanced Intel SpeedStep Technology Select Lock (this + /// bit), - Enhanced Intel SpeedStep Technology Enable bit. The bit must + /// be set before an Enhanced Intel SpeedStep Technology transition is + /// requested. This bit is cleared on reset. + /// + UINT32 EISTLock:1; + UINT32 Reserved6:1; + /// + /// [Bit 22] Shared. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved9:2; + /// + /// [Bit 37] Unique. DCU Prefetcher Disable (R/W) When set to 1, The DCU + /// L1 data cache prefetcher is disabled. The default value after reset is + /// 0. BIOS may write '1' to disable this feature. The DCU prefetcher is + /// an L1 data cache prefetcher. When the DCU prefetcher detects multiple + /// loads from the same line done within a time limit, the DCU prefetcher + /// assumes the next line will be required. The next line is prefetched in + /// to the L1 data cache from memory or L2. + /// + UINT32 DCUPrefetcherDisable:1; + /// + /// [Bit 38] Shared. IDA Disable (R/W) When set to 1 on processors that + /// support IDA, the Intel Dynamic Acceleration feature (IDA) is disabled + /// and the IDA_Enable feature flag will be clear (CPUID.06H: EAX[1]=0). + /// When set to a 0 on processors that support IDA, CPUID.06H: EAX[1] + /// reports the processor's support of IDA is enabled. Note: the power-on + /// default value is used by BIOS to detect hardware support of IDA. If + /// power-on default value is 1, IDA is available in the processor. If + /// power-on default value is 0, IDA is not available. + /// + UINT32 IDADisable:1; + /// + /// [Bit 39] Unique. IP Prefetcher Disable (R/W) When set to 1, The IP + /// prefetcher is disabled. The default value after reset is 0. BIOS may + /// write '1' to disable this feature. The IP prefetcher is an L1 data + /// cache prefetcher. The IP prefetcher looks for sequential load history + /// to determine whether to prefetch the next expected data into the L1 + /// cache from memory or L2. + /// + UINT32 IPPrefetcherDisable:1; + UINT32 Reserved10:24; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_IA32_MISC_ENABLE_REGISTER; + + +/** + Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) + that points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP (at 40H). + + @param ECX MSR_CORE2_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_CORE2_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_CORE2_LASTBRANCH_TOS 0x000001C9 + + +/** + Unique. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_CORE2_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_LER_FROM_LIP); + @endcode + @note MSR_CORE2_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_CORE2_LER_FROM_LIP 0x000001DD + + +/** + Unique. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_CORE2_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_LER_TO_LIP); + @endcode + @note MSR_CORE2_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_CORE2_LER_TO_LIP 0x000001DE + + +/** + Unique. Fixed-Function Performance Counter Register n (R/W). + + @param ECX MSR_CORE2_PERF_FIXED_CTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_PERF_FIXED_CTR0); + AsmWriteMsr64 (MSR_CORE2_PERF_FIXED_CTR0, Msr); + @endcode + @note MSR_CORE2_PERF_FIXED_CTR0 is defined as MSR_PERF_FIXED_CTR0 in SDM. + MSR_CORE2_PERF_FIXED_CTR1 is defined as MSR_PERF_FIXED_CTR1 in SDM. + MSR_CORE2_PERF_FIXED_CTR2 is defined as MSR_PERF_FIXED_CTR2 in SDM. + @{ +**/ +#define MSR_CORE2_PERF_FIXED_CTR0 0x00000309 +#define MSR_CORE2_PERF_FIXED_CTR1 0x0000030A +#define MSR_CORE2_PERF_FIXED_CTR2 0x0000030B +/// @} + + +/** + Unique. RO. This applies to processors that do not support architectural + perfmon version 2. + + @param ECX MSR_CORE2_PERF_CAPABILITIES (0x00000345) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_PERF_CAPABILITIES_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_PERF_CAPABILITIES_REGISTER. + + Example usage + @code + MSR_CORE2_PERF_CAPABILITIES_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PERF_CAPABILITIES); + AsmWriteMsr64 (MSR_CORE2_PERF_CAPABILITIES, Msr.Uint64); + @endcode + @note MSR_CORE2_PERF_CAPABILITIES is defined as MSR_PERF_CAPABILITIES in SDM. +**/ +#define MSR_CORE2_PERF_CAPABILITIES 0x00000345 + +/** + MSR information returned for MSR index #MSR_CORE2_PERF_CAPABILITIES +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 5:0] LBR Format. See Table 35-2. + /// + UINT32 LBR_FMT:6; + /// + /// [Bit 6] PEBS Record Format. + /// + UINT32 PEBS_FMT:1; + /// + /// [Bit 7] PEBSSaveArchRegs. See Table 35-2. + /// + UINT32 PEBS_ARCH_REG:1; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_PERF_CAPABILITIES_REGISTER; + + +/** + Unique. Fixed-Function-Counter Control Register (R/W). + + @param ECX MSR_CORE2_PERF_FIXED_CTR_CTRL (0x0000038D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_PERF_FIXED_CTR_CTRL); + AsmWriteMsr64 (MSR_CORE2_PERF_FIXED_CTR_CTRL, Msr); + @endcode + @note MSR_CORE2_PERF_FIXED_CTR_CTRL is defined as MSR_PERF_FIXED_CTR_CTRL in SDM. +**/ +#define MSR_CORE2_PERF_FIXED_CTR_CTRL 0x0000038D + + +/** + Unique. See Section 18.4.2, "Global Counter Control Facilities.". + + @param ECX MSR_CORE2_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_STATUS, Msr); + @endcode + @note MSR_CORE2_PERF_GLOBAL_STATUS is defined as MSR_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_CORE2_PERF_GLOBAL_STATUS 0x0000038E + + +/** + Unique. See Section 18.4.2, "Global Counter Control Facilities.". + + @param ECX MSR_CORE2_PERF_GLOBAL_CTRL (0x0000038F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_CTRL, Msr); + @endcode + @note MSR_CORE2_PERF_GLOBAL_CTRL is defined as MSR_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_CORE2_PERF_GLOBAL_CTRL 0x0000038F + + +/** + Unique. See Section 18.4.2, "Global Counter Control Facilities.". + + @param ECX MSR_CORE2_PERF_GLOBAL_OVF_CTRL (0x00000390) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_OVF_CTRL, Msr); + @endcode + @note MSR_CORE2_PERF_GLOBAL_OVF_CTRL is defined as MSR_PERF_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_CORE2_PERF_GLOBAL_OVF_CTRL 0x00000390 + + +/** + Unique. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling + (PEBS).". + + @param ECX MSR_CORE2_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE2_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE2_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_CORE2_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PEBS_ENABLE); + AsmWriteMsr64 (MSR_CORE2_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_CORE2_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_CORE2_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_CORE2_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). + /// + UINT32 Enable:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE2_PEBS_ENABLE_REGISTER; + + +/** + Unique. GBUSQ Event Control/Counter Register (R/W) Apply to Intel Xeon + processor 7400 series (processor signature 06_1D) only. See Section 17.2.2. + + @param ECX MSR_CORE2_EMON_L3_CTR_CTLn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_EMON_L3_CTR_CTL0); + AsmWriteMsr64 (MSR_CORE2_EMON_L3_CTR_CTL0, Msr); + @endcode + @note MSR_CORE2_EMON_L3_CTR_CTL0 is defined as MSR_EMON_L3_CTR_CTL0 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL1 is defined as MSR_EMON_L3_CTR_CTL1 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL2 is defined as MSR_EMON_L3_CTR_CTL2 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL3 is defined as MSR_EMON_L3_CTR_CTL3 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL4 is defined as MSR_EMON_L3_CTR_CTL4 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL5 is defined as MSR_EMON_L3_CTR_CTL5 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL6 is defined as MSR_EMON_L3_CTR_CTL6 in SDM. + MSR_CORE2_EMON_L3_CTR_CTL7 is defined as MSR_EMON_L3_CTR_CTL7 in SDM. + @{ +**/ +#define MSR_CORE2_EMON_L3_CTR_CTL0 0x000107CC +#define MSR_CORE2_EMON_L3_CTR_CTL1 0x000107CD +#define MSR_CORE2_EMON_L3_CTR_CTL2 0x000107CE +#define MSR_CORE2_EMON_L3_CTR_CTL3 0x000107CF +#define MSR_CORE2_EMON_L3_CTR_CTL4 0x000107D0 +#define MSR_CORE2_EMON_L3_CTR_CTL5 0x000107D1 +#define MSR_CORE2_EMON_L3_CTR_CTL6 0x000107D2 +#define MSR_CORE2_EMON_L3_CTR_CTL7 0x000107D3 +/// @} + + +/** + Unique. L3/FSB Common Control Register (R/W) Apply to Intel Xeon processor + 7400 series (processor signature 06_1D) only. See Section 17.2.2. + + @param ECX MSR_CORE2_EMON_L3_GL_CTL (0x000107D8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE2_EMON_L3_GL_CTL); + AsmWriteMsr64 (MSR_CORE2_EMON_L3_GL_CTL, Msr); + @endcode + @note MSR_CORE2_EMON_L3_GL_CTL is defined as MSR_EMON_L3_GL_CTL in SDM. +**/ +#define MSR_CORE2_EMON_L3_GL_CTL 0x000107D8 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/CoreMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/CoreMsr.h new file mode 100644 index 0000000000..4897c74d5a --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/CoreMsr.h @@ -0,0 +1,1110 @@ +/** @file + MSR Definitions for Intel Core Solo and Intel Core Duo Processors. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.19. + +**/ + +#ifndef __CORE_MSR_H__ +#define __CORE_MSR_H__ + +#include + +/** + Is Intel Core Solo and Intel Core Duo Processors? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_CORE_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x0E \ + ) \ + ) + +/** + Unique. See Section 35.22, "MSRs in Pentium Processors," and see Table 35-2. + + @param ECX MSR_CORE_P5_MC_ADDR (0x00000000) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_P5_MC_ADDR); + AsmWriteMsr64 (MSR_CORE_P5_MC_ADDR, Msr); + @endcode + @note MSR_CORE_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. +**/ +#define MSR_CORE_P5_MC_ADDR 0x00000000 + + +/** + Unique. See Section 35.22, "MSRs in Pentium Processors," and see Table 35-2. + + @param ECX MSR_CORE_P5_MC_TYPE (0x00000001) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_P5_MC_TYPE); + AsmWriteMsr64 (MSR_CORE_P5_MC_TYPE, Msr); + @endcode + @note MSR_CORE_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. +**/ +#define MSR_CORE_P5_MC_TYPE 0x00000001 + + +/** + Shared. Processor Hard Power-On Configuration (R/W) Enables and disables + processor features; (R) indicates current processor configuration. + + @param ECX MSR_CORE_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_CORE_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_CORE_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_CORE_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. +**/ +#define MSR_CORE_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_CORE_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Note: Not all processor implements R/W. + /// + UINT32 DataErrorCheckingEnable:1; + /// + /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled + /// Note: Not all processor implements R/W. + /// + UINT32 ResponseErrorCheckingEnable:1; + /// + /// [Bit 3] MCERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not + /// all processor implements R/W. + /// + UINT32 MCERR_DriveEnable:1; + /// + /// [Bit 4] Address Parity Enable (R/W) 1 = Enabled; 0 = Disabled Note: + /// Not all processor implements R/W. + /// + UINT32 AddressParityEnable:1; + UINT32 Reserved2:2; + /// + /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not + /// all processor implements R/W. + /// + UINT32 BINIT_DriverEnable:1; + /// + /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 OutputTriStateEnable:1; + /// + /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 MCERR_ObservationEnabled:1; + UINT32 Reserved3:1; + /// + /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 BINIT_ObservationEnabled:1; + UINT32 Reserved4:1; + /// + /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. + /// + UINT32 ResetVector:1; + UINT32 Reserved5:1; + /// + /// [Bits 17:16] APIC Cluster ID (R/O). + /// + UINT32 APICClusterID:2; + /// + /// [Bit 18] System Bus Frequency (R/O) 1. = 100 MHz 2. = Reserved. + /// + UINT32 SystemBusFrequency:1; + UINT32 Reserved6:1; + /// + /// [Bits 21:20] Symmetric Arbitration ID (R/O). + /// + UINT32 SymmetricArbitrationID:2; + /// + /// [Bits 26:22] Clock Frequency Ratio (R/O). + /// + UINT32 ClockFrequencyRatio:5; + UINT32 Reserved7:5; + UINT32 Reserved8:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_EBL_CR_POWERON_REGISTER; + + +/** + Unique. Last Branch Record n (R/W) One of 8 last branch record registers on + the last branch record stack: bits 31-0 hold the 'from' address and bits + 63-32 hold the 'to' address. See also: - Last Branch Record Stack TOS at + 1C9H - Section 17.13, "Last Branch, Interrupt, and Exception Recording + (Pentium M Processors).". + + @param ECX MSR_CORE_LASTBRANCH_n + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_LASTBRANCH_0); + AsmWriteMsr64 (MSR_CORE_LASTBRANCH_0, Msr); + @endcode + @note MSR_CORE_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. + MSR_CORE_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. + MSR_CORE_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. + MSR_CORE_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. + MSR_CORE_LASTBRANCH_4 is defined as MSR_LASTBRANCH_4 in SDM. + MSR_CORE_LASTBRANCH_5 is defined as MSR_LASTBRANCH_5 in SDM. + MSR_CORE_LASTBRANCH_6 is defined as MSR_LASTBRANCH_6 in SDM. + MSR_CORE_LASTBRANCH_7 is defined as MSR_LASTBRANCH_7 in SDM. + @{ +**/ +#define MSR_CORE_LASTBRANCH_0 0x00000040 +#define MSR_CORE_LASTBRANCH_1 0x00000041 +#define MSR_CORE_LASTBRANCH_2 0x00000042 +#define MSR_CORE_LASTBRANCH_3 0x00000043 +#define MSR_CORE_LASTBRANCH_4 0x00000044 +#define MSR_CORE_LASTBRANCH_5 0x00000045 +#define MSR_CORE_LASTBRANCH_6 0x00000046 +#define MSR_CORE_LASTBRANCH_7 0x00000047 +/// @} + + +/** + Shared. Scalable Bus Speed (RO) This field indicates the scalable bus + clock speed:. + + @param ECX MSR_CORE_FSB_FREQ (0x000000CD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_FSB_FREQ_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_FSB_FREQ_REGISTER. + + Example usage + @code + MSR_CORE_FSB_FREQ_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_FSB_FREQ); + @endcode + @note MSR_CORE_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. +**/ +#define MSR_CORE_FSB_FREQ 0x000000CD + +/** + MSR information returned for MSR index #MSR_CORE_FSB_FREQ +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] - Scalable Bus Speed + /// 101B: 100 MHz (FSB 400) + /// 001B: 133 MHz (FSB 533) + /// 011B: 167 MHz (FSB 667) + /// + /// 133.33 MHz should be utilized if performing calculation with System Bus + /// Speed when encoding is 101B. 166.67 MHz should be utilized if + /// performing calculation with System Bus Speed when encoding is 001B. + /// + UINT32 ScalableBusSpeed:3; + UINT32 Reserved1:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_FSB_FREQ_REGISTER; + + +/** + Shared. + + @param ECX MSR_CORE_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_CORE_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_CORE_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_CORE_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. +**/ +#define MSR_CORE_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_CORE_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = + /// Indicates if the L2 is hardware-disabled. + /// + UINT32 L2HardwareEnabled:1; + UINT32 Reserved1:7; + /// + /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = + /// Disabled (default) Until this bit is set the processor will not + /// respond to the WBINVD instruction or the assertion of the FLUSH# input. + /// + UINT32 L2Enabled:1; + UINT32 Reserved2:14; + /// + /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. + /// + UINT32 L2NotPresent:1; + UINT32 Reserved3:8; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_BBL_CR_CTL3_REGISTER; + + +/** + Unique. + + @param ECX MSR_CORE_THERM2_CTL (0x0000019D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_THERM2_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_THERM2_CTL_REGISTER. + + Example usage + @code + MSR_CORE_THERM2_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_THERM2_CTL); + AsmWriteMsr64 (MSR_CORE_THERM2_CTL, Msr.Uint64); + @endcode + @note MSR_CORE_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. +**/ +#define MSR_CORE_THERM2_CTL 0x0000019D + +/** + MSR information returned for MSR index #MSR_CORE_THERM2_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = + /// Thermal Monitor 1 (thermally-initiated on-die modulation of the + /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated + /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is + /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 will be enabled. + /// + UINT32 TM_SELECT:1; + UINT32 Reserved2:15; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_THERM2_CTL_REGISTER; + + +/** + Enable Miscellaneous Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_CORE_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_CORE_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_CORE_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_CORE_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_CORE_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_CORE_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:3; + /// + /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:2; + /// + /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by + /// the processor to indicate a pending break event within the processor 0 + /// = Indicates compatible FERR# signaling behavior This bit must be set + /// to 1 to support XAPIC interrupt model usage. + /// + UINT32 FERR:1; + /// + /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + UINT32 Reserved4:1; + /// + /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the + /// thermal sensor indicates that the die temperature is at the + /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. + /// TM2 will reduce the bus to core ratio and voltage according to the + /// value last written to MSR_THERM2_CTL bits 15:0. When this bit is clear + /// (0, default), the processor does not change the VID signals or the bus + /// to core ratio when the processor enters a thermal managed state. If + /// the TM2 feature flag (ECX[8]) is not set to 1 after executing CPUID + /// with EAX = 1, then this feature is not supported and BIOS must not + /// alter the contents of this bit location. The processor is operating + /// out of spec if both this bit and the TM1 bit are set to disabled + /// states. + /// + UINT32 TM2:1; + UINT32 Reserved5:2; + /// + /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) 1 = + /// Enhanced Intel SpeedStep Technology enabled. + /// + UINT32 EIST:1; + UINT32 Reserved6:1; + /// + /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved7:1; + UINT32 Reserved8:2; + /// + /// [Bit 22] Shared. Limit CPUID Maxval (R/W) See Table 35-2. Setting this + /// bit may cause behavior in software that depends on the availability of + /// CPUID leaves greater than 2. + /// + UINT32 LimitCpuidMaxval:1; + UINT32 Reserved9:9; + UINT32 Reserved10:2; + /// + /// [Bit 34] Shared. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved11:29; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_IA32_MISC_ENABLE_REGISTER; + + +/** + Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) + that points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP (at 40H). + + @param ECX MSR_CORE_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_CORE_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_CORE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_CORE_LASTBRANCH_TOS 0x000001C9 + + +/** + Unique. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_CORE_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_LER_FROM_LIP); + @endcode + @note MSR_CORE_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_CORE_LER_FROM_LIP 0x000001DD + + +/** + Unique. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_CORE_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_LER_TO_LIP); + @endcode + @note MSR_CORE_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_CORE_LER_TO_LIP 0x000001DE + + +/** + Unique. + + @param ECX MSR_CORE_ROB_CR_BKUPTMPDR6 (0x000001E0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER. + + Example usage + @code + MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_ROB_CR_BKUPTMPDR6); + AsmWriteMsr64 (MSR_CORE_ROB_CR_BKUPTMPDR6, Msr.Uint64); + @endcode + @note MSR_CORE_ROB_CR_BKUPTMPDR6 is defined as ROB_CR_BKUPTMPDR6 in SDM. +**/ +#define MSR_CORE_ROB_CR_BKUPTMPDR6 0x000001E0 + +/** + MSR information returned for MSR index #MSR_CORE_ROB_CR_BKUPTMPDR6 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:2; + /// + /// [Bit 2] Fast Strings Enable bit. (Default, enabled). + /// + UINT32 FastStrings:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER; + + +/** + Unique. + + @param ECX MSR_CORE_MTRRPHYSBASEn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRPHYSBASE0); + AsmWriteMsr64 (MSR_CORE_MTRRPHYSBASE0, Msr); + @endcode + @note MSR_CORE_MTRRPHYSBASE0 is defined as MTRRPHYSBASE0 in SDM. + MSR_CORE_MTRRPHYSBASE1 is defined as MTRRPHYSBASE1 in SDM. + MSR_CORE_MTRRPHYSBASE2 is defined as MTRRPHYSBASE2 in SDM. + MSR_CORE_MTRRPHYSBASE3 is defined as MTRRPHYSBASE3 in SDM. + MSR_CORE_MTRRPHYSBASE4 is defined as MTRRPHYSBASE4 in SDM. + MSR_CORE_MTRRPHYSBASE5 is defined as MTRRPHYSBASE5 in SDM. + MSR_CORE_MTRRPHYSMASK6 is defined as MTRRPHYSMASK6 in SDM. + MSR_CORE_MTRRPHYSMASK7 is defined as MTRRPHYSMASK7 in SDM. + @{ +**/ +#define MSR_CORE_MTRRPHYSBASE0 0x00000200 +#define MSR_CORE_MTRRPHYSBASE1 0x00000202 +#define MSR_CORE_MTRRPHYSBASE2 0x00000204 +#define MSR_CORE_MTRRPHYSBASE3 0x00000206 +#define MSR_CORE_MTRRPHYSBASE4 0x00000208 +#define MSR_CORE_MTRRPHYSBASE5 0x0000020A +#define MSR_CORE_MTRRPHYSMASK6 0x0000020D +#define MSR_CORE_MTRRPHYSMASK7 0x0000020F +/// @} + + +/** + Unique. + + @param ECX MSR_CORE_MTRRPHYSMASKn (0x00000201) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRPHYSMASK0); + AsmWriteMsr64 (MSR_CORE_MTRRPHYSMASK0, Msr); + @endcode + @note MSR_CORE_MTRRPHYSMASK0 is defined as MTRRPHYSMASK0 in SDM. + MSR_CORE_MTRRPHYSMASK1 is defined as MTRRPHYSMASK1 in SDM. + MSR_CORE_MTRRPHYSMASK2 is defined as MTRRPHYSMASK2 in SDM. + MSR_CORE_MTRRPHYSMASK3 is defined as MTRRPHYSMASK3 in SDM. + MSR_CORE_MTRRPHYSMASK4 is defined as MTRRPHYSMASK4 in SDM. + MSR_CORE_MTRRPHYSMASK5 is defined as MTRRPHYSMASK5 in SDM. + MSR_CORE_MTRRPHYSBASE6 is defined as MTRRPHYSBASE6 in SDM. + MSR_CORE_MTRRPHYSBASE7 is defined as MTRRPHYSBASE7 in SDM. + @{ +**/ +#define MSR_CORE_MTRRPHYSMASK0 0x00000201 +#define MSR_CORE_MTRRPHYSMASK1 0x00000203 +#define MSR_CORE_MTRRPHYSMASK2 0x00000205 +#define MSR_CORE_MTRRPHYSMASK3 0x00000207 +#define MSR_CORE_MTRRPHYSMASK4 0x00000209 +#define MSR_CORE_MTRRPHYSMASK5 0x0000020B +#define MSR_CORE_MTRRPHYSBASE6 0x0000020C +#define MSR_CORE_MTRRPHYSBASE7 0x0000020E +/// @} + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX64K_00000 (0x00000250) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX64K_00000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX64K_00000, Msr); + @endcode + @note MSR_CORE_MTRRFIX64K_00000 is defined as MTRRFIX64K_00000 in SDM. +**/ +#define MSR_CORE_MTRRFIX64K_00000 0x00000250 + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX16K_80000 (0x00000258) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX16K_80000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX16K_80000, Msr); + @endcode + @note MSR_CORE_MTRRFIX16K_80000 is defined as MTRRFIX16K_80000 in SDM. +**/ +#define MSR_CORE_MTRRFIX16K_80000 0x00000258 + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX16K_A0000 (0x00000259) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX16K_A0000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX16K_A0000, Msr); + @endcode + @note MSR_CORE_MTRRFIX16K_A0000 is defined as MTRRFIX16K_A0000 in SDM. +**/ +#define MSR_CORE_MTRRFIX16K_A0000 0x00000259 + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_C0000 (0x00000268) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_C0000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_C0000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_C0000 is defined as MTRRFIX4K_C0000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_C0000 0x00000268 + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_C8000 (0x00000269) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_C8000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_C8000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_C8000 is defined as MTRRFIX4K_C8000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_C8000 0x00000269 + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_D0000 (0x0000026A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_D0000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_D0000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_D0000 is defined as MTRRFIX4K_D0000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_D0000 0x0000026A + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_D8000 (0x0000026B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_D8000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_D8000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_D8000 is defined as MTRRFIX4K_D8000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_D8000 0x0000026B + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_E0000 (0x0000026C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_E0000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_E0000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_E0000 is defined as MTRRFIX4K_E0000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_E0000 0x0000026C + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_E8000 (0x0000026D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_E8000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_E8000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_E8000 is defined as MTRRFIX4K_E8000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_E8000 0x0000026D + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_F0000 (0x0000026E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_F0000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_F0000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_F0000 is defined as MTRRFIX4K_F0000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_F0000 0x0000026E + + +/** + Unique. + + @param ECX MSR_CORE_MTRRFIX4K_F8000 (0x0000026F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_F8000); + AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_F8000, Msr); + @endcode + @note MSR_CORE_MTRRFIX4K_F8000 is defined as MTRRFIX4K_F8000 in SDM. +**/ +#define MSR_CORE_MTRRFIX4K_F8000 0x0000026F + + +/** + Unique. See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". + + @param ECX MSR_CORE_MC4_CTL (0x0000040C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC4_CTL); + AsmWriteMsr64 (MSR_CORE_MC4_CTL, Msr); + @endcode + @note MSR_CORE_MC4_CTL is defined as MSR_MC4_CTL in SDM. +**/ +#define MSR_CORE_MC4_CTL 0x0000040C + + +/** + Unique. See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". + + @param ECX MSR_CORE_MC4_STATUS (0x0000040D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC4_STATUS); + AsmWriteMsr64 (MSR_CORE_MC4_STATUS, Msr); + @endcode + @note MSR_CORE_MC4_STATUS is defined as MSR_MC4_STATUS in SDM. +**/ +#define MSR_CORE_MC4_STATUS 0x0000040D + + +/** + Unique. See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC4_ADDR + register is either not implemented or contains no address if the ADDRV flag + in the MSR_MC4_STATUS register is clear. When not implemented in the + processor, all reads and writes to this MSR will cause a general-protection + exception. + + @param ECX MSR_CORE_MC4_ADDR (0x0000040E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC4_ADDR); + AsmWriteMsr64 (MSR_CORE_MC4_ADDR, Msr); + @endcode + @note MSR_CORE_MC4_ADDR is defined as MSR_MC4_ADDR in SDM. +**/ +#define MSR_CORE_MC4_ADDR 0x0000040E + + +/** + Unique. See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC3_ADDR + register is either not implemented or contains no address if the ADDRV flag + in the MSR_MC3_STATUS register is clear. When not implemented in the + processor, all reads and writes to this MSR will cause a general-protection + exception. + + @param ECX MSR_CORE_MC3_ADDR (0x00000412) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC3_ADDR); + AsmWriteMsr64 (MSR_CORE_MC3_ADDR, Msr); + @endcode + @note MSR_CORE_MC3_ADDR is defined as MSR_MC3_ADDR in SDM. +**/ +#define MSR_CORE_MC3_ADDR 0x00000412 + + +/** + Unique. + + @param ECX MSR_CORE_MC3_MISC (0x00000413) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC3_MISC); + AsmWriteMsr64 (MSR_CORE_MC3_MISC, Msr); + @endcode + @note MSR_CORE_MC3_MISC is defined as MSR_MC3_MISC in SDM. +**/ +#define MSR_CORE_MC3_MISC 0x00000413 + + +/** + Unique. + + @param ECX MSR_CORE_MC5_CTL (0x00000414) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC5_CTL); + AsmWriteMsr64 (MSR_CORE_MC5_CTL, Msr); + @endcode + @note MSR_CORE_MC5_CTL is defined as MSR_MC5_CTL in SDM. +**/ +#define MSR_CORE_MC5_CTL 0x00000414 + + +/** + Unique. + + @param ECX MSR_CORE_MC5_STATUS (0x00000415) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC5_STATUS); + AsmWriteMsr64 (MSR_CORE_MC5_STATUS, Msr); + @endcode + @note MSR_CORE_MC5_STATUS is defined as MSR_MC5_STATUS in SDM. +**/ +#define MSR_CORE_MC5_STATUS 0x00000415 + + +/** + Unique. + + @param ECX MSR_CORE_MC5_ADDR (0x00000416) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC5_ADDR); + AsmWriteMsr64 (MSR_CORE_MC5_ADDR, Msr); + @endcode + @note MSR_CORE_MC5_ADDR is defined as MSR_MC5_ADDR in SDM. +**/ +#define MSR_CORE_MC5_ADDR 0x00000416 + + +/** + Unique. + + @param ECX MSR_CORE_MC5_MISC (0x00000417) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_CORE_MC5_MISC); + AsmWriteMsr64 (MSR_CORE_MC5_MISC, Msr); + @endcode + @note MSR_CORE_MC5_MISC is defined as MSR_MC5_MISC in SDM. +**/ +#define MSR_CORE_MC5_MISC 0x00000417 + + +/** + Unique. See Table 35-2. + + @param ECX MSR_CORE_IA32_EFER (0xC0000080) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_CORE_IA32_EFER_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_CORE_IA32_EFER_REGISTER. + + Example usage + @code + MSR_CORE_IA32_EFER_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_CORE_IA32_EFER); + AsmWriteMsr64 (MSR_CORE_IA32_EFER, Msr.Uint64); + @endcode + @note MSR_CORE_IA32_EFER is defined as IA32_EFER in SDM. +**/ +#define MSR_CORE_IA32_EFER 0xC0000080 + +/** + MSR information returned for MSR index #MSR_CORE_IA32_EFER +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:11; + /// + /// [Bit 11] Execute Disable Bit Enable. + /// + UINT32 NXE:1; + UINT32 Reserved2:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_CORE_IA32_EFER_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h new file mode 100644 index 0000000000..5730918ec6 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h @@ -0,0 +1,2531 @@ +/** @file + MSR Definitions for Intel Atom processors based on the Goldmont microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.5. + +**/ + +#ifndef __GOLDMONT_MSR_H__ +#define __GOLDMONT_MSR_H__ + +#include + +/** + Is Intel Atom processors based on the Goldmont microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_GOLDMONT_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x5C \ + ) \ + ) + +/** + Core. Control Features in Intel 64Processor (R/W). + + @param ECX MSR_GOLDMONT_FEATURE_CONTROL (0x0000003A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_GOLDMONT_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. +**/ +#define MSR_GOLDMONT_FEATURE_CONTROL 0x0000003A + +/** + MSR information returned for MSR index #MSR_GOLDMONT_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock bit (R/WL) + /// + UINT32 Lock:1; + /// + /// [Bit 1] Enable VMX inside SMX operation (R/WL) + /// + UINT32 EnableVmxInsideSmx:1; + /// + /// [Bit 2] Enable VMX outside SMX operation (R/WL) + /// + UINT32 EnableVmxOutsideSmx:1; + UINT32 Reserved1:5; + /// + /// [Bits 14:8] SENTER local function enables (R/WL) + /// + UINT32 SenterLocalFunctionEnables:7; + /// + /// [Bit 15] SENTER global functions enable (R/WL) + /// + UINT32 SenterGlobalEnable:1; + UINT32 Reserved2:2; + /// + /// [Bit 18] SGX global functions enable (R/WL) + /// + UINT32 SgxEnable:1; + UINT32 Reserved3:13; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_FEATURE_CONTROL_REGISTER; + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_GOLDMONT_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PLATFORM_INFO); + AsmWriteMsr64 (MSR_GOLDMONT_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_GOLDMONT_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + /// + /// [Bit 30] Package. Programmable TJ OFFSET (R/O) When set to 1, + /// indicates that MSR_TEMPERATURE_TARGET.[27:24] is valid and writable to + /// specify an temperature offset. + /// + UINT32 TJOFFSET:1; + UINT32 Reserved3:1; + UINT32 Reserved4:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved5:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PLATFORM_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. See http://biosbits.org. + + @param ECX MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type + MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type + MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power). for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 0000b: + /// No limit 0001b: C1 0010b: C3 0011b: C6 0100b: C7 0101b: C7S 0110b: C8 + /// 0111b: C9 1000b: C10. + /// + UINT32 Limit:4; + UINT32 Reserved1:6; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map + /// IO_read instructions sent to IO register specified by + /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register + /// until next reset. + /// + UINT32 CFGLock:1; + UINT32 Reserved3:16; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Core. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability Enhancement. + Accessible only while in SMM. + + @param ECX MSR_GOLDMONT_SMM_MCA_CAP (0x0000017D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_MCA_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_MCA_CAP_REGISTER. + + Example usage + @code + MSR_GOLDMONT_SMM_MCA_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_MCA_CAP); + AsmWriteMsr64 (MSR_GOLDMONT_SMM_MCA_CAP, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. +**/ +#define MSR_GOLDMONT_SMM_MCA_CAP 0x0000017D + +/** + MSR information returned for MSR index #MSR_GOLDMONT_SMM_MCA_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:26; + /// + /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the + /// SMM code access restriction is supported and the + /// MSR_SMM_FEATURE_CONTROL is supported. + /// + UINT32 SMM_Code_Access_Chk:1; + /// + /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the + /// SMM long flow indicator is supported and the MSR_SMM_DELAYED is + /// supported. + /// + UINT32 Long_Flow_Indication:1; + UINT32 Reserved3:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_SMM_MCA_CAP_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_GOLDMONT_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_GOLDMONT_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Package. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. Default value is 1. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Core. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:3; + /// + /// [Bit 11] Core. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Core. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + UINT32 Reserved4:3; + /// + /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] Core. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved6:3; + /// + /// [Bit 22] Core. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Package. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] Core. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved9:3; + /// + /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors + /// that support Intel Turbo Boost Technology, the turbo mode feature is + /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: + /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: + /// EAX[1] reports the processor's support of turbo mode is enabled. Note: + /// the power-on default value is used by BIOS to detect hardware support + /// of turbo mode. If power-on default value is 1, turbo mode is available + /// in the processor. If power-on default value is 0, turbo mode is not + /// available. + /// + UINT32 TurboModeDisable:1; + UINT32 Reserved10:25; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER; + + +/** + Miscellaneous Feature Control (R/W). + + @param ECX MSR_GOLDMONT_MISC_FEATURE_CONTROL (0x000001A4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_MISC_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_GOLDMONT_MISC_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. +**/ +#define MSR_GOLDMONT_MISC_FEATURE_CONTROL 0x000001A4 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_MISC_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the + /// L2 hardware prefetcher, which fetches additional lines of code or data + /// into the L2 cache. + /// + UINT32 L2HardwarePrefetcherDisable:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables + /// the L1 data cache prefetcher, which fetches the next cache line into + /// L1 data cache. + /// + UINT32 DCUHardwarePrefetcherDisable:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER; + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_GOLDMONT_MISC_PWR_MGMT (0x000001AA) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER. + + Example usage + @code + MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_MISC_PWR_MGMT); + AsmWriteMsr64 (MSR_GOLDMONT_MISC_PWR_MGMT, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. +**/ +#define MSR_GOLDMONT_MISC_PWR_MGMT 0x000001AA + +/** + MSR information returned for MSR index #MSR_GOLDMONT_MISC_PWR_MGMT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] EIST Hardware Coordination Disable (R/W) When 0, enables + /// hardware coordination of Enhanced Intel Speedstep Technology request + /// from processor cores; When 1, disables hardware coordination of + /// Enhanced Intel Speedstep Technology requests. + /// + UINT32 EISTHardwareCoordinationDisable:1; + UINT32 Reserved1:21; + /// + /// [Bit 22] Thermal Interrupt Coordination Enable (R/W) If set, then + /// thermal interrupt on one core is routed to all cores. + /// + UINT32 ThermalInterruptCoordinationEnable:1; + UINT32 Reserved2:9; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode by Core Groups (RW) Specifies + Maximum Ratio Limit for each Core Group. Max ratio for groups with more + cores must decrease monotonically. For groups with less than 4 cores, the + max ratio must be 32 or less. For groups with 4-5 cores, the max ratio must + be 22 or less. For groups with more than 5 cores, the max ratio must be 16 + or less.. + + @param ECX MSR_GOLDMONT_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_RATIO_LIMIT); + AsmWriteMsr64 (MSR_GOLDMONT_TURBO_RATIO_LIMIT, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_GOLDMONT_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_GOLDMONT_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for Active cores in Group 0 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 0 threshold. + /// + UINT32 MaxRatioLimitGroup0:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for Active cores in Group 1 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 1 threshold and greater than Group 0 threshold. + /// + UINT32 MaxRatioLimitGroup1:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for Active cores in Group 2 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 2 threshold and greater than Group 1 threshold. + /// + UINT32 MaxRatioLimitGroup2:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for Active cores in Group 3 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 3 threshold and greater than Group 2 threshold. + /// + UINT32 MaxRatioLimitGroup3:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for Active cores in Group 4 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 4 threshold and greater than Group 3 threshold. + /// + UINT32 MaxRatioLimitGroup4:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for Active cores in Group 5 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 5 threshold and greater than Group 4 threshold. + /// + UINT32 MaxRatioLimitGroup5:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for Active cores in Group 6 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 6 threshold and greater than Group 5 threshold. + /// + UINT32 MaxRatioLimitGroup6:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for Active cores in Group 7 + /// Maximum turbo ratio limit when number of active cores is less or equal + /// to Group 7 threshold and greater than Group 6 threshold. + /// + UINT32 MaxRatioLimitGroup7:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. Group Size of Active Cores for Turbo Mode Operation (RW) Writes of + 0 threshold is ignored. + + @param ECX MSR_GOLDMONT_TURBO_GROUP_CORECNT (0x000001AE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER. + + Example usage + @code + MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_GROUP_CORECNT); + AsmWriteMsr64 (MSR_GOLDMONT_TURBO_GROUP_CORECNT, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_TURBO_GROUP_CORECNT is defined as MSR_TURBO_GROUP_CORECNT in SDM. +**/ +#define MSR_GOLDMONT_TURBO_GROUP_CORECNT 0x000001AE + +/** + MSR information returned for MSR index #MSR_GOLDMONT_TURBO_GROUP_CORECNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Group 0 Core Count Threshold Maximum number of + /// active cores to operate under Group 0 Max Turbo Ratio limit. + /// + UINT32 CoreCountThresholdGroup0:8; + /// + /// [Bits 15:8] Package. Group 1 Core Count Threshold Maximum number of + /// active cores to operate under Group 1 Max Turbo Ratio limit. Must be + /// greater than Group 0 Core Count. + /// + UINT32 CoreCountThresholdGroup1:8; + /// + /// [Bits 23:16] Package. Group 2 Core Count Threshold Maximum number of + /// active cores to operate under Group 2 Max Turbo Ratio limit. Must be + /// greater than Group 1 Core Count. + /// + UINT32 CoreCountThresholdGroup2:8; + /// + /// [Bits 31:24] Package. Group 3 Core Count Threshold Maximum number of + /// active cores to operate under Group 3 Max Turbo Ratio limit. Must be + /// greater than Group 2 Core Count. + /// + UINT32 CoreCountThresholdGroup3:8; + /// + /// [Bits 39:32] Package. Group 4 Core Count Threshold Maximum number of + /// active cores to operate under Group 4 Max Turbo Ratio limit. Must be + /// greater than Group 3 Core Count. + /// + UINT32 CoreCountThresholdGroup4:8; + /// + /// [Bits 47:40] Package. Group 5 Core Count Threshold Maximum number of + /// active cores to operate under Group 5 Max Turbo Ratio limit. Must be + /// greater than Group 4 Core Count. + /// + UINT32 CoreCountThresholdGroup5:8; + /// + /// [Bits 55:48] Package. Group 6 Core Count Threshold Maximum number of + /// active cores to operate under Group 6 Max Turbo Ratio limit. Must be + /// greater than Group 5 Core Count. + /// + UINT32 CoreCountThresholdGroup6:8; + /// + /// [Bits 63:56] Package. Group 7 Core Count Threshold Maximum number of + /// active cores to operate under Group 7 Max Turbo Ratio limit. Must be + /// greater than Group 6 Core Count and not less than the total number of + /// processor cores in the package. E.g. specify 255. + /// + UINT32 CoreCountThresholdGroup7:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER; + + +/** + Core. Last Branch Record Filtering Select Register (R/W) See Section + 17.7.2, "Filtering of Last Branch Records.". + + @param ECX MSR_GOLDMONT_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LBR_SELECT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LBR_SELECT_REGISTER. + + Example usage + @code + MSR_GOLDMONT_LBR_SELECT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LBR_SELECT); + AsmWriteMsr64 (MSR_GOLDMONT_LBR_SELECT, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_GOLDMONT_LBR_SELECT 0x000001C8 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_LBR_SELECT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CPL_EQ_0. + /// + UINT32 CPL_EQ_0:1; + /// + /// [Bit 1] CPL_NEQ_0. + /// + UINT32 CPL_NEQ_0:1; + /// + /// [Bit 2] JCC. + /// + UINT32 JCC:1; + /// + /// [Bit 3] NEAR_REL_CALL. + /// + UINT32 NEAR_REL_CALL:1; + /// + /// [Bit 4] NEAR_IND_CALL. + /// + UINT32 NEAR_IND_CALL:1; + /// + /// [Bit 5] NEAR_RET. + /// + UINT32 NEAR_RET:1; + /// + /// [Bit 6] NEAR_IND_JMP. + /// + UINT32 NEAR_IND_JMP:1; + /// + /// [Bit 7] NEAR_REL_JMP. + /// + UINT32 NEAR_REL_JMP:1; + /// + /// [Bit 8] FAR_BRANCH. + /// + UINT32 FAR_BRANCH:1; + /// + /// [Bit 9] EN_CALL_STACK. + /// + UINT32 EN_CALL_STACK:1; + UINT32 Reserved1:22; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_LBR_SELECT_REGISTER; + + +/** + Core. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-4) that + points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP. + + @param ECX MSR_GOLDMONT_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_GOLDMONT_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_GOLDMONT_LASTBRANCH_TOS 0x000001C9 + + +/** + Core. Power Control Register. See http://biosbits.org. + + @param ECX MSR_GOLDMONT_POWER_CTL (0x000001FC) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_POWER_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_POWER_CTL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_POWER_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_POWER_CTL); + AsmWriteMsr64 (MSR_GOLDMONT_POWER_CTL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_POWER_CTL is defined as MSR_POWER_CTL in SDM. +**/ +#define MSR_GOLDMONT_POWER_CTL 0x000001FC + +/** + MSR information returned for MSR index #MSR_GOLDMONT_POWER_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Package. C1E Enable (R/W) When set to '1', will enable the + /// CPU to switch to the Minimum Enhanced Intel SpeedStep Technology + /// operating point when all execution cores enter MWAIT (C1). + /// + UINT32 C1EEnable:1; + UINT32 Reserved2:30; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_POWER_CTL_REGISTER; + + +/** + Package. Lower 64 Bit OwnerEpoch Component of SGX Key (RO). Low 64 bits of + an 128-bit external entropy value for key derivation of an enclave. + + @param ECX MSR_GOLDMONT_SGXOWNER0 (0x00000300) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_SGXOWNER0); + @endcode + @note MSR_GOLDMONT_SGXOWNER0 is defined as MSR_SGXOWNER0 in SDM. +**/ +#define MSR_GOLDMONT_SGXOWNER0 0x00000300 + + +/** + Package. Upper 64 Bit OwnerEpoch Component of SGX Key (RO). Upper 64 bits of + an 128-bit external entropy value for key derivation of an enclave. + + @param ECX MSR_GOLDMONT_SGXOWNER1 (0x00000301) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_SGXOWNER1); + @endcode + @note MSR_GOLDMONT_SGXOWNER1 is defined as MSR_SGXOWNER1 in SDM. +**/ +#define MSR_GOLDMONT_SGXOWNER1 0x00000301 + + +/** + Core. See Table 35-2. See Section 18.2.4, "Architectural Performance + Monitoring Version 4.". + + @param ECX MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. +**/ +#define MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 + +/** + MSR information returned for MSR index + #MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Set 1 to clear Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Set 1 to clear Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Set 1 to clear Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Set 1 to clear Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Set 1 to clear Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Set 1 to clear Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Set 1 to clear Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Set 1 to clear Trace_ToPA_PMI. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] Set 1 to clear LBR_Frz. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Set 1 to clear CTR_Frz. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Set 1 to clear ASCI. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Set 1 to clear Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Set 1 to clear Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + /// + /// [Bit 63] Set 1 to clear CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; + + +/** + Core. See Table 35-2. See Section 18.2.4, "Architectural Performance + Monitoring Version 4.". + + @param ECX MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. +**/ +#define MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 + +/** + MSR information returned for MSR index + #MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Set 1 to cause Ovf_PMC0 = 1. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Set 1 to cause Ovf_PMC1 = 1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Set 1 to cause Ovf_PMC2 = 1. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Set 1 to cause Ovf_PMC3 = 1. + /// + UINT32 Ovf_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Set 1 to cause Ovf_FixedCtr0 = 1. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Set 1 to cause Ovf_FixedCtr1 = 1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Set 1 to cause Ovf_FixedCtr2 = 1. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Set 1 to cause Trace_ToPA_PMI = 1. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] Set 1 to cause LBR_Frz = 1. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Set 1 to cause CTR_Frz = 1. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Set 1 to cause ASCI = 1. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Set 1 to cause Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Set 1 to cause Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + UINT32 Reserved4:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; + + +/** + Core. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling + (PEBS).". + + @param ECX MSR_GOLDMONT_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PEBS_ENABLE); + AsmWriteMsr64 (MSR_GOLDMONT_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_GOLDMONT_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS trigger and recording for the programmed event + /// (precise or otherwise) on IA32_PMC0. (R/W). + /// + UINT32 Enable:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PEBS_ENABLE_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_GOLDMONT_PKG_C3_RESIDENCY (0x000003F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C3_RESIDENCY); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_C3_RESIDENCY, Msr); + @endcode + @note MSR_GOLDMONT_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. +**/ +#define MSR_GOLDMONT_PKG_C3_RESIDENCY 0x000003F8 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C6 states. Count at the same frequency as the TSC. + + @param ECX MSR_GOLDMONT_PKG_C6_RESIDENCY (0x000003F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_GOLDMONT_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_GOLDMONT_PKG_C6_RESIDENCY 0x000003F9 + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_GOLDMONT_CORE_C3_RESIDENCY (0x000003FC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_CORE_C3_RESIDENCY); + AsmWriteMsr64 (MSR_GOLDMONT_CORE_C3_RESIDENCY, Msr); + @endcode + @note MSR_GOLDMONT_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. +**/ +#define MSR_GOLDMONT_CORE_C3_RESIDENCY 0x000003FC + + +/** + Package. Enhanced SMM Feature Control (SMM-RW) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_GOLDMONT_SMM_FEATURE_CONTROL (0x000004E0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_GOLDMONT_SMM_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_SMM_FEATURE_CONTROL is defined as MSR_SMM_FEATURE_CONTROL in SDM. +**/ +#define MSR_GOLDMONT_SMM_FEATURE_CONTROL 0x000004E0 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_SMM_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock (SMM-RWO) When set to '1' locks this register from + /// further changes. + /// + UINT32 Lock:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] SMM_Code_Chk_En (SMM-RW) This control bit is available only if + /// MSR_SMM_MCA_CAP[58] == 1. When set to '0' (default) none of the + /// logical processors are prevented from executing SMM code outside the + /// ranges defined by the SMRR. When set to '1' any logical processor in + /// the package that attempts to execute SMM code not within the ranges + /// defined by the SMRR will assert an unrecoverable MCE. + /// + UINT32 SMM_Code_Chk_En:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER; + + +/** + Package. SMM Delayed (SMM-RO) Reports the interruptible state of all logical + processors in the package. Available only while in SMM and + MSR_SMM_MCA_CAP[LONG_FLOW_INDICATION] == 1. + + @param ECX MSR_GOLDMONT_SMM_DELAYED (0x000004E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_DELAYED_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_DELAYED_REGISTER. + + Example usage + @code + MSR_GOLDMONT_SMM_DELAYED_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_DELAYED); + AsmWriteMsr64 (MSR_GOLDMONT_SMM_DELAYED, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_SMM_DELAYED is defined as MSR_SMM_DELAYED in SDM. +**/ +#define MSR_GOLDMONT_SMM_DELAYED 0x000004E2 + + +/** + Package. SMM Blocked (SMM-RO) Reports the blocked state of all logical + processors in the package. Available only while in SMM. + + @param ECX MSR_GOLDMONT_SMM_BLOCKED (0x000004E3) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_BLOCKED_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_SMM_BLOCKED_REGISTER. + + Example usage + @code + MSR_GOLDMONT_SMM_BLOCKED_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_BLOCKED); + AsmWriteMsr64 (MSR_GOLDMONT_SMM_BLOCKED, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_SMM_BLOCKED is defined as MSR_SMM_BLOCKED in SDM. +**/ +#define MSR_GOLDMONT_SMM_BLOCKED 0x000004E3 + + +/** + Core. Trace Control Register (R/W). + + @param ECX MSR_GOLDMONT_IA32_RTIT_CTL (0x00000570) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_RTIT_CTL); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_RTIT_CTL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_RTIT_CTL is defined as IA32_RTIT_CTL in SDM. +**/ +#define MSR_IA32_RTIT_CTL 0x00000570 + +/** + MSR information returned for MSR index #MSR_IA32_RTIT_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] TraceEn. + /// + UINT32 TraceEn:1; + /// + /// [Bit 1] CYCEn. + /// + UINT32 CYCEn:1; + /// + /// [Bit 2] OS. + /// + UINT32 OS:1; + /// + /// [Bit 3] User. + /// + UINT32 User:1; + UINT32 Reserved1:3; + /// + /// [Bit 7] CR3 filter. + /// + UINT32 CR3:1; + /// + /// [Bit 8] ToPA. Writing 0 will #GP if also setting TraceEn. + /// + UINT32 ToPA:1; + /// + /// [Bit 9] MTCEn. + /// + UINT32 MTCEn:1; + /// + /// [Bit 10] TSCEn. + /// + UINT32 TSCEn:1; + /// + /// [Bit 11] DisRETC. + /// + UINT32 DisRETC:1; + UINT32 Reserved2:1; + /// + /// [Bit 13] BranchEn. + /// + UINT32 BranchEn:1; + /// + /// [Bits 17:14] MTCFreq. + /// + UINT32 MTCFreq:4; + UINT32 Reserved3:1; + /// + /// [Bits 22:19] CYCThresh. + /// + UINT32 CYCThresh:4; + UINT32 Reserved4:1; + /// + /// [Bits 27:24] PSBFreq. + /// + UINT32 PSBFreq:4; + UINT32 Reserved5:4; + /// + /// [Bits 35:32] ADDR0_CFG. + /// + UINT32 ADDR0_CFG:4; + /// + /// [Bits 39:36] ADDR1_CFG. + /// + UINT32 ADDR1_CFG:4; + UINT32 Reserved6:24; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER; + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, + "RAPL Interfaces.". + + @param ECX MSR_GOLDMONT_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_RAPL_POWER_UNIT); + @endcode + @note MSR_GOLDMONT_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_GOLDMONT_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Power Units. Power related information (in Watts) is in + /// unit of, 1W/2^PU; where PU is an unsigned integer represented by bits + /// 3:0. Default value is 1000b, indicating power unit is in 3.9 + /// milliWatts increment. + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Energy Status Units. Energy related information (in + /// Joules) is in unit of, 1Joule/ (2^ESU); where ESU is an unsigned + /// integer represented by bits 12:8. Default value is 01110b, indicating + /// energy unit is in 61 microJoules. + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Time Unit. Time related information (in seconds) is in + /// unit of, 1S/2^TU; where TU is an unsigned integer represented by bits + /// 19:16. Default value is 1010b, indicating power unit is in 0.977 + /// millisecond. + /// + UINT32 TimeUnit:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. Package C3 Interrupt Response Limit (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. + + @param ECX MSR_GOLDMONT_PKGC3_IRTL (0x0000060A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC3_IRTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC3_IRTL_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PKGC3_IRTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC3_IRTL); + AsmWriteMsr64 (MSR_GOLDMONT_PKGC3_IRTL, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PKGC3_IRTL is defined as MSR_PKGC3_IRTL in SDM. +**/ +#define MSR_GOLDMONT_PKGC3_IRTL 0x0000060A + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PKGC3_IRTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C3 state. + /// + UINT32 InterruptResponseTimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. See Table 35-18 for + /// supported time unit encodings. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PKGC3_IRTL_REGISTER; + + +/** + Package. Package C6/C7S Interrupt Response Limit 1 (R/W) This MSR defines + the interrupt response time limit used by the processor to manage transition + to package C6 or C7S state. Note: C-state values are processor specific + C-state code names, unrelated to MWAIT extension C-state parameters or ACPI + CStates. + + @param ECX MSR_GOLDMONT_PKGC_IRTL1 (0x0000060B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC_IRTL1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC_IRTL1_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PKGC_IRTL1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC_IRTL1); + AsmWriteMsr64 (MSR_GOLDMONT_PKGC_IRTL1, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PKGC_IRTL1 is defined as MSR_PKGC_IRTL1 in SDM. +**/ +#define MSR_GOLDMONT_PKGC_IRTL1 0x0000060B + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PKGC_IRTL1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C6 or C7S state. + /// + UINT32 InterruptResponseTimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. See Table 35-18 for + /// supported time unit encodings. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PKGC_IRTL1_REGISTER; + + +/** + Package. Package C7 Interrupt Response Limit 2 (R/W) This MSR defines the + interrupt response time limit used by the processor to manage transition to + package C7 state. Note: C-state values are processor specific C-state code + names, unrelated to MWAIT extension C-state parameters or ACPI CStates. + + @param ECX MSR_GOLDMONT_PKGC_IRTL2 (0x0000060C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC_IRTL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKGC_IRTL2_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PKGC_IRTL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC_IRTL2); + AsmWriteMsr64 (MSR_GOLDMONT_PKGC_IRTL2, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PKGC_IRTL2 is defined as MSR_PKGC_IRTL2 in SDM. +**/ +#define MSR_GOLDMONT_PKGC_IRTL2 0x0000060C + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PKGC_IRTL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C7 state. + /// + UINT32 InterruptResponseTimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. See Table 35-18 for + /// supported time unit encodings. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PKGC_IRTL2_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C2 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C2 states. Count at the same frequency as the TSC. + + @param ECX MSR_GOLDMONT_PKG_C2_RESIDENCY (0x0000060D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C2_RESIDENCY); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_C2_RESIDENCY, Msr); + @endcode + @note MSR_GOLDMONT_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. +**/ +#define MSR_GOLDMONT_PKG_C2_RESIDENCY 0x0000060D + + +/** + Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package + RAPL Domain.". + + @param ECX MSR_GOLDMONT_PKG_POWER_LIMIT (0x00000610) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_POWER_LIMIT); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_POWER_LIMIT, Msr); + @endcode + @note MSR_GOLDMONT_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. +**/ +#define MSR_GOLDMONT_PKG_POWER_LIMIT 0x00000610 + + +/** + Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_GOLDMONT_PKG_ENERGY_STATUS (0x00000611) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_ENERGY_STATUS); + @endcode + @note MSR_GOLDMONT_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. +**/ +#define MSR_GOLDMONT_PKG_ENERGY_STATUS 0x00000611 + + +/** + Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_GOLDMONT_PKG_PERF_STATUS (0x00000613) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_PERF_STATUS); + @endcode + @note MSR_GOLDMONT_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. +**/ +#define MSR_GOLDMONT_PKG_PERF_STATUS 0x00000613 + + +/** + Package. PKG RAPL Parameters (R/W). + + @param ECX MSR_GOLDMONT_PKG_POWER_INFO (0x00000614) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKG_POWER_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_PKG_POWER_INFO_REGISTER. + + Example usage + @code + MSR_GOLDMONT_PKG_POWER_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKG_POWER_INFO); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_POWER_INFO, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. +**/ +#define MSR_GOLDMONT_PKG_POWER_INFO 0x00000614 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_PKG_POWER_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Thermal Spec Power (R/W) See Section 14.9.3, "Package + /// RAPL Domain.". + /// + UINT32 ThermalSpecPower:15; + UINT32 Reserved1:1; + /// + /// [Bits 30:16] Minimum Power (R/W) See Section 14.9.3, "Package RAPL + /// Domain.". + /// + UINT32 MinimumPower:15; + UINT32 Reserved2:1; + /// + /// [Bits 46:32] Maximum Power (R/W) See Section 14.9.3, "Package RAPL + /// Domain.". + /// + UINT32 MaximumPower:15; + UINT32 Reserved3:1; + /// + /// [Bits 54:48] Maximum Time Window (R/W) Specified by 2^Y * (1.0 + + /// Z/4.0) * Time_Unit, where "Y" is the unsigned integer value + /// represented. by bits 52:48, "Z" is an unsigned integer represented by + /// bits 54:53. "Time_Unit" is specified by the "Time Units" field of + /// MSR_RAPL_POWER_UNIT. + /// + UINT32 MaximumTimeWindow:7; + UINT32 Reserved4:9; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_PKG_POWER_INFO_REGISTER; + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_GOLDMONT_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_GOLDMONT_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_GOLDMONT_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_GOLDMONT_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_GOLDMONT_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_ENERGY_STATUS); + @endcode + @note MSR_GOLDMONT_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_GOLDMONT_DRAM_ENERGY_STATUS 0x00000619 + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_GOLDMONT_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_PERF_STATUS); + @endcode + @note MSR_GOLDMONT_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_GOLDMONT_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_GOLDMONT_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_GOLDMONT_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_GOLDMONT_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_GOLDMONT_DRAM_POWER_INFO 0x0000061C + + +/** + Package. Note: C-state values are processor specific C-state code names,. + Package C10 Residency Counter. (R/O) Value since last reset that the entire + SOC is in an S0i3 state. Count at the same frequency as the TSC. + + @param ECX MSR_GOLDMONT_PKG_C10_RESIDENCY (0x00000632) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C10_RESIDENCY); + AsmWriteMsr64 (MSR_GOLDMONT_PKG_C10_RESIDENCY, Msr); + @endcode + @note MSR_GOLDMONT_PKG_C10_RESIDENCY is defined as MSR_PKG_C10_RESIDENCY in SDM. +**/ +#define MSR_GOLDMONT_PKG_C10_RESIDENCY 0x00000632 + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_GOLDMONT_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PP0_ENERGY_STATUS); + @endcode + @note MSR_GOLDMONT_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_GOLDMONT_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_GOLDMONT_PP1_ENERGY_STATUS (0x00000641) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_GOLDMONT_PP1_ENERGY_STATUS); + @endcode + @note MSR_GOLDMONT_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. +**/ +#define MSR_GOLDMONT_PP1_ENERGY_STATUS 0x00000641 + + +/** + Package. ConfigTDP Control (R/W). + + @param ECX MSR_GOLDMONT_TURBO_ACTIVATION_RATIO (0x0000064C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER. + + Example usage + @code + MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_ACTIVATION_RATIO); + AsmWriteMsr64 (MSR_GOLDMONT_TURBO_ACTIVATION_RATIO, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. +**/ +#define MSR_GOLDMONT_TURBO_ACTIVATION_RATIO 0x0000064C + +/** + MSR information returned for MSR index #MSR_GOLDMONT_TURBO_ACTIVATION_RATIO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this + /// field. + /// + UINT32 MAX_NON_TURBO_RATIO:8; + UINT32 Reserved1:23; + /// + /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the + /// content of this register is locked until a reset. + /// + UINT32 TURBO_ACTIVATION_RATIO_Lock:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER; + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS (0x0000064F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS 0x0000064F + +/** + MSR information returned for MSR index #MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is + /// reduced below the operating system request due to assertion of + /// external PROCHOT. + /// + UINT32 PROCHOTStatus:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + /// + /// [Bit 2] Package-Level Power Limiting PL1 Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL1. + /// + UINT32 PL1Status:1; + /// + /// [Bit 3] Package-Level PL2 Power Limiting Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL2. + /// + UINT32 PL2Status:1; + UINT32 Reserved1:5; + /// + /// [Bit 9] Core Power Limiting Status (R0) When set, frequency is reduced + /// below the operating system request due to domain-level power limiting. + /// + UINT32 PowerLimitingStatus:1; + /// + /// [Bit 10] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + /// + /// [Bit 11] Max Turbo Limit Status (R0) When set, frequency is reduced + /// below the operating system request due to multi-core turbo limits. + /// + UINT32 MaxTurboLimitStatus:1; + /// + /// [Bit 12] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + /// + /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency + /// is reduced below the operating system request due to Turbo transition + /// attenuation. This prevents performance degradation due to frequent + /// operating ratio changes. + /// + UINT32 TurboTransitionAttenuationStatus:1; + /// + /// [Bit 14] Maximum Efficiency Frequency Status (R0) When set, frequency + /// is reduced below the maximum efficiency frequency. + /// + UINT32 MaximumEfficiencyFrequencyStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + /// + /// [Bit 18] Package-Level PL1 Power Limiting Log When set, indicates + /// that the Package Level PL1 Power Limiting Status bit has asserted + /// since the log bit was last cleared. This log bit will remain set until + /// cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 19] Package-Level PL2 Power Limiting Log When set, indicates that + /// the Package Level PL2 Power Limiting Status bit has asserted since the + /// log bit was last cleared. This log bit will remain set until cleared + /// by software writing 0. + /// + UINT32 PL2Log:1; + UINT32 Reserved3:5; + /// + /// [Bit 25] Core Power Limiting Log When set, indicates that the Core + /// Power Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CorePowerLimitingLog:1; + /// + /// [Bit 26] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + /// + /// [Bit 27] Max Turbo Limit Log When set, indicates that the Max Turbo + /// Limit Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MaxTurboLimitLog:1; + /// + /// [Bit 28] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + /// + /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the + /// Turbo Transition Attenuation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 TurboTransitionAttenuationLog:1; + /// + /// [Bit 30] Maximum Efficiency Frequency Log When set, indicates that + /// the Maximum Efficiency Frequency Status bit has asserted since the log + /// bit was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 MaximumEfficiencyFrequencyLog:1; + UINT32 Reserved4:1; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER; + + +/** + Core. Last Branch Record n From IP (R/W) One of 32 pairs of last branch + record registers on the last branch record stack. The From_IP part of the + stack contains pointers to the source instruction . See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.6 and record format in Section + 17.4.8.1. + + @param ECX MSR_GOLDMONT_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER. + + Example usage + @code + MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_n_FROM_IP); + AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_n_FROM_IP, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_16_FROM_IP is defined as MSR_LASTBRANCH_16_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_17_FROM_IP is defined as MSR_LASTBRANCH_17_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_18_FROM_IP is defined as MSR_LASTBRANCH_18_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_19_FROM_IP is defined as MSR_LASTBRANCH_19_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_20_FROM_IP is defined as MSR_LASTBRANCH_20_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_21_FROM_IP is defined as MSR_LASTBRANCH_21_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_22_FROM_IP is defined as MSR_LASTBRANCH_22_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_23_FROM_IP is defined as MSR_LASTBRANCH_23_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_24_FROM_IP is defined as MSR_LASTBRANCH_24_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_25_FROM_IP is defined as MSR_LASTBRANCH_25_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_26_FROM_IP is defined as MSR_LASTBRANCH_26_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_27_FROM_IP is defined as MSR_LASTBRANCH_27_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_28_FROM_IP is defined as MSR_LASTBRANCH_28_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_29_FROM_IP is defined as MSR_LASTBRANCH_29_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_30_FROM_IP is defined as MSR_LASTBRANCH_30_FROM_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_31_FROM_IP is defined as MSR_LASTBRANCH_31_FROM_IP in SDM. + @{ +**/ +#define MSR_GOLDMONT_LASTBRANCH_0_FROM_IP 0x00000680 +#define MSR_GOLDMONT_LASTBRANCH_1_FROM_IP 0x00000681 +#define MSR_GOLDMONT_LASTBRANCH_2_FROM_IP 0x00000682 +#define MSR_GOLDMONT_LASTBRANCH_3_FROM_IP 0x00000683 +#define MSR_GOLDMONT_LASTBRANCH_4_FROM_IP 0x00000684 +#define MSR_GOLDMONT_LASTBRANCH_5_FROM_IP 0x00000685 +#define MSR_GOLDMONT_LASTBRANCH_6_FROM_IP 0x00000686 +#define MSR_GOLDMONT_LASTBRANCH_7_FROM_IP 0x00000687 +#define MSR_GOLDMONT_LASTBRANCH_8_FROM_IP 0x00000688 +#define MSR_GOLDMONT_LASTBRANCH_9_FROM_IP 0x00000689 +#define MSR_GOLDMONT_LASTBRANCH_10_FROM_IP 0x0000068A +#define MSR_GOLDMONT_LASTBRANCH_11_FROM_IP 0x0000068B +#define MSR_GOLDMONT_LASTBRANCH_12_FROM_IP 0x0000068C +#define MSR_GOLDMONT_LASTBRANCH_13_FROM_IP 0x0000068D +#define MSR_GOLDMONT_LASTBRANCH_14_FROM_IP 0x0000068E +#define MSR_GOLDMONT_LASTBRANCH_15_FROM_IP 0x0000068F +#define MSR_GOLDMONT_LASTBRANCH_16_FROM_IP 0x00000690 +#define MSR_GOLDMONT_LASTBRANCH_17_FROM_IP 0x00000691 +#define MSR_GOLDMONT_LASTBRANCH_18_FROM_IP 0x00000692 +#define MSR_GOLDMONT_LASTBRANCH_19_FROM_IP 0x00000693 +#define MSR_GOLDMONT_LASTBRANCH_20_FROM_IP 0x00000694 +#define MSR_GOLDMONT_LASTBRANCH_21_FROM_IP 0x00000695 +#define MSR_GOLDMONT_LASTBRANCH_22_FROM_IP 0x00000696 +#define MSR_GOLDMONT_LASTBRANCH_23_FROM_IP 0x00000697 +#define MSR_GOLDMONT_LASTBRANCH_24_FROM_IP 0x00000698 +#define MSR_GOLDMONT_LASTBRANCH_25_FROM_IP 0x00000699 +#define MSR_GOLDMONT_LASTBRANCH_26_FROM_IP 0x0000069A +#define MSR_GOLDMONT_LASTBRANCH_27_FROM_IP 0x0000069B +#define MSR_GOLDMONT_LASTBRANCH_28_FROM_IP 0x0000069C +#define MSR_GOLDMONT_LASTBRANCH_29_FROM_IP 0x0000069D +#define MSR_GOLDMONT_LASTBRANCH_30_FROM_IP 0x0000069E +#define MSR_GOLDMONT_LASTBRANCH_31_FROM_IP 0x0000069F +/// @} + +/** + MSR information returned for MSR indexes #MSR_GOLDMONT_LASTBRANCH_0_FROM_IP + to #MSR_GOLDMONT_LASTBRANCH_31_FROM_IP. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 31:0] From Linear Address (R/W). + /// + UINT32 FromLinearAddress:32; + /// + /// [Bit 47:32] From Linear Address (R/W). + /// + UINT32 FromLinearAddressHi:16; + /// + /// [Bits 62:48] Signed extension of bits 47:0. + /// + UINT32 SignedExtension:15; + /// + /// [Bit 63] Mispred. + /// + UINT32 Mispred:1; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER; + + +/** + Core. Last Branch Record n To IP (R/W) One of 32 pairs of last branch record + registers on the last branch record stack. The To_IP part of the stack + contains pointers to the Destination instruction and elapsed cycles from + last LBR update. See also: - Section 17.6. + + @param ECX MSR_GOLDMONT_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER. + + Example usage + @code + MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_0_TO_IP, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_16_TO_IP is defined as MSR_LASTBRANCH_16_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_17_TO_IP is defined as MSR_LASTBRANCH_17_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_18_TO_IP is defined as MSR_LASTBRANCH_18_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_19_TO_IP is defined as MSR_LASTBRANCH_19_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_20_TO_IP is defined as MSR_LASTBRANCH_20_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_21_TO_IP is defined as MSR_LASTBRANCH_21_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_22_TO_IP is defined as MSR_LASTBRANCH_22_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_23_TO_IP is defined as MSR_LASTBRANCH_23_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_24_TO_IP is defined as MSR_LASTBRANCH_24_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_25_TO_IP is defined as MSR_LASTBRANCH_25_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_26_TO_IP is defined as MSR_LASTBRANCH_26_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_27_TO_IP is defined as MSR_LASTBRANCH_27_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_28_TO_IP is defined as MSR_LASTBRANCH_28_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_29_TO_IP is defined as MSR_LASTBRANCH_29_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_30_TO_IP is defined as MSR_LASTBRANCH_30_TO_IP in SDM. + MSR_GOLDMONT_LASTBRANCH_31_TO_IP is defined as MSR_LASTBRANCH_31_TO_IP in SDM. + @{ +**/ +#define MSR_GOLDMONT_LASTBRANCH_0_TO_IP 0x000006C0 +#define MSR_GOLDMONT_LASTBRANCH_1_TO_IP 0x000006C1 +#define MSR_GOLDMONT_LASTBRANCH_2_TO_IP 0x000006C2 +#define MSR_GOLDMONT_LASTBRANCH_3_TO_IP 0x000006C3 +#define MSR_GOLDMONT_LASTBRANCH_4_TO_IP 0x000006C4 +#define MSR_GOLDMONT_LASTBRANCH_5_TO_IP 0x000006C5 +#define MSR_GOLDMONT_LASTBRANCH_6_TO_IP 0x000006C6 +#define MSR_GOLDMONT_LASTBRANCH_7_TO_IP 0x000006C7 +#define MSR_GOLDMONT_LASTBRANCH_8_TO_IP 0x000006C8 +#define MSR_GOLDMONT_LASTBRANCH_9_TO_IP 0x000006C9 +#define MSR_GOLDMONT_LASTBRANCH_10_TO_IP 0x000006CA +#define MSR_GOLDMONT_LASTBRANCH_11_TO_IP 0x000006CB +#define MSR_GOLDMONT_LASTBRANCH_12_TO_IP 0x000006CC +#define MSR_GOLDMONT_LASTBRANCH_13_TO_IP 0x000006CD +#define MSR_GOLDMONT_LASTBRANCH_14_TO_IP 0x000006CE +#define MSR_GOLDMONT_LASTBRANCH_15_TO_IP 0x000006CF +#define MSR_GOLDMONT_LASTBRANCH_16_TO_IP 0x000006D0 +#define MSR_GOLDMONT_LASTBRANCH_17_TO_IP 0x000006D1 +#define MSR_GOLDMONT_LASTBRANCH_18_TO_IP 0x000006D2 +#define MSR_GOLDMONT_LASTBRANCH_19_TO_IP 0x000006D3 +#define MSR_GOLDMONT_LASTBRANCH_20_TO_IP 0x000006D4 +#define MSR_GOLDMONT_LASTBRANCH_21_TO_IP 0x000006D5 +#define MSR_GOLDMONT_LASTBRANCH_22_TO_IP 0x000006D6 +#define MSR_GOLDMONT_LASTBRANCH_23_TO_IP 0x000006D7 +#define MSR_GOLDMONT_LASTBRANCH_24_TO_IP 0x000006D8 +#define MSR_GOLDMONT_LASTBRANCH_25_TO_IP 0x000006D9 +#define MSR_GOLDMONT_LASTBRANCH_26_TO_IP 0x000006DA +#define MSR_GOLDMONT_LASTBRANCH_27_TO_IP 0x000006DB +#define MSR_GOLDMONT_LASTBRANCH_28_TO_IP 0x000006DC +#define MSR_GOLDMONT_LASTBRANCH_29_TO_IP 0x000006DD +#define MSR_GOLDMONT_LASTBRANCH_30_TO_IP 0x000006DE +#define MSR_GOLDMONT_LASTBRANCH_31_TO_IP 0x000006DF +/// @} + +/** + MSR information returned for MSR indexes #MSR_GOLDMONT_LASTBRANCH_0_TO_IP to + #MSR_GOLDMONT_LASTBRANCH_31_TO_IP. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 31:0] Target Linear Address (R/W). + /// + UINT32 TargetLinearAddress:32; + /// + /// [Bit 47:32] Target Linear Address (R/W). + /// + UINT32 TargetLinearAddressHi:16; + /// + /// [Bits 63:48] Elapsed cycles from last update to the LBR. + /// + UINT32 ElapsedCycles:16; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER; + + +/** + Core. Resource Association Register (R/W). + + @param ECX MSR_GOLDMONT_IA32_PQR_ASSOC (0x00000C8F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PQR_ASSOC); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_PQR_ASSOC, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. +**/ +#define MSR_GOLDMONT_IA32_PQR_ASSOC 0x00000C8F + +/** + MSR information returned for MSR index #MSR_GOLDMONT_IA32_PQR_ASSOC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + /// + /// [Bits 33:32] COS (R/W). + /// + UINT32 COS:2; + UINT32 Reserved2:30; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER; + + +/** + Module. L2 Class Of Service Mask - COS n (R/W) if CPUID.(EAX=10H, + ECX=1):EDX.COS_MAX[15:0] >=n. + + @param ECX MSR_GOLDMONT_IA32_L2_QOS_MASK_n + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_n); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_n, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_L2_QOS_MASK_0 is defined as IA32_L2_QOS_MASK_0 in SDM. + MSR_GOLDMONT_IA32_L2_QOS_MASK_1 is defined as IA32_L2_QOS_MASK_1 in SDM. + MSR_GOLDMONT_IA32_L2_QOS_MASK_2 is defined as IA32_L2_QOS_MASK_2 in SDM. + @{ +**/ +#define MSR_GOLDMONT_IA32_L2_QOS_MASK_0 0x00000D10 +#define MSR_GOLDMONT_IA32_L2_QOS_MASK_1 0x00000D11 +#define MSR_GOLDMONT_IA32_L2_QOS_MASK_2 0x00000D12 +/// @} + +/** + MSR information returned for MSR indexes #MSR_GOLDMONT_IA32_L2_QOS_MASK_0 to + #MSR_GOLDMONT_IA32_L2_QOS_MASK_2. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] CBM: Bit vector of available L2 ways for COS 0 enforcement + /// + UINT32 CBM:8; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER; + + +/** + Package. L2 Class Of Service Mask - COS 3 (R/W) if CPUID.(EAX=10H, + ECX=1):EDX.COS_MAX[15:0] >=3. + + @param ECX MSR_GOLDMONT_IA32_L2_QOS_MASK_3 + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER. + + Example usage + @code + MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_3); + AsmWriteMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_3, Msr.Uint64); + @endcode + @note MSR_GOLDMONT_IA32_L2_QOS_MASK_3 is defined as IA32_L2_QOS_MASK_3 in SDM. +**/ +#define MSR_GOLDMONT_IA32_L2_QOS_MASK_3 0x00000D13 + +/** + MSR information returned for MSR index #MSR_GOLDMONT_IA32_L2_QOS_MASK_3. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 19:0] CBM: Bit vector of available L2 ways for COS 0 enforcement + /// + UINT32 CBM:20; + UINT32 Reserved1:12; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER; + + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h new file mode 100644 index 0000000000..b737a9e4b8 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h @@ -0,0 +1,6352 @@ +/** @file + MSR Definitions for Intel processors based on the Haswell-E microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.12. + +**/ + +#ifndef __HASWELL_E_MSR_H__ +#define __HASWELL_E_MSR_H__ + +#include + +/** + Is Intel processors based on the Haswell-E microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_HASWELL_E_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x3F \ + ) \ + ) + +/** + Package. Configured State of Enabled Processor Core Count and Logical + Processor Count (RO) - After a Power-On RESET, enumerates factory + configuration of the number of processor cores and logical processors in the + physical package. - Following the sequence of (i) BIOS modified a + Configuration Mask which selects a subset of processor cores to be active + post RESET and (ii) a RESET event after the modification, enumerates the + current configuration of enabled processor core count and logical processor + count in the physical package. + + @param ECX MSR_HASWELL_E_CORE_THREAD_COUNT (0x00000035) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER. + + Example usage + @code + MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_CORE_THREAD_COUNT); + @endcode + @note MSR_HASWELL_E_CORE_THREAD_COUNT is defined as MSR_CORE_THREAD_COUNT in SDM. +**/ +#define MSR_HASWELL_E_CORE_THREAD_COUNT 0x00000035 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_CORE_THREAD_COUNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Core_COUNT (RO) The number of processor cores that are + /// currently enabled (by either factory configuration or BIOS + /// configuration) in the physical package. + /// + UINT32 Core_Count:16; + /// + /// [Bits 31:16] THREAD_COUNT (RO) The number of logical processors that + /// are currently enabled (by either factory configuration or BIOS + /// configuration) in the physical package. + /// + UINT32 Thread_Count:16; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER; + + +/** + Thread. A Hardware Assigned ID for the Logical Processor (RO). + + @param ECX MSR_HASWELL_E_THREAD_ID_INFO (0x00000053) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_THREAD_ID_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_THREAD_ID_INFO_REGISTER. + + Example usage + @code + MSR_HASWELL_E_THREAD_ID_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_THREAD_ID_INFO); + @endcode + @note MSR_HASWELL_E_THREAD_ID_INFO is defined as MSR_THREAD_ID_INFO in SDM. +**/ +#define MSR_HASWELL_E_THREAD_ID_INFO 0x00000053 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_THREAD_ID_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Logical_Processor_ID (RO) An implementation-specific + /// numerical. value physically assigned to each logical processor. This + /// ID is not related to Initial APIC ID or x2APIC ID, it is unique within + /// a physical package. + /// + UINT32 Logical_Processor_ID:8; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_THREAD_ID_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are processor + specific C-state code names, unrelated to MWAIT extension C-state parameters + or ACPI C-states. `See http://biosbits.org. `__. + + @param ECX MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power) for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0/C1 (no package C-state support) 001b: C2 010b: C6 (non-retention) + /// 011b: C6 (retention) 111b: No Package C state limits. All C states + /// supported by the processor are available. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W). + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO). + /// + UINT32 CFGLock:1; + UINT32 Reserved3:9; + /// + /// [Bit 25] C3 State Auto Demotion Enable (R/W). + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 State Auto Demotion Enable (R/W). + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 Undemotion (R/W). + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 Undemotion (R/W). + /// + UINT32 C1Undemotion:1; + /// + /// [Bit 29] Package C State Demotion Enable (R/W). + /// + UINT32 CStateDemotion:1; + /// + /// [Bit 30] Package C State UnDemotion Enable (R/W). + /// + UINT32 CStateUndemotion:1; + UINT32 Reserved4:1; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Thread. Global Machine Check Capability (R/O). + + @param ECX MSR_HASWELL_E_IA32_MCG_CAP (0x00000179) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_MCG_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_MCG_CAP_REGISTER. + + Example usage + @code + MSR_HASWELL_E_IA32_MCG_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_MCG_CAP); + @endcode + @note MSR_HASWELL_E_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. +**/ +#define MSR_HASWELL_E_IA32_MCG_CAP 0x00000179 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_IA32_MCG_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Count. + /// + UINT32 Count:8; + /// + /// [Bit 8] MCG_CTL_P. + /// + UINT32 MCG_CTL_P:1; + /// + /// [Bit 9] MCG_EXT_P. + /// + UINT32 MCG_EXT_P:1; + /// + /// [Bit 10] MCP_CMCI_P. + /// + UINT32 MCP_CMCI_P:1; + /// + /// [Bit 11] MCG_TES_P. + /// + UINT32 MCG_TES_P:1; + UINT32 Reserved1:4; + /// + /// [Bits 23:16] MCG_EXT_CNT. + /// + UINT32 MCG_EXT_CNT:8; + /// + /// [Bit 24] MCG_SER_P. + /// + UINT32 MCG_SER_P:1; + /// + /// [Bit 25] MCG_EM_P. + /// + UINT32 MCG_EM_P:1; + /// + /// [Bit 26] MCG_ELOG_P. + /// + UINT32 MCG_ELOG_P:1; + UINT32 Reserved2:5; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_IA32_MCG_CAP_REGISTER; + + +/** + THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_HASWELL_E_SMM_MCA_CAP (0x0000017D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_SMM_MCA_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_SMM_MCA_CAP_REGISTER. + + Example usage + @code + MSR_HASWELL_E_SMM_MCA_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_SMM_MCA_CAP); + AsmWriteMsr64 (MSR_HASWELL_E_SMM_MCA_CAP, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. +**/ +#define MSR_HASWELL_E_SMM_MCA_CAP 0x0000017D + +/** + MSR information returned for MSR index #MSR_HASWELL_E_SMM_MCA_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:26; + /// + /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the + /// SMM code access restriction is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 SMM_Code_Access_Chk:1; + /// + /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the + /// SMM long flow indicator is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 Long_Flow_Indication:1; + UINT32 Reserved3:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_SMM_MCA_CAP_REGISTER; + + +/** + Package. MC Bank Error Configuration (R/W). + + @param ECX MSR_HASWELL_E_ERROR_CONTROL (0x0000017F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_ERROR_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_ERROR_CONTROL_REGISTER. + + Example usage + @code + MSR_HASWELL_E_ERROR_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_ERROR_CONTROL); + AsmWriteMsr64 (MSR_HASWELL_E_ERROR_CONTROL, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. +**/ +#define MSR_HASWELL_E_ERROR_CONTROL 0x0000017F + +/** + MSR information returned for MSR index #MSR_HASWELL_E_ERROR_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank + /// to log additional info in bits 36:32. + /// + UINT32 MemErrorLogEnable:1; + UINT32 Reserved2:30; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_ERROR_CONTROL_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT); + @endcode + @note MSR_HASWELL_E_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_HASWELL_E_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio + /// limit of 5 core active. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio + /// limit of 6 core active. + /// + UINT32 Maximum6C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio + /// limit of 7 core active. + /// + UINT32 Maximum7C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio + /// limit of 8 core active. + /// + UINT32 Maximum8C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT1 (0x000001AE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER. + + Example usage + @code + MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT1); + @endcode + @note MSR_HASWELL_E_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. +**/ +#define MSR_HASWELL_E_TURBO_RATIO_LIMIT1 0x000001AE + +/** + MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 9C Maximum turbo ratio + /// limit of 9 core active. + /// + UINT32 Maximum9C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 10C Maximum turbo ratio + /// limit of 10 core active. + /// + UINT32 Maximum10C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 11C Maximum turbo ratio + /// limit of 11 core active. + /// + UINT32 Maximum11C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 12C Maximum turbo ratio + /// limit of 12 core active. + /// + UINT32 Maximum12C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 13C Maximum turbo ratio + /// limit of 13 core active. + /// + UINT32 Maximum13C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 14C Maximum turbo ratio + /// limit of 14 core active. + /// + UINT32 Maximum14C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 15C Maximum turbo ratio + /// limit of 15 core active. + /// + UINT32 Maximum15C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for16C Maximum turbo ratio + /// limit of 16 core active. + /// + UINT32 Maximum16C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT2 (0x000001AF) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER. + + Example usage + @code + MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT2); + @endcode + @note MSR_HASWELL_E_TURBO_RATIO_LIMIT2 is defined as MSR_TURBO_RATIO_LIMIT2 in SDM. +**/ +#define MSR_HASWELL_E_TURBO_RATIO_LIMIT2 0x000001AF + +/** + MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 17C Maximum turbo ratio + /// limit of 17 core active. + /// + UINT32 Maximum17C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 18C Maximum turbo ratio + /// limit of 18 core active. + /// + UINT32 Maximum18C:8; + UINT32 Reserved1:16; + UINT32 Reserved2:31; + /// + /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, + /// the processor uses override configuration specified in + /// MSR_TURBO_RATIO_LIMIT, MSR_TURBO_RATIO_LIMIT1 and + /// MSR_TURBO_RATIO_LIMIT2. If 0, the processor uses factory-set + /// configuration (Default). + /// + UINT32 TurboRatioLimitConfigurationSemaphore:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER; + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O). + + @param ECX MSR_HASWELL_E_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_RAPL_POWER_UNIT); + @endcode + @note MSR_HASWELL_E_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_HASWELL_E_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Package. Energy Status Units Energy related information + /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an + /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 + /// micro-joules). + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL + /// Interfaces.". + /// + UINT32 TimeUnits:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_HASWELL_E_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_HASWELL_E_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_HASWELL_E_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_HASWELL_E_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) Energy Consumed by DRAM devices. + + @param ECX MSR_HASWELL_E_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER. + + Example usage + @code + MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_DRAM_ENERGY_STATUS); + @endcode + @note MSR_HASWELL_E_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_HASWELL_E_DRAM_ENERGY_STATUS 0x00000619 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_DRAM_ENERGY_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Energy in 15.3 micro-joules. Requires BIOS configuration + /// to enable DRAM RAPL mode 0 (Direct VR). + /// + UINT32 Energy:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER; + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_HASWELL_E_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_PERF_STATUS); + @endcode + @note MSR_HASWELL_E_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_HASWELL_E_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_HASWELL_E_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_HASWELL_E_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_HASWELL_E_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_HASWELL_E_DRAM_POWER_INFO 0x0000061C + + +/** + Package. Configuration of PCIE PLL Relative to BCLK(R/W). + + @param ECX MSR_HASWELL_E_PCIE_PLL_RATIO (0x0000061E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER. + + Example usage + @code + MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_PCIE_PLL_RATIO); + AsmWriteMsr64 (MSR_HASWELL_E_PCIE_PLL_RATIO, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_PCIE_PLL_RATIO is defined as MSR_PCIE_PLL_RATIO in SDM. +**/ +#define MSR_HASWELL_E_PCIE_PLL_RATIO 0x0000061E + +/** + MSR information returned for MSR index #MSR_HASWELL_E_PCIE_PLL_RATIO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] Package. PCIE Ratio (R/W) 00b: Use 5:5 mapping for100MHz + /// operation (default) 01b: Use 5:4 mapping for125MHz operation 10b: Use + /// 5:3 mapping for166MHz operation 11b: Use 5:2 mapping for250MHz + /// operation. + /// + UINT32 PCIERatio:2; + /// + /// [Bit 2] Package. LPLL Select (R/W) if 1, use configured setting of + /// PCIE Ratio. + /// + UINT32 LPLLSelect:1; + /// + /// [Bit 3] Package. LONG RESET (R/W) if 1, wait additional time-out + /// before re-locking Gen2/Gen3 PLLs. + /// + UINT32 LONGRESET:1; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER; + + +/** + Package. Reserved (R/O) Reads return 0. + + @param ECX MSR_HASWELL_E_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PP0_ENERGY_STATUS); + @endcode + @note MSR_HASWELL_E_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_HASWELL_E_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS (0x00000690) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS 0x00000690 + +/** + MSR information returned for MSR index #MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is + /// reduced below the operating system request due to assertion of + /// external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + /// + /// [Bit 2] Power Budget Management Status (R0) When set, frequency is + /// reduced below the operating system request due to PBM limit. + /// + UINT32 PowerBudgetManagementStatus:1; + /// + /// [Bit 3] Platform Configuration Services Status (R0) When set, + /// frequency is reduced below the operating system request due to PCS + /// limit. + /// + UINT32 PlatformConfigurationServicesStatus:1; + UINT32 Reserved1:1; + /// + /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) + /// When set, frequency is reduced below the operating system request + /// because the processor has detected that utilization is low. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + UINT32 Reserved3:1; + /// + /// [Bit 10] Multi-Core Turbo Status (R0) When set, frequency is reduced + /// below the operating system request due to Multi-Core Turbo limits. + /// + UINT32 MultiCoreTurboStatus:1; + UINT32 Reserved4:2; + /// + /// [Bit 13] Core Frequency P1 Status (R0) When set, frequency is reduced + /// below max non-turbo P1. + /// + UINT32 FrequencyP1Status:1; + /// + /// [Bit 14] Core Max n-core Turbo Frequency Limiting Status (R0) When + /// set, frequency is reduced below max n-core turbo frequency. + /// + UINT32 TurboFrequencyLimitingStatus:1; + /// + /// [Bit 15] Core Frequency Limiting Status (R0) When set, frequency is + /// reduced below the operating system request. + /// + UINT32 FrequencyLimitingStatus:1; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + /// + /// [Bit 18] Power Budget Management Log When set, indicates that the PBM + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 PowerBudgetManagementLog:1; + /// + /// [Bit 19] Platform Configuration Services Log When set, indicates that + /// the PCS Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 PlatformConfigurationServicesLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, + /// indicates that the AUBFC Status bit has asserted since the log bit was + /// last cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + UINT32 Reserved6:1; + /// + /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + UINT32 Reserved7:1; + /// + /// [Bit 26] Multi-Core Turbo Log When set, indicates that the Multi-Core + /// Turbo Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MultiCoreTurboLog:1; + UINT32 Reserved8:2; + /// + /// [Bit 29] Core Frequency P1 Log When set, indicates that the Core + /// Frequency P1 Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CoreFrequencyP1Log:1; + /// + /// [Bit 30] Core Max n-core Turbo Frequency Limiting Log When set, + /// indicates that the Core Max n-core Turbo Frequency Limiting Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 TurboFrequencyLimitingLog:1; + /// + /// [Bit 31] Core Frequency Limiting Log When set, indicates that the Core + /// Frequency Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CoreFrequencyLimitingLog:1; + UINT32 Reserved9:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER; + + +/** + THREAD. Monitoring Event Select Register (R/W). if CPUID.(EAX=07H, + ECX=0):EBX.RDT-M[bit 12] = 1. + + @param ECX MSR_HASWELL_E_IA32_QM_EVTSEL (0x00000C8D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER. + + Example usage + @code + MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_QM_EVTSEL); + AsmWriteMsr64 (MSR_HASWELL_E_IA32_QM_EVTSEL, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. +**/ +#define MSR_HASWELL_E_IA32_QM_EVTSEL 0x00000C8D + +/** + MSR information returned for MSR index #MSR_HASWELL_E_IA32_QM_EVTSEL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] EventID (RW) Event encoding: 0x0: no monitoring 0x1: L3 + /// occupancy monitoring all other encoding reserved.. + /// + UINT32 EventID:8; + UINT32 Reserved1:24; + /// + /// [Bits 41:32] RMID (RW). + /// + UINT32 RMID:10; + UINT32 Reserved2:22; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER; + + +/** + THREAD. Resource Association Register (R/W).. + + @param ECX MSR_HASWELL_E_IA32_PQR_ASSOC (0x00000C8F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER. + + Example usage + @code + MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_PQR_ASSOC); + AsmWriteMsr64 (MSR_HASWELL_E_IA32_PQR_ASSOC, Msr.Uint64); + @endcode + @note MSR_HASWELL_E_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. +**/ +#define MSR_HASWELL_E_IA32_PQR_ASSOC 0x00000C8F + +/** + MSR information returned for MSR index #MSR_HASWELL_E_IA32_PQR_ASSOC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] RMID. + /// + UINT32 RMID:10; + UINT32 Reserved1:22; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER; + + +/** + Package. Uncore perfmon per-socket global control. + + @param ECX MSR_HASWELL_E_PMON_GLOBAL_CTL (0x00000700) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CTL, Msr); + @endcode + @note MSR_HASWELL_E_PMON_GLOBAL_CTL is defined as MSR_PMON_GLOBAL_CTL in SDM. +**/ +#define MSR_HASWELL_E_PMON_GLOBAL_CTL 0x00000700 + + +/** + Package. Uncore perfmon per-socket global status. + + @param ECX MSR_HASWELL_E_PMON_GLOBAL_STATUS (0x00000701) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_PMON_GLOBAL_STATUS is defined as MSR_PMON_GLOBAL_STATUS in SDM. +**/ +#define MSR_HASWELL_E_PMON_GLOBAL_STATUS 0x00000701 + + +/** + Package. Uncore perfmon per-socket global configuration. + + @param ECX MSR_HASWELL_E_PMON_GLOBAL_CONFIG (0x00000702) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CONFIG); + AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CONFIG, Msr); + @endcode + @note MSR_HASWELL_E_PMON_GLOBAL_CONFIG is defined as MSR_PMON_GLOBAL_CONFIG in SDM. +**/ +#define MSR_HASWELL_E_PMON_GLOBAL_CONFIG 0x00000702 + + +/** + Package. Uncore U-box UCLK fixed counter control. + + @param ECX MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL (0x00000703) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL is defined as MSR_U_PMON_UCLK_FIXED_CTL in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL 0x00000703 + + +/** + Package. Uncore U-box UCLK fixed counter. + + @param ECX MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR (0x00000704) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR is defined as MSR_U_PMON_UCLK_FIXED_CTR in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR 0x00000704 + + +/** + Package. Uncore U-box perfmon event select for U-box counter 0. + + @param ECX MSR_HASWELL_E_U_PMON_EVNTSEL0 (0x00000705) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_EVNTSEL0 is defined as MSR_U_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_EVNTSEL0 0x00000705 + + +/** + Package. Uncore U-box perfmon event select for U-box counter 1. + + @param ECX MSR_HASWELL_E_U_PMON_EVNTSEL1 (0x00000706) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_EVNTSEL1 is defined as MSR_U_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_EVNTSEL1 0x00000706 + + +/** + Package. Uncore U-box perfmon U-box wide status. + + @param ECX MSR_HASWELL_E_U_PMON_BOX_STATUS (0x00000708) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_BOX_STATUS is defined as MSR_U_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_BOX_STATUS 0x00000708 + + +/** + Package. Uncore U-box perfmon counter 0. + + @param ECX MSR_HASWELL_E_U_PMON_CTR0 (0x00000709) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_CTR0 is defined as MSR_U_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_CTR0 0x00000709 + + +/** + Package. Uncore U-box perfmon counter 1. + + @param ECX MSR_HASWELL_E_U_PMON_CTR1 (0x0000070A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_U_PMON_CTR1 is defined as MSR_U_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_U_PMON_CTR1 0x0000070A + + +/** + Package. Uncore PCU perfmon for PCU-box-wide control. + + @param ECX MSR_HASWELL_E_PCU_PMON_BOX_CTL (0x00000710) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_BOX_CTL is defined as MSR_PCU_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_BOX_CTL 0x00000710 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 0. + + @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL0 (0x00000711) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_EVNTSEL0 is defined as MSR_PCU_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_EVNTSEL0 0x00000711 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 1. + + @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL1 (0x00000712) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_EVNTSEL1 is defined as MSR_PCU_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_EVNTSEL1 0x00000712 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 2. + + @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL2 (0x00000713) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_EVNTSEL2 is defined as MSR_PCU_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_EVNTSEL2 0x00000713 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 3. + + @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL3 (0x00000714) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_EVNTSEL3 is defined as MSR_PCU_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_EVNTSEL3 0x00000714 + + +/** + Package. Uncore PCU perfmon box-wide filter. + + @param ECX MSR_HASWELL_E_PCU_PMON_BOX_FILTER (0x00000715) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_BOX_FILTER is defined as MSR_PCU_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_BOX_FILTER 0x00000715 + + +/** + Package. Uncore PCU perfmon box wide status. + + @param ECX MSR_HASWELL_E_PCU_PMON_BOX_STATUS (0x00000716) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_BOX_STATUS is defined as MSR_PCU_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_BOX_STATUS 0x00000716 + + +/** + Package. Uncore PCU perfmon counter 0. + + @param ECX MSR_HASWELL_E_PCU_PMON_CTR0 (0x00000717) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_CTR0 is defined as MSR_PCU_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_CTR0 0x00000717 + + +/** + Package. Uncore PCU perfmon counter 1. + + @param ECX MSR_HASWELL_E_PCU_PMON_CTR1 (0x00000718) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_CTR1 is defined as MSR_PCU_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_CTR1 0x00000718 + + +/** + Package. Uncore PCU perfmon counter 2. + + @param ECX MSR_HASWELL_E_PCU_PMON_CTR2 (0x00000719) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_CTR2 is defined as MSR_PCU_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_CTR2 0x00000719 + + +/** + Package. Uncore PCU perfmon counter 3. + + @param ECX MSR_HASWELL_E_PCU_PMON_CTR3 (0x0000071A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_PCU_PMON_CTR3 is defined as MSR_PCU_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_PCU_PMON_CTR3 0x0000071A + + +/** + Package. Uncore SBo 0 perfmon for SBo 0 box-wide control. + + @param ECX MSR_HASWELL_E_S0_PMON_BOX_CTL (0x00000720) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_BOX_CTL is defined as MSR_S0_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_BOX_CTL 0x00000720 + + +/** + Package. Uncore SBo 0 perfmon event select for SBo 0 counter 0. + + @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL0 (0x00000721) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_EVNTSEL0 is defined as MSR_S0_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_EVNTSEL0 0x00000721 + + +/** + Package. Uncore SBo 0 perfmon event select for SBo 0 counter 1. + + @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL1 (0x00000722) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_EVNTSEL1 is defined as MSR_S0_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_EVNTSEL1 0x00000722 + + +/** + Package. Uncore SBo 0 perfmon event select for SBo 0 counter 2. + + @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL2 (0x00000723) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_EVNTSEL2 is defined as MSR_S0_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_EVNTSEL2 0x00000723 + + +/** + Package. Uncore SBo 0 perfmon event select for SBo 0 counter 3. + + @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL3 (0x00000724) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_EVNTSEL3 is defined as MSR_S0_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_EVNTSEL3 0x00000724 + + +/** + Package. Uncore SBo 0 perfmon box-wide filter. + + @param ECX MSR_HASWELL_E_S0_PMON_BOX_FILTER (0x00000725) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_BOX_FILTER is defined as MSR_S0_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_BOX_FILTER 0x00000725 + + +/** + Package. Uncore SBo 0 perfmon counter 0. + + @param ECX MSR_HASWELL_E_S0_PMON_CTR0 (0x00000726) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_CTR0 is defined as MSR_S0_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_CTR0 0x00000726 + + +/** + Package. Uncore SBo 0 perfmon counter 1. + + @param ECX MSR_HASWELL_E_S0_PMON_CTR1 (0x00000727) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_CTR1 is defined as MSR_S0_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_CTR1 0x00000727 + + +/** + Package. Uncore SBo 0 perfmon counter 2. + + @param ECX MSR_HASWELL_E_S0_PMON_CTR2 (0x00000728) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_CTR2 is defined as MSR_S0_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_CTR2 0x00000728 + + +/** + Package. Uncore SBo 0 perfmon counter 3. + + @param ECX MSR_HASWELL_E_S0_PMON_CTR3 (0x00000729) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_S0_PMON_CTR3 is defined as MSR_S0_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_S0_PMON_CTR3 0x00000729 + + +/** + Package. Uncore SBo 1 perfmon for SBo 1 box-wide control. + + @param ECX MSR_HASWELL_E_S1_PMON_BOX_CTL (0x0000072A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_BOX_CTL is defined as MSR_S1_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_BOX_CTL 0x0000072A + + +/** + Package. Uncore SBo 1 perfmon event select for SBo 1 counter 0. + + @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL0 (0x0000072B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_EVNTSEL0 is defined as MSR_S1_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_EVNTSEL0 0x0000072B + + +/** + Package. Uncore SBo 1 perfmon event select for SBo 1 counter 1. + + @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL1 (0x0000072C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_EVNTSEL1 is defined as MSR_S1_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_EVNTSEL1 0x0000072C + + +/** + Package. Uncore SBo 1 perfmon event select for SBo 1 counter 2. + + @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL2 (0x0000072D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_EVNTSEL2 is defined as MSR_S1_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_EVNTSEL2 0x0000072D + + +/** + Package. Uncore SBo 1 perfmon event select for SBo 1 counter 3. + + @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL3 (0x0000072E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_EVNTSEL3 is defined as MSR_S1_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_EVNTSEL3 0x0000072E + + +/** + Package. Uncore SBo 1 perfmon box-wide filter. + + @param ECX MSR_HASWELL_E_S1_PMON_BOX_FILTER (0x0000072F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_BOX_FILTER is defined as MSR_S1_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_BOX_FILTER 0x0000072F + + +/** + Package. Uncore SBo 1 perfmon counter 0. + + @param ECX MSR_HASWELL_E_S1_PMON_CTR0 (0x00000730) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_CTR0 is defined as MSR_S1_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_CTR0 0x00000730 + + +/** + Package. Uncore SBo 1 perfmon counter 1. + + @param ECX MSR_HASWELL_E_S1_PMON_CTR1 (0x00000731) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_CTR1 is defined as MSR_S1_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_CTR1 0x00000731 + + +/** + Package. Uncore SBo 1 perfmon counter 2. + + @param ECX MSR_HASWELL_E_S1_PMON_CTR2 (0x00000732) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_CTR2 is defined as MSR_S1_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_CTR2 0x00000732 + + +/** + Package. Uncore SBo 1 perfmon counter 3. + + @param ECX MSR_HASWELL_E_S1_PMON_CTR3 (0x00000733) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_S1_PMON_CTR3 is defined as MSR_S1_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_S1_PMON_CTR3 0x00000733 + + +/** + Package. Uncore SBo 2 perfmon for SBo 2 box-wide control. + + @param ECX MSR_HASWELL_E_S2_PMON_BOX_CTL (0x00000734) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_BOX_CTL is defined as MSR_S2_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_BOX_CTL 0x00000734 + + +/** + Package. Uncore SBo 2 perfmon event select for SBo 2 counter 0. + + @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL0 (0x00000735) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_EVNTSEL0 is defined as MSR_S2_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_EVNTSEL0 0x00000735 + + +/** + Package. Uncore SBo 2 perfmon event select for SBo 2 counter 1. + + @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL1 (0x00000736) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_EVNTSEL1 is defined as MSR_S2_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_EVNTSEL1 0x00000736 + + +/** + Package. Uncore SBo 2 perfmon event select for SBo 2 counter 2. + + @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL2 (0x00000737) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_EVNTSEL2 is defined as MSR_S2_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_EVNTSEL2 0x00000737 + + +/** + Package. Uncore SBo 2 perfmon event select for SBo 2 counter 3. + + @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL3 (0x00000738) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_EVNTSEL3 is defined as MSR_S2_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_EVNTSEL3 0x00000738 + + +/** + Package. Uncore SBo 2 perfmon box-wide filter. + + @param ECX MSR_HASWELL_E_S2_PMON_BOX_FILTER (0x00000739) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_BOX_FILTER is defined as MSR_S2_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_BOX_FILTER 0x00000739 + + +/** + Package. Uncore SBo 2 perfmon counter 0. + + @param ECX MSR_HASWELL_E_S2_PMON_CTR0 (0x0000073A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_CTR0 is defined as MSR_S2_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_CTR0 0x0000073A + + +/** + Package. Uncore SBo 2 perfmon counter 1. + + @param ECX MSR_HASWELL_E_S2_PMON_CTR1 (0x0000073B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_CTR1 is defined as MSR_S2_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_CTR1 0x0000073B + + +/** + Package. Uncore SBo 2 perfmon counter 2. + + @param ECX MSR_HASWELL_E_S2_PMON_CTR2 (0x0000073C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_CTR2 is defined as MSR_S2_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_CTR2 0x0000073C + + +/** + Package. Uncore SBo 2 perfmon counter 3. + + @param ECX MSR_HASWELL_E_S2_PMON_CTR3 (0x0000073D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_S2_PMON_CTR3 is defined as MSR_S2_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_S2_PMON_CTR3 0x0000073D + + +/** + Package. Uncore SBo 3 perfmon for SBo 3 box-wide control. + + @param ECX MSR_HASWELL_E_S3_PMON_BOX_CTL (0x0000073E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_BOX_CTL is defined as MSR_S3_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_BOX_CTL 0x0000073E + + +/** + Package. Uncore SBo 3 perfmon event select for SBo 3 counter 0. + + @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL0 (0x0000073F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_EVNTSEL0 is defined as MSR_S3_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_EVNTSEL0 0x0000073F + + +/** + Package. Uncore SBo 3 perfmon event select for SBo 3 counter 1. + + @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL1 (0x00000740) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_EVNTSEL1 is defined as MSR_S3_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_EVNTSEL1 0x00000740 + + +/** + Package. Uncore SBo 3 perfmon event select for SBo 3 counter 2. + + @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL2 (0x00000741) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_EVNTSEL2 is defined as MSR_S3_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_EVNTSEL2 0x00000741 + + +/** + Package. Uncore SBo 3 perfmon event select for SBo 3 counter 3. + + @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL3 (0x00000742) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_EVNTSEL3 is defined as MSR_S3_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_EVNTSEL3 0x00000742 + + +/** + Package. Uncore SBo 3 perfmon box-wide filter. + + @param ECX MSR_HASWELL_E_S3_PMON_BOX_FILTER (0x00000743) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_BOX_FILTER is defined as MSR_S3_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_BOX_FILTER 0x00000743 + + +/** + Package. Uncore SBo 3 perfmon counter 0. + + @param ECX MSR_HASWELL_E_S3_PMON_CTR0 (0x00000744) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_CTR0 is defined as MSR_S3_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_CTR0 0x00000744 + + +/** + Package. Uncore SBo 3 perfmon counter 1. + + @param ECX MSR_HASWELL_E_S3_PMON_CTR1 (0x00000745) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_CTR1 is defined as MSR_S3_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_CTR1 0x00000745 + + +/** + Package. Uncore SBo 3 perfmon counter 2. + + @param ECX MSR_HASWELL_E_S3_PMON_CTR2 (0x00000746) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_CTR2 is defined as MSR_S3_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_CTR2 0x00000746 + + +/** + Package. Uncore SBo 3 perfmon counter 3. + + @param ECX MSR_HASWELL_E_S3_PMON_CTR3 (0x00000747) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_S3_PMON_CTR3 is defined as MSR_S3_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_S3_PMON_CTR3 0x00000747 + + +/** + Package. Uncore C-box 0 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C0_PMON_BOX_CTL (0x00000E00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_BOX_CTL is defined as MSR_C0_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_BOX_CTL 0x00000E00 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 0. + + @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL0 (0x00000E01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_EVNTSEL0 is defined as MSR_C0_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_EVNTSEL0 0x00000E01 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 1. + + @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL1 (0x00000E02) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_EVNTSEL1 is defined as MSR_C0_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_EVNTSEL1 0x00000E02 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 2. + + @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL2 (0x00000E03) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_EVNTSEL2 is defined as MSR_C0_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_EVNTSEL2 0x00000E03 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 3. + + @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL3 (0x00000E04) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_EVNTSEL3 is defined as MSR_C0_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_EVNTSEL3 0x00000E04 + + +/** + Package. Uncore C-box 0 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C0_PMON_BOX_FILTER0 (0x00000E05) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_BOX_FILTER0 is defined as MSR_C0_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_BOX_FILTER0 0x00000E05 + + +/** + Package. Uncore C-box 0 perfmon box wide filter 1. + + @param ECX MSR_HASWELL_E_C0_PMON_BOX_FILTER1 (0x00000E06) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_BOX_FILTER1 is defined as MSR_C0_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_BOX_FILTER1 0x00000E06 + + +/** + Package. Uncore C-box 0 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C0_PMON_BOX_STATUS (0x00000E07) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_BOX_STATUS is defined as MSR_C0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_BOX_STATUS 0x00000E07 + + +/** + Package. Uncore C-box 0 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C0_PMON_CTR0 (0x00000E08) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_CTR0 0x00000E08 + + +/** + Package. Uncore C-box 0 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C0_PMON_CTR1 (0x00000E09) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_CTR1 0x00000E09 + + +/** + Package. Uncore C-box 0 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C0_PMON_CTR2 (0x00000E0A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_CTR2 0x00000E0A + + +/** + Package. Uncore C-box 0 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C0_PMON_CTR3 (0x00000E0B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C0_PMON_CTR3 0x00000E0B + + +/** + Package. Uncore C-box 1 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C1_PMON_BOX_CTL (0x00000E10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_BOX_CTL is defined as MSR_C1_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_BOX_CTL 0x00000E10 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 0. + + @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL0 (0x00000E11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_EVNTSEL0 is defined as MSR_C1_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_EVNTSEL0 0x00000E11 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 1. + + @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL1 (0x00000E12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_EVNTSEL1 is defined as MSR_C1_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_EVNTSEL1 0x00000E12 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 2. + + @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL2 (0x00000E13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_EVNTSEL2 is defined as MSR_C1_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_EVNTSEL2 0x00000E13 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 3. + + @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL3 (0x00000E14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_EVNTSEL3 is defined as MSR_C1_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_EVNTSEL3 0x00000E14 + + +/** + Package. Uncore C-box 1 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C1_PMON_BOX_FILTER0 (0x00000E15) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_BOX_FILTER0 is defined as MSR_C1_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_BOX_FILTER0 0x00000E15 + + +/** + Package. Uncore C-box 1 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C1_PMON_BOX_FILTER1 (0x00000E16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_BOX_FILTER1 is defined as MSR_C1_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_BOX_FILTER1 0x00000E16 + + +/** + Package. Uncore C-box 1 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C1_PMON_BOX_STATUS (0x00000E17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_BOX_STATUS is defined as MSR_C1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_BOX_STATUS 0x00000E17 + + +/** + Package. Uncore C-box 1 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C1_PMON_CTR0 (0x00000E18) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_CTR0 0x00000E18 + + +/** + Package. Uncore C-box 1 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C1_PMON_CTR1 (0x00000E19) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_CTR1 0x00000E19 + + +/** + Package. Uncore C-box 1 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C1_PMON_CTR2 (0x00000E1A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_CTR2 0x00000E1A + + +/** + Package. Uncore C-box 1 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C1_PMON_CTR3 (0x00000E1B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C1_PMON_CTR3 0x00000E1B + + +/** + Package. Uncore C-box 2 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C2_PMON_BOX_CTL (0x00000E20) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_BOX_CTL is defined as MSR_C2_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_BOX_CTL 0x00000E20 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 0. + + @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL0 (0x00000E21) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_EVNTSEL0 is defined as MSR_C2_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_EVNTSEL0 0x00000E21 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 1. + + @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL1 (0x00000E22) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_EVNTSEL1 is defined as MSR_C2_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_EVNTSEL1 0x00000E22 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 2. + + @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL2 (0x00000E23) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_EVNTSEL2 is defined as MSR_C2_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_EVNTSEL2 0x00000E23 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 3. + + @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL3 (0x00000E24) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_EVNTSEL3 is defined as MSR_C2_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_EVNTSEL3 0x00000E24 + + +/** + Package. Uncore C-box 2 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C2_PMON_BOX_FILTER0 (0x00000E25) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_BOX_FILTER0 is defined as MSR_C2_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_BOX_FILTER0 0x00000E25 + + +/** + Package. Uncore C-box 2 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C2_PMON_BOX_FILTER1 (0x00000E26) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_BOX_FILTER1 is defined as MSR_C2_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_BOX_FILTER1 0x00000E26 + + +/** + Package. Uncore C-box 2 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C2_PMON_BOX_STATUS (0x00000E27) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_BOX_STATUS is defined as MSR_C2_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_BOX_STATUS 0x00000E27 + + +/** + Package. Uncore C-box 2 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C2_PMON_CTR0 (0x00000E28) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_CTR0 0x00000E28 + + +/** + Package. Uncore C-box 2 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C2_PMON_CTR1 (0x00000E29) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_CTR1 0x00000E29 + + +/** + Package. Uncore C-box 2 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C2_PMON_CTR2 (0x00000E2A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_CTR2 0x00000E2A + + +/** + Package. Uncore C-box 2 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C2_PMON_CTR3 (0x00000E2B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C2_PMON_CTR3 0x00000E2B + + +/** + Package. Uncore C-box 3 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C3_PMON_BOX_CTL (0x00000E30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_BOX_CTL is defined as MSR_C3_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_BOX_CTL 0x00000E30 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 0. + + @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL0 (0x00000E31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_EVNTSEL0 is defined as MSR_C3_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_EVNTSEL0 0x00000E31 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 1. + + @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL1 (0x00000E32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_EVNTSEL1 is defined as MSR_C3_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_EVNTSEL1 0x00000E32 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 2. + + @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL2 (0x00000E33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_EVNTSEL2 is defined as MSR_C3_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_EVNTSEL2 0x00000E33 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 3. + + @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL3 (0x00000E34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_EVNTSEL3 is defined as MSR_C3_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_EVNTSEL3 0x00000E34 + + +/** + Package. Uncore C-box 3 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C3_PMON_BOX_FILTER0 (0x00000E35) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_BOX_FILTER0 is defined as MSR_C3_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_BOX_FILTER0 0x00000E35 + + +/** + Package. Uncore C-box 3 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C3_PMON_BOX_FILTER1 (0x00000E36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_BOX_FILTER1 is defined as MSR_C3_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_BOX_FILTER1 0x00000E36 + + +/** + Package. Uncore C-box 3 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C3_PMON_BOX_STATUS (0x00000E37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_BOX_STATUS is defined as MSR_C3_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_BOX_STATUS 0x00000E37 + + +/** + Package. Uncore C-box 3 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C3_PMON_CTR0 (0x00000E38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_CTR0 0x00000E38 + + +/** + Package. Uncore C-box 3 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C3_PMON_CTR1 (0x00000E39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_CTR1 0x00000E39 + + +/** + Package. Uncore C-box 3 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C3_PMON_CTR2 (0x00000E3A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_CTR2 0x00000E3A + + +/** + Package. Uncore C-box 3 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C3_PMON_CTR3 (0x00000E3B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C3_PMON_CTR3 0x00000E3B + + +/** + Package. Uncore C-box 4 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C4_PMON_BOX_CTL (0x00000E40) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_BOX_CTL is defined as MSR_C4_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_BOX_CTL 0x00000E40 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 0. + + @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL0 (0x00000E41) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_EVNTSEL0 is defined as MSR_C4_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_EVNTSEL0 0x00000E41 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 1. + + @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL1 (0x00000E42) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_EVNTSEL1 is defined as MSR_C4_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_EVNTSEL1 0x00000E42 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 2. + + @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL2 (0x00000E43) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_EVNTSEL2 is defined as MSR_C4_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_EVNTSEL2 0x00000E43 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 3. + + @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL3 (0x00000E44) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_EVNTSEL3 is defined as MSR_C4_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_EVNTSEL3 0x00000E44 + + +/** + Package. Uncore C-box 4 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C4_PMON_BOX_FILTER0 (0x00000E45) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_BOX_FILTER0 is defined as MSR_C4_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_BOX_FILTER0 0x00000E45 + + +/** + Package. Uncore C-box 4 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C4_PMON_BOX_FILTER1 (0x00000E46) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_BOX_FILTER1 is defined as MSR_C4_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_BOX_FILTER1 0x00000E46 + + +/** + Package. Uncore C-box 4 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C4_PMON_BOX_STATUS (0x00000E47) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_BOX_STATUS is defined as MSR_C4_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_BOX_STATUS 0x00000E47 + + +/** + Package. Uncore C-box 4 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C4_PMON_CTR0 (0x00000E48) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_CTR0 0x00000E48 + + +/** + Package. Uncore C-box 4 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C4_PMON_CTR1 (0x00000E49) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_CTR1 0x00000E49 + + +/** + Package. Uncore C-box 4 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C4_PMON_CTR2 (0x00000E4A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_CTR2 0x00000E4A + + +/** + Package. Uncore C-box 4 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C4_PMON_CTR3 (0x00000E4B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C4_PMON_CTR3 0x00000E4B + + +/** + Package. Uncore C-box 5 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C5_PMON_BOX_CTL (0x00000E50) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_BOX_CTL is defined as MSR_C5_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_BOX_CTL 0x00000E50 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 0. + + @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL0 (0x00000E51) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_EVNTSEL0 is defined as MSR_C5_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_EVNTSEL0 0x00000E51 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 1. + + @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL1 (0x00000E52) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_EVNTSEL1 is defined as MSR_C5_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_EVNTSEL1 0x00000E52 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 2. + + @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL2 (0x00000E53) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_EVNTSEL2 is defined as MSR_C5_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_EVNTSEL2 0x00000E53 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 3. + + @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL3 (0x00000E54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_EVNTSEL3 is defined as MSR_C5_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_EVNTSEL3 0x00000E54 + + +/** + Package. Uncore C-box 5 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C5_PMON_BOX_FILTER0 (0x00000E55) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_BOX_FILTER0 is defined as MSR_C5_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_BOX_FILTER0 0x00000E55 + + +/** + Package. Uncore C-box 5 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C5_PMON_BOX_FILTER1 (0x00000E56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_BOX_FILTER1 is defined as MSR_C5_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_BOX_FILTER1 0x00000E56 + + +/** + Package. Uncore C-box 5 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C5_PMON_BOX_STATUS (0x00000E57) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_BOX_STATUS is defined as MSR_C5_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_BOX_STATUS 0x00000E57 + + +/** + Package. Uncore C-box 5 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C5_PMON_CTR0 (0x00000E58) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_CTR0 0x00000E58 + + +/** + Package. Uncore C-box 5 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C5_PMON_CTR1 (0x00000E59) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_CTR1 0x00000E59 + + +/** + Package. Uncore C-box 5 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C5_PMON_CTR2 (0x00000E5A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_CTR2 0x00000E5A + + +/** + Package. Uncore C-box 5 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C5_PMON_CTR3 (0x00000E5B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C5_PMON_CTR3 0x00000E5B + + +/** + Package. Uncore C-box 6 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C6_PMON_BOX_CTL (0x00000E60) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_BOX_CTL is defined as MSR_C6_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_BOX_CTL 0x00000E60 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 0. + + @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL0 (0x00000E61) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_EVNTSEL0 is defined as MSR_C6_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_EVNTSEL0 0x00000E61 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 1. + + @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL1 (0x00000E62) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_EVNTSEL1 is defined as MSR_C6_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_EVNTSEL1 0x00000E62 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 2. + + @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL2 (0x00000E63) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_EVNTSEL2 is defined as MSR_C6_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_EVNTSEL2 0x00000E63 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 3. + + @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL3 (0x00000E64) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_EVNTSEL3 is defined as MSR_C6_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_EVNTSEL3 0x00000E64 + + +/** + Package. Uncore C-box 6 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C6_PMON_BOX_FILTER0 (0x00000E65) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_BOX_FILTER0 is defined as MSR_C6_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_BOX_FILTER0 0x00000E65 + + +/** + Package. Uncore C-box 6 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C6_PMON_BOX_FILTER1 (0x00000E66) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_BOX_FILTER1 is defined as MSR_C6_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_BOX_FILTER1 0x00000E66 + + +/** + Package. Uncore C-box 6 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C6_PMON_BOX_STATUS (0x00000E67) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_BOX_STATUS is defined as MSR_C6_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_BOX_STATUS 0x00000E67 + + +/** + Package. Uncore C-box 6 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C6_PMON_CTR0 (0x00000E68) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_CTR0 0x00000E68 + + +/** + Package. Uncore C-box 6 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C6_PMON_CTR1 (0x00000E69) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_CTR1 0x00000E69 + + +/** + Package. Uncore C-box 6 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C6_PMON_CTR2 (0x00000E6A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_CTR2 0x00000E6A + + +/** + Package. Uncore C-box 6 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C6_PMON_CTR3 (0x00000E6B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C6_PMON_CTR3 0x00000E6B + + +/** + Package. Uncore C-box 7 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C7_PMON_BOX_CTL (0x00000E70) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_BOX_CTL is defined as MSR_C7_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_BOX_CTL 0x00000E70 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 0. + + @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL0 (0x00000E71) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_EVNTSEL0 is defined as MSR_C7_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_EVNTSEL0 0x00000E71 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 1. + + @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL1 (0x00000E72) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_EVNTSEL1 is defined as MSR_C7_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_EVNTSEL1 0x00000E72 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 2. + + @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL2 (0x00000E73) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_EVNTSEL2 is defined as MSR_C7_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_EVNTSEL2 0x00000E73 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 3. + + @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL3 (0x00000E74) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_EVNTSEL3 is defined as MSR_C7_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_EVNTSEL3 0x00000E74 + + +/** + Package. Uncore C-box 7 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C7_PMON_BOX_FILTER0 (0x00000E75) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_BOX_FILTER0 is defined as MSR_C7_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_BOX_FILTER0 0x00000E75 + + +/** + Package. Uncore C-box 7 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C7_PMON_BOX_FILTER1 (0x00000E76) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_BOX_FILTER1 is defined as MSR_C7_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_BOX_FILTER1 0x00000E76 + + +/** + Package. Uncore C-box 7 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C7_PMON_BOX_STATUS (0x00000E77) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_BOX_STATUS is defined as MSR_C7_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_BOX_STATUS 0x00000E77 + + +/** + Package. Uncore C-box 7 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C7_PMON_CTR0 (0x00000E78) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_CTR0 0x00000E78 + + +/** + Package. Uncore C-box 7 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C7_PMON_CTR1 (0x00000E79) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_CTR1 0x00000E79 + + +/** + Package. Uncore C-box 7 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C7_PMON_CTR2 (0x00000E7A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_CTR2 0x00000E7A + + +/** + Package. Uncore C-box 7 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C7_PMON_CTR3 (0x00000E7B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C7_PMON_CTR3 0x00000E7B + + +/** + Package. Uncore C-box 8 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C8_PMON_BOX_CTL (0x00000E80) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_BOX_CTL is defined as MSR_C8_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_BOX_CTL 0x00000E80 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 0. + + @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL0 (0x00000E81) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_EVNTSEL0 is defined as MSR_C8_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_EVNTSEL0 0x00000E81 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 1. + + @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL1 (0x00000E82) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_EVNTSEL1 is defined as MSR_C8_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_EVNTSEL1 0x00000E82 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 2. + + @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL2 (0x00000E83) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_EVNTSEL2 is defined as MSR_C8_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_EVNTSEL2 0x00000E83 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 3. + + @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL3 (0x00000E84) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_EVNTSEL3 is defined as MSR_C8_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_EVNTSEL3 0x00000E84 + + +/** + Package. Uncore C-box 8 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C8_PMON_BOX_FILTER0 (0x00000E85) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_BOX_FILTER0 is defined as MSR_C8_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_BOX_FILTER0 0x00000E85 + + +/** + Package. Uncore C-box 8 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C8_PMON_BOX_FILTER1 (0x00000E86) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_BOX_FILTER1 is defined as MSR_C8_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_BOX_FILTER1 0x00000E86 + + +/** + Package. Uncore C-box 8 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C8_PMON_BOX_STATUS (0x00000E87) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_BOX_STATUS is defined as MSR_C8_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_BOX_STATUS 0x00000E87 + + +/** + Package. Uncore C-box 8 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C8_PMON_CTR0 (0x00000E88) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_CTR0 0x00000E88 + + +/** + Package. Uncore C-box 8 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C8_PMON_CTR1 (0x00000E89) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_CTR1 0x00000E89 + + +/** + Package. Uncore C-box 8 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C8_PMON_CTR2 (0x00000E8A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_CTR2 0x00000E8A + + +/** + Package. Uncore C-box 8 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C8_PMON_CTR3 (0x00000E8B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C8_PMON_CTR3 0x00000E8B + + +/** + Package. Uncore C-box 9 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C9_PMON_BOX_CTL (0x00000E90) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_BOX_CTL is defined as MSR_C9_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_BOX_CTL 0x00000E90 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 0. + + @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL0 (0x00000E91) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_EVNTSEL0 is defined as MSR_C9_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_EVNTSEL0 0x00000E91 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 1. + + @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL1 (0x00000E92) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_EVNTSEL1 is defined as MSR_C9_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_EVNTSEL1 0x00000E92 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 2. + + @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL2 (0x00000E93) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_EVNTSEL2 is defined as MSR_C9_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_EVNTSEL2 0x00000E93 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 3. + + @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL3 (0x00000E94) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_EVNTSEL3 is defined as MSR_C9_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_EVNTSEL3 0x00000E94 + + +/** + Package. Uncore C-box 9 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C9_PMON_BOX_FILTER0 (0x00000E95) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_BOX_FILTER0 is defined as MSR_C9_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_BOX_FILTER0 0x00000E95 + + +/** + Package. Uncore C-box 9 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C9_PMON_BOX_FILTER1 (0x00000E96) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_BOX_FILTER1 is defined as MSR_C9_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_BOX_FILTER1 0x00000E96 + + +/** + Package. Uncore C-box 9 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C9_PMON_BOX_STATUS (0x00000E97) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_BOX_STATUS is defined as MSR_C9_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_BOX_STATUS 0x00000E97 + + +/** + Package. Uncore C-box 9 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C9_PMON_CTR0 (0x00000E98) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_CTR0 0x00000E98 + + +/** + Package. Uncore C-box 9 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C9_PMON_CTR1 (0x00000E99) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_CTR1 0x00000E99 + + +/** + Package. Uncore C-box 9 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C9_PMON_CTR2 (0x00000E9A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_CTR2 0x00000E9A + + +/** + Package. Uncore C-box 9 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C9_PMON_CTR3 (0x00000E9B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C9_PMON_CTR3 0x00000E9B + + +/** + Package. Uncore C-box 10 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C10_PMON_BOX_CTL (0x00000EA0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_BOX_CTL is defined as MSR_C10_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_BOX_CTL 0x00000EA0 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 0. + + @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL0 (0x00000EA1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_EVNTSEL0 is defined as MSR_C10_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_EVNTSEL0 0x00000EA1 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 1. + + @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL1 (0x00000EA2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_EVNTSEL1 is defined as MSR_C10_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_EVNTSEL1 0x00000EA2 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 2. + + @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL2 (0x00000EA3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_EVNTSEL2 is defined as MSR_C10_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_EVNTSEL2 0x00000EA3 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 3. + + @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL3 (0x00000EA4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_EVNTSEL3 is defined as MSR_C10_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_EVNTSEL3 0x00000EA4 + + +/** + Package. Uncore C-box 10 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C10_PMON_BOX_FILTER0 (0x00000EA5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_BOX_FILTER0 is defined as MSR_C10_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_BOX_FILTER0 0x00000EA5 + + +/** + Package. Uncore C-box 10 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C10_PMON_BOX_FILTER1 (0x00000EA6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_BOX_FILTER1 is defined as MSR_C10_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_BOX_FILTER1 0x00000EA6 + + +/** + Package. Uncore C-box 10 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C10_PMON_BOX_STATUS (0x00000EA7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_BOX_STATUS is defined as MSR_C10_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_BOX_STATUS 0x00000EA7 + + +/** + Package. Uncore C-box 10 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C10_PMON_CTR0 (0x00000EA8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_CTR0 is defined as MSR_C10_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_CTR0 0x00000EA8 + + +/** + Package. Uncore C-box 10 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C10_PMON_CTR1 (0x00000EA9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_CTR1 is defined as MSR_C10_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_CTR1 0x00000EA9 + + +/** + Package. Uncore C-box 10 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C10_PMON_CTR2 (0x00000EAA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_CTR2 is defined as MSR_C10_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_CTR2 0x00000EAA + + +/** + Package. Uncore C-box 10 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C10_PMON_CTR3 (0x00000EAB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C10_PMON_CTR3 is defined as MSR_C10_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C10_PMON_CTR3 0x00000EAB + + +/** + Package. Uncore C-box 11 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C11_PMON_BOX_CTL (0x00000EB0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_BOX_CTL is defined as MSR_C11_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_BOX_CTL 0x00000EB0 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 0. + + @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL0 (0x00000EB1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_EVNTSEL0 is defined as MSR_C11_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_EVNTSEL0 0x00000EB1 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 1. + + @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL1 (0x00000EB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_EVNTSEL1 is defined as MSR_C11_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_EVNTSEL1 0x00000EB2 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 2. + + @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL2 (0x00000EB3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_EVNTSEL2 is defined as MSR_C11_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_EVNTSEL2 0x00000EB3 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 3. + + @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL3 (0x00000EB4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_EVNTSEL3 is defined as MSR_C11_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_EVNTSEL3 0x00000EB4 + + +/** + Package. Uncore C-box 11 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C11_PMON_BOX_FILTER0 (0x00000EB5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_BOX_FILTER0 is defined as MSR_C11_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_BOX_FILTER0 0x00000EB5 + + +/** + Package. Uncore C-box 11 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C11_PMON_BOX_FILTER1 (0x00000EB6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_BOX_FILTER1 is defined as MSR_C11_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_BOX_FILTER1 0x00000EB6 + + +/** + Package. Uncore C-box 11 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C11_PMON_BOX_STATUS (0x00000EB7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_BOX_STATUS is defined as MSR_C11_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_BOX_STATUS 0x00000EB7 + + +/** + Package. Uncore C-box 11 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C11_PMON_CTR0 (0x00000EB8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_CTR0 is defined as MSR_C11_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_CTR0 0x00000EB8 + + +/** + Package. Uncore C-box 11 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C11_PMON_CTR1 (0x00000EB9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_CTR1 is defined as MSR_C11_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_CTR1 0x00000EB9 + + +/** + Package. Uncore C-box 11 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C11_PMON_CTR2 (0x00000EBA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_CTR2 is defined as MSR_C11_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_CTR2 0x00000EBA + + +/** + Package. Uncore C-box 11 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C11_PMON_CTR3 (0x00000EBB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C11_PMON_CTR3 is defined as MSR_C11_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C11_PMON_CTR3 0x00000EBB + + +/** + Package. Uncore C-box 12 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C12_PMON_BOX_CTL (0x00000EC0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_BOX_CTL is defined as MSR_C12_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_BOX_CTL 0x00000EC0 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 0. + + @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL0 (0x00000EC1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_EVNTSEL0 is defined as MSR_C12_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_EVNTSEL0 0x00000EC1 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 1. + + @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL1 (0x00000EC2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_EVNTSEL1 is defined as MSR_C12_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_EVNTSEL1 0x00000EC2 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 2. + + @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL2 (0x00000EC3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_EVNTSEL2 is defined as MSR_C12_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_EVNTSEL2 0x00000EC3 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 3. + + @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL3 (0x00000EC4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_EVNTSEL3 is defined as MSR_C12_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_EVNTSEL3 0x00000EC4 + + +/** + Package. Uncore C-box 12 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C12_PMON_BOX_FILTER0 (0x00000EC5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_BOX_FILTER0 is defined as MSR_C12_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_BOX_FILTER0 0x00000EC5 + + +/** + Package. Uncore C-box 12 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C12_PMON_BOX_FILTER1 (0x00000EC6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_BOX_FILTER1 is defined as MSR_C12_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_BOX_FILTER1 0x00000EC6 + + +/** + Package. Uncore C-box 12 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C12_PMON_BOX_STATUS (0x00000EC7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_BOX_STATUS is defined as MSR_C12_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_BOX_STATUS 0x00000EC7 + + +/** + Package. Uncore C-box 12 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C12_PMON_CTR0 (0x00000EC8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_CTR0 is defined as MSR_C12_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_CTR0 0x00000EC8 + + +/** + Package. Uncore C-box 12 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C12_PMON_CTR1 (0x00000EC9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_CTR1 is defined as MSR_C12_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_CTR1 0x00000EC9 + + +/** + Package. Uncore C-box 12 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C12_PMON_CTR2 (0x00000ECA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_CTR2 is defined as MSR_C12_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_CTR2 0x00000ECA + + +/** + Package. Uncore C-box 12 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C12_PMON_CTR3 (0x00000ECB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C12_PMON_CTR3 is defined as MSR_C12_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C12_PMON_CTR3 0x00000ECB + + +/** + Package. Uncore C-box 13 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C13_PMON_BOX_CTL (0x00000ED0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_BOX_CTL is defined as MSR_C13_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_BOX_CTL 0x00000ED0 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 0. + + @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL0 (0x00000ED1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_EVNTSEL0 is defined as MSR_C13_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_EVNTSEL0 0x00000ED1 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 1. + + @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL1 (0x00000ED2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_EVNTSEL1 is defined as MSR_C13_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_EVNTSEL1 0x00000ED2 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 2. + + @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL2 (0x00000ED3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_EVNTSEL2 is defined as MSR_C13_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_EVNTSEL2 0x00000ED3 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 3. + + @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL3 (0x00000ED4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_EVNTSEL3 is defined as MSR_C13_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_EVNTSEL3 0x00000ED4 + + +/** + Package. Uncore C-box 13 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C13_PMON_BOX_FILTER0 (0x00000ED5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_BOX_FILTER0 is defined as MSR_C13_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_BOX_FILTER0 0x00000ED5 + + +/** + Package. Uncore C-box 13 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C13_PMON_BOX_FILTER1 (0x00000ED6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_BOX_FILTER1 is defined as MSR_C13_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_BOX_FILTER1 0x00000ED6 + + +/** + Package. Uncore C-box 13 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C13_PMON_BOX_STATUS (0x00000ED7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_BOX_STATUS is defined as MSR_C13_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_BOX_STATUS 0x00000ED7 + + +/** + Package. Uncore C-box 13 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C13_PMON_CTR0 (0x00000ED8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_CTR0 is defined as MSR_C13_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_CTR0 0x00000ED8 + + +/** + Package. Uncore C-box 13 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C13_PMON_CTR1 (0x00000ED9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_CTR1 is defined as MSR_C13_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_CTR1 0x00000ED9 + + +/** + Package. Uncore C-box 13 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C13_PMON_CTR2 (0x00000EDA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_CTR2 is defined as MSR_C13_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_CTR2 0x00000EDA + + +/** + Package. Uncore C-box 13 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C13_PMON_CTR3 (0x00000EDB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C13_PMON_CTR3 is defined as MSR_C13_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C13_PMON_CTR3 0x00000EDB + + +/** + Package. Uncore C-box 14 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C14_PMON_BOX_CTL (0x00000EE0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_BOX_CTL is defined as MSR_C14_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_BOX_CTL 0x00000EE0 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 0. + + @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL0 (0x00000EE1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_EVNTSEL0 is defined as MSR_C14_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_EVNTSEL0 0x00000EE1 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 1. + + @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL1 (0x00000EE2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_EVNTSEL1 is defined as MSR_C14_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_EVNTSEL1 0x00000EE2 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 2. + + @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL2 (0x00000EE3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_EVNTSEL2 is defined as MSR_C14_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_EVNTSEL2 0x00000EE3 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 3. + + @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL3 (0x00000EE4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_EVNTSEL3 is defined as MSR_C14_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_EVNTSEL3 0x00000EE4 + + +/** + Package. Uncore C-box 14 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C14_PMON_BOX_FILTER (0x00000EE5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_BOX_FILTER is defined as MSR_C14_PMON_BOX_FILTER in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_BOX_FILTER 0x00000EE5 + + +/** + Package. Uncore C-box 14 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C14_PMON_BOX_FILTER1 (0x00000EE6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_BOX_FILTER1 is defined as MSR_C14_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_BOX_FILTER1 0x00000EE6 + + +/** + Package. Uncore C-box 14 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C14_PMON_BOX_STATUS (0x00000EE7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_BOX_STATUS is defined as MSR_C14_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_BOX_STATUS 0x00000EE7 + + +/** + Package. Uncore C-box 14 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C14_PMON_CTR0 (0x00000EE8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_CTR0 is defined as MSR_C14_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_CTR0 0x00000EE8 + + +/** + Package. Uncore C-box 14 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C14_PMON_CTR1 (0x00000EE9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_CTR1 is defined as MSR_C14_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_CTR1 0x00000EE9 + + +/** + Package. Uncore C-box 14 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C14_PMON_CTR2 (0x00000EEA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_CTR2 is defined as MSR_C14_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_CTR2 0x00000EEA + + +/** + Package. Uncore C-box 14 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C14_PMON_CTR3 (0x00000EEB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C14_PMON_CTR3 is defined as MSR_C14_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C14_PMON_CTR3 0x00000EEB + + +/** + Package. Uncore C-box 15 perfmon local box wide control. + + @param ECX MSR_HASWELL_E_C15_PMON_BOX_CTL (0x00000EF0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_BOX_CTL is defined as MSR_C15_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_BOX_CTL 0x00000EF0 + + +/** + Package. Uncore C-box 15 perfmon event select for C-box 15 counter 0. + + @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL0 (0x00000EF1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_EVNTSEL0 is defined as MSR_C15_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_EVNTSEL0 0x00000EF1 + + +/** + Package. Uncore C-box 15 perfmon event select for C-box 15 counter 1. + + @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL1 (0x00000EF2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_EVNTSEL1 is defined as MSR_C15_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_EVNTSEL1 0x00000EF2 + + +/** + Package. Uncore C-box 15 perfmon event select for C-box 15 counter 2. + + @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL2 (0x00000EF3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_EVNTSEL2 is defined as MSR_C15_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_EVNTSEL2 0x00000EF3 + + +/** + Package. Uncore C-box 15 perfmon event select for C-box 15 counter 3. + + @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL3 (0x00000EF4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_EVNTSEL3 is defined as MSR_C15_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_EVNTSEL3 0x00000EF4 + + +/** + Package. Uncore C-box 15 perfmon box wide filter0. + + @param ECX MSR_HASWELL_E_C15_PMON_BOX_FILTER0 (0x00000EF5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_BOX_FILTER0 is defined as MSR_C15_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_BOX_FILTER0 0x00000EF5 + + +/** + Package. Uncore C-box 15 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C15_PMON_BOX_FILTER1 (0x00000EF6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_BOX_FILTER1 is defined as MSR_C15_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_BOX_FILTER1 0x00000EF6 + + +/** + Package. Uncore C-box 15 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C15_PMON_BOX_STATUS (0x00000EF7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_BOX_STATUS is defined as MSR_C15_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_BOX_STATUS 0x00000EF7 + + +/** + Package. Uncore C-box 15 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C15_PMON_CTR0 (0x00000EF8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_CTR0 is defined as MSR_C15_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_CTR0 0x00000EF8 + + +/** + Package. Uncore C-box 15 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C15_PMON_CTR1 (0x00000EF9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_CTR1 is defined as MSR_C15_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_CTR1 0x00000EF9 + + +/** + Package. Uncore C-box 15 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C15_PMON_CTR2 (0x00000EFA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_CTR2 is defined as MSR_C15_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_CTR2 0x00000EFA + + +/** + Package. Uncore C-box 15 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C15_PMON_CTR3 (0x00000EFB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C15_PMON_CTR3 is defined as MSR_C15_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C15_PMON_CTR3 0x00000EFB + + +/** + Package. Uncore C-box 16 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C16_PMON_BOX_CTL (0x00000F00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_BOX_CTL is defined as MSR_C16_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_BOX_CTL 0x00000F00 + + +/** + Package. Uncore C-box 16 perfmon event select for C-box 16 counter 0. + + @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL0 (0x00000F01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_EVNTSEL0 is defined as MSR_C16_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_EVNTSEL0 0x00000F01 + + +/** + Package. Uncore C-box 16 perfmon event select for C-box 16 counter 1. + + @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL1 (0x00000F02) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_EVNTSEL1 is defined as MSR_C16_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_EVNTSEL1 0x00000F02 + + +/** + Package. Uncore C-box 16 perfmon event select for C-box 16 counter 2. + + @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL2 (0x00000F03) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_EVNTSEL2 is defined as MSR_C16_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_EVNTSEL2 0x00000F03 + + +/** + Package. Uncore C-box 16 perfmon event select for C-box 16 counter 3. + + @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL3 (0x00000F04) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_EVNTSEL3 is defined as MSR_C16_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_EVNTSEL3 0x00000F04 + + +/** + Package. Uncore C-box 16 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C16_PMON_BOX_FILTER0 (0x00000F05) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_BOX_FILTER0 is defined as MSR_C16_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_BOX_FILTER0 0x00000F05 + + +/** + Package. Uncore C-box 16 perfmon box wide filter 1. + + @param ECX MSR_HASWELL_E_C16_PMON_BOX_FILTER1 (0x00000F06) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_BOX_FILTER1 is defined as MSR_C16_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_BOX_FILTER1 0x00000F06 + + +/** + Package. Uncore C-box 16 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C16_PMON_BOX_STATUS (0x00000F07) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_BOX_STATUS is defined as MSR_C16_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_BOX_STATUS 0x00000F07 + + +/** + Package. Uncore C-box 16 perfmon counter 0. + + @param ECX MSR_HASWELL_E_C16_PMON_CTR0 (0x00000F08) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_CTR0 is defined as MSR_C16_PMON_CTR0 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_CTR0 0x00000F08 + + +/** + Package. Uncore C-box 16 perfmon counter 1. + + @param ECX MSR_HASWELL_E_C16_PMON_CTR1 (0x00000F09) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR1); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR1, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_CTR1 is defined as MSR_C16_PMON_CTR1 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_CTR1 0x00000F09 + + +/** + Package. Uncore C-box 16 perfmon counter 2. + + @param ECX MSR_HASWELL_E_C16_PMON_CTR2 (0x00000F0A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR2); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR2, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_CTR2 is defined as MSR_C16_PMON_CTR2 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_CTR2 0x00000F0A + + +/** + Package. Uncore C-box 16 perfmon counter 3. + + @param ECX MSR_HASWELL_E_C16_PMON_CTR3 (0x00000E0B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR3); + AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR3, Msr); + @endcode + @note MSR_HASWELL_E_C16_PMON_CTR3 is defined as MSR_C16_PMON_CTR3 in SDM. +**/ +#define MSR_HASWELL_E_C16_PMON_CTR3 0x00000E0B + + +/** + Package. Uncore C-box 17 perfmon for box-wide control. + + @param ECX MSR_HASWELL_E_C17_PMON_BOX_CTL (0x00000F10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_CTL, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_BOX_CTL is defined as MSR_C17_PMON_BOX_CTL in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_BOX_CTL 0x00000F10 + + +/** + Package. Uncore C-box 17 perfmon event select for C-box 17 counter 0. + + @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL0 (0x00000F11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_EVNTSEL0 is defined as MSR_C17_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_EVNTSEL0 0x00000F11 + + +/** + Package. Uncore C-box 17 perfmon event select for C-box 17 counter 1. + + @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL1 (0x00000F12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_EVNTSEL1 is defined as MSR_C17_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_EVNTSEL1 0x00000F12 + + +/** + Package. Uncore C-box 17 perfmon event select for C-box 17 counter 2. + + @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL2 (0x00000F13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_EVNTSEL2 is defined as MSR_C17_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_EVNTSEL2 0x00000F13 + + +/** + Package. Uncore C-box 17 perfmon event select for C-box 17 counter 3. + + @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL3 (0x00000F14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_EVNTSEL3 is defined as MSR_C17_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_EVNTSEL3 0x00000F14 + + +/** + Package. Uncore C-box 17 perfmon box wide filter 0. + + @param ECX MSR_HASWELL_E_C17_PMON_BOX_FILTER0 (0x00000F15) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER0); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER0, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_BOX_FILTER0 is defined as MSR_C17_PMON_BOX_FILTER0 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_BOX_FILTER0 0x00000F15 + + +/** + Package. Uncore C-box 17 perfmon box wide filter1. + + @param ECX MSR_HASWELL_E_C17_PMON_BOX_FILTER1 (0x00000F16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_BOX_FILTER1 is defined as MSR_C17_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_BOX_FILTER1 0x00000F16 + +/** + Package. Uncore C-box 17 perfmon box wide status. + + @param ECX MSR_HASWELL_E_C17_PMON_BOX_STATUS (0x00000F17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_BOX_STATUS is defined as MSR_C17_PMON_BOX_STATUS in SDM. +**/ +#define MSR_HASWELL_E_C17_PMON_BOX_STATUS 0x00000F17 + + +/** + Package. Uncore C-box 17 perfmon counter n. + + @param ECX MSR_HASWELL_E_C17_PMON_CTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_CTR0); + AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_CTR0, Msr); + @endcode + @note MSR_HASWELL_E_C17_PMON_CTR0 is defined as MSR_C17_PMON_CTR0 in SDM. + MSR_HASWELL_E_C17_PMON_CTR1 is defined as MSR_C17_PMON_CTR1 in SDM. + MSR_HASWELL_E_C17_PMON_CTR2 is defined as MSR_C17_PMON_CTR2 in SDM. + MSR_HASWELL_E_C17_PMON_CTR3 is defined as MSR_C17_PMON_CTR3 in SDM. + @{ +**/ +#define MSR_HASWELL_E_C17_PMON_CTR0 0x00000F18 +#define MSR_HASWELL_E_C17_PMON_CTR1 0x00000F19 +#define MSR_HASWELL_E_C17_PMON_CTR2 0x00000F1A +#define MSR_HASWELL_E_C17_PMON_CTR3 0x00000F1B +/// @} + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h new file mode 100644 index 0000000000..3cd15846b4 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h @@ -0,0 +1,2637 @@ +/** @file + MSR Definitions for Intel processors based on the Haswell microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.11. + +**/ + +#ifndef __HASWELL_MSR_H__ +#define __HASWELL_MSR_H__ + +#include + +/** + Is Intel processors based on the Haswell microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_HASWELL_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x3C || \ + DisplayModel == 0x45 || \ + DisplayModel == 0x46 \ + ) \ + ) + +/** + Package. + + @param ECX MSR_HASWELL_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_HASWELL_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PLATFORM_INFO); + AsmWriteMsr64 (MSR_HASWELL_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_HASWELL_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_HASWELL_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_HASWELL_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + UINT32 Reserved3:2; + /// + /// [Bit 32] Package. Low Power Mode Support (LPM) (R/O) When set to 1, + /// indicates that LPM is supported, and when set to 0, indicates LPM is + /// not supported. + /// + UINT32 LowPowerModeSupport:1; + /// + /// [Bits 34:33] Package. Number of ConfigTDP Levels (R/O) 00: Only Base + /// TDP level available. 01: One additional TDP level available. 02: Two + /// additional TDP level available. 11: Reserved. + /// + UINT32 ConfigTDPLevels:2; + UINT32 Reserved4:5; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + /// + /// [Bits 55:48] Package. Minimum Operating Ratio (R/O) Contains the + /// minimum supported operating ratio in units of 100 MHz. + /// + UINT32 MinimumOperatingRatio:8; + UINT32 Reserved5:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PLATFORM_INFO_REGISTER; + + +/** + THREAD. Performance Event Select for Counter n (R/W) Supports all fields + described inTable 35-2 and the fields below. + + @param ECX MSR_HASWELL_IA32_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_IA32_PERFEVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_IA32_PERFEVTSEL_REGISTER. + + Example usage + @code + MSR_HASWELL_IA32_PERFEVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_IA32_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_IA32_PERFEVTSEL0, Msr.Uint64); + @endcode + @note MSR_HASWELL_IA32_PERFEVTSEL0 is defined as IA32_PERFEVTSEL0 in SDM. + MSR_HASWELL_IA32_PERFEVTSEL1 is defined as IA32_PERFEVTSEL1 in SDM. + MSR_HASWELL_IA32_PERFEVTSEL3 is defined as IA32_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_HASWELL_IA32_PERFEVTSEL0 0x00000186 +#define MSR_HASWELL_IA32_PERFEVTSEL1 0x00000187 +#define MSR_HASWELL_IA32_PERFEVTSEL3 0x00000189 +/// @} + +/** + MSR information returned for MSR indexes #MSR_HASWELL_IA32_PERFEVTSEL0, + #MSR_HASWELL_IA32_PERFEVTSEL1, and #MSR_HASWELL_IA32_PERFEVTSEL3. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Event Select: Selects a performance event logic unit. + /// + UINT32 EventSelect:8; + /// + /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to + /// detect on the selected event logic. + /// + UINT32 UMASK:8; + /// + /// [Bit 16] USR: Counts while in privilege level is not ring 0. + /// + UINT32 USR:1; + /// + /// [Bit 17] OS: Counts while in privilege level is ring 0. + /// + UINT32 OS:1; + /// + /// [Bit 18] Edge: Enables edge detection if set. + /// + UINT32 E:1; + /// + /// [Bit 19] PC: enables pin control. + /// + UINT32 PC:1; + /// + /// [Bit 20] INT: enables interrupt on counter overflow. + /// + UINT32 INT:1; + /// + /// [Bit 21] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. + /// + UINT32 ANY:1; + /// + /// [Bit 22] EN: enables the corresponding performance counter to commence + /// counting when this bit is set. + /// + UINT32 EN:1; + /// + /// [Bit 23] INV: invert the CMASK. + /// + UINT32 INV:1; + /// + /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding + /// performance counter increments each cycle if the event count is + /// greater than or equal to the CMASK. + /// + UINT32 CMASK:8; + UINT32 Reserved:32; + /// + /// [Bit 32] IN_TX: see Section 18.11.5.1 When IN_TX (bit 32) is set, + /// AnyThread (bit 21) should be cleared to prevent incorrect results. + /// + UINT32 IN_TX:1; + UINT32 Reserved2:31; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_IA32_PERFEVTSEL_REGISTER; + + +/** + THREAD. Performance Event Select for Counter 2 (R/W) Supports all fields + described inTable 35-2 and the fields below. + + @param ECX MSR_HASWELL_IA32_PERFEVTSEL2 (0x00000188) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER. + + Example usage + @code + MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_IA32_PERFEVTSEL2); + AsmWriteMsr64 (MSR_HASWELL_IA32_PERFEVTSEL2, Msr.Uint64); + @endcode + @note MSR_HASWELL_IA32_PERFEVTSEL2 is defined as IA32_PERFEVTSEL2 in SDM. +**/ +#define MSR_HASWELL_IA32_PERFEVTSEL2 0x00000188 + +/** + MSR information returned for MSR index #MSR_HASWELL_IA32_PERFEVTSEL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Event Select: Selects a performance event logic unit. + /// + UINT32 EventSelect:8; + /// + /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to + /// detect on the selected event logic. + /// + UINT32 UMASK:8; + /// + /// [Bit 16] USR: Counts while in privilege level is not ring 0. + /// + UINT32 USR:1; + /// + /// [Bit 17] OS: Counts while in privilege level is ring 0. + /// + UINT32 OS:1; + /// + /// [Bit 18] Edge: Enables edge detection if set. + /// + UINT32 E:1; + /// + /// [Bit 19] PC: enables pin control. + /// + UINT32 PC:1; + /// + /// [Bit 20] INT: enables interrupt on counter overflow. + /// + UINT32 INT:1; + /// + /// [Bit 21] AnyThread: When set to 1, it enables counting the associated + /// event conditions occurring across all logical processors sharing a + /// processor core. When set to 0, the counter only increments the + /// associated event conditions occurring in the logical processor which + /// programmed the MSR. + /// + UINT32 ANY:1; + /// + /// [Bit 22] EN: enables the corresponding performance counter to commence + /// counting when this bit is set. + /// + UINT32 EN:1; + /// + /// [Bit 23] INV: invert the CMASK. + /// + UINT32 INV:1; + /// + /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding + /// performance counter increments each cycle if the event count is + /// greater than or equal to the CMASK. + /// + UINT32 CMASK:8; + UINT32 Reserved:32; + /// + /// [Bit 32] IN_TX: see Section 18.11.5.1 When IN_TX (bit 32) is set, + /// AnyThread (bit 21) should be cleared to prevent incorrect results. + /// + UINT32 IN_TX:1; + /// + /// [Bit 33] IN_TXCP: see Section 18.11.5.1 When IN_TXCP=1 & IN_TX=1 and + /// in sampling, spurious PMI may occur and transactions may continuously + /// abort near overflow conditions. Software should favor using IN_TXCP + /// for counting over sampling. If sampling, software should use large + /// "sample-after" value after clearing the counter configured to use + /// IN_TXCP and also always reset the counter even when no overflow + /// condition was reported. + /// + UINT32 IN_TXCP:1; + UINT32 Reserved2:30; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER; + + +/** + Thread. Last Branch Record Filtering Select Register (R/W). + + @param ECX MSR_HASWELL_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_LBR_SELECT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_LBR_SELECT_REGISTER. + + Example usage + @code + MSR_HASWELL_LBR_SELECT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_LBR_SELECT); + AsmWriteMsr64 (MSR_HASWELL_LBR_SELECT, Msr.Uint64); + @endcode + @note MSR_HASWELL_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_HASWELL_LBR_SELECT 0x000001C8 + +/** + MSR information returned for MSR index #MSR_HASWELL_LBR_SELECT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CPL_EQ_0. + /// + UINT32 CPL_EQ_0:1; + /// + /// [Bit 1] CPL_NEQ_0. + /// + UINT32 CPL_NEQ_0:1; + /// + /// [Bit 2] JCC. + /// + UINT32 JCC:1; + /// + /// [Bit 3] NEAR_REL_CALL. + /// + UINT32 NEAR_REL_CALL:1; + /// + /// [Bit 4] NEAR_IND_CALL. + /// + UINT32 NEAR_IND_CALL:1; + /// + /// [Bit 5] NEAR_RET. + /// + UINT32 NEAR_RET:1; + /// + /// [Bit 6] NEAR_IND_JMP. + /// + UINT32 NEAR_IND_JMP:1; + /// + /// [Bit 7] NEAR_REL_JMP. + /// + UINT32 NEAR_REL_JMP:1; + /// + /// [Bit 8] FAR_BRANCH. + /// + UINT32 FAR_BRANCH:1; + /// + /// [Bit 9] EN_CALL_STACK. + /// + UINT32 EN_CALL_STACK:1; + UINT32 Reserved1:22; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_LBR_SELECT_REGISTER; + + +/** + Package. Package C6/C7 Interrupt Response Limit 1 (R/W) This MSR defines + the interrupt response time limit used by the processor to manage transition + to package C6 or C7 state. The latency programmed in this register is for + the shorter-latency sub C-states used by an MWAIT hint to C6 or C7 state. + Note: C-state values are processor specific C-state code names, unrelated to + MWAIT extension C-state parameters or ACPI C-States. + + @param ECX MSR_HASWELL_PKGC_IRTL1 (0x0000060B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKGC_IRTL1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKGC_IRTL1_REGISTER. + + Example usage + @code + MSR_HASWELL_PKGC_IRTL1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKGC_IRTL1); + AsmWriteMsr64 (MSR_HASWELL_PKGC_IRTL1, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKGC_IRTL1 is defined as MSR_PKGC_IRTL1 in SDM. +**/ +#define MSR_HASWELL_PKGC_IRTL1 0x0000060B + +/** + MSR information returned for MSR index #MSR_HASWELL_PKGC_IRTL1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C6 or C7 state. + /// + UINT32 InterruptResponseTimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. See Table 35-18 for + /// supported time unit encodings. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKGC_IRTL1_REGISTER; + + +/** + Package. Package C6/C7 Interrupt Response Limit 2 (R/W) This MSR defines + the interrupt response time limit used by the processor to manage transition + to package C6 or C7 state. The latency programmed in this register is for + the longer-latency sub Cstates used by an MWAIT hint to C6 or C7 state. + Note: C-state values are processor specific C-state code names, unrelated to + MWAIT extension C-state parameters or ACPI C-States. + + @param ECX MSR_HASWELL_PKGC_IRTL2 (0x0000060C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKGC_IRTL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKGC_IRTL2_REGISTER. + + Example usage + @code + MSR_HASWELL_PKGC_IRTL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKGC_IRTL2); + AsmWriteMsr64 (MSR_HASWELL_PKGC_IRTL2, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKGC_IRTL2 is defined as MSR_PKGC_IRTL2 in SDM. +**/ +#define MSR_HASWELL_PKGC_IRTL2 0x0000060C + +/** + MSR information returned for MSR index #MSR_HASWELL_PKGC_IRTL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C6 or C7 state. + /// + UINT32 InterruptResponseTimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. See Table 35-18 for + /// supported time unit encodings. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKGC_IRTL2_REGISTER; + + +/** + Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_HASWELL_PKG_PERF_STATUS (0x00000613) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_PKG_PERF_STATUS); + @endcode + @note MSR_HASWELL_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. +**/ +#define MSR_HASWELL_PKG_PERF_STATUS 0x00000613 + + +/** + Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_HASWELL_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_DRAM_ENERGY_STATUS); + @endcode + @note MSR_HASWELL_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_HASWELL_DRAM_ENERGY_STATUS 0x00000619 + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_HASWELL_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_DRAM_PERF_STATUS); + @endcode + @note MSR_HASWELL_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_HASWELL_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. Base TDP Ratio (R/O). + + @param ECX MSR_HASWELL_CONFIG_TDP_NOMINAL (0x00000648) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER. + + Example usage + @code + MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_NOMINAL); + @endcode + @note MSR_HASWELL_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. +**/ +#define MSR_HASWELL_CONFIG_TDP_NOMINAL 0x00000648 + +/** + MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_NOMINAL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Config_TDP_Base Base TDP level ratio to be used for this + /// specific processor (in units of 100 MHz). + /// + UINT32 Config_TDP_Base:8; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER; + + +/** + Package. ConfigTDP Level 1 ratio and power level (R/O). + + @param ECX MSR_HASWELL_CONFIG_TDP_LEVEL1 (0x00000649) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER. + + Example usage + @code + MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_LEVEL1); + @endcode + @note MSR_HASWELL_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. +**/ +#define MSR_HASWELL_CONFIG_TDP_LEVEL1 0x00000649 + +/** + MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_LEVEL1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] PKG_TDP_LVL1. Power setting for ConfigTDP Level 1. + /// + UINT32 PKG_TDP_LVL1:15; + UINT32 Reserved1:1; + /// + /// [Bits 23:16] Config_TDP_LVL1_Ratio. ConfigTDP level 1 ratio to be used + /// for this specific processor. + /// + UINT32 Config_TDP_LVL1_Ratio:8; + UINT32 Reserved2:8; + /// + /// [Bits 46:32] PKG_MAX_PWR_LVL1. Max Power setting allowed for ConfigTDP + /// Level 1. + /// + UINT32 PKG_MAX_PWR_LVL1:15; + /// + /// [Bits 62:47] PKG_MIN_PWR_LVL1. MIN Power setting allowed for ConfigTDP + /// Level 1. + /// + UINT32 PKG_MIN_PWR_LVL1:16; + UINT32 Reserved3:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER; + + +/** + Package. ConfigTDP Level 2 ratio and power level (R/O). + + @param ECX MSR_HASWELL_CONFIG_TDP_LEVEL2 (0x0000064A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER. + + Example usage + @code + MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_LEVEL2); + @endcode + @note MSR_HASWELL_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. +**/ +#define MSR_HASWELL_CONFIG_TDP_LEVEL2 0x0000064A + +/** + MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_LEVEL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] PKG_TDP_LVL2. Power setting for ConfigTDP Level 2. + /// + UINT32 PKG_TDP_LVL2:15; + UINT32 Reserved1:1; + /// + /// [Bits 23:16] Config_TDP_LVL2_Ratio. ConfigTDP level 2 ratio to be used + /// for this specific processor. + /// + UINT32 Config_TDP_LVL2_Ratio:8; + UINT32 Reserved2:8; + /// + /// [Bits 46:32] PKG_MAX_PWR_LVL2. Max Power setting allowed for ConfigTDP + /// Level 2. + /// + UINT32 PKG_MAX_PWR_LVL2:15; + /// + /// [Bits 62:47] PKG_MIN_PWR_LVL2. MIN Power setting allowed for ConfigTDP + /// Level 2. + /// + UINT32 PKG_MIN_PWR_LVL2:16; + UINT32 Reserved3:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER; + + +/** + Package. ConfigTDP Control (R/W). + + @param ECX MSR_HASWELL_CONFIG_TDP_CONTROL (0x0000064B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER. + + Example usage + @code + MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_CONTROL); + AsmWriteMsr64 (MSR_HASWELL_CONFIG_TDP_CONTROL, Msr.Uint64); + @endcode + @note MSR_HASWELL_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. +**/ +#define MSR_HASWELL_CONFIG_TDP_CONTROL 0x0000064B + +/** + MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] TDP_LEVEL (RW/L) System BIOS can program this field. + /// + UINT32 TDP_LEVEL:2; + UINT32 Reserved1:29; + /// + /// [Bit 31] Config_TDP_Lock (RW/L) When this bit is set, the content of + /// this register is locked until a reset. + /// + UINT32 Config_TDP_Lock:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER; + + +/** + Package. ConfigTDP Control (R/W). + + @param ECX MSR_HASWELL_TURBO_ACTIVATION_RATIO (0x0000064C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER. + + Example usage + @code + MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_TURBO_ACTIVATION_RATIO); + AsmWriteMsr64 (MSR_HASWELL_TURBO_ACTIVATION_RATIO, Msr.Uint64); + @endcode + @note MSR_HASWELL_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. +**/ +#define MSR_HASWELL_TURBO_ACTIVATION_RATIO 0x0000064C + +/** + MSR information returned for MSR index #MSR_HASWELL_TURBO_ACTIVATION_RATIO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this + /// field. + /// + UINT32 MAX_NON_TURBO_RATIO:8; + UINT32 Reserved1:23; + /// + /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the + /// content of this register is locked until a reset. + /// + UINT32 TURBO_ACTIVATION_RATIO_Lock:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are processor + specific C-state code names, unrelated to MWAIT extension C-state parameters + or ACPI Cstates. `See http://biosbits.org. `__. + + @param ECX MSR_HASWELL_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_HASWELL_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_HASWELL_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_HASWELL_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power) for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 0000b: + /// C0/C1 (no package C-state support) 0001b: C2 0010b: C3 0011b: C6 + /// 0100b: C7 0101b: C7s Package C states C7 are not available to + /// processor with signature 06_3CH. + /// + UINT32 Limit:4; + UINT32 Reserved1:6; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W). + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO). + /// + UINT32 CFGLock:1; + UINT32 Reserved3:9; + /// + /// [Bit 25] C3 State Auto Demotion Enable (R/W). + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 State Auto Demotion Enable (R/W). + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 Undemotion (R/W). + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 Undemotion (R/W). + /// + UINT32 C1Undemotion:1; + UINT32 Reserved4:3; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_HASWELL_SMM_MCA_CAP (0x0000017D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_SMM_MCA_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_SMM_MCA_CAP_REGISTER. + + Example usage + @code + MSR_HASWELL_SMM_MCA_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_SMM_MCA_CAP); + AsmWriteMsr64 (MSR_HASWELL_SMM_MCA_CAP, Msr.Uint64); + @endcode + @note MSR_HASWELL_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. +**/ +#define MSR_HASWELL_SMM_MCA_CAP 0x0000017D + +/** + MSR information returned for MSR index #MSR_HASWELL_SMM_MCA_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:26; + /// + /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the + /// SMM code access restriction is supported and the + /// MSR_SMM_FEATURE_CONTROL is supported. + /// + UINT32 SMM_Code_Access_Chk:1; + /// + /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the + /// SMM long flow indicator is supported and the MSR_SMM_DELAYED is + /// supported. + /// + UINT32 Long_Flow_Indication:1; + UINT32 Reserved3:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_SMM_MCA_CAP_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_HASWELL_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_TURBO_RATIO_LIMIT); + @endcode + @note MSR_HASWELL_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_HASWELL_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_HASWELL_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. Uncore PMU global control. + + @param ECX MSR_HASWELL_UNC_PERF_GLOBAL_CTRL (0x00000391) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER. + + Example usage + @code + MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); + @endcode + @note MSR_HASWELL_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_HASWELL_UNC_PERF_GLOBAL_CTRL 0x00000391 + +/** + MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_GLOBAL_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core 0 select. + /// + UINT32 PMI_Sel_Core0:1; + /// + /// [Bit 1] Core 1 select. + /// + UINT32 PMI_Sel_Core1:1; + /// + /// [Bit 2] Core 2 select. + /// + UINT32 PMI_Sel_Core2:1; + /// + /// [Bit 3] Core 3 select. + /// + UINT32 PMI_Sel_Core3:1; + UINT32 Reserved1:15; + UINT32 Reserved2:10; + /// + /// [Bit 29] Enable all uncore counters. + /// + UINT32 EN:1; + /// + /// [Bit 30] Enable wake on PMI. + /// + UINT32 WakePMI:1; + /// + /// [Bit 31] Enable Freezing counter when overflow. + /// + UINT32 FREEZE:1; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER; + + +/** + Package. Uncore PMU main status. + + @param ECX MSR_HASWELL_UNC_PERF_GLOBAL_STATUS (0x00000392) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_HASWELL_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_HASWELL_UNC_PERF_GLOBAL_STATUS 0x00000392 + +/** + MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fixed counter overflowed. + /// + UINT32 Fixed:1; + /// + /// [Bit 1] An ARB counter overflowed. + /// + UINT32 ARB:1; + UINT32 Reserved1:1; + /// + /// [Bit 3] A CBox counter overflowed (on any slice). + /// + UINT32 CBox:1; + UINT32 Reserved2:28; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Package. Uncore fixed counter control (R/W). + + @param ECX MSR_HASWELL_UNC_PERF_FIXED_CTRL (0x00000394) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER. + + Example usage + @code + MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTRL); + AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTRL, Msr.Uint64); + @endcode + @note MSR_HASWELL_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. +**/ +#define MSR_HASWELL_UNC_PERF_FIXED_CTRL 0x00000394 + +/** + MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_FIXED_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:20; + /// + /// [Bit 20] Enable overflow propagation. + /// + UINT32 EnableOverflow:1; + UINT32 Reserved2:1; + /// + /// [Bit 22] Enable counting. + /// + UINT32 EnableCounting:1; + UINT32 Reserved3:9; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER; + + +/** + Package. Uncore fixed counter. + + @param ECX MSR_HASWELL_UNC_PERF_FIXED_CTR (0x00000395) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER. + + Example usage + @code + MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTR); + AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTR, Msr.Uint64); + @endcode + @note MSR_HASWELL_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. +**/ +#define MSR_HASWELL_UNC_PERF_FIXED_CTR 0x00000395 + +/** + MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_FIXED_CTR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Current count. + /// + UINT32 CurrentCount:32; + /// + /// [Bits 47:32] Current count. + /// + UINT32 CurrentCountHi:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER; + + +/** + Package. Uncore C-Box configuration information (R/O). + + @param ECX MSR_HASWELL_UNC_CBO_CONFIG (0x00000396) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_CBO_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_UNC_CBO_CONFIG_REGISTER. + + Example usage + @code + MSR_HASWELL_UNC_CBO_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_CONFIG); + @endcode + @note MSR_HASWELL_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_CONFIG 0x00000396 + +/** + MSR information returned for MSR index #MSR_HASWELL_UNC_CBO_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Encoded number of C-Box, derive value by "-1". + /// + UINT32 CBox:4; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_UNC_CBO_CONFIG_REGISTER; + + +/** + Package. Uncore Arb unit, performance counter 0. + + @param ECX MSR_HASWELL_UNC_ARB_PERFCTR0 (0x000003B0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR0); + AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR0, Msr); + @endcode + @note MSR_HASWELL_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. +**/ +#define MSR_HASWELL_UNC_ARB_PERFCTR0 0x000003B0 + + +/** + Package. Uncore Arb unit, performance counter 1. + + @param ECX MSR_HASWELL_UNC_ARB_PERFCTR1 (0x000003B1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR1); + AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR1, Msr); + @endcode + @note MSR_HASWELL_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. +**/ +#define MSR_HASWELL_UNC_ARB_PERFCTR1 0x000003B1 + + +/** + Package. Uncore Arb unit, counter 0 event select MSR. + + @param ECX MSR_HASWELL_UNC_ARB_PERFEVTSEL0 (0x000003B2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL0, Msr); + @endcode + @note MSR_HASWELL_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. +**/ +#define MSR_HASWELL_UNC_ARB_PERFEVTSEL0 0x000003B2 + + +/** + Package. Uncore Arb unit, counter 1 event select MSR. + + @param ECX MSR_HASWELL_UNC_ARB_PERFEVTSEL1 (0x000003B3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL1); + AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL1, Msr); + @endcode + @note MSR_HASWELL_UNC_ARB_PERFEVTSEL1 is defined as MSR_UNC_ARB_PERFEVTSEL1 in SDM. +**/ +#define MSR_HASWELL_UNC_ARB_PERFEVTSEL1 0x000003B3 + + +/** + Package. Enhanced SMM Feature Control (SMM-RW) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_HASWELL_SMM_FEATURE_CONTROL (0x000004E0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_SMM_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_HASWELL_SMM_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_HASWELL_SMM_FEATURE_CONTROL is defined as MSR_SMM_FEATURE_CONTROL in SDM. +**/ +#define MSR_HASWELL_SMM_FEATURE_CONTROL 0x000004E0 + +/** + MSR information returned for MSR index #MSR_HASWELL_SMM_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock (SMM-RWO) When set to '1' locks this register from + /// further changes. + /// + UINT32 Lock:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] SMM_Code_Chk_En (SMM-RW) This control bit is available only if + /// MSR_SMM_MCA_CAP[58] == 1. When set to '0' (default) none of the + /// logical processors are prevented from executing SMM code outside the + /// ranges defined by the SMRR. When set to '1' any logical processor in + /// the package that attempts to execute SMM code not within the ranges + /// defined by the SMRR will assert an unrecoverable MCE. + /// + UINT32 SMM_Code_Chk_En:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER; + + +/** + Package. SMM Delayed (SMM-RO) Reports the interruptible state of all logical + processors in the package. Available only while in SMM and + MSR_SMM_MCA_CAP[LONG_FLOW_INDICATION] == 1. + + [Bits 31:0] LOG_PROC_STATE (SMM-RO) Each bit represents a logical + processor of its state in a long flow of internal operation which + delays servicing an interrupt. The corresponding bit will be set at + the start of long events such as: Microcode Update Load, C6, WBINVD, + Ratio Change, Throttle. The bit is automatically cleared at the end of + each long event. The reset value of this field is 0. Only bit + positions below N = CPUID.(EAX=0BH, ECX=PKG_LVL):EBX[15:0] can be + updated. + + [Bits 63:32] LOG_PROC_STATE (SMM-RO) Each bit represents a logical + processor of its state in a long flow of internal operation which + delays servicing an interrupt. The corresponding bit will be set at + the start of long events such as: Microcode Update Load, C6, WBINVD, + Ratio Change, Throttle. The bit is automatically cleared at the end of + each long event. The reset value of this field is 0. Only bit + positions below N = CPUID.(EAX=0BH, ECX=PKG_LVL):EBX[15:0] can be + updated. + + @param ECX MSR_HASWELL_SMM_DELAYED (0x000004E2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_SMM_DELAYED); + @endcode + @note MSR_HASWELL_SMM_DELAYED is defined as MSR_SMM_DELAYED in SDM. +**/ +#define MSR_HASWELL_SMM_DELAYED 0x000004E2 + + +/** + Package. SMM Blocked (SMM-RO) Reports the blocked state of all logical + processors in the package. Available only while in SMM. + + [Bits 31:0] LOG_PROC_STATE (SMM-RO) Each bit represents a logical + processor of its blocked state to service an SMI. The corresponding + bit will be set if the logical processor is in one of the following + states: Wait For SIPI or SENTER Sleep. The reset value of this field + is 0FFFH. Only bit positions below N = CPUID.(EAX=0BH, + ECX=PKG_LVL):EBX[15:0] can be updated. + + + [Bits 63:32] LOG_PROC_STATE (SMM-RO) Each bit represents a logical + processor of its blocked state to service an SMI. The corresponding + bit will be set if the logical processor is in one of the following + states: Wait For SIPI or SENTER Sleep. The reset value of this field + is 0FFFH. Only bit positions below N = CPUID.(EAX=0BH, + ECX=PKG_LVL):EBX[15:0] can be updated. + + @param ECX MSR_HASWELL_SMM_BLOCKED (0x000004E3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_SMM_BLOCKED); + @endcode + @note MSR_HASWELL_SMM_BLOCKED is defined as MSR_SMM_BLOCKED in SDM. +**/ +#define MSR_HASWELL_SMM_BLOCKED 0x000004E3 + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O). + + @param ECX MSR_HASWELL_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_HASWELL_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_RAPL_POWER_UNIT); + @endcode + @note MSR_HASWELL_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_HASWELL_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_HASWELL_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Package. Energy Status Units Energy related information + /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an + /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 + /// micro-joules). + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL + /// Interfaces.". + /// + UINT32 TimeUnits:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_HASWELL_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_PP0_ENERGY_STATUS); + @endcode + @note MSR_HASWELL_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_HASWELL_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. PP1 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 + RAPL Domains.". + + @param ECX MSR_HASWELL_PP1_POWER_LIMIT (0x00000640) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_PP1_POWER_LIMIT); + AsmWriteMsr64 (MSR_HASWELL_PP1_POWER_LIMIT, Msr); + @endcode + @note MSR_HASWELL_PP1_POWER_LIMIT is defined as MSR_PP1_POWER_LIMIT in SDM. +**/ +#define MSR_HASWELL_PP1_POWER_LIMIT 0x00000640 + + +/** + Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_HASWELL_PP1_ENERGY_STATUS (0x00000641) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_PP1_ENERGY_STATUS); + @endcode + @note MSR_HASWELL_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. +**/ +#define MSR_HASWELL_PP1_ENERGY_STATUS 0x00000641 + + +/** + Package. PP1 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_HASWELL_PP1_POLICY (0x00000642) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_PP1_POLICY); + AsmWriteMsr64 (MSR_HASWELL_PP1_POLICY, Msr); + @endcode + @note MSR_HASWELL_PP1_POLICY is defined as MSR_PP1_POLICY in SDM. +**/ +#define MSR_HASWELL_PP1_POLICY 0x00000642 + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_HASWELL_CORE_PERF_LIMIT_REASONS (0x00000690) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_HASWELL_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_HASWELL_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_HASWELL_CORE_PERF_LIMIT_REASONS 0x00000690 + +/** + MSR information returned for MSR index #MSR_HASWELL_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is + /// reduced below the operating system request due to assertion of + /// external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:2; + /// + /// [Bit 4] Graphics Driver Status (R0) When set, frequency is reduced + /// below the operating system request due to Processor Graphics driver + /// override. + /// + UINT32 GraphicsDriverStatus:1; + /// + /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) + /// When set, frequency is reduced below the operating system request + /// because the processor has detected that utilization is low. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + /// + /// [Bit 9] Core Power Limiting Status (R0) When set, frequency is reduced + /// below the operating system request due to domain-level power limiting. + /// + UINT32 PLStatus:1; + /// + /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL1. + /// + UINT32 PL1Status:1; + /// + /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL2. + /// + UINT32 PL2Status:1; + /// + /// [Bit 12] Max Turbo Limit Status (R0) When set, frequency is reduced + /// below the operating system request due to multi-core turbo limits. + /// + UINT32 MaxTurboLimitStatus:1; + /// + /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency + /// is reduced below the operating system request due to Turbo transition + /// attenuation. This prevents performance degradation due to frequent + /// operating ratio changes. + /// + UINT32 TurboTransitionAttenuationStatus:1; + UINT32 Reserved3:2; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved4:2; + /// + /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics + /// Driver Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 GraphicsDriverLog:1; + /// + /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, + /// indicates that the Autonomous Utilization-Based Frequency Control + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + /// + /// [Bit 25] Core Power Limiting Log When set, indicates that the Core + /// Power Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 PLLog:1; + /// + /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates + /// that the Package Level PL1 Power Limiting Status bit has asserted + /// since the log bit was last cleared. This log bit will remain set until + /// cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that + /// the Package Level PL2 Power Limiting Status bit has asserted since the + /// log bit was last cleared. This log bit will remain set until cleared + /// by software writing 0. + /// + UINT32 PL2Log:1; + /// + /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo + /// Limit Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MaxTurboLimitLog:1; + /// + /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the + /// Turbo Transition Attenuation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 TurboTransitionAttenuationLog:1; + UINT32 Reserved6:2; + UINT32 Reserved7:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER; + + +/** + Package. Indicator of Frequency Clipping in the Processor Graphics (R/W) + (frequency refers to processor graphics frequency). + + @param ECX MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS (0x000006B0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS is defined as MSR_GRAPHICS_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS 0x000006B0 + +/** + MSR information returned for MSR index + #MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the + /// operating system request due to assertion of external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:2; + /// + /// [Bit 4] Graphics Driver Status (R0) When set, frequency is reduced + /// below the operating system request due to Processor Graphics driver + /// override. + /// + UINT32 GraphicsDriverStatus:1; + /// + /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) + /// When set, frequency is reduced below the operating system request + /// because the processor has detected that utilization is low. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + /// + /// [Bit 9] Graphics Power Limiting Status (R0) When set, frequency is + /// reduced below the operating system request due to domain-level power + /// limiting. + /// + UINT32 GraphicsPowerLimitingStatus:1; + /// + /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL1. + /// + UINT32 PL1STatus:1; + /// + /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL2. + /// + UINT32 PL2Status:1; + UINT32 Reserved3:4; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved4:2; + /// + /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics + /// Driver Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 GraphicsDriverLog:1; + /// + /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, + /// indicates that the Autonomous Utilization-Based Frequency Control + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + /// + /// [Bit 25] Core Power Limiting Log When set, indicates that the Core + /// Power Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CorePowerLimitingLog:1; + /// + /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates + /// that the Package Level PL1 Power Limiting Status bit has asserted + /// since the log bit was last cleared. This log bit will remain set until + /// cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that + /// the Package Level PL2 Power Limiting Status bit has asserted since the + /// log bit was last cleared. This log bit will remain set until cleared + /// by software writing 0. + /// + UINT32 PL2Log:1; + /// + /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo + /// Limit Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MaxTurboLimitLog:1; + /// + /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the + /// Turbo Transition Attenuation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 TurboTransitionAttenuationLog:1; + UINT32 Reserved6:2; + UINT32 Reserved7:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER; + + +/** + Package. Indicator of Frequency Clipping in the Ring Interconnect (R/W) + (frequency refers to ring interconnect in the uncore). + + @param ECX MSR_HASWELL_RING_PERF_LIMIT_REASONS (0x000006B1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_RING_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_HASWELL_RING_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_HASWELL_RING_PERF_LIMIT_REASONS is defined as MSR_RING_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_HASWELL_RING_PERF_LIMIT_REASONS 0x000006B1 + +/** + MSR information returned for MSR index #MSR_HASWELL_RING_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the + /// operating system request due to assertion of external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:4; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + UINT32 Reserved3:1; + /// + /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL1. + /// + UINT32 PL1STatus:1; + /// + /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, + /// frequency is reduced below the operating system request due to + /// package-level power limiting PL2. + /// + UINT32 PL2Status:1; + UINT32 Reserved4:4; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved5:2; + /// + /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics + /// Driver Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 GraphicsDriverLog:1; + /// + /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, + /// indicates that the Autonomous Utilization-Based Frequency Control + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + UINT32 Reserved6:1; + /// + /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + /// + /// [Bit 25] Core Power Limiting Log When set, indicates that the Core + /// Power Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CorePowerLimitingLog:1; + /// + /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates + /// that the Package Level PL1 Power Limiting Status bit has asserted + /// since the log bit was last cleared. This log bit will remain set until + /// cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that + /// the Package Level PL2 Power Limiting Status bit has asserted since the + /// log bit was last cleared. This log bit will remain set until cleared + /// by software writing 0. + /// + UINT32 PL2Log:1; + /// + /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo + /// Limit Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MaxTurboLimitLog:1; + /// + /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the + /// Turbo Transition Attenuation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 TurboTransitionAttenuationLog:1; + UINT32 Reserved7:2; + UINT32 Reserved8:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER; + + +/** + Package. Uncore C-Box 0, counter 0 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 (0x00000700) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 0x00000700 + + +/** + Package. Uncore C-Box 0, counter 1 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 (0x00000701) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 0x00000701 + + +/** + Package. Uncore C-Box 0, performance counter 0. + + @param ECX MSR_HASWELL_UNC_CBO_0_PERFCTR0 (0x00000706) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_0_PERFCTR0 0x00000706 + + +/** + Package. Uncore C-Box 0, performance counter 1. + + @param ECX MSR_HASWELL_UNC_CBO_0_PERFCTR1 (0x00000707) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_0_PERFCTR1 0x00000707 + + +/** + Package. Uncore C-Box 1, counter 0 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 (0x00000710) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 0x00000710 + + +/** + Package. Uncore C-Box 1, counter 1 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 (0x00000711) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 0x00000711 + + +/** + Package. Uncore C-Box 1, performance counter 0. + + @param ECX MSR_HASWELL_UNC_CBO_1_PERFCTR0 (0x00000716) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_1_PERFCTR0 0x00000716 + + +/** + Package. Uncore C-Box 1, performance counter 1. + + @param ECX MSR_HASWELL_UNC_CBO_1_PERFCTR1 (0x00000717) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_1_PERFCTR1 0x00000717 + + +/** + Package. Uncore C-Box 2, counter 0 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 (0x00000720) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 0x00000720 + + +/** + Package. Uncore C-Box 2, counter 1 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 (0x00000721) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 0x00000721 + + +/** + Package. Uncore C-Box 2, performance counter 0. + + @param ECX MSR_HASWELL_UNC_CBO_2_PERFCTR0 (0x00000726) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_2_PERFCTR0 0x00000726 + + +/** + Package. Uncore C-Box 2, performance counter 1. + + @param ECX MSR_HASWELL_UNC_CBO_2_PERFCTR1 (0x00000727) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_2_PERFCTR1 0x00000727 + + +/** + Package. Uncore C-Box 3, counter 0 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 (0x00000730) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 0x00000730 + + +/** + Package. Uncore C-Box 3, counter 1 event select MSR. + + @param ECX MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 (0x00000731) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 0x00000731 + + +/** + Package. Uncore C-Box 3, performance counter 0. + + @param ECX MSR_HASWELL_UNC_CBO_3_PERFCTR0 (0x00000736) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR0); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR0, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_3_PERFCTR0 0x00000736 + + +/** + Package. Uncore C-Box 3, performance counter 1. + + @param ECX MSR_HASWELL_UNC_CBO_3_PERFCTR1 (0x00000737) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR1); + AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR1, Msr); + @endcode + @note MSR_HASWELL_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. +**/ +#define MSR_HASWELL_UNC_CBO_3_PERFCTR1 0x00000737 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. + + @param ECX MSR_HASWELL_PKG_C8_RESIDENCY (0x00000630) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER. + + Example usage + @code + MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C8_RESIDENCY); + AsmWriteMsr64 (MSR_HASWELL_PKG_C8_RESIDENCY, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKG_C8_RESIDENCY is defined as MSR_PKG_C8_RESIDENCY in SDM. +**/ +#define MSR_HASWELL_PKG_C8_RESIDENCY 0x00000630 + +/** + MSR information returned for MSR index #MSR_HASWELL_PKG_C8_RESIDENCY +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Package C8 Residency Counter. (R/O) Value since last reset + /// that this package is in processor-specific C8 states. Count at the + /// same frequency as the TSC. + /// + UINT32 C8ResidencyCounter:32; + /// + /// [Bits 59:32] Package C8 Residency Counter. (R/O) Value since last + /// reset that this package is in processor-specific C8 states. Count at + /// the same frequency as the TSC. + /// + UINT32 C8ResidencyCounterHi:28; + UINT32 Reserved:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. + + @param ECX MSR_HASWELL_PKG_C9_RESIDENCY (0x00000631) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER. + + Example usage + @code + MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C9_RESIDENCY); + AsmWriteMsr64 (MSR_HASWELL_PKG_C9_RESIDENCY, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKG_C9_RESIDENCY is defined as MSR_PKG_C9_RESIDENCY in SDM. +**/ +#define MSR_HASWELL_PKG_C9_RESIDENCY 0x00000631 + +/** + MSR information returned for MSR index #MSR_HASWELL_PKG_C9_RESIDENCY +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Package C9 Residency Counter. (R/O) Value since last reset + /// that this package is in processor-specific C9 states. Count at the + /// same frequency as the TSC. + /// + UINT32 C9ResidencyCounter:32; + /// + /// [Bits 59:32] Package C9 Residency Counter. (R/O) Value since last + /// reset that this package is in processor-specific C9 states. Count at + /// the same frequency as the TSC. + /// + UINT32 C9ResidencyCounterHi:28; + UINT32 Reserved:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. + + @param ECX MSR_HASWELL_PKG_C10_RESIDENCY (0x00000632) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER. + + Example usage + @code + MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C10_RESIDENCY); + AsmWriteMsr64 (MSR_HASWELL_PKG_C10_RESIDENCY, Msr.Uint64); + @endcode + @note MSR_HASWELL_PKG_C10_RESIDENCY is defined as MSR_PKG_C10_RESIDENCY in SDM. +**/ +#define MSR_HASWELL_PKG_C10_RESIDENCY 0x00000632 + +/** + MSR information returned for MSR index #MSR_HASWELL_PKG_C10_RESIDENCY +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Package C10 Residency Counter. (R/O) Value since last + /// reset that this package is in processor-specific C10 states. Count at + /// the same frequency as the TSC. + /// + UINT32 C10ResidencyCounter:32; + /// + /// [Bits 59:32] Package C10 Residency Counter. (R/O) Value since last + /// reset that this package is in processor-specific C10 states. Count at + /// the same frequency as the TSC. + /// + UINT32 C10ResidencyCounterHi:28; + UINT32 Reserved:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h new file mode 100644 index 0000000000..9eb07994ec --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h @@ -0,0 +1,2892 @@ +/** @file + MSR Definitions for Intel processors based on the Ivy Bridge microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.10. + +**/ + +#ifndef __IVY_BRIDGE_MSR_H__ +#define __IVY_BRIDGE_MSR_H__ + +#include + +/** + Is Intel processors based on the Ivy Bridge microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_IVY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x3A \ + ) \ + ) + +/** + Package. See http://biosbits.org. + + @param ECX MSR_IVY_BRIDGE_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_IVY_BRIDGE_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + UINT32 Reserved3:2; + /// + /// [Bit 32] Package. Low Power Mode Support (LPM) (R/O) When set to 1, + /// indicates that LPM is supported, and when set to 0, indicates LPM is + /// not supported. + /// + UINT32 LowPowerModeSupport:1; + /// + /// [Bits 34:33] Package. Number of ConfigTDP Levels (R/O) 00: Only Base + /// TDP level available. 01: One additional TDP level available. 02: Two + /// additional TDP level available. 11: Reserved. + /// + UINT32 ConfigTDPLevels:2; + UINT32 Reserved4:5; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + /// + /// [Bits 55:48] Package. Minimum Operating Ratio (R/O) Contains the + /// minimum supported operating ratio in units of 100 MHz. + /// + UINT32 MinimumOperatingRatio:8; + UINT32 Reserved5:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI C-States. See http://biosbits.org. + + @param ECX MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power). for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0/C1 (no package C-sate support) 001b: C2 010b: C6 no retention 011b: + /// C6 retention 100b: C7 101b: C7s 111: No package C-state limit. Note: + /// This field cannot be used to limit package C-state to C3. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map + /// IO_read instructions sent to IO register specified by + /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register + /// until next reset. + /// + UINT32 CFGLock:1; + UINT32 Reserved3:9; + /// + /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C6/C7 requests to C3 based on uncore + /// auto-demote information. + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C3/C6/C7 requests to C1 based on uncore + /// auto-demote information. + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 undemotion (R/W) When set, enables undemotion from + /// demoted C3. + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 undemotion (R/W) When set, enables undemotion from + /// demoted C1. + /// + UINT32 C1Undemotion:1; + UINT32 Reserved4:3; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_IVY_BRIDGE_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PP0_ENERGY_STATUS); + @endcode + @note MSR_IVY_BRIDGE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. Base TDP Ratio (R/O). + + @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL (0x00000648) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL); + @endcode + @note MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. +**/ +#define MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL 0x00000648 + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Config_TDP_Base Base TDP level ratio to be used for this + /// specific processor (in units of 100 MHz). + /// + UINT32 Config_TDP_Base:8; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER; + + +/** + Package. ConfigTDP Level 1 ratio and power level (R/O). + + @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 (0x00000649) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1); + @endcode + @note MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 0x00000649 + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] PKG_TDP_LVL1. Power setting for ConfigTDP Level 1. + /// + UINT32 PKG_TDP_LVL1:15; + UINT32 Reserved1:1; + /// + /// [Bits 23:16] Config_TDP_LVL1_Ratio. ConfigTDP level 1 ratio to be used + /// for this specific processor. + /// + UINT32 Config_TDP_LVL1_Ratio:8; + UINT32 Reserved2:8; + /// + /// [Bits 46:32] PKG_MAX_PWR_LVL1. Max Power setting allowed for ConfigTDP + /// Level 1. + /// + UINT32 PKG_MAX_PWR_LVL1:15; + UINT32 Reserved3:1; + /// + /// [Bits 62:48] PKG_MIN_PWR_LVL1. MIN Power setting allowed for ConfigTDP + /// Level 1. + /// + UINT32 PKG_MIN_PWR_LVL1:15; + UINT32 Reserved4:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER; + + +/** + Package. ConfigTDP Level 2 ratio and power level (R/O). + + @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 (0x0000064A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2); + @endcode + @note MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 0x0000064A + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] PKG_TDP_LVL2. Power setting for ConfigTDP Level 2. + /// + UINT32 PKG_TDP_LVL2:15; + UINT32 Reserved1:1; + /// + /// [Bits 23:16] Config_TDP_LVL2_Ratio. ConfigTDP level 2 ratio to be used + /// for this specific processor. + /// + UINT32 Config_TDP_LVL2_Ratio:8; + UINT32 Reserved2:8; + /// + /// [Bits 46:32] PKG_MAX_PWR_LVL2. Max Power setting allowed for ConfigTDP + /// Level 2. + /// + UINT32 PKG_MAX_PWR_LVL2:15; + UINT32 Reserved3:1; + /// + /// [Bits 62:48] PKG_MIN_PWR_LVL2. MIN Power setting allowed for ConfigTDP + /// Level 2. + /// + UINT32 PKG_MIN_PWR_LVL2:15; + UINT32 Reserved4:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER; + + +/** + Package. ConfigTDP Control (R/W). + + @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL (0x0000064B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. +**/ +#define MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL 0x0000064B + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] TDP_LEVEL (RW/L) System BIOS can program this field. + /// + UINT32 TDP_LEVEL:2; + UINT32 Reserved1:29; + /// + /// [Bit 31] Config_TDP_Lock (RW/L) When this bit is set, the content of + /// this register is locked until a reset. + /// + UINT32 Config_TDP_Lock:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER; + + +/** + Package. ConfigTDP Control (R/W). + + @param ECX MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO (0x0000064C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO); + AsmWriteMsr64 (MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. +**/ +#define MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO 0x0000064C + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this + /// field. + /// + UINT32 MAX_NON_TURBO_RATIO:8; + UINT32 Reserved1:23; + /// + /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the + /// content of this register is locked until a reset. + /// + UINT32 TURBO_ACTIVATION_RATIO_Lock:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER; + + +/** + Package. Protected Processor Inventory Number Enable Control (R/W). + + @param ECX MSR_IVY_BRIDGE_PPIN_CTL (0x0000004E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PPIN_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PPIN_CTL_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_PPIN_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PPIN_CTL, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_PPIN_CTL is defined as MSR_PPIN_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_PPIN_CTL 0x0000004E + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_PPIN_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LockOut (R/WO) Set 1to prevent further writes to MSR_PPIN_CTL. + /// Writing 1 to MSR_PPINCTL[bit 0] is permitted only if MSR_PPIN_CTL[bit + /// 1] is clear, Default is 0. BIOS should provide an opt-in menu to + /// enable the user to turn on MSR_PPIN_CTL[bit 1] for privileged + /// inventory initialization agent to access MSR_PPIN. After reading + /// MSR_PPIN, the privileged inventory initialization agent should write + /// '01b' to MSR_PPIN_CTL to disable further access to MSR_PPIN and + /// prevent unauthorized modification to MSR_PPIN_CTL. + /// + UINT32 LockOut:1; + /// + /// [Bit 1] Enable_PPIN (R/W) If 1, enables MSR_PPIN to be accessible + /// using RDMSR. Once set, attempt to write 1 to MSR_PPIN_CTL[bit 0] will + /// cause #GP. If 0, an attempt to read MSR_PPIN will cause #GP. Default + /// is 0. + /// + UINT32 Enable_PPIN:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_PPIN_CTL_REGISTER; + + +/** + Package. Protected Processor Inventory Number (R/O). Protected Processor + Inventory Number (R/O) A unique value within a given CPUID + family/model/stepping signature that a privileged inventory initialization + agent can access to identify each physical processor, when access to + MSR_PPIN is enabled. Access to MSR_PPIN is permitted only if + MSR_PPIN_CTL[bits 1:0] = '10b'. + + @param ECX MSR_IVY_BRIDGE_PPIN (0x0000004F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN); + @endcode + @note MSR_IVY_BRIDGE_PPIN is defined as MSR_PPIN in SDM. +**/ +#define MSR_IVY_BRIDGE_PPIN 0x0000004F + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_IVY_BRIDGE_PLATFORM_INFO_1 (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_PLATFORM_INFO_1 is defined as MSR_PLATFORM_INFO_1 in SDM. +**/ +#define MSR_IVY_BRIDGE_PLATFORM_INFO_1 0x000000CE + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_PLATFORM_INFO_1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:7; + /// + /// [Bit 23] Package. PPIN_CAP (R/O) When set to 1, indicates that + /// Protected Processor Inventory Number (PPIN) capability can be enabled + /// for privileged system inventory agent to read PPIN from MSR_PPIN. When + /// set to 0, PPIN capability is not supported. An attempt to access + /// MSR_PPIN_CTL or MSR_PPIN will cause #GP. + /// + UINT32 PPIN_CAP:1; + UINT32 Reserved3:4; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + /// + /// [Bit 30] Package. Programmable TJ OFFSET (R/O) When set to 1, + /// indicates that MSR_TEMPERATURE_TARGET.[27:24] is valid and writable to + /// specify an temperature offset. + /// + UINT32 TJOFFSET:1; + UINT32 Reserved4:1; + UINT32 Reserved5:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved6:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER; + + +/** + Package. MC Bank Error Configuration (R/W). + + @param ECX MSR_IVY_BRIDGE_ERROR_CONTROL (0x0000017F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_ERROR_CONTROL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_ERROR_CONTROL, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. +**/ +#define MSR_IVY_BRIDGE_ERROR_CONTROL 0x0000017F + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_ERROR_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank + /// to log additional info in bits 36:32. + /// + UINT32 MemErrorLogEnable:1; + UINT32 Reserved2:30; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER; + + +/** + Package. + + @param ECX MSR_IVY_BRIDGE_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_IVY_BRIDGE_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_IVY_BRIDGE_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (RO) The minimum temperature at which + /// PROCHOT# will be asserted. The value is degree C. + /// + UINT32 TemperatureTarget:8; + /// + /// [Bits 27:24] TCC Activation Offset (R/W) Specifies a temperature + /// offset in degrees C from the temperature target (bits 23:16). PROCHOT# + /// will assert at the offset target temperature. Write is permitted only + /// MSR_PLATFORM_INFO.[30] is set. + /// + UINT32 TCCActivationOffset:4; + UINT32 Reserved2:4; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 (0x000001AE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1); + @endcode + @note MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. +**/ +#define MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 0x000001AE + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 9C Maximum turbo ratio + /// limit of 9 core active. + /// + UINT32 Maximum9C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 10C Maximum turbo ratio + /// limit of 10core active. + /// + UINT32 Maximum10C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 11C Maximum turbo ratio + /// limit of 11 core active. + /// + UINT32 Maximum11C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 12C Maximum turbo ratio + /// limit of 12 core active. + /// + UINT32 Maximum12C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 13C Maximum turbo ratio + /// limit of 13 core active. + /// + UINT32 Maximum13C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 14C Maximum turbo ratio + /// limit of 14 core active. + /// + UINT32 Maximum14C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 15C Maximum turbo ratio + /// limit of 15 core active. + /// + UINT32 Maximum15C:8; + UINT32 Reserved:7; + /// + /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, + /// the processor uses override configuration specified in + /// MSR_TURBO_RATIO_LIMIT and MSR_TURBO_RATIO_LIMIT1. If 0, the processor + /// uses factory-set configuration (Default). + /// + UINT32 TurboRatioLimitConfigurationSemaphore:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER; + + +/** + Package. Misc MAC information of Integrated I/O. (R/O) see Section 15.3.2.4. + + @param ECX MSR_IVY_BRIDGE_IA32_MC6_MISC (0x0000041B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC6_MISC); + @endcode + @note MSR_IVY_BRIDGE_IA32_MC6_MISC is defined as IA32_MC6_MISC in SDM. +**/ +#define MSR_IVY_BRIDGE_IA32_MC6_MISC 0x0000041B + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_IA32_MC6_MISC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 5:0] Recoverable Address LSB. + /// + UINT32 RecoverableAddressLSB:6; + /// + /// [Bits 8:6] Address Mode. + /// + UINT32 AddressMode:3; + UINT32 Reserved1:7; + /// + /// [Bits 31:16] PCI Express Requestor ID. + /// + UINT32 PCIExpressRequestorID:16; + /// + /// [Bits 39:32] PCI Express Segment Number. + /// + UINT32 PCIExpressSegmentNumber:8; + UINT32 Reserved2:24; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER; + + +/** + Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section + 15.3.2.4, "IA32_MCi_MISC MSRs.". + + Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) + and its corresponding slice of L3. + + @param ECX MSR_IVY_BRIDGE_IA32_MCi_CTL + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_IA32_MC29_CTL is defined as IA32_MC29_CTL in SDM. + MSR_IVY_BRIDGE_IA32_MC30_CTL is defined as IA32_MC30_CTL in SDM. + MSR_IVY_BRIDGE_IA32_MC31_CTL is defined as IA32_MC31_CTL in SDM. + @{ +**/ +#define MSR_IVY_BRIDGE_IA32_MC29_CTL 0x00000474 +#define MSR_IVY_BRIDGE_IA32_MC30_CTL 0x00000478 +#define MSR_IVY_BRIDGE_IA32_MC31_CTL 0x0000047C +/// @} + + +/** + Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section + 15.3.2.4, "IA32_MCi_MISC MSRs.". + + Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) + and its corresponding slice of L3. + + @param ECX MSR_IVY_BRIDGE_IA32_MCi_STATUS + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_STATUS); + AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_STATUS, Msr); + @endcode + @note MSR_IVY_BRIDGE_IA32_MC29_STATUS is defined as IA32_MC29_STATUS in SDM. + MSR_IVY_BRIDGE_IA32_MC30_STATUS is defined as IA32_MC30_STATUS in SDM. + MSR_IVY_BRIDGE_IA32_MC31_STATUS is defined as IA32_MC31_STATUS in SDM. + @{ +**/ +#define MSR_IVY_BRIDGE_IA32_MC29_STATUS 0x00000475 +#define MSR_IVY_BRIDGE_IA32_MC30_STATUS 0x00000479 +#define MSR_IVY_BRIDGE_IA32_MC31_STATUS 0x0000047D +/// @} + + +/** + Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section + 15.3.2.4, "IA32_MCi_MISC MSRs.". + + Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) + and its corresponding slice of L3. + + @param ECX MSR_IVY_BRIDGE_IA32_MCi_ADDR + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_ADDR); + AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_ADDR, Msr); + @endcode + @note MSR_IVY_BRIDGE_IA32_MC29_ADDR is defined as IA32_MC29_ADDR in SDM. + MSR_IVY_BRIDGE_IA32_MC30_ADDR is defined as IA32_MC30_ADDR in SDM. + MSR_IVY_BRIDGE_IA32_MC31_ADDR is defined as IA32_MC31_ADDR in SDM. + @{ +**/ +#define MSR_IVY_BRIDGE_IA32_MC29_ADDR 0x00000476 +#define MSR_IVY_BRIDGE_IA32_MC30_ADDR 0x0000047A +#define MSR_IVY_BRIDGE_IA32_MC31_ADDR 0x0000047E +/// @} + + +/** + Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section + 15.3.2.4, "IA32_MCi_MISC MSRs.". + + Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) + and its corresponding slice of L3. + + @param ECX MSR_IVY_BRIDGE_IA32_MCi_MISC + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_MISC); + AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_MISC, Msr); + @endcode + @note MSR_IVY_BRIDGE_IA32_MC29_MISC is defined as IA32_MC29_MISC in SDM. + MSR_IVY_BRIDGE_IA32_MC30_MISC is defined as IA32_MC30_MISC in SDM. + MSR_IVY_BRIDGE_IA32_MC31_MISC is defined as IA32_MC31_MISC in SDM. + @{ +**/ +#define MSR_IVY_BRIDGE_IA32_MC29_MISC 0x00000477 +#define MSR_IVY_BRIDGE_IA32_MC30_MISC 0x0000047B +#define MSR_IVY_BRIDGE_IA32_MC31_MISC 0x0000047F +/// @} + + +/** + Package. Package RAPL Perf Status (R/O). + + @param ECX MSR_IVY_BRIDGE_PKG_PERF_STATUS (0x00000613) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PKG_PERF_STATUS); + @endcode + @note MSR_IVY_BRIDGE_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_PKG_PERF_STATUS 0x00000613 + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_IVY_BRIDGE_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_IVY_BRIDGE_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_IVY_BRIDGE_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS); + @endcode + @note MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS 0x00000619 + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_IVY_BRIDGE_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_PERF_STATUS); + @endcode + @note MSR_IVY_BRIDGE_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_IVY_BRIDGE_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_IVY_BRIDGE_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_IVY_BRIDGE_DRAM_POWER_INFO 0x0000061C + + +/** + Thread. See Section 18.8.1.1, "Precise Event Based Sampling (PEBS).". + + @param ECX MSR_IVY_BRIDGE_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PEBS_ENABLE); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_IVY_BRIDGE_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_IVY_BRIDGE_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_IVY_BRIDGE_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). + /// + UINT32 PEBS_EN_PMC0:1; + /// + /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). + /// + UINT32 PEBS_EN_PMC1:1; + /// + /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). + /// + UINT32 PEBS_EN_PMC2:1; + /// + /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). + /// + UINT32 PEBS_EN_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). + /// + UINT32 LL_EN_PMC0:1; + /// + /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). + /// + UINT32 LL_EN_PMC1:1; + /// + /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). + /// + UINT32 LL_EN_PMC2:1; + /// + /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). + /// + UINT32 LL_EN_PMC3:1; + UINT32 Reserved2:28; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER; + + +/** + Package. Uncore perfmon per-socket global control. + + @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_CTL (0x00000C00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_PMON_GLOBAL_CTL is defined as MSR_PMON_GLOBAL_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_PMON_GLOBAL_CTL 0x00000C00 + + +/** + Package. Uncore perfmon per-socket global status. + + @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS (0x00000C01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS, Msr); + @endcode + @note MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS is defined as MSR_PMON_GLOBAL_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS 0x00000C01 + + +/** + Package. Uncore perfmon per-socket global configuration. + + @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG (0x00000C06) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG, Msr); + @endcode + @note MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG is defined as MSR_PMON_GLOBAL_CONFIG in SDM. +**/ +#define MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG 0x00000C06 + + +/** + Package. Uncore U-box perfmon U-box wide status. + + @param ECX MSR_IVY_BRIDGE_U_PMON_BOX_STATUS (0x00000C15) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_U_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_IVY_BRIDGE_U_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_IVY_BRIDGE_U_PMON_BOX_STATUS is defined as MSR_U_PMON_BOX_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_U_PMON_BOX_STATUS 0x00000C15 + + +/** + Package. Uncore PCU perfmon box wide status. + + @param ECX MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS (0x00000C35) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS is defined as MSR_PCU_PMON_BOX_STATUS in SDM. +**/ +#define MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS 0x00000C35 + + +/** + Package. Uncore C-box 0 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 (0x00000D1A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 is defined as MSR_C0_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 0x00000D1A + + +/** + Package. Uncore C-box 1 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 (0x00000D3A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 is defined as MSR_C1_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 0x00000D3A + + +/** + Package. Uncore C-box 2 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 (0x00000D5A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 is defined as MSR_C2_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 0x00000D5A + + +/** + Package. Uncore C-box 3 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 (0x00000D7A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 is defined as MSR_C3_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 0x00000D7A + + +/** + Package. Uncore C-box 4 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 (0x00000D9A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 is defined as MSR_C4_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 0x00000D9A + + +/** + Package. Uncore C-box 5 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 (0x00000DBA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 is defined as MSR_C5_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 0x00000DBA + + +/** + Package. Uncore C-box 6 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 (0x00000DDA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 is defined as MSR_C6_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 0x00000DDA + + +/** + Package. Uncore C-box 7 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 (0x00000DFA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 is defined as MSR_C7_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 0x00000DFA + + +/** + Package. Uncore C-box 8 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_CTL (0x00000E04) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_BOX_CTL is defined as MSR_C8_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_BOX_CTL 0x00000E04 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 0. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 (0x00000E10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 is defined as MSR_C8_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 0x00000E10 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 1. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 (0x00000E11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 is defined as MSR_C8_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 0x00000E11 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 2. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 (0x00000E12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 is defined as MSR_C8_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 0x00000E12 + + +/** + Package. Uncore C-box 8 perfmon event select for C-box 8 counter 3. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 (0x00000E13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 is defined as MSR_C8_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 0x00000E13 + + +/** + Package. Uncore C-box 8 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER (0x00000E14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER is defined as MSR_C8_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER 0x00000E14 + + +/** + Package. Uncore C-box 8 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR0 (0x00000E16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_CTR0 0x00000E16 + + +/** + Package. Uncore C-box 8 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR1 (0x00000E17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_CTR1 0x00000E17 + + +/** + Package. Uncore C-box 8 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR2 (0x00000E18) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_CTR2 0x00000E18 + + +/** + Package. Uncore C-box 8 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR3 (0x00000E19) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_CTR3 0x00000E19 + + +/** + Package. Uncore C-box 8 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 (0x00000E1A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 is defined as MSR_C8_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 0x00000E1A + + +/** + Package. Uncore C-box 9 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_CTL (0x00000E24) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_BOX_CTL is defined as MSR_C9_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_BOX_CTL 0x00000E24 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 0. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 (0x00000E30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 is defined as MSR_C9_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 0x00000E30 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 1. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 (0x00000E31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 is defined as MSR_C9_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 0x00000E31 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 2. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 (0x00000E32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 is defined as MSR_C9_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 0x00000E32 + + +/** + Package. Uncore C-box 9 perfmon event select for C-box 9 counter 3. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 (0x00000E33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 is defined as MSR_C9_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 0x00000E33 + + +/** + Package. Uncore C-box 9 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER (0x00000E34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER is defined as MSR_C9_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER 0x00000E34 + + +/** + Package. Uncore C-box 9 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR0 (0x00000E36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_CTR0 0x00000E36 + + +/** + Package. Uncore C-box 9 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR1 (0x00000E37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_CTR1 0x00000E37 + + +/** + Package. Uncore C-box 9 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR2 (0x00000E38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_CTR2 0x00000E38 + + +/** + Package. Uncore C-box 9 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR3 (0x00000E39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_CTR3 0x00000E39 + + +/** + Package. Uncore C-box 9 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 (0x00000E3A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 is defined as MSR_C9_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 0x00000E3A + + +/** + Package. Uncore C-box 10 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_CTL (0x00000E44) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_BOX_CTL is defined as MSR_C10_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_BOX_CTL 0x00000E44 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 0. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 (0x00000E50) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 is defined as MSR_C10_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 0x00000E50 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 1. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 (0x00000E51) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 is defined as MSR_C10_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 0x00000E51 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 2. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 (0x00000E52) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 is defined as MSR_C10_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 0x00000E52 + + +/** + Package. Uncore C-box 10 perfmon event select for C-box 10 counter 3. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 (0x00000E53) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 is defined as MSR_C10_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 0x00000E53 + + +/** + Package. Uncore C-box 10 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER (0x00000E54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER is defined as MSR_C10_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER 0x00000E54 + + +/** + Package. Uncore C-box 10 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR0 (0x00000E56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_CTR0 is defined as MSR_C10_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_CTR0 0x00000E56 + + +/** + Package. Uncore C-box 10 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR1 (0x00000E57) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_CTR1 is defined as MSR_C10_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_CTR1 0x00000E57 + + +/** + Package. Uncore C-box 10 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR2 (0x00000E58) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_CTR2 is defined as MSR_C10_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_CTR2 0x00000E58 + + +/** + Package. Uncore C-box 10 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR3 (0x00000E59) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_CTR3 is defined as MSR_C10_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_CTR3 0x00000E59 + + +/** + Package. Uncore C-box 10 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 (0x00000E5A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 is defined as MSR_C10_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 0x00000E5A + + +/** + Package. Uncore C-box 11 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_CTL (0x00000E64) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_BOX_CTL is defined as MSR_C11_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_BOX_CTL 0x00000E64 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 0. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 (0x00000E70) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 is defined as MSR_C11_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 0x00000E70 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 1. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 (0x00000E71) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 is defined as MSR_C11_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 0x00000E71 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 2. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 (0x00000E72) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 is defined as MSR_C11_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 0x00000E72 + + +/** + Package. Uncore C-box 11 perfmon event select for C-box 11 counter 3. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 (0x00000E73) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 is defined as MSR_C11_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 0x00000E73 + + +/** + Package. Uncore C-box 11 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER (0x00000E74) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER is defined as MSR_C11_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER 0x00000E74 + + +/** + Package. Uncore C-box 11 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR0 (0x00000E76) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_CTR0 is defined as MSR_C11_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_CTR0 0x00000E76 + + +/** + Package. Uncore C-box 11 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR1 (0x00000E77) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_CTR1 is defined as MSR_C11_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_CTR1 0x00000E77 + + +/** + Package. Uncore C-box 11 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR2 (0x00000E78) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_CTR2 is defined as MSR_C11_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_CTR2 0x00000E78 + + +/** + Package. Uncore C-box 11 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR3 (0x00000E79) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_CTR3 is defined as MSR_C11_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_CTR3 0x00000E79 + + +/** + Package. Uncore C-box 11 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 (0x00000E7A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 is defined as MSR_C11_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 0x00000E7A + + +/** + Package. Uncore C-box 12 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_CTL (0x00000E84) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_BOX_CTL is defined as MSR_C12_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_BOX_CTL 0x00000E84 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 0. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 (0x00000E90) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 is defined as MSR_C12_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 0x00000E90 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 1. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 (0x00000E91) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 is defined as MSR_C12_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 0x00000E91 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 2. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 (0x00000E92) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 is defined as MSR_C12_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 0x00000E92 + + +/** + Package. Uncore C-box 12 perfmon event select for C-box 12 counter 3. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 (0x00000E93) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 is defined as MSR_C12_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 0x00000E93 + + +/** + Package. Uncore C-box 12 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER (0x00000E94) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER is defined as MSR_C12_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER 0x00000E94 + + +/** + Package. Uncore C-box 12 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR0 (0x00000E96) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_CTR0 is defined as MSR_C12_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_CTR0 0x00000E96 + + +/** + Package. Uncore C-box 12 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR1 (0x00000E97) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_CTR1 is defined as MSR_C12_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_CTR1 0x00000E97 + + +/** + Package. Uncore C-box 12 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR2 (0x00000E98) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_CTR2 is defined as MSR_C12_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_CTR2 0x00000E98 + + +/** + Package. Uncore C-box 12 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR3 (0x00000E99) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_CTR3 is defined as MSR_C12_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_CTR3 0x00000E99 + + +/** + Package. Uncore C-box 12 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 (0x00000E9A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 is defined as MSR_C12_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 0x00000E9A + + +/** + Package. Uncore C-box 13 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_CTL (0x00000EA4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_BOX_CTL is defined as MSR_C13_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_BOX_CTL 0x00000EA4 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 0. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 (0x00000EB0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 is defined as MSR_C13_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 0x00000EB0 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 1. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 (0x00000EB1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 is defined as MSR_C13_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 0x00000EB1 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 2. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 (0x00000EB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 is defined as MSR_C13_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 0x00000EB2 + + +/** + Package. Uncore C-box 13 perfmon event select for C-box 13 counter 3. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 (0x00000EB3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 is defined as MSR_C13_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 0x00000EB3 + + +/** + Package. Uncore C-box 13 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER (0x00000EB4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER is defined as MSR_C13_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER 0x00000EB4 + + +/** + Package. Uncore C-box 13 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR0 (0x00000EB6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_CTR0 is defined as MSR_C13_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_CTR0 0x00000EB6 + + +/** + Package. Uncore C-box 13 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR1 (0x00000EB7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_CTR1 is defined as MSR_C13_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_CTR1 0x00000EB7 + + +/** + Package. Uncore C-box 13 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR2 (0x00000EB8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_CTR2 is defined as MSR_C13_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_CTR2 0x00000EB8 + + +/** + Package. Uncore C-box 13 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR3 (0x00000EB9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_CTR3 is defined as MSR_C13_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_CTR3 0x00000EB9 + + +/** + Package. Uncore C-box 13 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 (0x00000EBA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 is defined as MSR_C13_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 0x00000EBA + + +/** + Package. Uncore C-box 14 perfmon local box wide control. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_CTL (0x00000EC4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_CTL, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_BOX_CTL is defined as MSR_C14_PMON_BOX_CTL in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_BOX_CTL 0x00000EC4 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 0. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 (0x00000ED0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 is defined as MSR_C14_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 0x00000ED0 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 1. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 (0x00000ED1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 is defined as MSR_C14_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 0x00000ED1 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 2. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 (0x00000ED2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 is defined as MSR_C14_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 0x00000ED2 + + +/** + Package. Uncore C-box 14 perfmon event select for C-box 14 counter 3. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 (0x00000ED3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 is defined as MSR_C14_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 0x00000ED3 + + +/** + Package. Uncore C-box 14 perfmon box wide filter. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER (0x00000ED4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER is defined as MSR_C14_PMON_BOX_FILTER in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER 0x00000ED4 + + +/** + Package. Uncore C-box 14 perfmon counter 0. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR0 (0x00000ED6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR0); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR0, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_CTR0 is defined as MSR_C14_PMON_CTR0 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_CTR0 0x00000ED6 + + +/** + Package. Uncore C-box 14 perfmon counter 1. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR1 (0x00000ED7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_CTR1 is defined as MSR_C14_PMON_CTR1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_CTR1 0x00000ED7 + + +/** + Package. Uncore C-box 14 perfmon counter 2. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR2 (0x00000ED8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR2); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR2, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_CTR2 is defined as MSR_C14_PMON_CTR2 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_CTR2 0x00000ED8 + + +/** + Package. Uncore C-box 14 perfmon counter 3. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR3 (0x00000ED9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR3); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR3, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_CTR3 is defined as MSR_C14_PMON_CTR3 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_CTR3 0x00000ED9 + + +/** + Package. Uncore C-box 14 perfmon box wide filter1. + + @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 (0x00000EDA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1); + AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1, Msr); + @endcode + @note MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 is defined as MSR_C14_PMON_BOX_FILTER1 in SDM. +**/ +#define MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 0x00000EDA + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h new file mode 100644 index 0000000000..94aebba4d1 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h @@ -0,0 +1,7430 @@ +/** @file + MSR Definitions for Intel processors based on the Nehalem microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.6. + +**/ + +#ifndef __NEHALEM_MSR_H__ +#define __NEHALEM_MSR_H__ + +#include + +/** + Is Intel processors based on the Nehalem microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_NEHALEM_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x1A || \ + DisplayModel == 0x1E || \ + DisplayModel == 0x1F || \ + DisplayModel == 0x2E \ + ) \ + ) + +/** + Package. Model Specific Platform ID (R). + + @param ECX MSR_NEHALEM_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_NEHALEM_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PLATFORM_ID); + @endcode + @note MSR_NEHALEM_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. +**/ +#define MSR_NEHALEM_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:18; + /// + /// [Bits 52:50] See Table 35-2. + /// + UINT32 PlatformId:3; + UINT32 Reserved3:11; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PLATFORM_ID_REGISTER; + + +/** + Thread. SMI Counter (R/O). + + @param ECX MSR_NEHALEM_SMI_COUNT (0x00000034) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_SMI_COUNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_SMI_COUNT_REGISTER. + + Example usage + @code + MSR_NEHALEM_SMI_COUNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_SMI_COUNT); + @endcode + @note MSR_NEHALEM_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. +**/ +#define MSR_NEHALEM_SMI_COUNT 0x00000034 + +/** + MSR information returned for MSR index #MSR_NEHALEM_SMI_COUNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] SMI Count (R/O) Running count of SMI events since last + /// RESET. + /// + UINT32 SMICount:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_SMI_COUNT_REGISTER; + + +/** + Package. see http://biosbits.org. + + @param ECX MSR_NEHALEM_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_NEHALEM_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PLATFORM_INFO); + AsmWriteMsr64 (MSR_NEHALEM_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_NEHALEM_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_NEHALEM_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. The invariant TSC + /// frequency can be computed by multiplying this ratio by 133.33 MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDC-TDP Limit for Turbo Mode (R/O) + /// When set to 1, indicates that TDC/TDP Limits for Turbo mode are + /// programmable, and when set to 0, indicates TDC and TDP Limits for + /// Turbo mode are not programmable. + /// + UINT32 TDC_TDPLimit:1; + UINT32 Reserved3:2; + UINT32 Reserved4:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 133.33MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved5:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PLATFORM_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. See http://biosbits.org. + + @param ECX MSR_NEHALEM_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_NEHALEM_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_NEHALEM_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power). for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0 (no package C-sate support) 001b: C1 (Behavior is the same as 000b) + /// 010b: C3 011b: C6 100b: C7 101b and 110b: Reserved 111: No package + /// C-state limit. Note: This field cannot be used to limit package + /// C-state to C3. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map + /// IO_read instructions sent to IO register specified by + /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register + /// until next reset. + /// + UINT32 CFGLock:1; + UINT32 Reserved3:8; + /// + /// [Bit 24] Interrupt filtering enable (R/W) When set, processor cores + /// in a deep C-State will wake only when the event message is destined + /// for that core. When 0, all processor cores in a deep C-State will wake + /// for an event message. + /// + UINT32 InterruptFiltering:1; + /// + /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C6/C7 requests to C3 based on uncore + /// auto-demote information. + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C3/C6/C7 requests to C1 based on uncore + /// auto-demote information. + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 Undemotion (R/W). + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 Undemotion (R/W). + /// + UINT32 C1Undemotion:1; + /// + /// [Bit 29] Package C State Demotion Enable (R/W). + /// + UINT32 CStateDemotion:1; + /// + /// [Bit 30] Package C State UnDemotion Enable (R/W). + /// + UINT32 CStateUndemotion:1; + UINT32 Reserved4:1; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Core. Power Management IO Redirection in C-state (R/W) See + http://biosbits.org. + + @param ECX MSR_NEHALEM_PMG_IO_CAPTURE_BASE (0x000000E4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER. + + Example usage + @code + MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PMG_IO_CAPTURE_BASE); + AsmWriteMsr64 (MSR_NEHALEM_PMG_IO_CAPTURE_BASE, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. +**/ +#define MSR_NEHALEM_PMG_IO_CAPTURE_BASE 0x000000E4 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PMG_IO_CAPTURE_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address + /// visible to software for IO redirection. If IO MWAIT Redirection is + /// enabled, reads to this address will be consumed by the power + /// management logic and decoded to MWAIT instructions. When IO port + /// address redirection is enabled, this is the IO port address reported + /// to the OS/software. + /// + UINT32 Lvl2Base:16; + /// + /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the + /// maximum C-State code name to be included when IO read to MWAIT + /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 000b - C3 + /// is the max C-State to include 001b - C6 is the max C-State to include + /// 010b - C7 is the max C-State to include. + /// + UINT32 CStateRange:3; + UINT32 Reserved1:13; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_NEHALEM_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_NEHALEM_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_NEHALEM_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_NEHALEM_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_NEHALEM_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Thread. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. Default value is 1. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Thread. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:3; + /// + /// [Bit 11] Thread. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Thread. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + UINT32 Reserved4:3; + /// + /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] Thread. ENABLE MONITOR FSM. (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved6:3; + /// + /// [Bit 22] Thread. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Thread. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] Thread. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved9:3; + /// + /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors + /// that support Intel Turbo Boost Technology, the turbo mode feature is + /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: + /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: + /// EAX[1] reports the processor's support of turbo mode is enabled. Note: + /// the power-on default value is used by BIOS to detect hardware support + /// of turbo mode. If power-on default value is 1, turbo mode is available + /// in the processor. If power-on default value is 0, turbo mode is not + /// available. + /// + UINT32 TurboModeDisable:1; + UINT32 Reserved10:25; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER; + + +/** + Thread. + + @param ECX MSR_NEHALEM_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_NEHALEM_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_NEHALEM_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_NEHALEM_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_NEHALEM_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (R) The minimum temperature at which + /// PROCHOT# will be asserted. The value is degree C. + /// + UINT32 TemperatureTarget:8; + UINT32 Reserved2:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER; + + +/** + Miscellaneous Feature Control (R/W). + + @param ECX MSR_NEHALEM_MISC_FEATURE_CONTROL (0x000001A4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_MISC_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_NEHALEM_MISC_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_NEHALEM_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. +**/ +#define MSR_NEHALEM_MISC_FEATURE_CONTROL 0x000001A4 + +/** + MSR information returned for MSR index #MSR_NEHALEM_MISC_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the + /// L2 hardware prefetcher, which fetches additional lines of code or data + /// into the L2 cache. + /// + UINT32 L2HardwarePrefetcherDisable:1; + /// + /// [Bit 1] Core. L2 Adjacent Cache Line Prefetcher Disable (R/W) If 1, + /// disables the adjacent cache line prefetcher, which fetches the cache + /// line that comprises a cache line pair (128 bytes). + /// + UINT32 L2AdjacentCacheLinePrefetcherDisable:1; + /// + /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables + /// the L1 data cache prefetcher, which fetches the next cache line into + /// L1 data cache. + /// + UINT32 DCUHardwarePrefetcherDisable:1; + /// + /// [Bit 3] Core. DCU IP Prefetcher Disable (R/W) If 1, disables the L1 + /// data cache IP prefetcher, which uses sequential load history (based on + /// instruction Pointer of previous loads) to determine whether to + /// prefetch additional lines. + /// + UINT32 DCUIPPrefetcherDisable:1; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER; + + +/** + Thread. Offcore Response Event Select Register (R/W). + + @param ECX MSR_NEHALEM_OFFCORE_RSP_0 (0x000001A6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_OFFCORE_RSP_0); + AsmWriteMsr64 (MSR_NEHALEM_OFFCORE_RSP_0, Msr); + @endcode + @note MSR_NEHALEM_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. +**/ +#define MSR_NEHALEM_OFFCORE_RSP_0 0x000001A6 + + +/** + See http://biosbits.org. + + @param ECX MSR_NEHALEM_MISC_PWR_MGMT (0x000001AA) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_MISC_PWR_MGMT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_MISC_PWR_MGMT_REGISTER. + + Example usage + @code + MSR_NEHALEM_MISC_PWR_MGMT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_MISC_PWR_MGMT); + AsmWriteMsr64 (MSR_NEHALEM_MISC_PWR_MGMT, Msr.Uint64); + @endcode + @note MSR_NEHALEM_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. +**/ +#define MSR_NEHALEM_MISC_PWR_MGMT 0x000001AA + +/** + MSR information returned for MSR index #MSR_NEHALEM_MISC_PWR_MGMT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Package. EIST Hardware Coordination Disable (R/W) When 0, + /// enables hardware coordination of Enhanced Intel Speedstep Technology + /// request from processor cores; When 1, disables hardware coordination + /// of Enhanced Intel Speedstep Technology requests. + /// + UINT32 EISTHardwareCoordinationDisable:1; + /// + /// [Bit 1] Thread. Energy/Performance Bias Enable (R/W) This bit makes + /// the IA32_ENERGY_PERF_BIAS register (MSR 1B0h) visible to software with + /// Ring 0 privileges. This bit's status (1 or 0) is also reflected by + /// CPUID.(EAX=06h):ECX[3]. + /// + UINT32 EnergyPerformanceBiasEnable:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_MISC_PWR_MGMT_REGISTER; + + +/** + See http://biosbits.org. + + @param ECX MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT (0x000001AC) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER. + + Example usage + @code + MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT); + AsmWriteMsr64 (MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT, Msr.Uint64); + @endcode + @note MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT is defined as MSR_TURBO_POWER_CURRENT_LIMIT in SDM. +**/ +#define MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT 0x000001AC + +/** + MSR information returned for MSR index #MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Package. TDP Limit (R/W) TDP limit in 1/8 Watt + /// granularity. + /// + UINT32 TDPLimit:15; + /// + /// [Bit 15] Package. TDP Limit Override Enable (R/W) A value = 0 + /// indicates override is not active, and a value = 1 indicates active. + /// + UINT32 TDPLimitOverrideEnable:1; + /// + /// [Bits 30:16] Package. TDC Limit (R/W) TDC limit in 1/8 Amp + /// granularity. + /// + UINT32 TDCLimit:15; + /// + /// [Bit 31] Package. TDC Limit Override Enable (R/W) A value = 0 + /// indicates override is not active, and a value = 1 indicates active. + /// + UINT32 TDCLimitOverrideEnable:1; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_NEHALEM_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TURBO_RATIO_LIMIT); + @endcode + @note MSR_NEHALEM_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_NEHALEM_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Core. Last Branch Record Filtering Select Register (R/W) See Section + 17.7.2, "Filtering of Last Branch Records.". + + @param ECX MSR_NEHALEM_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_LBR_SELECT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_LBR_SELECT_REGISTER. + + Example usage + @code + MSR_NEHALEM_LBR_SELECT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_LBR_SELECT); + AsmWriteMsr64 (MSR_NEHALEM_LBR_SELECT, Msr.Uint64); + @endcode + @note MSR_NEHALEM_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_NEHALEM_LBR_SELECT 0x000001C8 + +/** + MSR information returned for MSR index #MSR_NEHALEM_LBR_SELECT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CPL_EQ_0. + /// + UINT32 CPL_EQ_0:1; + /// + /// [Bit 1] CPL_NEQ_0. + /// + UINT32 CPL_NEQ_0:1; + /// + /// [Bit 2] JCC. + /// + UINT32 JCC:1; + /// + /// [Bit 3] NEAR_REL_CALL. + /// + UINT32 NEAR_REL_CALL:1; + /// + /// [Bit 4] NEAR_IND_CALL. + /// + UINT32 NEAR_IND_CALL:1; + /// + /// [Bit 5] NEAR_RET. + /// + UINT32 NEAR_RET:1; + /// + /// [Bit 6] NEAR_IND_JMP. + /// + UINT32 NEAR_IND_JMP:1; + /// + /// [Bit 7] NEAR_REL_JMP. + /// + UINT32 NEAR_REL_JMP:1; + /// + /// [Bit 8] FAR_BRANCH. + /// + UINT32 FAR_BRANCH:1; + UINT32 Reserved1:23; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_LBR_SELECT_REGISTER; + + +/** + Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) + that points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP (at 680H). + + @param ECX MSR_NEHALEM_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_NEHALEM_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_NEHALEM_LASTBRANCH_TOS 0x000001C9 + + +/** + Thread. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_NEHALEM_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_LER_FROM_LIP); + @endcode + @note MSR_NEHALEM_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_NEHALEM_LER_FROM_LIP 0x000001DD + + +/** + Thread. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_NEHALEM_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_LER_TO_LIP); + @endcode + @note MSR_NEHALEM_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_NEHALEM_LER_TO_LIP 0x000001DE + + +/** + Core. Power Control Register. See http://biosbits.org. + + @param ECX MSR_NEHALEM_POWER_CTL (0x000001FC) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_POWER_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_POWER_CTL_REGISTER. + + Example usage + @code + MSR_NEHALEM_POWER_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_POWER_CTL); + AsmWriteMsr64 (MSR_NEHALEM_POWER_CTL, Msr.Uint64); + @endcode + @note MSR_NEHALEM_POWER_CTL is defined as MSR_POWER_CTL in SDM. +**/ +#define MSR_NEHALEM_POWER_CTL 0x000001FC + +/** + MSR information returned for MSR index #MSR_NEHALEM_POWER_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Package. C1E Enable (R/W) When set to '1', will enable the + /// CPU to switch to the Minimum Enhanced Intel SpeedStep Technology + /// operating point when all execution cores enter MWAIT (C1). + /// + UINT32 C1EEnable:1; + UINT32 Reserved2:30; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_POWER_CTL_REGISTER; + + +/** + Thread. (RO). + + @param ECX MSR_NEHALEM_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PERF_GLOBAL_STATUS); + @endcode + @note MSR_NEHALEM_PERF_GLOBAL_STATUS is defined as MSR_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_NEHALEM_PERF_GLOBAL_STATUS 0x0000038E + +/** + MSR information returned for MSR index #MSR_NEHALEM_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:29; + /// + /// [Bit 61] UNC_Ovf Uncore overflowed if 1. + /// + UINT32 Ovf_Uncore:1; + UINT32 Reserved3:2; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Thread. (R/W). + + @param ECX MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER. + + Example usage + @code + MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL is defined as MSR_PERF_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL 0x00000390 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:29; + /// + /// [Bit 61] CLR_UNC_Ovf Set 1 to clear UNC_Ovf. + /// + UINT32 Ovf_Uncore:1; + UINT32 Reserved3:2; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER; + + +/** + Thread. See Section 18.8.1.1, "Processor Event Based Sampling (PEBS).". + + @param ECX MSR_NEHALEM_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_NEHALEM_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PEBS_ENABLE); + AsmWriteMsr64 (MSR_NEHALEM_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_NEHALEM_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). + /// + UINT32 PEBS_EN_PMC0:1; + /// + /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). + /// + UINT32 PEBS_EN_PMC1:1; + /// + /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). + /// + UINT32 PEBS_EN_PMC2:1; + /// + /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). + /// + UINT32 PEBS_EN_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). + /// + UINT32 LL_EN_PMC0:1; + /// + /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). + /// + UINT32 LL_EN_PMC1:1; + /// + /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). + /// + UINT32 LL_EN_PMC2:1; + /// + /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). + /// + UINT32 LL_EN_PMC3:1; + UINT32 Reserved2:28; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PEBS_ENABLE_REGISTER; + + +/** + Thread. See Section 18.8.1.2, "Load Latency Performance Monitoring + Facility.". + + @param ECX MSR_NEHALEM_PEBS_LD_LAT (0x000003F6) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_PEBS_LD_LAT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_PEBS_LD_LAT_REGISTER. + + Example usage + @code + MSR_NEHALEM_PEBS_LD_LAT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PEBS_LD_LAT); + AsmWriteMsr64 (MSR_NEHALEM_PEBS_LD_LAT, Msr.Uint64); + @endcode + @note MSR_NEHALEM_PEBS_LD_LAT is defined as MSR_PEBS_LD_LAT in SDM. +**/ +#define MSR_NEHALEM_PEBS_LD_LAT 0x000003F6 + +/** + MSR information returned for MSR index #MSR_NEHALEM_PEBS_LD_LAT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Minimum threshold latency value of tagged load operation + /// that will be counted. (R/W). + /// + UINT32 MinimumThreshold:16; + UINT32 Reserved1:16; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_PEBS_LD_LAT_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_NEHALEM_PKG_C3_RESIDENCY (0x000003F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C3_RESIDENCY); + AsmWriteMsr64 (MSR_NEHALEM_PKG_C3_RESIDENCY, Msr); + @endcode + @note MSR_NEHALEM_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. +**/ +#define MSR_NEHALEM_PKG_C3_RESIDENCY 0x000003F8 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C6 states. Count at the same frequency as the TSC. + + @param ECX MSR_NEHALEM_PKG_C6_RESIDENCY (0x000003F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_NEHALEM_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_NEHALEM_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_NEHALEM_PKG_C6_RESIDENCY 0x000003F9 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C7 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C7 states. Count at the same frequency as the TSC. + + @param ECX MSR_NEHALEM_PKG_C7_RESIDENCY (0x000003FA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C7_RESIDENCY); + AsmWriteMsr64 (MSR_NEHALEM_PKG_C7_RESIDENCY, Msr); + @endcode + @note MSR_NEHALEM_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. +**/ +#define MSR_NEHALEM_PKG_C7_RESIDENCY 0x000003FA + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_NEHALEM_CORE_C3_RESIDENCY (0x000003FC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_CORE_C3_RESIDENCY); + AsmWriteMsr64 (MSR_NEHALEM_CORE_C3_RESIDENCY, Msr); + @endcode + @note MSR_NEHALEM_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. +**/ +#define MSR_NEHALEM_CORE_C3_RESIDENCY 0x000003FC + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C6 states. Count at the same frequency as the TSC. + + @param ECX MSR_NEHALEM_CORE_C6_RESIDENCY (0x000003FD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_CORE_C6_RESIDENCY); + AsmWriteMsr64 (MSR_NEHALEM_CORE_C6_RESIDENCY, Msr); + @endcode + @note MSR_NEHALEM_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. +**/ +#define MSR_NEHALEM_CORE_C6_RESIDENCY 0x000003FD + + +/** + Thread. Last Branch Record n From IP (R/W) One of sixteen pairs of last + branch record registers on the last branch record stack. The From_IP part of + the stack contains pointers to the source instruction. See also: - Last + Branch Record Stack TOS at 1C9H - Section 17.7.1 and record format in + Section 17.4.8.1. + + @param ECX MSR_NEHALEM_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_NEHALEM_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. + MSR_NEHALEM_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. + @{ +**/ +#define MSR_NEHALEM_LASTBRANCH_0_FROM_IP 0x00000680 +#define MSR_NEHALEM_LASTBRANCH_1_FROM_IP 0x00000681 +#define MSR_NEHALEM_LASTBRANCH_2_FROM_IP 0x00000682 +#define MSR_NEHALEM_LASTBRANCH_3_FROM_IP 0x00000683 +#define MSR_NEHALEM_LASTBRANCH_4_FROM_IP 0x00000684 +#define MSR_NEHALEM_LASTBRANCH_5_FROM_IP 0x00000685 +#define MSR_NEHALEM_LASTBRANCH_6_FROM_IP 0x00000686 +#define MSR_NEHALEM_LASTBRANCH_7_FROM_IP 0x00000687 +#define MSR_NEHALEM_LASTBRANCH_8_FROM_IP 0x00000688 +#define MSR_NEHALEM_LASTBRANCH_9_FROM_IP 0x00000689 +#define MSR_NEHALEM_LASTBRANCH_10_FROM_IP 0x0000068A +#define MSR_NEHALEM_LASTBRANCH_11_FROM_IP 0x0000068B +#define MSR_NEHALEM_LASTBRANCH_12_FROM_IP 0x0000068C +#define MSR_NEHALEM_LASTBRANCH_13_FROM_IP 0x0000068D +#define MSR_NEHALEM_LASTBRANCH_14_FROM_IP 0x0000068E +#define MSR_NEHALEM_LASTBRANCH_15_FROM_IP 0x0000068F +/// @} + + +/** + Thread. Last Branch Record n To IP (R/W) One of sixteen pairs of last branch + record registers on the last branch record stack. This part of the stack + contains pointers to the destination instruction. + + @param ECX MSR_NEHALEM_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_NEHALEM_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. + MSR_NEHALEM_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. + @{ +**/ +#define MSR_NEHALEM_LASTBRANCH_0_TO_IP 0x000006C0 +#define MSR_NEHALEM_LASTBRANCH_1_TO_IP 0x000006C1 +#define MSR_NEHALEM_LASTBRANCH_2_TO_IP 0x000006C2 +#define MSR_NEHALEM_LASTBRANCH_3_TO_IP 0x000006C3 +#define MSR_NEHALEM_LASTBRANCH_4_TO_IP 0x000006C4 +#define MSR_NEHALEM_LASTBRANCH_5_TO_IP 0x000006C5 +#define MSR_NEHALEM_LASTBRANCH_6_TO_IP 0x000006C6 +#define MSR_NEHALEM_LASTBRANCH_7_TO_IP 0x000006C7 +#define MSR_NEHALEM_LASTBRANCH_8_TO_IP 0x000006C8 +#define MSR_NEHALEM_LASTBRANCH_9_TO_IP 0x000006C9 +#define MSR_NEHALEM_LASTBRANCH_10_TO_IP 0x000006CA +#define MSR_NEHALEM_LASTBRANCH_11_TO_IP 0x000006CB +#define MSR_NEHALEM_LASTBRANCH_12_TO_IP 0x000006CC +#define MSR_NEHALEM_LASTBRANCH_13_TO_IP 0x000006CD +#define MSR_NEHALEM_LASTBRANCH_14_TO_IP 0x000006CE +#define MSR_NEHALEM_LASTBRANCH_15_TO_IP 0x000006CF +/// @} + + +/** + Package. + + @param ECX MSR_NEHALEM_GQ_SNOOP_MESF (0x00000301) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER. + + Example usage + @code + MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_GQ_SNOOP_MESF); + AsmWriteMsr64 (MSR_NEHALEM_GQ_SNOOP_MESF, Msr.Uint64); + @endcode + @note MSR_NEHALEM_GQ_SNOOP_MESF is defined as MSR_GQ_SNOOP_MESF in SDM. +**/ +#define MSR_NEHALEM_GQ_SNOOP_MESF 0x00000301 + +/** + MSR information returned for MSR index #MSR_NEHALEM_GQ_SNOOP_MESF +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] From M to S (R/W). + /// + UINT32 FromMtoS:1; + /// + /// [Bit 1] From E to S (R/W). + /// + UINT32 FromEtoS:1; + /// + /// [Bit 2] From S to S (R/W). + /// + UINT32 FromStoS:1; + /// + /// [Bit 3] From F to S (R/W). + /// + UINT32 FromFtoS:1; + /// + /// [Bit 4] From M to I (R/W). + /// + UINT32 FromMtoI:1; + /// + /// [Bit 5] From E to I (R/W). + /// + UINT32 FromEtoI:1; + /// + /// [Bit 6] From S to I (R/W). + /// + UINT32 FromStoI:1; + /// + /// [Bit 7] From F to I (R/W). + /// + UINT32 FromFtoI:1; + UINT32 Reserved1:24; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER; + + +/** + Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL (0x00000391) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL is defined as MSR_UNCORE_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL 0x00000391 + + +/** + Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS (0x00000392) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS is defined as MSR_UNCORE_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS 0x00000392 + + +/** + Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL (0x00000393) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL is defined as MSR_UNCORE_PERF_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL 0x00000393 + + +/** + Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_FIXED_CTR0 (0x00000394) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR0, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_FIXED_CTR0 is defined as MSR_UNCORE_FIXED_CTR0 in SDM. +**/ +#define MSR_NEHALEM_UNCORE_FIXED_CTR0 0x00000394 + + +/** + Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL (0x00000395) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL is defined as MSR_UNCORE_FIXED_CTR_CTRL in SDM. +**/ +#define MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL 0x00000395 + + +/** + Package. See Section 18.8.2.3, "Uncore Address/Opcode Match MSR.". + + @param ECX MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH (0x00000396) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH is defined as MSR_UNCORE_ADDR_OPCODE_MATCH in SDM. +**/ +#define MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH 0x00000396 + + +/** + Package. See Section 18.8.2.2, "Uncore Performance Event Configuration + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_PMCi + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PMC0); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PMC0, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_PMC0 is defined as MSR_UNCORE_PMC0 in SDM. + MSR_NEHALEM_UNCORE_PMC1 is defined as MSR_UNCORE_PMC1 in SDM. + MSR_NEHALEM_UNCORE_PMC2 is defined as MSR_UNCORE_PMC2 in SDM. + MSR_NEHALEM_UNCORE_PMC3 is defined as MSR_UNCORE_PMC3 in SDM. + MSR_NEHALEM_UNCORE_PMC4 is defined as MSR_UNCORE_PMC4 in SDM. + MSR_NEHALEM_UNCORE_PMC5 is defined as MSR_UNCORE_PMC5 in SDM. + MSR_NEHALEM_UNCORE_PMC6 is defined as MSR_UNCORE_PMC6 in SDM. + MSR_NEHALEM_UNCORE_PMC7 is defined as MSR_UNCORE_PMC7 in SDM. + @{ +**/ +#define MSR_NEHALEM_UNCORE_PMC0 0x000003B0 +#define MSR_NEHALEM_UNCORE_PMC1 0x000003B1 +#define MSR_NEHALEM_UNCORE_PMC2 0x000003B2 +#define MSR_NEHALEM_UNCORE_PMC3 0x000003B3 +#define MSR_NEHALEM_UNCORE_PMC4 0x000003B4 +#define MSR_NEHALEM_UNCORE_PMC5 0x000003B5 +#define MSR_NEHALEM_UNCORE_PMC6 0x000003B6 +#define MSR_NEHALEM_UNCORE_PMC7 0x000003B7 +/// @} + +/** + Package. See Section 18.8.2.2, "Uncore Performance Event Configuration + Facility.". + + @param ECX MSR_NEHALEM_UNCORE_PERFEVTSELi + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERFEVTSEL0); + AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERFEVTSEL0, Msr); + @endcode + @note MSR_NEHALEM_UNCORE_PERFEVTSEL0 is defined as MSR_UNCORE_PERFEVTSEL0 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL1 is defined as MSR_UNCORE_PERFEVTSEL1 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL2 is defined as MSR_UNCORE_PERFEVTSEL2 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL3 is defined as MSR_UNCORE_PERFEVTSEL3 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL4 is defined as MSR_UNCORE_PERFEVTSEL4 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL5 is defined as MSR_UNCORE_PERFEVTSEL5 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL6 is defined as MSR_UNCORE_PERFEVTSEL6 in SDM. + MSR_NEHALEM_UNCORE_PERFEVTSEL7 is defined as MSR_UNCORE_PERFEVTSEL7 in SDM. + @{ +**/ +#define MSR_NEHALEM_UNCORE_PERFEVTSEL0 0x000003C0 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL1 0x000003C1 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL2 0x000003C2 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL3 0x000003C3 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL4 0x000003C4 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL5 0x000003C5 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL6 0x000003C6 +#define MSR_NEHALEM_UNCORE_PERFEVTSEL7 0x000003C7 +/// @} + + +/** + Package. Uncore W-box perfmon fixed counter. + + @param ECX MSR_NEHALEM_W_PMON_FIXED_CTR (0x00000394) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_FIXED_CTR is defined as MSR_W_PMON_FIXED_CTR in SDM. +**/ +#define MSR_NEHALEM_W_PMON_FIXED_CTR 0x00000394 + + +/** + Package. Uncore U-box perfmon fixed counter control MSR. + + @param ECX MSR_NEHALEM_W_PMON_FIXED_CTR_CTL (0x00000395) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR_CTL); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR_CTL, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_FIXED_CTR_CTL is defined as MSR_W_PMON_FIXED_CTR_CTL in SDM. +**/ +#define MSR_NEHALEM_W_PMON_FIXED_CTR_CTL 0x00000395 + + +/** + Package. Uncore U-box perfmon global control MSR. + + @param ECX MSR_NEHALEM_U_PMON_GLOBAL_CTRL (0x00000C00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_CTRL, Msr); + @endcode + @note MSR_NEHALEM_U_PMON_GLOBAL_CTRL is defined as MSR_U_PMON_GLOBAL_CTRL in SDM. +**/ +#define MSR_NEHALEM_U_PMON_GLOBAL_CTRL 0x00000C00 + + +/** + Package. Uncore U-box perfmon global status MSR. + + @param ECX MSR_NEHALEM_U_PMON_GLOBAL_STATUS (0x00000C01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_STATUS, Msr); + @endcode + @note MSR_NEHALEM_U_PMON_GLOBAL_STATUS is defined as MSR_U_PMON_GLOBAL_STATUS in SDM. +**/ +#define MSR_NEHALEM_U_PMON_GLOBAL_STATUS 0x00000C01 + + +/** + Package. Uncore U-box perfmon global overflow control MSR. + + @param ECX MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL (0x00000C02) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL is defined as MSR_U_PMON_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL 0x00000C02 + + +/** + Package. Uncore U-box perfmon event select MSR. + + @param ECX MSR_NEHALEM_U_PMON_EVNT_SEL (0x00000C10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_EVNT_SEL); + AsmWriteMsr64 (MSR_NEHALEM_U_PMON_EVNT_SEL, Msr); + @endcode + @note MSR_NEHALEM_U_PMON_EVNT_SEL is defined as MSR_U_PMON_EVNT_SEL in SDM. +**/ +#define MSR_NEHALEM_U_PMON_EVNT_SEL 0x00000C10 + + +/** + Package. Uncore U-box perfmon counter MSR. + + @param ECX MSR_NEHALEM_U_PMON_CTR (0x00000C11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_CTR); + AsmWriteMsr64 (MSR_NEHALEM_U_PMON_CTR, Msr); + @endcode + @note MSR_NEHALEM_U_PMON_CTR is defined as MSR_U_PMON_CTR in SDM. +**/ +#define MSR_NEHALEM_U_PMON_CTR 0x00000C11 + + +/** + Package. Uncore B-box 0 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_B0_PMON_BOX_CTRL (0x00000C20) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_BOX_CTRL is defined as MSR_B0_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_BOX_CTRL 0x00000C20 + + +/** + Package. Uncore B-box 0 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_B0_PMON_BOX_STATUS (0x00000C21) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_BOX_STATUS is defined as MSR_B0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_BOX_STATUS 0x00000C21 + + +/** + Package. Uncore B-box 0 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL (0x00000C22) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL is defined as MSR_B0_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL 0x00000C22 + + +/** + Package. Uncore B-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL0 (0x00000C30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_EVNT_SEL0 is defined as MSR_B0_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_EVNT_SEL0 0x00000C30 + + +/** + Package. Uncore B-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B0_PMON_CTR0 (0x00000C31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_CTR0 is defined as MSR_B0_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_CTR0 0x00000C31 + + +/** + Package. Uncore B-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL1 (0x00000C32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_EVNT_SEL1 is defined as MSR_B0_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_EVNT_SEL1 0x00000C32 + + +/** + Package. Uncore B-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B0_PMON_CTR1 (0x00000C33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_CTR1 is defined as MSR_B0_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_CTR1 0x00000C33 + + +/** + Package. Uncore B-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL2 (0x00000C34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_EVNT_SEL2 is defined as MSR_B0_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_EVNT_SEL2 0x00000C34 + + +/** + Package. Uncore B-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B0_PMON_CTR2 (0x00000C35) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_CTR2 is defined as MSR_B0_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_CTR2 0x00000C35 + + +/** + Package. Uncore B-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL3 (0x00000C36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_EVNT_SEL3 is defined as MSR_B0_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_EVNT_SEL3 0x00000C36 + + +/** + Package. Uncore B-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B0_PMON_CTR3 (0x00000C37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_CTR3 is defined as MSR_B0_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_CTR3 0x00000C37 + + +/** + Package. Uncore S-box 0 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_S0_PMON_BOX_CTRL (0x00000C40) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_BOX_CTRL is defined as MSR_S0_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_BOX_CTRL 0x00000C40 + + +/** + Package. Uncore S-box 0 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_S0_PMON_BOX_STATUS (0x00000C41) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_BOX_STATUS is defined as MSR_S0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_BOX_STATUS 0x00000C41 + + +/** + Package. Uncore S-box 0 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL (0x00000C42) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL is defined as MSR_S0_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL 0x00000C42 + + +/** + Package. Uncore S-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL0 (0x00000C50) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_EVNT_SEL0 is defined as MSR_S0_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_EVNT_SEL0 0x00000C50 + + +/** + Package. Uncore S-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S0_PMON_CTR0 (0x00000C51) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_CTR0 is defined as MSR_S0_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_CTR0 0x00000C51 + + +/** + Package. Uncore S-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL1 (0x00000C52) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_EVNT_SEL1 is defined as MSR_S0_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_EVNT_SEL1 0x00000C52 + + +/** + Package. Uncore S-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S0_PMON_CTR1 (0x00000C53) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_CTR1 is defined as MSR_S0_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_CTR1 0x00000C53 + + +/** + Package. Uncore S-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL2 (0x00000C54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_EVNT_SEL2 is defined as MSR_S0_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_EVNT_SEL2 0x00000C54 + + +/** + Package. Uncore S-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S0_PMON_CTR2 (0x00000C55) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_CTR2 is defined as MSR_S0_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_CTR2 0x00000C55 + + +/** + Package. Uncore S-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL3 (0x00000C56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_EVNT_SEL3 is defined as MSR_S0_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_EVNT_SEL3 0x00000C56 + + +/** + Package. Uncore S-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S0_PMON_CTR3 (0x00000C57) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_CTR3 is defined as MSR_S0_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_CTR3 0x00000C57 + + +/** + Package. Uncore B-box 1 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_B1_PMON_BOX_CTRL (0x00000C60) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_BOX_CTRL is defined as MSR_B1_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_BOX_CTRL 0x00000C60 + + +/** + Package. Uncore B-box 1 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_B1_PMON_BOX_STATUS (0x00000C61) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_BOX_STATUS is defined as MSR_B1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_BOX_STATUS 0x00000C61 + + +/** + Package. Uncore B-box 1 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL (0x00000C62) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL is defined as MSR_B1_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL 0x00000C62 + + +/** + Package. Uncore B-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL0 (0x00000C70) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_EVNT_SEL0 is defined as MSR_B1_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_EVNT_SEL0 0x00000C70 + + +/** + Package. Uncore B-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B1_PMON_CTR0 (0x00000C71) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_CTR0 is defined as MSR_B1_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_CTR0 0x00000C71 + + +/** + Package. Uncore B-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL1 (0x00000C72) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_EVNT_SEL1 is defined as MSR_B1_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_EVNT_SEL1 0x00000C72 + + +/** + Package. Uncore B-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B1_PMON_CTR1 (0x00000C73) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_CTR1 is defined as MSR_B1_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_CTR1 0x00000C73 + + +/** + Package. Uncore B-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL2 (0x00000C74) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_EVNT_SEL2 is defined as MSR_B1_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_EVNT_SEL2 0x00000C74 + + +/** + Package. Uncore B-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B1_PMON_CTR2 (0x00000C75) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_CTR2 is defined as MSR_B1_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_CTR2 0x00000C75 + + +/** + Package. Uncore B-box 1vperfmon event select MSR. + + @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL3 (0x00000C76) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_EVNT_SEL3 is defined as MSR_B1_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_EVNT_SEL3 0x00000C76 + + +/** + Package. Uncore B-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_B1_PMON_CTR3 (0x00000C77) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_CTR3 is defined as MSR_B1_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_CTR3 0x00000C77 + + +/** + Package. Uncore W-box perfmon local box control MSR. + + @param ECX MSR_NEHALEM_W_PMON_BOX_CTRL (0x00000C80) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_BOX_CTRL is defined as MSR_W_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_W_PMON_BOX_CTRL 0x00000C80 + + +/** + Package. Uncore W-box perfmon local box status MSR. + + @param ECX MSR_NEHALEM_W_PMON_BOX_STATUS (0x00000C81) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_BOX_STATUS is defined as MSR_W_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_W_PMON_BOX_STATUS 0x00000C81 + + +/** + Package. Uncore W-box perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_W_PMON_BOX_OVF_CTRL (0x00000C82) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_BOX_OVF_CTRL is defined as MSR_W_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_W_PMON_BOX_OVF_CTRL 0x00000C82 + + +/** + Package. Uncore W-box perfmon event select MSR. + + @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL0 (0x00000C90) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_EVNT_SEL0 is defined as MSR_W_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_EVNT_SEL0 0x00000C90 + + +/** + Package. Uncore W-box perfmon counter MSR. + + @param ECX MSR_NEHALEM_W_PMON_CTR0 (0x00000C91) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_CTR0 is defined as MSR_W_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_CTR0 0x00000C91 + + +/** + Package. Uncore W-box perfmon event select MSR. + + @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL1 (0x00000C92) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_EVNT_SEL1 is defined as MSR_W_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_EVNT_SEL1 0x00000C92 + + +/** + Package. Uncore W-box perfmon counter MSR. + + @param ECX MSR_NEHALEM_W_PMON_CTR1 (0x00000C93) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_CTR1 is defined as MSR_W_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_CTR1 0x00000C93 + + +/** + Package. Uncore W-box perfmon event select MSR. + + @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL2 (0x00000C94) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_EVNT_SEL2 is defined as MSR_W_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_EVNT_SEL2 0x00000C94 + + +/** + Package. Uncore W-box perfmon counter MSR. + + @param ECX MSR_NEHALEM_W_PMON_CTR2 (0x00000C95) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_CTR2 is defined as MSR_W_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_CTR2 0x00000C95 + + +/** + Package. Uncore W-box perfmon event select MSR. + + @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL3 (0x00000C96) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_EVNT_SEL3 is defined as MSR_W_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_EVNT_SEL3 0x00000C96 + + +/** + Package. Uncore W-box perfmon counter MSR. + + @param ECX MSR_NEHALEM_W_PMON_CTR3 (0x00000C97) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_W_PMON_CTR3 is defined as MSR_W_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_W_PMON_CTR3 0x00000C97 + + +/** + Package. Uncore M-box 0 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_M0_PMON_BOX_CTRL (0x00000CA0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_BOX_CTRL is defined as MSR_M0_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_BOX_CTRL 0x00000CA0 + + +/** + Package. Uncore M-box 0 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_M0_PMON_BOX_STATUS (0x00000CA1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_BOX_STATUS is defined as MSR_M0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_BOX_STATUS 0x00000CA1 + + +/** + Package. Uncore M-box 0 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL (0x00000CA2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL is defined as MSR_M0_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL 0x00000CA2 + + +/** + Package. Uncore M-box 0 perfmon time stamp unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_TIMESTAMP (0x00000CA4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_TIMESTAMP); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_TIMESTAMP, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_TIMESTAMP is defined as MSR_M0_PMON_TIMESTAMP in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_TIMESTAMP 0x00000CA4 + + +/** + Package. Uncore M-box 0 perfmon DSP unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_DSP (0x00000CA5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_DSP); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_DSP, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_DSP is defined as MSR_M0_PMON_DSP in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_DSP 0x00000CA5 + + +/** + Package. Uncore M-box 0 perfmon ISS unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_ISS (0x00000CA6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ISS); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ISS, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_ISS is defined as MSR_M0_PMON_ISS in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_ISS 0x00000CA6 + + +/** + Package. Uncore M-box 0 perfmon MAP unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_MAP (0x00000CA7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MAP); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MAP, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_MAP is defined as MSR_M0_PMON_MAP in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_MAP 0x00000CA7 + + +/** + Package. Uncore M-box 0 perfmon MIC THR select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_MSC_THR (0x00000CA8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MSC_THR); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MSC_THR, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_MSC_THR is defined as MSR_M0_PMON_MSC_THR in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_MSC_THR 0x00000CA8 + + +/** + Package. Uncore M-box 0 perfmon PGT unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_PGT (0x00000CA9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_PGT); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_PGT, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_PGT is defined as MSR_M0_PMON_PGT in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_PGT 0x00000CA9 + + +/** + Package. Uncore M-box 0 perfmon PLD unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_PLD (0x00000CAA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_PLD); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_PLD, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_PLD is defined as MSR_M0_PMON_PLD in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_PLD 0x00000CAA + + +/** + Package. Uncore M-box 0 perfmon ZDP unit select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_ZDP (0x00000CAB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ZDP); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ZDP, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_ZDP is defined as MSR_M0_PMON_ZDP in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_ZDP 0x00000CAB + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL0 (0x00000CB0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL0 is defined as MSR_M0_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL0 0x00000CB0 + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR0 (0x00000CB1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR0 is defined as MSR_M0_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR0 0x00000CB1 + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL1 (0x00000CB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL1 is defined as MSR_M0_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL1 0x00000CB2 + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR1 (0x00000CB3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR1 is defined as MSR_M0_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR1 0x00000CB3 + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL2 (0x00000CB4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL2 is defined as MSR_M0_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL2 0x00000CB4 + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR2 (0x00000CB5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR2 is defined as MSR_M0_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR2 0x00000CB5 + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL3 (0x00000CB6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL3 is defined as MSR_M0_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL3 0x00000CB6 + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR3 (0x00000CB7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR3 is defined as MSR_M0_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR3 0x00000CB7 + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL4 (0x00000CB8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL4 is defined as MSR_M0_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL4 0x00000CB8 + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR4 (0x00000CB9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR4 is defined as MSR_M0_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR4 0x00000CB9 + + +/** + Package. Uncore M-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL5 (0x00000CBA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_EVNT_SEL5 is defined as MSR_M0_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_EVNT_SEL5 0x00000CBA + + +/** + Package. Uncore M-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M0_PMON_CTR5 (0x00000CBB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_CTR5 is defined as MSR_M0_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_CTR5 0x00000CBB + + +/** + Package. Uncore S-box 1 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_S1_PMON_BOX_CTRL (0x00000CC0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_BOX_CTRL is defined as MSR_S1_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_BOX_CTRL 0x00000CC0 + + +/** + Package. Uncore S-box 1 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_S1_PMON_BOX_STATUS (0x00000CC1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_BOX_STATUS is defined as MSR_S1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_BOX_STATUS 0x00000CC1 + + +/** + Package. Uncore S-box 1 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL (0x00000CC2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL is defined as MSR_S1_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL 0x00000CC2 + + +/** + Package. Uncore S-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL0 (0x00000CD0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_EVNT_SEL0 is defined as MSR_S1_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_EVNT_SEL0 0x00000CD0 + + +/** + Package. Uncore S-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S1_PMON_CTR0 (0x00000CD1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_CTR0 is defined as MSR_S1_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_CTR0 0x00000CD1 + + +/** + Package. Uncore S-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL1 (0x00000CD2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_EVNT_SEL1 is defined as MSR_S1_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_EVNT_SEL1 0x00000CD2 + + +/** + Package. Uncore S-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S1_PMON_CTR1 (0x00000CD3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_CTR1 is defined as MSR_S1_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_CTR1 0x00000CD3 + + +/** + Package. Uncore S-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL2 (0x00000CD4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_EVNT_SEL2 is defined as MSR_S1_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_EVNT_SEL2 0x00000CD4 + + +/** + Package. Uncore S-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S1_PMON_CTR2 (0x00000CD5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_CTR2 is defined as MSR_S1_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_CTR2 0x00000CD5 + + +/** + Package. Uncore S-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL3 (0x00000CD6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_EVNT_SEL3 is defined as MSR_S1_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_EVNT_SEL3 0x00000CD6 + + +/** + Package. Uncore S-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_S1_PMON_CTR3 (0x00000CD7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_CTR3 is defined as MSR_S1_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_CTR3 0x00000CD7 + + +/** + Package. Uncore M-box 1 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_M1_PMON_BOX_CTRL (0x00000CE0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_BOX_CTRL is defined as MSR_M1_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_BOX_CTRL 0x00000CE0 + + +/** + Package. Uncore M-box 1 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_M1_PMON_BOX_STATUS (0x00000CE1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_BOX_STATUS is defined as MSR_M1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_BOX_STATUS 0x00000CE1 + + +/** + Package. Uncore M-box 1 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL (0x00000CE2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL is defined as MSR_M1_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL 0x00000CE2 + + +/** + Package. Uncore M-box 1 perfmon time stamp unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_TIMESTAMP (0x00000CE4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_TIMESTAMP); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_TIMESTAMP, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_TIMESTAMP is defined as MSR_M1_PMON_TIMESTAMP in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_TIMESTAMP 0x00000CE4 + + +/** + Package. Uncore M-box 1 perfmon DSP unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_DSP (0x00000CE5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_DSP); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_DSP, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_DSP is defined as MSR_M1_PMON_DSP in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_DSP 0x00000CE5 + + +/** + Package. Uncore M-box 1 perfmon ISS unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_ISS (0x00000CE6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ISS); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ISS, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_ISS is defined as MSR_M1_PMON_ISS in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_ISS 0x00000CE6 + + +/** + Package. Uncore M-box 1 perfmon MAP unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_MAP (0x00000CE7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MAP); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MAP, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_MAP is defined as MSR_M1_PMON_MAP in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_MAP 0x00000CE7 + + +/** + Package. Uncore M-box 1 perfmon MIC THR select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_MSC_THR (0x00000CE8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MSC_THR); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MSC_THR, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_MSC_THR is defined as MSR_M1_PMON_MSC_THR in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_MSC_THR 0x00000CE8 + + +/** + Package. Uncore M-box 1 perfmon PGT unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_PGT (0x00000CE9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_PGT); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_PGT, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_PGT is defined as MSR_M1_PMON_PGT in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_PGT 0x00000CE9 + + +/** + Package. Uncore M-box 1 perfmon PLD unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_PLD (0x00000CEA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_PLD); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_PLD, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_PLD is defined as MSR_M1_PMON_PLD in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_PLD 0x00000CEA + + +/** + Package. Uncore M-box 1 perfmon ZDP unit select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_ZDP (0x00000CEB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ZDP); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ZDP, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_ZDP is defined as MSR_M1_PMON_ZDP in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_ZDP 0x00000CEB + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL0 (0x00000CF0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL0 is defined as MSR_M1_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL0 0x00000CF0 + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR0 (0x00000CF1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR0 is defined as MSR_M1_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR0 0x00000CF1 + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL1 (0x00000CF2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL1 is defined as MSR_M1_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL1 0x00000CF2 + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR1 (0x00000CF3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR1 is defined as MSR_M1_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR1 0x00000CF3 + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL2 (0x00000CF4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL2 is defined as MSR_M1_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL2 0x00000CF4 + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR2 (0x00000CF5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR2 is defined as MSR_M1_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR2 0x00000CF5 + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL3 (0x00000CF6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL3 is defined as MSR_M1_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL3 0x00000CF6 + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR3 (0x00000CF7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR3 is defined as MSR_M1_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR3 0x00000CF7 + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL4 (0x00000CF8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL4 is defined as MSR_M1_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL4 0x00000CF8 + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR4 (0x00000CF9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR4 is defined as MSR_M1_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR4 0x00000CF9 + + +/** + Package. Uncore M-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL5 (0x00000CFA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_EVNT_SEL5 is defined as MSR_M1_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_EVNT_SEL5 0x00000CFA + + +/** + Package. Uncore M-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_M1_PMON_CTR5 (0x00000CFB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_CTR5 is defined as MSR_M1_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_CTR5 0x00000CFB + + +/** + Package. Uncore C-box 0 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C0_PMON_BOX_CTRL (0x00000D00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_BOX_CTRL is defined as MSR_C0_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_BOX_CTRL 0x00000D00 + + +/** + Package. Uncore C-box 0 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C0_PMON_BOX_STATUS (0x00000D01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_BOX_STATUS is defined as MSR_C0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_BOX_STATUS 0x00000D01 + + +/** + Package. Uncore C-box 0 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL (0x00000D02) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL is defined as MSR_C0_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL 0x00000D02 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL0 (0x00000D10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL0 is defined as MSR_C0_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL0 0x00000D10 + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR0 (0x00000D11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR0 0x00000D11 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL1 (0x00000D12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL1 is defined as MSR_C0_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL1 0x00000D12 + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR1 (0x00000D13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR1 0x00000D13 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL2 (0x00000D14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL2 is defined as MSR_C0_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL2 0x00000D14 + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR2 (0x00000D15) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR2 0x00000D15 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL3 (0x00000D16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL3 is defined as MSR_C0_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL3 0x00000D16 + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR3 (0x00000D17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR3 0x00000D17 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL4 (0x00000D18) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL4 is defined as MSR_C0_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL4 0x00000D18 + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR4 (0x00000D19) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR4 is defined as MSR_C0_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR4 0x00000D19 + + +/** + Package. Uncore C-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL5 (0x00000D1A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_EVNT_SEL5 is defined as MSR_C0_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_EVNT_SEL5 0x00000D1A + + +/** + Package. Uncore C-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C0_PMON_CTR5 (0x00000D1B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C0_PMON_CTR5 is defined as MSR_C0_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C0_PMON_CTR5 0x00000D1B + + +/** + Package. Uncore C-box 4 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C4_PMON_BOX_CTRL (0x00000D20) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_BOX_CTRL is defined as MSR_C4_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_BOX_CTRL 0x00000D20 + + +/** + Package. Uncore C-box 4 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C4_PMON_BOX_STATUS (0x00000D21) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_BOX_STATUS is defined as MSR_C4_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_BOX_STATUS 0x00000D21 + + +/** + Package. Uncore C-box 4 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL (0x00000D22) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL is defined as MSR_C4_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL 0x00000D22 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL0 (0x00000D30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL0 is defined as MSR_C4_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL0 0x00000D30 + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR0 (0x00000D31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR0 0x00000D31 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL1 (0x00000D32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL1 is defined as MSR_C4_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL1 0x00000D32 + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR1 (0x00000D33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR1 0x00000D33 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL2 (0x00000D34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL2 is defined as MSR_C4_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL2 0x00000D34 + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR2 (0x00000D35) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR2 0x00000D35 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL3 (0x00000D36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL3 is defined as MSR_C4_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL3 0x00000D36 + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR3 (0x00000D37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR3 0x00000D37 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL4 (0x00000D38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL4 is defined as MSR_C4_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL4 0x00000D38 + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR4 (0x00000D39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR4 is defined as MSR_C4_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR4 0x00000D39 + + +/** + Package. Uncore C-box 4 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL5 (0x00000D3A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_EVNT_SEL5 is defined as MSR_C4_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_EVNT_SEL5 0x00000D3A + + +/** + Package. Uncore C-box 4 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C4_PMON_CTR5 (0x00000D3B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C4_PMON_CTR5 is defined as MSR_C4_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C4_PMON_CTR5 0x00000D3B + + +/** + Package. Uncore C-box 2 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C2_PMON_BOX_CTRL (0x00000D40) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_BOX_CTRL is defined as MSR_C2_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_BOX_CTRL 0x00000D40 + + +/** + Package. Uncore C-box 2 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C2_PMON_BOX_STATUS (0x00000D41) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_BOX_STATUS is defined as MSR_C2_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_BOX_STATUS 0x00000D41 + + +/** + Package. Uncore C-box 2 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL (0x00000D42) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL is defined as MSR_C2_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL 0x00000D42 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL0 (0x00000D50) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL0 is defined as MSR_C2_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL0 0x00000D50 + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR0 (0x00000D51) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR0 0x00000D51 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL1 (0x00000D52) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL1 is defined as MSR_C2_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL1 0x00000D52 + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR1 (0x00000D53) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR1 0x00000D53 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL2 (0x00000D54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL2 is defined as MSR_C2_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL2 0x00000D54 + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR2 (0x00000D55) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR2 0x00000D55 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL3 (0x00000D56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL3 is defined as MSR_C2_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL3 0x00000D56 + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR3 (0x00000D57) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR3 0x00000D57 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL4 (0x00000D58) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL4 is defined as MSR_C2_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL4 0x00000D58 + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR4 (0x00000D59) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR4 is defined as MSR_C2_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR4 0x00000D59 + + +/** + Package. Uncore C-box 2 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL5 (0x00000D5A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_EVNT_SEL5 is defined as MSR_C2_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_EVNT_SEL5 0x00000D5A + + +/** + Package. Uncore C-box 2 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C2_PMON_CTR5 (0x00000D5B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C2_PMON_CTR5 is defined as MSR_C2_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C2_PMON_CTR5 0x00000D5B + + +/** + Package. Uncore C-box 6 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C6_PMON_BOX_CTRL (0x00000D60) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_BOX_CTRL is defined as MSR_C6_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_BOX_CTRL 0x00000D60 + + +/** + Package. Uncore C-box 6 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C6_PMON_BOX_STATUS (0x00000D61) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_BOX_STATUS is defined as MSR_C6_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_BOX_STATUS 0x00000D61 + + +/** + Package. Uncore C-box 6 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL (0x00000D62) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL is defined as MSR_C6_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL 0x00000D62 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL0 (0x00000D70) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL0 is defined as MSR_C6_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL0 0x00000D70 + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR0 (0x00000D71) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR0 0x00000D71 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL1 (0x00000D72) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL1 is defined as MSR_C6_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL1 0x00000D72 + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR1 (0x00000D73) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR1 0x00000D73 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL2 (0x00000D74) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL2 is defined as MSR_C6_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL2 0x00000D74 + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR2 (0x00000D75) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR2 0x00000D75 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL3 (0x00000D76) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL3 is defined as MSR_C6_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL3 0x00000D76 + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR3 (0x00000D77) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR3 0x00000D77 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL4 (0x00000D78) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL4 is defined as MSR_C6_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL4 0x00000D78 + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR4 (0x00000D79) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR4 is defined as MSR_C6_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR4 0x00000D79 + + +/** + Package. Uncore C-box 6 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL5 (0x00000D7A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_EVNT_SEL5 is defined as MSR_C6_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_EVNT_SEL5 0x00000D7A + + +/** + Package. Uncore C-box 6 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C6_PMON_CTR5 (0x00000D7B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C6_PMON_CTR5 is defined as MSR_C6_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C6_PMON_CTR5 0x00000D7B + + +/** + Package. Uncore C-box 1 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C1_PMON_BOX_CTRL (0x00000D80) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_BOX_CTRL is defined as MSR_C1_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_BOX_CTRL 0x00000D80 + + +/** + Package. Uncore C-box 1 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C1_PMON_BOX_STATUS (0x00000D81) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_BOX_STATUS is defined as MSR_C1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_BOX_STATUS 0x00000D81 + + +/** + Package. Uncore C-box 1 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL (0x00000D82) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL is defined as MSR_C1_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL 0x00000D82 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL0 (0x00000D90) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL0 is defined as MSR_C1_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL0 0x00000D90 + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR0 (0x00000D91) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR0 0x00000D91 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL1 (0x00000D92) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL1 is defined as MSR_C1_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL1 0x00000D92 + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR1 (0x00000D93) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR1 0x00000D93 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL2 (0x00000D94) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL2 is defined as MSR_C1_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL2 0x00000D94 + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR2 (0x00000D95) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR2 0x00000D95 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL3 (0x00000D96) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL3 is defined as MSR_C1_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL3 0x00000D96 + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR3 (0x00000D97) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR3 0x00000D97 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL4 (0x00000D98) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL4 is defined as MSR_C1_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL4 0x00000D98 + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR4 (0x00000D99) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR4 is defined as MSR_C1_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR4 0x00000D99 + + +/** + Package. Uncore C-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL5 (0x00000D9A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_EVNT_SEL5 is defined as MSR_C1_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_EVNT_SEL5 0x00000D9A + + +/** + Package. Uncore C-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C1_PMON_CTR5 (0x00000D9B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C1_PMON_CTR5 is defined as MSR_C1_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C1_PMON_CTR5 0x00000D9B + + +/** + Package. Uncore C-box 5 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C5_PMON_BOX_CTRL (0x00000DA0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_BOX_CTRL is defined as MSR_C5_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_BOX_CTRL 0x00000DA0 + + +/** + Package. Uncore C-box 5 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C5_PMON_BOX_STATUS (0x00000DA1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_BOX_STATUS is defined as MSR_C5_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_BOX_STATUS 0x00000DA1 + + +/** + Package. Uncore C-box 5 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL (0x00000DA2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL is defined as MSR_C5_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL 0x00000DA2 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL0 (0x00000DB0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL0 is defined as MSR_C5_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL0 0x00000DB0 + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR0 (0x00000DB1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR0 0x00000DB1 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL1 (0x00000DB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL1 is defined as MSR_C5_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL1 0x00000DB2 + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR1 (0x00000DB3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR1 0x00000DB3 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL2 (0x00000DB4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL2 is defined as MSR_C5_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL2 0x00000DB4 + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR2 (0x00000DB5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR2 0x00000DB5 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL3 (0x00000DB6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL3 is defined as MSR_C5_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL3 0x00000DB6 + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR3 (0x00000DB7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR3 0x00000DB7 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL4 (0x00000DB8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL4 is defined as MSR_C5_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL4 0x00000DB8 + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR4 (0x00000DB9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR4 is defined as MSR_C5_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR4 0x00000DB9 + + +/** + Package. Uncore C-box 5 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL5 (0x00000DBA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_EVNT_SEL5 is defined as MSR_C5_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_EVNT_SEL5 0x00000DBA + + +/** + Package. Uncore C-box 5 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C5_PMON_CTR5 (0x00000DBB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C5_PMON_CTR5 is defined as MSR_C5_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C5_PMON_CTR5 0x00000DBB + + +/** + Package. Uncore C-box 3 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C3_PMON_BOX_CTRL (0x00000DC0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_BOX_CTRL is defined as MSR_C3_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_BOX_CTRL 0x00000DC0 + + +/** + Package. Uncore C-box 3 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C3_PMON_BOX_STATUS (0x00000DC1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_BOX_STATUS is defined as MSR_C3_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_BOX_STATUS 0x00000DC1 + + +/** + Package. Uncore C-box 3 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL (0x00000DC2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL is defined as MSR_C3_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL 0x00000DC2 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL0 (0x00000DD0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL0 is defined as MSR_C3_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL0 0x00000DD0 + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR0 (0x00000DD1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR0 0x00000DD1 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL1 (0x00000DD2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL1 is defined as MSR_C3_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL1 0x00000DD2 + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR1 (0x00000DD3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR1 0x00000DD3 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL2 (0x00000DD4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL2 is defined as MSR_C3_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL2 0x00000DD4 + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR2 (0x00000DD5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR2 0x00000DD5 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL3 (0x00000DD6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL3 is defined as MSR_C3_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL3 0x00000DD6 + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR3 (0x00000DD7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR3 0x00000DD7 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL4 (0x00000DD8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL4 is defined as MSR_C3_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL4 0x00000DD8 + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR4 (0x00000DD9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR4 is defined as MSR_C3_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR4 0x00000DD9 + + +/** + Package. Uncore C-box 3 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL5 (0x00000DDA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_EVNT_SEL5 is defined as MSR_C3_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_EVNT_SEL5 0x00000DDA + + +/** + Package. Uncore C-box 3 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C3_PMON_CTR5 (0x00000DDB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C3_PMON_CTR5 is defined as MSR_C3_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C3_PMON_CTR5 0x00000DDB + + +/** + Package. Uncore C-box 7 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_C7_PMON_BOX_CTRL (0x00000DE0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_BOX_CTRL is defined as MSR_C7_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_BOX_CTRL 0x00000DE0 + + +/** + Package. Uncore C-box 7 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_C7_PMON_BOX_STATUS (0x00000DE1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_BOX_STATUS is defined as MSR_C7_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_BOX_STATUS 0x00000DE1 + + +/** + Package. Uncore C-box 7 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL (0x00000DE2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL is defined as MSR_C7_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL 0x00000DE2 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL0 (0x00000DF0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL0 is defined as MSR_C7_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL0 0x00000DF0 + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR0 (0x00000DF1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR0 0x00000DF1 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL1 (0x00000DF2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL1 is defined as MSR_C7_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL1 0x00000DF2 + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR1 (0x00000DF3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR1 0x00000DF3 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL2 (0x00000DF4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL2 is defined as MSR_C7_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL2 0x00000DF4 + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR2 (0x00000DF5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR2 0x00000DF5 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL3 (0x00000DF6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL3 is defined as MSR_C7_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL3 0x00000DF6 + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR3 (0x00000DF7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR3 0x00000DF7 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL4 (0x00000DF8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL4 is defined as MSR_C7_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL4 0x00000DF8 + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR4 (0x00000DF9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR4 is defined as MSR_C7_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR4 0x00000DF9 + + +/** + Package. Uncore C-box 7 perfmon event select MSR. + + @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL5 (0x00000DFA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_EVNT_SEL5 is defined as MSR_C7_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_EVNT_SEL5 0x00000DFA + + +/** + Package. Uncore C-box 7 perfmon counter MSR. + + @param ECX MSR_NEHALEM_C7_PMON_CTR5 (0x00000DFB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_C7_PMON_CTR5 is defined as MSR_C7_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_C7_PMON_CTR5 0x00000DFB + + +/** + Package. Uncore R-box 0 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_R0_PMON_BOX_CTRL (0x00000E00) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_BOX_CTRL is defined as MSR_R0_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_BOX_CTRL 0x00000E00 + + +/** + Package. Uncore R-box 0 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_R0_PMON_BOX_STATUS (0x00000E01) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_BOX_STATUS is defined as MSR_R0_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_BOX_STATUS 0x00000E01 + + +/** + Package. Uncore R-box 0 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL (0x00000E02) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL is defined as MSR_R0_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL 0x00000E02 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 0 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P0 (0x00000E04) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P0); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P0, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P0 is defined as MSR_R0_PMON_IPERF0_P0 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P0 0x00000E04 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 1 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P1 (0x00000E05) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P1); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P1, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P1 is defined as MSR_R0_PMON_IPERF0_P1 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P1 0x00000E05 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 2 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P2 (0x00000E06) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P2); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P2, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P2 is defined as MSR_R0_PMON_IPERF0_P2 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P2 0x00000E06 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 3 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P3 (0x00000E07) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P3); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P3, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P3 is defined as MSR_R0_PMON_IPERF0_P3 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P3 0x00000E07 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 4 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P4 (0x00000E08) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P4); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P4, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P4 is defined as MSR_R0_PMON_IPERF0_P4 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P4 0x00000E08 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 5 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P5 (0x00000E09) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P5); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P5, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P5 is defined as MSR_R0_PMON_IPERF0_P5 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P5 0x00000E09 + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 6 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P6 (0x00000E0A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P6); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P6, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P6 is defined as MSR_R0_PMON_IPERF0_P6 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P6 0x00000E0A + + +/** + Package. Uncore R-box 0 perfmon IPERF0 unit Port 7 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P7 (0x00000E0B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P7); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P7, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_IPERF0_P7 is defined as MSR_R0_PMON_IPERF0_P7 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_IPERF0_P7 0x00000E0B + + +/** + Package. Uncore R-box 0 perfmon QLX unit Port 0 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_QLX_P0 (0x00000E0C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P0); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P0, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_QLX_P0 is defined as MSR_R0_PMON_QLX_P0 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_QLX_P0 0x00000E0C + + +/** + Package. Uncore R-box 0 perfmon QLX unit Port 1 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_QLX_P1 (0x00000E0D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P1); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P1, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_QLX_P1 is defined as MSR_R0_PMON_QLX_P1 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_QLX_P1 0x00000E0D + + +/** + Package. Uncore R-box 0 perfmon QLX unit Port 2 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_QLX_P2 (0x00000E0E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P2); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P2, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_QLX_P2 is defined as MSR_R0_PMON_QLX_P2 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_QLX_P2 0x00000E0E + + +/** + Package. Uncore R-box 0 perfmon QLX unit Port 3 select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_QLX_P3 (0x00000E0F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P3); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P3, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_QLX_P3 is defined as MSR_R0_PMON_QLX_P3 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_QLX_P3 0x00000E0F + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL0 (0x00000E10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL0 is defined as MSR_R0_PMON_EVNT_SEL0 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL0 0x00000E10 + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR0 (0x00000E11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR0); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR0, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR0 is defined as MSR_R0_PMON_CTR0 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR0 0x00000E11 + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL1 (0x00000E12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL1); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL1, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL1 is defined as MSR_R0_PMON_EVNT_SEL1 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL1 0x00000E12 + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR1 (0x00000E13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR1); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR1, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR1 is defined as MSR_R0_PMON_CTR1 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR1 0x00000E13 + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL2 (0x00000E14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL2); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL2, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL2 is defined as MSR_R0_PMON_EVNT_SEL2 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL2 0x00000E14 + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR2 (0x00000E15) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR2); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR2, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR2 is defined as MSR_R0_PMON_CTR2 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR2 0x00000E15 + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL3 (0x00000E16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL3); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL3, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL3 is defined as MSR_R0_PMON_EVNT_SEL3 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL3 0x00000E16 + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR3 (0x00000E17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR3); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR3, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR3 is defined as MSR_R0_PMON_CTR3 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR3 0x00000E17 + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL4 (0x00000E18) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL4); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL4, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL4 is defined as MSR_R0_PMON_EVNT_SEL4 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL4 0x00000E18 + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR4 (0x00000E19) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR4); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR4, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR4 is defined as MSR_R0_PMON_CTR4 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR4 0x00000E19 + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL5 (0x00000E1A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL5); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL5, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL5 is defined as MSR_R0_PMON_EVNT_SEL5 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL5 0x00000E1A + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR5 (0x00000E1B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR5); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR5, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR5 is defined as MSR_R0_PMON_CTR5 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR5 0x00000E1B + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL6 (0x00000E1C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL6); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL6, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL6 is defined as MSR_R0_PMON_EVNT_SEL6 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL6 0x00000E1C + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR6 (0x00000E1D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR6); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR6, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR6 is defined as MSR_R0_PMON_CTR6 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR6 0x00000E1D + + +/** + Package. Uncore R-box 0 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL7 (0x00000E1E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL7); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL7, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_EVNT_SEL7 is defined as MSR_R0_PMON_EVNT_SEL7 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_EVNT_SEL7 0x00000E1E + + +/** + Package. Uncore R-box 0 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R0_PMON_CTR7 (0x00000E1F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR7); + AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR7, Msr); + @endcode + @note MSR_NEHALEM_R0_PMON_CTR7 is defined as MSR_R0_PMON_CTR7 in SDM. +**/ +#define MSR_NEHALEM_R0_PMON_CTR7 0x00000E1F + + +/** + Package. Uncore R-box 1 perfmon local box control MSR. + + @param ECX MSR_NEHALEM_R1_PMON_BOX_CTRL (0x00000E20) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_BOX_CTRL is defined as MSR_R1_PMON_BOX_CTRL in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_BOX_CTRL 0x00000E20 + + +/** + Package. Uncore R-box 1 perfmon local box status MSR. + + @param ECX MSR_NEHALEM_R1_PMON_BOX_STATUS (0x00000E21) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_BOX_STATUS is defined as MSR_R1_PMON_BOX_STATUS in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_BOX_STATUS 0x00000E21 + + +/** + Package. Uncore R-box 1 perfmon local box overflow control MSR. + + @param ECX MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL (0x00000E22) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL is defined as MSR_R1_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL 0x00000E22 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 8 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P8 (0x00000E24) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P8); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P8, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P8 is defined as MSR_R1_PMON_IPERF1_P8 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P8 0x00000E24 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 9 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P9 (0x00000E25) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P9); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P9, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P9 is defined as MSR_R1_PMON_IPERF1_P9 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P9 0x00000E25 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 10 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P10 (0x00000E26) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P10); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P10, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P10 is defined as MSR_R1_PMON_IPERF1_P10 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P10 0x00000E26 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 11 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P11 (0x00000E27) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P11); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P11, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P11 is defined as MSR_R1_PMON_IPERF1_P11 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P11 0x00000E27 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 12 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P12 (0x00000E28) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P12); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P12, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P12 is defined as MSR_R1_PMON_IPERF1_P12 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P12 0x00000E28 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 13 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P13 (0x00000E29) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P13); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P13, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P13 is defined as MSR_R1_PMON_IPERF1_P13 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P13 0x00000E29 + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 14 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P14 (0x00000E2A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P14); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P14, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P14 is defined as MSR_R1_PMON_IPERF1_P14 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P14 0x00000E2A + + +/** + Package. Uncore R-box 1 perfmon IPERF1 unit Port 15 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P15 (0x00000E2B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P15); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P15, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_IPERF1_P15 is defined as MSR_R1_PMON_IPERF1_P15 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_IPERF1_P15 0x00000E2B + + +/** + Package. Uncore R-box 1 perfmon QLX unit Port 4 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_QLX_P4 (0x00000E2C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P4); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P4, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_QLX_P4 is defined as MSR_R1_PMON_QLX_P4 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_QLX_P4 0x00000E2C + + +/** + Package. Uncore R-box 1 perfmon QLX unit Port 5 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_QLX_P5 (0x00000E2D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P5); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P5, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_QLX_P5 is defined as MSR_R1_PMON_QLX_P5 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_QLX_P5 0x00000E2D + + +/** + Package. Uncore R-box 1 perfmon QLX unit Port 6 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_QLX_P6 (0x00000E2E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P6); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P6, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_QLX_P6 is defined as MSR_R1_PMON_QLX_P6 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_QLX_P6 0x00000E2E + + +/** + Package. Uncore R-box 1 perfmon QLX unit Port 7 select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_QLX_P7 (0x00000E2F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P7); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P7, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_QLX_P7 is defined as MSR_R1_PMON_QLX_P7 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_QLX_P7 0x00000E2F + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL8 (0x00000E30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL8); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL8, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL8 is defined as MSR_R1_PMON_EVNT_SEL8 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL8 0x00000E30 + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR8 (0x00000E31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR8); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR8, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR8 is defined as MSR_R1_PMON_CTR8 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR8 0x00000E31 + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL9 (0x00000E32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL9); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL9, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL9 is defined as MSR_R1_PMON_EVNT_SEL9 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL9 0x00000E32 + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR9 (0x00000E33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR9); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR9, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR9 is defined as MSR_R1_PMON_CTR9 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR9 0x00000E33 + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL10 (0x00000E34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL10); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL10, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL10 is defined as MSR_R1_PMON_EVNT_SEL10 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL10 0x00000E34 + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR10 (0x00000E35) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR10); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR10, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR10 is defined as MSR_R1_PMON_CTR10 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR10 0x00000E35 + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL11 (0x00000E36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL11); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL11, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL11 is defined as MSR_R1_PMON_EVNT_SEL11 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL11 0x00000E36 + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR11 (0x00000E37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR11); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR11, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR11 is defined as MSR_R1_PMON_CTR11 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR11 0x00000E37 + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL12 (0x00000E38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL12); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL12, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL12 is defined as MSR_R1_PMON_EVNT_SEL12 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL12 0x00000E38 + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR12 (0x00000E39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR12); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR12, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR12 is defined as MSR_R1_PMON_CTR12 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR12 0x00000E39 + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL13 (0x00000E3A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL13); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL13, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL13 is defined as MSR_R1_PMON_EVNT_SEL13 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL13 0x00000E3A + + +/** + Package. Uncore R-box 1perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR13 (0x00000E3B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR13); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR13, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR13 is defined as MSR_R1_PMON_CTR13 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR13 0x00000E3B + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL14 (0x00000E3C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL14); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL14, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL14 is defined as MSR_R1_PMON_EVNT_SEL14 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL14 0x00000E3C + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR14 (0x00000E3D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR14); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR14, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR14 is defined as MSR_R1_PMON_CTR14 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR14 0x00000E3D + + +/** + Package. Uncore R-box 1 perfmon event select MSR. + + @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL15 (0x00000E3E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL15); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL15, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_EVNT_SEL15 is defined as MSR_R1_PMON_EVNT_SEL15 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_EVNT_SEL15 0x00000E3E + + +/** + Package. Uncore R-box 1 perfmon counter MSR. + + @param ECX MSR_NEHALEM_R1_PMON_CTR15 (0x00000E3F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR15); + AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR15, Msr); + @endcode + @note MSR_NEHALEM_R1_PMON_CTR15 is defined as MSR_R1_PMON_CTR15 in SDM. +**/ +#define MSR_NEHALEM_R1_PMON_CTR15 0x00000E3F + + +/** + Package. Uncore B-box 0 perfmon local box match MSR. + + @param ECX MSR_NEHALEM_B0_PMON_MATCH (0x00000E45) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_MATCH, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_MATCH is defined as MSR_B0_PMON_MATCH in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_MATCH 0x00000E45 + + +/** + Package. Uncore B-box 0 perfmon local box mask MSR. + + @param ECX MSR_NEHALEM_B0_PMON_MASK (0x00000E46) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_MASK); + AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_MASK, Msr); + @endcode + @note MSR_NEHALEM_B0_PMON_MASK is defined as MSR_B0_PMON_MASK in SDM. +**/ +#define MSR_NEHALEM_B0_PMON_MASK 0x00000E46 + + +/** + Package. Uncore S-box 0 perfmon local box match MSR. + + @param ECX MSR_NEHALEM_S0_PMON_MATCH (0x00000E49) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_MATCH, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_MATCH is defined as MSR_S0_PMON_MATCH in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_MATCH 0x00000E49 + + +/** + Package. Uncore S-box 0 perfmon local box mask MSR. + + @param ECX MSR_NEHALEM_S0_PMON_MASK (0x00000E4A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_MASK); + AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_MASK, Msr); + @endcode + @note MSR_NEHALEM_S0_PMON_MASK is defined as MSR_S0_PMON_MASK in SDM. +**/ +#define MSR_NEHALEM_S0_PMON_MASK 0x00000E4A + + +/** + Package. Uncore B-box 1 perfmon local box match MSR. + + @param ECX MSR_NEHALEM_B1_PMON_MATCH (0x00000E4D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_MATCH, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_MATCH is defined as MSR_B1_PMON_MATCH in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_MATCH 0x00000E4D + + +/** + Package. Uncore B-box 1 perfmon local box mask MSR. + + @param ECX MSR_NEHALEM_B1_PMON_MASK (0x00000E4E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_MASK); + AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_MASK, Msr); + @endcode + @note MSR_NEHALEM_B1_PMON_MASK is defined as MSR_B1_PMON_MASK in SDM. +**/ +#define MSR_NEHALEM_B1_PMON_MASK 0x00000E4E + + +/** + Package. Uncore M-box 0 perfmon local box address match/mask config MSR. + + @param ECX MSR_NEHALEM_M0_PMON_MM_CONFIG (0x00000E54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MM_CONFIG); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MM_CONFIG, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_MM_CONFIG is defined as MSR_M0_PMON_MM_CONFIG in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_MM_CONFIG 0x00000E54 + + +/** + Package. Uncore M-box 0 perfmon local box address match MSR. + + @param ECX MSR_NEHALEM_M0_PMON_ADDR_MATCH (0x00000E55) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MATCH, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_ADDR_MATCH is defined as MSR_M0_PMON_ADDR_MATCH in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_ADDR_MATCH 0x00000E55 + + +/** + Package. Uncore M-box 0 perfmon local box address mask MSR. + + @param ECX MSR_NEHALEM_M0_PMON_ADDR_MASK (0x00000E56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MASK); + AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MASK, Msr); + @endcode + @note MSR_NEHALEM_M0_PMON_ADDR_MASK is defined as MSR_M0_PMON_ADDR_MASK in SDM. +**/ +#define MSR_NEHALEM_M0_PMON_ADDR_MASK 0x00000E56 + + +/** + Package. Uncore S-box 1 perfmon local box match MSR. + + @param ECX MSR_NEHALEM_S1_PMON_MATCH (0x00000E59) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_MATCH, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_MATCH is defined as MSR_S1_PMON_MATCH in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_MATCH 0x00000E59 + + +/** + Package. Uncore S-box 1 perfmon local box mask MSR. + + @param ECX MSR_NEHALEM_S1_PMON_MASK (0x00000E5A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_MASK); + AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_MASK, Msr); + @endcode + @note MSR_NEHALEM_S1_PMON_MASK is defined as MSR_S1_PMON_MASK in SDM. +**/ +#define MSR_NEHALEM_S1_PMON_MASK 0x00000E5A + + +/** + Package. Uncore M-box 1 perfmon local box address match/mask config MSR. + + @param ECX MSR_NEHALEM_M1_PMON_MM_CONFIG (0x00000E5C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MM_CONFIG); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MM_CONFIG, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_MM_CONFIG is defined as MSR_M1_PMON_MM_CONFIG in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_MM_CONFIG 0x00000E5C + + +/** + Package. Uncore M-box 1 perfmon local box address match MSR. + + @param ECX MSR_NEHALEM_M1_PMON_ADDR_MATCH (0x00000E5D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MATCH); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MATCH, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_ADDR_MATCH is defined as MSR_M1_PMON_ADDR_MATCH in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_ADDR_MATCH 0x00000E5D + + +/** + Package. Uncore M-box 1 perfmon local box address mask MSR. + + @param ECX MSR_NEHALEM_M1_PMON_ADDR_MASK (0x00000E5E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MASK); + AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MASK, Msr); + @endcode + @note MSR_NEHALEM_M1_PMON_ADDR_MASK is defined as MSR_M1_PMON_ADDR_MASK in SDM. +**/ +#define MSR_NEHALEM_M1_PMON_ADDR_MASK 0x00000E5E + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/P6Msr.h b/Core/UefiCpuPkg/Include/Register/Msr/P6Msr.h new file mode 100644 index 0000000000..aec2e2c868 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/P6Msr.h @@ -0,0 +1,1712 @@ +/** @file + MSR Definitions for P6 Family Processors. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.21. + +**/ + +#ifndef __P6_MSR_H__ +#define __P6_MSR_H__ + +#include + +/** + Is P6 Family Processors? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_P6_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x03 || \ + DisplayModel == 0x05 || \ + DisplayModel == 0x07 || \ + DisplayModel == 0x08 || \ + DisplayModel == 0x0A || \ + DisplayModel == 0x0B \ + ) \ + ) + +/** + See Section 35.22, "MSRs in Pentium Processors.". + + @param ECX MSR_P6_P5_MC_ADDR (0x00000000) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_P5_MC_ADDR); + AsmWriteMsr64 (MSR_P6_P5_MC_ADDR, Msr); + @endcode + @note MSR_P6_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. +**/ +#define MSR_P6_P5_MC_ADDR 0x00000000 + + +/** + See Section 35.22, "MSRs in Pentium Processors.". + + @param ECX MSR_P6_P5_MC_TYPE (0x00000001) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_P5_MC_TYPE); + AsmWriteMsr64 (MSR_P6_P5_MC_TYPE, Msr); + @endcode + @note MSR_P6_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. +**/ +#define MSR_P6_P5_MC_TYPE 0x00000001 + + +/** + See Section 17.14, "Time-Stamp Counter.". + + @param ECX MSR_P6_TSC (0x00000010) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_TSC); + AsmWriteMsr64 (MSR_P6_TSC, Msr); + @endcode + @note MSR_P6_TSC is defined as TSC in SDM. +**/ +#define MSR_P6_TSC 0x00000010 + + +/** + Platform ID (R) The operating system can use this MSR to determine "slot" + information for the processor and the proper microcode update to load. + + @param ECX MSR_P6_IA32_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_IA32_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_IA32_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_P6_IA32_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_IA32_PLATFORM_ID); + @endcode + @note MSR_P6_IA32_PLATFORM_ID is defined as IA32_PLATFORM_ID in SDM. +**/ +#define MSR_P6_IA32_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_P6_IA32_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:18; + /// + /// [Bits 52:50] Platform Id (R) Contains information concerning the + /// intended platform for the processor. + /// + /// 52 51 50 + /// 0 0 0 Processor Flag 0. + /// 0 0 1 Processor Flag 1 + /// 0 1 0 Processor Flag 2 + /// 0 1 1 Processor Flag 3 + /// 1 0 0 Processor Flag 4 + /// 1 0 1 Processor Flag 5 + /// 1 1 0 Processor Flag 6 + /// 1 1 1 Processor Flag 7 + /// + UINT32 PlatformId:3; + /// + /// [Bits 56:53] L2 Cache Latency Read. + /// + UINT32 L2CacheLatencyRead:4; + UINT32 Reserved3:3; + /// + /// [Bit 60] Clock Frequency Ratio Read. + /// + UINT32 ClockFrequencyRatioRead:1; + UINT32 Reserved4:3; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_IA32_PLATFORM_ID_REGISTER; + + +/** + Section 10.4.4, "Local APIC Status and Location.". + + @param ECX MSR_P6_APIC_BASE (0x0000001B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_APIC_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_APIC_BASE_REGISTER. + + Example usage + @code + MSR_P6_APIC_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_APIC_BASE); + AsmWriteMsr64 (MSR_P6_APIC_BASE, Msr.Uint64); + @endcode + @note MSR_P6_APIC_BASE is defined as APIC_BASE in SDM. +**/ +#define MSR_P6_APIC_BASE 0x0000001B + +/** + MSR information returned for MSR index #MSR_P6_APIC_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bit 8] Boot Strap Processor indicator Bit 1 = BSP. + /// + UINT32 BSP:1; + UINT32 Reserved2:2; + /// + /// [Bit 11] APIC Global Enable Bit - Permanent till reset 1 = Enabled 0 = + /// Disabled. + /// + UINT32 EN:1; + /// + /// [Bits 31:12] APIC Base Address. + /// + UINT32 ApicBase:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_APIC_BASE_REGISTER; + + +/** + Processor Hard Power-On Configuration (R/W) Enables and disables processor + features; (R) indicates current processor configuration. + + @param ECX MSR_P6_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_P6_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_P6_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_P6_EBL_CR_POWERON is defined as EBL_CR_POWERON in SDM. +**/ +#define MSR_P6_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_P6_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled 0 = Disabled. + /// + UINT32 DataErrorCheckingEnable:1; + /// + /// [Bit 2] Response Error Checking Enable FRCERR Observation Enable (R/W) + /// 1 = Enabled 0 = Disabled. + /// + UINT32 ResponseErrorCheckingEnable:1; + /// + /// [Bit 3] AERR# Drive Enable (R/W) 1 = Enabled 0 = Disabled. + /// + UINT32 AERR_DriveEnable:1; + /// + /// [Bit 4] BERR# Enable for Initiator Bus Requests (R/W) 1 = Enabled 0 = + /// Disabled. + /// + UINT32 BERR_Enable:1; + UINT32 Reserved2:1; + /// + /// [Bit 6] BERR# Driver Enable for Initiator Internal Errors (R/W) 1 = + /// Enabled 0 = Disabled. + /// + UINT32 BERR_DriverEnable:1; + /// + /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled 0 = Disabled. + /// + UINT32 BINIT_DriverEnable:1; + /// + /// [Bit 8] Output Tri-state Enabled (R) 1 = Enabled 0 = Disabled. + /// + UINT32 OutputTriStateEnable:1; + /// + /// [Bit 9] Execute BIST (R) 1 = Enabled 0 = Disabled. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 10] AERR# Observation Enabled (R) 1 = Enabled 0 = Disabled. + /// + UINT32 AERR_ObservationEnabled:1; + UINT32 Reserved3:1; + /// + /// [Bit 12] BINIT# Observation Enabled (R) 1 = Enabled 0 = Disabled. + /// + UINT32 BINIT_ObservationEnabled:1; + /// + /// [Bit 13] In Order Queue Depth (R) 1 = 1 0 = 8. + /// + UINT32 InOrderQueueDepth:1; + /// + /// [Bit 14] 1-MByte Power on Reset Vector (R) 1 = 1MByte 0 = 4GBytes. + /// + UINT32 ResetVector:1; + /// + /// [Bit 15] FRC Mode Enable (R) 1 = Enabled 0 = Disabled. + /// + UINT32 FRCModeEnable:1; + /// + /// [Bits 17:16] APIC Cluster ID (R). + /// + UINT32 APICClusterID:2; + /// + /// [Bits 19:18] System Bus Frequency (R) 00 = 66MHz 10 = 100Mhz 01 = + /// 133MHz 11 = Reserved. + /// + UINT32 SystemBusFrequency:2; + /// + /// [Bits 21:20] Symmetric Arbitration ID (R). + /// + UINT32 SymmetricArbitrationID:2; + /// + /// [Bits 25:22] Clock Frequency Ratio (R). + /// + UINT32 ClockFrequencyRatio:4; + /// + /// [Bit 26] Low Power Mode Enable (R/W). + /// + UINT32 LowPowerModeEnable:1; + /// + /// [Bit 27] Clock Frequency Ratio. + /// + UINT32 ClockFrequencyRatio1:1; + UINT32 Reserved4:4; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_EBL_CR_POWERON_REGISTER; + + +/** + Test Control Register. + + @param ECX MSR_P6_TEST_CTL (0x00000033) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_TEST_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_TEST_CTL_REGISTER. + + Example usage + @code + MSR_P6_TEST_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_TEST_CTL); + AsmWriteMsr64 (MSR_P6_TEST_CTL, Msr.Uint64); + @endcode + @note MSR_P6_TEST_CTL is defined as TEST_CTL in SDM. +**/ +#define MSR_P6_TEST_CTL 0x00000033 + +/** + MSR information returned for MSR index #MSR_P6_TEST_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:30; + /// + /// [Bit 30] Streaming Buffer Disable. + /// + UINT32 StreamingBufferDisable:1; + /// + /// [Bit 31] Disable LOCK# Assertion for split locked access. + /// + UINT32 Disable_LOCK:1; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_TEST_CTL_REGISTER; + + +/** + BIOS Update Trigger Register. + + @param ECX MSR_P6_BIOS_UPDT_TRIG (0x00000079) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BIOS_UPDT_TRIG); + AsmWriteMsr64 (MSR_P6_BIOS_UPDT_TRIG, Msr); + @endcode + @note MSR_P6_BIOS_UPDT_TRIG is defined as BIOS_UPDT_TRIG in SDM. +**/ +#define MSR_P6_BIOS_UPDT_TRIG 0x00000079 + + +/** + Chunk n data register D[63:0]: used to write to and read from the L2. + + @param ECX MSR_P6_BBL_CR_Dn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BBL_CR_D0); + AsmWriteMsr64 (MSR_P6_BBL_CR_D0, Msr); + @endcode + @note MSR_P6_BBL_CR_D0 is defined as BBL_CR_D0 in SDM. + MSR_P6_BBL_CR_D1 is defined as BBL_CR_D1 in SDM. + MSR_P6_BBL_CR_D2 is defined as BBL_CR_D2 in SDM. + @{ +**/ +#define MSR_P6_BBL_CR_D0 0x00000088 +#define MSR_P6_BBL_CR_D1 0x00000089 +#define MSR_P6_BBL_CR_D2 0x0000008A +/// @} + + +/** + BIOS Update Signature Register or Chunk 3 data register D[63:0] Used to + write to and read from the L2 depending on the usage model. + + @param ECX MSR_P6_BIOS_SIGN (0x0000008B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BIOS_SIGN); + AsmWriteMsr64 (MSR_P6_BIOS_SIGN, Msr); + @endcode + @note MSR_P6_BIOS_SIGN is defined as BIOS_SIGN in SDM. +**/ +#define MSR_P6_BIOS_SIGN 0x0000008B + + +/** + + + @param ECX MSR_P6_PERFCTR0 (0x000000C1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_PERFCTR0); + AsmWriteMsr64 (MSR_P6_PERFCTR0, Msr); + @endcode + @note MSR_P6_PERFCTR0 is defined as PERFCTR0 in SDM. + MSR_P6_PERFCTR1 is defined as PERFCTR1 in SDM. + @{ +**/ +#define MSR_P6_PERFCTR0 0x000000C1 +#define MSR_P6_PERFCTR1 0x000000C2 +/// @} + + +/** + + + @param ECX MSR_P6_MTRRCAP (0x000000FE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRCAP); + AsmWriteMsr64 (MSR_P6_MTRRCAP, Msr); + @endcode + @note MSR_P6_MTRRCAP is defined as MTRRCAP in SDM. +**/ +#define MSR_P6_MTRRCAP 0x000000FE + + +/** + Address register: used to send specified address (A31-A3) to L2 during cache + initialization accesses. + + @param ECX MSR_P6_BBL_CR_ADDR (0x00000116) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_ADDR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_ADDR_REGISTER. + + Example usage + @code + MSR_P6_BBL_CR_ADDR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_ADDR); + AsmWriteMsr64 (MSR_P6_BBL_CR_ADDR, Msr.Uint64); + @endcode + @note MSR_P6_BBL_CR_ADDR is defined as BBL_CR_ADDR in SDM. +**/ +#define MSR_P6_BBL_CR_ADDR 0x00000116 + +/** + MSR information returned for MSR index #MSR_P6_BBL_CR_ADDR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:3; + /// + /// [Bits 31:3] Address bits + /// + UINT32 Address:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_BBL_CR_ADDR_REGISTER; + + +/** + Data ECC register D[7:0]: used to write ECC and read ECC to/from L2. + + @param ECX MSR_P6_BBL_CR_DECC (0x00000118) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BBL_CR_DECC); + AsmWriteMsr64 (MSR_P6_BBL_CR_DECC, Msr); + @endcode + @note MSR_P6_BBL_CR_DECC is defined as BBL_CR_DECC in SDM. +**/ +#define MSR_P6_BBL_CR_DECC 0x00000118 + + +/** + Control register: used to program L2 commands to be issued via cache + configuration accesses mechanism. Also receives L2 lookup response. + + @param ECX MSR_P6_BBL_CR_CTL (0x00000119) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_CTL_REGISTER. + + Example usage + @code + MSR_P6_BBL_CR_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_CTL); + AsmWriteMsr64 (MSR_P6_BBL_CR_CTL, Msr.Uint64); + @endcode + @note MSR_P6_BBL_CR_CTL is defined as BBL_CR_CTL in SDM. +**/ +#define MSR_P6_BBL_CR_CTL 0x00000119 + +/** + MSR information returned for MSR index #MSR_P6_BBL_CR_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 4:0] L2 Command + /// Data Read w/ LRU update (RLU) + /// Tag Read w/ Data Read (TRR) + /// Tag Inquire (TI) + /// L2 Control Register Read (CR) + /// L2 Control Register Write (CW) + /// Tag Write w/ Data Read (TWR) + /// Tag Write w/ Data Write (TWW) + /// Tag Write (TW). + /// + UINT32 L2Command:5; + /// + /// [Bits 6:5] State to L2 + /// + UINT32 StateToL2:2; + UINT32 Reserved:1; + /// + /// [Bits 9:8] Way to L2. + /// + UINT32 WayToL2:2; + /// + /// [Bits 11:10] Way 0 - 00, Way 1 - 01, Way 2 - 10, Way 3 - 11. + /// + UINT32 Way:2; + /// + /// [Bits 13:12] Modified - 11,Exclusive - 10, Shared - 01, Invalid - 00. + /// + UINT32 MESI:2; + /// + /// [Bits 15:14] State from L2. + /// + UINT32 StateFromL2:2; + UINT32 Reserved2:1; + /// + /// [Bit 17] L2 Hit. + /// + UINT32 L2Hit:1; + UINT32 Reserved3:1; + /// + /// [Bits 20:19] User supplied ECC. + /// + UINT32 UserEcc:2; + /// + /// [Bit 21] Processor number Disable = 1 Enable = 0 Reserved. + /// + UINT32 ProcessorNumber:1; + UINT32 Reserved4:10; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_BBL_CR_CTL_REGISTER; + + +/** + Trigger register: used to initiate a cache configuration accesses access, + Write only with Data = 0. + + @param ECX MSR_P6_BBL_CR_TRIG (0x0000011A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BBL_CR_TRIG); + AsmWriteMsr64 (MSR_P6_BBL_CR_TRIG, Msr); + @endcode + @note MSR_P6_BBL_CR_TRIG is defined as BBL_CR_TRIG in SDM. +**/ +#define MSR_P6_BBL_CR_TRIG 0x0000011A + + +/** + Busy register: indicates when a cache configuration accesses L2 command is + in progress. D[0] = 1 = BUSY. + + @param ECX MSR_P6_BBL_CR_BUSY (0x0000011B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_BBL_CR_BUSY); + AsmWriteMsr64 (MSR_P6_BBL_CR_BUSY, Msr); + @endcode + @note MSR_P6_BBL_CR_BUSY is defined as BBL_CR_BUSY in SDM. +**/ +#define MSR_P6_BBL_CR_BUSY 0x0000011B + + +/** + Control register 3: used to configure the L2 Cache. + + @param ECX MSR_P6_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_P6_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_P6_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_P6_BBL_CR_CTL3 is defined as BBL_CR_CTL3 in SDM. +**/ +#define MSR_P6_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_P6_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Configured (read/write ). + /// + UINT32 L2Configured:1; + /// + /// [Bits 4:1] L2 Cache Latency (read/write). + /// + UINT32 L2CacheLatency:4; + /// + /// [Bit 5] ECC Check Enable (read/write). + /// + UINT32 ECCCheckEnable:1; + /// + /// [Bit 6] Address Parity Check Enable (read/write). + /// + UINT32 AddressParityCheckEnable:1; + /// + /// [Bit 7] CRTN Parity Check Enable (read/write). + /// + UINT32 CRTNParityCheckEnable:1; + /// + /// [Bit 8] L2 Enabled (read/write). + /// + UINT32 L2Enabled:1; + /// + /// [Bits 10:9] L2 Associativity (read only) Direct Mapped 2 Way 4 Way + /// Reserved. + /// + UINT32 L2Associativity:2; + /// + /// [Bits 12:11] Number of L2 banks (read only). + /// + UINT32 L2Banks:2; + /// + /// [Bits 17:13] Cache size per bank (read/write) 256KBytes 512KBytes + /// 1MByte 2MByte 4MBytes. + /// + UINT32 CacheSizePerBank:5; + /// + /// [Bit 18] Cache State error checking enable (read/write). + /// + UINT32 CacheStateErrorEnable:1; + UINT32 Reserved1:1; + /// + /// [Bits 22:20] L2 Physical Address Range support 64GBytes 32GBytes + /// 16GBytes 8GBytes 4GBytes 2GBytes 1GBytes 512MBytes. + /// + UINT32 L2AddressRange:3; + /// + /// [Bit 23] L2 Hardware Disable (read only). + /// + UINT32 L2HardwareDisable:1; + UINT32 Reserved2:1; + /// + /// [Bit 25] Cache bus fraction (read only). + /// + UINT32 CacheBusFraction:1; + UINT32 Reserved3:6; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_BBL_CR_CTL3_REGISTER; + + +/** + CS register target for CPL 0 code. + + @param ECX MSR_P6_SYSENTER_CS_MSR (0x00000174) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_SYSENTER_CS_MSR); + AsmWriteMsr64 (MSR_P6_SYSENTER_CS_MSR, Msr); + @endcode + @note MSR_P6_SYSENTER_CS_MSR is defined as SYSENTER_CS_MSR in SDM. +**/ +#define MSR_P6_SYSENTER_CS_MSR 0x00000174 + + +/** + Stack pointer for CPL 0 stack. + + @param ECX MSR_P6_SYSENTER_ESP_MSR (0x00000175) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_SYSENTER_ESP_MSR); + AsmWriteMsr64 (MSR_P6_SYSENTER_ESP_MSR, Msr); + @endcode + @note MSR_P6_SYSENTER_ESP_MSR is defined as SYSENTER_ESP_MSR in SDM. +**/ +#define MSR_P6_SYSENTER_ESP_MSR 0x00000175 + + +/** + CPL 0 code entry point. + + @param ECX MSR_P6_SYSENTER_EIP_MSR (0x00000176) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_SYSENTER_EIP_MSR); + AsmWriteMsr64 (MSR_P6_SYSENTER_EIP_MSR, Msr); + @endcode + @note MSR_P6_SYSENTER_EIP_MSR is defined as SYSENTER_EIP_MSR in SDM. +**/ +#define MSR_P6_SYSENTER_EIP_MSR 0x00000176 + + +/** + + + @param ECX MSR_P6_MCG_CAP (0x00000179) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MCG_CAP); + AsmWriteMsr64 (MSR_P6_MCG_CAP, Msr); + @endcode + @note MSR_P6_MCG_CAP is defined as MCG_CAP in SDM. +**/ +#define MSR_P6_MCG_CAP 0x00000179 + + +/** + + + @param ECX MSR_P6_MCG_STATUS (0x0000017A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MCG_STATUS); + AsmWriteMsr64 (MSR_P6_MCG_STATUS, Msr); + @endcode + @note MSR_P6_MCG_STATUS is defined as MCG_STATUS in SDM. +**/ +#define MSR_P6_MCG_STATUS 0x0000017A + + +/** + + + @param ECX MSR_P6_MCG_CTL (0x0000017B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MCG_CTL); + AsmWriteMsr64 (MSR_P6_MCG_CTL, Msr); + @endcode + @note MSR_P6_MCG_CTL is defined as MCG_CTL in SDM. +**/ +#define MSR_P6_MCG_CTL 0x0000017B + + +/** + + + @param ECX MSR_P6_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_PERFEVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_PERFEVTSEL_REGISTER. + + Example usage + @code + MSR_P6_PERFEVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_PERFEVTSEL0); + AsmWriteMsr64 (MSR_P6_PERFEVTSEL0, Msr.Uint64); + @endcode + @note MSR_P6_PERFEVTSEL0 is defined as PERFEVTSEL0 in SDM. + MSR_P6_PERFEVTSEL1 is defined as PERFEVTSEL1 in SDM. + @{ +**/ +#define MSR_P6_PERFEVTSEL0 0x00000186 +#define MSR_P6_PERFEVTSEL1 0x00000187 +/// @} + +/** + MSR information returned for MSR indexes #MSR_P6_PERFEVTSEL0 and + #MSR_P6_PERFEVTSEL1. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Event Select Refer to Performance Counter section for a + /// list of event encodings. + /// + UINT32 EventSelect:8; + /// + /// [Bits 15:8] UMASK (Unit Mask) Unit mask register set to 0 to enable + /// all count options. + /// + UINT32 UMASK:8; + /// + /// [Bit 16] USER Controls the counting of events at Privilege levels of + /// 1, 2, and 3. + /// + UINT32 USR:1; + /// + /// [Bit 17] OS Controls the counting of events at Privilege level of 0. + /// + UINT32 OS:1; + /// + /// [Bit 18] E Occurrence/Duration Mode Select 1 = Occurrence 0 = Duration. + /// + UINT32 E:1; + /// + /// [Bit 19] PC Enabled the signaling of performance counter overflow via + /// BP0 pin. + /// + UINT32 PC:1; + /// + /// [Bit 20] INT Enables the signaling of counter overflow via input to + /// APIC 1 = Enable 0 = Disable. + /// + UINT32 INT:1; + UINT32 Reserved1:1; + /// + /// [Bit 22] ENABLE Enables the counting of performance events in both + /// counters 1 = Enable 0 = Disable. + /// + UINT32 EN:1; + /// + /// [Bit 23] INV Inverts the result of the CMASK condition 1 = Inverted 0 + /// = Non-Inverted. + /// + UINT32 INV:1; + /// + /// [Bits 31:24] CMASK (Counter Mask). + /// + UINT32 CMASK:8; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_PERFEVTSEL_REGISTER; + + +/** + + + @param ECX MSR_P6_DEBUGCTLMSR (0x000001D9) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_DEBUGCTLMSR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_DEBUGCTLMSR_REGISTER. + + Example usage + @code + MSR_P6_DEBUGCTLMSR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_DEBUGCTLMSR); + AsmWriteMsr64 (MSR_P6_DEBUGCTLMSR, Msr.Uint64); + @endcode + @note MSR_P6_DEBUGCTLMSR is defined as DEBUGCTLMSR in SDM. +**/ +#define MSR_P6_DEBUGCTLMSR 0x000001D9 + +/** + MSR information returned for MSR index #MSR_P6_DEBUGCTLMSR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable/Disable Last Branch Records. + /// + UINT32 LBR:1; + /// + /// [Bit 1] Branch Trap Flag. + /// + UINT32 BTF:1; + /// + /// [Bit 2] Performance Monitoring/Break Point Pins. + /// + UINT32 PB0:1; + /// + /// [Bit 3] Performance Monitoring/Break Point Pins. + /// + UINT32 PB1:1; + /// + /// [Bit 4] Performance Monitoring/Break Point Pins. + /// + UINT32 PB2:1; + /// + /// [Bit 5] Performance Monitoring/Break Point Pins. + /// + UINT32 PB3:1; + /// + /// [Bit 6] Enable/Disable Execution Trace Messages. + /// + UINT32 TR:1; + UINT32 Reserved1:25; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_DEBUGCTLMSR_REGISTER; + + +/** + + + @param ECX MSR_P6_LASTBRANCHFROMIP (0x000001DB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_LASTBRANCHFROMIP); + AsmWriteMsr64 (MSR_P6_LASTBRANCHFROMIP, Msr); + @endcode + @note MSR_P6_LASTBRANCHFROMIP is defined as LASTBRANCHFROMIP in SDM. +**/ +#define MSR_P6_LASTBRANCHFROMIP 0x000001DB + + +/** + + + @param ECX MSR_P6_LASTBRANCHTOIP (0x000001DC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_LASTBRANCHTOIP); + AsmWriteMsr64 (MSR_P6_LASTBRANCHTOIP, Msr); + @endcode + @note MSR_P6_LASTBRANCHTOIP is defined as LASTBRANCHTOIP in SDM. +**/ +#define MSR_P6_LASTBRANCHTOIP 0x000001DC + + +/** + + + @param ECX MSR_P6_LASTINTFROMIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_LASTINTFROMIP); + AsmWriteMsr64 (MSR_P6_LASTINTFROMIP, Msr); + @endcode + @note MSR_P6_LASTINTFROMIP is defined as LASTINTFROMIP in SDM. +**/ +#define MSR_P6_LASTINTFROMIP 0x000001DD + + +/** + + + @param ECX MSR_P6_LASTINTTOIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_LASTINTTOIP); + AsmWriteMsr64 (MSR_P6_LASTINTTOIP, Msr); + @endcode + @note MSR_P6_LASTINTTOIP is defined as LASTINTTOIP in SDM. +**/ +#define MSR_P6_LASTINTTOIP 0x000001DE + + +/** + + + @param ECX MSR_P6_ROB_CR_BKUPTMPDR6 (0x000001E0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER. + + Example usage + @code + MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_ROB_CR_BKUPTMPDR6); + AsmWriteMsr64 (MSR_P6_ROB_CR_BKUPTMPDR6, Msr.Uint64); + @endcode + @note MSR_P6_ROB_CR_BKUPTMPDR6 is defined as ROB_CR_BKUPTMPDR6 in SDM. +**/ +#define MSR_P6_ROB_CR_BKUPTMPDR6 0x000001E0 + +/** + MSR information returned for MSR index #MSR_P6_ROB_CR_BKUPTMPDR6 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:2; + /// + /// [Bit 2] Fast Strings Enable bit. Default is enabled. + /// + UINT32 FastStrings:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER; + + +/** + + + @param ECX MSR_P6_MTRRPHYSBASEn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRPHYSBASE0); + AsmWriteMsr64 (MSR_P6_MTRRPHYSBASE0, Msr); + @endcode + @note MSR_P6_MTRRPHYSBASE0 is defined as MTRRPHYSBASE0 in SDM. + MSR_P6_MTRRPHYSBASE1 is defined as MTRRPHYSBASE1 in SDM. + MSR_P6_MTRRPHYSBASE2 is defined as MTRRPHYSBASE2 in SDM. + MSR_P6_MTRRPHYSBASE3 is defined as MTRRPHYSBASE3 in SDM. + MSR_P6_MTRRPHYSBASE4 is defined as MTRRPHYSBASE4 in SDM. + MSR_P6_MTRRPHYSBASE5 is defined as MTRRPHYSBASE5 in SDM. + MSR_P6_MTRRPHYSBASE6 is defined as MTRRPHYSBASE6 in SDM. + MSR_P6_MTRRPHYSBASE7 is defined as MTRRPHYSBASE7 in SDM. + @{ +**/ +#define MSR_P6_MTRRPHYSBASE0 0x00000200 +#define MSR_P6_MTRRPHYSBASE1 0x00000202 +#define MSR_P6_MTRRPHYSBASE2 0x00000204 +#define MSR_P6_MTRRPHYSBASE3 0x00000206 +#define MSR_P6_MTRRPHYSBASE4 0x00000208 +#define MSR_P6_MTRRPHYSBASE5 0x0000020A +#define MSR_P6_MTRRPHYSBASE6 0x0000020C +#define MSR_P6_MTRRPHYSBASE7 0x0000020E +/// @} + + +/** + + + @param ECX MSR_P6_MTRRPHYSMASKn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRPHYSMASK0); + AsmWriteMsr64 (MSR_P6_MTRRPHYSMASK0, Msr); + @endcode + @note MSR_P6_MTRRPHYSMASK0 is defined as MTRRPHYSMASK0 in SDM. + MSR_P6_MTRRPHYSMASK1 is defined as MTRRPHYSMASK1 in SDM. + MSR_P6_MTRRPHYSMASK2 is defined as MTRRPHYSMASK2 in SDM. + MSR_P6_MTRRPHYSMASK3 is defined as MTRRPHYSMASK3 in SDM. + MSR_P6_MTRRPHYSMASK4 is defined as MTRRPHYSMASK4 in SDM. + MSR_P6_MTRRPHYSMASK5 is defined as MTRRPHYSMASK5 in SDM. + MSR_P6_MTRRPHYSMASK6 is defined as MTRRPHYSMASK6 in SDM. + MSR_P6_MTRRPHYSMASK7 is defined as MTRRPHYSMASK7 in SDM. + @{ +**/ +#define MSR_P6_MTRRPHYSMASK0 0x00000201 +#define MSR_P6_MTRRPHYSMASK1 0x00000203 +#define MSR_P6_MTRRPHYSMASK2 0x00000205 +#define MSR_P6_MTRRPHYSMASK3 0x00000207 +#define MSR_P6_MTRRPHYSMASK4 0x00000209 +#define MSR_P6_MTRRPHYSMASK5 0x0000020B +#define MSR_P6_MTRRPHYSMASK6 0x0000020D +#define MSR_P6_MTRRPHYSMASK7 0x0000020F +/// @} + + +/** + + + @param ECX MSR_P6_MTRRFIX64K_00000 (0x00000250) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX64K_00000); + AsmWriteMsr64 (MSR_P6_MTRRFIX64K_00000, Msr); + @endcode + @note MSR_P6_MTRRFIX64K_00000 is defined as MTRRFIX64K_00000 in SDM. +**/ +#define MSR_P6_MTRRFIX64K_00000 0x00000250 + + +/** + + + @param ECX MSR_P6_MTRRFIX16K_80000 (0x00000258) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX16K_80000); + AsmWriteMsr64 (MSR_P6_MTRRFIX16K_80000, Msr); + @endcode + @note MSR_P6_MTRRFIX16K_80000 is defined as MTRRFIX16K_80000 in SDM. +**/ +#define MSR_P6_MTRRFIX16K_80000 0x00000258 + + +/** + + + @param ECX MSR_P6_MTRRFIX16K_A0000 (0x00000259) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX16K_A0000); + AsmWriteMsr64 (MSR_P6_MTRRFIX16K_A0000, Msr); + @endcode + @note MSR_P6_MTRRFIX16K_A0000 is defined as MTRRFIX16K_A0000 in SDM. +**/ +#define MSR_P6_MTRRFIX16K_A0000 0x00000259 + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_C0000 (0x00000268) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_C0000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_C0000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_C0000 is defined as MTRRFIX4K_C0000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_C0000 0x00000268 + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_C8000 (0x00000269) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_C8000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_C8000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_C8000 is defined as MTRRFIX4K_C8000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_C8000 0x00000269 + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_D0000 (0x0000026A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_D0000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_D0000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_D0000 is defined as MTRRFIX4K_D0000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_D0000 0x0000026A + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_D8000 (0x0000026B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_D8000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_D8000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_D8000 is defined as MTRRFIX4K_D8000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_D8000 0x0000026B + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_E0000 (0x0000026C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_E0000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_E0000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_E0000 is defined as MTRRFIX4K_E0000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_E0000 0x0000026C + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_E8000 (0x0000026D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_E8000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_E8000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_E8000 is defined as MTRRFIX4K_E8000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_E8000 0x0000026D + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_F0000 (0x0000026E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_F0000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_F0000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_F0000 is defined as MTRRFIX4K_F0000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_F0000 0x0000026E + + +/** + + + @param ECX MSR_P6_MTRRFIX4K_F8000 (0x0000026F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_F8000); + AsmWriteMsr64 (MSR_P6_MTRRFIX4K_F8000, Msr); + @endcode + @note MSR_P6_MTRRFIX4K_F8000 is defined as MTRRFIX4K_F8000 in SDM. +**/ +#define MSR_P6_MTRRFIX4K_F8000 0x0000026F + + +/** + + + @param ECX MSR_P6_MTRRDEFTYPE (0x000002FF) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_MTRRDEFTYPE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_MTRRDEFTYPE_REGISTER. + + Example usage + @code + MSR_P6_MTRRDEFTYPE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_MTRRDEFTYPE); + AsmWriteMsr64 (MSR_P6_MTRRDEFTYPE, Msr.Uint64); + @endcode + @note MSR_P6_MTRRDEFTYPE is defined as MTRRDEFTYPE in SDM. +**/ +#define MSR_P6_MTRRDEFTYPE 0x000002FF + +/** + MSR information returned for MSR index #MSR_P6_MTRRDEFTYPE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Default memory type. + /// + UINT32 Type:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] Fixed MTRR enable. + /// + UINT32 FE:1; + /// + /// [Bit 11] MTRR Enable. + /// + UINT32 E:1; + UINT32 Reserved2:20; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_MTRRDEFTYPE_REGISTER; + + +/** + + + @param ECX MSR_P6_MC0_CTL (0x00000400) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MC0_CTL); + AsmWriteMsr64 (MSR_P6_MC0_CTL, Msr); + @endcode + @note MSR_P6_MC0_CTL is defined as MC0_CTL in SDM. + MSR_P6_MC1_CTL is defined as MC1_CTL in SDM. + MSR_P6_MC2_CTL is defined as MC2_CTL in SDM. + MSR_P6_MC3_CTL is defined as MC3_CTL in SDM. + MSR_P6_MC4_CTL is defined as MC4_CTL in SDM. + @{ +**/ +#define MSR_P6_MC0_CTL 0x00000400 +#define MSR_P6_MC1_CTL 0x00000404 +#define MSR_P6_MC2_CTL 0x00000408 +#define MSR_P6_MC3_CTL 0x00000410 +#define MSR_P6_MC4_CTL 0x0000040C +/// @} + + +/** + + Bit definitions for MSR_P6_MC4_STATUS are the same as MSR_P6_MC0_STATUS, + except bits 0, 4, 57, and 61 are hardcoded to 1. + + @param ECX MSR_P6_MCn_STATUS + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_P6_MC_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_P6_MC_STATUS_REGISTER. + + Example usage + @code + MSR_P6_MC_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_P6_MC0_STATUS); + AsmWriteMsr64 (MSR_P6_MC0_STATUS, Msr.Uint64); + @endcode + @note MSR_P6_MC0_STATUS is defined as MC0_STATUS in SDM. + MSR_P6_MC1_STATUS is defined as MC1_STATUS in SDM. + MSR_P6_MC2_STATUS is defined as MC2_STATUS in SDM. + MSR_P6_MC3_STATUS is defined as MC3_STATUS in SDM. + MSR_P6_MC4_STATUS is defined as MC4_STATUS in SDM. + @{ +**/ +#define MSR_P6_MC0_STATUS 0x00000401 +#define MSR_P6_MC1_STATUS 0x00000405 +#define MSR_P6_MC2_STATUS 0x00000409 +#define MSR_P6_MC3_STATUS 0x00000411 +#define MSR_P6_MC4_STATUS 0x0000040D +/// @} + +/** + MSR information returned for MSR index #MSR_P6_MC0_STATUS to + #MSR_P6_MC4_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] MC_STATUS_MCACOD. + /// + UINT32 MC_STATUS_MCACOD:16; + /// + /// [Bits 31:16] MC_STATUS_MSCOD. + /// + UINT32 MC_STATUS_MSCOD:16; + UINT32 Reserved:25; + /// + /// [Bit 57] MC_STATUS_DAM. + /// + UINT32 MC_STATUS_DAM:1; + /// + /// [Bit 58] MC_STATUS_ADDRV. + /// + UINT32 MC_STATUS_ADDRV:1; + /// + /// [Bit 59] MC_STATUS_MISCV. + /// + UINT32 MC_STATUS_MISCV:1; + /// + /// [Bit 60] MC_STATUS_EN. (Note: For MC0_STATUS only, this bit is + /// hardcoded to 1.). + /// + UINT32 MC_STATUS_EN:1; + /// + /// [Bit 61] MC_STATUS_UC. + /// + UINT32 MC_STATUS_UC:1; + /// + /// [Bit 62] MC_STATUS_O. + /// + UINT32 MC_STATUS_O:1; + /// + /// [Bit 63] MC_STATUS_V. + /// + UINT32 MC_STATUS_V:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_P6_MC_STATUS_REGISTER; + + +/** + + MSR_P6_MC4_ADDR is defined in MCA architecture but not implemented in P6 Family processors. + + @param ECX MSR_P6_MC0_ADDR (0x00000402) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MC0_ADDR); + AsmWriteMsr64 (MSR_P6_MC0_ADDR, Msr); + @endcode + @note MSR_P6_MC0_ADDR is defined as MC0_ADDR in SDM. + MSR_P6_MC1_ADDR is defined as MC1_ADDR in SDM. + MSR_P6_MC2_ADDR is defined as MC2_ADDR in SDM. + MSR_P6_MC3_ADDR is defined as MC3_ADDR in SDM. + MSR_P6_MC4_ADDR is defined as MC4_ADDR in SDM. + @{ +**/ +#define MSR_P6_MC0_ADDR 0x00000402 +#define MSR_P6_MC1_ADDR 0x00000406 +#define MSR_P6_MC2_ADDR 0x0000040A +#define MSR_P6_MC3_ADDR 0x00000412 +#define MSR_P6_MC4_ADDR 0x0000040E +/// @} + + +/** + Defined in MCA architecture but not implemented in the P6 family processors. + + @param ECX MSR_P6_MC0_MISC (0x00000403) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_P6_MC0_MISC); + AsmWriteMsr64 (MSR_P6_MC0_MISC, Msr); + @endcode + @note MSR_P6_MC0_MISC is defined as MC0_MISC in SDM. + MSR_P6_MC1_MISC is defined as MC1_MISC in SDM. + MSR_P6_MC2_MISC is defined as MC2_MISC in SDM. + MSR_P6_MC3_MISC is defined as MC3_MISC in SDM. + MSR_P6_MC4_MISC is defined as MC4_MISC in SDM. + @{ +**/ +#define MSR_P6_MC0_MISC 0x00000403 +#define MSR_P6_MC1_MISC 0x00000407 +#define MSR_P6_MC2_MISC 0x0000040B +#define MSR_P6_MC3_MISC 0x00000413 +#define MSR_P6_MC4_MISC 0x0000040F +/// @} + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h b/Core/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h new file mode 100644 index 0000000000..8922d56e2f --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h @@ -0,0 +1,2730 @@ +/** @file + MSR Definitions for Pentium(R) 4 Processors. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.18. + +**/ + +#ifndef __PENTIUM_4_MSR_H__ +#define __PENTIUM_4_MSR_H__ + +#include + +/** + Is Pentium(R) 4 Processors? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_PENTIUM_4_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x0F \ + ) + +/** + 3, 4, 6. Shared. See Section 8.10.5, "Monitor/Mwait Address Range + Determination.". + + @param ECX MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE (0x00000006) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE); + AsmWriteMsr64 (MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE, Msr); + @endcode + @note MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE is defined as IA32_MONITOR_FILTER_LINE_SIZE in SDM. +**/ +#define MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE 0x00000006 + + +/** + 0, 1, 2, 3, 4, 6. Shared. Processor Hard Power-On Configuration (R/W) + Enables and disables processor features; (R) indicates current processor + configuration. + + @param ECX MSR_PENTIUM_4_EBC_HARD_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_HARD_POWERON); + AsmWriteMsr64 (MSR_PENTIUM_4_EBC_HARD_POWERON, Msr.Uint64); + @endcode + @note MSR_PENTIUM_4_EBC_HARD_POWERON is defined as MSR_EBC_HARD_POWERON in SDM. +**/ +#define MSR_PENTIUM_4_EBC_HARD_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_EBC_HARD_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Output Tri-state Enabled (R) Indicates whether tri-state + /// output is enabled (1) or disabled (0) as set by the strapping of SMI#. + /// The value in this bit is written on the deassertion of RESET#; the bit + /// is set to 1 when the address bus signal is asserted. + /// + UINT32 OutputTriStateEnabled:1; + /// + /// [Bit 1] Execute BIST (R) Indicates whether the execution of the BIST + /// is enabled (1) or disabled (0) as set by the strapping of INIT#. The + /// value in this bit is written on the deassertion of RESET#; the bit is + /// set to 1 when the address bus signal is asserted. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 2] In Order Queue Depth (R) Indicates whether the in order queue + /// depth for the system bus is 1 (1) or up to 12 (0) as set by the + /// strapping of A7#. The value in this bit is written on the deassertion + /// of RESET#; the bit is set to 1 when the address bus signal is asserted. + /// + UINT32 InOrderQueueDepth:1; + /// + /// [Bit 3] MCERR# Observation Disabled (R) Indicates whether MCERR# + /// observation is enabled (0) or disabled (1) as determined by the + /// strapping of A9#. The value in this bit is written on the deassertion + /// of RESET#; the bit is set to 1 when the address bus signal is asserted. + /// + UINT32 MCERR_ObservationDisabled:1; + /// + /// [Bit 4] BINIT# Observation Enabled (R) Indicates whether BINIT# + /// observation is enabled (0) or disabled (1) as determined by the + /// strapping of A10#. The value in this bit is written on the deassertion + /// of RESET#; the bit is set to 1 when the address bus signal is asserted. + /// + UINT32 BINIT_ObservationEnabled:1; + /// + /// [Bits 6:5] APIC Cluster ID (R) Contains the logical APIC cluster ID + /// value as set by the strapping of A12# and A11#. The logical cluster ID + /// value is written into the field on the deassertion of RESET#; the + /// field is set to 1 when the address bus signal is asserted. + /// + UINT32 APICClusterID:2; + /// + /// [Bit 7] Bus Park Disable (R) Indicates whether bus park is enabled + /// (0) or disabled (1) as set by the strapping of A15#. The value in this + /// bit is written on the deassertion of RESET#; the bit is set to 1 when + /// the address bus signal is asserted. + /// + UINT32 BusParkDisable:1; + UINT32 Reserved1:4; + /// + /// [Bits 13:12] Agent ID (R) Contains the logical agent ID value as set + /// by the strapping of BR[3:0]. The logical ID value is written into the + /// field on the deassertion of RESET#; the field is set to 1 when the + /// address bus signal is asserted. + /// + UINT32 AgentID:2; + UINT32 Reserved2:18; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER; + + +/** + 0, 1, 2, 3, 4, 6. Shared. Processor Soft Power-On Configuration (R/W) + Enables and disables processor features. + + @param ECX MSR_PENTIUM_4_EBC_SOFT_POWERON (0x0000002B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_SOFT_POWERON); + AsmWriteMsr64 (MSR_PENTIUM_4_EBC_SOFT_POWERON, Msr.Uint64); + @endcode + @note MSR_PENTIUM_4_EBC_SOFT_POWERON is defined as MSR_EBC_SOFT_POWERON in SDM. +**/ +#define MSR_PENTIUM_4_EBC_SOFT_POWERON 0x0000002B + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_EBC_SOFT_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] RCNT/SCNT On Request Encoding Enable (R/W) Controls the + /// driving of RCNT/SCNT on the request encoding. Set to enable (1); clear + /// to disabled (0, default). + /// + UINT32 RCNT_SCNT:1; + /// + /// [Bit 1] Data Error Checking Disable (R/W) Set to disable system data + /// bus parity checking; clear to enable parity checking. + /// + UINT32 DataErrorCheckingDisable:1; + /// + /// [Bit 2] Response Error Checking Disable (R/W) Set to disable + /// (default); clear to enable. + /// + UINT32 ResponseErrorCheckingDisable:1; + /// + /// [Bit 3] Address/Request Error Checking Disable (R/W) Set to disable + /// (default); clear to enable. + /// + UINT32 AddressRequestErrorCheckingDisable:1; + /// + /// [Bit 4] Initiator MCERR# Disable (R/W) Set to disable MCERR# driving + /// for initiator bus requests (default); clear to enable. + /// + UINT32 InitiatorMCERR_Disable:1; + /// + /// [Bit 5] Internal MCERR# Disable (R/W) Set to disable MCERR# driving + /// for initiator internal errors (default); clear to enable. + /// + UINT32 InternalMCERR_Disable:1; + /// + /// [Bit 6] BINIT# Driver Disable (R/W) Set to disable BINIT# driver + /// (default); clear to enable driver. + /// + UINT32 BINIT_DriverDisable:1; + UINT32 Reserved1:25; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER; + + +/** + 2,3, 4, 6. Shared. Processor Frequency Configuration The bit field layout of + this MSR varies according to the MODEL value in the CPUID version + information. The following bit field layout applies to Pentium 4 and Xeon + Processors with MODEL encoding equal or greater than 2. (R) The field + Indicates the current processor frequency configuration. + + @param ECX MSR_PENTIUM_4_EBC_FREQUENCY_ID (0x0000002C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_FREQUENCY_ID); + @endcode + @note MSR_PENTIUM_4_EBC_FREQUENCY_ID is defined as MSR_EBC_FREQUENCY_ID in SDM. +**/ +#define MSR_PENTIUM_4_EBC_FREQUENCY_ID 0x0000002C + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_EBC_FREQUENCY_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 18:16] Scalable Bus Speed (R/W) Indicates the intended scalable + /// bus speed: *EncodingScalable Bus Speed* + /// + /// 000B 100 MHz (Model 2). + /// 000B 266 MHz (Model 3 or 4) + /// 001B 133 MHz + /// 010B 200 MHz + /// 011B 166 MHz + /// 100B 333 MHz (Model 6) + /// + /// 133.33 MHz should be utilized if performing calculation with System + /// Bus Speed when encoding is 001B. 166.67 MHz should be utilized if + /// performing calculation with System Bus Speed when encoding is 011B. + /// 266.67 MHz should be utilized if performing calculation with System + /// Bus Speed when encoding is 000B and model encoding = 3 or 4. 333.33 + /// MHz should be utilized if performing calculation with System Bus + /// Speed when encoding is 100B and model encoding = 6. All other values + /// are reserved. + /// + UINT32 ScalableBusSpeed:3; + UINT32 Reserved2:5; + /// + /// [Bits 31:24] Core Clock Frequency to System Bus Frequency Ratio (R) + /// The processor core clock frequency to system bus frequency ratio + /// observed at the de-assertion of the reset pin. + /// + UINT32 ClockRatio:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER; + + +/** + 0, 1. Shared. Processor Frequency Configuration (R) The bit field layout of + this MSR varies according to the MODEL value of the CPUID version + information. This bit field layout applies to Pentium 4 and Xeon Processors + with MODEL encoding less than 2. Indicates current processor frequency + configuration. + + @param ECX MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 (0x0000002C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_FREQUENCY_ID_1); + @endcode + @note MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 is defined as MSR_EBC_FREQUENCY_ID_1 in SDM. +**/ +#define MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 0x0000002C + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:21; + /// + /// [Bits 23:21] Scalable Bus Speed (R/W) Indicates the intended scalable + /// bus speed: *Encoding* *Scalable Bus Speed* + /// + /// 000B 100 MHz All others values reserved. + /// + UINT32 ScalableBusSpeed:3; + UINT32 Reserved2:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER; + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EAX/RAX Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RAX (0x00000180) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RAX); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RAX, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RAX is defined as MSR_MCG_RAX in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RAX 0x00000180 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EBX/RBX Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RBX (0x00000181) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RBX); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RBX, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RBX is defined as MSR_MCG_RBX in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RBX 0x00000181 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check ECX/RCX Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RCX (0x00000182) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RCX); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RCX, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RCX is defined as MSR_MCG_RCX in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RCX 0x00000182 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EDX/RDX Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RDX (0x00000183) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RDX); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RDX, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RDX is defined as MSR_MCG_RDX in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RDX 0x00000183 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check ESI/RSI Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RSI (0x00000184) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RSI); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RSI, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RSI is defined as MSR_MCG_RSI in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RSI 0x00000184 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EDI/RDI Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RDI (0x00000185) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RDI); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RDI, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RDI is defined as MSR_MCG_RDI in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RDI 0x00000185 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EBP/RBP Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RBP (0x00000186) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RBP); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RBP, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RBP is defined as MSR_MCG_RBP in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RBP 0x00000186 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check ESP/RSP Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RSP (0x00000187) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RSP); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RSP, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RSP is defined as MSR_MCG_RSP in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RSP 0x00000187 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EFLAGS/RFLAG Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RFLAGS (0x00000188) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RFLAGS); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RFLAGS, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RFLAGS is defined as MSR_MCG_RFLAGS in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RFLAGS 0x00000188 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check EIP/RIP Save State See Section + 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register + state at time of machine check error. When in non-64-bit modes at the time + of the error, bits 63-32 do not contain valid data. + + @param ECX MSR_PENTIUM_4_MCG_RIP (0x00000189) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RIP); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RIP, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_RIP is defined as MSR_MCG_RIP in SDM. +**/ +#define MSR_PENTIUM_4_MCG_RIP 0x00000189 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check Miscellaneous See Section 15.3.2.6, + "IA32_MCG Extended Machine Check State MSRs.". + + @param ECX MSR_PENTIUM_4_MCG_MISC (0x0000018A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_MCG_MISC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_MCG_MISC_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_MCG_MISC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_MCG_MISC); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_MISC, Msr.Uint64); + @endcode + @note MSR_PENTIUM_4_MCG_MISC is defined as MSR_MCG_MISC in SDM. +**/ +#define MSR_PENTIUM_4_MCG_MISC 0x0000018A + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_MCG_MISC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] DS When set, the bit indicates that a page assist or page + /// fault occurred during DS normal operation. The processors response is + /// to shut down. The bit is used as an aid for debugging DS handling + /// code. It is the responsibility of the user (BIOS or operating system) + /// to clear this bit for normal operation. + /// + UINT32 DS:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_MCG_MISC_REGISTER; + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R8 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R8 (0x00000190) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R8); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R8, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R8 is defined as MSR_MCG_R8 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R8 0x00000190 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R9D/R9 See Section 15.3.2.6, + "IA32_MCG Extended Machine Check State MSRs.". Registers R8-15 (and the + associated state-save MSRs) exist only in Intel 64 processors. These + registers contain valid information only when the processor is operating in + 64-bit mode at the time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R9 (0x00000191) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R9); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R9, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R9 is defined as MSR_MCG_R9 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R9 0x00000191 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R10 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R10 (0x00000192) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R10); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R10, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R10 is defined as MSR_MCG_R10 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R10 0x00000192 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R11 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R11 (0x00000193) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R11); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R11, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R11 is defined as MSR_MCG_R11 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R11 0x00000193 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R12 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R12 (0x00000194) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R12); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R12, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R12 is defined as MSR_MCG_R12 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R12 0x00000194 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R13 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R13 (0x00000195) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R13); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R13, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R13 is defined as MSR_MCG_R13 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R13 0x00000195 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R14 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R14 (0x00000196) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R14); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R14, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R14 is defined as MSR_MCG_R14 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R14 0x00000196 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Machine Check R15 See Section 15.3.2.6, "IA32_MCG + Extended Machine Check State MSRs.". Registers R8-15 (and the associated + state-save MSRs) exist only in Intel 64 processors. These registers contain + valid information only when the processor is operating in 64-bit mode at the + time of the error. + + @param ECX MSR_PENTIUM_4_MCG_R15 (0x00000197) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R15); + AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R15, Msr); + @endcode + @note MSR_PENTIUM_4_MCG_R15 is defined as MSR_MCG_R15 in SDM. +**/ +#define MSR_PENTIUM_4_MCG_R15 0x00000197 + + +/** + Thermal Monitor 2 Control. 3,. Shared. For Family F, Model 3 processors: + When read, specifies the value of the target TM2 transition last written. + When set, it sets the next target value for TM2 transition. 4, 6. Shared. + For Family F, Model 4 and Model 6 processors: When read, specifies the value + of the target TM2 transition last written. Writes may cause #GP exceptions. + + @param ECX MSR_PENTIUM_4_THERM2_CTL (0x0000019D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_THERM2_CTL); + AsmWriteMsr64 (MSR_PENTIUM_4_THERM2_CTL, Msr); + @endcode + @note MSR_PENTIUM_4_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. +**/ +#define MSR_PENTIUM_4_THERM2_CTL 0x0000019D + + +/** + 0, 1, 2, 3, 4, 6. Shared. Enable Miscellaneous Processor Features (R/W). + + @param ECX MSR_PENTIUM_4_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_PENTIUM_4_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_PENTIUM_4_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_PENTIUM_4_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fast-Strings Enable. See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] x87 FPU Fopcode Compatibility Mode Enable. + /// + UINT32 FPU:1; + /// + /// [Bit 3] Thermal Monitor 1 Enable See Section 14.7.2, "Thermal + /// Monitor," and see Table 35-2. + /// + UINT32 TM1:1; + /// + /// [Bit 4] Split-Lock Disable When set, the bit causes an #AC exception + /// to be issued instead of a split-lock cycle. Operating systems that set + /// this bit must align system structures to avoid split-lock scenarios. + /// When the bit is clear (default), normal split-locks are issued to the + /// bus. + /// This debug feature is specific to the Pentium 4 processor. + /// + UINT32 SplitLockDisable:1; + UINT32 Reserved2:1; + /// + /// [Bit 6] Third-Level Cache Disable (R/W) When set, the third-level + /// cache is disabled; when clear (default) the third-level cache is + /// enabled. This flag is reserved for processors that do not have a + /// third-level cache. Note that the bit controls only the third-level + /// cache; and only if overall caching is enabled through the CD flag of + /// control register CR0, the page-level cache controls, and/or the MTRRs. + /// See Section 11.5.4, "Disabling and Enabling the L3 Cache.". + /// + UINT32 ThirdLevelCacheDisable:1; + /// + /// [Bit 7] Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + /// + /// [Bit 8] Suppress Lock Enable When set, assertion of LOCK on the bus is + /// suppressed during a Split Lock access. When clear (default), LOCK is + /// not suppressed. + /// + UINT32 SuppressLockEnable:1; + /// + /// [Bit 9] Prefetch Queue Disable When set, disables the prefetch queue. + /// When clear (default), enables the prefetch queue. + /// + UINT32 PrefetchQueueDisable:1; + /// + /// [Bit 10] FERR# Interrupt Reporting Enable (R/W) When set, interrupt + /// reporting through the FERR# pin is enabled; when clear, this interrupt + /// reporting function is disabled. + /// When this flag is set and the processor is in the stop-clock state + /// (STPCLK# is asserted), asserting the FERR# pin signals to the + /// processor that an interrupt (such as, INIT#, BINIT#, INTR, NMI, + /// SMI#, or RESET#) is pending and that the processor should return to + /// normal operation to handle the interrupt. This flag does not affect + /// the normal operation of the FERR# pin (to indicate an unmasked + /// floatingpoint error) when the STPCLK# pin is not asserted. + /// + UINT32 FERR:1; + /// + /// [Bit 11] Branch Trace Storage Unavailable (BTS_UNAVILABLE) (R) See + /// Table 35-2. When set, the processor does not support branch trace + /// storage (BTS); when clear, BTS is supported. + /// + UINT32 BTS:1; + /// + /// [Bit 12] PEBS_UNAVILABLE: Processor Event Based Sampling Unavailable + /// (R) See Table 35-2. When set, the processor does not support processor + /// event-based sampling (PEBS); when clear, PEBS is supported. + /// + UINT32 PEBS:1; + /// + /// [Bit 13] 3. TM2 Enable (R/W) When this bit is set (1) and the thermal + /// sensor indicates that the die temperature is at the predetermined + /// threshold, the Thermal Monitor 2 mechanism is engaged. TM2 will reduce + /// the bus to core ratio and voltage according to the value last written + /// to MSR_THERM2_CTL bits 15:0. When this bit is clear (0, default), the + /// processor does not change the VID signals or the bus to core ratio + /// when the processor enters a thermal managed state. If the TM2 feature + /// flag (ECX[8]) is not set to 1 after executing CPUID with EAX = 1, then + /// this feature is not supported and BIOS must not alter the contents of + /// this bit location. The processor is operating out of spec if both this + /// bit and the TM1 bit are set to disabled states. + /// + UINT32 TM2:1; + UINT32 Reserved3:4; + /// + /// [Bit 18] 3, 4, 6. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + /// + /// [Bit 19] Adjacent Cache Line Prefetch Disable (R/W) When set to 1, + /// the processor fetches the cache line of the 128-byte sector containing + /// currently required data. When set to 0, the processor fetches both + /// cache lines in the sector. + /// Single processor platforms should not set this bit. Server platforms + /// should set or clear this bit based on platform performance observed + /// in validation and testing. BIOS may contain a setup option that + /// controls the setting of this bit. + /// + UINT32 AdjacentCacheLinePrefetchDisable:1; + UINT32 Reserved4:2; + /// + /// [Bit 22] 3, 4, 6. Limit CPUID MAXVAL (R/W) See Table 35-2. Setting + /// this can cause unexpected behavior to software that depends on the + /// availability of CPUID leaves greater than 3. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + /// + /// [Bit 24] L1 Data Cache Context Mode (R/W) When set, the L1 data cache + /// is placed in shared mode; when clear (default), the cache is placed in + /// adaptive mode. This bit is only enabled for IA-32 processors that + /// support Intel Hyper-Threading Technology. See Section 11.5.6, "L1 Data + /// Cache Context Mode." When L1 is running in adaptive mode and CR3s are + /// identical, data in L1 is shared across logical processors. Otherwise, + /// L1 is not shared and cache use is competitive. If the Context ID + /// feature flag (ECX[10]) is set to 0 after executing CPUID with EAX = 1, + /// the ability to switch modes is not supported. BIOS must not alter the + /// contents of IA32_MISC_ENABLE[24]. + /// + UINT32 L1DataCacheContextMode:1; + UINT32 Reserved5:7; + UINT32 Reserved6:2; + /// + /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved7:29; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER; + + +/** + 3, 4, 6. Shared. Platform Feature Requirements (R). + + @param ECX MSR_PENTIUM_4_PLATFORM_BRV (0x000001A1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_PLATFORM_BRV_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_PLATFORM_BRV_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_PLATFORM_BRV_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_PLATFORM_BRV); + @endcode + @note MSR_PENTIUM_4_PLATFORM_BRV is defined as MSR_PLATFORM_BRV in SDM. +**/ +#define MSR_PENTIUM_4_PLATFORM_BRV 0x000001A1 + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_PLATFORM_BRV +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:18; + /// + /// [Bit 18] PLATFORM Requirements When set to 1, indicates the processor + /// has specific platform requirements. The details of the platform + /// requirements are listed in the respective data sheets of the processor. + /// + UINT32 PLATFORM:1; + UINT32 Reserved2:13; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_PLATFORM_BRV_REGISTER; + + +/** + 0, 1, 2, 3, 4, 6. Unique. Last Exception Record From Linear IP (R) Contains + a pointer to the last branch instruction that the processor executed prior + to the last exception that was generated or the last interrupt that was + handled. See Section 17.11.3, "Last Exception Records.". Unique. From Linear + IP Linear address of the last branch instruction (If IA32e mode is active). + From Linear IP Linear address of the last branch instruction. Reserved. + + @param ECX MSR_PENTIUM_4_LER_FROM_LIP (0x000001D7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LER_FROM_LIP); + @endcode + @note MSR_PENTIUM_4_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_PENTIUM_4_LER_FROM_LIP 0x000001D7 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Last Exception Record To Linear IP (R) This area + contains a pointer to the target of the last branch instruction that the + processor executed prior to the last exception that was generated or the + last interrupt that was handled. See Section 17.11.3, "Last Exception + Records.". Unique. From Linear IP Linear address of the target of the last + branch instruction (If IA-32e mode is active). From Linear IP Linear address + of the target of the last branch instruction. Reserved. + + @param ECX MSR_PENTIUM_4_LER_TO_LIP (0x000001D8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LER_TO_LIP); + @endcode + @note MSR_PENTIUM_4_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_PENTIUM_4_LER_TO_LIP 0x000001D8 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Debug Control (R/W) Controls how several debug + features are used. Bit definitions are discussed in the referenced section. + See Section 17.11.1, "MSR_DEBUGCTLA MSR.". + + @param ECX MSR_PENTIUM_4_DEBUGCTLA (0x000001D9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_DEBUGCTLA); + AsmWriteMsr64 (MSR_PENTIUM_4_DEBUGCTLA, Msr); + @endcode + @note MSR_PENTIUM_4_DEBUGCTLA is defined as MSR_DEBUGCTLA in SDM. +**/ +#define MSR_PENTIUM_4_DEBUGCTLA 0x000001D9 + + +/** + 0, 1, 2, 3, 4, 6. Unique. Last Branch Record Stack TOS (R/W) Contains an + index (0-3 or 0-15) that points to the top of the last branch record stack + (that is, that points the index of the MSR containing the most recent branch + record). See Section 17.11.2, "LBR Stack for Processors Based on Intel + NetBurst(R) Microarchitecture"; and addresses 1DBH-1DEH and 680H-68FH. + + @param ECX MSR_PENTIUM_4_LASTBRANCH_TOS (0x000001DA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_PENTIUM_4_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_PENTIUM_4_LASTBRANCH_TOS 0x000001DA + + +/** + 0, 1, 2. Unique. Last Branch Record n (R/W) One of four last branch record + registers on the last branch record stack. It contains pointers to the + source and destination instruction for one of the last four branches, + exceptions, or interrupts that the processor took. MSR_LASTBRANCH_0 through + MSR_LASTBRANCH_3 at 1DBH-1DEH are available only on family 0FH, models + 0H-02H. They have been replaced by the MSRs at 680H68FH and 6C0H-6CFH. See + Section 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording + for Processors based on Skylake Microarchitecture.". + + @param ECX MSR_PENTIUM_4_LASTBRANCH_n + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0); + AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0, Msr); + @endcode + @note MSR_PENTIUM_4_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. + MSR_PENTIUM_4_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. + MSR_PENTIUM_4_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. + MSR_PENTIUM_4_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_LASTBRANCH_0 0x000001DB +#define MSR_PENTIUM_4_LASTBRANCH_1 0x000001DC +#define MSR_PENTIUM_4_LASTBRANCH_2 0x000001DD +#define MSR_PENTIUM_4_LASTBRANCH_3 0x000001DE +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". + + @param ECX MSR_PENTIUM_4_BPU_COUNTERn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_COUNTER0); + AsmWriteMsr64 (MSR_PENTIUM_4_BPU_COUNTER0, Msr); + @endcode + @note MSR_PENTIUM_4_BPU_COUNTER0 is defined as MSR_BPU_COUNTER0 in SDM. + MSR_PENTIUM_4_BPU_COUNTER1 is defined as MSR_BPU_COUNTER1 in SDM. + MSR_PENTIUM_4_BPU_COUNTER2 is defined as MSR_BPU_COUNTER2 in SDM. + MSR_PENTIUM_4_BPU_COUNTER3 is defined as MSR_BPU_COUNTER3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_BPU_COUNTER0 0x00000300 +#define MSR_PENTIUM_4_BPU_COUNTER1 0x00000301 +#define MSR_PENTIUM_4_BPU_COUNTER2 0x00000302 +#define MSR_PENTIUM_4_BPU_COUNTER3 0x00000303 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". + + @param ECX MSR_PENTIUM_4_MS_COUNTERn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_COUNTER0); + AsmWriteMsr64 (MSR_PENTIUM_4_MS_COUNTER0, Msr); + @endcode + @note MSR_PENTIUM_4_MS_COUNTER0 is defined as MSR_MS_COUNTER0 in SDM. + MSR_PENTIUM_4_MS_COUNTER1 is defined as MSR_MS_COUNTER1 in SDM. + MSR_PENTIUM_4_MS_COUNTER2 is defined as MSR_MS_COUNTER2 in SDM. + MSR_PENTIUM_4_MS_COUNTER3 is defined as MSR_MS_COUNTER3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_MS_COUNTER0 0x00000304 +#define MSR_PENTIUM_4_MS_COUNTER1 0x00000305 +#define MSR_PENTIUM_4_MS_COUNTER2 0x00000306 +#define MSR_PENTIUM_4_MS_COUNTER3 0x00000307 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". + + @param ECX MSR_PENTIUM_4_FLAME_COUNTERn (0x00000308) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_COUNTER0); + AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_COUNTER0, Msr); + @endcode + @note MSR_PENTIUM_4_FLAME_COUNTER0 is defined as MSR_FLAME_COUNTER0 in SDM. + MSR_PENTIUM_4_FLAME_COUNTER1 is defined as MSR_FLAME_COUNTER1 in SDM. + MSR_PENTIUM_4_FLAME_COUNTER2 is defined as MSR_FLAME_COUNTER2 in SDM. + MSR_PENTIUM_4_FLAME_COUNTER3 is defined as MSR_FLAME_COUNTER3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_FLAME_COUNTER0 0x00000308 +#define MSR_PENTIUM_4_FLAME_COUNTER1 0x00000309 +#define MSR_PENTIUM_4_FLAME_COUNTER2 0x0000030A +#define MSR_PENTIUM_4_FLAME_COUNTER3 0x0000030B +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". + + @param ECX MSR_PENTIUM_4_IQ_COUNTERn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_COUNTER0); + AsmWriteMsr64 (MSR_PENTIUM_4_IQ_COUNTER0, Msr); + @endcode + @note MSR_PENTIUM_4_IQ_COUNTER0 is defined as MSR_IQ_COUNTER0 in SDM. + MSR_PENTIUM_4_IQ_COUNTER1 is defined as MSR_IQ_COUNTER1 in SDM. + MSR_PENTIUM_4_IQ_COUNTER2 is defined as MSR_IQ_COUNTER2 in SDM. + MSR_PENTIUM_4_IQ_COUNTER3 is defined as MSR_IQ_COUNTER3 in SDM. + MSR_PENTIUM_4_IQ_COUNTER4 is defined as MSR_IQ_COUNTER4 in SDM. + MSR_PENTIUM_4_IQ_COUNTER5 is defined as MSR_IQ_COUNTER5 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_IQ_COUNTER0 0x0000030C +#define MSR_PENTIUM_4_IQ_COUNTER1 0x0000030D +#define MSR_PENTIUM_4_IQ_COUNTER2 0x0000030E +#define MSR_PENTIUM_4_IQ_COUNTER3 0x0000030F +#define MSR_PENTIUM_4_IQ_COUNTER4 0x00000310 +#define MSR_PENTIUM_4_IQ_COUNTER5 0x00000311 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". + + @param ECX MSR_PENTIUM_4_BPU_CCCRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_CCCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_BPU_CCCR0, Msr); + @endcode + @note MSR_PENTIUM_4_BPU_CCCR0 is defined as MSR_BPU_CCCR0 in SDM. + MSR_PENTIUM_4_BPU_CCCR1 is defined as MSR_BPU_CCCR1 in SDM. + MSR_PENTIUM_4_BPU_CCCR2 is defined as MSR_BPU_CCCR2 in SDM. + MSR_PENTIUM_4_BPU_CCCR3 is defined as MSR_BPU_CCCR3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_BPU_CCCR0 0x00000360 +#define MSR_PENTIUM_4_BPU_CCCR1 0x00000361 +#define MSR_PENTIUM_4_BPU_CCCR2 0x00000362 +#define MSR_PENTIUM_4_BPU_CCCR3 0x00000363 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". + + @param ECX MSR_PENTIUM_4_MS_CCCRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_CCCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_MS_CCCR0, Msr); + @endcode + @note MSR_PENTIUM_4_MS_CCCR0 is defined as MSR_MS_CCCR0 in SDM. + MSR_PENTIUM_4_MS_CCCR1 is defined as MSR_MS_CCCR1 in SDM. + MSR_PENTIUM_4_MS_CCCR2 is defined as MSR_MS_CCCR2 in SDM. + MSR_PENTIUM_4_MS_CCCR3 is defined as MSR_MS_CCCR3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_MS_CCCR0 0x00000364 +#define MSR_PENTIUM_4_MS_CCCR1 0x00000365 +#define MSR_PENTIUM_4_MS_CCCR2 0x00000366 +#define MSR_PENTIUM_4_MS_CCCR3 0x00000367 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". + + @param ECX MSR_PENTIUM_4_FLAME_CCCRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_CCCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_CCCR0, Msr); + @endcode + @note MSR_PENTIUM_4_FLAME_CCCR0 is defined as MSR_FLAME_CCCR0 in SDM. + MSR_PENTIUM_4_FLAME_CCCR1 is defined as MSR_FLAME_CCCR1 in SDM. + MSR_PENTIUM_4_FLAME_CCCR2 is defined as MSR_FLAME_CCCR2 in SDM. + MSR_PENTIUM_4_FLAME_CCCR3 is defined as MSR_FLAME_CCCR3 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_FLAME_CCCR0 0x00000368 +#define MSR_PENTIUM_4_FLAME_CCCR1 0x00000369 +#define MSR_PENTIUM_4_FLAME_CCCR2 0x0000036A +#define MSR_PENTIUM_4_FLAME_CCCR3 0x0000036B +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". + + @param ECX MSR_PENTIUM_4_IQ_CCCRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_CCCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_IQ_CCCR0, Msr); + @endcode + @note MSR_PENTIUM_4_IQ_CCCR0 is defined as MSR_IQ_CCCR0 in SDM. + MSR_PENTIUM_4_IQ_CCCR1 is defined as MSR_IQ_CCCR1 in SDM. + MSR_PENTIUM_4_IQ_CCCR2 is defined as MSR_IQ_CCCR2 in SDM. + MSR_PENTIUM_4_IQ_CCCR3 is defined as MSR_IQ_CCCR3 in SDM. + MSR_PENTIUM_4_IQ_CCCR4 is defined as MSR_IQ_CCCR4 in SDM. + MSR_PENTIUM_4_IQ_CCCR5 is defined as MSR_IQ_CCCR5 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_IQ_CCCR0 0x0000036C +#define MSR_PENTIUM_4_IQ_CCCR1 0x0000036D +#define MSR_PENTIUM_4_IQ_CCCR2 0x0000036E +#define MSR_PENTIUM_4_IQ_CCCR3 0x0000036F +#define MSR_PENTIUM_4_IQ_CCCR4 0x00000370 +#define MSR_PENTIUM_4_IQ_CCCR5 0x00000371 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_BSU_ESCR0 (0x000003A0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BSU_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_BSU_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_BSU_ESCR0 is defined as MSR_BSU_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_BSU_ESCR0 0x000003A0 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_BSU_ESCR1 (0x000003A1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BSU_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_BSU_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_BSU_ESCR1 is defined as MSR_BSU_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_BSU_ESCR1 0x000003A1 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FSB_ESCR0 (0x000003A2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FSB_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_FSB_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_FSB_ESCR0 is defined as MSR_FSB_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_FSB_ESCR0 0x000003A2 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FSB_ESCR1 (0x000003A3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FSB_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_FSB_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_FSB_ESCR1 is defined as MSR_FSB_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_FSB_ESCR1 0x000003A3 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FIRM_ESCR0 (0x000003A4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FIRM_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_FIRM_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_FIRM_ESCR0 is defined as MSR_FIRM_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_FIRM_ESCR0 0x000003A4 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FIRM_ESCR1 (0x000003A5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FIRM_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_FIRM_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_FIRM_ESCR1 is defined as MSR_FIRM_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_FIRM_ESCR1 0x000003A5 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FLAME_ESCR0 (0x000003A6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_FLAME_ESCR0 is defined as MSR_FLAME_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_FLAME_ESCR0 0x000003A6 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_FLAME_ESCR1 (0x000003A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_FLAME_ESCR1 is defined as MSR_FLAME_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_FLAME_ESCR1 0x000003A7 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_DAC_ESCR0 (0x000003A8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_DAC_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_DAC_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_DAC_ESCR0 is defined as MSR_DAC_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_DAC_ESCR0 0x000003A8 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_DAC_ESCR1 (0x000003A9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_DAC_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_DAC_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_DAC_ESCR1 is defined as MSR_DAC_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_DAC_ESCR1 0x000003A9 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_MOB_ESCR0 (0x000003AA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MOB_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_MOB_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_MOB_ESCR0 is defined as MSR_MOB_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_MOB_ESCR0 0x000003AA + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_MOB_ESCR1 (0x000003AB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MOB_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_MOB_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_MOB_ESCR1 is defined as MSR_MOB_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_MOB_ESCR1 0x000003AB + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_PMH_ESCR0 (0x000003AC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_PMH_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_PMH_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_PMH_ESCR0 is defined as MSR_PMH_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_PMH_ESCR0 0x000003AC + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_PMH_ESCR1 (0x000003AD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_PMH_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_PMH_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_PMH_ESCR1 is defined as MSR_PMH_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_PMH_ESCR1 0x000003AD + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_SAAT_ESCR0 (0x000003AE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_SAAT_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_SAAT_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_SAAT_ESCR0 is defined as MSR_SAAT_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_SAAT_ESCR0 0x000003AE + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_SAAT_ESCR1 (0x000003AF) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_SAAT_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_SAAT_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_SAAT_ESCR1 is defined as MSR_SAAT_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_SAAT_ESCR1 0x000003AF + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_U2L_ESCR0 (0x000003B0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_U2L_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_U2L_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_U2L_ESCR0 is defined as MSR_U2L_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_U2L_ESCR0 0x000003B0 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_U2L_ESCR1 (0x000003B1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_U2L_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_U2L_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_U2L_ESCR1 is defined as MSR_U2L_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_U2L_ESCR1 0x000003B1 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_BPU_ESCR0 (0x000003B2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_BPU_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_BPU_ESCR0 is defined as MSR_BPU_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_BPU_ESCR0 0x000003B2 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_BPU_ESCR1 (0x000003B3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_BPU_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_BPU_ESCR1 is defined as MSR_BPU_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_BPU_ESCR1 0x000003B3 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_IS_ESCR0 (0x000003B4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IS_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_IS_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_IS_ESCR0 is defined as MSR_IS_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_IS_ESCR0 0x000003B4 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_IS_ESCR1 (0x000003B5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IS_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_IS_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_IS_ESCR1 is defined as MSR_IS_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_IS_ESCR1 0x000003B5 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_ITLB_ESCR0 (0x000003B6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_ITLB_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_ITLB_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_ITLB_ESCR0 is defined as MSR_ITLB_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_ITLB_ESCR0 0x000003B6 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_ITLB_ESCR1 (0x000003B7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_ITLB_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_ITLB_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_ITLB_ESCR1 is defined as MSR_ITLB_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_ITLB_ESCR1 0x000003B7 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_CRU_ESCR0 (0x000003B8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_CRU_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_CRU_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_CRU_ESCR0 is defined as MSR_CRU_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_CRU_ESCR0 0x000003B8 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_CRU_ESCR1 (0x000003B9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_CRU_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_CRU_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_CRU_ESCR1 is defined as MSR_CRU_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_CRU_ESCR1 0x000003B9 + + +/** + 0, 1, 2. Shared. See Section 18.15.1, "ESCR MSRs." This MSR is not available + on later processors. It is only available on processor family 0FH, models + 01H-02H. + + @param ECX MSR_PENTIUM_4_IQ_ESCR0 (0x000003BA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_IQ_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_IQ_ESCR0 is defined as MSR_IQ_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_IQ_ESCR0 0x000003BA + + +/** + 0, 1, 2. Shared. See Section 18.15.1, "ESCR MSRs." This MSR is not available + on later processors. It is only available on processor family 0FH, models + 01H-02H. + + @param ECX MSR_PENTIUM_4_IQ_ESCR1 (0x000003BB) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_IQ_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_IQ_ESCR1 is defined as MSR_IQ_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_IQ_ESCR1 0x000003BB + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_RAT_ESCR0 (0x000003BC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_RAT_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_RAT_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_RAT_ESCR0 is defined as MSR_RAT_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_RAT_ESCR0 0x000003BC + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_RAT_ESCR1 (0x000003BD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_RAT_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_RAT_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_RAT_ESCR1 is defined as MSR_RAT_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_RAT_ESCR1 0x000003BD + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_SSU_ESCR0 (0x000003BE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_SSU_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_SSU_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_SSU_ESCR0 is defined as MSR_SSU_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_SSU_ESCR0 0x000003BE + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_MS_ESCR0 (0x000003C0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_MS_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_MS_ESCR0 is defined as MSR_MS_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_MS_ESCR0 0x000003C0 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_MS_ESCR1 (0x000003C1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_MS_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_MS_ESCR1 is defined as MSR_MS_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_MS_ESCR1 0x000003C1 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_TBPU_ESCR0 (0x000003C2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_TBPU_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_TBPU_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_TBPU_ESCR0 is defined as MSR_TBPU_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_TBPU_ESCR0 0x000003C2 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_TBPU_ESCR1 (0x000003C3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_TBPU_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_TBPU_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_TBPU_ESCR1 is defined as MSR_TBPU_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_TBPU_ESCR1 0x000003C3 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_TC_ESCR0 (0x000003C4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_TC_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_TC_ESCR0 is defined as MSR_TC_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_TC_ESCR0 0x000003C4 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_TC_ESCR1 (0x000003C5) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_TC_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_TC_ESCR1 is defined as MSR_TC_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_TC_ESCR1 0x000003C5 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_IX_ESCR0 (0x000003C8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IX_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_IX_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_IX_ESCR0 is defined as MSR_IX_ESCR0 in SDM. +**/ +#define MSR_PENTIUM_4_IX_ESCR0 0x000003C8 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_IX_ESCR1 (0x000003C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IX_ESCR1); + AsmWriteMsr64 (MSR_PENTIUM_4_IX_ESCR1, Msr); + @endcode + @note MSR_PENTIUM_4_IX_ESCR1 is defined as MSR_IX_ESCR1 in SDM. +**/ +#define MSR_PENTIUM_4_IX_ESCR1 0x000003C9 + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_ALF_ESCRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_ALF_ESCR0); + AsmWriteMsr64 (MSR_PENTIUM_4_ALF_ESCR0, Msr); + @endcode + @note MSR_PENTIUM_4_ALF_ESCR0 is defined as MSR_ALF_ESCR0 in SDM. + MSR_PENTIUM_4_ALF_ESCR1 is defined as MSR_ALF_ESCR1 in SDM. + MSR_PENTIUM_4_CRU_ESCR2 is defined as MSR_CRU_ESCR2 in SDM. + MSR_PENTIUM_4_CRU_ESCR3 is defined as MSR_CRU_ESCR3 in SDM. + MSR_PENTIUM_4_CRU_ESCR4 is defined as MSR_CRU_ESCR4 in SDM. + MSR_PENTIUM_4_CRU_ESCR5 is defined as MSR_CRU_ESCR5 in SDM. + @{ +**/ +#define MSR_PENTIUM_4_ALF_ESCR0 0x000003CA +#define MSR_PENTIUM_4_ALF_ESCR1 0x000003CB +#define MSR_PENTIUM_4_CRU_ESCR2 0x000003CC +#define MSR_PENTIUM_4_CRU_ESCR3 0x000003CD +#define MSR_PENTIUM_4_CRU_ESCR4 0x000003E0 +#define MSR_PENTIUM_4_CRU_ESCR5 0x000003E1 +/// @} + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". + + @param ECX MSR_PENTIUM_4_TC_PRECISE_EVENT (0x000003F0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_PRECISE_EVENT); + AsmWriteMsr64 (MSR_PENTIUM_4_TC_PRECISE_EVENT, Msr); + @endcode + @note MSR_PENTIUM_4_TC_PRECISE_EVENT is defined as MSR_TC_PRECISE_EVENT in SDM. +**/ +#define MSR_PENTIUM_4_TC_PRECISE_EVENT 0x000003F0 + + +/** + 0, 1, 2, 3, 4, 6. Shared. Processor Event Based Sampling (PEBS) (R/W) + Controls the enabling of processor event sampling and replay tagging. + + @param ECX MSR_PENTIUM_4_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_4_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_PENTIUM_4_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_PEBS_ENABLE); + AsmWriteMsr64 (MSR_PENTIUM_4_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_PENTIUM_4_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_PENTIUM_4_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_PENTIUM_4_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 12:0] See Table 19-33. + /// + UINT32 EventNum:13; + UINT32 Reserved1:11; + /// + /// [Bit 24] UOP Tag Enables replay tagging when set. + /// + UINT32 UOP:1; + /// + /// [Bit 25] ENABLE_PEBS_MY_THR (R/W) Enables PEBS for the target logical + /// processor when set; disables PEBS when clear (default). See Section + /// 18.16.3, "IA32_PEBS_ENABLE MSR," for an explanation of the target + /// logical processor. This bit is called ENABLE_PEBS in IA-32 processors + /// that do not support Intel HyperThreading Technology. + /// + UINT32 ENABLE_PEBS_MY_THR:1; + /// + /// [Bit 26] ENABLE_PEBS_OTH_THR (R/W) Enables PEBS for the target logical + /// processor when set; disables PEBS when clear (default). See Section + /// 18.16.3, "IA32_PEBS_ENABLE MSR," for an explanation of the target + /// logical processor. This bit is reserved for IA-32 processors that do + /// not support Intel Hyper-Threading Technology. + /// + UINT32 ENABLE_PEBS_OTH_THR:1; + UINT32 Reserved2:5; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_4_PEBS_ENABLE_REGISTER; + + +/** + 0, 1, 2, 3, 4, 6. Shared. See Table 19-33. + + @param ECX MSR_PENTIUM_4_PEBS_MATRIX_VERT (0x000003F2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_PEBS_MATRIX_VERT); + AsmWriteMsr64 (MSR_PENTIUM_4_PEBS_MATRIX_VERT, Msr); + @endcode + @note MSR_PENTIUM_4_PEBS_MATRIX_VERT is defined as MSR_PEBS_MATRIX_VERT in SDM. +**/ +#define MSR_PENTIUM_4_PEBS_MATRIX_VERT 0x000003F2 + + +/** + 3, 4, 6. Unique. Last Branch Record n (R/W) One of 16 pairs of last branch + record registers on the last branch record stack (680H-68FH). This part of + the stack contains pointers to the source instruction for one of the last 16 + branches, exceptions, or interrupts taken by the processor. The MSRs at + 680H-68FH, 6C0H-6CfH are not available in processor releases before family + 0FH, model 03H. These MSRs replace MSRs previously located at + 1DBH-1DEH.which performed the same function for early releases. See Section + 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording for + Processors based on Skylake Microarchitecture.". + + @param ECX MSR_PENTIUM_4_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. + @{ +**/ +#define MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP 0x00000680 +#define MSR_PENTIUM_4_LASTBRANCH_1_FROM_IP 0x00000681 +#define MSR_PENTIUM_4_LASTBRANCH_2_FROM_IP 0x00000682 +#define MSR_PENTIUM_4_LASTBRANCH_3_FROM_IP 0x00000683 +#define MSR_PENTIUM_4_LASTBRANCH_4_FROM_IP 0x00000684 +#define MSR_PENTIUM_4_LASTBRANCH_5_FROM_IP 0x00000685 +#define MSR_PENTIUM_4_LASTBRANCH_6_FROM_IP 0x00000686 +#define MSR_PENTIUM_4_LASTBRANCH_7_FROM_IP 0x00000687 +#define MSR_PENTIUM_4_LASTBRANCH_8_FROM_IP 0x00000688 +#define MSR_PENTIUM_4_LASTBRANCH_9_FROM_IP 0x00000689 +#define MSR_PENTIUM_4_LASTBRANCH_10_FROM_IP 0x0000068A +#define MSR_PENTIUM_4_LASTBRANCH_11_FROM_IP 0x0000068B +#define MSR_PENTIUM_4_LASTBRANCH_12_FROM_IP 0x0000068C +#define MSR_PENTIUM_4_LASTBRANCH_13_FROM_IP 0x0000068D +#define MSR_PENTIUM_4_LASTBRANCH_14_FROM_IP 0x0000068E +#define MSR_PENTIUM_4_LASTBRANCH_15_FROM_IP 0x0000068F +/// @} + + +/** + 3, 4, 6. Unique. Last Branch Record n (R/W) One of 16 pairs of last branch + record registers on the last branch record stack (6C0H-6CFH). This part of + the stack contains pointers to the destination instruction for one of the + last 16 branches, exceptions, or interrupts that the processor took. See + Section 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording + for Processors based on Skylake Microarchitecture.". + + @param ECX MSR_PENTIUM_4_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_PENTIUM_4_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. + MSR_PENTIUM_4_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. + @{ +**/ +#define MSR_PENTIUM_4_LASTBRANCH_0_TO_IP 0x000006C0 +#define MSR_PENTIUM_4_LASTBRANCH_1_TO_IP 0x000006C1 +#define MSR_PENTIUM_4_LASTBRANCH_2_TO_IP 0x000006C2 +#define MSR_PENTIUM_4_LASTBRANCH_3_TO_IP 0x000006C3 +#define MSR_PENTIUM_4_LASTBRANCH_4_TO_IP 0x000006C4 +#define MSR_PENTIUM_4_LASTBRANCH_5_TO_IP 0x000006C5 +#define MSR_PENTIUM_4_LASTBRANCH_6_TO_IP 0x000006C6 +#define MSR_PENTIUM_4_LASTBRANCH_7_TO_IP 0x000006C7 +#define MSR_PENTIUM_4_LASTBRANCH_8_TO_IP 0x000006C8 +#define MSR_PENTIUM_4_LASTBRANCH_9_TO_IP 0x000006C9 +#define MSR_PENTIUM_4_LASTBRANCH_10_TO_IP 0x000006CA +#define MSR_PENTIUM_4_LASTBRANCH_11_TO_IP 0x000006CB +#define MSR_PENTIUM_4_LASTBRANCH_12_TO_IP 0x000006CC +#define MSR_PENTIUM_4_LASTBRANCH_13_TO_IP 0x000006CD +#define MSR_PENTIUM_4_LASTBRANCH_14_TO_IP 0x000006CE +#define MSR_PENTIUM_4_LASTBRANCH_15_TO_IP 0x000006CF +/// @} + + +/** + 3, 4. Shared. IFSB BUSQ Event Control and Counter Register (R/W) See + Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP + with Up to 8-MByte L3 Cache.". + + @param ECX MSR_PENTIUM_4_IFSB_BUSQ0 (0x000107CC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_BUSQ0); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_BUSQ0, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_BUSQ0 is defined as MSR_IFSB_BUSQ0 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_BUSQ0 0x000107CC + + +/** + 3, 4. Shared. IFSB BUSQ Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_IFSB_BUSQ1 (0x000107CD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_BUSQ1); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_BUSQ1, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_BUSQ1 is defined as MSR_IFSB_BUSQ1 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_BUSQ1 0x000107CD + + +/** + 3, 4. Shared. IFSB SNPQ Event Control and Counter Register (R/W) See + Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP + with Up to 8-MByte L3 Cache.". + + @param ECX MSR_PENTIUM_4_IFSB_SNPQ0 (0x000107CE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_SNPQ0); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_SNPQ0, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_SNPQ0 is defined as MSR_IFSB_SNPQ0 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_SNPQ0 0x000107CE + + +/** + 3, 4. Shared. IFSB SNPQ Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_IFSB_SNPQ1 (0x000107CF) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_SNPQ1); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_SNPQ1, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_SNPQ1 is defined as MSR_IFSB_SNPQ1 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_SNPQ1 0x000107CF + + +/** + 3, 4. Shared. EFSB DRDY Event Control and Counter Register (R/W) See + Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP + with Up to 8-MByte L3 Cache" for details. + + @param ECX MSR_PENTIUM_4_EFSB_DRDY0 (0x000107D0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EFSB_DRDY0); + AsmWriteMsr64 (MSR_PENTIUM_4_EFSB_DRDY0, Msr); + @endcode + @note MSR_PENTIUM_4_EFSB_DRDY0 is defined as MSR_EFSB_DRDY0 in SDM. +**/ +#define MSR_PENTIUM_4_EFSB_DRDY0 0x000107D0 + + +/** + 3, 4. Shared. EFSB DRDY Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EFSB_DRDY1 (0x000107D1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EFSB_DRDY1); + AsmWriteMsr64 (MSR_PENTIUM_4_EFSB_DRDY1, Msr); + @endcode + @note MSR_PENTIUM_4_EFSB_DRDY1 is defined as MSR_EFSB_DRDY1 in SDM. +**/ +#define MSR_PENTIUM_4_EFSB_DRDY1 0x000107D1 + + +/** + 3, 4. Shared. IFSB Latency Event Control Register (R/W) See Section 18.21, + "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte + L3 Cache" for details. + + @param ECX MSR_PENTIUM_4_IFSB_CTL6 (0x000107D2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_CTL6); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_CTL6, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_CTL6 is defined as MSR_IFSB_CTL6 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_CTL6 0x000107D2 + + +/** + 3, 4. Shared. IFSB Latency Event Counter Register (R/W) See Section 18.21, + "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte + L3 Cache.". + + @param ECX MSR_PENTIUM_4_IFSB_CNTR7 (0x000107D3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_CNTR7); + AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_CNTR7, Msr); + @endcode + @note MSR_PENTIUM_4_IFSB_CNTR7 is defined as MSR_IFSB_CNTR7 in SDM. +**/ +#define MSR_PENTIUM_4_IFSB_CNTR7 0x000107D3 + + +/** + 6. Shared. GBUSQ Event Control and Counter Register (R/W) See Section 18.21, + "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte + L3 Cache.". + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL0 (0x000107CC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL0); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL0, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL0 is defined as MSR_EMON_L3_CTR_CTL0 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL0 0x000107CC + + +/** + 6. Shared. GBUSQ Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL1 (0x000107CD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL1); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL1, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL1 is defined as MSR_EMON_L3_CTR_CTL1 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL1 0x000107CD + + +/** + 6. Shared. GSNPQ Event Control and Counter Register (R/W) See Section + 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to + 8-MByte L3 Cache.". + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL2 (0x000107CE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL2); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL2, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL2 is defined as MSR_EMON_L3_CTR_CTL2 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL2 0x000107CE + + +/** + 6. Shared. GSNPQ Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL3 (0x000107CF) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL3); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL3, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL3 is defined as MSR_EMON_L3_CTR_CTL3 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL3 0x000107CF + + +/** + 6. Shared. FSB Event Control and Counter Register (R/W) See Section 18.21, + "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte + L3 Cache" for details. + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL4 (0x000107D0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL4); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL4, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL4 is defined as MSR_EMON_L3_CTR_CTL4 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL4 0x000107D0 + + +/** + 6. Shared. FSB Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL5 (0x000107D1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL5); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL5, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL5 is defined as MSR_EMON_L3_CTR_CTL5 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL5 0x000107D1 + + +/** + 6. Shared. FSB Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL6 (0x000107D2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL6); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL6, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL6 is defined as MSR_EMON_L3_CTR_CTL6 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL6 0x000107D2 + + +/** + 6. Shared. FSB Event Control and Counter Register (R/W). + + @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL7 (0x000107D3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL7); + AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL7, Msr); + @endcode + @note MSR_PENTIUM_4_EMON_L3_CTR_CTL7 is defined as MSR_EMON_L3_CTR_CTL7 in SDM. +**/ +#define MSR_PENTIUM_4_EMON_L3_CTR_CTL7 0x000107D3 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h new file mode 100644 index 0000000000..70d54c81ee --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h @@ -0,0 +1,684 @@ +/** @file + MSR Definitions for Pentium M Processors. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.20. + +**/ + +#ifndef __PENTIUM_M_MSR_H__ +#define __PENTIUM_M_MSR_H__ + +#include + +/** + Is Pentium M Processors? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_PENTIUM_M_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x0D \ + ) \ + ) + +/** + See Section 35.22, "MSRs in Pentium Processors.". + + @param ECX MSR_PENTIUM_M_P5_MC_ADDR (0x00000000) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_P5_MC_ADDR); + AsmWriteMsr64 (MSR_PENTIUM_M_P5_MC_ADDR, Msr); + @endcode + @note MSR_PENTIUM_M_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. +**/ +#define MSR_PENTIUM_M_P5_MC_ADDR 0x00000000 + + +/** + See Section 35.22, "MSRs in Pentium Processors.". + + @param ECX MSR_PENTIUM_M_P5_MC_TYPE (0x00000001) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_P5_MC_TYPE); + AsmWriteMsr64 (MSR_PENTIUM_M_P5_MC_TYPE, Msr); + @endcode + @note MSR_PENTIUM_M_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. +**/ +#define MSR_PENTIUM_M_P5_MC_TYPE 0x00000001 + + +/** + Processor Hard Power-On Configuration (R/W) Enables and disables processor + features. (R) Indicates current processor configuration. + + @param ECX MSR_PENTIUM_M_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_PENTIUM_M_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_PENTIUM_M_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. +**/ +#define MSR_PENTIUM_M_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_PENTIUM_M_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] Data Error Checking Enable (R) 0 = Disabled Always 0 on the + /// Pentium M processor. + /// + UINT32 DataErrorCheckingEnable:1; + /// + /// [Bit 2] Response Error Checking Enable (R) 0 = Disabled Always 0 on + /// the Pentium M processor. + /// + UINT32 ResponseErrorCheckingEnable:1; + /// + /// [Bit 3] MCERR# Drive Enable (R) 0 = Disabled Always 0 on the Pentium + /// M processor. + /// + UINT32 MCERR_DriveEnable:1; + /// + /// [Bit 4] Address Parity Enable (R) 0 = Disabled Always 0 on the Pentium + /// M processor. + /// + UINT32 AddressParityEnable:1; + UINT32 Reserved2:2; + /// + /// [Bit 7] BINIT# Driver Enable (R) 1 = Enabled; 0 = Disabled Always 0 on + /// the Pentium M processor. + /// + UINT32 BINIT_DriverEnable:1; + /// + /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 OutputTriStateEnable:1; + /// + /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. + /// + UINT32 ExecuteBIST:1; + /// + /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled + /// Always 0 on the Pentium M processor. + /// + UINT32 MCERR_ObservationEnabled:1; + UINT32 Reserved3:1; + /// + /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled + /// Always 0 on the Pentium M processor. + /// + UINT32 BINIT_ObservationEnabled:1; + UINT32 Reserved4:1; + /// + /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes + /// Always 0 on the Pentium M processor. + /// + UINT32 ResetVector:1; + UINT32 Reserved5:1; + /// + /// [Bits 17:16] APIC Cluster ID (R/O) Always 00B on the Pentium M + /// processor. + /// + UINT32 APICClusterID:2; + /// + /// [Bit 18] System Bus Frequency (R/O) 1. = 100 MHz 2. = Reserved Always + /// 0 on the Pentium M processor. + /// + UINT32 SystemBusFrequency:1; + UINT32 Reserved6:1; + /// + /// [Bits 21:20] Symmetric Arbitration ID (R/O) Always 00B on the Pentium + /// M processor. + /// + UINT32 SymmetricArbitrationID:2; + /// + /// [Bits 26:22] Clock Frequency Ratio (R/O). + /// + UINT32 ClockFrequencyRatio:5; + UINT32 Reserved7:5; + UINT32 Reserved8:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER; + + +/** + Last Branch Record n (R/W) One of 8 last branch record registers on the last + branch record stack: bits 31-0 hold the 'from' address and bits 63-32 hold + the to address. See also: - Last Branch Record Stack TOS at 1C9H - Section + 17.13, "Last Branch, Interrupt, and Exception Recording (Pentium M + Processors)". + + @param ECX MSR_PENTIUM_M_LASTBRANCH_n + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_LASTBRANCH_0); + AsmWriteMsr64 (MSR_PENTIUM_M_LASTBRANCH_0, Msr); + @endcode + @note MSR_PENTIUM_M_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. + MSR_PENTIUM_M_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. + MSR_PENTIUM_M_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. + MSR_PENTIUM_M_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. + MSR_PENTIUM_M_LASTBRANCH_4 is defined as MSR_LASTBRANCH_4 in SDM. + MSR_PENTIUM_M_LASTBRANCH_5 is defined as MSR_LASTBRANCH_5 in SDM. + MSR_PENTIUM_M_LASTBRANCH_6 is defined as MSR_LASTBRANCH_6 in SDM. + MSR_PENTIUM_M_LASTBRANCH_7 is defined as MSR_LASTBRANCH_7 in SDM. + @{ +**/ +#define MSR_PENTIUM_M_LASTBRANCH_0 0x00000040 +#define MSR_PENTIUM_M_LASTBRANCH_1 0x00000041 +#define MSR_PENTIUM_M_LASTBRANCH_2 0x00000042 +#define MSR_PENTIUM_M_LASTBRANCH_3 0x00000043 +#define MSR_PENTIUM_M_LASTBRANCH_4 0x00000044 +#define MSR_PENTIUM_M_LASTBRANCH_5 0x00000045 +#define MSR_PENTIUM_M_LASTBRANCH_6 0x00000046 +#define MSR_PENTIUM_M_LASTBRANCH_7 0x00000047 +/// @} + + +/** + Reserved. + + @param ECX MSR_PENTIUM_M_BBL_CR_CTL (0x00000119) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_BBL_CR_CTL); + AsmWriteMsr64 (MSR_PENTIUM_M_BBL_CR_CTL, Msr); + @endcode + @note MSR_PENTIUM_M_BBL_CR_CTL is defined as MSR_BBL_CR_CTL in SDM. +**/ +#define MSR_PENTIUM_M_BBL_CR_CTL 0x00000119 + + +/** + + + @param ECX MSR_PENTIUM_M_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_PENTIUM_M_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_PENTIUM_M_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. +**/ +#define MSR_PENTIUM_M_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_PENTIUM_M_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = + /// Indicates if the L2 is hardware-disabled. + /// + UINT32 L2HardwareEnabled:1; + UINT32 Reserved1:4; + /// + /// [Bit 5] ECC Check Enable (RO) This bit enables ECC checking on the + /// cache data bus. ECC is always generated on write cycles. 1. = Disabled + /// (default) 2. = Enabled For the Pentium M processor, ECC checking on + /// the cache data bus is always enabled. + /// + UINT32 ECCCheckEnable:1; + UINT32 Reserved2:2; + /// + /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = + /// Disabled (default) Until this bit is set the processor will not + /// respond to the WBINVD instruction or the assertion of the FLUSH# input. + /// + UINT32 L2Enabled:1; + UINT32 Reserved3:14; + /// + /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. + /// + UINT32 L2NotPresent:1; + UINT32 Reserved4:8; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER; + + +/** + + + @param ECX MSR_PENTIUM_M_THERM2_CTL (0x0000019D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_THERM2_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_THERM2_CTL_REGISTER. + + Example usage + @code + MSR_PENTIUM_M_THERM2_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_THERM2_CTL); + AsmWriteMsr64 (MSR_PENTIUM_M_THERM2_CTL, Msr.Uint64); + @endcode + @note MSR_PENTIUM_M_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. +**/ +#define MSR_PENTIUM_M_THERM2_CTL 0x0000019D + +/** + MSR information returned for MSR index #MSR_PENTIUM_M_THERM2_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = + /// Thermal Monitor 1 (thermally-initiated on-die modulation of the + /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated + /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is + /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 will be enabled. + /// + UINT32 TM_SELECT:1; + UINT32 Reserved2:15; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_M_THERM2_CTL_REGISTER; + + +/** + Enable Miscellaneous Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_PENTIUM_M_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_PENTIUM_M_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_PENTIUM_M_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_PENTIUM_M_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_PENTIUM_M_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:3; + /// + /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) 1 = Setting + /// this bit enables the thermal control circuit (TCC) portion of the + /// Intel Thermal Monitor feature. This allows processor clocks to be + /// automatically modulated based on the processor's thermal sensor + /// operation. 0 = Disabled (default). The automatic thermal control + /// circuit enable bit determines if the thermal control circuit (TCC) + /// will be activated when the processor's internal thermal sensor + /// determines the processor is about to exceed its maximum operating + /// temperature. When the TCC is activated and TM1 is enabled, the + /// processors clocks will be forced to a 50% duty cycle. BIOS must enable + /// this feature. The bit should not be confused with the on-demand + /// thermal control circuit enable bit. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Performance Monitoring Available (R) 1 = Performance + /// monitoring enabled 0 = Performance monitoring disabled. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:2; + /// + /// [Bit 10] FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by the + /// processor to indicate a pending break event within the processor 0 = + /// Indicates compatible FERR# signaling behavior This bit must be set to + /// 1 to support XAPIC interrupt model usage. + /// **Branch Trace Storage Unavailable (RO)** 1 = Processor doesn't + /// support branch trace storage (BTS) 0 = BTS is supported + /// + UINT32 FERR:1; + /// + /// [Bit 11] Branch Trace Storage Unavailable (RO) + /// 1 = Processor doesn't support branch trace storage (BTS) + /// 0 = BTS is supported + /// + UINT32 BTS:1; + /// + /// [Bit 12] Processor Event Based Sampling Unavailable (RO) 1 = + /// Processor does not support processor event based sampling (PEBS); 0 = + /// PEBS is supported. The Pentium M processor does not support PEBS. + /// + UINT32 PEBS:1; + UINT32 Reserved5:3; + /// + /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W) 1 = + /// Enhanced Intel SpeedStep Technology enabled. On the Pentium M + /// processor, this bit may be configured to be read-only. + /// + UINT32 EIST:1; + UINT32 Reserved6:6; + /// + /// [Bit 23] xTPR Message Disable (R/W) When set to 1, xTPR messages are + /// disabled. xTPR messages are optional messages that allow the processor + /// to inform the chipset of its priority. The default is processor + /// specific. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER; + + +/** + Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) that points + to the MSR containing the most recent branch record. See also: - + MSR_LASTBRANCH_0_FROM_IP (at 40H) - Section 17.13, "Last Branch, Interrupt, + and Exception Recording (Pentium M Processors)". + + @param ECX MSR_PENTIUM_M_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_PENTIUM_M_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_PENTIUM_M_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_PENTIUM_M_LASTBRANCH_TOS 0x000001C9 + + +/** + Debug Control (R/W) Controls how several debug features are used. Bit + definitions are discussed in the referenced section. See Section 17.13, + "Last Branch, Interrupt, and Exception Recording (Pentium M Processors).". + + @param ECX MSR_PENTIUM_M_DEBUGCTLB (0x000001D9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_DEBUGCTLB); + AsmWriteMsr64 (MSR_PENTIUM_M_DEBUGCTLB, Msr); + @endcode + @note MSR_PENTIUM_M_DEBUGCTLB is defined as MSR_DEBUGCTLB in SDM. +**/ +#define MSR_PENTIUM_M_DEBUGCTLB 0x000001D9 + + +/** + Last Exception Record To Linear IP (R) This area contains a pointer to the + target of the last branch instruction that the processor executed prior to + the last exception that was generated or the last interrupt that was + handled. See Section 17.13, "Last Branch, Interrupt, and Exception Recording + (Pentium M Processors)" and Section 17.14.2, "Last Branch and Last Exception + MSRs.". + + @param ECX MSR_PENTIUM_M_LER_TO_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_LER_TO_LIP); + @endcode + @note MSR_PENTIUM_M_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_PENTIUM_M_LER_TO_LIP 0x000001DD + + +/** + Last Exception Record From Linear IP (R) Contains a pointer to the last + branch instruction that the processor executed prior to the last exception + that was generated or the last interrupt that was handled. See Section + 17.13, "Last Branch, Interrupt, and Exception Recording (Pentium M + Processors)" and Section 17.14.2, "Last Branch and Last Exception MSRs.". + + @param ECX MSR_PENTIUM_M_LER_FROM_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_LER_FROM_LIP); + @endcode + @note MSR_PENTIUM_M_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_PENTIUM_M_LER_FROM_LIP 0x000001DE + + +/** + See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". + + @param ECX MSR_PENTIUM_M_MC4_CTL (0x0000040C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_CTL); + AsmWriteMsr64 (MSR_PENTIUM_M_MC4_CTL, Msr); + @endcode + @note MSR_PENTIUM_M_MC4_CTL is defined as MSR_MC4_CTL in SDM. +**/ +#define MSR_PENTIUM_M_MC4_CTL 0x0000040C + + +/** + See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". + + @param ECX MSR_PENTIUM_M_MC4_STATUS (0x0000040D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_STATUS); + AsmWriteMsr64 (MSR_PENTIUM_M_MC4_STATUS, Msr); + @endcode + @note MSR_PENTIUM_M_MC4_STATUS is defined as MSR_MC4_STATUS in SDM. +**/ +#define MSR_PENTIUM_M_MC4_STATUS 0x0000040D + + +/** + See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC4_ADDR register is + either not implemented or contains no address if the ADDRV flag in the + MSR_MC4_STATUS register is clear. When not implemented in the processor, all + reads and writes to this MSR will cause a general-protection exception. + + @param ECX MSR_PENTIUM_M_MC4_ADDR (0x0000040E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_ADDR); + AsmWriteMsr64 (MSR_PENTIUM_M_MC4_ADDR, Msr); + @endcode + @note MSR_PENTIUM_M_MC4_ADDR is defined as MSR_MC4_ADDR in SDM. +**/ +#define MSR_PENTIUM_M_MC4_ADDR 0x0000040E + + +/** + See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". + + @param ECX MSR_PENTIUM_M_MC3_CTL (0x00000410) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_CTL); + AsmWriteMsr64 (MSR_PENTIUM_M_MC3_CTL, Msr); + @endcode + @note MSR_PENTIUM_M_MC3_CTL is defined as MSR_MC3_CTL in SDM. +**/ +#define MSR_PENTIUM_M_MC3_CTL 0x00000410 + + +/** + See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". + + @param ECX MSR_PENTIUM_M_MC3_STATUS (0x00000411) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_STATUS); + AsmWriteMsr64 (MSR_PENTIUM_M_MC3_STATUS, Msr); + @endcode + @note MSR_PENTIUM_M_MC3_STATUS is defined as MSR_MC3_STATUS in SDM. +**/ +#define MSR_PENTIUM_M_MC3_STATUS 0x00000411 + + +/** + See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC3_ADDR register is + either not implemented or contains no address if the ADDRV flag in the + MSR_MC3_STATUS register is clear. When not implemented in the processor, all + reads and writes to this MSR will cause a general-protection exception. + + @param ECX MSR_PENTIUM_M_MC3_ADDR (0x00000412) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_ADDR); + AsmWriteMsr64 (MSR_PENTIUM_M_MC3_ADDR, Msr); + @endcode + @note MSR_PENTIUM_M_MC3_ADDR is defined as MSR_MC3_ADDR in SDM. +**/ +#define MSR_PENTIUM_M_MC3_ADDR 0x00000412 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h new file mode 100644 index 0000000000..9b2578bac8 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h @@ -0,0 +1,145 @@ +/** @file + MSR Definitions for Pentium Processors. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.22. + +**/ + +#ifndef __PENTIUM_MSR_H__ +#define __PENTIUM_MSR_H__ + +#include + +/** + Is Pentium Processors? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_PENTIUM_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x05 && \ + ( \ + DisplayModel == 0x01 || \ + DisplayModel == 0x02 || \ + DisplayModel == 0x04 \ + ) \ + ) + +/** + See Section 15.10.2, "Pentium Processor Machine-Check Exception Handling.". + + @param ECX MSR_PENTIUM_P5_MC_ADDR (0x00000000) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_P5_MC_ADDR); + AsmWriteMsr64 (MSR_PENTIUM_P5_MC_ADDR, Msr); + @endcode + @note MSR_PENTIUM_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. +**/ +#define MSR_PENTIUM_P5_MC_ADDR 0x00000000 + + +/** + See Section 15.10.2, "Pentium Processor Machine-Check Exception Handling.". + + @param ECX MSR_PENTIUM_P5_MC_TYPE (0x00000001) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_P5_MC_TYPE); + AsmWriteMsr64 (MSR_PENTIUM_P5_MC_TYPE, Msr); + @endcode + @note MSR_PENTIUM_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. +**/ +#define MSR_PENTIUM_P5_MC_TYPE 0x00000001 + + +/** + See Section 17.15, "Time-Stamp Counter.". + + @param ECX MSR_PENTIUM_TSC (0x00000010) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_TSC); + AsmWriteMsr64 (MSR_PENTIUM_TSC, Msr); + @endcode + @note MSR_PENTIUM_TSC is defined as TSC in SDM. +**/ +#define MSR_PENTIUM_TSC 0x00000010 + + +/** + See Section 18.24.1, "Control and Event Select Register (CESR).". + + @param ECX MSR_PENTIUM_CESR (0x00000011) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_CESR); + AsmWriteMsr64 (MSR_PENTIUM_CESR, Msr); + @endcode + @note MSR_PENTIUM_CESR is defined as CESR in SDM. +**/ +#define MSR_PENTIUM_CESR 0x00000011 + + +/** + Section 18.24.3, "Events Counted.". + + @param ECX MSR_PENTIUM_CTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_PENTIUM_CTR0); + AsmWriteMsr64 (MSR_PENTIUM_CTR0, Msr); + @endcode + @note MSR_PENTIUM_CTR0 is defined as CTR0 in SDM. + MSR_PENTIUM_CTR1 is defined as CTR1 in SDM. + @{ +**/ +#define MSR_PENTIUM_CTR0 0x00000012 +#define MSR_PENTIUM_CTR1 0x00000013 +/// @} + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h new file mode 100644 index 0000000000..c8a0b971d3 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h @@ -0,0 +1,4796 @@ +/** @file + MSR Definitions for Intel processors based on the Sandy Bridge microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.9. + +**/ + +#ifndef __SANDY_BRIDGE_MSR_H__ +#define __SANDY_BRIDGE_MSR_H__ + +#include + +/** + Is Intel processors based on the Sandy Bridge microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_SANDY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x2A || \ + DisplayModel == 0x2D \ + ) \ + ) + +/** + Thread. SMI Counter (R/O). + + @param ECX MSR_SANDY_BRIDGE_SMI_COUNT (0x00000034) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_SMI_COUNT); + @endcode + @note MSR_SANDY_BRIDGE_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. +**/ +#define MSR_SANDY_BRIDGE_SMI_COUNT 0x00000034 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_SMI_COUNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] SMI Count (R/O) Count SMIs. + /// + UINT32 SMICount:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER; + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_SANDY_BRIDGE_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PLATFORM_INFO); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_SANDY_BRIDGE_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + UINT32 Reserved3:2; + UINT32 Reserved4:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved5:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. See http://biosbits.org. + + @param ECX MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power). for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0/C1 (no package C-sate support) 001b: C2 010b: C6 no retention 011b: + /// C6 retention 100b: C7 101b: C7s 111: No package C-state limit. Note: + /// This field cannot be used to limit package C-state to C3. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map + /// IO_read instructions sent to IO register specified by + /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register + /// until next reset. + /// + UINT32 CFGLock:1; + UINT32 Reserved3:9; + /// + /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C6/C7 requests to C3 based on uncore + /// auto-demote information. + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor + /// will conditionally demote C3/C6/C7 requests to C1 based on uncore + /// auto-demote information. + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 undemotion (R/W) When set, enables undemotion from + /// demoted C3. + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 undemotion (R/W) When set, enables undemotion from + /// demoted C1. + /// + UINT32 C1Undemotion:1; + UINT32 Reserved4:3; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Core. Power Management IO Redirection in C-state (R/W) See + http://biosbits.org. + + @param ECX MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE (0x000000E4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. +**/ +#define MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE 0x000000E4 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address + /// visible to software for IO redirection. If IO MWAIT Redirection is + /// enabled, reads to this address will be consumed by the power + /// management logic and decoded to MWAIT instructions. When IO port + /// address redirection is enabled, this is the IO port address reported + /// to the OS/software. + /// + UINT32 Lvl2Base:16; + /// + /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the + /// maximum C-State code name to be included when IO read to MWAIT + /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 000b - C3 + /// is the max C-State to include 001b - C6 is the max C-State to include + /// 010b - C7 is the max C-State to include. + /// + UINT32 CStateRange:3; + UINT32 Reserved1:13; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER; + + +/** + Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP + handler to handle unsuccessful read of this MSR. + + @param ECX MSR_SANDY_BRIDGE_FEATURE_CONFIG (0x0000013C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. +**/ +#define MSR_SANDY_BRIDGE_FEATURE_CONFIG 0x0000013C + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this + /// MSR, the configuration of AES instruction set availability is as + /// follows: 11b: AES instructions are not available until next RESET. + /// otherwise, AES instructions are available. Note, AES instruction set + /// is not available if read is unsuccessful. If the configuration is not + /// 01b, AES instruction can be mis-configured if a privileged agent + /// unintentionally writes 11b. + /// + UINT32 AESConfiguration:2; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER; + + +/** + Core. See Table 35-2; If CPUID.0AH:EAX[15:8] = 8. + + @param ECX MSR_SANDY_BRIDGE_IA32_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4, Msr); + @endcode + @note MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4 is defined as IA32_PERFEVTSEL4 in SDM. + MSR_SANDY_BRIDGE_IA32_PERFEVTSEL5 is defined as IA32_PERFEVTSEL5 in SDM. + MSR_SANDY_BRIDGE_IA32_PERFEVTSEL6 is defined as IA32_PERFEVTSEL6 in SDM. + MSR_SANDY_BRIDGE_IA32_PERFEVTSEL7 is defined as IA32_PERFEVTSEL7 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4 0x0000018A +#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL5 0x0000018B +#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL6 0x0000018C +#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL7 0x0000018D +/// @} + + +/** + Package. + + @param ECX MSR_SANDY_BRIDGE_PERF_STATUS (0x00000198) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PERF_STATUS); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PERF_STATUS, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_PERF_STATUS 0x00000198 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PERF_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + /// + /// [Bits 47:32] Core Voltage (R/O) P-state core voltage can be computed + /// by MSR_PERF_STATUS[37:32] * (float) 1/(2^13). + /// + UINT32 CoreVoltage:16; + UINT32 Reserved2:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER; + + +/** + Thread. Clock Modulation (R/W) See Table 35-2 IA32_CLOCK_MODULATION MSR was + originally named IA32_THERM_CONTROL MSR. + + @param ECX MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION (0x0000019A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION is defined as IA32_CLOCK_MODULATION in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION 0x0000019A + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] On demand Clock Modulation Duty Cycle (R/W) In 6.25% + /// increment. + /// + UINT32 OnDemandClockModulationDutyCycle:4; + /// + /// [Bit 4] On demand Clock Modulation Enable (R/W). + /// + UINT32 OnDemandClockModulationEnable:1; + UINT32 Reserved1:27; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_SANDY_BRIDGE_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:6; + /// + /// [Bit 7] Thread. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved2:3; + /// + /// [Bit 11] Thread. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Thread. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + UINT32 Reserved3:3; + /// + /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved4:1; + /// + /// [Bit 18] Thread. ENABLE MONITOR FSM. (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved5:3; + /// + /// [Bit 22] Thread. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Thread. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved6:8; + UINT32 Reserved7:2; + /// + /// [Bit 34] Thread. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved8:3; + /// + /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors + /// that support Intel Turbo Boost Technology, the turbo mode feature is + /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: + /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: + /// EAX[1] reports the processor's support of turbo mode is enabled. Note: + /// the power-on default value is used by BIOS to detect hardware support + /// of turbo mode. If power-on default value is 1, turbo mode is available + /// in the processor. If power-on default value is 0, turbo mode is not + /// available. + /// + UINT32 TurboModeDisable:1; + UINT32 Reserved9:25; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER; + + +/** + Unique. + + @param ECX MSR_SANDY_BRIDGE_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_SANDY_BRIDGE_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (R) The minimum temperature at which + /// PROCHOT# will be asserted. The value is degree C. + /// + UINT32 TemperatureTarget:8; + UINT32 Reserved2:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER; + + +/** + Miscellaneous Feature Control (R/W). + + @param ECX MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL (0x000001A4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. +**/ +#define MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL 0x000001A4 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the + /// L2 hardware prefetcher, which fetches additional lines of code or data + /// into the L2 cache. + /// + UINT32 L2HardwarePrefetcherDisable:1; + /// + /// [Bit 1] Core. L2 Adjacent Cache Line Prefetcher Disable (R/W) If 1, + /// disables the adjacent cache line prefetcher, which fetches the cache + /// line that comprises a cache line pair (128 bytes). + /// + UINT32 L2AdjacentCacheLinePrefetcherDisable:1; + /// + /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables + /// the L1 data cache prefetcher, which fetches the next cache line into + /// L1 data cache. + /// + UINT32 DCUHardwarePrefetcherDisable:1; + /// + /// [Bit 3] Core. DCU IP Prefetcher Disable (R/W) If 1, disables the L1 + /// data cache IP prefetcher, which uses sequential load history (based on + /// instruction Pointer of previous loads) to determine whether to + /// prefetch additional lines. + /// + UINT32 DCUIPPrefetcherDisable:1; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER; + + +/** + Thread. Offcore Response Event Select Register (R/W). + + @param ECX MSR_SANDY_BRIDGE_OFFCORE_RSP_0 (0x000001A6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_OFFCORE_RSP_0 0x000001A6 + + +/** + Thread. Offcore Response Event Select Register (R/W). + + @param ECX MSR_SANDY_BRIDGE_OFFCORE_RSP_1 (0x000001A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_OFFCORE_RSP_1 0x000001A7 + + +/** + See http://biosbits.org. + + @param ECX MSR_SANDY_BRIDGE_MISC_PWR_MGMT (0x000001AA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_MISC_PWR_MGMT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_MISC_PWR_MGMT, Msr); + @endcode + @note MSR_SANDY_BRIDGE_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. +**/ +#define MSR_SANDY_BRIDGE_MISC_PWR_MGMT 0x000001AA + + +/** + Thread. Last Branch Record Filtering Select Register (R/W) See Section + 17.7.2, "Filtering of Last Branch Records.". + + @param ECX MSR_SANDY_BRIDGE_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_LBR_SELECT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_LBR_SELECT, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_SANDY_BRIDGE_LBR_SELECT 0x000001C8 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_LBR_SELECT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CPL_EQ_0. + /// + UINT32 CPL_EQ_0:1; + /// + /// [Bit 1] CPL_NEQ_0. + /// + UINT32 CPL_NEQ_0:1; + /// + /// [Bit 2] JCC. + /// + UINT32 JCC:1; + /// + /// [Bit 3] NEAR_REL_CALL. + /// + UINT32 NEAR_REL_CALL:1; + /// + /// [Bit 4] NEAR_IND_CALL. + /// + UINT32 NEAR_IND_CALL:1; + /// + /// [Bit 5] NEAR_RET. + /// + UINT32 NEAR_RET:1; + /// + /// [Bit 6] NEAR_IND_JMP. + /// + UINT32 NEAR_IND_JMP:1; + /// + /// [Bit 7] NEAR_REL_JMP. + /// + UINT32 NEAR_REL_JMP:1; + /// + /// [Bit 8] FAR_BRANCH. + /// + UINT32 FAR_BRANCH:1; + UINT32 Reserved1:23; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER; + + +/** + Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) + that points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP (at 680H). + + @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_SANDY_BRIDGE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_SANDY_BRIDGE_LASTBRANCH_TOS 0x000001C9 + + +/** + Thread. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_SANDY_BRIDGE_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LER_FROM_LIP); + @endcode + @note MSR_SANDY_BRIDGE_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_SANDY_BRIDGE_LER_FROM_LIP 0x000001DD + + +/** + Thread. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_SANDY_BRIDGE_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LER_TO_LIP); + @endcode + @note MSR_SANDY_BRIDGE_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_SANDY_BRIDGE_LER_TO_LIP 0x000001DE + + +/** + Core. See http://biosbits.org. + + @param ECX MSR_SANDY_BRIDGE_POWER_CTL (0x000001FC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_POWER_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_POWER_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_POWER_CTL is defined as MSR_POWER_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_POWER_CTL 0x000001FC + + +/** + Package. Always 0 (CMCI not supported). + + @param ECX MSR_SANDY_BRIDGE_IA32_MC4_CTL2 (0x00000284) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_IA32_MC4_CTL2 is defined as IA32_MC4_CTL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_MC4_CTL2 0x00000284 + + +/** + See Table 35-2. See Section 18.4.2, "Global Counter Control Facilities.". + + @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS 0x0000038E + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Thread. Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Thread. Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Thread. Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + /// + /// [Bit 4] Core. Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). + /// + UINT32 Ovf_PMC4:1; + /// + /// [Bit 5] Core. Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). + /// + UINT32 Ovf_PMC5:1; + /// + /// [Bit 6] Core. Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). + /// + UINT32 Ovf_PMC6:1; + /// + /// [Bit 7] Core. Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). + /// + UINT32 Ovf_PMC7:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Thread. Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Thread. Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:26; + /// + /// [Bit 61] Thread. Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Thread. Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + /// + /// [Bit 63] Thread. CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Thread. See Table 35-2. See Section 18.4.2, "Global Counter Control + Facilities.". + + @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL (0x0000038F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL is defined as IA32_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL 0x0000038F + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Set 1 to enable PMC0 to count. + /// + UINT32 PCM0_EN:1; + /// + /// [Bit 1] Thread. Set 1 to enable PMC1 to count. + /// + UINT32 PCM1_EN:1; + /// + /// [Bit 2] Thread. Set 1 to enable PMC2 to count. + /// + UINT32 PCM2_EN:1; + /// + /// [Bit 3] Thread. Set 1 to enable PMC3 to count. + /// + UINT32 PCM3_EN:1; + /// + /// [Bit 4] Core. Set 1 to enable PMC4 to count (if CPUID.0AH:EAX[15:8] > + /// 4). + /// + UINT32 PCM4_EN:1; + /// + /// [Bit 5] Core. Set 1 to enable PMC5 to count (if CPUID.0AH:EAX[15:8] > + /// 5). + /// + UINT32 PCM5_EN:1; + /// + /// [Bit 6] Core. Set 1 to enable PMC6 to count (if CPUID.0AH:EAX[15:8] > + /// 6). + /// + UINT32 PCM6_EN:1; + /// + /// [Bit 7] Core. Set 1 to enable PMC7 to count (if CPUID.0AH:EAX[15:8] > + /// 7). + /// + UINT32 PCM7_EN:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Set 1 to enable FixedCtr0 to count. + /// + UINT32 FIXED_CTR0:1; + /// + /// [Bit 33] Thread. Set 1 to enable FixedCtr1 to count. + /// + UINT32 FIXED_CTR1:1; + /// + /// [Bit 34] Thread. Set 1 to enable FixedCtr2 to count. + /// + UINT32 FIXED_CTR2:1; + UINT32 Reserved2:29; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER; + + +/** + See Table 35-2. See Section 18.4.2, "Global Counter Control Facilities.". + + @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL is defined as IA32_PERF_GLOBAL_OVF_CTRL in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL 0x00000390 + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Set 1 to clear Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Thread. Set 1 to clear Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Thread. Set 1 to clear Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Thread. Set 1 to clear Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + /// + /// [Bit 4] Core. Set 1 to clear Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). + /// + UINT32 Ovf_PMC4:1; + /// + /// [Bit 5] Core. Set 1 to clear Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). + /// + UINT32 Ovf_PMC5:1; + /// + /// [Bit 6] Core. Set 1 to clear Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). + /// + UINT32 Ovf_PMC6:1; + /// + /// [Bit 7] Core. Set 1 to clear Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). + /// + UINT32 Ovf_PMC7:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Set 1 to clear Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Thread. Set 1 to clear Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Thread. Set 1 to clear Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:26; + /// + /// [Bit 61] Thread. Set 1 to clear Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Thread. Set 1 to clear Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + /// + /// [Bit 63] Thread. Set 1 to clear CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER; + + +/** + Thread. See Section 18.8.1.1, "Processor Event Based Sampling (PEBS).". + + @param ECX MSR_SANDY_BRIDGE_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_ENABLE); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_SANDY_BRIDGE_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). + /// + UINT32 PEBS_EN_PMC0:1; + /// + /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). + /// + UINT32 PEBS_EN_PMC1:1; + /// + /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). + /// + UINT32 PEBS_EN_PMC2:1; + /// + /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). + /// + UINT32 PEBS_EN_PMC3:1; + UINT32 Reserved1:28; + /// + /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). + /// + UINT32 LL_EN_PMC0:1; + /// + /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). + /// + UINT32 LL_EN_PMC1:1; + /// + /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). + /// + UINT32 LL_EN_PMC2:1; + /// + /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). + /// + UINT32 LL_EN_PMC3:1; + UINT32 Reserved2:27; + /// + /// [Bit 63] Enable Precise Store. (R/W). + /// + UINT32 PS_EN:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER; + + +/** + Thread. see See Section 18.8.1.2, "Load Latency Performance Monitoring + Facility.". + + @param ECX MSR_SANDY_BRIDGE_PEBS_LD_LAT (0x000003F6) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_LD_LAT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_LD_LAT, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PEBS_LD_LAT is defined as MSR_PEBS_LD_LAT in SDM. +**/ +#define MSR_SANDY_BRIDGE_PEBS_LD_LAT 0x000003F6 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_LD_LAT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] Minimum threshold latency value of tagged load operation + /// that will be counted. (R/W). + /// + UINT32 MinimumThreshold:16; + UINT32 Reserved1:16; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY (0x000003F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY 0x000003F8 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C6 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY (0x000003F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY 0x000003F9 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C7 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C7 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY (0x000003FA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY 0x000003FA + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C3 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY (0x000003FC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY 0x000003FC + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C6 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY (0x000003FD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY 0x000003FD + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C7 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C7 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY (0x000003FE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY is defined as MSR_CORE_C7_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY 0x000003FE + + +/** + Core. See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". + + @param ECX MSR_SANDY_BRIDGE_IA32_MC4_CTL (0x00000410) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_IA32_MC4_CTL is defined as IA32_MC4_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_MC4_CTL 0x00000410 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_IA32_MC4_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PCU Hardware Error (R/W) When set, enables signaling of PCU + /// hardware detected errors. + /// + UINT32 PCUHardwareError:1; + /// + /// [Bit 1] PCU Controller Error (R/W) When set, enables signaling of PCU + /// controller detected errors. + /// + UINT32 PCUControllerError:1; + /// + /// [Bit 2] PCU Firmware Error (R/W) When set, enables signaling of PCU + /// firmware detected errors. + /// + UINT32 PCUFirmwareError:1; + UINT32 Reserved1:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER; + + +/** + Thread. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. + + @param ECX MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM (0x0000048C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM); + @endcode + @note MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. +**/ +#define MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM 0x0000048C + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, + "RAPL Interfaces.". + + @param ECX MSR_SANDY_BRIDGE_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_RAPL_POWER_UNIT); + @endcode + @note MSR_SANDY_BRIDGE_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_RAPL_POWER_UNIT 0x00000606 + + +/** + Package. Package C3 Interrupt Response Limit (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. + + @param ECX MSR_SANDY_BRIDGE_PKGC3_IRTL (0x0000060A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC3_IRTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC3_IRTL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PKGC3_IRTL is defined as MSR_PKGC3_IRTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKGC3_IRTL 0x0000060A + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC3_IRTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C3 state. + /// + UINT32 TimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. The following time unit + /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: + /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER; + + +/** + Package. Package C6 Interrupt Response Limit (R/W) This MSR defines the + budget allocated for the package to exit from C6 to a C0 state, where + interrupt request can be delivered to the core and serviced. Additional + core-exit latency amy be applicable depending on the actual C-state the core + is in. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. + + @param ECX MSR_SANDY_BRIDGE_PKGC6_IRTL (0x0000060B) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC6_IRTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC6_IRTL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PKGC6_IRTL is defined as MSR_PKGC6_IRTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKGC6_IRTL 0x0000060B + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC6_IRTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C6 state. + /// + UINT32 TimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. The following time unit + /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: + /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C2 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C2 states. Count at the same frequency as the TSC. + + @param ECX MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY (0x0000060D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY 0x0000060D + + +/** + Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package + RAPL Domain.". + + @param ECX MSR_SANDY_BRIDGE_PKG_POWER_LIMIT (0x00000610) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_LIMIT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_LIMIT, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_POWER_LIMIT 0x00000610 + + +/** + Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS (0x00000611) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS 0x00000611 + + +/** + Package. PKG RAPL Parameters (R/W) See Section 14.9.3, "Package RAPL + Domain.". + + @param ECX MSR_SANDY_BRIDGE_PKG_POWER_INFO (0x00000614) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_INFO); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_INFO, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_POWER_INFO 0x00000614 + + +/** + Package. PP0 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 + RAPL Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP0_POWER_LIMIT (0x00000638) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_POWER_LIMIT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP0_POWER_LIMIT, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP0_POWER_LIMIT 0x00000638 + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS 0x00000639 + + +/** + Thread. Last Branch Record n From IP (R/W) One of sixteen pairs of last + branch record registers on the last branch record stack. This part of the + stack contains pointers to the source instruction. See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.7.1 and record format in Section + 17.4.8.1. + + @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP 0x00000680 +#define MSR_SANDY_BRIDGE_LASTBRANCH_1_FROM_IP 0x00000681 +#define MSR_SANDY_BRIDGE_LASTBRANCH_2_FROM_IP 0x00000682 +#define MSR_SANDY_BRIDGE_LASTBRANCH_3_FROM_IP 0x00000683 +#define MSR_SANDY_BRIDGE_LASTBRANCH_4_FROM_IP 0x00000684 +#define MSR_SANDY_BRIDGE_LASTBRANCH_5_FROM_IP 0x00000685 +#define MSR_SANDY_BRIDGE_LASTBRANCH_6_FROM_IP 0x00000686 +#define MSR_SANDY_BRIDGE_LASTBRANCH_7_FROM_IP 0x00000687 +#define MSR_SANDY_BRIDGE_LASTBRANCH_8_FROM_IP 0x00000688 +#define MSR_SANDY_BRIDGE_LASTBRANCH_9_FROM_IP 0x00000689 +#define MSR_SANDY_BRIDGE_LASTBRANCH_10_FROM_IP 0x0000068A +#define MSR_SANDY_BRIDGE_LASTBRANCH_11_FROM_IP 0x0000068B +#define MSR_SANDY_BRIDGE_LASTBRANCH_12_FROM_IP 0x0000068C +#define MSR_SANDY_BRIDGE_LASTBRANCH_13_FROM_IP 0x0000068D +#define MSR_SANDY_BRIDGE_LASTBRANCH_14_FROM_IP 0x0000068E +#define MSR_SANDY_BRIDGE_LASTBRANCH_15_FROM_IP 0x0000068F +/// @} + + +/** + Thread. Last Branch Record n To IP (R/W) One of sixteen pairs of last branch + record registers on the last branch record stack. This part of the stack + contains pointers to the destination instruction. + + @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. + MSR_SANDY_BRIDGE_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP 0x000006C0 +#define MSR_SANDY_BRIDGE_LASTBRANCH_1_TO_IP 0x000006C1 +#define MSR_SANDY_BRIDGE_LASTBRANCH_2_TO_IP 0x000006C2 +#define MSR_SANDY_BRIDGE_LASTBRANCH_3_TO_IP 0x000006C3 +#define MSR_SANDY_BRIDGE_LASTBRANCH_4_TO_IP 0x000006C4 +#define MSR_SANDY_BRIDGE_LASTBRANCH_5_TO_IP 0x000006C5 +#define MSR_SANDY_BRIDGE_LASTBRANCH_6_TO_IP 0x000006C6 +#define MSR_SANDY_BRIDGE_LASTBRANCH_7_TO_IP 0x000006C7 +#define MSR_SANDY_BRIDGE_LASTBRANCH_8_TO_IP 0x000006C8 +#define MSR_SANDY_BRIDGE_LASTBRANCH_9_TO_IP 0x000006C9 +#define MSR_SANDY_BRIDGE_LASTBRANCH_10_TO_IP 0x000006CA +#define MSR_SANDY_BRIDGE_LASTBRANCH_11_TO_IP 0x000006CB +#define MSR_SANDY_BRIDGE_LASTBRANCH_12_TO_IP 0x000006CC +#define MSR_SANDY_BRIDGE_LASTBRANCH_13_TO_IP 0x000006CD +#define MSR_SANDY_BRIDGE_LASTBRANCH_14_TO_IP 0x000006CE +#define MSR_SANDY_BRIDGE_LASTBRANCH_15_TO_IP 0x000006CF +/// @} + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT); + @endcode + @note MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio + /// limit of 5 core active. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio + /// limit of 6 core active. + /// + UINT32 Maximum6C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio + /// limit of 7 core active. + /// + UINT32 Maximum7C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio + /// limit of 8 core active. + /// + UINT32 Maximum8C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. Uncore PMU global control. + + @param ECX MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL (0x00000391) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL 0x00000391 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Slice 0 select. + /// + UINT32 PMI_Sel_Slice0:1; + /// + /// [Bit 1] Slice 1 select. + /// + UINT32 PMI_Sel_Slice1:1; + /// + /// [Bit 2] Slice 2 select. + /// + UINT32 PMI_Sel_Slice2:1; + /// + /// [Bit 3] Slice 3 select. + /// + UINT32 PMI_Sel_Slice3:1; + /// + /// [Bit 4] Slice 4 select. + /// + UINT32 PMI_Sel_Slice4:1; + UINT32 Reserved1:14; + UINT32 Reserved2:10; + /// + /// [Bit 29] Enable all uncore counters. + /// + UINT32 EN:1; + /// + /// [Bit 30] Enable wake on PMI. + /// + UINT32 WakePMI:1; + /// + /// [Bit 31] Enable Freezing counter when overflow. + /// + UINT32 FREEZE:1; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER; + + +/** + Package. Uncore PMU main status. + + @param ECX MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS (0x00000392) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS 0x00000392 + +/** + MSR information returned for MSR index + #MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fixed counter overflowed. + /// + UINT32 Fixed:1; + /// + /// [Bit 1] An ARB counter overflowed. + /// + UINT32 ARB:1; + UINT32 Reserved1:1; + /// + /// [Bit 3] A CBox counter overflowed (on any slice). + /// + UINT32 CBox:1; + UINT32 Reserved2:28; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER; + + +/** + Package. Uncore fixed counter control (R/W). + + @param ECX MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL (0x00000394) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL 0x00000394 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:20; + /// + /// [Bit 20] Enable overflow propagation. + /// + UINT32 EnableOverflow:1; + UINT32 Reserved2:1; + /// + /// [Bit 22] Enable counting. + /// + UINT32 EnableCounting:1; + UINT32 Reserved3:9; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER; + + +/** + Package. Uncore fixed counter. + + @param ECX MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR (0x00000395) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR 0x00000395 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Current count. + /// + UINT32 CurrentCount:32; + /// + /// [Bits 47:32] Current count. + /// + UINT32 CurrentCountHi:16; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER; + + +/** + Package. Uncore C-Box configuration information (R/O). + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_CONFIG (0x00000396) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_CONFIG); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_CONFIG 0x00000396 + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_CBO_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Report the number of C-Box units with performance counters, + /// including processor cores and processor graphics". + /// + UINT32 CBox:4; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER; + + +/** + Package. Uncore Arb unit, performance counter 0. + + @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 (0x000003B0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 0x000003B0 + + +/** + Package. Uncore Arb unit, performance counter 1. + + @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 (0x000003B1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 0x000003B1 + + +/** + Package. Uncore Arb unit, counter 0 event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 (0x000003B2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 0x000003B2 + + +/** + Package. Uncore Arb unit, counter 1 event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 (0x000003B3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 is defined as MSR_UNC_ARB_PERFEVTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 0x000003B3 + + +/** + Package. Package C7 Interrupt Response Limit (R/W) This MSR defines the + budget allocated for the package to exit from C7 to a C0 state, where + interrupt request can be delivered to the core and serviced. Additional + core-exit latency amy be applicable depending on the actual C-state the core + is in. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. + + @param ECX MSR_SANDY_BRIDGE_PKGC7_IRTL (0x0000060C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC7_IRTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC7_IRTL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PKGC7_IRTL is defined as MSR_PKGC7_IRTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKGC7_IRTL 0x0000060C + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC7_IRTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit + /// that should be used to decide if the package should be put into a + /// package C7 state. + /// + UINT32 TimeLimit:10; + /// + /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time + /// unit of the interrupt response time limit. The following time unit + /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: + /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. + /// + UINT32 TimeUnit:3; + UINT32 Reserved1:2; + /// + /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are + /// valid and can be used by the processor for package C-sate management. + /// + UINT32 Valid:1; + UINT32 Reserved2:16; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER; + + +/** + Package. PP0 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP0_POLICY (0x0000063A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_POLICY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP0_POLICY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PP0_POLICY is defined as MSR_PP0_POLICY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP0_POLICY 0x0000063A + + +/** + Package. PP1 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 + RAPL Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP1_POWER_LIMIT (0x00000640) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_POWER_LIMIT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP1_POWER_LIMIT, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PP1_POWER_LIMIT is defined as MSR_PP1_POWER_LIMIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP1_POWER_LIMIT 0x00000640 + + +/** + Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS (0x00000641) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS 0x00000641 + + +/** + Package. PP1 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_SANDY_BRIDGE_PP1_POLICY (0x00000642) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_POLICY); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP1_POLICY, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PP1_POLICY is defined as MSR_PP1_POLICY in SDM. +**/ +#define MSR_SANDY_BRIDGE_PP1_POLICY 0x00000642 + + +/** + Package. Uncore C-Box 0, counter n event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL2 is defined as MSR_UNC_CBO_0_PERFEVTSEL2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL3 is defined as MSR_UNC_CBO_0_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0 0x00000700 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL1 0x00000701 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL2 0x00000702 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL3 0x00000703 +/// @} + + +/** + Package. Uncore C-Box n, unit status for counter 0-3. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_n_UNIT_STATUS + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS is defined as MSR_UNC_CBO_0_UNIT_STATUS in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_UNIT_STATUS is defined as MSR_UNC_CBO_1_UNIT_STATUS in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_UNIT_STATUS is defined as MSR_UNC_CBO_2_UNIT_STATUS in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_UNIT_STATUS is defined as MSR_UNC_CBO_3_UNIT_STATUS in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_UNIT_STATUS is defined as MSR_UNC_CBO_4_UNIT_STATUS in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS 0x00000705 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_UNIT_STATUS 0x00000715 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_UNIT_STATUS 0x00000725 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_UNIT_STATUS 0x00000735 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_UNIT_STATUS 0x00000745 +/// @} + + +/** + Package. Uncore C-Box 0, performance counter n. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR2 is defined as MSR_UNC_CBO_0_PERFCTR2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR3 is defined as MSR_UNC_CBO_0_PERFCTR3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0 0x00000706 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR1 0x00000707 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR2 0x00000708 +#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR3 0x00000709 +/// @} + + +/** + Package. Uncore C-Box 1, counter n event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL2 is defined as MSR_UNC_CBO_1_PERFEVTSEL2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL3 is defined as MSR_UNC_CBO_1_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0 0x00000710 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL1 0x00000711 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL2 0x00000712 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL3 0x00000713 +/// @} + + +/** + Package. Uncore C-Box 1, performance counter n. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR2 is defined as MSR_UNC_CBO_1_PERFCTR2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR3 is defined as MSR_UNC_CBO_1_PERFCTR3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0 0x00000716 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR1 0x00000717 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR2 0x00000718 +#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR3 0x00000719 +/// @} + + +/** + Package. Uncore C-Box 2, counter n event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL2 is defined as MSR_UNC_CBO_2_PERFEVTSEL2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL3 is defined as MSR_UNC_CBO_2_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0 0x00000720 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL1 0x00000721 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL2 0x00000722 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL3 0x00000723 +/// @} + + +/** + Package. Uncore C-Box 2, performance counter n. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR2 is defined as MSR_UNC_CBO_2_PERFCTR2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR3 is defined as MSR_UNC_CBO_2_PERFCTR3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0 0x00000726 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR1 0x00000727 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR2 0x00000728 +#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR3 0x00000729 +/// @} + + +/** + Package. Uncore C-Box 3, counter n event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL2 is defined as MSR_UNC_CBO_3_PERFEVTSEL2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL3 is defined as MSR_UNC_CBO_3_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0 0x00000730 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL1 0x00000731 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL2 0x00000732 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL3 0x00000733 +/// @} + + +/** + Package. Uncore C-Box 3, performance counter n. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR2 is defined as MSR_UNC_CBO_3_PERFCTR2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR3 is defined as MSR_UNC_CBO_3_PERFCTR3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0 0x00000736 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR1 0x00000737 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR2 0x00000738 +#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR3 0x00000739 +/// @} + + +/** + Package. Uncore C-Box 4, counter n event select MSR. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0 is defined as MSR_UNC_CBO_4_PERFEVTSEL0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL1 is defined as MSR_UNC_CBO_4_PERFEVTSEL1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL2 is defined as MSR_UNC_CBO_4_PERFEVTSEL2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL3 is defined as MSR_UNC_CBO_4_PERFEVTSEL3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0 0x00000740 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL1 0x00000741 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL2 0x00000742 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL3 0x00000743 +/// @} + + +/** + Package. Uncore C-Box 4, performance counter n. + + @param ECX MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0 is defined as MSR_UNC_CBO_4_PERFCTR0 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR1 is defined as MSR_UNC_CBO_4_PERFCTR1 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR2 is defined as MSR_UNC_CBO_4_PERFCTR2 in SDM. + MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR3 is defined as MSR_UNC_CBO_4_PERFCTR3 in SDM. + @{ +**/ +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0 0x00000746 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR1 0x00000747 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR2 0x00000748 +#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR3 0x00000749 +/// @} + + +/** + Package. MC Bank Error Configuration (R/W). + + @param ECX MSR_SANDY_BRIDGE_ERROR_CONTROL (0x0000017F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_ERROR_CONTROL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_ERROR_CONTROL, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. +**/ +#define MSR_SANDY_BRIDGE_ERROR_CONTROL 0x0000017F + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_ERROR_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:1; + /// + /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank + /// to log additional info in bits 36:32. + /// + UINT32 MemErrorLogEnable:1; + UINT32 Reserved2:30; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER; + + +/** + Package. + + @param ECX MSR_SANDY_BRIDGE_PEBS_NUM_ALT (0x0000039C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER. + + Example usage + @code + MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_NUM_ALT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_NUM_ALT, Msr.Uint64); + @endcode + @note MSR_SANDY_BRIDGE_PEBS_NUM_ALT is defined as MSR_PEBS_NUM_ALT in SDM. +**/ +#define MSR_SANDY_BRIDGE_PEBS_NUM_ALT 0x0000039C + +/** + MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_NUM_ALT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] ENABLE_PEBS_NUM_ALT (RW) Write 1 to enable alternate PEBS + /// counting logic for specific events requiring additional configuration, + /// see Table 19-15. + /// + UINT32 ENABLE_PEBS_NUM_ALT:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER; + + +/** + Package. Package RAPL Perf Status (R/O). + + @param ECX MSR_SANDY_BRIDGE_PKG_PERF_STATUS (0x00000613) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_PERF_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_PKG_PERF_STATUS 0x00000613 + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS 0x00000619 + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_SANDY_BRIDGE_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_PERF_STATUS); + @endcode + @note MSR_SANDY_BRIDGE_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_SANDY_BRIDGE_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_SANDY_BRIDGE_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_SANDY_BRIDGE_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_SANDY_BRIDGE_DRAM_POWER_INFO 0x0000061C + + +/** + Package. Uncore U-box UCLK fixed counter control. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL (0x00000C08) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL is defined as MSR_U_PMON_UCLK_FIXED_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL 0x00000C08 + + +/** + Package. Uncore U-box UCLK fixed counter. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR (0x00000C09) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR is defined as MSR_U_PMON_UCLK_FIXED_CTR in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR 0x00000C09 + + +/** + Package. Uncore U-box perfmon event select for U-box counter 0. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 (0x00000C10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 is defined as MSR_U_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 0x00000C10 + + +/** + Package. Uncore U-box perfmon event select for U-box counter 1. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 (0x00000C11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 is defined as MSR_U_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 0x00000C11 + + +/** + Package. Uncore U-box perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_CTR0 (0x00000C16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_CTR0 is defined as MSR_U_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_CTR0 0x00000C16 + + +/** + Package. Uncore U-box perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_U_PMON_CTR1 (0x00000C17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_U_PMON_CTR1 is defined as MSR_U_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_U_PMON_CTR1 0x00000C17 + + +/** + Package. Uncore PCU perfmon for PCU-box-wide control. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL (0x00000C24) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL is defined as MSR_PCU_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL 0x00000C24 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 0. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 (0x00000C30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 is defined as MSR_PCU_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 0x00000C30 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 1. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 (0x00000C31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 is defined as MSR_PCU_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 0x00000C31 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 2. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 (0x00000C32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 is defined as MSR_PCU_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 0x00000C32 + + +/** + Package. Uncore PCU perfmon event select for PCU counter 3. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 (0x00000C33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 is defined as MSR_PCU_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 0x00000C33 + + +/** + Package. Uncore PCU perfmon box-wide filter. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER (0x00000C34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER is defined as MSR_PCU_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER 0x00000C34 + + +/** + Package. Uncore PCU perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR0 (0x00000C36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_CTR0 is defined as MSR_PCU_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_CTR0 0x00000C36 + + +/** + Package. Uncore PCU perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR1 (0x00000C37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_CTR1 is defined as MSR_PCU_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_CTR1 0x00000C37 + + +/** + Package. Uncore PCU perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR2 (0x00000C38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_CTR2 is defined as MSR_PCU_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_CTR2 0x00000C38 + + +/** + Package. Uncore PCU perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR3 (0x00000C39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_PCU_PMON_CTR3 is defined as MSR_PCU_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_PCU_PMON_CTR3 0x00000C39 + + +/** + Package. Uncore C-box 0 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL (0x00000D04) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL is defined as MSR_C0_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL 0x00000D04 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 (0x00000D10) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 is defined as MSR_C0_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 0x00000D10 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 (0x00000D11) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 is defined as MSR_C0_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 0x00000D11 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 (0x00000D12) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 is defined as MSR_C0_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 0x00000D12 + + +/** + Package. Uncore C-box 0 perfmon event select for C-box 0 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 (0x00000D13) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 is defined as MSR_C0_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 0x00000D13 + + +/** + Package. Uncore C-box 0 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER (0x00000D14) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER is defined as MSR_C0_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER 0x00000D14 + + +/** + Package. Uncore C-box 0 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR0 (0x00000D16) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_CTR0 0x00000D16 + + +/** + Package. Uncore C-box 0 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR1 (0x00000D17) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_CTR1 0x00000D17 + + +/** + Package. Uncore C-box 0 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR2 (0x00000D18) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_CTR2 0x00000D18 + + +/** + Package. Uncore C-box 0 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR3 (0x00000D19) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C0_PMON_CTR3 0x00000D19 + + +/** + Package. Uncore C-box 1 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL (0x00000D24) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL is defined as MSR_C1_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL 0x00000D24 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 (0x00000D30) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 is defined as MSR_C1_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 0x00000D30 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 (0x00000D31) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 is defined as MSR_C1_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 0x00000D31 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 (0x00000D32) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 is defined as MSR_C1_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 0x00000D32 + + +/** + Package. Uncore C-box 1 perfmon event select for C-box 1 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 (0x00000D33) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 is defined as MSR_C1_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 0x00000D33 + + +/** + Package. Uncore C-box 1 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER (0x00000D34) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER is defined as MSR_C1_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER 0x00000D34 + + +/** + Package. Uncore C-box 1 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR0 (0x00000D36) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_CTR0 0x00000D36 + + +/** + Package. Uncore C-box 1 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR1 (0x00000D37) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_CTR1 0x00000D37 + + +/** + Package. Uncore C-box 1 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR2 (0x00000D38) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_CTR2 0x00000D38 + + +/** + Package. Uncore C-box 1 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR3 (0x00000D39) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C1_PMON_CTR3 0x00000D39 + + +/** + Package. Uncore C-box 2 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL (0x00000D44) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL is defined as MSR_C2_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL 0x00000D44 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 (0x00000D50) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 is defined as MSR_C2_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 0x00000D50 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 (0x00000D51) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 is defined as MSR_C2_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 0x00000D51 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 (0x00000D52) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 is defined as MSR_C2_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 0x00000D52 + + +/** + Package. Uncore C-box 2 perfmon event select for C-box 2 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 (0x00000D53) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 is defined as MSR_C2_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 0x00000D53 + + +/** + Package. Uncore C-box 2 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER (0x00000D54) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER is defined as MSR_C2_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER 0x00000D54 + + +/** + Package. Uncore C-box 2 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR0 (0x00000D56) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_CTR0 0x00000D56 + + +/** + Package. Uncore C-box 2 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR1 (0x00000D57) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_CTR1 0x00000D57 + + +/** + Package. Uncore C-box 2 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR2 (0x00000D58) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_CTR2 0x00000D58 + + +/** + Package. Uncore C-box 2 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR3 (0x00000D59) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C2_PMON_CTR3 0x00000D59 + + +/** + Package. Uncore C-box 3 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL (0x00000D64) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL is defined as MSR_C3_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL 0x00000D64 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 (0x00000D70) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 is defined as MSR_C3_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 0x00000D70 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 (0x00000D71) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 is defined as MSR_C3_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 0x00000D71 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 (0x00000D72) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 is defined as MSR_C3_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 0x00000D72 + + +/** + Package. Uncore C-box 3 perfmon event select for C-box 3 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 (0x00000D73) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 is defined as MSR_C3_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 0x00000D73 + + +/** + Package. Uncore C-box 3 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER (0x00000D74) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER is defined as MSR_C3_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER 0x00000D74 + + +/** + Package. Uncore C-box 3 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR0 (0x00000D76) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_CTR0 0x00000D76 + + +/** + Package. Uncore C-box 3 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR1 (0x00000D77) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_CTR1 0x00000D77 + + +/** + Package. Uncore C-box 3 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR2 (0x00000D78) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_CTR2 0x00000D78 + + +/** + Package. Uncore C-box 3 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR3 (0x00000D79) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C3_PMON_CTR3 0x00000D79 + + +/** + Package. Uncore C-box 4 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL (0x00000D84) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL is defined as MSR_C4_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL 0x00000D84 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 (0x00000D90) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 is defined as MSR_C4_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 0x00000D90 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 (0x00000D91) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 is defined as MSR_C4_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 0x00000D91 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 (0x00000D92) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 is defined as MSR_C4_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 0x00000D92 + + +/** + Package. Uncore C-box 4 perfmon event select for C-box 4 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 (0x00000D93) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 is defined as MSR_C4_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 0x00000D93 + + +/** + Package. Uncore C-box 4 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER (0x00000D94) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER is defined as MSR_C4_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER 0x00000D94 + + +/** + Package. Uncore C-box 4 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR0 (0x00000D96) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_CTR0 0x00000D96 + + +/** + Package. Uncore C-box 4 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR1 (0x00000D97) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_CTR1 0x00000D97 + + +/** + Package. Uncore C-box 4 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR2 (0x00000D98) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_CTR2 0x00000D98 + + +/** + Package. Uncore C-box 4 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR3 (0x00000D99) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C4_PMON_CTR3 0x00000D99 + + +/** + Package. Uncore C-box 5 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL (0x00000DA4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL is defined as MSR_C5_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL 0x00000DA4 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 (0x00000DB0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 is defined as MSR_C5_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 0x00000DB0 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 (0x00000DB1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 is defined as MSR_C5_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 0x00000DB1 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 (0x00000DB2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 is defined as MSR_C5_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 0x00000DB2 + + +/** + Package. Uncore C-box 5 perfmon event select for C-box 5 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 (0x00000DB3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 is defined as MSR_C5_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 0x00000DB3 + + +/** + Package. Uncore C-box 5 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER (0x00000DB4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER is defined as MSR_C5_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER 0x00000DB4 + + +/** + Package. Uncore C-box 5 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR0 (0x00000DB6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_CTR0 0x00000DB6 + + +/** + Package. Uncore C-box 5 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR1 (0x00000DB7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_CTR1 0x00000DB7 + + +/** + Package. Uncore C-box 5 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR2 (0x00000DB8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_CTR2 0x00000DB8 + + +/** + Package. Uncore C-box 5 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR3 (0x00000DB9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C5_PMON_CTR3 0x00000DB9 + + +/** + Package. Uncore C-box 6 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL (0x00000DC4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL is defined as MSR_C6_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL 0x00000DC4 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 (0x00000DD0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 is defined as MSR_C6_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 0x00000DD0 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 (0x00000DD1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 is defined as MSR_C6_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 0x00000DD1 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 (0x00000DD2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 is defined as MSR_C6_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 0x00000DD2 + + +/** + Package. Uncore C-box 6 perfmon event select for C-box 6 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 (0x00000DD3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 is defined as MSR_C6_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 0x00000DD3 + + +/** + Package. Uncore C-box 6 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER (0x00000DD4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER is defined as MSR_C6_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER 0x00000DD4 + + +/** + Package. Uncore C-box 6 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR0 (0x00000DD6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_CTR0 0x00000DD6 + + +/** + Package. Uncore C-box 6 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR1 (0x00000DD7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_CTR1 0x00000DD7 + + +/** + Package. Uncore C-box 6 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR2 (0x00000DD8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_CTR2 0x00000DD8 + + +/** + Package. Uncore C-box 6 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR3 (0x00000DD9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C6_PMON_CTR3 0x00000DD9 + + +/** + Package. Uncore C-box 7 perfmon local box wide control. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL (0x00000DE4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL is defined as MSR_C7_PMON_BOX_CTL in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL 0x00000DE4 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 0. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 (0x00000DF0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 is defined as MSR_C7_PMON_EVNTSEL0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 0x00000DF0 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 1. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 (0x00000DF1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 is defined as MSR_C7_PMON_EVNTSEL1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 0x00000DF1 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 2. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 (0x00000DF2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 is defined as MSR_C7_PMON_EVNTSEL2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 0x00000DF2 + + +/** + Package. Uncore C-box 7 perfmon event select for C-box 7 counter 3. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 (0x00000DF3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 is defined as MSR_C7_PMON_EVNTSEL3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 0x00000DF3 + + +/** + Package. Uncore C-box 7 perfmon box wide filter. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER (0x00000DF4) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER is defined as MSR_C7_PMON_BOX_FILTER in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER 0x00000DF4 + + +/** + Package. Uncore C-box 7 perfmon counter 0. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR0 (0x00000DF6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR0); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR0, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_CTR0 0x00000DF6 + + +/** + Package. Uncore C-box 7 perfmon counter 1. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR1 (0x00000DF7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR1); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR1, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_CTR1 0x00000DF7 + + +/** + Package. Uncore C-box 7 perfmon counter 2. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR2 (0x00000DF8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR2); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR2, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_CTR2 0x00000DF8 + + +/** + Package. Uncore C-box 7 perfmon counter 3. + + @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR3 (0x00000DF9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR3); + AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR3, Msr); + @endcode + @note MSR_SANDY_BRIDGE_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. +**/ +#define MSR_SANDY_BRIDGE_C7_PMON_CTR3 0x00000DF9 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h new file mode 100644 index 0000000000..ec09bf3c13 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h @@ -0,0 +1,1570 @@ +/** @file + MSR Definitions for Intel processors based on the Silvermont microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.4. + +**/ + +#ifndef __SILVERMONT_MSR_H__ +#define __SILVERMONT_MSR_H__ + +#include + +/** + Is Intel processors based on the Silvermont microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_SILVERMONT_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x37 || \ + DisplayModel == 0x4A || \ + DisplayModel == 0x4D || \ + DisplayModel == 0x5A || \ + DisplayModel == 0x5D \ + ) \ + ) + +/** + Module. Model Specific Platform ID (R). + + @param ECX MSR_SILVERMONT_PLATFORM_ID (0x00000017) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PLATFORM_ID_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PLATFORM_ID_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PLATFORM_ID_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PLATFORM_ID); + @endcode + @note MSR_SILVERMONT_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. +**/ +#define MSR_SILVERMONT_PLATFORM_ID 0x00000017 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PLATFORM_ID +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. + /// + UINT32 MaximumQualifiedRatio:5; + UINT32 Reserved2:19; + UINT32 Reserved3:18; + /// + /// [Bits 52:50] See Table 35-2. + /// + UINT32 PlatformId:3; + UINT32 Reserved4:11; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PLATFORM_ID_REGISTER; + + +/** + Module. Processor Hard Power-On Configuration (R/W) Writes ignored. + + @param ECX MSR_SILVERMONT_EBL_CR_POWERON (0x0000002A) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_EBL_CR_POWERON_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_EBL_CR_POWERON_REGISTER. + + Example usage + @code + MSR_SILVERMONT_EBL_CR_POWERON_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_EBL_CR_POWERON); + AsmWriteMsr64 (MSR_SILVERMONT_EBL_CR_POWERON, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. +**/ +#define MSR_SILVERMONT_EBL_CR_POWERON 0x0000002A + +/** + MSR information returned for MSR index #MSR_SILVERMONT_EBL_CR_POWERON +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_EBL_CR_POWERON_REGISTER; + + +/** + Core. SMI Counter (R/O). + + @param ECX MSR_SILVERMONT_SMI_COUNT (0x00000034) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_SMI_COUNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_SMI_COUNT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_SMI_COUNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_SMI_COUNT); + @endcode + @note MSR_SILVERMONT_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. +**/ +#define MSR_SILVERMONT_SMI_COUNT 0x00000034 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_SMI_COUNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] SMI Count (R/O) Running count of SMI events since last + /// RESET. + /// + UINT32 SMICount:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_SMI_COUNT_REGISTER; + + +/** + Core. Control Features in Intel 64 Processor (R/W). See Table 35-2. + + @param ECX MSR_IA32_SILVERMONT_FEATURE_CONTROL (0x0000003A) + @param EAX Lower 32-bits of MSR value. + Described by the type + MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type + MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_IA32_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_SILVERMONT_IA32_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_IA32_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. +**/ +#define MSR_SILVERMONT_IA32_FEATURE_CONTROL 0x0000003A + +/** + MSR information returned for MSR index #MSR_SILVERMONT_IA32_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Lock (R/WL). + /// + UINT32 Lock:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Enable VMX outside SMX operation (R/WL). + /// + UINT32 EnableVmxOutsideSmx:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER; + + +/** + Core. Last Branch Record n From IP (R/W) One of eight pairs of last branch + record registers on the last branch record stack. The From_IP part of the + stack contains pointers to the source instruction. See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.5 and record format in Section + 17.4.8.1. + + @param ECX MSR_SILVERMONT_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_0_FROM_IP); + AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_0_FROM_IP, Msr); + @endcode + @note MSR_SILVERMONT_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. + @{ +**/ +#define MSR_SILVERMONT_LASTBRANCH_0_FROM_IP 0x00000040 +#define MSR_SILVERMONT_LASTBRANCH_1_FROM_IP 0x00000041 +#define MSR_SILVERMONT_LASTBRANCH_2_FROM_IP 0x00000042 +#define MSR_SILVERMONT_LASTBRANCH_3_FROM_IP 0x00000043 +#define MSR_SILVERMONT_LASTBRANCH_4_FROM_IP 0x00000044 +#define MSR_SILVERMONT_LASTBRANCH_5_FROM_IP 0x00000045 +#define MSR_SILVERMONT_LASTBRANCH_6_FROM_IP 0x00000046 +#define MSR_SILVERMONT_LASTBRANCH_7_FROM_IP 0x00000047 +/// @} + + +/** + Core. Last Branch Record n To IP (R/W) One of eight pairs of last branch + record registers on the last branch record stack. The To_IP part of the + stack contains pointers to the destination instruction. + + @param ECX MSR_SILVERMONT_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_0_TO_IP); + AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_0_TO_IP, Msr); + @endcode + @note MSR_SILVERMONT_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. + MSR_SILVERMONT_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. + @{ +**/ +#define MSR_SILVERMONT_LASTBRANCH_0_TO_IP 0x00000060 +#define MSR_SILVERMONT_LASTBRANCH_1_TO_IP 0x00000061 +#define MSR_SILVERMONT_LASTBRANCH_2_TO_IP 0x00000062 +#define MSR_SILVERMONT_LASTBRANCH_3_TO_IP 0x00000063 +#define MSR_SILVERMONT_LASTBRANCH_4_TO_IP 0x00000064 +#define MSR_SILVERMONT_LASTBRANCH_5_TO_IP 0x00000065 +#define MSR_SILVERMONT_LASTBRANCH_6_TO_IP 0x00000066 +#define MSR_SILVERMONT_LASTBRANCH_7_TO_IP 0x00000067 +/// @} + + +/** + Module. Scalable Bus Speed(RO) This field indicates the intended scalable + bus clock speed for processors based on Silvermont microarchitecture:. + + @param ECX MSR_SILVERMONT_FSB_FREQ (0x000000CD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_FSB_FREQ_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_FSB_FREQ_REGISTER. + + Example usage + @code + MSR_SILVERMONT_FSB_FREQ_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_FSB_FREQ); + @endcode + @note MSR_SILVERMONT_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. +**/ +#define MSR_SILVERMONT_FSB_FREQ 0x000000CD + +/** + MSR information returned for MSR index #MSR_SILVERMONT_FSB_FREQ +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Scalable Bus Speed + /// + /// Silvermont Processor Family + /// --------------------------- + /// 100B: 080.0 MHz + /// 000B: 083.3 MHz + /// 001B: 100.0 MHz + /// 010B: 133.3 MHz + /// 011B: 116.7 MHz + /// + /// Airmont Processor Family + /// --------------------------- + /// 0000B: 083.3 MHz + /// 0001B: 100.0 MHz + /// 0010B: 133.3 MHz + /// 0011B: 116.7 MHz + /// 0100B: 080.0 MHz + /// 0101B: 093.3 MHz + /// 0110B: 090.0 MHz + /// 0111B: 088.9 MHz + /// 1000B: 087.5 MHz + /// + UINT32 ScalableBusSpeed:4; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_FSB_FREQ_REGISTER; + + +/** + Module. C-State Configuration Control (R/W) Note: C-state values are + processor specific C-state code names, unrelated to MWAIT extension C-state + parameters or ACPI CStates. See http://biosbits.org. + + @param ECX MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power). for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0 (no package C-sate support) 001b: C1 (Behavior is the same as 000b) + /// 100b: C4 110b: C6 111b: C7 (Silvermont only). + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map + /// IO_read instructions sent to IO register specified by + /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register + /// until next reset. + /// + UINT32 CFGLock:1; + UINT32 Reserved3:16; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Module. Power Management IO Redirection in C-state (R/W) See + http://biosbits.org. + + @param ECX MSR_SILVERMONT_PMG_IO_CAPTURE_BASE (0x000000E4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PMG_IO_CAPTURE_BASE); + AsmWriteMsr64 (MSR_SILVERMONT_PMG_IO_CAPTURE_BASE, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. +**/ +#define MSR_SILVERMONT_PMG_IO_CAPTURE_BASE 0x000000E4 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PMG_IO_CAPTURE_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address + /// visible to software for IO redirection. If IO MWAIT Redirection is + /// enabled, reads to this address will be consumed by the power + /// management logic and decoded to MWAIT instructions. When IO port + /// address redirection is enabled, this is the IO port address reported + /// to the OS/software. + /// + UINT32 Lvl2Base:16; + /// + /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the + /// maximum C-State code name to be included when IO read to MWAIT + /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 100b - C4 + /// is the max C-State to include 110b - C6 is the max C-State to include + /// 111b - C7 is the max C-State to include. + /// + UINT32 CStateRange:3; + UINT32 Reserved1:13; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER; + + +/** + Module. + + @param ECX MSR_SILVERMONT_BBL_CR_CTL3 (0x0000011E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_BBL_CR_CTL3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_BBL_CR_CTL3_REGISTER. + + Example usage + @code + MSR_SILVERMONT_BBL_CR_CTL3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_BBL_CR_CTL3); + AsmWriteMsr64 (MSR_SILVERMONT_BBL_CR_CTL3, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. +**/ +#define MSR_SILVERMONT_BBL_CR_CTL3 0x0000011E + +/** + MSR information returned for MSR index #MSR_SILVERMONT_BBL_CR_CTL3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = + /// Indicates if the L2 is hardware-disabled. + /// + UINT32 L2HardwareEnabled:1; + UINT32 Reserved1:7; + /// + /// [Bit 8] L2 Enabled. (R/W) 1 = L2 cache has been initialized 0 = + /// Disabled (default) Until this bit is set the processor will not + /// respond to the WBINVD instruction or the assertion of the FLUSH# input. + /// + UINT32 L2Enabled:1; + UINT32 Reserved2:14; + /// + /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. + /// + UINT32 L2NotPresent:1; + UINT32 Reserved3:8; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_BBL_CR_CTL3_REGISTER; + + +/** + Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP + handler to handle unsuccessful read of this MSR. + + @param ECX MSR_SILVERMONT_FEATURE_CONFIG (0x0000013C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_FEATURE_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_FEATURE_CONFIG_REGISTER. + + Example usage + @code + MSR_SILVERMONT_FEATURE_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_FEATURE_CONFIG); + AsmWriteMsr64 (MSR_SILVERMONT_FEATURE_CONFIG, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. +**/ +#define MSR_SILVERMONT_FEATURE_CONFIG 0x0000013C + +/** + MSR information returned for MSR index #MSR_SILVERMONT_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this + /// MSR, the configuration of AES instruction set availability is as + /// follows: 11b: AES instructions are not available until next RESET. + /// otherwise, AES instructions are available. Note, AES instruction set + /// is not available if read is unsuccessful. If the configuration is not + /// 01b, AES instruction can be mis-configured if a privileged agent + /// unintentionally writes 11b. + /// + UINT32 AESConfiguration:2; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_FEATURE_CONFIG_REGISTER; + + +/** + Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_SILVERMONT_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_SILVERMONT_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_SILVERMONT_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. Fast-Strings Enable See Table 35-2. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Module. Automatic Thermal Control Circuit Enable (R/W) See + /// Table 35-2. Default value is 0. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Core. Performance Monitoring Available (R) See Table 35-2. + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:3; + /// + /// [Bit 11] Core. Branch Trace Storage Unavailable (RO) See Table 35-2. + /// + UINT32 BTS:1; + /// + /// [Bit 12] Core. Processor Event Based Sampling Unavailable (RO) See + /// Table 35-2. + /// + UINT32 PEBS:1; + UINT32 Reserved4:3; + /// + /// [Bit 16] Module. Enhanced Intel SpeedStep Technology Enable (R/W) See + /// Table 35-2. + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] Core. ENABLE MONITOR FSM (R/W) See Table 35-2. + /// + UINT32 MONITOR:1; + UINT32 Reserved6:3; + /// + /// [Bit 22] Core. Limit CPUID Maxval (R/W) See Table 35-2. + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] Module. xTPR Message Disable (R/W) See Table 35-2. + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] Core. XD Bit Disable (R/W) See Table 35-2. + /// + UINT32 XD:1; + UINT32 Reserved9:3; + /// + /// [Bit 38] Module. Turbo Mode Disable (R/W) When set to 1 on processors + /// that support Intel Turbo Boost Technology, the turbo mode feature is + /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: + /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: + /// EAX[1] reports the processor's support of turbo mode is enabled. Note: + /// the power-on default value is used by BIOS to detect hardware support + /// of turbo mode. If power-on default value is 1, turbo mode is available + /// in the processor. If power-on default value is 0, turbo mode is not + /// available. + /// + UINT32 TurboModeDisable:1; + UINT32 Reserved10:25; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER; + + +/** + Package. + + @param ECX MSR_SILVERMONT_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_SILVERMONT_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_SILVERMONT_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (R) The default thermal throttling or + /// PROCHOT# activation temperature in degree C, The effective temperature + /// for thermal throttling or PROCHOT# activation is "Temperature Target" + /// + "Target Offset". + /// + UINT32 TemperatureTarget:8; + /// + /// [Bits 29:24] Target Offset (R/W) Specifies an offset in degrees C to + /// adjust the throttling and PROCHOT# activation temperature from the + /// default target specified in TEMPERATURE_TARGET (bits 23:16). + /// + UINT32 TargetOffset:6; + UINT32 Reserved2:2; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER; + + +/** + Miscellaneous Feature Control (R/W). + + @param ECX MSR_SILVERMONT_MISC_FEATURE_CONTROL (0x000001A4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_MISC_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_SILVERMONT_MISC_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. +**/ +#define MSR_SILVERMONT_MISC_FEATURE_CONTROL 0x000001A4 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_MISC_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the + /// L2 hardware prefetcher, which fetches additional lines of code or data + /// into the L2 cache. + /// + UINT32 L2HardwarePrefetcherDisable:1; + UINT32 Reserved1:1; + /// + /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables + /// the L1 data cache prefetcher, which fetches the next cache line into + /// L1 data cache. + /// + UINT32 DCUHardwarePrefetcherDisable:1; + UINT32 Reserved2:29; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER; + + +/** + Module. Offcore Response Event Select Register (R/W). + + @param ECX MSR_SILVERMONT_OFFCORE_RSP_0 (0x000001A6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_OFFCORE_RSP_0); + AsmWriteMsr64 (MSR_SILVERMONT_OFFCORE_RSP_0, Msr); + @endcode + @note MSR_SILVERMONT_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. +**/ +#define MSR_SILVERMONT_OFFCORE_RSP_0 0x000001A6 + + +/** + Module. Offcore Response Event Select Register (R/W). + + @param ECX MSR_SILVERMONT_OFFCORE_RSP_1 (0x000001A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_OFFCORE_RSP_1); + AsmWriteMsr64 (MSR_SILVERMONT_OFFCORE_RSP_1, Msr); + @endcode + @note MSR_SILVERMONT_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. +**/ +#define MSR_SILVERMONT_OFFCORE_RSP_1 0x000001A7 + + +/** + Package. Maximum Ratio Limit of Turbo Mode (RW). + + @param ECX MSR_SILVERMONT_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_TURBO_RATIO_LIMIT); + AsmWriteMsr64 (MSR_SILVERMONT_TURBO_RATIO_LIMIT, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_SILVERMONT_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_SILVERMONT_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio + /// limit of 5 core active. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio + /// limit of 6 core active. + /// + UINT32 Maximum6C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio + /// limit of 7 core active. + /// + UINT32 Maximum7C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio + /// limit of 8 core active. + /// + UINT32 Maximum8C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Core. Last Branch Record Filtering Select Register (R/W) See Section + 17.7.2, "Filtering of Last Branch Records.". + + @param ECX MSR_SILVERMONT_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_LBR_SELECT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_LBR_SELECT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_LBR_SELECT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_LBR_SELECT); + AsmWriteMsr64 (MSR_SILVERMONT_LBR_SELECT, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_SILVERMONT_LBR_SELECT 0x000001C8 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_LBR_SELECT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CPL_EQ_0. + /// + UINT32 CPL_EQ_0:1; + /// + /// [Bit 1] CPL_NEQ_0. + /// + UINT32 CPL_NEQ_0:1; + /// + /// [Bit 2] JCC. + /// + UINT32 JCC:1; + /// + /// [Bit 3] NEAR_REL_CALL. + /// + UINT32 NEAR_REL_CALL:1; + /// + /// [Bit 4] NEAR_IND_CALL. + /// + UINT32 NEAR_IND_CALL:1; + /// + /// [Bit 5] NEAR_RET. + /// + UINT32 NEAR_RET:1; + /// + /// [Bit 6] NEAR_IND_JMP. + /// + UINT32 NEAR_IND_JMP:1; + /// + /// [Bit 7] NEAR_REL_JMP. + /// + UINT32 NEAR_REL_JMP:1; + /// + /// [Bit 8] FAR_BRANCH. + /// + UINT32 FAR_BRANCH:1; + UINT32 Reserved1:23; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_LBR_SELECT_REGISTER; + + +/** + Core. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-2) that + points to the MSR containing the most recent branch record. See + MSR_LASTBRANCH_0_FROM_IP. + + @param ECX MSR_SILVERMONT_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_SILVERMONT_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_SILVERMONT_LASTBRANCH_TOS 0x000001C9 + + +/** + Core. Last Exception Record From Linear IP (R) Contains a pointer to the + last branch instruction that the processor executed prior to the last + exception that was generated or the last interrupt that was handled. + + @param ECX MSR_SILVERMONT_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_LER_FROM_LIP); + @endcode + @note MSR_SILVERMONT_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_SILVERMONT_LER_FROM_LIP 0x000001DD + + +/** + Core. Last Exception Record To Linear IP (R) This area contains a pointer + to the target of the last branch instruction that the processor executed + prior to the last exception that was generated or the last interrupt that + was handled. + + @param ECX MSR_SILVERMONT_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_LER_TO_LIP); + @endcode + @note MSR_SILVERMONT_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_SILVERMONT_LER_TO_LIP 0x000001DE + + +/** + Core. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling + (PEBS).". + + @param ECX MSR_SILVERMONT_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PEBS_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PEBS_ENABLE_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PEBS_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PEBS_ENABLE); + AsmWriteMsr64 (MSR_SILVERMONT_PEBS_ENABLE, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_SILVERMONT_PEBS_ENABLE 0x000003F1 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PEBS_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Enable PEBS for precise event on IA32_PMC0. (R/W). + /// + UINT32 PEBS:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PEBS_ENABLE_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 + Residency Counter. (R/O) Value since last reset that this package is in + processor-specific C6 states. Counts at the TSC Frequency. + + @param ECX MSR_SILVERMONT_PKG_C6_RESIDENCY (0x000003FA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_SILVERMONT_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_SILVERMONT_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_SILVERMONT_PKG_C6_RESIDENCY 0x000003FA + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C6 states. Counts at the TSC Frequency. + + @param ECX MSR_SILVERMONT_CORE_C6_RESIDENCY (0x000003FD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_CORE_C6_RESIDENCY); + AsmWriteMsr64 (MSR_SILVERMONT_CORE_C6_RESIDENCY, Msr); + @endcode + @note MSR_SILVERMONT_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. +**/ +#define MSR_SILVERMONT_CORE_C6_RESIDENCY 0x000003FD + + +/** + Core. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. + + @param ECX MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM (0x0000048C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM); + @endcode + @note MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. +**/ +#define MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM 0x0000048C + + +/** + Core. Capability Reporting Register of VM-function Controls (R/O) See Table + 35-2. + + @param ECX MSR_SILVERMONT_IA32_VMX_FMFUNC (0x00000491) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_IA32_VMX_FMFUNC); + @endcode + @note MSR_SILVERMONT_IA32_VMX_FMFUNC is defined as IA32_VMX_FMFUNC in SDM. +**/ +#define MSR_SILVERMONT_IA32_VMX_FMFUNC 0x00000491 + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C1 + Residency Counter. (R/O) Value since last reset that this core is in + processor-specific C1 states. Counts at the TSC frequency. + + @param ECX MSR_SILVERMONT_CORE_C1_RESIDENCY (0x00000660) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_CORE_C1_RESIDENCY); + AsmWriteMsr64 (MSR_SILVERMONT_CORE_C1_RESIDENCY, Msr); + @endcode + @note MSR_SILVERMONT_CORE_C1_RESIDENCY is defined as MSR_CORE_C1_RESIDENCY in SDM. +**/ +#define MSR_SILVERMONT_CORE_C1_RESIDENCY 0x00000660 + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, + "RAPL Interfaces.". + + @param ECX MSR_SILVERMONT_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_RAPL_POWER_UNIT); + @endcode + @note MSR_SILVERMONT_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_SILVERMONT_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Power Units. Power related information (in milliWatts) is + /// based on the multiplier, 2^PU; where PU is an unsigned integer + /// represented by bits 3:0. Default value is 0101b, indicating power unit + /// is in 32 milliWatts increment. + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Energy Status Units. Energy related information (in + /// microJoules) is based on the multiplier, 2^ESU; where ESU is an + /// unsigned integer represented by bits 12:8. Default value is 00101b, + /// indicating energy unit is in 32 microJoules increment. + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Time Unit. The value is 0000b, indicating time unit is in + /// one second. + /// + UINT32 TimeUnits:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. PKG RAPL Power Limit Control (R/W). + + @param ECX MSR_SILVERMONT_PKG_POWER_LIMIT (0x00000610) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_POWER_LIMIT); + AsmWriteMsr64 (MSR_SILVERMONT_PKG_POWER_LIMIT, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. +**/ +#define MSR_SILVERMONT_PKG_POWER_LIMIT 0x00000610 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PKG_POWER_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Package Power Limit #1. (R/W) See Section 14.9.3, "Package + /// RAPL Domain." and MSR_RAPL_POWER_UNIT in Table 35-8. + /// + UINT32 Limit:15; + /// + /// [Bit 15] Enable Power Limit #1. (R/W) See Section 14.9.3, "Package + /// RAPL Domain.". + /// + UINT32 Enable:1; + /// + /// [Bit 16] Package Clamping Limitation #1. (R/W) See Section 14.9.3, + /// "Package RAPL Domain.". + /// + UINT32 ClampingLimit:1; + /// + /// [Bits 23:17] Time Window for Power Limit #1. (R/W) in unit of second. + /// If 0 is specified in bits [23:17], defaults to 1 second window. + /// + UINT32 Time:7; + UINT32 Reserved1:8; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER; + + +/** + Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain." + and MSR_RAPL_POWER_UNIT in Table 35-8. + + @param ECX MSR_SILVERMONT_PKG_ENERGY_STATUS (0x00000611) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_PKG_ENERGY_STATUS); + @endcode + @note MSR_SILVERMONT_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. +**/ +#define MSR_SILVERMONT_PKG_ENERGY_STATUS 0x00000611 + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains." and MSR_RAPL_POWER_UNIT in Table 35-8. + + @param ECX MSR_SILVERMONT_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_PP0_ENERGY_STATUS); + @endcode + @note MSR_SILVERMONT_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_SILVERMONT_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. Core C6 demotion policy config MSR. Controls per-core C6 demotion + policy. Writing a value of 0 disables core level HW demotion policy. + + @param ECX MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG (0x00000668) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG); + AsmWriteMsr64 (MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG, Msr); + @endcode + @note MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG is defined as MSR_CC6_DEMOTION_POLICY_CONFIG in SDM. +**/ +#define MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG 0x00000668 + + +/** + Package. Module C6 demotion policy config MSR. Controls module (i.e. two + cores sharing the second-level cache) C6 demotion policy. Writing a value of + 0 disables module level HW demotion policy. + + @param ECX MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG (0x00000669) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG); + AsmWriteMsr64 (MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG, Msr); + @endcode + @note MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG is defined as MSR_MC6_DEMOTION_POLICY_CONFIG in SDM. +**/ +#define MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG 0x00000669 + + +/** + Module. Module C6 Residency Counter (R/0) Note: C-state values are processor + specific C-state code names, unrelated to MWAIT extension C-state parameters + or ACPI CStates. Time that this module is in module-specific C6 states since + last reset. Counts at 1 Mhz frequency. + + @param ECX MSR_SILVERMONT_MC6_RESIDENCY_COUNTER (0x00000664) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SILVERMONT_MC6_RESIDENCY_COUNTER); + @endcode + @note MSR_SILVERMONT_MC6_RESIDENCY_COUNTER is defined as MSR_MC6_RESIDENCY_COUNTER in SDM. +**/ +#define MSR_SILVERMONT_MC6_RESIDENCY_COUNTER 0x00000664 + + +/** + Package. PKG RAPL Parameter (R/0). + + @param ECX MSR_SILVERMONT_PKG_POWER_INFO (0x0000066E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_POWER_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PKG_POWER_INFO_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PKG_POWER_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_POWER_INFO); + @endcode + @note MSR_SILVERMONT_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. +**/ +#define MSR_SILVERMONT_PKG_POWER_INFO 0x0000066E + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PKG_POWER_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Thermal Spec Power. (R/0) The unsigned integer value is + /// the equivalent of thermal specification power of the package domain. + /// The unit of this field is specified by the "Power Units" field of + /// MSR_RAPL_POWER_UNIT. + /// + UINT32 ThermalSpecPower:15; + UINT32 Reserved1:17; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PKG_POWER_INFO_REGISTER; + + +/** + Package. PP0 RAPL Power Limit Control (R/W). + + @param ECX MSR_SILVERMONT_PP0_POWER_LIMIT (0x00000638) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER. + + Example usage + @code + MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PP0_POWER_LIMIT); + AsmWriteMsr64 (MSR_SILVERMONT_PP0_POWER_LIMIT, Msr.Uint64); + @endcode + @note MSR_SILVERMONT_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. +**/ +#define MSR_SILVERMONT_PP0_POWER_LIMIT 0x00000638 + +/** + MSR information returned for MSR index #MSR_SILVERMONT_PP0_POWER_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] PP0 Power Limit #1. (R/W) See Section 14.9.4, "PP0/PP1 + /// RAPL Domains." and MSR_RAPL_POWER_UNIT in Table 35-8. + /// + UINT32 Limit:15; + /// + /// [Bit 15] Enable Power Limit #1. (R/W) See Section 14.9.4, "PP0/PP1 + /// RAPL Domains.". + /// + UINT32 Enable:1; + UINT32 Reserved1:1; + /// + /// [Bits 23:17] Time Window for Power Limit #1. (R/W) Specifies the time + /// duration over which the average power must remain below + /// PP0_POWER_LIMIT #1(14:0). Supported Encodings: 0x0: 1 second time + /// duration. 0x1: 5 second time duration (Default). 0x2: 10 second time + /// duration. 0x3: 15 second time duration. 0x4: 20 second time duration. + /// 0x5: 25 second time duration. 0x6: 30 second time duration. 0x7: 35 + /// second time duration. 0x8: 40 second time duration. 0x9: 45 second + /// time duration. 0xA: 50 second time duration. 0xB-0x7F - reserved. + /// + UINT32 Time:7; + UINT32 Reserved2:8; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h new file mode 100644 index 0000000000..7166e5f9e0 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h @@ -0,0 +1,2257 @@ +/** @file + MSR Definitions for Intel processors based on the Skylake microarchitecture. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.15. + +**/ + +#ifndef __SKYLAKE_MSR_H__ +#define __SKYLAKE_MSR_H__ + +#include + +/** + Is Intel processors based on the Skylake microarchitecture? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_SKYLAKE_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x4E || \ + DisplayModel == 0x5E \ + ) \ + ) + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_SKYLAKE_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_TURBO_RATIO_LIMIT); + @endcode + @note MSR_SKYLAKE_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_SKYLAKE_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_SKYLAKE_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-4) + that points to the MSR containing the most recent branch record. + + @param ECX MSR_SKYLAKE_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_SKYLAKE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_SKYLAKE_LASTBRANCH_TOS 0x000001C9 + + +/** + Package. Lower 64 Bit OwnerEpoch Component of SGX Key (RO). Low 64 bits of + an 128-bit external entropy value for key derivation of an enclave. + + @param ECX MSR_SKYLAKE_SGXOWNER0 (0x00000300) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_SGXOWNER0); + @endcode + @note MSR_SKYLAKE_SGXOWNER0 is defined as MSR_SGXOWNER0 in SDM. +**/ +#define MSR_SKYLAKE_SGXOWNER0 0x00000300 + + +/** + Package. Upper 64 Bit OwnerEpoch Component of SGX Key (RO). Upper 64 bits of + an 128-bit external entropy value for key derivation of an enclave. + + @param ECX MSR_SKYLAKE_SGXOWNER1 (0x00000301) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_SGXOWNER1); + @endcode + @note MSR_SKYLAKE_SGXOWNER1 is defined as MSR_SGXOWNER1 in SDM. +**/ +#define MSR_SKYLAKE_SGXOWNER1 0x00000301 + + +/** + See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring + Version 4.". + + @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS (0x0000038E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS 0x0000038E + +/** + MSR information returned for MSR index #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Thread. Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Thread. Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Thread. Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + /// + /// [Bit 4] Thread. Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). + /// + UINT32 Ovf_PMC4:1; + /// + /// [Bit 5] Thread. Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). + /// + UINT32 Ovf_PMC5:1; + /// + /// [Bit 6] Thread. Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). + /// + UINT32 Ovf_PMC6:1; + /// + /// [Bit 7] Thread. Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). + /// + UINT32 Ovf_PMC7:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Thread. Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Thread. Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Thread. Trace_ToPA_PMI. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] Thread. LBR_Frz. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Thread. CTR_Frz. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Thread. ASCI. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Thread. Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Thread. Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + /// + /// [Bit 63] Thread. CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER; + + +/** + See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring + Version 4.". + + @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. + + Example usage + @code + MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET); + AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. +**/ +#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 + +/** + MSR information returned for MSR index + #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Set 1 to clear Ovf_PMC0. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Thread. Set 1 to clear Ovf_PMC1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Thread. Set 1 to clear Ovf_PMC2. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Thread. Set 1 to clear Ovf_PMC3. + /// + UINT32 Ovf_PMC3:1; + /// + /// [Bit 4] Thread. Set 1 to clear Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). + /// + UINT32 Ovf_PMC4:1; + /// + /// [Bit 5] Thread. Set 1 to clear Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). + /// + UINT32 Ovf_PMC5:1; + /// + /// [Bit 6] Thread. Set 1 to clear Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). + /// + UINT32 Ovf_PMC6:1; + /// + /// [Bit 7] Thread. Set 1 to clear Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). + /// + UINT32 Ovf_PMC7:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Set 1 to clear Ovf_FixedCtr0. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Thread. Set 1 to clear Ovf_FixedCtr1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Thread. Set 1 to clear Ovf_FixedCtr2. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Thread. Set 1 to clear Trace_ToPA_PMI. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] Thread. Set 1 to clear LBR_Frz. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Thread. Set 1 to clear CTR_Frz. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Thread. Set 1 to clear ASCI. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Thread. Set 1 to clear Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Thread. Set 1 to clear Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + /// + /// [Bit 63] Thread. Set 1 to clear CondChgd. + /// + UINT32 CondChgd:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; + + +/** + See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring + Version 4.". + + @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. + + Example usage + @code + MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET); + AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. +**/ +#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 + +/** + MSR information returned for MSR index + #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Thread. Set 1 to cause Ovf_PMC0 = 1. + /// + UINT32 Ovf_PMC0:1; + /// + /// [Bit 1] Thread. Set 1 to cause Ovf_PMC1 = 1. + /// + UINT32 Ovf_PMC1:1; + /// + /// [Bit 2] Thread. Set 1 to cause Ovf_PMC2 = 1. + /// + UINT32 Ovf_PMC2:1; + /// + /// [Bit 3] Thread. Set 1 to cause Ovf_PMC3 = 1. + /// + UINT32 Ovf_PMC3:1; + /// + /// [Bit 4] Thread. Set 1 to cause Ovf_PMC4=1 (if CPUID.0AH:EAX[15:8] > 4). + /// + UINT32 Ovf_PMC4:1; + /// + /// [Bit 5] Thread. Set 1 to cause Ovf_PMC5=1 (if CPUID.0AH:EAX[15:8] > 5). + /// + UINT32 Ovf_PMC5:1; + /// + /// [Bit 6] Thread. Set 1 to cause Ovf_PMC6=1 (if CPUID.0AH:EAX[15:8] > 6). + /// + UINT32 Ovf_PMC6:1; + /// + /// [Bit 7] Thread. Set 1 to cause Ovf_PMC7=1 (if CPUID.0AH:EAX[15:8] > 7). + /// + UINT32 Ovf_PMC7:1; + UINT32 Reserved1:24; + /// + /// [Bit 32] Thread. Set 1 to cause Ovf_FixedCtr0 = 1. + /// + UINT32 Ovf_FixedCtr0:1; + /// + /// [Bit 33] Thread. Set 1 to cause Ovf_FixedCtr1 = 1. + /// + UINT32 Ovf_FixedCtr1:1; + /// + /// [Bit 34] Thread. Set 1 to cause Ovf_FixedCtr2 = 1. + /// + UINT32 Ovf_FixedCtr2:1; + UINT32 Reserved2:20; + /// + /// [Bit 55] Thread. Set 1 to cause Trace_ToPA_PMI = 1. + /// + UINT32 Trace_ToPA_PMI:1; + UINT32 Reserved3:2; + /// + /// [Bit 58] Thread. Set 1 to cause LBR_Frz = 1. + /// + UINT32 LBR_Frz:1; + /// + /// [Bit 59] Thread. Set 1 to cause CTR_Frz = 1. + /// + UINT32 CTR_Frz:1; + /// + /// [Bit 60] Thread. Set 1 to cause ASCI = 1. + /// + UINT32 ASCI:1; + /// + /// [Bit 61] Thread. Set 1 to cause Ovf_Uncore. + /// + UINT32 Ovf_Uncore:1; + /// + /// [Bit 62] Thread. Set 1 to cause Ovf_BufDSSAVE. + /// + UINT32 Ovf_BufDSSAVE:1; + UINT32 Reserved4:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; + + +/** + Thread. FrontEnd Precise Event Condition Select (R/W). + + @param ECX MSR_SKYLAKE_PEBS_FRONTEND (0x000003F7) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PEBS_FRONTEND_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PEBS_FRONTEND_REGISTER. + + Example usage + @code + MSR_SKYLAKE_PEBS_FRONTEND_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PEBS_FRONTEND); + AsmWriteMsr64 (MSR_SKYLAKE_PEBS_FRONTEND, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_PEBS_FRONTEND is defined as MSR_PEBS_FRONTEND in SDM. +**/ +#define MSR_SKYLAKE_PEBS_FRONTEND 0x000003F7 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_PEBS_FRONTEND +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Event Code Select. + /// + UINT32 EventCodeSelect:3; + UINT32 Reserved1:1; + /// + /// [Bit 4] Event Code Select High. + /// + UINT32 EventCodeSelectHigh:1; + UINT32 Reserved2:3; + /// + /// [Bits 19:8] IDQ_Bubble_Length Specifier. + /// + UINT32 IDQ_Bubble_Length:12; + /// + /// [Bits 22:20] IDQ_Bubble_Width Specifier. + /// + UINT32 IDQ_Bubble_Width:3; + UINT32 Reserved3:9; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_PEBS_FRONTEND_REGISTER; + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_SKYLAKE_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_PP0_ENERGY_STATUS); + @endcode + @note MSR_SKYLAKE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_SKYLAKE_PP0_ENERGY_STATUS 0x00000639 + + +/** + Platform*. Platform Energy Counter. (R/O). This MSR is valid only if both + platform vendor hardware implementation and BIOS enablement support it. This + MSR will read 0 if not valid. + + @param ECX MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER (0x0000064D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER. + + Example usage + @code + MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER); + @endcode + @note MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER is defined as MSR_PLATFORM_ENERGY_COUNTER in SDM. +**/ +#define MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER 0x0000064D + +/** + MSR information returned for MSR index #MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Total energy consumed by all devices in the platform that + /// receive power from integrated power delivery mechanism, Included + /// platform devices are processor cores, SOC, memory, add-on or + /// peripheral devices that get powered directly from the platform power + /// delivery means. The energy units are specified in the + /// MSR_RAPL_POWER_UNIT.Enery_Status_Unit. + /// + UINT32 TotalEnergy:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER; + + +/** + Thread. Productive Performance Count. (R/O). Hardware's view of workload + scalability. See Section 14.4.5.1. + + @param ECX MSR_SKYLAKE_PPERF (0x0000064E) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_PPERF); + @endcode + @note MSR_SKYLAKE_PPERF is defined as MSR_PPERF in SDM. +**/ +#define MSR_SKYLAKE_PPERF 0x0000064E + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS (0x0000064F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS 0x0000064F + +/** + MSR information returned for MSR index #MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the + /// operating system request due to assertion of external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:2; + /// + /// [Bit 4] Residency State Regulation Status (R0) When set, frequency is + /// reduced below the operating system request due to residency state + /// regulation limit. + /// + UINT32 ResidencyStateRegulationStatus:1; + /// + /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency + /// is reduced below the operating system request due to Running Average + /// Thermal Limit (RATL). + /// + UINT32 RunningAverageThermalLimitStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from a + /// processor Voltage Regulator (VR). + /// + UINT32 VRThermAlertStatus:1; + /// + /// [Bit 7] VR Therm Design Current Status (R0) When set, frequency is + /// reduced below the operating system request due to VR thermal design + /// current limit. + /// + UINT32 VRThermDesignCurrentStatus:1; + /// + /// [Bit 8] Other Status (R0) When set, frequency is reduced below the + /// operating system request due to electrical or other constraints. + /// + UINT32 OtherStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When + /// set, frequency is reduced below the operating system request due to + /// package/platform-level power limiting PL1. + /// + UINT32 PL1Status:1; + /// + /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When + /// set, frequency is reduced below the operating system request due to + /// package/platform-level power limiting PL2/PL3. + /// + UINT32 PL2Status:1; + /// + /// [Bit 12] Max Turbo Limit Status (R0) When set, frequency is reduced + /// below the operating system request due to multi-core turbo limits. + /// + UINT32 MaxTurboLimitStatus:1; + /// + /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency + /// is reduced below the operating system request due to Turbo transition + /// attenuation. This prevents performance degradation due to frequent + /// operating ratio changes. + /// + UINT32 TurboTransitionAttenuationStatus:1; + UINT32 Reserved3:2; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved4:2; + /// + /// [Bit 20] Residency State Regulation Log When set, indicates that the + /// Residency State Regulation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 ResidencyStateRegulationLog:1; + /// + /// [Bit 21] Running Average Thermal Limit Log When set, indicates that + /// the RATL Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 RunningAverageThermalLimitLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + /// + /// [Bit 23] VR Thermal Design Current Log When set, indicates that the + /// VR TDC Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermalDesignCurrentLog:1; + /// + /// [Bit 24] Other Log When set, indicates that the Other Status bit has + /// asserted since the log bit was last cleared. This log bit will remain + /// set until cleared by software writing 0. + /// + UINT32 OtherLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, + /// indicates that the Package or Platform Level PL1 Power Limiting Status + /// bit has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, + /// indicates that the Package or Platform Level PL2/PL3 Power Limiting + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 PL2Log:1; + /// + /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo + /// Limit Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MaxTurboLimitLog:1; + /// + /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the + /// Turbo Transition Attenuation Status bit has asserted since the log bit + /// was last cleared. This log bit will remain set until cleared by + /// software writing 0. + /// + UINT32 TurboTransitionAttenuationLog:1; + UINT32 Reserved6:2; + UINT32 Reserved7:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER; + + +/** + Package. HDC Configuration (R/W).. + + @param ECX MSR_SKYLAKE_PKG_HDC_CONFIG (0x00000652) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER. + + Example usage + @code + MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_CONFIG); + AsmWriteMsr64 (MSR_SKYLAKE_PKG_HDC_CONFIG, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_PKG_HDC_CONFIG is defined as MSR_PKG_HDC_CONFIG in SDM. +**/ +#define MSR_SKYLAKE_PKG_HDC_CONFIG 0x00000652 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_PKG_HDC_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] PKG_Cx_Monitor. Configures Package Cx state threshold for + /// MSR_PKG_HDC_DEEP_RESIDENCY. + /// + UINT32 PKG_Cx_Monitor:3; + UINT32 Reserved1:29; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER; + + +/** + Core. Core HDC Idle Residency. (R/O). Core_Cx_Duty_Cycle_Cnt. + + @param ECX MSR_SKYLAKE_CORE_HDC_RESIDENCY (0x00000653) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_CORE_HDC_RESIDENCY); + @endcode + @note MSR_SKYLAKE_CORE_HDC_RESIDENCY is defined as MSR_CORE_HDC_RESIDENCY in SDM. +**/ +#define MSR_SKYLAKE_CORE_HDC_RESIDENCY 0x00000653 + + +/** + Package. Accumulate the cycles the package was in C2 state and at least one + logical processor was in forced idle. (R/O). Pkg_C2_Duty_Cycle_Cnt. + + @param ECX MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY (0x00000655) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY); + @endcode + @note MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY is defined as MSR_PKG_HDC_SHALLOW_RESIDENCY in SDM. +**/ +#define MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY 0x00000655 + + +/** + Package. Package Cx HDC Idle Residency. (R/O). Pkg_Cx_Duty_Cycle_Cnt. + + @param ECX MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY (0x00000656) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY); + @endcode + @note MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY is defined as MSR_PKG_HDC_DEEP_RESIDENCY in SDM. +**/ +#define MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY 0x00000656 + + +/** + Package. Core-count Weighted C0 Residency. (R/O). Increment at the same rate + as the TSC. The increment each cycle is weighted by the number of processor + cores in the package that reside in C0. If N cores are simultaneously in C0, + then each cycle the counter increments by N. + + @param ECX MSR_SKYLAKE_WEIGHTED_CORE_C0 (0x00000658) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_WEIGHTED_CORE_C0); + @endcode + @note MSR_SKYLAKE_WEIGHTED_CORE_C0 is defined as MSR_WEIGHTED_CORE_C0 in SDM. +**/ +#define MSR_SKYLAKE_WEIGHTED_CORE_C0 0x00000658 + + +/** + Package. Any Core C0 Residency. (R/O). Increment at the same rate as the + TSC. The increment each cycle is one if any processor core in the package is + in C0. + + @param ECX MSR_SKYLAKE_ANY_CORE_C0 (0x00000659) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_ANY_CORE_C0); + @endcode + @note MSR_SKYLAKE_ANY_CORE_C0 is defined as MSR_ANY_CORE_C0 in SDM. +**/ +#define MSR_SKYLAKE_ANY_CORE_C0 0x00000659 + + +/** + Package. Any Graphics Engine C0 Residency. (R/O). Increment at the same rate + as the TSC. The increment each cycle is one if any processor graphic + device's compute engines are in C0. + + @param ECX MSR_SKYLAKE_ANY_GFXE_C0 (0x0000065A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_ANY_GFXE_C0); + @endcode + @note MSR_SKYLAKE_ANY_GFXE_C0 is defined as MSR_ANY_GFXE_C0 in SDM. +**/ +#define MSR_SKYLAKE_ANY_GFXE_C0 0x0000065A + + +/** + Package. Core and Graphics Engine Overlapped C0 Residency. (R/O). Increment + at the same rate as the TSC. The increment each cycle is one if at least one + compute engine of the processor graphics is in C0 and at least one processor + core in the package is also in C0. + + @param ECX MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 (0x0000065B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0); + @endcode + @note MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 is defined as MSR_CORE_GFXE_OVERLAP_C0 in SDM. +**/ +#define MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 0x0000065B + + +/** + Platform*. Platform Power Limit Control (R/W-L) Allows platform BIOS to + limit power consumption of the platform devices to the specified values. The + Long Duration power consumption is specified via Platform_Power_Limit_1 and + Platform_Power_Limit_1_Time. The Short Duration power consumption limit is + specified via the Platform_Power_Limit_2 with duration chosen by the + processor. The processor implements an exponential-weighted algorithm in the + placement of the time windows. + + @param ECX MSR_SKYLAKE_PLATFORM_POWER_LIMIT (0x0000065C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER. + + Example usage + @code + MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PLATFORM_POWER_LIMIT); + AsmWriteMsr64 (MSR_SKYLAKE_PLATFORM_POWER_LIMIT, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_PLATFORM_POWER_LIMIT is defined as MSR_PLATFORM_POWER_LIMIT in SDM. +**/ +#define MSR_SKYLAKE_PLATFORM_POWER_LIMIT 0x0000065C + +/** + MSR information returned for MSR index #MSR_SKYLAKE_PLATFORM_POWER_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 14:0] Platform Power Limit #1. Average Power limit value which + /// the platform must not exceed over a time window as specified by + /// Power_Limit_1_TIME field. The default value is the Thermal Design + /// Power (TDP) and varies with product skus. The unit is specified in + /// MSR_RAPLPOWER_UNIT. + /// + UINT32 PlatformPowerLimit1:15; + /// + /// [Bit 15] Enable Platform Power Limit #1. When set, enables the + /// processor to apply control policy such that the platform power does + /// not exceed Platform Power limit #1 over the time window specified by + /// Power Limit #1 Time Window. + /// + UINT32 EnablePlatformPowerLimit1:1; + /// + /// [Bit 16] Platform Clamping Limitation #1. When set, allows the + /// processor to go below the OS requested P states in order to maintain + /// the power below specified Platform Power Limit #1 value. This bit is + /// writeable only when CPUID (EAX=6):EAX[4] is set. + /// + UINT32 PlatformClampingLimitation1:1; + /// + /// [Bits 23:17] Time Window for Platform Power Limit #1. Specifies the + /// duration of the time window over which Platform Power Limit 1 value + /// should be maintained for sustained long duration. This field is made + /// up of two numbers from the following equation: Time Window = (float) + /// ((1+(X/4))*(2^Y)), where: X. = POWER_LIMIT_1_TIME[23:22] Y. = + /// POWER_LIMIT_1_TIME[21:17]. The maximum allowed value in this field is + /// defined in MSR_PKG_POWER_INFO[PKG_MAX_WIN]. The default value is 0DH, + /// The unit is specified in MSR_RAPLPOWER_UNIT[Time Unit]. + /// + UINT32 Time:7; + UINT32 Reserved1:8; + /// + /// [Bits 46:32] Platform Power Limit #2. Average Power limit value which + /// the platform must not exceed over the Short Duration time window + /// chosen by the processor. The recommended default value is 1.25 times + /// the Long Duration Power Limit (i.e. Platform Power Limit # 1). + /// + UINT32 PlatformPowerLimit2:15; + /// + /// [Bit 47] Enable Platform Power Limit #2. When set, enables the + /// processor to apply control policy such that the platform power does + /// not exceed Platform Power limit #2 over the Short Duration time window. + /// + UINT32 EnablePlatformPowerLimit2:1; + /// + /// [Bit 48] Platform Clamping Limitation #2. When set, allows the + /// processor to go below the OS requested P states in order to maintain + /// the power below specified Platform Power Limit #2 value. + /// + UINT32 PlatformClampingLimitation2:1; + UINT32 Reserved2:14; + /// + /// [Bit 63] Lock. Setting this bit will lock all other bits of this MSR + /// until system RESET. + /// + UINT32 Lock:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER; + + +/** + Thread. Last Branch Record n From IP (R/W) One of 32 triplets of last + branch record registers on the last branch record stack. This part of the + stack contains pointers to the source instruction. See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.10. + + @param ECX MSR_SKYLAKE_LASTBRANCH_n_FROM_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_16_FROM_IP); + AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_16_FROM_IP, Msr); + @endcode + @note MSR_SKYLAKE_LASTBRANCH_16_FROM_IP is defined as MSR_LASTBRANCH_16_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_17_FROM_IP is defined as MSR_LASTBRANCH_17_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_18_FROM_IP is defined as MSR_LASTBRANCH_18_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_19_FROM_IP is defined as MSR_LASTBRANCH_19_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_20_FROM_IP is defined as MSR_LASTBRANCH_20_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_21_FROM_IP is defined as MSR_LASTBRANCH_21_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_22_FROM_IP is defined as MSR_LASTBRANCH_22_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_23_FROM_IP is defined as MSR_LASTBRANCH_23_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_24_FROM_IP is defined as MSR_LASTBRANCH_24_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_25_FROM_IP is defined as MSR_LASTBRANCH_25_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_26_FROM_IP is defined as MSR_LASTBRANCH_26_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_27_FROM_IP is defined as MSR_LASTBRANCH_27_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_28_FROM_IP is defined as MSR_LASTBRANCH_28_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_29_FROM_IP is defined as MSR_LASTBRANCH_29_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_30_FROM_IP is defined as MSR_LASTBRANCH_30_FROM_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_31_FROM_IP is defined as MSR_LASTBRANCH_31_FROM_IP in SDM. + @{ +**/ +#define MSR_SKYLAKE_LASTBRANCH_16_FROM_IP 0x00000690 +#define MSR_SKYLAKE_LASTBRANCH_17_FROM_IP 0x00000691 +#define MSR_SKYLAKE_LASTBRANCH_18_FROM_IP 0x00000692 +#define MSR_SKYLAKE_LASTBRANCH_19_FROM_IP 0x00000693 +#define MSR_SKYLAKE_LASTBRANCH_20_FROM_IP 0x00000694 +#define MSR_SKYLAKE_LASTBRANCH_21_FROM_IP 0x00000695 +#define MSR_SKYLAKE_LASTBRANCH_22_FROM_IP 0x00000696 +#define MSR_SKYLAKE_LASTBRANCH_23_FROM_IP 0x00000697 +#define MSR_SKYLAKE_LASTBRANCH_24_FROM_IP 0x00000698 +#define MSR_SKYLAKE_LASTBRANCH_25_FROM_IP 0x00000699 +#define MSR_SKYLAKE_LASTBRANCH_26_FROM_IP 0x0000069A +#define MSR_SKYLAKE_LASTBRANCH_27_FROM_IP 0x0000069B +#define MSR_SKYLAKE_LASTBRANCH_28_FROM_IP 0x0000069C +#define MSR_SKYLAKE_LASTBRANCH_29_FROM_IP 0x0000069D +#define MSR_SKYLAKE_LASTBRANCH_30_FROM_IP 0x0000069E +#define MSR_SKYLAKE_LASTBRANCH_31_FROM_IP 0x0000069F +/// @} + + +/** + Package. Indicator of Frequency Clipping in the Processor Graphics (R/W) + (frequency refers to processor graphics frequency). + + @param ECX MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS (0x000006B0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS is defined as MSR_GRAPHICS_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS 0x000006B0 + +/** + MSR information returned for MSR index + #MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced due to + /// assertion of external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced due to a + /// thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:3; + /// + /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency + /// is reduced due to running average thermal limit. + /// + UINT32 RunningAverageThermalLimitStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced due + /// to a thermal alert from a processor Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + /// + /// [Bit 7] VR Thermal Design Current Status (R0) When set, frequency is + /// reduced due to VR TDC limit. + /// + UINT32 VRThermalDesignCurrentStatus:1; + /// + /// [Bit 8] Other Status (R0) When set, frequency is reduced due to + /// electrical or other constraints. + /// + UINT32 OtherStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When + /// set, frequency is reduced due to package/platform-level power limiting + /// PL1. + /// + UINT32 PL1Status:1; + /// + /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When + /// set, frequency is reduced due to package/platform-level power limiting + /// PL2/PL3. + /// + UINT32 PL2Status:1; + /// + /// [Bit 12] Inefficient Operation Status (R0) When set, processor + /// graphics frequency is operating below target frequency. + /// + UINT32 InefficientOperationStatus:1; + UINT32 Reserved3:3; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved4:3; + /// + /// [Bit 21] Running Average Thermal Limit Log When set, indicates that + /// the RATL Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 RunningAverageThermalLimitLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + /// + /// [Bit 23] VR Thermal Design Current Log When set, indicates that the + /// VR Therm Alert Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 VRThermalDesignCurrentLog:1; + /// + /// [Bit 24] Other Log When set, indicates that the OTHER Status bit has + /// asserted since the log bit was last cleared. This log bit will remain + /// set until cleared by software writing 0. + /// + UINT32 OtherLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, + /// indicates that the Package/Platform Level PL1 Power Limiting Status + /// bit has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, + /// indicates that the Package/Platform Level PL2 Power Limiting Status + /// bit has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PL2Log:1; + /// + /// [Bit 28] Inefficient Operation Log When set, indicates that the + /// Inefficient Operation Status bit has asserted since the log bit was + /// last cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 InefficientOperationLog:1; + UINT32 Reserved6:3; + UINT32 Reserved7:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER; + + +/** + Package. Indicator of Frequency Clipping in the Ring Interconnect (R/W) + (frequency refers to ring interconnect in the uncore). + + @param ECX MSR_SKYLAKE_RING_PERF_LIMIT_REASONS (0x000006B1) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_RING_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_SKYLAKE_RING_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_RING_PERF_LIMIT_REASONS is defined as MSR_RING_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_SKYLAKE_RING_PERF_LIMIT_REASONS 0x000006B1 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_RING_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced due to + /// assertion of external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced due to a + /// thermal event. + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:3; + /// + /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency + /// is reduced due to running average thermal limit. + /// + UINT32 RunningAverageThermalLimitStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced due + /// to a thermal alert from a processor Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + /// + /// [Bit 7] VR Thermal Design Current Status (R0) When set, frequency is + /// reduced due to VR TDC limit. + /// + UINT32 VRThermalDesignCurrentStatus:1; + /// + /// [Bit 8] Other Status (R0) When set, frequency is reduced due to + /// electrical or other constraints. + /// + UINT32 OtherStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When + /// set, frequency is reduced due to package/Platform-level power limiting + /// PL1. + /// + UINT32 PL1Status:1; + /// + /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When + /// set, frequency is reduced due to package/Platform-level power limiting + /// PL2/PL3. + /// + UINT32 PL2Status:1; + UINT32 Reserved3:4; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + UINT32 Reserved4:3; + /// + /// [Bit 21] Running Average Thermal Limit Log When set, indicates that + /// the RATL Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 RunningAverageThermalLimitLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + /// + /// [Bit 23] VR Thermal Design Current Log When set, indicates that the + /// VR Therm Alert Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 VRThermalDesignCurrentLog:1; + /// + /// [Bit 24] Other Log When set, indicates that the OTHER Status bit has + /// asserted since the log bit was last cleared. This log bit will remain + /// set until cleared by software writing 0. + /// + UINT32 OtherLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, + /// indicates that the Package/Platform Level PL1 Power Limiting Status + /// bit has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PL1Log:1; + /// + /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, + /// indicates that the Package/Platform Level PL2 Power Limiting Status + /// bit has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PL2Log:1; + UINT32 Reserved6:4; + UINT32 Reserved7:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER; + + +/** + Thread. Last Branch Record n To IP (R/W) One of 32 triplets of last branch + record registers on the last branch record stack. This part of the stack + contains pointers to the destination instruction. See also: - Last Branch + Record Stack TOS at 1C9H - Section 17.10. + + @param ECX MSR_SKYLAKE_LASTBRANCH_n_TO_IP + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_16_TO_IP); + AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_16_TO_IP, Msr); + @endcode + @note MSR_SKYLAKE_LASTBRANCH_16_TO_IP is defined as MSR_LASTBRANCH_16_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_17_TO_IP is defined as MSR_LASTBRANCH_17_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_18_TO_IP is defined as MSR_LASTBRANCH_18_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_19_TO_IP is defined as MSR_LASTBRANCH_19_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_20_TO_IP is defined as MSR_LASTBRANCH_20_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_21_TO_IP is defined as MSR_LASTBRANCH_21_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_22_TO_IP is defined as MSR_LASTBRANCH_22_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_23_TO_IP is defined as MSR_LASTBRANCH_23_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_24_TO_IP is defined as MSR_LASTBRANCH_24_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_25_TO_IP is defined as MSR_LASTBRANCH_25_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_26_TO_IP is defined as MSR_LASTBRANCH_26_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_27_TO_IP is defined as MSR_LASTBRANCH_27_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_28_TO_IP is defined as MSR_LASTBRANCH_28_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_29_TO_IP is defined as MSR_LASTBRANCH_29_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_30_TO_IP is defined as MSR_LASTBRANCH_30_TO_IP in SDM. + MSR_SKYLAKE_LASTBRANCH_31_TO_IP is defined as MSR_LASTBRANCH_31_TO_IP in SDM. + @{ +**/ +#define MSR_SKYLAKE_LASTBRANCH_16_TO_IP 0x000006D0 +#define MSR_SKYLAKE_LASTBRANCH_17_TO_IP 0x000006D1 +#define MSR_SKYLAKE_LASTBRANCH_18_TO_IP 0x000006D2 +#define MSR_SKYLAKE_LASTBRANCH_19_TO_IP 0x000006D3 +#define MSR_SKYLAKE_LASTBRANCH_20_TO_IP 0x000006D4 +#define MSR_SKYLAKE_LASTBRANCH_21_TO_IP 0x000006D5 +#define MSR_SKYLAKE_LASTBRANCH_22_TO_IP 0x000006D6 +#define MSR_SKYLAKE_LASTBRANCH_23_TO_IP 0x000006D7 +#define MSR_SKYLAKE_LASTBRANCH_24_TO_IP 0x000006D8 +#define MSR_SKYLAKE_LASTBRANCH_25_TO_IP 0x000006D9 +#define MSR_SKYLAKE_LASTBRANCH_26_TO_IP 0x000006DA +#define MSR_SKYLAKE_LASTBRANCH_27_TO_IP 0x000006DB +#define MSR_SKYLAKE_LASTBRANCH_28_TO_IP 0x000006DC +#define MSR_SKYLAKE_LASTBRANCH_29_TO_IP 0x000006DD +#define MSR_SKYLAKE_LASTBRANCH_30_TO_IP 0x000006DE +#define MSR_SKYLAKE_LASTBRANCH_31_TO_IP 0x000006DF +/// @} + + +/** + Thread. Last Branch Record n Additional Information (R/W) One of 32 triplet + of last branch record registers on the last branch record stack. This part + of the stack contains flag, TSX-related and elapsed cycle information. See + also: - Last Branch Record Stack TOS at 1C9H - Section 17.7.1, "LBR + Stack.". + + @param ECX MSR_SKYLAKE_LBR_INFO_n + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_LBR_INFO_0); + AsmWriteMsr64 (MSR_SKYLAKE_LBR_INFO_0, Msr); + @endcode + @note MSR_SKYLAKE_LBR_INFO_0 is defined as MSR_LBR_INFO_0 in SDM. + MSR_SKYLAKE_LBR_INFO_1 is defined as MSR_LBR_INFO_1 in SDM. + MSR_SKYLAKE_LBR_INFO_2 is defined as MSR_LBR_INFO_2 in SDM. + MSR_SKYLAKE_LBR_INFO_3 is defined as MSR_LBR_INFO_3 in SDM. + MSR_SKYLAKE_LBR_INFO_4 is defined as MSR_LBR_INFO_4 in SDM. + MSR_SKYLAKE_LBR_INFO_5 is defined as MSR_LBR_INFO_5 in SDM. + MSR_SKYLAKE_LBR_INFO_6 is defined as MSR_LBR_INFO_6 in SDM. + MSR_SKYLAKE_LBR_INFO_7 is defined as MSR_LBR_INFO_7 in SDM. + MSR_SKYLAKE_LBR_INFO_8 is defined as MSR_LBR_INFO_8 in SDM. + MSR_SKYLAKE_LBR_INFO_9 is defined as MSR_LBR_INFO_9 in SDM. + MSR_SKYLAKE_LBR_INFO_10 is defined as MSR_LBR_INFO_10 in SDM. + MSR_SKYLAKE_LBR_INFO_11 is defined as MSR_LBR_INFO_11 in SDM. + MSR_SKYLAKE_LBR_INFO_12 is defined as MSR_LBR_INFO_12 in SDM. + MSR_SKYLAKE_LBR_INFO_13 is defined as MSR_LBR_INFO_13 in SDM. + MSR_SKYLAKE_LBR_INFO_14 is defined as MSR_LBR_INFO_14 in SDM. + MSR_SKYLAKE_LBR_INFO_15 is defined as MSR_LBR_INFO_15 in SDM. + MSR_SKYLAKE_LBR_INFO_16 is defined as MSR_LBR_INFO_16 in SDM. + MSR_SKYLAKE_LBR_INFO_17 is defined as MSR_LBR_INFO_17 in SDM. + MSR_SKYLAKE_LBR_INFO_18 is defined as MSR_LBR_INFO_18 in SDM. + MSR_SKYLAKE_LBR_INFO_19 is defined as MSR_LBR_INFO_19 in SDM. + MSR_SKYLAKE_LBR_INFO_20 is defined as MSR_LBR_INFO_20 in SDM. + MSR_SKYLAKE_LBR_INFO_21 is defined as MSR_LBR_INFO_21 in SDM. + MSR_SKYLAKE_LBR_INFO_22 is defined as MSR_LBR_INFO_22 in SDM. + MSR_SKYLAKE_LBR_INFO_23 is defined as MSR_LBR_INFO_23 in SDM. + MSR_SKYLAKE_LBR_INFO_24 is defined as MSR_LBR_INFO_24 in SDM. + MSR_SKYLAKE_LBR_INFO_25 is defined as MSR_LBR_INFO_25 in SDM. + MSR_SKYLAKE_LBR_INFO_26 is defined as MSR_LBR_INFO_26 in SDM. + MSR_SKYLAKE_LBR_INFO_27 is defined as MSR_LBR_INFO_27 in SDM. + MSR_SKYLAKE_LBR_INFO_28 is defined as MSR_LBR_INFO_28 in SDM. + MSR_SKYLAKE_LBR_INFO_29 is defined as MSR_LBR_INFO_29 in SDM. + MSR_SKYLAKE_LBR_INFO_30 is defined as MSR_LBR_INFO_30 in SDM. + MSR_SKYLAKE_LBR_INFO_31 is defined as MSR_LBR_INFO_31 in SDM. + @{ +**/ +#define MSR_SKYLAKE_LBR_INFO_0 0x00000DC0 +#define MSR_SKYLAKE_LBR_INFO_1 0x00000DC1 +#define MSR_SKYLAKE_LBR_INFO_2 0x00000DC2 +#define MSR_SKYLAKE_LBR_INFO_3 0x00000DC3 +#define MSR_SKYLAKE_LBR_INFO_4 0x00000DC4 +#define MSR_SKYLAKE_LBR_INFO_5 0x00000DC5 +#define MSR_SKYLAKE_LBR_INFO_6 0x00000DC6 +#define MSR_SKYLAKE_LBR_INFO_7 0x00000DC7 +#define MSR_SKYLAKE_LBR_INFO_8 0x00000DC8 +#define MSR_SKYLAKE_LBR_INFO_9 0x00000DC9 +#define MSR_SKYLAKE_LBR_INFO_10 0x00000DCA +#define MSR_SKYLAKE_LBR_INFO_11 0x00000DCB +#define MSR_SKYLAKE_LBR_INFO_12 0x00000DCC +#define MSR_SKYLAKE_LBR_INFO_13 0x00000DCD +#define MSR_SKYLAKE_LBR_INFO_14 0x00000DCE +#define MSR_SKYLAKE_LBR_INFO_15 0x00000DCF +#define MSR_SKYLAKE_LBR_INFO_16 0x00000DD0 +#define MSR_SKYLAKE_LBR_INFO_17 0x00000DD1 +#define MSR_SKYLAKE_LBR_INFO_18 0x00000DD2 +#define MSR_SKYLAKE_LBR_INFO_19 0x00000DD3 +#define MSR_SKYLAKE_LBR_INFO_20 0x00000DD4 +#define MSR_SKYLAKE_LBR_INFO_21 0x00000DD5 +#define MSR_SKYLAKE_LBR_INFO_22 0x00000DD6 +#define MSR_SKYLAKE_LBR_INFO_23 0x00000DD7 +#define MSR_SKYLAKE_LBR_INFO_24 0x00000DD8 +#define MSR_SKYLAKE_LBR_INFO_25 0x00000DD9 +#define MSR_SKYLAKE_LBR_INFO_26 0x00000DDA +#define MSR_SKYLAKE_LBR_INFO_27 0x00000DDB +#define MSR_SKYLAKE_LBR_INFO_28 0x00000DDC +#define MSR_SKYLAKE_LBR_INFO_29 0x00000DDD +#define MSR_SKYLAKE_LBR_INFO_30 0x00000DDE +#define MSR_SKYLAKE_LBR_INFO_31 0x00000DDF +/// @} + + +/** + Package. Uncore fixed counter control (R/W). + + @param ECX MSR_SKYLAKE_UNC_PERF_FIXED_CTRL (0x00000394) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER. + + Example usage + @code + MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTRL); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTRL, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. +**/ +#define MSR_SKYLAKE_UNC_PERF_FIXED_CTRL 0x00000394 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_FIXED_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:20; + /// + /// [Bit 20] Enable overflow propagation. + /// + UINT32 EnableOverflow:1; + UINT32 Reserved2:1; + /// + /// [Bit 22] Enable counting. + /// + UINT32 EnableCounting:1; + UINT32 Reserved3:9; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER; + + +/** + Package. Uncore fixed counter. + + @param ECX MSR_SKYLAKE_UNC_PERF_FIXED_CTR (0x00000395) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER. + + Example usage + @code + MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTR); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTR, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. +**/ +#define MSR_SKYLAKE_UNC_PERF_FIXED_CTR 0x00000395 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_FIXED_CTR +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Current count. + /// + UINT32 CurrentCount:32; + /// + /// [Bits 43:32] Current count. + /// + UINT32 CurrentCountHi:12; + UINT32 Reserved:20; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER; + + +/** + Package. Uncore C-Box configuration information (R/O). + + @param ECX MSR_SKYLAKE_UNC_CBO_CONFIG (0x00000396) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER. + + Example usage + @code + MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_CONFIG); + @endcode + @note MSR_SKYLAKE_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_CONFIG 0x00000396 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_UNC_CBO_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Specifies the number of C-Box units with programmable + /// counters (including processor cores and processor graphics),. + /// + UINT32 CBox:4; + UINT32 Reserved1:28; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER; + + +/** + Package. Uncore Arb unit, performance counter 0. + + @param ECX MSR_SKYLAKE_UNC_ARB_PERFCTR0 (0x000003B0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_ARB_PERFCTR0 0x000003B0 + + +/** + Package. Uncore Arb unit, performance counter 1. + + @param ECX MSR_SKYLAKE_UNC_ARB_PERFCTR1 (0x000003B1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_ARB_PERFCTR1 0x000003B1 + + +/** + Package. Uncore Arb unit, counter 0 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 (0x000003B2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 0x000003B2 + + +/** + Package. Uncore Arb unit, counter 1 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 (0x000003B3) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 is defined as MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 0x000003B3 + + +/** + Package. Uncore C-Box 0, counter 0 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 (0x00000700) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 0x00000700 + + +/** + Package. Uncore C-Box 0, counter 1 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 (0x00000701) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 0x00000701 + + +/** + Package. Uncore C-Box 0, performance counter 0. + + @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 (0x00000706) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 0x00000706 + + +/** + Package. Uncore C-Box 0, performance counter 1. + + @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 (0x00000707) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 0x00000707 + + +/** + Package. Uncore C-Box 1, counter 0 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 (0x00000710) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 0x00000710 + + +/** + Package. Uncore C-Box 1, counter 1 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 (0x00000711) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 0x00000711 + + +/** + Package. Uncore C-Box 1, performance counter 0. + + @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 (0x00000716) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 0x00000716 + + +/** + Package. Uncore C-Box 1, performance counter 1. + + @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 (0x00000717) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 0x00000717 + + +/** + Package. Uncore C-Box 2, counter 0 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 (0x00000720) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 0x00000720 + + +/** + Package. Uncore C-Box 2, counter 1 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 (0x00000721) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 0x00000721 + + +/** + Package. Uncore C-Box 2, performance counter 0. + + @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 (0x00000726) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 0x00000726 + + +/** + Package. Uncore C-Box 2, performance counter 1. + + @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 (0x00000727) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 0x00000727 + + +/** + Package. Uncore C-Box 3, counter 0 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 (0x00000730) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 0x00000730 + + +/** + Package. Uncore C-Box 3, counter 1 event select MSR. + + @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 (0x00000731) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 0x00000731 + + +/** + Package. Uncore C-Box 3, performance counter 0. + + @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 (0x00000736) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR0); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR0, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 0x00000736 + + +/** + Package. Uncore C-Box 3, performance counter 1. + + @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 (0x00000737) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR1); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR1, Msr); + @endcode + @note MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. +**/ +#define MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 0x00000737 + + +/** + Package. Uncore PMU global control. + + @param ECX MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL (0x00000E01) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER. + + Example usage + @code + MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. +**/ +#define MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL 0x00000E01 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Slice 0 select. + /// + UINT32 PMI_Sel_Slice0:1; + /// + /// [Bit 1] Slice 1 select. + /// + UINT32 PMI_Sel_Slice1:1; + /// + /// [Bit 2] Slice 2 select. + /// + UINT32 PMI_Sel_Slice2:1; + /// + /// [Bit 3] Slice 3 select. + /// + UINT32 PMI_Sel_Slice3:1; + /// + /// [Bit 4] Slice 4select. + /// + UINT32 PMI_Sel_Slice4:1; + UINT32 Reserved1:14; + UINT32 Reserved2:10; + /// + /// [Bit 29] Enable all uncore counters. + /// + UINT32 EN:1; + /// + /// [Bit 30] Enable wake on PMI. + /// + UINT32 WakePMI:1; + /// + /// [Bit 31] Enable Freezing counter when overflow. + /// + UINT32 FREEZE:1; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER; + + +/** + Package. Uncore PMU main status. + + @param ECX MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS (0x00000E02) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER. + + Example usage + @code + MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS); + AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); + @endcode + @note MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. +**/ +#define MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS 0x00000E02 + +/** + MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fixed counter overflowed. + /// + UINT32 Fixed:1; + /// + /// [Bit 1] An ARB counter overflowed. + /// + UINT32 ARB:1; + UINT32 Reserved1:1; + /// + /// [Bit 3] A CBox counter overflowed (on any slice). + /// + UINT32 CBox:1; + UINT32 Reserved2:28; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h b/Core/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h new file mode 100644 index 0000000000..ad7128ae95 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h @@ -0,0 +1,203 @@ +/** @file + MSR Definitions for Intel(R) Xeon(R) Processor Series 5600. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.7. + +**/ + +#ifndef __XEON_5600_MSR_H__ +#define __XEON_5600_MSR_H__ + +#include + +/** + Is Intel(R) Xeon(R) Processor Series 5600? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_XEON_5600_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x25 || \ + DisplayModel == 0x2C \ + ) \ + ) + +/** + Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP + handler to handle unsuccessful read of this MSR. + + @param ECX MSR_XEON_5600_FEATURE_CONFIG (0x0000013C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_5600_FEATURE_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_5600_FEATURE_CONFIG_REGISTER. + + Example usage + @code + MSR_XEON_5600_FEATURE_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_5600_FEATURE_CONFIG); + AsmWriteMsr64 (MSR_XEON_5600_FEATURE_CONFIG, Msr.Uint64); + @endcode + @note MSR_XEON_5600_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. +**/ +#define MSR_XEON_5600_FEATURE_CONFIG 0x0000013C + +/** + MSR information returned for MSR index #MSR_XEON_5600_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this + /// MSR, the configuration of AES instruction set availability is as + /// follows: 11b: AES instructions are not available until next RESET. + /// otherwise, AES instructions are available. Note, AES instruction set + /// is not available if read is unsuccessful. If the configuration is not + /// 01b, AES instruction can be mis-configured if a privileged agent + /// unintentionally writes 11b. + /// + UINT32 AESConfiguration:2; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_5600_FEATURE_CONFIG_REGISTER; + + +/** + Thread. Offcore Response Event Select Register (R/W). + + @param ECX MSR_XEON_5600_OFFCORE_RSP_1 (0x000001A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_5600_OFFCORE_RSP_1); + AsmWriteMsr64 (MSR_XEON_5600_OFFCORE_RSP_1, Msr); + @endcode + @note MSR_XEON_5600_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. +**/ +#define MSR_XEON_5600_OFFCORE_RSP_1 0x000001A7 + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_XEON_5600_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_5600_TURBO_RATIO_LIMIT); + @endcode + @note MSR_XEON_5600_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_XEON_5600_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio + /// limit of 1 core active. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio + /// limit of 2 core active. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio + /// limit of 3 core active. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio + /// limit of 4 core active. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio + /// limit of 5 core active. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio + /// limit of 6 core active. + /// + UINT32 Maximum6C:8; + UINT32 Reserved:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. See Table 35-2. + + @param ECX MSR_XEON_5600_IA32_ENERGY_PERF_BIAS (0x000001B0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_5600_IA32_ENERGY_PERF_BIAS); + AsmWriteMsr64 (MSR_XEON_5600_IA32_ENERGY_PERF_BIAS, Msr); + @endcode + @note MSR_XEON_5600_IA32_ENERGY_PERF_BIAS is defined as IA32_ENERGY_PERF_BIAS in SDM. +**/ +#define MSR_XEON_5600_IA32_ENERGY_PERF_BIAS 0x000001B0 + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h new file mode 100644 index 0000000000..7b31288a35 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h @@ -0,0 +1,1219 @@ +/** @file + MSR Definitions for Intel(R) Xeon(R) Processor D product Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.14. + +**/ + +#ifndef __XEON_D_MSR_H__ +#define __XEON_D_MSR_H__ + +#include + +/** + Is Intel(R) Xeon(R) Processor D product Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_XEON_D_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x4F || \ + DisplayModel == 0x56 \ + ) \ + ) + +/** + Package. Protected Processor Inventory Number Enable Control (R/W). + + @param ECX MSR_XEON_D_PPIN_CTL (0x0000004E) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_PPIN_CTL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_PPIN_CTL_REGISTER. + + Example usage + @code + MSR_XEON_D_PPIN_CTL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PPIN_CTL); + AsmWriteMsr64 (MSR_XEON_D_PPIN_CTL, Msr.Uint64); + @endcode + @note MSR_XEON_D_PPIN_CTL is defined as MSR_PPIN_CTL in SDM. +**/ +#define MSR_XEON_D_PPIN_CTL 0x0000004E + +/** + MSR information returned for MSR index #MSR_XEON_D_PPIN_CTL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] LockOut (R/WO) See Table 35-24. + /// + UINT32 LockOut:1; + /// + /// [Bit 1] Enable_PPIN (R/W) See Table 35-24. + /// + UINT32 Enable_PPIN:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_PPIN_CTL_REGISTER; + + +/** + Package. Protected Processor Inventory Number (R/O). Protected Processor + Inventory Number (R/O) See Table 35-24. + + @param ECX MSR_XEON_D_PPIN (0x0000004F) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_D_PPIN); + @endcode + @note MSR_XEON_D_PPIN is defined as MSR_PPIN in SDM. +**/ +#define MSR_XEON_D_PPIN 0x0000004F + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_XEON_D_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_XEON_D_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PLATFORM_INFO); + AsmWriteMsr64 (MSR_XEON_D_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_XEON_D_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_XEON_D_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_XEON_D_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) See Table 35-24. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:7; + /// + /// [Bit 23] Package. PPIN_CAP (R/O) See Table 35-24. + /// + UINT32 PPIN_CAP:1; + UINT32 Reserved3:4; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) See + /// Table 35-24. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) See + /// Table 35-24. + /// + UINT32 TDPLimit:1; + /// + /// [Bit 30] Package. Programmable TJ OFFSET (R/O) See Table 35-24. + /// + UINT32 TJOFFSET:1; + UINT32 Reserved4:1; + UINT32 Reserved5:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) See Table 35-24. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved6:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_PLATFORM_INFO_REGISTER; + + +/** + Core. C-State Configuration Control (R/W) Note: C-state values are processor + specific C-state code names, unrelated to MWAIT extension C-state parameters + or ACPI C-states. `See http://biosbits.org. `__. + + @param ECX MSR_XEON_D_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_XEON_D_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_XEON_D_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_XEON_D_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_XEON_D_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest + /// processor-specific C-state code name (consuming the least power) for + /// the package. The default is set as factory-configured package C-state + /// limit. The following C-state code name encodings are supported: 000b: + /// C0/C1 (no package C-state support) 001b: C2 010b: C6 (non-retention) + /// 011b: C6 (retention) 111b: No Package C state limits. All C states + /// supported by the processor are available. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W). + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO). + /// + UINT32 CFGLock:1; + /// + /// [Bit 16] Automatic C-State Conversion Enable (R/W) If 1, the processor + /// will convert HALT or MWAT(C1) to MWAIT(C6). + /// + UINT32 CStateConversion:1; + UINT32 Reserved3:8; + /// + /// [Bit 25] C3 State Auto Demotion Enable (R/W). + /// + UINT32 C3AutoDemotion:1; + /// + /// [Bit 26] C1 State Auto Demotion Enable (R/W). + /// + UINT32 C1AutoDemotion:1; + /// + /// [Bit 27] Enable C3 Undemotion (R/W). + /// + UINT32 C3Undemotion:1; + /// + /// [Bit 28] Enable C1 Undemotion (R/W). + /// + UINT32 C1Undemotion:1; + /// + /// [Bit 29] Package C State Demotion Enable (R/W). + /// + UINT32 CStateDemotion:1; + /// + /// [Bit 30] Package C State UnDemotion Enable (R/W). + /// + UINT32 CStateUndemotion:1; + UINT32 Reserved4:1; + UINT32 Reserved5:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Thread. Global Machine Check Capability (R/O). + + @param ECX MSR_XEON_D_IA32_MCG_CAP (0x00000179) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_MCG_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_MCG_CAP_REGISTER. + + Example usage + @code + MSR_XEON_D_IA32_MCG_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_MCG_CAP); + @endcode + @note MSR_XEON_D_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. +**/ +#define MSR_XEON_D_IA32_MCG_CAP 0x00000179 + +/** + MSR information returned for MSR index #MSR_XEON_D_IA32_MCG_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Count. + /// + UINT32 Count:8; + /// + /// [Bit 8] MCG_CTL_P. + /// + UINT32 MCG_CTL_P:1; + /// + /// [Bit 9] MCG_EXT_P. + /// + UINT32 MCG_EXT_P:1; + /// + /// [Bit 10] MCP_CMCI_P. + /// + UINT32 MCP_CMCI_P:1; + /// + /// [Bit 11] MCG_TES_P. + /// + UINT32 MCG_TES_P:1; + UINT32 Reserved1:4; + /// + /// [Bits 23:16] MCG_EXT_CNT. + /// + UINT32 MCG_EXT_CNT:8; + /// + /// [Bit 24] MCG_SER_P. + /// + UINT32 MCG_SER_P:1; + /// + /// [Bit 25] MCG_EM_P. + /// + UINT32 MCG_EM_P:1; + /// + /// [Bit 26] MCG_ELOG_P. + /// + UINT32 MCG_ELOG_P:1; + UINT32 Reserved2:5; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_IA32_MCG_CAP_REGISTER; + + +/** + THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_XEON_D_SMM_MCA_CAP (0x0000017D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_SMM_MCA_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_SMM_MCA_CAP_REGISTER. + + Example usage + @code + MSR_XEON_D_SMM_MCA_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_SMM_MCA_CAP); + AsmWriteMsr64 (MSR_XEON_D_SMM_MCA_CAP, Msr.Uint64); + @endcode + @note MSR_XEON_D_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. +**/ +#define MSR_XEON_D_SMM_MCA_CAP 0x0000017D + +/** + MSR information returned for MSR index #MSR_XEON_D_SMM_MCA_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:26; + /// + /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the + /// SMM code access restriction is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 SMM_Code_Access_Chk:1; + /// + /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the + /// SMM long flow indicator is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 Long_Flow_Indication:1; + UINT32 Reserved3:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_SMM_MCA_CAP_REGISTER; + + +/** + Package. + + @param ECX MSR_XEON_D_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_XEON_D_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_XEON_D_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_XEON_D_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_XEON_D_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_XEON_D_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (RO) See Table 35-24. + /// + UINT32 TemperatureTarget:8; + /// + /// [Bits 27:24] TCC Activation Offset (R/W) See Table 35-24. + /// + UINT32 TCCActivationOffset:4; + UINT32 Reserved2:4; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_TEMPERATURE_TARGET_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT); + @endcode + @note MSR_XEON_D_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_XEON_D_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 1C. + /// + UINT32 Maximum1C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 2C. + /// + UINT32 Maximum2C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 3C. + /// + UINT32 Maximum3C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 4C. + /// + UINT32 Maximum4C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 5C. + /// + UINT32 Maximum5C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 6C. + /// + UINT32 Maximum6C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 7C. + /// + UINT32 Maximum7C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for 8C. + /// + UINT32 Maximum8C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT1 (0x000001AE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER. + + Example usage + @code + MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT1); + @endcode + @note MSR_XEON_D_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. +**/ +#define MSR_XEON_D_TURBO_RATIO_LIMIT1 0x000001AE + +/** + MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT1 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] Package. Maximum Ratio Limit for 9C. + /// + UINT32 Maximum9C:8; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for 10C. + /// + UINT32 Maximum10C:8; + /// + /// [Bits 23:16] Package. Maximum Ratio Limit for 11C. + /// + UINT32 Maximum11C:8; + /// + /// [Bits 31:24] Package. Maximum Ratio Limit for 12C. + /// + UINT32 Maximum12C:8; + /// + /// [Bits 39:32] Package. Maximum Ratio Limit for 13C. + /// + UINT32 Maximum13C:8; + /// + /// [Bits 47:40] Package. Maximum Ratio Limit for 14C. + /// + UINT32 Maximum14C:8; + /// + /// [Bits 55:48] Package. Maximum Ratio Limit for 15C. + /// + UINT32 Maximum15C:8; + /// + /// [Bits 63:56] Package. Maximum Ratio Limit for 16C. + /// + UINT32 Maximum16C:8; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER; + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O). + + @param ECX MSR_XEON_D_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_XEON_D_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_RAPL_POWER_UNIT); + @endcode + @note MSR_XEON_D_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_XEON_D_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_XEON_D_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Package. Energy Status Units Energy related information + /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an + /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 + /// micro-joules). + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL + /// Interfaces.". + /// + UINT32 TimeUnits:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_XEON_D_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_XEON_D_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_XEON_D_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_XEON_D_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) Energy consumed by DRAM devices. + + @param ECX MSR_XEON_D_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER. + + Example usage + @code + MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_DRAM_ENERGY_STATUS); + @endcode + @note MSR_XEON_D_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_XEON_D_DRAM_ENERGY_STATUS 0x00000619 + +/** + MSR information returned for MSR index #MSR_XEON_D_DRAM_ENERGY_STATUS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] Energy in 15.3 micro-joules. Requires BIOS configuration + /// to enable DRAM RAPL mode 0 (Direct VR). + /// + UINT32 Energy:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER; + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_XEON_D_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_PERF_STATUS); + @endcode + @note MSR_XEON_D_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_XEON_D_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_XEON_D_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_XEON_D_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_XEON_D_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_XEON_D_DRAM_POWER_INFO 0x0000061C + + +/** + Package. Reserved (R/O) Reads return 0. + + @param ECX MSR_XEON_D_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_D_PP0_ENERGY_STATUS); + @endcode + @note MSR_XEON_D_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_XEON_D_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_XEON_D_CORE_PERF_LIMIT_REASONS (0x00000690) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_XEON_D_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_XEON_D_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_XEON_D_CORE_PERF_LIMIT_REASONS 0x00000690 + +/** + MSR information returned for MSR index #MSR_XEON_D_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is + /// reduced below the operating system request due to assertion of + /// external PROCHOT. + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the + /// operating system request due to a thermal event. + /// + UINT32 ThermalStatus:1; + /// + /// [Bit 2] Power Budget Management Status (R0) When set, frequency is + /// reduced below the operating system request due to PBM limit. + /// + UINT32 PowerBudgetManagementStatus:1; + /// + /// [Bit 3] Platform Configuration Services Status (R0) When set, + /// frequency is reduced below the operating system request due to PCS + /// limit. + /// + UINT32 PlatformConfigurationServicesStatus:1; + UINT32 Reserved1:1; + /// + /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) + /// When set, frequency is reduced below the operating system request + /// because the processor has detected that utilization is low. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; + /// + /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced + /// below the operating system request due to a thermal alert from the + /// Voltage Regulator. + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is + /// reduced below the operating system request due to electrical design + /// point constraints (e.g. maximum electrical current consumption). + /// + UINT32 ElectricalDesignPointStatus:1; + UINT32 Reserved3:1; + /// + /// [Bit 10] Multi-Core Turbo Status (R0) When set, frequency is reduced + /// below the operating system request due to Multi-Core Turbo limits. + /// + UINT32 MultiCoreTurboStatus:1; + UINT32 Reserved4:2; + /// + /// [Bit 13] Core Frequency P1 Status (R0) When set, frequency is reduced + /// below max non-turbo P1. + /// + UINT32 FrequencyP1Status:1; + /// + /// [Bit 14] Core Max n-core Turbo Frequency Limiting Status (R0) When + /// set, frequency is reduced below max n-core turbo frequency. + /// + UINT32 TurboFrequencyLimitingStatus:1; + /// + /// [Bit 15] Core Frequency Limiting Status (R0) When set, frequency is + /// reduced below the operating system request. + /// + UINT32 FrequencyLimitingStatus:1; + /// + /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 PROCHOT_Log:1; + /// + /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 ThermalLog:1; + /// + /// [Bit 18] Power Budget Management Log When set, indicates that the PBM + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 PowerBudgetManagementLog:1; + /// + /// [Bit 19] Platform Configuration Services Log When set, indicates that + /// the PCS Status bit has asserted since the log bit was last cleared. + /// This log bit will remain set until cleared by software writing 0. + /// + UINT32 PlatformConfigurationServicesLog:1; + UINT32 Reserved5:1; + /// + /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, + /// indicates that the AUBFC Status bit has asserted since the log bit was + /// last cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; + /// + /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm + /// Alert Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 VRThermAlertLog:1; + UINT32 Reserved6:1; + /// + /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP + /// Status bit has asserted since the log bit was last cleared. This log + /// bit will remain set until cleared by software writing 0. + /// + UINT32 ElectricalDesignPointLog:1; + UINT32 Reserved7:1; + /// + /// [Bit 26] Multi-Core Turbo Log When set, indicates that the Multi-Core + /// Turbo Status bit has asserted since the log bit was last cleared. This + /// log bit will remain set until cleared by software writing 0. + /// + UINT32 MultiCoreTurboLog:1; + UINT32 Reserved8:2; + /// + /// [Bit 29] Core Frequency P1 Log When set, indicates that the Core + /// Frequency P1 Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CoreFrequencyP1Log:1; + /// + /// [Bit 30] Core Max n-core Turbo Frequency Limiting Log When set, + /// indicates that the Core Max n-core Turbo Frequency Limiting Status bit + /// has asserted since the log bit was last cleared. This log bit will + /// remain set until cleared by software writing 0. + /// + UINT32 TurboFrequencyLimitingLog:1; + /// + /// [Bit 31] Core Frequency Limiting Log When set, indicates that the Core + /// Frequency Limiting Status bit has asserted since the log bit was last + /// cleared. This log bit will remain set until cleared by software + /// writing 0. + /// + UINT32 CoreFrequencyLimitingLog:1; + UINT32 Reserved9:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER; + + +/** + THREAD. Monitoring Event Select Register (R/W) if CPUID.(EAX=07H, + ECX=0):EBX.RDT-M[bit 12] = 1. + + @param ECX MSR_XEON_D_IA32_QM_EVTSEL (0x00000C8D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_QM_EVTSEL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_QM_EVTSEL_REGISTER. + + Example usage + @code + MSR_XEON_D_IA32_QM_EVTSEL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_QM_EVTSEL); + AsmWriteMsr64 (MSR_XEON_D_IA32_QM_EVTSEL, Msr.Uint64); + @endcode + @note MSR_XEON_D_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. +**/ +#define MSR_XEON_D_IA32_QM_EVTSEL 0x00000C8D + +/** + MSR information returned for MSR index #MSR_XEON_D_IA32_QM_EVTSEL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 7:0] EventID (RW) Event encoding: 0x00: no monitoring 0x01: L3 + /// occupancy monitoring 0x02: Total memory bandwidth monitoring 0x03: + /// Local memory bandwidth monitoring All other encoding reserved. + /// + UINT32 EventID:8; + UINT32 Reserved1:24; + /// + /// [Bits 41:32] RMID (RW). + /// + UINT32 RMID:10; + UINT32 Reserved2:22; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_IA32_QM_EVTSEL_REGISTER; + + +/** + THREAD. Resource Association Register (R/W). + + @param ECX MSR_XEON_D_IA32_PQR_ASSOC (0x00000C8F) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_PQR_ASSOC_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_PQR_ASSOC_REGISTER. + + Example usage + @code + MSR_XEON_D_IA32_PQR_ASSOC_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_PQR_ASSOC); + AsmWriteMsr64 (MSR_XEON_D_IA32_PQR_ASSOC, Msr.Uint64); + @endcode + @note MSR_XEON_D_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. +**/ +#define MSR_XEON_D_IA32_PQR_ASSOC 0x00000C8F + +/** + MSR information returned for MSR index #MSR_XEON_D_IA32_PQR_ASSOC +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 9:0] RMID. + /// + UINT32 RMID:10; + UINT32 Reserved1:22; + /// + /// [Bits 51:32] COS (R/W). + /// + UINT32 COS:20; + UINT32 Reserved2:12; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_IA32_PQR_ASSOC_REGISTER; + + +/** + Package. L3 Class Of Service Mask - COS n (R/W) if CPUID.(EAX=10H, + ECX=1):EDX.COS_MAX[15:0] >= n. + + @param ECX MSR_XEON_D_IA32_L3_QOS_MASK_n + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER. + + Example usage + @code + MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_L3_QOS_MASK_0); + AsmWriteMsr64 (MSR_XEON_D_IA32_L3_QOS_MASK_0, Msr.Uint64); + @endcode + @note MSR_XEON_D_IA32_L3_QOS_MASK_0 is defined as IA32_L3_QOS_MASK_0 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_1 is defined as IA32_L3_QOS_MASK_1 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_2 is defined as IA32_L3_QOS_MASK_2 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_3 is defined as IA32_L3_QOS_MASK_3 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_4 is defined as IA32_L3_QOS_MASK_4 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_5 is defined as IA32_L3_QOS_MASK_5 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_6 is defined as IA32_L3_QOS_MASK_6 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_7 is defined as IA32_L3_QOS_MASK_7 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_8 is defined as IA32_L3_QOS_MASK_8 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_9 is defined as IA32_L3_QOS_MASK_9 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_10 is defined as IA32_L3_QOS_MASK_10 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_11 is defined as IA32_L3_QOS_MASK_11 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_12 is defined as IA32_L3_QOS_MASK_12 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_13 is defined as IA32_L3_QOS_MASK_13 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_14 is defined as IA32_L3_QOS_MASK_14 in SDM. + MSR_XEON_D_IA32_L3_QOS_MASK_15 is defined as IA32_L3_QOS_MASK_15 in SDM. + @{ +**/ +#define MSR_XEON_D_IA32_L3_QOS_MASK_0 0x00000C90 +#define MSR_XEON_D_IA32_L3_QOS_MASK_1 0x00000C91 +#define MSR_XEON_D_IA32_L3_QOS_MASK_2 0x00000C92 +#define MSR_XEON_D_IA32_L3_QOS_MASK_3 0x00000C93 +#define MSR_XEON_D_IA32_L3_QOS_MASK_4 0x00000C94 +#define MSR_XEON_D_IA32_L3_QOS_MASK_5 0x00000C95 +#define MSR_XEON_D_IA32_L3_QOS_MASK_6 0x00000C96 +#define MSR_XEON_D_IA32_L3_QOS_MASK_7 0x00000C97 +#define MSR_XEON_D_IA32_L3_QOS_MASK_8 0x00000C98 +#define MSR_XEON_D_IA32_L3_QOS_MASK_9 0x00000C99 +#define MSR_XEON_D_IA32_L3_QOS_MASK_10 0x00000C9A +#define MSR_XEON_D_IA32_L3_QOS_MASK_11 0x00000C9B +#define MSR_XEON_D_IA32_L3_QOS_MASK_12 0x00000C9C +#define MSR_XEON_D_IA32_L3_QOS_MASK_13 0x00000C9D +#define MSR_XEON_D_IA32_L3_QOS_MASK_14 0x00000C9E +#define MSR_XEON_D_IA32_L3_QOS_MASK_15 0x00000C9F +/// @} + +/** + MSR information returned for MSR indexes #MSR_XEON_D_IA32_L3_QOS_MASK_0 + to #MSR_XEON_D_IA32_L3_QOS_MASK_15. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 19:0] CBM: Bit vector of available L3 ways for COS 0 enforcement. + /// + UINT32 CBM:20; + UINT32 Reserved2:12; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER; + + +/** + Package. Config Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, + RW if MSR_PLATFORM_INFO.[28] = 1. + + @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT3 (0x000001AC) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER. + + Example usage + @code + MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT3); + @endcode + @note MSR_XEON_D_TURBO_RATIO_LIMIT3 is defined as MSR_TURBO_RATIO_LIMIT3 in SDM. +**/ +#define MSR_XEON_D_TURBO_RATIO_LIMIT3 0x000001AC + +/** + MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT3 +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:31; + /// + /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, + /// the processor uses override configuration specified in + /// MSR_TURBO_RATIO_LIMIT, MSR_TURBO_RATIO_LIMIT1. If 0, the processor + /// uses factory-set configuration (Default). + /// + UINT32 TurboRatioLimitConfigurationSemaphore:1; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER; + + +/** + Package. Cache Allocation Technology Configuration (R/W). + + @param ECX MSR_XEON_D_IA32_L3_QOS_CFG (0x00000C81) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER. + + Example usage + @code + MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_L3_QOS_CFG); + AsmWriteMsr64 (MSR_XEON_D_IA32_L3_QOS_CFG, Msr.Uint64); + @endcode + @note MSR_XEON_D_IA32_L3_QOS_CFG is defined as IA32_L3_QOS_CFG in SDM. +**/ +#define MSR_XEON_D_IA32_L3_QOS_CFG 0x00000C81 + +/** + MSR information returned for MSR index #MSR_XEON_D_IA32_L3_QOS_CFG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] CAT Enable. Set 1 to enable Cache Allocation Technology. + /// + UINT32 CAT:1; + UINT32 Reserved1:31; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h b/Core/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h new file mode 100644 index 0000000000..d509660c52 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h @@ -0,0 +1,373 @@ +/** @file + MSR Definitions for Intel(R) Xeon(R) Processor E7 Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.8. + +**/ + +#ifndef __XEON_E7_MSR_H__ +#define __XEON_E7_MSR_H__ + +#include + +/** + Is Intel(R) Xeon(R) Processor E7 Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_XEON_E7_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x2F \ + ) \ + ) + +/** + Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP + handler to handle unsuccessful read of this MSR. + + @param ECX MSR_XEON_E7_FEATURE_CONFIG (0x0000013C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_E7_FEATURE_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_E7_FEATURE_CONFIG_REGISTER. + + Example usage + @code + MSR_XEON_E7_FEATURE_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_E7_FEATURE_CONFIG); + AsmWriteMsr64 (MSR_XEON_E7_FEATURE_CONFIG, Msr.Uint64); + @endcode + @note MSR_XEON_E7_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. +**/ +#define MSR_XEON_E7_FEATURE_CONFIG 0x0000013C + +/** + MSR information returned for MSR index #MSR_XEON_E7_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this + /// MSR, the configuration of AES instruction set availability is as + /// follows: 11b: AES instructions are not available until next RESET. + /// otherwise, AES instructions are available. Note, AES instruction set + /// is not available if read is unsuccessful. If the configuration is not + /// 01b, AES instruction can be mis-configured if a privileged agent + /// unintentionally writes 11b. + /// + UINT32 AESConfiguration:2; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_E7_FEATURE_CONFIG_REGISTER; + + +/** + Thread. Offcore Response Event Select Register (R/W). + + @param ECX MSR_XEON_E7_OFFCORE_RSP_1 (0x000001A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_OFFCORE_RSP_1); + AsmWriteMsr64 (MSR_XEON_E7_OFFCORE_RSP_1, Msr); + @endcode + @note MSR_XEON_E7_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. +**/ +#define MSR_XEON_E7_OFFCORE_RSP_1 0x000001A7 + + +/** + Package. Reserved Attempt to read/write will cause #UD. + + @param ECX MSR_XEON_E7_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_TURBO_RATIO_LIMIT); + AsmWriteMsr64 (MSR_XEON_E7_TURBO_RATIO_LIMIT, Msr); + @endcode + @note MSR_XEON_E7_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_XEON_E7_TURBO_RATIO_LIMIT 0x000001AD + + +/** + Package. Uncore C-box 8 perfmon local box control MSR. + + @param ECX MSR_XEON_E7_C8_PMON_BOX_CTRL (0x00000F40) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_XEON_E7_C8_PMON_BOX_CTRL is defined as MSR_C8_PMON_BOX_CTRL in SDM. +**/ +#define MSR_XEON_E7_C8_PMON_BOX_CTRL 0x00000F40 + + +/** + Package. Uncore C-box 8 perfmon local box status MSR. + + @param ECX MSR_XEON_E7_C8_PMON_BOX_STATUS (0x00000F41) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_XEON_E7_C8_PMON_BOX_STATUS is defined as MSR_C8_PMON_BOX_STATUS in SDM. +**/ +#define MSR_XEON_E7_C8_PMON_BOX_STATUS 0x00000F41 + + +/** + Package. Uncore C-box 8 perfmon local box overflow control MSR. + + @param ECX MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL (0x00000F42) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL is defined as MSR_C8_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL 0x00000F42 + + +/** + Package. Uncore C-box 8 perfmon event select MSR. + + @param ECX MSR_XEON_E7_C8_PMON_EVNT_SELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_XEON_E7_C8_PMON_EVNT_SEL0 is defined as MSR_C8_PMON_EVNT_SEL0 in SDM. + MSR_XEON_E7_C8_PMON_EVNT_SEL1 is defined as MSR_C8_PMON_EVNT_SEL1 in SDM. + MSR_XEON_E7_C8_PMON_EVNT_SEL2 is defined as MSR_C8_PMON_EVNT_SEL2 in SDM. + MSR_XEON_E7_C8_PMON_EVNT_SEL3 is defined as MSR_C8_PMON_EVNT_SEL3 in SDM. + MSR_XEON_E7_C8_PMON_EVNT_SEL4 is defined as MSR_C8_PMON_EVNT_SEL4 in SDM. + MSR_XEON_E7_C8_PMON_EVNT_SEL5 is defined as MSR_C8_PMON_EVNT_SEL5 in SDM. + @{ +**/ +#define MSR_XEON_E7_C8_PMON_EVNT_SEL0 0x00000F50 +#define MSR_XEON_E7_C8_PMON_EVNT_SEL1 0x00000F52 +#define MSR_XEON_E7_C8_PMON_EVNT_SEL2 0x00000F54 +#define MSR_XEON_E7_C8_PMON_EVNT_SEL3 0x00000F56 +#define MSR_XEON_E7_C8_PMON_EVNT_SEL4 0x00000F58 +#define MSR_XEON_E7_C8_PMON_EVNT_SEL5 0x00000F5A +/// @} + + +/** + Package. Uncore C-box 8 perfmon counter MSR. + + @param ECX MSR_XEON_E7_C8_PMON_CTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_CTR0); + AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_CTR0, Msr); + @endcode + @note MSR_XEON_E7_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. + MSR_XEON_E7_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. + MSR_XEON_E7_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. + MSR_XEON_E7_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. + MSR_XEON_E7_C8_PMON_CTR4 is defined as MSR_C8_PMON_CTR4 in SDM. + MSR_XEON_E7_C8_PMON_CTR5 is defined as MSR_C8_PMON_CTR5 in SDM. + @{ +**/ +#define MSR_XEON_E7_C8_PMON_CTR0 0x00000F51 +#define MSR_XEON_E7_C8_PMON_CTR1 0x00000F53 +#define MSR_XEON_E7_C8_PMON_CTR2 0x00000F55 +#define MSR_XEON_E7_C8_PMON_CTR3 0x00000F57 +#define MSR_XEON_E7_C8_PMON_CTR4 0x00000F59 +#define MSR_XEON_E7_C8_PMON_CTR5 0x00000F5B +/// @} + + +/** + Package. Uncore C-box 9 perfmon local box control MSR. + + @param ECX MSR_XEON_E7_C9_PMON_BOX_CTRL (0x00000FC0) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_CTRL); + AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_CTRL, Msr); + @endcode + @note MSR_XEON_E7_C9_PMON_BOX_CTRL is defined as MSR_C9_PMON_BOX_CTRL in SDM. +**/ +#define MSR_XEON_E7_C9_PMON_BOX_CTRL 0x00000FC0 + + +/** + Package. Uncore C-box 9 perfmon local box status MSR. + + @param ECX MSR_XEON_E7_C9_PMON_BOX_STATUS (0x00000FC1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_STATUS); + AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_STATUS, Msr); + @endcode + @note MSR_XEON_E7_C9_PMON_BOX_STATUS is defined as MSR_C9_PMON_BOX_STATUS in SDM. +**/ +#define MSR_XEON_E7_C9_PMON_BOX_STATUS 0x00000FC1 + + +/** + Package. Uncore C-box 9 perfmon local box overflow control MSR. + + @param ECX MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL (0x00000FC2) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL); + AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL, Msr); + @endcode + @note MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL is defined as MSR_C9_PMON_BOX_OVF_CTRL in SDM. +**/ +#define MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL 0x00000FC2 + + +/** + Package. Uncore C-box 9 perfmon event select MSR. + + @param ECX MSR_XEON_E7_C9_PMON_EVNT_SELn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_EVNT_SEL0); + AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_EVNT_SEL0, Msr); + @endcode + @note MSR_XEON_E7_C9_PMON_EVNT_SEL0 is defined as MSR_C9_PMON_EVNT_SEL0 in SDM. + MSR_XEON_E7_C9_PMON_EVNT_SEL1 is defined as MSR_C9_PMON_EVNT_SEL1 in SDM. + MSR_XEON_E7_C9_PMON_EVNT_SEL2 is defined as MSR_C9_PMON_EVNT_SEL2 in SDM. + MSR_XEON_E7_C9_PMON_EVNT_SEL3 is defined as MSR_C9_PMON_EVNT_SEL3 in SDM. + MSR_XEON_E7_C9_PMON_EVNT_SEL4 is defined as MSR_C9_PMON_EVNT_SEL4 in SDM. + MSR_XEON_E7_C9_PMON_EVNT_SEL5 is defined as MSR_C9_PMON_EVNT_SEL5 in SDM. + @{ +**/ +#define MSR_XEON_E7_C9_PMON_EVNT_SEL0 0x00000FD0 +#define MSR_XEON_E7_C9_PMON_EVNT_SEL1 0x00000FD2 +#define MSR_XEON_E7_C9_PMON_EVNT_SEL2 0x00000FD4 +#define MSR_XEON_E7_C9_PMON_EVNT_SEL3 0x00000FD6 +#define MSR_XEON_E7_C9_PMON_EVNT_SEL4 0x00000FD8 +#define MSR_XEON_E7_C9_PMON_EVNT_SEL5 0x00000FDA +/// @} + + +/** + Package. Uncore C-box 9 perfmon counter MSR. + + @param ECX MSR_XEON_E7_C9_PMON_CTRn + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_CTR0); + AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_CTR0, Msr); + @endcode + @note MSR_XEON_E7_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. + MSR_XEON_E7_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. + MSR_XEON_E7_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. + MSR_XEON_E7_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. + MSR_XEON_E7_C9_PMON_CTR4 is defined as MSR_C9_PMON_CTR4 in SDM. + MSR_XEON_E7_C9_PMON_CTR5 is defined as MSR_C9_PMON_CTR5 in SDM. + @{ +**/ +#define MSR_XEON_E7_C9_PMON_CTR0 0x00000FD1 +#define MSR_XEON_E7_C9_PMON_CTR1 0x00000FD3 +#define MSR_XEON_E7_C9_PMON_CTR2 0x00000FD5 +#define MSR_XEON_E7_C9_PMON_CTR3 0x00000FD7 +#define MSR_XEON_E7_C9_PMON_CTR4 0x00000FD9 +#define MSR_XEON_E7_C9_PMON_CTR5 0x00000FDB +/// @} + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h b/Core/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h new file mode 100644 index 0000000000..43354d15c9 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h @@ -0,0 +1,1405 @@ +/** @file + MSR Definitions for Intel(R) Xeon(R) Phi(TM) processor Family. + + Provides defines for Machine Specific Registers(MSR) indexes. Data structures + are provided for MSRs that contain one or more bit fields. If the MSR value + returned is a single 32-bit or 64-bit value, then a data structure is not + provided for that MSR. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, + September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.17. + +**/ + +#ifndef __XEON_PHI_MSR_H__ +#define __XEON_PHI_MSR_H__ + +#include + +/** + Is Intel(R) Xeon(R) Phi(TM) processor Family? + + @param DisplayFamily Display Family ID + @param DisplayModel Display Model ID + + @retval TRUE Yes, it is. + @retval FALSE No, it isn't. +**/ +#define IS_XEON_PHI_PROCESSOR(DisplayFamily, DisplayModel) \ + (DisplayFamily == 0x06 && \ + ( \ + DisplayModel == 0x57 \ + ) \ + ) + +/** + Thread. SMI Counter (R/O). + + @param ECX MSR_XEON_PHI_SMI_COUNT (0x00000034) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_SMI_COUNT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_SMI_COUNT_REGISTER. + + Example usage + @code + MSR_XEON_PHI_SMI_COUNT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_SMI_COUNT); + @endcode + @note MSR_XEON_PHI_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. +**/ +#define MSR_XEON_PHI_SMI_COUNT 0x00000034 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_SMI_COUNT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 31:0] SMI Count (R/O). + /// + UINT32 SMICount:32; + UINT32 Reserved:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_SMI_COUNT_REGISTER; + + +/** + Package. See http://biosbits.org. + + @param ECX MSR_XEON_PHI_PLATFORM_INFO (0x000000CE) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PLATFORM_INFO_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PLATFORM_INFO_REGISTER. + + Example usage + @code + MSR_XEON_PHI_PLATFORM_INFO_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PLATFORM_INFO); + AsmWriteMsr64 (MSR_XEON_PHI_PLATFORM_INFO, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. +**/ +#define MSR_XEON_PHI_PLATFORM_INFO 0x000000CE + +/** + MSR information returned for MSR index #MSR_XEON_PHI_PLATFORM_INFO +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:8; + /// + /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio + /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 + /// MHz. + /// + UINT32 MaximumNonTurboRatio:8; + UINT32 Reserved2:12; + /// + /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When + /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is + /// enabled, and when set to 0, indicates Programmable Ratio Limits for + /// Turbo mode is disabled. + /// + UINT32 RatioLimit:1; + /// + /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When + /// set to 1, indicates that TDP Limits for Turbo mode are programmable, + /// and when set to 0, indicates TDP Limit for Turbo mode is not + /// programmable. + /// + UINT32 TDPLimit:1; + UINT32 Reserved3:2; + UINT32 Reserved4:8; + /// + /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the + /// minimum ratio (maximum efficiency) that the processor can operates, in + /// units of 100MHz. + /// + UINT32 MaximumEfficiencyRatio:8; + UINT32 Reserved5:16; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_PLATFORM_INFO_REGISTER; + + +/** + Module. C-State Configuration Control (R/W). + + @param ECX MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL (0x000000E2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER. + + Example usage + @code + MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. +**/ +#define MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL 0x000000E2 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 2:0] Package C-State Limit (R/W) The following C-state code + /// name encodings are supported: 000b: C0/C1 001b: C2 010b: C6 No + /// Retention 011b: C6 Retention 111b: No limit. + /// + UINT32 Limit:3; + UINT32 Reserved1:7; + /// + /// [Bit 10] I/O MWAIT Redirection Enable (R/W). + /// + UINT32 IO_MWAIT:1; + UINT32 Reserved2:4; + /// + /// [Bit 15] CFG Lock (R/WO). + /// + UINT32 CFGLock:1; + UINT32 Reserved3:16; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER; + + +/** + Module. Power Management IO Redirection in C-state (R/W). + + @param ECX MSR_XEON_PHI_PMG_IO_CAPTURE_BASE (0x000000E4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER. + + Example usage + @code + MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PMG_IO_CAPTURE_BASE); + AsmWriteMsr64 (MSR_XEON_PHI_PMG_IO_CAPTURE_BASE, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. +**/ +#define MSR_XEON_PHI_PMG_IO_CAPTURE_BASE 0x000000E4 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_PMG_IO_CAPTURE_BASE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 15:0] LVL_2 Base Address (R/W). + /// + UINT32 Lvl2Base:16; + /// + /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the + /// maximum C-State code name to be included when IO read to MWAIT + /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 100b - C4 + /// is the max C-State to include 110b - C6 is the max C-State to include. + /// + UINT32 CStateRange:3; + UINT32 Reserved1:13; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER; + + +/** + Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP + handler to handle unsuccessful read of this MSR. + + @param ECX MSR_XEON_PHI_FEATURE_CONFIG (0x0000013C) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_FEATURE_CONFIG_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_FEATURE_CONFIG_REGISTER. + + Example usage + @code + MSR_XEON_PHI_FEATURE_CONFIG_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_FEATURE_CONFIG); + AsmWriteMsr64 (MSR_XEON_PHI_FEATURE_CONFIG, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. +**/ +#define MSR_XEON_PHI_FEATURE_CONFIG 0x0000013C + +/** + MSR information returned for MSR index #MSR_XEON_PHI_FEATURE_CONFIG +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this + /// MSR, the configuration of AES instruction set availability is as + /// follows: 11b: AES instructions are not available until next RESET. + /// otherwise, AES instructions are available. Note, AES instruction set + /// is not available if read is unsuccessful. If the configuration is not + /// 01b, AES instruction can be mis-configured if a privileged agent + /// unintentionally writes 11b. + /// + UINT32 AESConfiguration:2; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_FEATURE_CONFIG_REGISTER; + + +/** + THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability + Enhancement. Accessible only while in SMM. + + @param ECX MSR_XEON_PHI_SMM_MCA_CAP (0x0000017D) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_SMM_MCA_CAP_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_SMM_MCA_CAP_REGISTER. + + Example usage + @code + MSR_XEON_PHI_SMM_MCA_CAP_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_SMM_MCA_CAP); + AsmWriteMsr64 (MSR_XEON_PHI_SMM_MCA_CAP, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. +**/ +#define MSR_XEON_PHI_SMM_MCA_CAP 0x0000017D + +/** + MSR information returned for MSR index #MSR_XEON_PHI_SMM_MCA_CAP +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:32; + UINT32 Reserved2:26; + /// + /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the + /// SMM code access restriction is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 SMM_Code_Access_Chk:1; + /// + /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the + /// SMM long flow indicator is supported and a host-space interface + /// available to SMM handler. + /// + UINT32 Long_Flow_Indication:1; + UINT32 Reserved3:4; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_SMM_MCA_CAP_REGISTER; + + +/** + Thread. Enable Misc. Processor Features (R/W) Allows a variety of processor + functions to be enabled and disabled. + + @param ECX MSR_XEON_PHI_IA32_MISC_ENABLE (0x000001A0) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER. + + Example usage + @code + MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_IA32_MISC_ENABLE); + AsmWriteMsr64 (MSR_XEON_PHI_IA32_MISC_ENABLE, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. +**/ +#define MSR_XEON_PHI_IA32_MISC_ENABLE 0x000001A0 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_IA32_MISC_ENABLE +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Fast-Strings Enable. + /// + UINT32 FastStrings:1; + UINT32 Reserved1:2; + /// + /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) Default value + /// is 1. + /// + UINT32 AutomaticThermalControlCircuit:1; + UINT32 Reserved2:3; + /// + /// [Bit 7] Performance Monitoring Available (R). + /// + UINT32 PerformanceMonitoring:1; + UINT32 Reserved3:3; + /// + /// [Bit 11] Branch Trace Storage Unavailable (RO). + /// + UINT32 BTS:1; + /// + /// [Bit 12] Processor Event Based Sampling Unavailable (RO). + /// + UINT32 PEBS:1; + UINT32 Reserved4:3; + /// + /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W). + /// + UINT32 EIST:1; + UINT32 Reserved5:1; + /// + /// [Bit 18] ENABLE MONITOR FSM (R/W). + /// + UINT32 MONITOR:1; + UINT32 Reserved6:3; + /// + /// [Bit 22] Limit CPUID Maxval (R/W). + /// + UINT32 LimitCpuidMaxval:1; + /// + /// [Bit 23] xTPR Message Disable (R/W). + /// + UINT32 xTPR_Message_Disable:1; + UINT32 Reserved7:8; + UINT32 Reserved8:2; + /// + /// [Bit 34] XD Bit Disable (R/W). + /// + UINT32 XD:1; + UINT32 Reserved9:3; + /// + /// [Bit 38] Turbo Mode Disable (R/W). + /// + UINT32 TurboModeDisable:1; + UINT32 Reserved10:25; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER; + + +/** + Package. + + @param ECX MSR_XEON_PHI_TEMPERATURE_TARGET (0x000001A2) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER. + + Example usage + @code + MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_TEMPERATURE_TARGET); + AsmWriteMsr64 (MSR_XEON_PHI_TEMPERATURE_TARGET, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. +**/ +#define MSR_XEON_PHI_TEMPERATURE_TARGET 0x000001A2 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_TEMPERATURE_TARGET +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved1:16; + /// + /// [Bits 23:16] Temperature Target (R). + /// + UINT32 TemperatureTarget:8; + /// + /// [Bits 29:24] Target Offset (R/W). + /// + UINT32 TargetOffset:6; + UINT32 Reserved2:2; + UINT32 Reserved3:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER; + + +/** + Miscellaneous Feature Control (R/W). + + @param ECX MSR_XEON_PHI_MISC_FEATURE_CONTROL (0x000001A4) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER. + + Example usage + @code + MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_MISC_FEATURE_CONTROL); + AsmWriteMsr64 (MSR_XEON_PHI_MISC_FEATURE_CONTROL, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. +**/ +#define MSR_XEON_PHI_MISC_FEATURE_CONTROL 0x000001A4 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_MISC_FEATURE_CONTROL +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables the + /// L1 data cache prefetcher. + /// + UINT32 DCUHardwarePrefetcherDisable:1; + /// + /// [Bit 1] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the + /// L2 hardware prefetcher. + /// + UINT32 L2HardwarePrefetcherDisable:1; + UINT32 Reserved1:30; + UINT32 Reserved2:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER; + + +/** + Shared. Offcore Response Event Select Register (R/W). + + @param ECX MSR_XEON_PHI_OFFCORE_RSP_0 (0x000001A6) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_OFFCORE_RSP_0); + AsmWriteMsr64 (MSR_XEON_PHI_OFFCORE_RSP_0, Msr); + @endcode + @note MSR_XEON_PHI_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. +**/ +#define MSR_XEON_PHI_OFFCORE_RSP_0 0x000001A6 + + +/** + Shared. Offcore Response Event Select Register (R/W). + + @param ECX MSR_XEON_PHI_OFFCORE_RSP_1 (0x000001A7) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_OFFCORE_RSP_1); + AsmWriteMsr64 (MSR_XEON_PHI_OFFCORE_RSP_1, Msr); + @endcode + @note MSR_XEON_PHI_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. +**/ +#define MSR_XEON_PHI_OFFCORE_RSP_1 0x000001A7 + + +/** + Package. Maximum Ratio Limit of Turbo Mode for Groups of Cores (RW). + + @param ECX MSR_XEON_PHI_TURBO_RATIO_LIMIT (0x000001AD) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER. + + Example usage + @code + MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_TURBO_RATIO_LIMIT); + AsmWriteMsr64 (MSR_XEON_PHI_TURBO_RATIO_LIMIT, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. +**/ +#define MSR_XEON_PHI_TURBO_RATIO_LIMIT 0x000001AD + +/** + MSR information returned for MSR index #MSR_XEON_PHI_TURBO_RATIO_LIMIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + UINT32 Reserved:1; + /// + /// [Bits 7:1] Package. Maximum Number of Cores in Group 0 Number active + /// processor cores which operates under the maximum ratio limit for group + /// 0. + /// + UINT32 MaxCoresGroup0:7; + /// + /// [Bits 15:8] Package. Maximum Ratio Limit for Group 0 Maximum turbo + /// ratio limit when the number of active cores are not more than the + /// group 0 maximum core count. + /// + UINT32 MaxRatioLimitGroup0:8; + /// + /// [Bits 20:16] Package. Number of Incremental Cores Added to Group 1 + /// Group 1, which includes the specified number of additional cores plus + /// the cores in group 0, operates under the group 1 turbo max ratio limit + /// = "group 0 Max ratio limit" - "group ratio delta for group 1". + /// + UINT32 MaxIncrementalCoresGroup1:5; + /// + /// [Bits 23:21] Package. Group Ratio Delta for Group 1 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// to Group 0. + /// + UINT32 DeltaRatioGroup1:3; + /// + /// [Bits 28:24] Package. Number of Incremental Cores Added to Group 2 + /// Group 2, which includes the specified number of additional cores plus + /// all the cores in group 1, operates under the group 2 turbo max ratio + /// limit = "group 1 Max ratio limit" - "group ratio delta for group 2". + /// + UINT32 MaxIncrementalCoresGroup2:5; + /// + /// [Bits 31:29] Package. Group Ratio Delta for Group 2 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// for Group 1. + /// + UINT32 DeltaRatioGroup2:3; + /// + /// [Bits 36:32] Package. Number of Incremental Cores Added to Group 3 + /// Group 3, which includes the specified number of additional cores plus + /// all the cores in group 2, operates under the group 3 turbo max ratio + /// limit = "group 2 Max ratio limit" - "group ratio delta for group 3". + /// + UINT32 MaxIncrementalCoresGroup3:5; + /// + /// [Bits 39:37] Package. Group Ratio Delta for Group 3 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// for Group 2. + /// + UINT32 DeltaRatioGroup3:3; + /// + /// [Bits 44:40] Package. Number of Incremental Cores Added to Group 4 + /// Group 4, which includes the specified number of additional cores plus + /// all the cores in group 3, operates under the group 4 turbo max ratio + /// limit = "group 3 Max ratio limit" - "group ratio delta for group 4". + /// + UINT32 MaxIncrementalCoresGroup4:5; + /// + /// [Bits 47:45] Package. Group Ratio Delta for Group 4 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// for Group 3. + /// + UINT32 DeltaRatioGroup4:3; + /// + /// [Bits 52:48] Package. Number of Incremental Cores Added to Group 5 + /// Group 5, which includes the specified number of additional cores plus + /// all the cores in group 4, operates under the group 5 turbo max ratio + /// limit = "group 4 Max ratio limit" - "group ratio delta for group 5". + /// + UINT32 MaxIncrementalCoresGroup5:5; + /// + /// [Bits 55:53] Package. Group Ratio Delta for Group 5 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// for Group 4. + /// + UINT32 DeltaRatioGroup5:3; + /// + /// [Bits 60:56] Package. Number of Incremental Cores Added to Group 6 + /// Group 6, which includes the specified number of additional cores plus + /// all the cores in group 5, operates under the group 6 turbo max ratio + /// limit = "group 5 Max ratio limit" - "group ratio delta for group 6". + /// + UINT32 MaxIncrementalCoresGroup6:5; + /// + /// [Bits 63:61] Package. Group Ratio Delta for Group 6 An unsigned + /// integer specifying the ratio decrement relative to the Max ratio limit + /// for Group 5. + /// + UINT32 DeltaRatioGroup6:3; + } Bits; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER; + + +/** + Thread. Last Branch Record Filtering Select Register (R/W). + + @param ECX MSR_XEON_PHI_LBR_SELECT (0x000001C8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_LBR_SELECT); + AsmWriteMsr64 (MSR_XEON_PHI_LBR_SELECT, Msr); + @endcode + @note MSR_XEON_PHI_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. +**/ +#define MSR_XEON_PHI_LBR_SELECT 0x000001C8 + + +/** + Thread. Last Branch Record Stack TOS (R/W). + + @param ECX MSR_XEON_PHI_LASTBRANCH_TOS (0x000001C9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_LASTBRANCH_TOS); + AsmWriteMsr64 (MSR_XEON_PHI_LASTBRANCH_TOS, Msr); + @endcode + @note MSR_XEON_PHI_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. +**/ +#define MSR_XEON_PHI_LASTBRANCH_TOS 0x000001C9 + + +/** + Thread. Last Exception Record From Linear IP (R). + + @param ECX MSR_XEON_PHI_LER_FROM_LIP (0x000001DD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_LER_FROM_LIP); + @endcode + @note MSR_XEON_PHI_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. +**/ +#define MSR_XEON_PHI_LER_FROM_LIP 0x000001DD + + +/** + Thread. Last Exception Record To Linear IP (R). + + @param ECX MSR_XEON_PHI_LER_TO_LIP (0x000001DE) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_LER_TO_LIP); + @endcode + @note MSR_XEON_PHI_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. +**/ +#define MSR_XEON_PHI_LER_TO_LIP 0x000001DE + + +/** + Thread. See Table 35-2. + + @param ECX MSR_XEON_PHI_PEBS_ENABLE (0x000003F1) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PEBS_ENABLE); + AsmWriteMsr64 (MSR_XEON_PHI_PEBS_ENABLE, Msr); + @endcode + @note MSR_XEON_PHI_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. +**/ +#define MSR_XEON_PHI_PEBS_ENABLE 0x000003F1 + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. Package C3 + Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_PKG_C3_RESIDENCY (0x000003F8) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C3_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_C3_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_PKG_C3_RESIDENCY 0x000003F8 + + +/** + Package. Package C6 Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_PKG_C6_RESIDENCY (0x000003F9) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C6_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_C6_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_PKG_C6_RESIDENCY 0x000003F9 + + +/** + Package. Package C7 Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_PKG_C7_RESIDENCY (0x000003FA) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C7_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_C7_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_PKG_C7_RESIDENCY 0x000003FA + + +/** + Module. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. Module C0 + Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_MC0_RESIDENCY (0x000003FC) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_MC0_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_MC0_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_MC0_RESIDENCY is defined as MSR_MC0_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_MC0_RESIDENCY 0x000003FC + + +/** + Module. Module C6 Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_MC6_RESIDENCY (0x000003FD) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_MC6_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_MC6_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_MC6_RESIDENCY is defined as MSR_MC6_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_MC6_RESIDENCY 0x000003FD + + +/** + Core. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. CORE C6 + Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_CORE_C6_RESIDENCY (0x000003FF) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_CORE_C6_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_CORE_C6_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_CORE_C6_RESIDENCY 0x000003FF + + +/** + Core. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. + + @param ECX MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM (0x0000048C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM); + @endcode + @note MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. +**/ +#define MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM 0x0000048C + + +/** + Core. Capability Reporting Register of VM-function Controls (R/O) See Table + 35-2. + + @param ECX MSR_XEON_PHI_IA32_VMX_FMFUNC (0x00000491) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_IA32_VMX_FMFUNC); + @endcode + @note MSR_XEON_PHI_IA32_VMX_FMFUNC is defined as IA32_VMX_FMFUNC in SDM. +**/ +#define MSR_XEON_PHI_IA32_VMX_FMFUNC 0x00000491 + + +/** + Package. Unit Multipliers used in RAPL Interfaces (R/O). + + @param ECX MSR_XEON_PHI_RAPL_POWER_UNIT (0x00000606) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER. + + Example usage + @code + MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_RAPL_POWER_UNIT); + @endcode + @note MSR_XEON_PHI_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. +**/ +#define MSR_XEON_PHI_RAPL_POWER_UNIT 0x00000606 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_RAPL_POWER_UNIT +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". + /// + UINT32 PowerUnits:4; + UINT32 Reserved1:4; + /// + /// [Bits 12:8] Package. Energy Status Units Energy related information + /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an + /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 + /// micro-joules). + /// + UINT32 EnergyStatusUnits:5; + UINT32 Reserved2:3; + /// + /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL + /// Interfaces.". + /// + UINT32 TimeUnits:4; + UINT32 Reserved3:12; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER; + + +/** + Package. Note: C-state values are processor specific C-state code names, + unrelated to MWAIT extension C-state parameters or ACPI C-States. Package C2 + Residency Counter. (R/O). + + @param ECX MSR_XEON_PHI_PKG_C2_RESIDENCY (0x0000060D) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C2_RESIDENCY); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_C2_RESIDENCY, Msr); + @endcode + @note MSR_XEON_PHI_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. +**/ +#define MSR_XEON_PHI_PKG_C2_RESIDENCY 0x0000060D + + +/** + Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package + RAPL Domain.". + + @param ECX MSR_XEON_PHI_PKG_POWER_LIMIT (0x00000610) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_POWER_LIMIT); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_POWER_LIMIT, Msr); + @endcode + @note MSR_XEON_PHI_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. +**/ +#define MSR_XEON_PHI_PKG_POWER_LIMIT 0x00000610 + + +/** + Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_XEON_PHI_PKG_ENERGY_STATUS (0x00000611) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_ENERGY_STATUS); + @endcode + @note MSR_XEON_PHI_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. +**/ +#define MSR_XEON_PHI_PKG_ENERGY_STATUS 0x00000611 + + +/** + Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". + + @param ECX MSR_XEON_PHI_PKG_PERF_STATUS (0x00000613) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_PERF_STATUS); + @endcode + @note MSR_XEON_PHI_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. +**/ +#define MSR_XEON_PHI_PKG_PERF_STATUS 0x00000613 + + +/** + Package. PKG RAPL Parameters (R/W) See Section 14.9.3, "Package RAPL + Domain.". + + @param ECX MSR_XEON_PHI_PKG_POWER_INFO (0x00000614) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_POWER_INFO); + AsmWriteMsr64 (MSR_XEON_PHI_PKG_POWER_INFO, Msr); + @endcode + @note MSR_XEON_PHI_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. +**/ +#define MSR_XEON_PHI_PKG_POWER_INFO 0x00000614 + + +/** + Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL + Domain.". + + @param ECX MSR_XEON_PHI_DRAM_POWER_LIMIT (0x00000618) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_POWER_LIMIT); + AsmWriteMsr64 (MSR_XEON_PHI_DRAM_POWER_LIMIT, Msr); + @endcode + @note MSR_XEON_PHI_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. +**/ +#define MSR_XEON_PHI_DRAM_POWER_LIMIT 0x00000618 + + +/** + Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_XEON_PHI_DRAM_ENERGY_STATUS (0x00000619) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_ENERGY_STATUS); + @endcode + @note MSR_XEON_PHI_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. +**/ +#define MSR_XEON_PHI_DRAM_ENERGY_STATUS 0x00000619 + + +/** + Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM + RAPL Domain.". + + @param ECX MSR_XEON_PHI_DRAM_PERF_STATUS (0x0000061B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_PERF_STATUS); + @endcode + @note MSR_XEON_PHI_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. +**/ +#define MSR_XEON_PHI_DRAM_PERF_STATUS 0x0000061B + + +/** + Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". + + @param ECX MSR_XEON_PHI_DRAM_POWER_INFO (0x0000061C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_POWER_INFO); + AsmWriteMsr64 (MSR_XEON_PHI_DRAM_POWER_INFO, Msr); + @endcode + @note MSR_XEON_PHI_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. +**/ +#define MSR_XEON_PHI_DRAM_POWER_INFO 0x0000061C + + +/** + Package. PP0 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 + RAPL Domains.". + + @param ECX MSR_XEON_PHI_PP0_POWER_LIMIT (0x00000638) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PP0_POWER_LIMIT); + AsmWriteMsr64 (MSR_XEON_PHI_PP0_POWER_LIMIT, Msr); + @endcode + @note MSR_XEON_PHI_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. +**/ +#define MSR_XEON_PHI_PP0_POWER_LIMIT 0x00000638 + + +/** + Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL + Domains.". + + @param ECX MSR_XEON_PHI_PP0_ENERGY_STATUS (0x00000639) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_PP0_ENERGY_STATUS); + @endcode + @note MSR_XEON_PHI_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. +**/ +#define MSR_XEON_PHI_PP0_ENERGY_STATUS 0x00000639 + + +/** + Package. Base TDP Ratio (R/O) See Table 35-23. + + @param ECX MSR_XEON_PHI_CONFIG_TDP_NOMINAL (0x00000648) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_NOMINAL); + @endcode + @note MSR_XEON_PHI_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. +**/ +#define MSR_XEON_PHI_CONFIG_TDP_NOMINAL 0x00000648 + + +/** + Package. ConfigTDP Level 1 ratio and power level (R/O). See Table 35-23. + + @param ECX MSR_XEON_PHI_CONFIG_TDP_LEVEL1 (0x00000649) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_LEVEL1); + @endcode + @note MSR_XEON_PHI_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. +**/ +#define MSR_XEON_PHI_CONFIG_TDP_LEVEL1 0x00000649 + + +/** + Package. ConfigTDP Level 2 ratio and power level (R/O). See Table 35-23. + + @param ECX MSR_XEON_PHI_CONFIG_TDP_LEVEL2 (0x0000064A) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_LEVEL2); + @endcode + @note MSR_XEON_PHI_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. +**/ +#define MSR_XEON_PHI_CONFIG_TDP_LEVEL2 0x0000064A + + +/** + Package. ConfigTDP Control (R/W) See Table 35-23. + + @param ECX MSR_XEON_PHI_CONFIG_TDP_CONTROL (0x0000064B) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_CONTROL); + AsmWriteMsr64 (MSR_XEON_PHI_CONFIG_TDP_CONTROL, Msr); + @endcode + @note MSR_XEON_PHI_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. +**/ +#define MSR_XEON_PHI_CONFIG_TDP_CONTROL 0x0000064B + + +/** + Package. ConfigTDP Control (R/W) See Table 35-23. + + @param ECX MSR_XEON_PHI_TURBO_ACTIVATION_RATIO (0x0000064C) + @param EAX Lower 32-bits of MSR value. + @param EDX Upper 32-bits of MSR value. + + Example usage + @code + UINT64 Msr; + + Msr = AsmReadMsr64 (MSR_XEON_PHI_TURBO_ACTIVATION_RATIO); + AsmWriteMsr64 (MSR_XEON_PHI_TURBO_ACTIVATION_RATIO, Msr); + @endcode + @note MSR_XEON_PHI_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. +**/ +#define MSR_XEON_PHI_TURBO_ACTIVATION_RATIO 0x0000064C + + +/** + Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency + refers to processor core frequency). + + @param ECX MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS (0x00000690) + @param EAX Lower 32-bits of MSR value. + Described by the type MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER. + @param EDX Upper 32-bits of MSR value. + Described by the type MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER. + + Example usage + @code + MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER Msr; + + Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS); + AsmWriteMsr64 (MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS, Msr.Uint64); + @endcode + @note MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. +**/ +#define MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS 0x00000690 + +/** + MSR information returned for MSR index #MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { + /// + /// [Bit 0] PROCHOT Status (R0). + /// + UINT32 PROCHOT_Status:1; + /// + /// [Bit 1] Thermal Status (R0). + /// + UINT32 ThermalStatus:1; + UINT32 Reserved1:4; + /// + /// [Bit 6] VR Therm Alert Status (R0). + /// + UINT32 VRThermAlertStatus:1; + UINT32 Reserved2:1; + /// + /// [Bit 8] Electrical Design Point Status (R0). + /// + UINT32 ElectricalDesignPointStatus:1; + UINT32 Reserved3:23; + UINT32 Reserved4:32; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; + /// + /// All bit fields as a 64-bit value + /// + UINT64 Uint64; +} MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER; + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/SmramSaveStateMap.h b/Core/UefiCpuPkg/Include/Register/SmramSaveStateMap.h new file mode 100644 index 0000000000..a7c7562df8 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/SmramSaveStateMap.h @@ -0,0 +1,190 @@ +/** @file +SMRAM Save State Map Definitions. + +SMRAM Save State Map definitions based on contents of the +Intel(R) 64 and IA-32 Architectures Software Developer's Manual + Volume 3C, Section 34.4 SMRAM + Volume 3C, Section 34.5 SMI Handler Execution Environment + Volume 3C, Section 34.7 Managing Synchronous and Asynchronous SMIs + +Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __SMRAM_SAVE_STATE_MAP_H__ +#define __SMRAM_SAVE_STATE_MAP_H__ + +/// +/// Default SMBASE address +/// +#define SMM_DEFAULT_SMBASE 0x30000 + +/// +/// Offset of SMM handler from SMBASE +/// +#define SMM_HANDLER_OFFSET 0x8000 + +/// +/// Offset of SMRAM Save State Map from SMBASE +/// +#define SMRAM_SAVE_STATE_MAP_OFFSET 0xfc00 + +#pragma pack (1) + +/// +/// 32-bit SMRAM Save State Map +/// +typedef struct { + UINT8 Reserved[0x200]; // 7c00h + // Padded an extra 0x200 bytes so 32-bit and 64-bit + // SMRAM Save State Maps are the same size + UINT8 Reserved1[0xf8]; // 7e00h + UINT32 SMBASE; // 7ef8h + UINT32 SMMRevId; // 7efch + UINT16 IORestart; // 7f00h + UINT16 AutoHALTRestart; // 7f02h + UINT8 Reserved2[0x9C]; // 7f08h + UINT32 IOMemAddr; // 7fa0h + UINT32 IOMisc; // 7fa4h + UINT32 _ES; // 7fa8h + UINT32 _CS; // 7fach + UINT32 _SS; // 7fb0h + UINT32 _DS; // 7fb4h + UINT32 _FS; // 7fb8h + UINT32 _GS; // 7fbch + UINT32 Reserved3; // 7fc0h + UINT32 _TR; // 7fc4h + UINT32 _DR7; // 7fc8h + UINT32 _DR6; // 7fcch + UINT32 _EAX; // 7fd0h + UINT32 _ECX; // 7fd4h + UINT32 _EDX; // 7fd8h + UINT32 _EBX; // 7fdch + UINT32 _ESP; // 7fe0h + UINT32 _EBP; // 7fe4h + UINT32 _ESI; // 7fe8h + UINT32 _EDI; // 7fech + UINT32 _EIP; // 7ff0h + UINT32 _EFLAGS; // 7ff4h + UINT32 _CR3; // 7ff8h + UINT32 _CR0; // 7ffch +} SMRAM_SAVE_STATE_MAP32; + +/// +/// 64-bit SMRAM Save State Map +/// +typedef struct { + UINT8 Reserved1[0x1d0]; // 7c00h + UINT32 GdtBaseHiDword; // 7dd0h + UINT32 LdtBaseHiDword; // 7dd4h + UINT32 IdtBaseHiDword; // 7dd8h + UINT8 Reserved2[0xc]; // 7ddch + UINT64 IO_EIP; // 7de8h + UINT8 Reserved3[0x50]; // 7df0h + UINT32 _CR4; // 7e40h + UINT8 Reserved4[0x48]; // 7e44h + UINT32 GdtBaseLoDword; // 7e8ch + UINT32 Reserved5; // 7e90h + UINT32 IdtBaseLoDword; // 7e94h + UINT32 Reserved6; // 7e98h + UINT32 LdtBaseLoDword; // 7e9ch + UINT8 Reserved7[0x38]; // 7ea0h + UINT64 EptVmxControl; // 7ed8h + UINT32 EnEptVmxControl; // 7ee0h + UINT8 Reserved8[0x14]; // 7ee4h + UINT32 SMBASE; // 7ef8h + UINT32 SMMRevId; // 7efch + UINT16 IORestart; // 7f00h + UINT16 AutoHALTRestart; // 7f02h + UINT8 Reserved9[0x18]; // 7f04h + UINT64 _R15; // 7f1ch + UINT64 _R14; + UINT64 _R13; + UINT64 _R12; + UINT64 _R11; + UINT64 _R10; + UINT64 _R9; + UINT64 _R8; + UINT64 _RAX; // 7f5ch + UINT64 _RCX; + UINT64 _RDX; + UINT64 _RBX; + UINT64 _RSP; + UINT64 _RBP; + UINT64 _RSI; + UINT64 _RDI; + UINT64 IOMemAddr; // 7f9ch + UINT32 IOMisc; // 7fa4h + UINT32 _ES; // 7fa8h + UINT32 _CS; + UINT32 _SS; + UINT32 _DS; + UINT32 _FS; + UINT32 _GS; + UINT32 _LDTR; // 7fc0h + UINT32 _TR; + UINT64 _DR7; // 7fc8h + UINT64 _DR6; + UINT64 _RIP; // 7fd8h + UINT64 IA32_EFER; // 7fe0h + UINT64 _RFLAGS; // 7fe8h + UINT64 _CR3; // 7ff0h + UINT64 _CR0; // 7ff8h +} SMRAM_SAVE_STATE_MAP64; + +/// +/// Union of 32-bit and 64-bit SMRAM Save State Maps +/// +typedef union { + SMRAM_SAVE_STATE_MAP32 x86; + SMRAM_SAVE_STATE_MAP64 x64; +} SMRAM_SAVE_STATE_MAP; + +/// +/// Minimum SMM Revision ID that supports IOMisc field in SMRAM Save State Map +/// +#define SMRAM_SAVE_STATE_MIN_REV_ID_IOMISC 0x30004 + +/// +/// SMRAM Save State Map IOMisc I/O Length Values +/// +#define SMM_IO_LENGTH_BYTE 0x01 +#define SMM_IO_LENGTH_WORD 0x02 +#define SMM_IO_LENGTH_DWORD 0x04 + +/// +/// SMRAM Save State Map IOMisc I/O Instruction Type Values +/// +#define SMM_IO_TYPE_IN_IMMEDIATE 0x9 +#define SMM_IO_TYPE_IN_DX 0x1 +#define SMM_IO_TYPE_OUT_IMMEDIATE 0x8 +#define SMM_IO_TYPE_OUT_DX 0x0 +#define SMM_IO_TYPE_INS 0x3 +#define SMM_IO_TYPE_OUTS 0x2 +#define SMM_IO_TYPE_REP_INS 0x7 +#define SMM_IO_TYPE_REP_OUTS 0x6 + +/// +/// SMRAM Save State Map IOMisc structure +/// +typedef union { + struct { + UINT32 SmiFlag:1; + UINT32 Length:3; + UINT32 Type:4; + UINT32 Reserved1:8; + UINT32 Port:16; + } Bits; + UINT32 Uint32; +} SMRAM_SAVE_STATE_IOMISC; + +#pragma pack () + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/StmApi.h b/Core/UefiCpuPkg/Include/Register/StmApi.h new file mode 100644 index 0000000000..6fb5971b44 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/StmApi.h @@ -0,0 +1,954 @@ +/** @file + STM API definition + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + SMI Transfer Monitor (STM) User Guide Revision 1.00 + +**/ + +#ifndef _STM_API_H_ +#define _STM_API_H_ + +#include +#include +#include + +#pragma pack (1) + +/** + STM Header Structures +**/ + +typedef struct { + UINT32 Intel64ModeSupported :1; ///> bitfield + UINT32 EptSupported :1; ///> bitfield + UINT32 Reserved :30; ///> must be 0 +} STM_FEAT; + +#define STM_SPEC_VERSION_MAJOR 1 +#define STM_SPEC_VERSION_MINOR 0 + +typedef struct { + UINT8 StmSpecVerMajor; + UINT8 StmSpecVerMinor; + /// + /// Must be zero + /// + UINT16 Reserved; + UINT32 StaticImageSize; + UINT32 PerProcDynamicMemorySize; + UINT32 AdditionalDynamicMemorySize; + STM_FEAT StmFeatures; + UINT32 NumberOfRevIDs; + UINT32 StmSmmRevID[1]; + /// + /// The total STM_HEADER should be 4K. + /// +} SOFTWARE_STM_HEADER; + +typedef struct { + MSEG_HEADER HwStmHdr; + SOFTWARE_STM_HEADER SwStmHdr; +} STM_HEADER; + + +/** + VMCALL API Numbers + API number convention: BIOS facing VMCALL interfaces have bit 16 clear +**/ + +/** + StmMapAddressRange enables a SMM guest to create a non-1:1 virtual to + physical mapping of an address range into the SMM guest's virtual + memory space. + + @param EAX #STM_API_MAP_ADDRESS_RANGE (0x00000001) + @param EBX Low 32 bits of physical address of caller allocated + STM_MAP_ADDRESS_RANGE_DESCRIPTOR structure. + @param ECX High 32 bits of physical address of caller allocated + STM_MAP_ADDRESS_RANGE_DESCRIPTOR structure. If Intel64Mode is + clear (0), ECX must be 0. + + @note All fields of STM_MAP_ADDRESS_RANGE_DESCRIPTOR are inputs only. They + are not modified by StmMapAddressRange. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. + The memory range was mapped as requested. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_SECURITY_VIOLATION + The requested mapping contains a protected resource. + @retval EAX #ERROR_STM_CACHE_TYPE_NOT_SUPPORTED + The requested cache type could not be satisfied. + @retval EAX #ERROR_STM_PAGE_NOT_FOUND + Page count must not be zero. + @retval EAX #ERROR_STM_FUNCTION_NOT_SUPPORTED + STM supports EPT and has not implemented StmMapAddressRange(). + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_MAP_ADDRESS_RANGE 0x00000001 + +/** + STM Map Address Range Descriptor for #STM_API_MAP_ADDRESS_RANGE VMCALL +**/ +typedef struct { + UINT64 PhysicalAddress; + UINT64 VirtualAddress; + UINT32 PageCount; + UINT32 PatCacheType; +} STM_MAP_ADDRESS_RANGE_DESCRIPTOR; + +/** + Define values for PatCacheType field of #STM_MAP_ADDRESS_RANGE_DESCRIPTOR + @{ +**/ +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_ST_UC 0x00 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WC 0x01 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WT 0x04 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WP 0x05 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WB 0x06 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_UC 0x07 +#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_FOLLOW_MTRR 0xFFFFFFFF +/// @} + +/** + StmUnmapAddressRange enables a SMM guest to remove mappings from its page + table. + + If TXT_PROCESSOR_SMM_DESCRIPTOR.EptEnabled bit is set by the STM, BIOS can + control its own page tables. In this case, the STM implementation may + optionally return ERROR_STM_FUNCTION_NOT_SUPPORTED. + + @param EAX #STM_API_UNMAP_ADDRESS_RANGE (0x00000002) + @param EBX Low 32 bits of virtual address of caller allocated + STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR structure. + @param ECX High 32 bits of virtual address of caller allocated + STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR structure. If Intel64Mode is + clear (0), ECX must be zero. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The memory range was unmapped + as requested. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_FUNCTION_NOT_SUPPORTED + STM supports EPT and has not implemented StmUnmapAddressRange(). + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_UNMAP_ADDRESS_RANGE 0x00000002 + +/** + STM Unmap Address Range Descriptor for #STM_API_UNMAP_ADDRESS_RANGE VMCALL +**/ +typedef struct { + UINT64 VirtualAddress; + UINT32 Length; +} STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR; + + +/** + Since the normal OS environment runs with a different set of page tables than + the SMM guest, virtual mappings will certainly be different. In order to do a + guest virtual to host physical translation of an address from the normal OS + code (EIP for example), it is necessary to walk the page tables governing the + OS page mappings. Since the SMM guest has no direct access to the page tables, + it must ask the STM to do this page table walk. This is supported via the + StmAddressLookup VMCALL. All OS page table formats need to be supported, + (e.g. PAE, PSE, Intel64, EPT, etc.) + + StmAddressLookup takes a CR3 value and a virtual address from the interrupted + code as input and returns the corresponding physical address. It also + optionally maps the physical address into the SMM guest's virtual address + space. This new mapping persists ONLY for the duration of the SMI and if + needed in subsequent SMIs it must be remapped. PAT cache types follow the + interrupted environment's page table. + + If EPT is enabled, OS CR3 only provides guest physical address information, + but the SMM guest might also need to know the host physical address. Since + SMM does not have direct access rights to EPT (it is protected by the STM), + SMM can input InterruptedEptp to let STM help to walk through it, and output + the host physical address. + + @param EAX #STM_API_ADDRESS_LOOKUP (0x00000003) + @param EBX Low 32 bits of virtual address of caller allocated + STM_ADDRESS_LOOKUP_DESCRIPTOR structure. + @param ECX High 32 bits of virtual address of caller allocated + STM_ADDRESS_LOOKUP_DESCRIPTOR structure. If Intel64Mode is + clear (0), ECX must be zero. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. PhysicalAddress contains the + host physical address determined by walking the interrupted SMM + guest's page tables. SmmGuestVirtualAddress contains the SMM + guest's virtual mapping of the requested address. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_SECURITY_VIOLATION + The requested page was a protected page. + @retval EAX #ERROR_STM_PAGE_NOT_FOUND + The requested virtual address did not exist in the page given + page table. + @retval EAX #ERROR_STM_BAD_CR3 + The CR3 input was invalid. CR3 values must be from one of the + interrupted guest, or from the interrupted guest of another + processor. + @retval EAX #ERROR_STM_PHYSICAL_OVER_4G + The resulting physical address is greater than 4G and no virtual + address was supplied. The STM could not determine what address + within the SMM guest's virtual address space to do the mapping. + STM_ADDRESS_LOOKUP_DESCRIPTOR field PhysicalAddress contains the + physical address determined by walking the interrupted + environment's page tables. + @retval EAX #ERROR_STM_VIRTUAL_SPACE_TOO_SMALL + A specific virtual mapping was requested, but + SmmGuestVirtualAddress + Length exceeds 4G and the SMI handler + is running in 32 bit mode. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_ADDRESS_LOOKUP 0x00000003 + +/** + STM Lookup Address Range Descriptor for #STM_API_ADDRESS_LOOKUP VMCALL +**/ +typedef struct { + UINT64 InterruptedGuestVirtualAddress; + UINT32 Length; + UINT64 InterruptedCr3; + UINT64 InterruptedEptp; + UINT32 MapToSmmGuest:2; + UINT32 InterruptedCr4Pae:1; + UINT32 InterruptedCr4Pse:1; + UINT32 InterruptedIa32eMode:1; + UINT32 Reserved1:27; + UINT32 Reserved2; + UINT64 PhysicalAddress; + UINT64 SmmGuestVirtualAddress; +} STM_ADDRESS_LOOKUP_DESCRIPTOR; + +/** + Define values for the MapToSmmGuest field of #STM_ADDRESS_LOOKUP_DESCRIPTOR + @{ +**/ +#define STM_ADDRESS_LOOKUP_DESCRIPTOR_DO_NOT_MAP 0 +#define STM_ADDRESS_LOOKUP_DESCRIPTOR_ONE_TO_ONE 1 +#define STM_ADDRESS_LOOKUP_DESCRIPTOR_VIRTUAL_ADDRESS_SPECIFIED 3 +/// @} + + +/** + When returning from a protection exception (see section 6.2), the SMM guest + can instruct the STM to take one of two paths. It can either request a value + be logged to the TXT.ERRORCODE register and subsequently reset the machine + (indicating it couldn't resolve the problem), or it can request that the STM + resume the SMM guest again with the specified register state. + + Unlike other VMCALL interfaces, StmReturnFromProtectionException behaves more + like a jump or an IRET instruction than a "call". It does not return directly + to the caller, but indirectly to a different location specified on the + caller's stack (see section 6.2) or not at all. + + If the SMM guest STM protection exception handler itself causes a protection + exception (e.g. a single nested exception), or more than 100 un-nested + exceptions occur within the scope of a single SMI event, the STM must write + STM_CRASH_PROTECTION_EXCEPTION_FAILURE to the TXT.ERRORCODE register and + assert TXT.CMD.SYS_RESET. The reason for these restrictions is to simplify + the code requirements while still enabling a reasonable debugging capability. + + @param EAX #STM_API_RETURN_FROM_PROTECTION_EXCEPTION (0x00000004) + @param EBX If 0, resume SMM guest using register state found on exception + stack. If in range 0x01..0x0F, EBX contains a BIOS error code + which the STM must record in the TXT.ERRORCODE register and + subsequently reset the system via TXT.CMD.SYS_RESET. The value + of the TXT.ERRORCODE register is calculated as follows: + + TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC + + Values 0x10..0xFFFFFFFF are reserved, do not use. + +**/ +#define STM_API_RETURN_FROM_PROTECTION_EXCEPTION 0x00000004 + + +/** + VMCALL API Numbers + API number convention: MLE facing VMCALL interfaces have bit 16 set. + + The STM configuration lifecycle is as follows: + 1. SENTER->SINIT->MLE: MLE begins execution with SMI disabled (masked). + 2. MLE invokes #STM_API_INITIALIZE_PROTECTION VMCALL to prepare STM for + setup of initial protection profile. This is done on a single CPU and + has global effect. + 3. MLE invokes #STM_API_PROTECT_RESOURCE VMCALL to define the initial + protection profile. The protection profile is global across all CPUs. + 4. MLE invokes #STM_API_START VMCALL to enable the STM to begin receiving + SMI events. This must be done on every logical CPU. + 5. MLE may invoke #STM_API_PROTECT_RESOURCE VMCALL or + #STM_API_UNPROTECT_RESOURCE VMCALL during runtime as many times as + necessary. + 6. MLE invokes #STM_API_STOP VMCALL to disable the STM. SMI is again masked + following #STM_API_STOP VMCALL. +**/ + +/** + StartStmVmcall() is used to configure an STM that is present in MSEG. SMIs + should remain disabled from the invocation of GETSEC[SENTER] until they are + re-enabled by StartStmVMCALL(). When StartStmVMCALL() returns, SMI is + enabled and the STM has been started and is active. Prior to invoking + StartStmVMCALL(), the MLE root should first invoke + InitializeProtectionVMCALL() followed by as many iterations of + ProtectResourceVMCALL() as necessary to establish the initial protection + profile. StartStmVmcall() must be invoked on all processor threads. + + @param EAX #STM_API_START (0x00010001) + @param EDX STM configuration options. These provide the MLE with the + ability to pass configuration parameters to the STM. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The STM has been configured + and is now active and the guarding all requested resources. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_ALREADY_STARTED + The STM is already configured and active. STM remains active and + guarding previously enabled resource list. + @retval EAX #ERROR_STM_WITHOUT_SMX_UNSUPPORTED + The StartStmVMCALL() was invoked from VMX root mode, but outside + of SMX. This error code indicates the STM or platform does not + support the STM outside of SMX. The SMI handler remains active + and operates in legacy mode. See Appendix C + @retval EAX #ERROR_STM_UNSUPPORTED_MSR_BIT + The CPU doesn't support the MSR bit. The STM is not active. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_START (BIT16 | 1) + +/** + Bit values for EDX input parameter to #STM_API_START VMCALL + @{ +**/ +#define STM_CONFIG_SMI_UNBLOCKING_BY_VMX_OFF BIT0 +/// @} + + +/** + The StopStmVMCALL() is invoked by the MLE to teardown an active STM. This is + normally done as part of a full teardown of the SMX environment when the + system is being shut down. At the time the call is invoked, SMI is enabled + and the STM is active. When the call returns, the STM has been stopped and + all STM context is discarded and SMI is disabled. + + @param EAX #STM_API_STOP (0x00010002) + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The STM has been stopped and + is no longer processing SMI events. SMI is blocked. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_STOPPED + The STM was not active. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_STOP (BIT16 | 2) + + +/** + The ProtectResourceVMCALL() is invoked by the MLE root to request protection + of specific resources. The request is defined by a STM_RESOURCE_LIST, which + may contain more than one resource descriptor. Each resource descriptor is + processed separately by the STM. Whether or not protection for any specific + resource is granted is returned by the STM via the ReturnStatus bit in the + associated STM_RSC_DESC_HEADER. + + @param EAX #STM_API_PROTECT_RESOURCE (0x00010003) + @param EBX Low 32 bits of physical address of caller allocated + STM_RESOURCE_LIST. Bits 11:0 are ignored and assumed to be zero, + making the buffer 4K aligned. + @param ECX High 32 bits of physical address of caller allocated + STM_RESOURCE_LIST. + + @note All fields of STM_RESOURCE_LIST are inputs only, except for the + ReturnStatus bit. On input, the ReturnStatus bit must be clear. On + return, the ReturnStatus bit is set for each resource request granted, + and clear for each resource request denied. There are no other fields + modified by ProtectResourceVMCALL(). The STM_RESOURCE_LIST must be + contained entirely within a single 4K page. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The STM has successfully + merged the entire protection request into the active protection + profile. There is therefore no need to check the ReturnStatus + bits in the STM_RESOURCE_LIST. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_UNPROTECTABLE_RESOURCE + At least one of the requested resource protections intersects a + BIOS required resource. Therefore, the caller must walk through + the STM_RESOURCE_LIST to determine which of the requested + resources was not granted protection. The entire list must be + traversed since there may be multiple failures. + @retval EAX #ERROR_STM_MALFORMED_RESOURCE_LIST + The resource list could not be parsed correctly, or did not + terminate before crossing a 4K page boundary. The caller must + walk through the STM_RESOURCE_LIST to determine which of the + requested resources was not granted protection. The entire list + must be traversed since there may be multiple failures. + @retval EAX #ERROR_STM_OUT_OF_RESOURCES + The STM has encountered an internal error and cannot complete + the request. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_PROTECT_RESOURCE (BIT16 | 3) + + +/** + The UnProtectResourceVMCALL() is invoked by the MLE root to request that the + STM allow the SMI handler access to the specified resources. + + @param EAX #STM_API_UNPROTECT_RESOURCE (0x00010004) + @param EBX Low 32 bits of physical address of caller allocated + STM_RESOURCE_LIST. Bits 11:0 are ignored and assumed to be zero, + making the buffer 4K aligned. + @param ECX High 32 bits of physical address of caller allocated + STM_RESOURCE_LIST. + + @note All fields of STM_RESOURCE_LIST are inputs only, except for the + ReturnStatus bit. On input, the ReturnStatus bit must be clear. On + return, the ReturnStatus bit is set for each resource processed. For + a properly formed STM_RESOURCE_LIST, this should be all resources + listed. There are no other fields modified by + UnProtectResourceVMCALL(). The STM_RESOURCE_LIST must be contained + entirely within a single 4K page. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The requested resources are + not being guarded by the STM. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_MALFORMED_RESOURCE_LIST + The resource list could not be parsed correctly, or did not + terminate before crossing a 4K page boundary. The caller must + walk through the STM_RESOURCE_LIST to determine which of the + requested resources were not able to be unprotected. The entire + list must be traversed since there may be multiple failures. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_UNPROTECT_RESOURCE (BIT16 | 4) + + +/** + The GetBiosResourcesVMCALL() is invoked by the MLE root to request the list + of BIOS required resources from the STM. + + @param EAX #STM_API_GET_BIOS_RESOURCES (0x00010005) + @param EBX Low 32 bits of physical address of caller allocated destination + buffer. Bits 11:0 are ignored and assumed to be zero, making the + buffer 4K aligned. + @param ECX High 32 bits of physical address of caller allocated destination + buffer. + @param EDX Indicates which page of the BIOS resource list to copy into the + destination buffer. The first page is indicated by 0, the second + page by 1, etc. + + @retval CF 0 + No error, EAX set to STM_SUCCESS. The destination buffer + contains the BIOS required resources. If the page retrieved is + the last page, EDX will be cleared to 0. If there are more pages + to retrieve, EDX is incremented to the next page index. Calling + software should iterate on GetBiosResourcesVMCALL() until EDX is + returned cleared to 0. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_PAGE_NOT_FOUND + The page index supplied in EDX input was out of range. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + @retval EDX Page index of next page to read. A return of EDX=0 signifies + that the entire list has been read. + @note EDX is both an input and an output register. + + @note All other registers unmodified. +**/ +#define STM_API_GET_BIOS_RESOURCES (BIT16 | 5) + + +/** + The ManageVmcsDatabaseVMCALL() is invoked by the MLE root to add or remove an + MLE guest (including the MLE root) from the list of protected domains. + + @param EAX #STM_API_MANAGE_VMCS_DATABASE (0x00010006) + @param EBX Low 32 bits of physical address of caller allocated + STM_VMCS_DATABASE_REQUEST. Bits 11:0 are ignored and assumed to + be zero, making the buffer 4K aligned. + @param ECX High 32 bits of physical address of caller allocated + STM_VMCS_DATABASE_REQUEST. + + @note All fields of STM_VMCS_DATABASE_REQUEST are inputs only. They are not + modified by ManageVmcsDatabaseVMCALL(). + + @retval CF 0 + No error, EAX set to STM_SUCCESS. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_INVALID_VMCS + Indicates a request to remove a VMCS from the database was made, + but the referenced VMCS was not found in the database. + @retval EAX #ERROR_STM_VMCS_PRESENT + Indicates a request to add a VMCS to the database was made, but + the referenced VMCS was already present in the database. + @retval EAX #ERROR_INVALID_PARAMETER + Indicates non-zero reserved field. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred + + @note All other registers unmodified. +**/ +#define STM_API_MANAGE_VMCS_DATABASE (BIT16 | 6) + +/** + STM VMCS Database Request for #STM_API_MANAGE_VMCS_DATABASE VMCALL +**/ +typedef struct { + /// + /// bits 11:0 are reserved and must be 0 + /// + UINT64 VmcsPhysPointer; + UINT32 DomainType :4; + UINT32 XStatePolicy :2; + UINT32 DegradationPolicy :4; + /// + /// Must be 0 + /// + UINT32 Reserved1 :22; + UINT32 AddOrRemove; +} STM_VMCS_DATABASE_REQUEST; + +/** + Values for the DomainType field of #STM_VMCS_DATABASE_REQUEST + @{ +**/ +#define DOMAIN_UNPROTECTED 0 +#define DOMAIN_DISALLOWED_IO_OUT BIT0 +#define DOMAIN_DISALLOWED_IO_IN BIT1 +#define DOMAIN_INTEGRITY BIT2 +#define DOMAIN_CONFIDENTIALITY BIT3 +#define DOMAIN_INTEGRITY_PROT_OUT_IN (DOMAIN_INTEGRITY) +#define DOMAIN_FULLY_PROT_OUT_IN (DOMAIN_CONFIDENTIALITY | DOMAIN_INTEGRITY) +#define DOMAIN_FULLY_PROT (DOMAIN_FULLY_PROT_OUT_IN | DOMAIN_DISALLOWED_IO_IN | DOMAIN_DISALLOWED_IO_OUT) +/// @} + +/** + Values for the XStatePolicy field of #STM_VMCS_DATABASE_REQUEST + @{ +**/ +#define XSTATE_READWRITE 0x00 +#define XSTATE_READONLY 0x01 +#define XSTATE_SCRUB 0x03 +/// @} + +/** + Values for the AddOrRemove field of #STM_VMCS_DATABASE_REQUEST + @{ +**/ +#define STM_VMCS_DATABASE_REQUEST_ADD 1 +#define STM_VMCS_DATABASE_REQUEST_REMOVE 0 +/// @} + + +/** + InitializeProtectionVMCALL() prepares the STM for setup of the initial + protection profile which is subsequently communicated via one or more + invocations of ProtectResourceVMCALL(), prior to invoking StartStmVMCALL(). + It is only necessary to invoke InitializeProtectionVMCALL() on one processor + thread. InitializeProtectionVMCALL() does not alter whether SMIs are masked + or unmasked. The STM should return back to the MLE with "Blocking by SMI" set + to 1 in the GUEST_INTERRUPTIBILITY field for the VMCS the STM created for the + MLE guest. + + @param EAX #STM_API_INITIALIZE_PROTECTION (0x00010007) + + @retval CF 0 + No error, EAX set to STM_SUCCESS, EBX bits set to indicate STM + capabilities as defined below. The STM has set up an empty + protection profile, except for the resources that it sets up to + protect itself. The STM must not allow the SMI handler to map + any pages from the MSEG Base to the top of TSEG. The STM must + also not allow SMI handler access to those MSRs which the STM + requires for its own protection. + @retval CF 1 + An error occurred, EAX holds relevant error value. + @retval EAX #ERROR_STM_ALREADY_STARTED + The STM is already configured and active. The STM remains active + and guarding the previously enabled resource list. + @retval EAX #ERROR_STM_UNPROTECTABLE + The STM determines that based on the platform configuration, the + STM is unable to protect itself. For example, the BIOS required + resource list contains memory pages in MSEG. + @retval EAX #ERROR_STM_UNSPECIFIED + An unspecified error occurred. + + @note All other registers unmodified. +**/ +#define STM_API_INITIALIZE_PROTECTION (BIT16 | 7) + +/** + Byte granular support bits returned in EBX from #STM_API_INITIALIZE_PROTECTION + @{ +**/ +#define STM_RSC_BGI BIT1 +#define STM_RSC_BGM BIT2 +#define STM_RSC_MSR BIT3 +/// @} + + +/** + The ManageEventLogVMCALL() is invoked by the MLE root to control the logging + feature. It consists of several sub-functions to facilitate establishment of + the log itself, configuring what events will be logged, and functions to + start, stop, and clear the log. + + @param EAX #STM_API_MANAGE_EVENT_LOG (0x00010008) + @param EBX Low 32 bits of physical address of caller allocated + STM_EVENT_LOG_MANAGEMENT_REQUEST. Bits 11:0 are ignored and + assumed to be zero, making the buffer 4K aligned. + @param ECX High 32 bits of physical address of caller allocated + STM_EVENT_LOG_MANAGEMENT_REQUEST. + + @retval CF=0 + No error, EAX set to STM_SUCCESS. + @retval CF=1 + An error occurred, EAX holds relevant error value. See subfunction + descriptions below for details. + + @note All other registers unmodified. +**/ +#define STM_API_MANAGE_EVENT_LOG (BIT16 | 8) + +/// +/// STM Event Log Management Request for #STM_API_MANAGE_EVENT_LOG VMCALL +/// +typedef struct { + UINT32 SubFunctionIndex; + union { + struct { + UINT32 PageCount; + // + // number of elements is PageCount + // + UINT64 Pages[]; + } LogBuffer; + // + // bitmap of EVENT_TYPE + // + UINT32 EventEnableBitmap; + } Data; +} STM_EVENT_LOG_MANAGEMENT_REQUEST; + +/** + Defines values for the SubFunctionIndex field of + #STM_EVENT_LOG_MANAGEMENT_REQUEST + @{ +**/ +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_NEW_LOG 1 +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_CONFIGURE_LOG 2 +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_START_LOG 3 +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_STOP_LOG 4 +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_CLEAR_LOG 5 +#define STM_EVENT_LOG_MANAGEMENT_REQUEST_DELETE_LOG 6 +/// @} + +/** + Log Entry Header +**/ +typedef struct { + UINT32 EventSerialNumber; + UINT16 Type; + UINT16 Lock :1; + UINT16 Valid :1; + UINT16 ReadByMle :1; + UINT16 Wrapped :1; + UINT16 Reserved :12; +} LOG_ENTRY_HEADER; + +/** + Enum values for the Type field of #LOG_ENTRY_HEADER +**/ +typedef enum { + EvtLogStarted, + EvtLogStopped, + EvtLogInvalidParameterDetected, + EvtHandledProtectionException, + /// + /// unhandled protection exceptions result in reset & cannot be logged + /// + EvtBiosAccessToUnclaimedResource, + EvtMleResourceProtectionGranted, + EvtMleResourceProtectionDenied, + EvtMleResourceUnprotect, + EvtMleResourceUnprotectError, + EvtMleDomainTypeDegraded, + /// + /// add more here + /// + EvtMleMax, + /// + /// Not used + /// + EvtInvalid = 0xFFFFFFFF, +} EVENT_TYPE; + +typedef struct { + UINT32 Reserved; +} ENTRY_EVT_LOG_STARTED; + +typedef struct { + UINT32 Reserved; +} ENTRY_EVT_LOG_STOPPED; + +typedef struct { + UINT32 VmcallApiNumber; +} ENTRY_EVT_LOG_INVALID_PARAM; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_LOG_HANDLED_PROTECTION_EXCEPTION; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_BIOS_ACCESS_UNCLAIMED_RSC; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_MLE_RSC_PROT_GRANTED; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_MLE_RSC_PROT_DENIED; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_MLE_RSC_UNPROT; + +typedef struct { + STM_RSC Resource; +} ENTRY_EVT_MLE_RSC_UNPROT_ERROR; + +typedef struct { + UINT64 VmcsPhysPointer; + UINT8 ExpectedDomainType; + UINT8 DegradedDomainType; +} ENTRY_EVT_MLE_DOMAIN_TYPE_DEGRADED; + +typedef union { + ENTRY_EVT_LOG_STARTED Started; + ENTRY_EVT_LOG_STOPPED Stopped; + ENTRY_EVT_LOG_INVALID_PARAM InvalidParam; + ENTRY_EVT_LOG_HANDLED_PROTECTION_EXCEPTION HandledProtectionException; + ENTRY_EVT_BIOS_ACCESS_UNCLAIMED_RSC BiosUnclaimedRsc; + ENTRY_EVT_MLE_RSC_PROT_GRANTED MleRscProtGranted; + ENTRY_EVT_MLE_RSC_PROT_DENIED MleRscProtDenied; + ENTRY_EVT_MLE_RSC_UNPROT MleRscUnprot; + ENTRY_EVT_MLE_RSC_UNPROT_ERROR MleRscUnprotError; + ENTRY_EVT_MLE_DOMAIN_TYPE_DEGRADED MleDomainTypeDegraded; +} LOG_ENTRY_DATA; + +typedef struct { + LOG_ENTRY_HEADER Hdr; + LOG_ENTRY_DATA Data; +} STM_LOG_ENTRY; + +/** + Maximum STM Log Entry Size +**/ +#define STM_LOG_ENTRY_SIZE 256 + + +/** + STM Protection Exception Stack Frame Structures +**/ + +typedef struct { + UINT32 Rdi; + UINT32 Rsi; + UINT32 Rbp; + UINT32 Rdx; + UINT32 Rcx; + UINT32 Rbx; + UINT32 Rax; + UINT32 Cr3; + UINT32 Cr2; + UINT32 Cr0; + UINT32 VmcsExitInstructionInfo; + UINT32 VmcsExitInstructionLength; + UINT64 VmcsExitQualification; + /// + /// An TXT_SMM_PROTECTION_EXCEPTION_TYPE num value + /// + UINT32 ErrorCode; + UINT32 Rip; + UINT32 Cs; + UINT32 Rflags; + UINT32 Rsp; + UINT32 Ss; +} STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32; + +typedef struct { + UINT64 R15; + UINT64 R14; + UINT64 R13; + UINT64 R12; + UINT64 R11; + UINT64 R10; + UINT64 R9; + UINT64 R8; + UINT64 Rdi; + UINT64 Rsi; + UINT64 Rbp; + UINT64 Rdx; + UINT64 Rcx; + UINT64 Rbx; + UINT64 Rax; + UINT64 Cr8; + UINT64 Cr3; + UINT64 Cr2; + UINT64 Cr0; + UINT64 VmcsExitInstructionInfo; + UINT64 VmcsExitInstructionLength; + UINT64 VmcsExitQualification; + /// + /// An TXT_SMM_PROTECTION_EXCEPTION_TYPE num value + /// + UINT64 ErrorCode; + UINT64 Rip; + UINT64 Cs; + UINT64 Rflags; + UINT64 Rsp; + UINT64 Ss; +} STM_PROTECTION_EXCEPTION_STACK_FRAME_X64; + +typedef union { + STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32 *Ia32StackFrame; + STM_PROTECTION_EXCEPTION_STACK_FRAME_X64 *X64StackFrame; +} STM_PROTECTION_EXCEPTION_STACK_FRAME; + +/** + Enum values for the ErrorCode field in + #STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32 and + #STM_PROTECTION_EXCEPTION_STACK_FRAME_X64 +**/ +typedef enum { + TxtSmmPageViolation = 1, + TxtSmmMsrViolation, + TxtSmmRegisterViolation, + TxtSmmIoViolation, + TxtSmmPciViolation +} TXT_SMM_PROTECTION_EXCEPTION_TYPE; + +/** + TXT Pocessor SMM Descriptor (PSD) structures +**/ + +typedef struct { + UINT64 SpeRip; + UINT64 SpeRsp; + UINT16 SpeSs; + UINT16 PageViolationException:1; + UINT16 MsrViolationException:1; + UINT16 RegisterViolationException:1; + UINT16 IoViolationException:1; + UINT16 PciViolationException:1; + UINT16 Reserved1:11; + UINT32 Reserved2; +} STM_PROTECTION_EXCEPTION_HANDLER; + +typedef struct { + UINT8 ExecutionDisableOutsideSmrr:1; + UINT8 Intel64Mode:1; + UINT8 Cr4Pae : 1; + UINT8 Cr4Pse : 1; + UINT8 Reserved1 : 4; +} STM_SMM_ENTRY_STATE; + +typedef struct { + UINT8 SmramToVmcsRestoreRequired : 1; ///> BIOS restore hint + UINT8 ReinitializeVmcsRequired : 1; ///> BIOS request + UINT8 Reserved2 : 6; +} STM_SMM_RESUME_STATE; + +typedef struct { + UINT8 DomainType : 4; ///> STM input to BIOS on each SMI + UINT8 XStatePolicy : 2; ///> STM input to BIOS on each SMI + UINT8 EptEnabled : 1; + UINT8 Reserved3 : 1; +} STM_SMM_STATE; + +#define TXT_SMM_PSD_OFFSET 0xfb00 +#define TXT_PROCESSOR_SMM_DESCRIPTOR_SIGNATURE SIGNATURE_64('T', 'X', 'T', 'P', 'S', 'S', 'I', 'G') +#define TXT_PROCESSOR_SMM_DESCRIPTOR_VERSION_MAJOR 1 +#define TXT_PROCESSOR_SMM_DESCRIPTOR_VERSION_MINOR 0 + +typedef struct { + UINT64 Signature; + UINT16 Size; + UINT8 SmmDescriptorVerMajor; + UINT8 SmmDescriptorVerMinor; + UINT32 LocalApicId; + STM_SMM_ENTRY_STATE SmmEntryState; + STM_SMM_RESUME_STATE SmmResumeState; + STM_SMM_STATE StmSmmState; + UINT8 Reserved4; + UINT16 SmmCs; + UINT16 SmmDs; + UINT16 SmmSs; + UINT16 SmmOtherSegment; + UINT16 SmmTr; + UINT16 Reserved5; + UINT64 SmmCr3; + UINT64 SmmStmSetupRip; + UINT64 SmmStmTeardownRip; + UINT64 SmmSmiHandlerRip; + UINT64 SmmSmiHandlerRsp; + UINT64 SmmGdtPtr; + UINT32 SmmGdtSize; + UINT32 RequiredStmSmmRevId; + STM_PROTECTION_EXCEPTION_HANDLER StmProtectionExceptionHandler; + UINT64 Reserved6; + UINT64 BiosHwResourceRequirementsPtr; + // extend area + UINT64 AcpiRsdp; + UINT8 PhysicalAddressBits; +} TXT_PROCESSOR_SMM_DESCRIPTOR; + +#pragma pack () + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/StmResourceDescriptor.h b/Core/UefiCpuPkg/Include/Register/StmResourceDescriptor.h new file mode 100644 index 0000000000..1518462ec0 --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/StmResourceDescriptor.h @@ -0,0 +1,228 @@ +/** @file + STM Resource Descriptor + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + SMI Transfer Monitor (STM) User Guide Revision 1.00 + +**/ + +#ifndef _STM_RESOURCE_DESCRIPTOR_H_ +#define _STM_RESOURCE_DESCRIPTOR_H_ + +#pragma pack (1) + +/** + STM Resource Descriptor Header +**/ +typedef struct { + UINT32 RscType; + UINT16 Length; + UINT16 ReturnStatus:1; + UINT16 Reserved:14; + UINT16 IgnoreResource:1; +} STM_RSC_DESC_HEADER; + +/** + Define values for the RscType field of #STM_RSC_DESC_HEADER + @{ +**/ +#define END_OF_RESOURCES 0 +#define MEM_RANGE 1 +#define IO_RANGE 2 +#define MMIO_RANGE 3 +#define MACHINE_SPECIFIC_REG 4 +#define PCI_CFG_RANGE 5 +#define TRAPPED_IO_RANGE 6 +#define ALL_RESOURCES 7 +#define REGISTER_VIOLATION 8 +#define MAX_DESC_TYPE 8 +/// @} + +/** + STM Resource End Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT64 ResourceListContinuation; +} STM_RSC_END; + +/** + STM Resource Memory Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT64 Base; + UINT64 Length; + UINT32 RWXAttributes:3; + UINT32 Reserved:29; + UINT32 Reserved_2; +} STM_RSC_MEM_DESC; + +/** + Define values for the RWXAttributes field of #STM_RSC_MEM_DESC + @{ +**/ +#define STM_RSC_MEM_R 0x1 +#define STM_RSC_MEM_W 0x2 +#define STM_RSC_MEM_X 0x4 +/// @} + +/** + STM Resource I/O Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT16 Base; + UINT16 Length; + UINT32 Reserved; +} STM_RSC_IO_DESC; + +/** + STM Resource MMIO Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT64 Base; + UINT64 Length; + UINT32 RWXAttributes:3; + UINT32 Reserved:29; + UINT32 Reserved_2; +} STM_RSC_MMIO_DESC; + +/** + Define values for the RWXAttributes field of #STM_RSC_MMIO_DESC + @{ +**/ +#define STM_RSC_MMIO_R 0x1 +#define STM_RSC_MMIO_W 0x2 +#define STM_RSC_MMIO_X 0x4 +/// @} + +/** + STM Resource MSR Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT32 MsrIndex; + UINT32 KernelModeProcessing:1; + UINT32 Reserved:31; + UINT64 ReadMask; + UINT64 WriteMask; +} STM_RSC_MSR_DESC; + +/** + STM PCI Device Path node used for the PciDevicePath field of + #STM_RSC_PCI_CFG_DESC +**/ +typedef struct { + /// + /// Must be 1, indicating Hardware Device Path + /// + UINT8 Type; + /// + /// Must be 1, indicating PCI + /// + UINT8 Subtype; + /// + /// sizeof(STM_PCI_DEVICE_PATH_NODE) which is 6 + /// + UINT16 Length; + UINT8 PciFunction; + UINT8 PciDevice; +} STM_PCI_DEVICE_PATH_NODE; + +/** + STM Resource PCI Configuration Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT16 RWAttributes:2; + UINT16 Reserved:14; + UINT16 Base; + UINT16 Length; + UINT8 OriginatingBusNumber; + UINT8 LastNodeIndex; + STM_PCI_DEVICE_PATH_NODE PciDevicePath[1]; +//STM_PCI_DEVICE_PATH_NODE PciDevicePath[LastNodeIndex + 1]; +} STM_RSC_PCI_CFG_DESC; + +/** + Define values for the RWAttributes field of #STM_RSC_PCI_CFG_DESC + @{ +**/ +#define STM_RSC_PCI_CFG_R 0x1 +#define STM_RSC_PCI_CFG_W 0x2 +/// @} + +/** + STM Resource Trapped I/O Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT16 Base; + UINT16 Length; + UINT16 In:1; + UINT16 Out:1; + UINT16 Api:1; + UINT16 Reserved1:13; + UINT16 Reserved2; +} STM_RSC_TRAPPED_IO_DESC; + +/** + STM Resource All Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; +} STM_RSC_ALL_RESOURCES_DESC; + +/** + STM Register Volation Descriptor +**/ +typedef struct { + STM_RSC_DESC_HEADER Hdr; + UINT32 RegisterType; + UINT32 Reserved; + UINT64 ReadMask; + UINT64 WriteMask; +} STM_REGISTER_VIOLATION_DESC; + +/** + Enum values for the RWAttributes field of #STM_REGISTER_VIOLATION_DESC +**/ +typedef enum { + StmRegisterCr0, + StmRegisterCr2, + StmRegisterCr3, + StmRegisterCr4, + StmRegisterCr8, + StmRegisterMax, +} STM_REGISTER_VIOLATION_TYPE; + +/** + Union of all STM resource types +**/ +typedef union { + STM_RSC_DESC_HEADER Header; + STM_RSC_END End; + STM_RSC_MEM_DESC Mem; + STM_RSC_IO_DESC Io; + STM_RSC_MMIO_DESC Mmio; + STM_RSC_MSR_DESC Msr; + STM_RSC_PCI_CFG_DESC PciCfg; + STM_RSC_TRAPPED_IO_DESC TrappedIo; + STM_RSC_ALL_RESOURCES_DESC All; + STM_REGISTER_VIOLATION_DESC RegisterViolation; +} STM_RSC; + +#pragma pack () + +#endif diff --git a/Core/UefiCpuPkg/Include/Register/StmStatusCode.h b/Core/UefiCpuPkg/Include/Register/StmStatusCode.h new file mode 100644 index 0000000000..f1fcb8b6ef --- /dev/null +++ b/Core/UefiCpuPkg/Include/Register/StmStatusCode.h @@ -0,0 +1,78 @@ +/** @file + STM Status Codes + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + SMI Transfer Monitor (STM) User Guide Revision 1.00 + +**/ + +#ifndef _STM_STATUS_CODE_H_ +#define _STM_STATUS_CODE_H_ + +/** + STM Status Codes +**/ +typedef UINT32 STM_STATUS; + +/** + Success code have BIT31 clear. + All error codes have BIT31 set. + STM errors have BIT16 set. + SMM errors have BIT17 set + Errors that apply to both STM and SMM have bits BIT15, BT16, and BIT17 set. + STM TXT.ERRORCODE codes have BIT30 set. + @{ +**/ +#define STM_SUCCESS 0x00000000 +#define SMM_SUCCESS 0x00000000 +#define ERROR_STM_SECURITY_VIOLATION (BIT31 | BIT16 | 0x0001) +#define ERROR_STM_CACHE_TYPE_NOT_SUPPORTED (BIT31 | BIT16 | 0x0002) +#define ERROR_STM_PAGE_NOT_FOUND (BIT31 | BIT16 | 0x0003) +#define ERROR_STM_BAD_CR3 (BIT31 | BIT16 | 0x0004) +#define ERROR_STM_PHYSICAL_OVER_4G (BIT31 | BIT16 | 0x0005) +#define ERROR_STM_VIRTUAL_SPACE_TOO_SMALL (BIT31 | BIT16 | 0x0006) +#define ERROR_STM_UNPROTECTABLE_RESOURCE (BIT31 | BIT16 | 0x0007) +#define ERROR_STM_ALREADY_STARTED (BIT31 | BIT16 | 0x0008) +#define ERROR_STM_WITHOUT_SMX_UNSUPPORTED (BIT31 | BIT16 | 0x0009) +#define ERROR_STM_STOPPED (BIT31 | BIT16 | 0x000A) +#define ERROR_STM_BUFFER_TOO_SMALL (BIT31 | BIT16 | 0x000B) +#define ERROR_STM_INVALID_VMCS_DATABASE (BIT31 | BIT16 | 0x000C) +#define ERROR_STM_MALFORMED_RESOURCE_LIST (BIT31 | BIT16 | 0x000D) +#define ERROR_STM_INVALID_PAGECOUNT (BIT31 | BIT16 | 0x000E) +#define ERROR_STM_LOG_ALLOCATED (BIT31 | BIT16 | 0x000F) +#define ERROR_STM_LOG_NOT_ALLOCATED (BIT31 | BIT16 | 0x0010) +#define ERROR_STM_LOG_NOT_STOPPED (BIT31 | BIT16 | 0x0011) +#define ERROR_STM_LOG_NOT_STARTED (BIT31 | BIT16 | 0x0012) +#define ERROR_STM_RESERVED_BIT_SET (BIT31 | BIT16 | 0x0013) +#define ERROR_STM_NO_EVENTS_ENABLED (BIT31 | BIT16 | 0x0014) +#define ERROR_STM_OUT_OF_RESOURCES (BIT31 | BIT16 | 0x0015) +#define ERROR_STM_FUNCTION_NOT_SUPPORTED (BIT31 | BIT16 | 0x0016) +#define ERROR_STM_UNPROTECTABLE (BIT31 | BIT16 | 0x0017) +#define ERROR_STM_UNSUPPORTED_MSR_BIT (BIT31 | BIT16 | 0x0018) +#define ERROR_STM_UNSPECIFIED (BIT31 | BIT16 | 0xFFFF) +#define ERROR_SMM_BAD_BUFFER (BIT31 | BIT17 | 0x0001) +#define ERROR_SMM_INVALID_RSC (BIT31 | BIT17 | 0x0004) +#define ERROR_SMM_INVALID_BUFFER_SIZE (BIT31 | BIT17 | 0x0005) +#define ERROR_SMM_BUFFER_TOO_SHORT (BIT31 | BIT17 | 0x0006) +#define ERROR_SMM_INVALID_LIST (BIT31 | BIT17 | 0x0007) +#define ERROR_SMM_OUT_OF_MEMORY (BIT31 | BIT17 | 0x0008) +#define ERROR_SMM_AFTER_INIT (BIT31 | BIT17 | 0x0009) +#define ERROR_SMM_UNSPECIFIED (BIT31 | BIT17 | 0xFFFF) +#define ERROR_INVALID_API (BIT31 | BIT17 | BIT16 | BIT15 | 0x0001) +#define ERROR_INVALID_PARAMETER (BIT31 | BIT17 | BIT16 | BIT15 | 0x0002) +#define STM_CRASH_PROTECTION_EXCEPTION (BIT31 | BIT30 | 0xF001) +#define STM_CRASH_PROTECTION_EXCEPTION_FAILURE (BIT31 | BIT30 | 0xF002) +#define STM_CRASH_DOMAIN_DEGRADATION_FAILURE (BIT31 | BIT30 | 0xF003) +#define STM_CRASH_BIOS_PANIC (BIT31 | BIT30 | 0xE000) +/// @} + +#endif diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf new file mode 100644 index 0000000000..b397ce0dc6 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf @@ -0,0 +1,48 @@ +## @file +# This library defines some routines that are generic for IA32 family CPU. +# +# The library routines are UEFI specification compliant. +# +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseUefiCpuLib + MODULE_UNI_FILE = BaseUefiCpuLib.uni + FILE_GUID = 34C24FD7-7A90-45c2-89FD-946473D9CE98 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = UefiCpuLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.IA32] + Ia32/InitializeFpu.asm + Ia32/InitializeFpu.nasm + Ia32/InitializeFpu.S + +[Sources.X64] + X64/InitializeFpu.asm + X64/InitializeFpu.nasm + X64/InitializeFpu.S + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + UefiCpuLib + diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni new file mode 100644 index 0000000000..1a1c0d2411 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni @@ -0,0 +1,22 @@ +// /** @file +// This library defines some routines that are generic for IA32 family CPU. +// +// The library routines are UEFI specification compliant. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Defines generic routines for IA32 family CPUs." + +#string STR_MODULE_DESCRIPTION #language en-US "The library routines comply with the UEFI Specification." + diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S new file mode 100644 index 0000000000..4972bc2e7f --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S @@ -0,0 +1,73 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* +#------------------------------------------------------------------------------ + +# +# Float control word initial value: +# all exceptions masked, double-precision, round-to-nearest +# +ASM_PFX(mFpuControlWord): .word 0x027F +# +# Multimedia-extensions control word: +# all exceptions masked, round-to-nearest, flush to zero for masked underflow +# +ASM_PFX(mMmxControlWord): .long 0x01F80 + +# +# Initializes floating point units for requirement of UEFI specification. +# +# This function initializes floating-point control word to 0x027F (all exceptions +# masked,double-precision, round-to-nearest) and multimedia-extensions control word +# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +# for masked underflow). +# +ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits) +ASM_PFX(InitializeFloatingPointUnits): + + pushl %ebx + + # + # Initialize floating point units + # + finit + fldcw ASM_PFX(mFpuControlWord) + + # + # Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test + # whether the processor supports SSE instruction. + # + movl $1, %eax + cpuid + btl $25, %edx + jnc Done + + # + # Set OSFXSR bit 9 in CR4 + # + movl %cr4, %eax + or $0x200, %eax + movl %eax, %cr4 + + # + # The processor should support SSE instruction and we can use + # ldmxcsr instruction + # + ldmxcsr ASM_PFX(mMmxControlWord) + +Done: + popl %ebx + + ret + +#END + diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm new file mode 100644 index 0000000000..3c31da98f6 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm @@ -0,0 +1,79 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2009, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* +;------------------------------------------------------------------------------ + + + .686 + .model flat,C + .const +; +; Float control word initial value: +; all exceptions masked, double-precision, round-to-nearest +; +mFpuControlWord DW 027Fh +; +; Multimedia-extensions control word: +; all exceptions masked, round-to-nearest, flush to zero for masked underflow +; +mMmxControlWord DD 01F80h + + .xmm + .code + +; +; Initializes floating point units for requirement of UEFI specification. +; +; This function initializes floating-point control word to 0x027F (all exceptions +; masked,double-precision, round-to-nearest) and multimedia-extensions control word +; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +; for masked underflow). +; +InitializeFloatingPointUnits PROC PUBLIC + + push ebx + + ; + ; Initialize floating point units + ; + finit + fldcw mFpuControlWord + + ; + ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test + ; whether the processor supports SSE instruction. + ; + mov eax, 1 + cpuid + bt edx, 25 + jnc Done + + ; + ; Set OSFXSR bit 9 in CR4 + ; + mov eax, cr4 + or eax, BIT9 + mov cr4, eax + + ; + ; The processor should support SSE instruction and we can use + ; ldmxcsr instruction + ; + ldmxcsr mMmxControlWord +Done: + pop ebx + + ret + +InitializeFloatingPointUnits ENDP + +END diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm new file mode 100644 index 0000000000..55085e019f --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm @@ -0,0 +1,74 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2016, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* +;------------------------------------------------------------------------------ + + SECTION .rdata + +; +; Float control word initial value: +; all exceptions masked, double-precision, round-to-nearest +; +mFpuControlWord: DW 0x27F +; +; Multimedia-extensions control word: +; all exceptions masked, round-to-nearest, flush to zero for masked underflow +; +mMmxControlWord: DD 0x1F80 + + SECTION .text + +; +; Initializes floating point units for requirement of UEFI specification. +; +; This function initializes floating-point control word to 0x027F (all exceptions +; masked,double-precision, round-to-nearest) and multimedia-extensions control word +; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +; for masked underflow). +; +global ASM_PFX(InitializeFloatingPointUnits) +ASM_PFX(InitializeFloatingPointUnits): + + push ebx + + ; + ; Initialize floating point units + ; + finit + fldcw [mFpuControlWord] + + ; + ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test + ; whether the processor supports SSE instruction. + ; + mov eax, 1 + cpuid + bt edx, 25 + jnc Done + + ; + ; Set OSFXSR bit 9 in CR4 + ; + mov eax, cr4 + or eax, BIT9 + mov cr4, eax + + ; + ; The processor should support SSE instruction and we can use + ; ldmxcsr instruction + ; + ldmxcsr [mMmxControlWord] +Done: + pop ebx + + ret + diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S new file mode 100644 index 0000000000..97d9f72338 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S @@ -0,0 +1,57 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* +#------------------------------------------------------------------------------ + +# +# Initializes floating point units for requirement of UEFI specification. +# +# This function initializes floating-point control word to 0x037F (all exceptions +# masked,double-extended-precision, round-to-nearest) and multimedia-extensions control word +# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +# for masked underflow). +# +ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits) +ASM_PFX(InitializeFloatingPointUnits): + + # + # Initialize floating point units + # + finit + + # + # Float control word initial value: + # all exceptions masked, double-precision, round-to-nearest + # + pushq $0x037F + lea (%rsp), %rax + fldcw (%rax) + popq %rax + + # + # Set OSFXSR bit 9 in CR4 + # + movq %cr4, %rax + or $0x200, %rax + movq %rax, %cr4 + + # + # Multimedia-extensions control word: + # all exceptions masked, round-to-nearest, flush to zero for masked underflow + # + pushq $0x01F80 + lea (%rsp), %rax + ldmxcsr (%rax) + popq %rax + + ret + diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm new file mode 100644 index 0000000000..331af15cc6 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm @@ -0,0 +1,62 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* +;------------------------------------------------------------------------------ + + +.const +; +; Float control word initial value: +; all exceptions masked, double-extended-precision, round-to-nearest +; +mFpuControlWord DW 037Fh +; +; Multimedia-extensions control word: +; all exceptions masked, round-to-nearest, flush to zero for masked underflow +; +mMmxControlWord DD 01F80h + +.code + + +; +; Initializes floating point units for requirement of UEFI specification. +; +; This function initializes floating-point control word to 0x027F (all exceptions +; masked,double-precision, round-to-nearest) and multimedia-extensions control word +; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +; for masked underflow). +; +InitializeFloatingPointUnits PROC PUBLIC + + ; + ; Initialize floating point units + ; + ; The following opcodes stand for instruction 'finit' + ; to be supported by some 64-bit assemblers + ; + DB 9Bh, 0DBh, 0E3h + fldcw mFpuControlWord + + ; + ; Set OSFXSR bit 9 in CR4 + ; + mov rax, cr4 + or rax, BIT9 + mov cr4, rax + + ldmxcsr mMmxControlWord + + ret +InitializeFloatingPointUnits ENDP + +END diff --git a/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm new file mode 100644 index 0000000000..904b64e510 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm @@ -0,0 +1,60 @@ +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+;* This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* +;------------------------------------------------------------------------------ + + SECTION .rdata +; +; Float control word initial value: +; all exceptions masked, double-extended-precision, round-to-nearest +; +mFpuControlWord: DW 0x37F +; +; Multimedia-extensions control word: +; all exceptions masked, round-to-nearest, flush to zero for masked underflow +; +mMmxControlWord: DD 0x1F80 + +DEFAULT REL +SECTION .text + +; +; Initializes floating point units for requirement of UEFI specification. +; +; This function initializes floating-point control word to 0x027F (all exceptions +; masked,double-precision, round-to-nearest) and multimedia-extensions control word +; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero +; for masked underflow). +; +global ASM_PFX(InitializeFloatingPointUnits) +ASM_PFX(InitializeFloatingPointUnits): + + ; + ; Initialize floating point units + ; + ; The following opcodes stand for instruction 'finit' + ; to be supported by some 64-bit assemblers + ; + DB 0x9B, 0xDB, 0xE3 + fldcw [mFpuControlWord] + + ; + ; Set OSFXSR bit 9 in CR4 + ; + mov rax, cr4 + or rax, BIT9 + mov cr4, rax + + ldmxcsr [mMmxControlWord] + + ret + diff --git a/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c new file mode 100644 index 0000000000..f81bbb2252 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -0,0 +1,1093 @@ +/** @file + Local APIC Library. + + This local APIC library instance supports xAPIC mode only. + + Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +// +// Library internal functions +// + +/** + Determine if the CPU supports the Local APIC Base Address MSR. + + @retval TRUE The CPU supports the Local APIC Base Address MSR. + @retval FALSE The CPU does not support the Local APIC Base Address MSR. + +**/ +BOOLEAN +LocalApicBaseAddressMsrSupported ( + VOID + ) +{ + UINT32 RegEax; + UINTN FamilyId; + + AsmCpuid (1, &RegEax, NULL, NULL, NULL); + FamilyId = BitFieldRead32 (RegEax, 8, 11); + if (FamilyId == 0x04 || FamilyId == 0x05) { + // + // CPUs with a FamilyId of 0x04 or 0x05 do not support the + // Local APIC Base Address MSR + // + return FALSE; + } + return TRUE; +} + +/** + Retrieve the base address of local APIC. + + @return The base address of local APIC. + +**/ +UINTN +EFIAPI +GetLocalApicBaseAddress ( + VOID + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // If CPU does not support Local APIC Base Address MSR, then retrieve + // Local APIC Base Address from PCD + // + return PcdGet32 (PcdCpuLocalApicBaseAddress); + } + + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + + return (UINTN)(LShiftU64 ((UINT64) ApicBaseMsr.Bits.ApicBaseHi, 32)) + + (((UINTN)ApicBaseMsr.Bits.ApicBase) << 12); +} + +/** + Set the base address of local APIC. + + If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). + + @param[in] BaseAddress Local APIC base address to be set. + +**/ +VOID +EFIAPI +SetLocalApicBaseAddress ( + IN UINTN BaseAddress + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // Ignore set request if the CPU does not support APIC Base Address MSR + // + return; + } + + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + + ApicBaseMsr.Bits.ApicBase = (UINT32) (BaseAddress >> 12); + ApicBaseMsr.Bits.ApicBaseHi = (UINT32) (RShiftU64((UINT64) BaseAddress, 32)); + + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); +} + +/** + Read from a local APIC register. + + 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. + + @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. + It must be 16-byte aligned. + + @return 32-bit Value read from the register. +**/ +UINT32 +EFIAPI +ReadLocalApicReg ( + IN UINTN MmioOffset + ) +{ + ASSERT ((MmioOffset & 0xf) == 0); + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); + + return MmioRead32 (GetLocalApicBaseAddress() + MmioOffset); +} + +/** + Write to a local APIC register. + + This function writes to 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 write. + + if the register index is invalid or unsupported in current APIC mode, then ASSERT. + + @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. + It must be 16-byte aligned. + @param Value Value to be written to the register. +**/ +VOID +EFIAPI +WriteLocalApicReg ( + IN UINTN MmioOffset, + IN UINT32 Value + ) +{ + ASSERT ((MmioOffset & 0xf) == 0); + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); + + MmioWrite32 (GetLocalApicBaseAddress() + MmioOffset, Value); +} + +/** + Send an IPI by writing to ICR. + + This function returns after the IPI has been accepted by the target processor. + + @param IcrLow 32-bit value to be written to the low half of ICR. + @param ApicId APIC ID of the target processor if this IPI is targeted for a specific processor. +**/ +VOID +SendIpi ( + IN UINT32 IcrLow, + IN UINT32 ApicId + ) +{ + LOCAL_APIC_ICR_LOW IcrLowReg; + UINT32 IcrHigh; + BOOLEAN InterruptState; + + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); + ASSERT (ApicId <= 0xff); + + InterruptState = SaveAndDisableInterrupts (); + + // + // Save existing contents of ICR high 32 bits + // + IcrHigh = ReadLocalApicReg (XAPIC_ICR_HIGH_OFFSET); + + // + // Wait for DeliveryStatus clear in case a previous IPI + // is still being sent + // + do { + IcrLowReg.Uint32 = ReadLocalApicReg (XAPIC_ICR_LOW_OFFSET); + } while (IcrLowReg.Bits.DeliveryStatus != 0); + + // + // For xAPIC, the act of writing to the low doubleword of the ICR causes the IPI to be sent. + // + WriteLocalApicReg (XAPIC_ICR_HIGH_OFFSET, ApicId << 24); + WriteLocalApicReg (XAPIC_ICR_LOW_OFFSET, IcrLow); + + // + // Wait for DeliveryStatus clear again + // + do { + IcrLowReg.Uint32 = ReadLocalApicReg (XAPIC_ICR_LOW_OFFSET); + } while (IcrLowReg.Bits.DeliveryStatus != 0); + + // + // And restore old contents of ICR high + // + WriteLocalApicReg (XAPIC_ICR_HIGH_OFFSET, IcrHigh); + + SetInterruptState (InterruptState); + +} + +// +// Library API implementation functions +// + +/** + Get the current local APIC mode. + + If local APIC is disabled, then ASSERT. + + @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. + @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. +**/ +UINTN +EFIAPI +GetApicMode ( + VOID + ) +{ + DEBUG_CODE ( + { + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + // + // Check to see if the CPU supports the APIC Base Address MSR + // + if (LocalApicBaseAddressMsrSupported ()) { + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + // + // Local APIC should have been enabled + // + ASSERT (ApicBaseMsr.Bits.EN != 0); + ASSERT (ApicBaseMsr.Bits.EXTD == 0); + } + } + ); + return LOCAL_APIC_MODE_XAPIC; +} + +/** + Set the current local APIC mode. + + If the specified local APIC mode is not valid, then ASSERT. + If the specified local APIC mode can't be set as current, then ASSERT. + + @param ApicMode APIC mode to be set. + + @note This API must not be called from an interrupt handler or SMI handler. + It may result in unpredictable behavior. +**/ +VOID +EFIAPI +SetApicMode ( + IN UINTN ApicMode + ) +{ + ASSERT (ApicMode == LOCAL_APIC_MODE_XAPIC); + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); +} + +/** + Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. + + In xAPIC mode, the initial local APIC ID may be different from current APIC ID. + In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, + the 32-bit local APIC ID is returned as initial APIC ID. + + @return 32-bit initial local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetInitialApicId ( + VOID + ) +{ + UINT32 ApicId; + UINT32 MaxCpuIdIndex; + UINT32 RegEbx; + + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); + + // + // Get the max index of basic CPUID + // + AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + + // + // If CPUID Leaf B is supported, + // And CPUID.0BH:EBX[15:0] reports a non-zero value, + // Then the initial 32-bit APIC ID = CPUID.0BH:EDX + // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24] + // + if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, &RegEbx, NULL, &ApicId); + if ((RegEbx & (BIT16 - 1)) != 0) { + return ApicId; + } + } + + AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL); + return RegEbx >> 24; +} + +/** + Get the local APIC ID of the executing processor. + + @return 32-bit local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetApicId ( + VOID + ) +{ + UINT32 ApicId; + + ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); + + if ((ApicId = GetInitialApicId ()) < 0x100) { + // + // If the initial local APIC ID is less 0x100, read APIC ID from + // XAPIC_ID_OFFSET, otherwise return the initial local APIC ID. + // + ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET); + ApicId >>= 24; + } + return ApicId; +} + +/** + Get the value of the local APIC version register. + + @return the value of the local APIC version register. +**/ +UINT32 +EFIAPI +GetApicVersion ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_VERSION_OFFSET); +} + +/** + Send a Fixed IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId The local APIC ID of the target processor. + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpi ( + IN UINT32 ApicId, + IN UINT8 Vector + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; + IcrLow.Bits.Level = 1; + IcrLow.Bits.Vector = Vector; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send a Fixed IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpiAllExcludingSelf ( + IN UINT8 Vector + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + IcrLow.Bits.Vector = Vector; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send a SMI IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendSmiIpi ( + IN UINT32 ApicId + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send a SMI IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendSmiIpiAllExcludingSelf ( + VOID + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send an INIT IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendInitIpi ( + IN UINT32 ApicId + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send an INIT IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendInitIpiAllExcludingSelf ( + VOID + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param ApicId Specify the local APIC ID of the target processor. + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipi ( + IN UINT32 ApicId, + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) == 0); + + SendInitIpi (ApicId); + MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); + IcrLow.Uint32 = 0; + IcrLow.Bits.Vector = (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); + MicroSecondDelay (200); + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipiAllExcludingSelf ( + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) == 0); + + SendInitIpiAllExcludingSelf (); + MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); + IcrLow.Uint32 = 0; + IcrLow.Bits.Vector = (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); + MicroSecondDelay (200); + SendIpi (IcrLow.Uint32, 0); +} + +/** + Initialize the state of the SoftwareEnable bit in the Local APIC + Spurious Interrupt Vector register. + + @param Enable If TRUE, then set SoftwareEnable to 1 + If FALSE, then set SoftwareEnable to 0. + +**/ +VOID +EFIAPI +InitializeLocalApicSoftwareEnable ( + IN BOOLEAN Enable + ) +{ + LOCAL_APIC_SVR Svr; + + // + // Set local APIC software-enabled bit. + // + Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); + if (Enable) { + if (Svr.Bits.SoftwareEnable == 0) { + Svr.Bits.SoftwareEnable = 1; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } else { + if (Svr.Bits.SoftwareEnable == 1) { + Svr.Bits.SoftwareEnable = 0; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } +} + +/** + Programming Virtual Wire Mode. + + This function programs the local APIC for virtual wire mode following + the example described in chapter A.3 of the MP 1.4 spec. + + IOxAPIC is not involved in this type of virtual wire mode. +**/ +VOID +EFIAPI +ProgramVirtualWireMode ( + VOID + ) +{ + LOCAL_APIC_SVR Svr; + LOCAL_APIC_LVT_LINT Lint; + + // + // Enable the APIC via SVR and set the spurious interrupt to use Int 00F. + // + Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); + Svr.Bits.SpuriousVector = 0xf; + Svr.Bits.SoftwareEnable = 1; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + + // + // Program the LINT0 vector entry as ExtInt. Not masked, edge, active high. + // + Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); + Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_EXTINT; + Lint.Bits.InputPinPolarity = 0; + Lint.Bits.TriggerMode = 0; + Lint.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, Lint.Uint32); + + // + // Program the LINT0 vector entry as NMI. Not masked, edge, active high. + // + Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); + Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI; + Lint.Bits.InputPinPolarity = 0; + Lint.Bits.TriggerMode = 0; + Lint.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, Lint.Uint32); +} + +/** + Disable LINT0 & LINT1 interrupts. + + This function sets the mask flag in the LVT LINT0 & LINT1 registers. +**/ +VOID +EFIAPI +DisableLvtInterrupts ( + VOID + ) +{ + LOCAL_APIC_LVT_LINT LvtLint; + + LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); + LvtLint.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, LvtLint.Uint32); + + LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); + LvtLint.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, LvtLint.Uint32); +} + +/** + Read the initial count value from the init-count register. + + @return The initial count value read from the init-count register. +**/ +UINT32 +EFIAPI +GetApicTimerInitCount ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET); +} + +/** + Read the current count value from the current-count register. + + @return The current count value read from the current-count register. +**/ +UINT32 +EFIAPI +GetApicTimerCurrentCount ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_TIMER_CURRENT_COUNT_OFFSET); +} + +/** + Initialize the local APIC timer. + + The local APIC timer is initialized and enabled. + + @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + If it is 0, then use the current divide value in the DCR. + @param InitCount The initial count value. + @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector The timer interrupt vector number. +**/ +VOID +EFIAPI +InitializeApicTimer ( + IN UINTN DivideValue, + IN UINT32 InitCount, + IN BOOLEAN PeriodicMode, + IN UINT8 Vector + ) +{ + LOCAL_APIC_DCR Dcr; + LOCAL_APIC_LVT_TIMER LvtTimer; + UINT32 Divisor; + + // + // Ensure local APIC is in software-enabled state. + // + InitializeLocalApicSoftwareEnable (TRUE); + + // + // Program init-count register. + // + WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); + + if (DivideValue != 0) { + ASSERT (DivideValue <= 128); + ASSERT (DivideValue == GetPowerOfTwo32((UINT32)DivideValue)); + Divisor = (UINT32)((HighBitSet32 ((UINT32)DivideValue) - 1) & 0x7); + + Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); + Dcr.Bits.DivideValue1 = (Divisor & 0x3); + Dcr.Bits.DivideValue2 = (Divisor >> 2); + WriteLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET, Dcr.Uint32); + } + + // + // Enable APIC timer interrupt with specified timer mode. + // + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + if (PeriodicMode) { + LvtTimer.Bits.TimerMode = 1; + } else { + LvtTimer.Bits.TimerMode = 0; + } + LvtTimer.Bits.Mask = 0; + LvtTimer.Bits.Vector = Vector; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Get the state of the local APIC timer. + + This function will ASSERT if the local APIC is not software enabled. + + @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector Return the timer interrupt vector number. +**/ +VOID +EFIAPI +GetApicTimerState ( + OUT UINTN *DivideValue OPTIONAL, + OUT BOOLEAN *PeriodicMode OPTIONAL, + OUT UINT8 *Vector OPTIONAL + ) +{ + UINT32 Divisor; + LOCAL_APIC_DCR Dcr; + LOCAL_APIC_LVT_TIMER LvtTimer; + + // + // Check the APIC Software Enable/Disable bit (bit 8) in Spurious-Interrupt + // Vector Register. + // This bit will be 1, if local APIC is software enabled. + // + ASSERT ((ReadLocalApicReg(XAPIC_SPURIOUS_VECTOR_OFFSET) & BIT8) != 0); + + if (DivideValue != NULL) { + Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); + Divisor = Dcr.Bits.DivideValue1 | (Dcr.Bits.DivideValue2 << 2); + Divisor = (Divisor + 1) & 0x7; + *DivideValue = ((UINTN)1) << Divisor; + } + + if (PeriodicMode != NULL || Vector != NULL) { + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + if (PeriodicMode != NULL) { + if (LvtTimer.Bits.TimerMode == 1) { + *PeriodicMode = TRUE; + } else { + *PeriodicMode = FALSE; + } + } + if (Vector != NULL) { + *Vector = (UINT8) LvtTimer.Bits.Vector; + } + } +} + +/** + Enable the local APIC timer interrupt. +**/ +VOID +EFIAPI +EnableApicTimerInterrupt ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + LvtTimer.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Disable the local APIC timer interrupt. +**/ +VOID +EFIAPI +DisableApicTimerInterrupt ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + LvtTimer.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Get the local APIC timer interrupt state. + + @retval TRUE The local APIC timer interrupt is enabled. + @retval FALSE The local APIC timer interrupt is disabled. +**/ +BOOLEAN +EFIAPI +GetApicTimerInterruptState ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + return (BOOLEAN)(LvtTimer.Bits.Mask == 0); +} + +/** + Send EOI to the local APIC. +**/ +VOID +EFIAPI +SendApicEoi ( + VOID + ) +{ + WriteLocalApicReg (XAPIC_EOI_OFFSET, 0); +} + +/** + Get the 32-bit address that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + @return 32-bit address used to send an MSI to the Local APIC. +**/ +UINT32 +EFIAPI +GetApicMsiAddress ( + VOID + ) +{ + LOCAL_APIC_MSI_ADDRESS MsiAddress; + + // + // Return address for an MSI interrupt to be delivered only to the APIC ID + // of the currently executing processor. + // + MsiAddress.Uint32 = 0; + MsiAddress.Bits.BaseAddress = 0xFEE; + MsiAddress.Bits.DestinationId = GetApicId (); + return MsiAddress.Uint32; +} + +/** + Get the 64-bit data value that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + If Vector is not in range 0x10..0xFE, then ASSERT(). + If DeliveryMode is not supported, then ASSERT(). + + @param Vector The 8-bit interrupt vector associated with the MSI. + Must be in the range 0x10..0xFE + @param DeliveryMode A 3-bit value that specifies how the recept of the MSI + is handled. The only supported values are: + 0: LOCAL_APIC_DELIVERY_MODE_FIXED + 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY + 2: LOCAL_APIC_DELIVERY_MODE_SMI + 4: LOCAL_APIC_DELIVERY_MODE_NMI + 5: LOCAL_APIC_DELIVERY_MODE_INIT + 7: LOCAL_APIC_DELIVERY_MODE_EXTINT + + @param LevelTriggered TRUE specifies a level triggered interrupt. + FALSE specifies an edge triggered interrupt. + @param AssertionLevel Ignored if LevelTriggered is FALSE. + TRUE specifies a level triggered interrupt that active + when the interrupt line is asserted. + FALSE specifies a level triggered interrupt that active + when the interrupt line is deasserted. + + @return 64-bit data value used to send an MSI to the Local APIC. +**/ +UINT64 +EFIAPI +GetApicMsiValue ( + IN UINT8 Vector, + IN UINTN DeliveryMode, + IN BOOLEAN LevelTriggered, + IN BOOLEAN AssertionLevel + ) +{ + LOCAL_APIC_MSI_DATA MsiData; + + ASSERT (Vector >= 0x10 && Vector <= 0xFE); + ASSERT (DeliveryMode < 8 && DeliveryMode != 6 && DeliveryMode != 3); + + MsiData.Uint64 = 0; + MsiData.Bits.Vector = Vector; + MsiData.Bits.DeliveryMode = (UINT32)DeliveryMode; + if (LevelTriggered) { + MsiData.Bits.TriggerMode = 1; + if (AssertionLevel) { + MsiData.Bits.Level = 1; + } + } + return MsiData.Uint64; +} + +/** + Get Package ID/Core ID/Thread ID of a processor. + + The algorithm assumes the target system has symmetry across physical + package boundaries with respect to the number of logical processors + per package, number of cores per package. + + @param[in] InitialApicId Initial APIC ID of the target logical processor. + @param[out] Package Returns the processor package ID. + @param[out] Core Returns the processor core ID. + @param[out] Thread Returns the processor thread ID. +**/ +VOID +EFIAPI +GetProcessorLocationByApicId ( + IN UINT32 InitialApicId, + OUT UINT32 *Package OPTIONAL, + OUT UINT32 *Core OPTIONAL, + OUT UINT32 *Thread OPTIONAL + ) +{ + BOOLEAN TopologyLeafSupported; + UINTN ThreadBits; + UINTN CoreBits; + CPUID_VERSION_INFO_EBX VersionInfoEbx; + CPUID_VERSION_INFO_EDX VersionInfoEdx; + CPUID_CACHE_PARAMS_EAX CacheParamsEax; + CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; + CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; + UINT32 MaxCpuIdIndex; + UINT32 SubIndex; + UINTN LevelType; + UINT32 MaxLogicProcessorsPerPackage; + UINT32 MaxCoresPerPackage; + + // + // Check if the processor is capable of supporting more than one logical processor. + // + AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); + if (VersionInfoEdx.Bits.HTT == 0) { + if (Thread != NULL) { + *Thread = 0; + } + if (Core != NULL) { + *Core = 0; + } + if (Package != NULL) { + *Package = 0; + } + return; + } + + ThreadBits = 0; + CoreBits = 0; + + // + // Assume three-level mapping of APIC ID: Package:Core:SMT. + // + TopologyLeafSupported = FALSE; + + // + // Get the max index of basic CPUID + // + AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + + // + // If the extended topology enumeration leaf is available, it + // is the preferred mechanism for enumerating topology. + // + if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + AsmCpuidEx( + CPUID_EXTENDED_TOPOLOGY, + 0, + &ExtendedTopologyEax.Uint32, + &ExtendedTopologyEbx.Uint32, + &ExtendedTopologyEcx.Uint32, + NULL + ); + // + // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for + // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not + // supported on that processor. + // + if (ExtendedTopologyEbx.Uint32 != 0) { + TopologyLeafSupported = TRUE; + + // + // Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract + // the SMT sub-field of x2APIC ID. + // + LevelType = ExtendedTopologyEcx.Bits.LevelType; + ASSERT(LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT); + ThreadBits = ExtendedTopologyEax.Bits.ApicIdShift; + + // + // Software must not assume any "level type" encoding + // value to be related to any sub-leaf index, except sub-leaf 0. + // + SubIndex = 1; + do { + AsmCpuidEx( + CPUID_EXTENDED_TOPOLOGY, + SubIndex, + &ExtendedTopologyEax.Uint32, + NULL, + &ExtendedTopologyEcx.Uint32, + NULL + ); + LevelType = ExtendedTopologyEcx.Bits.LevelType; + if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE) { + CoreBits = ExtendedTopologyEax.Bits.ApicIdShift - ThreadBits; + break; + } + SubIndex++; + } while (LevelType != CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID); + } + } + + if (!TopologyLeafSupported) { + AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); + MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; + if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { + AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); + MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + } + else { + // + // Must be a single-core processor. + // + MaxCoresPerPackage = 1; + } + + ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); + CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } + + if (Thread != NULL) { + *Thread = InitialApicId & ((1 << ThreadBits) - 1); + } + if (Core != NULL) { + *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); + } + if (Package != NULL) { + *Package = (InitialApicId >> (ThreadBits + CoreBits)); + } +} diff --git a/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf new file mode 100644 index 0000000000..7dd2714af3 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf @@ -0,0 +1,49 @@ +## @file +# The Local Apic library supports xAPIC mode only. +# +# Note: Local APIC library assumes local APIC is enabled. It does not handle cases +# where local APIC is disabled. +# +# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseXApicLib + MODULE_UNI_FILE = BaseXApicLib.uni + FILE_GUID = D87CA0A8-1AC2-439b-90F8-EF4A2AC88DAF + MODULE_TYPE = BASE + VERSION_STRING = 1.1 + LIBRARY_CLASS = LocalApicLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + BaseXApicLib.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + TimerLib + IoLib + PcdLib + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress ## SOMETIMES_CONSUMES diff --git a/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni new file mode 100644 index 0000000000..49b05e6cec --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni @@ -0,0 +1,23 @@ +// /** @file +// The Local Apic library supports xAPIC mode only. +// +// Note: Local APIC library assumes local APIC is enabled. It does not handle cases +// where local APIC is disabled. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Supports xAPIC mode only" + +#string STR_MODULE_DESCRIPTION #language en-US "Note: Local APIC library assumes local APIC is enabled. It does not handle cases where local APIC is disabled." + diff --git a/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c new file mode 100644 index 0000000000..e690d2aa14 --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -0,0 +1,1188 @@ +/** @file + Local APIC Library. + + This local APIC library instance supports x2APIC capable processors + which have xAPIC and x2APIC modes. + + Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +// +// Library internal functions +// + +/** + Determine if the CPU supports the Local APIC Base Address MSR. + + @retval TRUE The CPU supports the Local APIC Base Address MSR. + @retval FALSE The CPU does not support the Local APIC Base Address MSR. + +**/ +BOOLEAN +LocalApicBaseAddressMsrSupported ( + VOID + ) +{ + UINT32 RegEax; + UINTN FamilyId; + + AsmCpuid (1, &RegEax, NULL, NULL, NULL); + FamilyId = BitFieldRead32 (RegEax, 8, 11); + if (FamilyId == 0x04 || FamilyId == 0x05) { + // + // CPUs with a FamilyId of 0x04 or 0x05 do not support the + // Local APIC Base Address MSR + // + return FALSE; + } + return TRUE; +} + +/** + Retrieve the base address of local APIC. + + @return The base address of local APIC. + +**/ +UINTN +EFIAPI +GetLocalApicBaseAddress ( + VOID + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // If CPU does not support Local APIC Base Address MSR, then retrieve + // Local APIC Base Address from PCD + // + return PcdGet32 (PcdCpuLocalApicBaseAddress); + } + + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + + return (UINTN)(LShiftU64 ((UINT64) ApicBaseMsr.Bits.ApicBaseHi, 32)) + + (((UINTN)ApicBaseMsr.Bits.ApicBase) << 12); +} + +/** + Set the base address of local APIC. + + If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). + + @param[in] BaseAddress Local APIC base address to be set. + +**/ +VOID +EFIAPI +SetLocalApicBaseAddress ( + IN UINTN BaseAddress + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // Ignore set request of the CPU does not support APIC Base Address MSR + // + return; + } + + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + + ApicBaseMsr.Bits.ApicBase = (UINT32) (BaseAddress >> 12); + ApicBaseMsr.Bits.ApicBaseHi = (UINT32) (RShiftU64((UINT64) BaseAddress, 32)); + + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); +} + +/** + Read from a local APIC register. + + 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. + + @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. + It must be 16-byte aligned. + + @return 32-bit Value read from the register. +**/ +UINT32 +EFIAPI +ReadLocalApicReg ( + IN UINTN MmioOffset + ) +{ + UINT32 MsrIndex; + + ASSERT ((MmioOffset & 0xf) == 0); + + if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { + return MmioRead32 (GetLocalApicBaseAddress() + MmioOffset); + } else { + // + // DFR is not supported in x2APIC mode. + // + ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET); + // + // Note that in x2APIC mode, ICR is a 64-bit MSR that needs special treatment. It + // is not supported in this function for simplicity. + // + ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET); + + MsrIndex = (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS; + return AsmReadMsr32 (MsrIndex); + } +} + +/** + Write to a local APIC register. + + This function writes to 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 write. + + if the register index is invalid or unsupported in current APIC mode, then ASSERT. + + @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. + It must be 16-byte aligned. + @param Value Value to be written to the register. +**/ +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 { + // + // DFR is not supported in x2APIC mode. + // + ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET); + // + // Note that in x2APIC mode, ICR is a 64-bit MSR that needs special treatment. It + // is not supported in this function for simplicity. + // + ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET); + ASSERT (MmioOffset != XAPIC_ICR_LOW_OFFSET); + + MsrIndex = (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS; + // + // The serializing semantics of WRMSR are relaxed when writing to the APIC registers. + // Use memory fence here to force the serializing semantics to be consisent with xAPIC mode. + // + MemoryFence (); + AsmWriteMsr32 (MsrIndex, Value); + } +} + +/** + Send an IPI by writing to ICR. + + This function returns after the IPI has been accepted by the target processor. + + @param IcrLow 32-bit value to be written to the low half of ICR. + @param ApicId APIC ID of the target processor if this IPI is targeted for a specific processor. +**/ +VOID +SendIpi ( + IN UINT32 IcrLow, + IN UINT32 ApicId + ) +{ + UINT64 MsrValue; + LOCAL_APIC_ICR_LOW IcrLowReg; + UINTN LocalApciBaseAddress; + UINT32 IcrHigh; + BOOLEAN InterruptState; + + // + // Legacy APIC or X2APIC? + // + if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { + ASSERT (ApicId <= 0xff); + + InterruptState = SaveAndDisableInterrupts (); + + // + // Get base address of this LAPIC + // + LocalApciBaseAddress = GetLocalApicBaseAddress(); + + // + // Save existing contents of ICR high 32 bits + // + IcrHigh = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET); + + // + // Wait for DeliveryStatus clear in case a previous IPI + // is still being sent + // + do { + IcrLowReg.Uint32 = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET); + } while (IcrLowReg.Bits.DeliveryStatus != 0); + + // + // For xAPIC, the act of writing to the low doubleword of the ICR causes the IPI to be sent. + // + MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET, ApicId << 24); + MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET, IcrLow); + + // + // Wait for DeliveryStatus clear again + // + do { + IcrLowReg.Uint32 = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET); + } while (IcrLowReg.Bits.DeliveryStatus != 0); + + // + // And restore old contents of ICR high + // + MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET, IcrHigh); + + SetInterruptState (InterruptState); + + } else { + // + // For x2APIC, A single MSR write to the Interrupt Command Register is required for dispatching an + // interrupt in x2APIC mode. + // + MsrValue = LShiftU64 ((UINT64) ApicId, 32) | IcrLow; + AsmWriteMsr64 (X2APIC_MSR_ICR_ADDRESS, MsrValue); + } +} + +// +// Library API implementation functions +// + +/** + Get the current local APIC mode. + + If local APIC is disabled, then ASSERT. + + @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. + @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. +**/ +UINTN +EFIAPI +GetApicMode ( + VOID + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // If CPU does not support APIC Base Address MSR, then return XAPIC mode + // + return LOCAL_APIC_MODE_XAPIC; + } + + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + // + // Local APIC should have been enabled + // + ASSERT (ApicBaseMsr.Bits.EN != 0); + if (ApicBaseMsr.Bits.EXTD != 0) { + return LOCAL_APIC_MODE_X2APIC; + } else { + return LOCAL_APIC_MODE_XAPIC; + } +} + +/** + Set the current local APIC mode. + + If the specified local APIC mode is not valid, then ASSERT. + If the specified local APIC mode can't be set as current, then ASSERT. + + @param ApicMode APIC mode to be set. + + @note This API must not be called from an interrupt handler or SMI handler. + It may result in unpredictable behavior. +**/ +VOID +EFIAPI +SetApicMode ( + IN UINTN ApicMode + ) +{ + UINTN CurrentMode; + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + + if (!LocalApicBaseAddressMsrSupported ()) { + // + // Ignore set request if the CPU does not support APIC Base Address MSR + // + return; + } + + CurrentMode = GetApicMode (); + if (CurrentMode == LOCAL_APIC_MODE_XAPIC) { + switch (ApicMode) { + case LOCAL_APIC_MODE_XAPIC: + break; + case LOCAL_APIC_MODE_X2APIC: + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + ApicBaseMsr.Bits.EXTD = 1; + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); + break; + default: + ASSERT (FALSE); + } + } else { + switch (ApicMode) { + case LOCAL_APIC_MODE_XAPIC: + // + // Transition from x2APIC mode to xAPIC mode is a two-step process: + // x2APIC -> Local APIC disabled -> xAPIC + // + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + ApicBaseMsr.Bits.EXTD = 0; + ApicBaseMsr.Bits.EN = 0; + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); + ApicBaseMsr.Bits.EN = 1; + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); + break; + case LOCAL_APIC_MODE_X2APIC: + break; + default: + ASSERT (FALSE); + } + } +} + +/** + Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. + + In xAPIC mode, the initial local APIC ID may be different from current APIC ID. + In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, + the 32-bit local APIC ID is returned as initial APIC ID. + + @return 32-bit initial local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetInitialApicId ( + VOID + ) +{ + UINT32 ApicId; + UINT32 MaxCpuIdIndex; + UINT32 RegEbx; + + if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { + // + // Get the max index of basic CPUID + // + AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + // + // If CPUID Leaf B is supported, + // And CPUID.0BH:EBX[15:0] reports a non-zero value, + // Then the initial 32-bit APIC ID = CPUID.0BH:EDX + // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24] + // + if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, &RegEbx, NULL, &ApicId); + if ((RegEbx & (BIT16 - 1)) != 0) { + return ApicId; + } + } + AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL); + return RegEbx >> 24; + } else { + return GetApicId (); + } +} + +/** + Get the local APIC ID of the executing processor. + + @return 32-bit local APIC ID of the executing processor. +**/ +UINT32 +EFIAPI +GetApicId ( + VOID + ) +{ + UINT32 ApicId; + UINT32 InitApicId; + + ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET); + if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { + ApicId = ((InitApicId = GetInitialApicId ()) < 0x100) ? (ApicId >> 24) : InitApicId; + } + + return ApicId; +} + +/** + Get the value of the local APIC version register. + + @return the value of the local APIC version register. +**/ +UINT32 +EFIAPI +GetApicVersion ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_VERSION_OFFSET); +} + +/** + Send a Fixed IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId The local APIC ID of the target processor. + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpi ( + IN UINT32 ApicId, + IN UINT8 Vector + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; + IcrLow.Bits.Level = 1; + IcrLow.Bits.Vector = Vector; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send a Fixed IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + @param Vector The vector number of the interrupt being sent. +**/ +VOID +EFIAPI +SendFixedIpiAllExcludingSelf ( + IN UINT8 Vector + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + IcrLow.Bits.Vector = Vector; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send a SMI IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendSmiIpi ( + IN UINT32 ApicId + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send a SMI IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendSmiIpiAllExcludingSelf ( + VOID + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send an INIT IPI to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + @param ApicId Specify the local APIC ID of the target processor. +**/ +VOID +EFIAPI +SendInitIpi ( + IN UINT32 ApicId + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send an INIT IPI to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. +**/ +VOID +EFIAPI +SendInitIpiAllExcludingSelf ( + VOID + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + IcrLow.Uint32 = 0; + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + +/** + Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. + + This function returns after the IPI has been accepted by the target processor. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param ApicId Specify the local APIC ID of the target processor. + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipi ( + IN UINT32 ApicId, + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) == 0); + + SendInitIpi (ApicId); + MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); + IcrLow.Uint32 = 0; + IcrLow.Bits.Vector = (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level = 1; + SendIpi (IcrLow.Uint32, ApicId); + MicroSecondDelay (200); + SendIpi (IcrLow.Uint32, ApicId); +} + +/** + Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. + + This function returns after the IPI has been accepted by the target processors. + + if StartupRoutine >= 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + + @param StartupRoutine Points to a start-up routine which is below 1M physical + address and 4K aligned. +**/ +VOID +EFIAPI +SendInitSipiSipiAllExcludingSelf ( + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) == 0); + + SendInitIpiAllExcludingSelf (); + MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); + IcrLow.Uint32 = 0; + IcrLow.Bits.Vector = (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level = 1; + IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); + MicroSecondDelay (200); + SendIpi (IcrLow.Uint32, 0); +} + +/** + Initialize the state of the SoftwareEnable bit in the Local APIC + Spurious Interrupt Vector register. + + @param Enable If TRUE, then set SoftwareEnable to 1 + If FALSE, then set SoftwareEnable to 0. + +**/ +VOID +EFIAPI +InitializeLocalApicSoftwareEnable ( + IN BOOLEAN Enable + ) +{ + LOCAL_APIC_SVR Svr; + + // + // Set local APIC software-enabled bit. + // + Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); + if (Enable) { + if (Svr.Bits.SoftwareEnable == 0) { + Svr.Bits.SoftwareEnable = 1; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } else { + if (Svr.Bits.SoftwareEnable == 1) { + Svr.Bits.SoftwareEnable = 0; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + } + } +} + +/** + Programming Virtual Wire Mode. + + This function programs the local APIC for virtual wire mode following + the example described in chapter A.3 of the MP 1.4 spec. + + IOxAPIC is not involved in this type of virtual wire mode. +**/ +VOID +EFIAPI +ProgramVirtualWireMode ( + VOID + ) +{ + LOCAL_APIC_SVR Svr; + LOCAL_APIC_LVT_LINT Lint; + + // + // Enable the APIC via SVR and set the spurious interrupt to use Int 00F. + // + Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); + Svr.Bits.SpuriousVector = 0xf; + Svr.Bits.SoftwareEnable = 1; + WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); + + // + // Program the LINT0 vector entry as ExtInt. Not masked, edge, active high. + // + Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); + Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_EXTINT; + Lint.Bits.InputPinPolarity = 0; + Lint.Bits.TriggerMode = 0; + Lint.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, Lint.Uint32); + + // + // Program the LINT0 vector entry as NMI. Not masked, edge, active high. + // + Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); + Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI; + Lint.Bits.InputPinPolarity = 0; + Lint.Bits.TriggerMode = 0; + Lint.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, Lint.Uint32); +} + +/** + Disable LINT0 & LINT1 interrupts. + + This function sets the mask flag in the LVT LINT0 & LINT1 registers. +**/ +VOID +EFIAPI +DisableLvtInterrupts ( + VOID + ) +{ + LOCAL_APIC_LVT_LINT LvtLint; + + LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); + LvtLint.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, LvtLint.Uint32); + + LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); + LvtLint.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, LvtLint.Uint32); +} + +/** + Read the initial count value from the init-count register. + + @return The initial count value read from the init-count register. +**/ +UINT32 +EFIAPI +GetApicTimerInitCount ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET); +} + +/** + Read the current count value from the current-count register. + + @return The current count value read from the current-count register. +**/ +UINT32 +EFIAPI +GetApicTimerCurrentCount ( + VOID + ) +{ + return ReadLocalApicReg (XAPIC_TIMER_CURRENT_COUNT_OFFSET); +} + +/** + Initialize the local APIC timer. + + The local APIC timer is initialized and enabled. + + @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + If it is 0, then use the current divide value in the DCR. + @param InitCount The initial count value. + @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector The timer interrupt vector number. +**/ +VOID +EFIAPI +InitializeApicTimer ( + IN UINTN DivideValue, + IN UINT32 InitCount, + IN BOOLEAN PeriodicMode, + IN UINT8 Vector + ) +{ + LOCAL_APIC_DCR Dcr; + LOCAL_APIC_LVT_TIMER LvtTimer; + UINT32 Divisor; + + // + // Ensure local APIC is in software-enabled state. + // + InitializeLocalApicSoftwareEnable (TRUE); + + // + // Program init-count register. + // + WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); + + if (DivideValue != 0) { + ASSERT (DivideValue <= 128); + ASSERT (DivideValue == GetPowerOfTwo32((UINT32)DivideValue)); + Divisor = (UINT32)((HighBitSet32 ((UINT32)DivideValue) - 1) & 0x7); + + Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); + Dcr.Bits.DivideValue1 = (Divisor & 0x3); + Dcr.Bits.DivideValue2 = (Divisor >> 2); + WriteLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET, Dcr.Uint32); + } + + // + // Enable APIC timer interrupt with specified timer mode. + // + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + if (PeriodicMode) { + LvtTimer.Bits.TimerMode = 1; + } else { + LvtTimer.Bits.TimerMode = 0; + } + LvtTimer.Bits.Mask = 0; + LvtTimer.Bits.Vector = Vector; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Get the state of the local APIC timer. + + This function will ASSERT if the local APIC is not software enabled. + + @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. + @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. + @param Vector Return the timer interrupt vector number. +**/ +VOID +EFIAPI +GetApicTimerState ( + OUT UINTN *DivideValue OPTIONAL, + OUT BOOLEAN *PeriodicMode OPTIONAL, + OUT UINT8 *Vector OPTIONAL + ) +{ + UINT32 Divisor; + LOCAL_APIC_DCR Dcr; + LOCAL_APIC_LVT_TIMER LvtTimer; + + // + // Check the APIC Software Enable/Disable bit (bit 8) in Spurious-Interrupt + // Vector Register. + // This bit will be 1, if local APIC is software enabled. + // + ASSERT ((ReadLocalApicReg(XAPIC_SPURIOUS_VECTOR_OFFSET) & BIT8) != 0); + + if (DivideValue != NULL) { + Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); + Divisor = Dcr.Bits.DivideValue1 | (Dcr.Bits.DivideValue2 << 2); + Divisor = (Divisor + 1) & 0x7; + *DivideValue = ((UINTN)1) << Divisor; + } + + if (PeriodicMode != NULL || Vector != NULL) { + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + if (PeriodicMode != NULL) { + if (LvtTimer.Bits.TimerMode == 1) { + *PeriodicMode = TRUE; + } else { + *PeriodicMode = FALSE; + } + } + if (Vector != NULL) { + *Vector = (UINT8) LvtTimer.Bits.Vector; + } + } +} + +/** + Enable the local APIC timer interrupt. +**/ +VOID +EFIAPI +EnableApicTimerInterrupt ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + LvtTimer.Bits.Mask = 0; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Disable the local APIC timer interrupt. +**/ +VOID +EFIAPI +DisableApicTimerInterrupt ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + LvtTimer.Bits.Mask = 1; + WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); +} + +/** + Get the local APIC timer interrupt state. + + @retval TRUE The local APIC timer interrupt is enabled. + @retval FALSE The local APIC timer interrupt is disabled. +**/ +BOOLEAN +EFIAPI +GetApicTimerInterruptState ( + VOID + ) +{ + LOCAL_APIC_LVT_TIMER LvtTimer; + + LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); + return (BOOLEAN)(LvtTimer.Bits.Mask == 0); +} + +/** + Send EOI to the local APIC. +**/ +VOID +EFIAPI +SendApicEoi ( + VOID + ) +{ + WriteLocalApicReg (XAPIC_EOI_OFFSET, 0); +} + +/** + Get the 32-bit address that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + @return 32-bit address used to send an MSI to the Local APIC. +**/ +UINT32 +EFIAPI +GetApicMsiAddress ( + VOID + ) +{ + LOCAL_APIC_MSI_ADDRESS MsiAddress; + + // + // Return address for an MSI interrupt to be delivered only to the APIC ID + // of the currently executing processor. + // + MsiAddress.Uint32 = 0; + MsiAddress.Bits.BaseAddress = 0xFEE; + MsiAddress.Bits.DestinationId = GetApicId (); + return MsiAddress.Uint32; +} + +/** + Get the 64-bit data value that a device should use to send a Message Signaled + Interrupt (MSI) to the Local APIC of the currently executing processor. + + If Vector is not in range 0x10..0xFE, then ASSERT(). + If DeliveryMode is not supported, then ASSERT(). + + @param Vector The 8-bit interrupt vector associated with the MSI. + Must be in the range 0x10..0xFE + @param DeliveryMode A 3-bit value that specifies how the recept of the MSI + is handled. The only supported values are: + 0: LOCAL_APIC_DELIVERY_MODE_FIXED + 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY + 2: LOCAL_APIC_DELIVERY_MODE_SMI + 4: LOCAL_APIC_DELIVERY_MODE_NMI + 5: LOCAL_APIC_DELIVERY_MODE_INIT + 7: LOCAL_APIC_DELIVERY_MODE_EXTINT + + @param LevelTriggered TRUE specifies a level triggered interrupt. + FALSE specifies an edge triggered interrupt. + @param AssertionLevel Ignored if LevelTriggered is FALSE. + TRUE specifies a level triggered interrupt that active + when the interrupt line is asserted. + FALSE specifies a level triggered interrupt that active + when the interrupt line is deasserted. + + @return 64-bit data value used to send an MSI to the Local APIC. +**/ +UINT64 +EFIAPI +GetApicMsiValue ( + IN UINT8 Vector, + IN UINTN DeliveryMode, + IN BOOLEAN LevelTriggered, + IN BOOLEAN AssertionLevel + ) +{ + LOCAL_APIC_MSI_DATA MsiData; + + ASSERT (Vector >= 0x10 && Vector <= 0xFE); + ASSERT (DeliveryMode < 8 && DeliveryMode != 6 && DeliveryMode != 3); + + MsiData.Uint64 = 0; + MsiData.Bits.Vector = Vector; + MsiData.Bits.DeliveryMode = (UINT32)DeliveryMode; + if (LevelTriggered) { + MsiData.Bits.TriggerMode = 1; + if (AssertionLevel) { + MsiData.Bits.Level = 1; + } + } + return MsiData.Uint64; +} + +/** + Get Package ID/Core ID/Thread ID of a processor. + + The algorithm assumes the target system has symmetry across physical + package boundaries with respect to the number of logical processors + per package, number of cores per package. + + @param[in] InitialApicId Initial APIC ID of the target logical processor. + @param[out] Package Returns the processor package ID. + @param[out] Core Returns the processor core ID. + @param[out] Thread Returns the processor thread ID. +**/ +VOID +EFIAPI +GetProcessorLocationByApicId ( + IN UINT32 InitialApicId, + OUT UINT32 *Package OPTIONAL, + OUT UINT32 *Core OPTIONAL, + OUT UINT32 *Thread OPTIONAL + ) +{ + BOOLEAN TopologyLeafSupported; + UINTN ThreadBits; + UINTN CoreBits; + CPUID_VERSION_INFO_EBX VersionInfoEbx; + CPUID_VERSION_INFO_EDX VersionInfoEdx; + CPUID_CACHE_PARAMS_EAX CacheParamsEax; + CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; + CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; + UINT32 MaxCpuIdIndex; + UINT32 SubIndex; + UINTN LevelType; + UINT32 MaxLogicProcessorsPerPackage; + UINT32 MaxCoresPerPackage; + + // + // Check if the processor is capable of supporting more than one logical processor. + // + AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); + if (VersionInfoEdx.Bits.HTT == 0) { + if (Thread != NULL) { + *Thread = 0; + } + if (Core != NULL) { + *Core = 0; + } + if (Package != NULL) { + *Package = 0; + } + return; + } + + ThreadBits = 0; + CoreBits = 0; + + // + // Assume three-level mapping of APIC ID: Package:Core:SMT. + // + TopologyLeafSupported = FALSE; + + // + // Get the max index of basic CPUID + // + AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + + // + // If the extended topology enumeration leaf is available, it + // is the preferred mechanism for enumerating topology. + // + if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + AsmCpuidEx( + CPUID_EXTENDED_TOPOLOGY, + 0, + &ExtendedTopologyEax.Uint32, + &ExtendedTopologyEbx.Uint32, + &ExtendedTopologyEcx.Uint32, + NULL + ); + // + // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for + // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not + // supported on that processor. + // + if (ExtendedTopologyEbx.Uint32 != 0) { + TopologyLeafSupported = TRUE; + + // + // Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract + // the SMT sub-field of x2APIC ID. + // + LevelType = ExtendedTopologyEcx.Bits.LevelType; + ASSERT(LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT); + ThreadBits = ExtendedTopologyEax.Bits.ApicIdShift; + + // + // Software must not assume any "level type" encoding + // value to be related to any sub-leaf index, except sub-leaf 0. + // + SubIndex = 1; + do { + AsmCpuidEx( + CPUID_EXTENDED_TOPOLOGY, + SubIndex, + &ExtendedTopologyEax.Uint32, + NULL, + &ExtendedTopologyEcx.Uint32, + NULL + ); + LevelType = ExtendedTopologyEcx.Bits.LevelType; + if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE) { + CoreBits = ExtendedTopologyEax.Bits.ApicIdShift - ThreadBits; + break; + } + SubIndex++; + } while (LevelType != CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID); + } + } + + if (!TopologyLeafSupported) { + AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); + MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; + if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { + AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); + MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + } + else { + // + // Must be a single-core processor. + // + MaxCoresPerPackage = 1; + } + + ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); + CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } + + if (Thread != NULL) { + *Thread = InitialApicId & ((1 << ThreadBits) - 1); + } + if (Core != NULL) { + *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); + } + if (Package != NULL) { + *Package = (InitialApicId >> (ThreadBits + CoreBits)); + } +} diff --git a/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf new file mode 100644 index 0000000000..53e186858f --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf @@ -0,0 +1,49 @@ +## @file +# The Local Apic library supports x2APIC capable processors which have xAPIC and x2APIC modes. +# +# Note: Local APIC library assumes local APIC is enabled. It does not handle cases +# where local APIC is disabled. +# +# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseXApicX2ApicLib + MODULE_UNI_FILE = BaseXApicX2ApicLib.uni + FILE_GUID = 967B6E05-F10D-4c10-8BF7-365291CA143F + MODULE_TYPE = BASE + VERSION_STRING = 1.1 + LIBRARY_CLASS = LocalApicLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + BaseXApicX2ApicLib.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + TimerLib + IoLib + PcdLib + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress ## SOMETIMES_CONSUMES diff --git a/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni new file mode 100644 index 0000000000..97f62273ba --- /dev/null +++ b/Core/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni @@ -0,0 +1,23 @@ +// /** @file +// The Local Apic library supports x2APIC capable processors which have xAPIC and x2APIC modes. +// +// Note: Local APIC library assumes local APIC is enabled. It does not handle cases +// where local APIC is disabled. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Supports x2APIC capable processors that have xAPIC and x2APIC modes" + +#string STR_MODULE_DESCRIPTION #language en-US "Note: Local APIC library assumes local APIC is enabled. It does not handle cases where local APIC is disabled." + diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c new file mode 100644 index 0000000000..178bfb50ab --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c @@ -0,0 +1,127 @@ +/** @file + AESNI feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +AesniGetConfigData ( + IN UINTN NumberOfProcessors + ) +{ + UINT64 *ConfigData; + + ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors); + ASSERT (ConfigData != NULL); + return ConfigData; +} + +/** + Detects if AESNI feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE AESNI feature is supported. + @retval FALSE AESNI feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +AesniSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; + + if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { + MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; + MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); + return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1); + } + return FALSE; +} + +/** + Initializes AESNI feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the AESNI feature must be enabled. + If FALSE, then the AESNI feature must be disabled. + + @retval RETURN_SUCCESS AESNI feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +AesniInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; + + // + // SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index, + // Simply use MSR_SANDY_BRIDGE_FEATURE_CONFIG here + // + // The scope of the MSR_SANDY_BRIDGE_FEATURE_CONFIG is Core, only program MSR_FEATURE_CONFIG for thread 0 + // of each core. Otherwise, once a thread in the core disabled AES, the other thread will cause GP when + // programming it. + // + if (CpuInfo->ProcessorInfo.Location.Thread == 0) { + MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; + if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_SANDY_BRIDGE_FEATURE_CONFIG, + MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER, + Bits.AESConfiguration, + BIT1 | ((State) ? 0 : BIT0) + ); + } + } + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c new file mode 100644 index 0000000000..47116355a8 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c @@ -0,0 +1,79 @@ +/** @file + C1E feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if C1E feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE C1E feature is supported. + @retval FALSE C1E feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +C1eSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel); +} + +/** + Initializes C1E feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the C1E feature must be enabled. + If FALSE, then the C1E feature must be disabled. + + @retval RETURN_SUCCESS C1E feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +C1eInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_NEHALEM_POWER_CTL, + MSR_NEHALEM_POWER_CTL_REGISTER, + Bits.C1EEnable, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c new file mode 100644 index 0000000000..56e53561e9 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c @@ -0,0 +1,106 @@ +/** @file + Clock Modulation feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Clock Modulation feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Clock Modulation feature is supported. + @retval FALSE Clock Modulation feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +ClockModulationSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1); +} + +/** + Initializes Clock Modulation feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Clock Modulation feature must be enabled. + If FALSE, then the Clock Modulation feature must be disabled. + + @retval RETURN_SUCCESS Clock Modulation feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +ClockModulationInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, + MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, + Bits.OnDemandClockModulationDutyCycle, + PcdGet8 (PcdCpuClockModulationDutyCycle) + ); + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, + MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, + Bits.OnDemandClockModulationEnable, + (State) ? 1 : 0 + ); + } else { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_CLOCK_MODULATION, + MSR_IA32_CLOCK_MODULATION_REGISTER, + Bits.OnDemandClockModulationDutyCycle, + PcdGet8 (PcdCpuClockModulationDutyCycle) + ); + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_CLOCK_MODULATION, + MSR_IA32_CLOCK_MODULATION_REGISTER, + Bits.OnDemandClockModulationEnable, + (State) ? 1 : 0 + ); + } + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h new file mode 100644 index 0000000000..aa6d1122b1 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h @@ -0,0 +1,867 @@ +/** @file + CPU Common features library header file. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_COMMON_FEATURES_H_ +#define _CPU_COMMON_FEATURES_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +AesniGetConfigData ( + IN UINTN NumberOfProcessors + ); + +/** + Detects if AESNI feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE AESNI feature is supported. + @retval FALSE AESNI feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +AesniSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes AESNI feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the AESNI feature must be enabled. + If FALSE, then the AESNI feature must be disabled. + + @retval RETURN_SUCCESS AESNI feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +AesniInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Clock Modulation feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Clock Modulation feature is supported. + @retval FALSE Clock Modulation feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +ClockModulationSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Clock Modulation feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Clock Modulation feature must be enabled. + If FALSE, then the Clock Modulation feature must be disabled. + + @retval RETURN_SUCCESS Clock Modulation feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +ClockModulationInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Enhanced Intel SpeedStep feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Enhanced Intel SpeedStep feature is supported. + @retval FALSE Enhanced Intel SpeedStep feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +EistSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Enhanced Intel SpeedStep feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Enhanced Intel SpeedStep feature + must be enabled. + If FALSE, then the Enhanced Intel SpeedStep feature + must be disabled. + + @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +EistInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Execute Disable feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Execute Disable feature is supported. + @retval FALSE Execute Disable feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +ExecuteDisableSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Execute Disable feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Execute Disable feature must be enabled. + If FALSE, then the Execute Disable feature must be disabled. + + @retval RETURN_SUCCESS Execute Disable feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +ExecuteDisableInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Initializes Fast-Strings feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Fast-Strings feature must be enabled. + If FALSE, then the Fast-Strings feature must be disabled. + + @retval RETURN_SUCCESS Fast-Strings feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +FastStringsInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if MONITOR/MWAIT feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE MONITOR/MWAIT feature is supported. + @retval FALSE MONITOR/MWAIT feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +MonitorMwaitSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes MONITOR/MWAIT feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled. + If FALSE, then the MONITOR/MWAIT feature must be disabled. + + @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +MonitorMwaitInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if VMX feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE VMX feature is supported. + @retval FALSE VMX feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +VmxSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes VMX inside SMX feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the VMX inside SMX feature must be enabled. + If FALSE, then the VMX inside SMX feature must be disabled. + + @retval RETURN_SUCCESS VMX inside SMX feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +VmxInsideSmxInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Initializes SENTER feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the SENTER feature must be enabled. + If FALSE, then the SENTER feature must be disabled. + + @retval RETURN_SUCCESS SENTER feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +SenterInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Lock Feature Control Register feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Lock Feature Control Register feature is supported. + @retval FALSE Lock Feature Control Register feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +LockFeatureControlRegisterSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Lock Feature Control Register feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled. + If FALSE, then the Lock Feature Control Register feature must be disabled. + + @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +LockFeatureControlRegisterInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if SMX feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE SMX feature is supported. + @retval FALSE SMX feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +SmxSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes VMX outside SMX feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the VMX outside SMX feature must be enabled. + If FALSE, then the VMX outside SMX feature must be disabled. + + @retval RETURN_SUCCESS VMX outside SMX feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +VmxOutsideSmxInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if LimitCpuidMaxval feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE LimitCpuidMaxval feature is supported. + @retval FALSE LimitCpuidMaxval feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +LimitCpuidMaxvalSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes LimitCpuidMaxval feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled. + If FALSE, then the LimitCpuidMaxval feature must be disabled. + + @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +LimitCpuidMaxvalInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Machine Check Exception feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Machine Check Exception feature is supported. + @retval FALSE Machine Check Exception feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +MceSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Machine Check Exception feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Machine Check Exception feature must be enabled. + If FALSE, then the Machine Check Exception feature must be disabled. + + @retval RETURN_SUCCESS Machine Check Exception feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +MceInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Machine Check Architecture feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Machine Check Architecture feature is supported. + @retval FALSE Machine Check Architecture feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +McaSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Machine Check Architecture feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Machine Check Architecture feature must be enabled. + If FALSE, then the Machine Check Architecture feature must be disabled. + + @retval RETURN_SUCCESS Machine Check Architecture feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +McaInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if IA32_MCG_CTL feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE IA32_MCG_CTL feature is supported. + @retval FALSE IA32_MCG_CTL feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +McgCtlSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes IA32_MCG_CTL feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the IA32_MCG_CTL feature must be enabled. + If FALSE, then the IA32_MCG_CTL feature must be disabled. + + @retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +McgCtlInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if Pending Break feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Pending Break feature is supported. + @retval FALSE Pending Break feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +PendingBreakSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes Pending Break feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Pending Break feature must be enabled. + If FALSE, then the Pending Break feature must be disabled. + + @retval RETURN_SUCCESS Pending Break feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +PendingBreakInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if C1E feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE C1E feature is supported. + @retval FALSE C1E feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +C1eSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes C1E feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the C1E feature must be enabled. + If FALSE, then the C1E feature must be disabled. + + @retval RETURN_SUCCESS C1E feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +C1eInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Detects if X2Apci feature supported on current processor. + + Detect if X2Apci has been already enabled. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE X2Apci feature is supported. + @retval FALSE X2Apci feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +X2ApicSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ); + +/** + Initializes X2Apci feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the X2Apci feature must be enabled. + If FALSE, then the X2Apci feature must be disabled. + + @retval RETURN_SUCCESS X2Apci feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +X2ApicInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ); + +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +FeatureControlGetConfigData ( + IN UINTN NumberOfProcessors + ); + +#endif diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c new file mode 100644 index 0000000000..3390aa8f2a --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c @@ -0,0 +1,227 @@ +/** @file + This library registers CPU features defined in Intel(R) 64 and IA-32 + Architectures Software Developer's Manual. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Register CPU features. + + @retval RETURN_SUCCESS Register successfully +**/ +RETURN_STATUS +EFIAPI +CpuCommonFeaturesLibConstructor ( + VOID + ) +{ + RETURN_STATUS Status; + + if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) { + Status = RegisterCpuFeature ( + "AESNI", + AesniGetConfigData, + AesniSupport, + AesniInitialize, + CPU_FEATURE_AESNI, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) { + Status = RegisterCpuFeature ( + "MWAIT", + NULL, + MonitorMwaitSupport, + MonitorMwaitInitialize, + CPU_FEATURE_MWAIT, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) { + Status = RegisterCpuFeature ( + "ACPI", + NULL, + ClockModulationSupport, + ClockModulationInitialize, + CPU_FEATURE_ACPI, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) { + Status = RegisterCpuFeature ( + "EIST", + NULL, + EistSupport, + EistInitialize, + CPU_FEATURE_EIST, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_XD)) { + Status = RegisterCpuFeature ( + "Execute Disable", + NULL, + ExecuteDisableSupport, + ExecuteDisableInitialize, + CPU_FEATURE_XD, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) { + Status = RegisterCpuFeature ( + "FastStrings", + NULL, + NULL, + FastStringsInitialize, + CPU_FEATURE_FASTSTRINGS, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) { + Status = RegisterCpuFeature ( + "Lock Feature Control Register", + FeatureControlGetConfigData, + LockFeatureControlRegisterSupport, + LockFeatureControlRegisterInitialize, + CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) { + Status = RegisterCpuFeature ( + "SENTER", + FeatureControlGetConfigData, + VmxSupport, + SenterInitialize, + CPU_FEATURE_SENTER, + CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, + CPU_FEATURE_SMX | CPU_FEATURE_AFTER, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) { + Status = RegisterCpuFeature ( + "SMX", + FeatureControlGetConfigData, + SmxSupport, + VmxInsideSmxInitialize, + CPU_FEATURE_SMX, + CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) { + Status = RegisterCpuFeature ( + "VMX", + FeatureControlGetConfigData, + SmxSupport, + VmxOutsideSmxInitialize, + CPU_FEATURE_VMX, + CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) { + Status = RegisterCpuFeature ( + "Limit CpuId Maximum Value", + NULL, + LimitCpuidMaxvalSupport, + LimitCpuidMaxvalInitialize, + CPU_FEATURE_LIMIT_CPUID_MAX_VAL, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) { + Status = RegisterCpuFeature ( + "Machine Check Enable", + NULL, + MceSupport, + MceInitialize, + CPU_FEATURE_MCE, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) { + Status = RegisterCpuFeature ( + "Machine Check Architect", + NULL, + McaSupport, + McaInitialize, + CPU_FEATURE_MCA, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) { + Status = RegisterCpuFeature ( + "MCG_CTL", + NULL, + McgCtlSupport, + McgCtlInitialize, + CPU_FEATURE_MCG_CTL, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) { + Status = RegisterCpuFeature ( + "Pending Break", + NULL, + PendingBreakSupport, + PendingBreakInitialize, + CPU_FEATURE_PENDING_BREAK, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) { + Status = RegisterCpuFeature ( + "C1E", + NULL, + C1eSupport, + C1eInitialize, + CPU_FEATURE_C1E, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) { + Status = RegisterCpuFeature ( + "X2Apic", + NULL, + X2ApicSupport, + X2ApicInitialize, + CPU_FEATURE_X2APIC, + CPU_FEATURE_END + ); + ASSERT_EFI_ERROR (Status); + } + + return RETURN_SUCCESS; +} + + + diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf new file mode 100644 index 0000000000..e68936be25 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf @@ -0,0 +1,68 @@ +## @file +# NULL instance to register CPU features. +# +# This library registers CPU features defined in Intel(R) 64 and IA-32 +# Architectures Software Developer's Manual. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuCommonFeaturesLib + MODULE_UNI_FILE = CpuCommonFeaturesLib.uni + FILE_GUID = 6D69F79F-9535-4893-9DD7-93929898252C + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = NULL + + CONSTRUCTOR = CpuCommonFeaturesLibConstructor + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + CpuCommonFeaturesLib.c + CpuCommonFeatures.h + Aesni.c + C1e.c + ClockModulation.c + Eist.c + ExecuteDisable.c + FastStrings.c + FeatureControl.c + LimitCpuIdMaxval.c + MachineCheck.c + MonitorMwait.c + PendingBreak.c + X2Apic.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + PcdLib + DebugLib + RegisterCpuFeaturesLib + BaseMemoryLib + MemoryAllocationLib + LocalApicLib + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## SOMETIMES_CONSUMES + diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni new file mode 100644 index 0000000000..d1a90c32d4 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni @@ -0,0 +1,25 @@ +// /** @file +// Dxe Crc32 Guided Section Extract library. +// +// This library doesn't produce any library class. The constructor function uses +// ExtractGuidedSectionLib service to register CRC32 guided section handler +// that parses CRC32 encapsulation section and extracts raw data. +// +// It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value. +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Dxe Crc32 Guided Section Extract library." + +#string STR_MODULE_DESCRIPTION #language en-US "This library doesn't produce any library class. The constructor function uses ExtractGuidedSectionLib service to register CRC32 guided section handler that parses CRC32 encapsulation section and extracts raw data. It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value." + diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c new file mode 100644 index 0000000000..2038171a14 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c @@ -0,0 +1,81 @@ +/** @file + Enhanced Intel SpeedStep feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Enhanced Intel SpeedStep feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Enhanced Intel SpeedStep feature is supported. + @retval FALSE Enhanced Intel SpeedStep feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +EistSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1); +} + +/** + Initializes Enhanced Intel SpeedStep feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Enhanced Intel SpeedStep feature + must be enabled. + If FALSE, then the Enhanced Intel SpeedStep feature + must be disabled. + + @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +EistInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_MISC_ENABLE, + MSR_IA32_MISC_ENABLE_REGISTER, + Bits.EIST, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c new file mode 100644 index 0000000000..921656a1e8 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c @@ -0,0 +1,91 @@ +/** @file + Execute Disable feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Execute Disable feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Execute Disable feature is supported. + @retval FALSE Execute Disable feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +ExecuteDisableSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + UINT32 Eax; + CPUID_EXTENDED_CPU_SIG_EDX Edx; + + AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); + if (Eax <= CPUID_EXTENDED_FUNCTION) { + // + // Extended CPUID functions are not supported on this processor. + // + return FALSE; + } + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); + return (Edx.Bits.NX != 0); +} + +/** + Initializes Execute Disable feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Execute Disable feature must be enabled. + If FALSE, then the Execute Disable feature must be disabled. + + @retval RETURN_SUCCESS Execute Disable feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +ExecuteDisableInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_EFER, + MSR_IA32_EFER_REGISTER, + Bits.NXE, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c new file mode 100644 index 0000000000..029bcf87b3 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c @@ -0,0 +1,52 @@ +/** @file + Fast-Strings feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Initializes Fast-Strings feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Fast-Strings feature must be enabled. + If FALSE, then the Fast-Strings feature must be disabled. + + @retval RETURN_SUCCESS Fast-Strings feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +FastStringsInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_MISC_ENABLE, + MSR_IA32_MISC_ENABLE_REGISTER, + Bits.FastStrings, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c new file mode 100644 index 0000000000..0b5c161f87 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c @@ -0,0 +1,314 @@ +/** @file + Features in MSR_IA32_FEATURE_CONTROL register. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Prepares for the data used by CPU feature detection and initialization. + + @param[in] NumberOfProcessors The number of CPUs in the platform. + + @return Pointer to a buffer of CPU related configuration data. + + @note This service could be called by BSP only. +**/ +VOID * +EFIAPI +FeatureControlGetConfigData ( + IN UINTN NumberOfProcessors + ) +{ + VOID *ConfigData; + + ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors); + ASSERT (ConfigData != NULL); + return ConfigData; +} + +/** + Detects if VMX feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE VMX feature is supported. + @retval FALSE VMX feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +VmxSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); + return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1); +} + +/** + Initializes VMX inside SMX feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the VMX inside SMX feature must be enabled. + If FALSE, then the VMX inside SMX feature must be disabled. + + @retval RETURN_SUCCESS VMX inside SMX feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +VmxInsideSmxInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_FEATURE_CONTROL, + MSR_IA32_FEATURE_CONTROL_REGISTER, + Bits.EnableVmxInsideSmx, + (State) ? 1 : 0 + ); + } + return RETURN_SUCCESS; +} + +/** + Initializes SENTER feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the SENTER feature must be enabled. + If FALSE, then the SENTER feature must be disabled. + + @retval RETURN_SUCCESS SENTER feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +SenterInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_FEATURE_CONTROL, + MSR_IA32_FEATURE_CONTROL_REGISTER, + Bits.SenterLocalFunctionEnables, + (State) ? 0x7F : 0 + ); + + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_FEATURE_CONTROL, + MSR_IA32_FEATURE_CONTROL_REGISTER, + Bits.SenterGlobalEnable, + (State) ? 1 : 0 + ); + } + return RETURN_SUCCESS; +} + +/** + Detects if Lock Feature Control Register feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Lock Feature Control Register feature is supported. + @retval FALSE Lock Feature Control Register feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +LockFeatureControlRegisterSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); + return TRUE; +} + +/** + Initializes Lock Feature Control Register feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled. + If FALSE, then the Lock Feature Control Register feature must be disabled. + + @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +LockFeatureControlRegisterInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_FEATURE_CONTROL, + MSR_IA32_FEATURE_CONTROL_REGISTER, + Bits.Lock, + 1 + ); + } + return RETURN_SUCCESS; +} + +/** + Detects if SMX feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE SMX feature is supported. + @retval FALSE SMX feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +SmxSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); + return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1); +} + +/** + Initializes VMX outside SMX feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the VMX outside SMX feature must be enabled. + If FALSE, then the VMX outside SMX feature must be disabled. + + @retval RETURN_SUCCESS VMX outside SMX feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +VmxOutsideSmxInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; + + ASSERT (ConfigData != NULL); + MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; + if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_FEATURE_CONTROL, + MSR_IA32_FEATURE_CONTROL_REGISTER, + Bits.EnableVmxOutsideSmx, + (State) ? 1 : 0 + ); + } + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c new file mode 100644 index 0000000000..40cc9d5fe0 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c @@ -0,0 +1,82 @@ +/** @file + LimitCpuidMaxval Feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if LimitCpuidMaxval feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE LimitCpuidMaxval feature is supported. + @retval FALSE LimitCpuidMaxval feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +LimitCpuidMaxvalSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + UINT32 Eax; + + AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL); + return (Eax > 3); +} + +/** + Initializes LimitCpuidMaxval feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled. + If FALSE, then the LimitCpuidMaxval feature must be disabled. + + @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +LimitCpuidMaxvalInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_MISC_ENABLE, + MSR_IA32_MISC_ENABLE_REGISTER, + Bits.LimitCpuidMaxval, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c new file mode 100644 index 0000000000..72f665d32e --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c @@ -0,0 +1,231 @@ +/** @file + Machine Check features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Machine Check Exception feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Machine Check Exception feature is supported. + @retval FALSE Machine Check Exception feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +MceSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1); +} + +/** + Initializes Machine Check Exception feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Machine Check Exception feature must be enabled. + If FALSE, then the Machine Check Exception feature must be disabled. + + @retval RETURN_SUCCESS Machine Check Exception feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +MceInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + // + // Set MCE bit in CR4 + // + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + ControlRegister, + 4, + IA32_CR4, + Bits.MCE, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} + +/** + Detects if Machine Check Architecture feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Machine Check Architecture feature is supported. + @retval FALSE Machine Check Architecture feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +McaSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1); +} + +/** + Initializes Machine Check Architecture feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Machine Check Architecture feature must be enabled. + If FALSE, then the Machine Check Architecture feature must be disabled. + + @retval RETURN_SUCCESS Machine Check Architecture feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +McaInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + MSR_IA32_MCG_CAP_REGISTER McgCap; + UINT32 BankIndex; + + McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); + for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) { + CPU_REGISTER_TABLE_WRITE64 ( + ProcessorNumber, + Msr, + MSR_IA32_MC0_CTL + BankIndex * 4, + MAX_UINT64 + ); + } + + if (PcdGetBool (PcdIsPowerOnReset)) { + for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) { + CPU_REGISTER_TABLE_WRITE64 ( + ProcessorNumber, + Msr, + MSR_IA32_MC0_STATUS + BankIndex * 4, + 0 + ); + } + } + + return RETURN_SUCCESS; +} + +/** + Detects if IA32_MCG_CTL feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE IA32_MCG_CTL feature is supported. + @retval FALSE IA32_MCG_CTL feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +McgCtlSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + MSR_IA32_MCG_CAP_REGISTER McgCap; + + if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) { + return FALSE; + } + McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); + return (McgCap.Bits.MCG_CTL_P == 1); +} + +/** + Initializes IA32_MCG_CTL feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the IA32_MCG_CTL feature must be enabled. + If FALSE, then the IA32_MCG_CTL feature must be disabled. + + @retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +McgCtlInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE64 ( + ProcessorNumber, + Msr, + MSR_IA32_MCG_CTL, + (State)? MAX_UINT64 : 0 + ); + return RETURN_SUCCESS; +} + diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c new file mode 100644 index 0000000000..1d43bd128a --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c @@ -0,0 +1,79 @@ +/** @file + MonitorMwait feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if MONITOR/MWAIT feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE MONITOR/MWAIT feature is supported. + @retval FALSE MONITOR/MWAIT feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +MonitorMwaitSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1); +} + +/** + Initializes MONITOR/MWAIT feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled. + If FALSE, then the MONITOR/MWAIT feature must be disabled. + + @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +MonitorMwaitInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_MISC_ENABLE, + MSR_IA32_MISC_ENABLE_REGISTER, + Bits.MONITOR, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c new file mode 100644 index 0000000000..8cafba4f4a --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c @@ -0,0 +1,90 @@ +/** @file + Pending Break feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if Pending Break feature supported on current processor. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE Pending Break feature is supported. + @retval FALSE Pending Break feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +PendingBreakSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || + IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { + return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1); + } + return FALSE; +} + +/** + Initializes Pending Break feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the Pending Break feature must be enabled. + If FALSE, then the Pending Break feature must be disabled. + + @retval RETURN_SUCCESS Pending Break feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +PendingBreakInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + // + // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index, + // Simply use MSR_ATOM_IA32_MISC_ENABLE here + // + CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_ATOM_IA32_MISC_ENABLE, + MSR_ATOM_IA32_MISC_ENABLE_REGISTER, + Bits.FERR, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c new file mode 100644 index 0000000000..9c2ad9ad31 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c @@ -0,0 +1,81 @@ +/** @file + X2Apic feature. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuCommonFeatures.h" + +/** + Detects if X2Apci feature supported on current processor. + + Detect if X2Apci has been already enabled. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + + @retval TRUE X2Apci feature is supported. + @retval FALSE X2Apci feature is not supported. + + @note This service could be called by BSP/APs. +**/ +BOOLEAN +EFIAPI +X2ApicSupport ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData OPTIONAL + ) +{ + return (GetApicMode () == LOCAL_APIC_MODE_X2APIC); +} + +/** + Initializes X2Apci feature to specific state. + + @param[in] ProcessorNumber The index of the CPU executing this function. + @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION + structure for the CPU executing this function. + @param[in] ConfigData A pointer to the configuration buffer returned + by CPU_FEATURE_GET_CONFIG_DATA. NULL if + CPU_FEATURE_GET_CONFIG_DATA was not provided in + RegisterCpuFeature(). + @param[in] State If TRUE, then the X2Apci feature must be enabled. + If FALSE, then the X2Apci feature must be disabled. + + @retval RETURN_SUCCESS X2Apci feature is initialized. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +X2ApicInitialize ( + IN UINTN ProcessorNumber, + IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, + IN VOID *ConfigData, OPTIONAL + IN BOOLEAN State + ) +{ + PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD ( + ProcessorNumber, + Msr, + MSR_IA32_APIC_BASE, + MSR_IA32_APIC_BASE_REGISTER, + Bits.EXTD, + (State) ? 1 : 0 + ); + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c new file mode 100644 index 0000000000..78ee182e8d --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c @@ -0,0 +1,180 @@ +/** @file + CPU Exception Handler Library common functions. + + Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuExceptionCommon.h" + +// +// Error code flag indicating whether or not an error code will be +// pushed on the stack if an exception occurs. +// +// 1 means an error code will be pushed, otherwise 0 +// +CONST UINT32 mErrorCodeFlag = 0x00027d00; + +// +// Define the maximum message length +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +CONST CHAR8 mExceptionReservedStr[] = "Reserved"; +CONST CHAR8 *mExceptionNameStr[] = { + "#DE - Divide Error", + "#DB - Debug", + "NMI Interrupt", + "#BP - Breakpoint", + "#OF - Overflow", + "#BR - BOUND Range Exceeded", + "#UD - Invalid Opcode", + "#NM - Device Not Available", + "#DF - Double Fault", + "Coprocessor Segment Overrun", + "#TS - Invalid TSS", + "#NP - Segment Not Present", + "#SS - Stack Fault Fault", + "#GP - General Protection", + "#PF - Page-Fault", + "Reserved", + "#MF - x87 FPU Floating-Point Error", + "#AC - Alignment Check", + "#MC - Machine-Check", + "#XM - SIMD floating-point", + "#VE - Virtualization" +}; + +#define EXCEPTION_KNOWN_NAME_NUM (sizeof (mExceptionNameStr) / sizeof (CHAR8 *)) + +/** + Get ASCII format string exception name by exception type. + + @param ExceptionType Exception type. + + @return ASCII format string exception name. +**/ +CONST CHAR8 * +GetExceptionNameStr ( + IN EFI_EXCEPTION_TYPE ExceptionType + ) +{ + if ((UINTN) ExceptionType < EXCEPTION_KNOWN_NAME_NUM) { + return mExceptionNameStr[ExceptionType]; + } else { + return mExceptionReservedStr; + } +} + +/** + Prints a message to the serial port. + + @param Format Format string for the message to print. + @param ... Variable argument list whose contents are accessed + based on the format string specified by Format. + +**/ +VOID +EFIAPI +InternalPrintMessage ( + IN CONST CHAR8 *Format, + ... + ) +{ + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + VA_LIST Marker; + + // + // Convert the message to an ASCII String + // + VA_START (Marker, Format); + AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + // + // Send the print string to a Serial Port + // + SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); +} + +/** + Find and display image base address and return image base and its entry point. + + @param CurrentEip Current instruction pointer. + +**/ +VOID +DumpModuleImageInfo ( + IN UINTN CurrentEip + ) +{ + EFI_STATUS Status; + UINTN Pe32Data; + VOID *PdbPointer; + VOID *EntryPoint; + + Pe32Data = PeCoffSerachImageBase (CurrentEip); + if (Pe32Data == 0) { + InternalPrintMessage ("!!!! Can't find image information. !!!!\n"); + } else { + // + // Find Image Base entry point + // + Status = PeCoffLoaderGetEntryPoint ((VOID *) Pe32Data, &EntryPoint); + if (EFI_ERROR (Status)) { + EntryPoint = NULL; + } + InternalPrintMessage ("!!!! Find image "); + PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data); + if (PdbPointer != NULL) { + InternalPrintMessage ("%a", PdbPointer); + } else { + InternalPrintMessage ("(No PDB) " ); + } + InternalPrintMessage ( + " (ImageBase=%016lp, EntryPoint=%016p) !!!!\n", + (VOID *) Pe32Data, + EntryPoint + ); + } +} + +/** + Read and save reserved vector information + + @param[in] VectorInfo Pointer to reserved vector list. + @param[out] ReservedVector Pointer to reserved vector data buffer. + @param[in] VectorCount Vector number to be updated. + + @return EFI_SUCCESS Read and save vector info successfully. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + +**/ +EFI_STATUS +ReadAndVerifyVectorInfo ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo, + OUT RESERVED_VECTORS_DATA *ReservedVector, + IN UINTN VectorCount + ) +{ + while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) { + if (VectorInfo->Attribute > EFI_VECTOR_HANDOFF_HOOK_AFTER) { + // + // If vector attrubute is invalid + // + return EFI_INVALID_PARAMETER; + } + if (VectorInfo->VectorNumber < VectorCount) { + ReservedVector[VectorInfo->VectorNumber].Attribute = VectorInfo->Attribute; + } + VectorInfo ++; + } + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h new file mode 100644 index 0000000000..740a58828b --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -0,0 +1,292 @@ +/** @file + Common header file for CPU Exception Handler Library. + + Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_EXCEPTION_COMMON_H_ +#define _CPU_EXCEPTION_COMMON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CPU_EXCEPTION_NUM 32 +#define CPU_INTERRUPT_NUM 256 +#define HOOKAFTER_STUB_SIZE 16 + +// +// Exception Error Code of Page-Fault Exception +// +#define IA32_PF_EC_P BIT0 +#define IA32_PF_EC_WR BIT1 +#define IA32_PF_EC_US BIT2 +#define IA32_PF_EC_RSVD BIT3 +#define IA32_PF_EC_ID BIT4 +#define IA32_PF_EC_PK BIT5 +#define IA32_PF_EC_SGX BIT15 + +#include "ArchInterruptDefs.h" + +#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \ + { \ + 0xb21d9148, 0x9211, 0x4d8f, { 0xad, 0xd3, 0x66, 0xb1, 0x89, 0xc9, 0x2c, 0x83 } \ + } + +// +// Record exception handler information +// +typedef struct { + UINTN ExceptionStart; + UINTN ExceptionStubHeaderSize; + UINTN HookAfterStubHeaderStart; +} EXCEPTION_HANDLER_TEMPLATE_MAP; + +typedef struct { + UINTN IdtEntryCount; + SPIN_LOCK DisplayMessageSpinLock; + RESERVED_VECTORS_DATA *ReservedVectors; + EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; +} EXCEPTION_HANDLER_DATA; + +extern CONST UINT32 mErrorCodeFlag; +extern CONST UINTN mDoFarReturnFlag; + +/** + Return address map of exception handler template so that C code can generate + exception tables. + + @param AddressMap Pointer to a buffer where the address map is returned. +**/ +VOID +EFIAPI +AsmGetTemplateAddressMap ( + OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap + ); + +/** + Return address map of exception handler template so that C code can generate + exception tables. + + @param IdtEntry Pointer to IDT entry to be updated. + @param InterruptHandler IDT handler value. + +**/ +VOID +ArchUpdateIdtEntry ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler + ); + +/** + Read IDT handler value from IDT entry. + + @param IdtEntry Pointer to IDT entry to be read. + +**/ +UINTN +ArchGetIdtHandler ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry + ); + +/** + Prints a message to the serial port. + + @param Format Format string for the message to print. + @param ... Variable argument list whose contents are accessed + based on the format string specified by Format. + +**/ +VOID +EFIAPI +InternalPrintMessage ( + IN CONST CHAR8 *Format, + ... + ); + +/** + Find and display image base address and return image base and its entry point. + + @param CurrentEip Current instruction pointer. + +**/ +VOID +DumpModuleImageInfo ( + IN UINTN CurrentEip + ); + +/** + Display CPU information. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +DumpImageAndCpuContent ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ); + +/** + Internal worker function to initialize exception handler. + + @param[in] VectorInfo Pointer to reserved vector list. + @param[in, out] ExceptionHandlerData Pointer to exception handler data. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +InitializeCpuExceptionHandlersWorker ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, + IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +/** + Registers a function to be called from the processor interrupt handler. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled + @param[in] ExceptionHandlerData Pointer to exception handler data. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +RegisterCpuInterruptHandlerWorker ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +/** + Internal worker function to update IDT entries accordling to vector attributes. + + @param[in] IdtTable Pointer to IDT table. + @param[in] TemplateMap Pointer to a buffer where the address map is + returned. + @param[in] ExceptionHandlerData Pointer to exception handler data. + +**/ +VOID +UpdateIdtTable ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtTable, + IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +/** + Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchSaveExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +/** + Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchRestoreExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +/** + Fix up the vector number and function address in the vector code. + + @param[in] NewVectorAddr New vector handler address. + @param[in] VectorNum Index of vector. + @param[in] OldVectorAddr Old vector handler address. + +**/ +VOID +EFIAPI +AsmVectorNumFixup ( + IN VOID *NewVectorAddr, + IN UINT8 VectorNum, + IN VOID *OldVectorAddr + ); + +/** + Read and save reserved vector information + + @param[in] VectorInfo Pointer to reserved vector list. + @param[out] ReservedVector Pointer to reserved vector data buffer. + @param[in] VectorCount Vector number to be updated. + + @return EFI_SUCCESS Read and save vector info successfully. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + +**/ +EFI_STATUS +ReadAndVerifyVectorInfo ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo, + OUT RESERVED_VECTORS_DATA *ReservedVector, + IN UINTN VectorCount + ); + +/** + Get ASCII format string exception name by exception type. + + @param ExceptionType Exception type. + + @return ASCII format string exception name. +**/ +CONST CHAR8 * +GetExceptionNameStr ( + IN EFI_EXCEPTION_TYPE ExceptionType + ); + +/** + Internal worker function for common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +CommonExceptionHandlerWorker ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ); + +#endif + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf new file mode 100644 index 0000000000..f4a8d01c80 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf @@ -0,0 +1,63 @@ +## @file +# CPU Exception Handler library instance for DXE modules. +# +# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxeCpuExceptionHandlerLib + MODULE_UNI_FILE = DxeCpuExceptionHandlerLib.uni + FILE_GUID = B6E9835A-EDCF-4748-98A8-27D3C722E02D + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.1 + LIBRARY_CLASS = CpuExceptionHandlerLib|DXE_CORE DXE_DRIVER UEFI_APPLICATION + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.Ia32] + Ia32/ExceptionHandlerAsm.asm + Ia32/ExceptionHandlerAsm.nasm + Ia32/ExceptionHandlerAsm.S + Ia32/ArchExceptionHandler.c + Ia32/ArchInterruptDefs.h + +[Sources.X64] + X64/ExceptionHandlerAsm.asm + X64/ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.S + X64/ArchExceptionHandler.c + X64/ArchInterruptDefs.h + +[Sources.common] + CpuExceptionCommon.h + CpuExceptionCommon.c + PeiDxeSmmCpuException.c + DxeException.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + SerialPortLib + PrintLib + SynchronizationLib + LocalApicLib + PeCoffGetEntryPointLib + MemoryAllocationLib + DebugLib diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni new file mode 100644 index 0000000000..ace4b6f287 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Exception Handler library instance for DXE modules. +// +// CPU Exception Handler library instance for DXE modules. +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for DXE modules." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for DXE modules." + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c new file mode 100644 index 0000000000..31febec976 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c @@ -0,0 +1,199 @@ +/** @file + CPU exception handler library implemenation for DXE modules. + + Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include "CpuExceptionCommon.h" +#include +#include + +CONST UINTN mDoFarReturnFlag = 0; + +RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM]; +EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM]; +UINTN mEnabledInterruptNum = 0; + +EXCEPTION_HANDLER_DATA mExceptionHandlerData; + +/** + Common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +CommonExceptionHandler ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData); +} + +/** + Initializes all CPU exceptions entries and provides the default exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuExceptionHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + mExceptionHandlerData.ReservedVectors = mReservedVectorsData; + mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable; + InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); + return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData); +} + +/** + Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized + with default interrupt/exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuInterruptHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + EFI_STATUS Status; + IA32_IDT_GATE_DESCRIPTOR *IdtTable; + IA32_DESCRIPTOR IdtDescriptor; + UINTN IdtEntryCount; + EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; + UINTN Index; + UINTN InterruptEntry; + UINT8 *InterruptEntryCode; + RESERVED_VECTORS_DATA *ReservedVectors; + EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; + + ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM); + ASSERT (ReservedVectors != NULL); + SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM, 0xff); + if (VectorInfo != NULL) { + Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, CPU_INTERRUPT_NUM); + if (EFI_ERROR (Status)) { + FreePool (ReservedVectors); + return EFI_INVALID_PARAMETER; + } + } + + ExternalInterruptHandler = AllocateZeroPool (sizeof (EFI_CPU_INTERRUPT_HANDLER) * CPU_INTERRUPT_NUM); + ASSERT (ExternalInterruptHandler != NULL); + + // + // Read IDT descriptor and calculate IDT size + // + AsmReadIdtr (&IdtDescriptor); + IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); + if (IdtEntryCount > CPU_INTERRUPT_NUM) { + IdtEntryCount = CPU_INTERRUPT_NUM; + } + // + // Create Interrupt Descriptor Table and Copy the old IDT table in + // + IdtTable = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM); + ASSERT (IdtTable != NULL); + CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount); + + AsmGetTemplateAddressMap (&TemplateMap); + ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE); + InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM); + ASSERT (InterruptEntryCode != NULL); + + InterruptEntry = (UINTN) InterruptEntryCode; + for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) { + CopyMem ( + (VOID *) InterruptEntry, + (VOID *) TemplateMap.ExceptionStart, + TemplateMap.ExceptionStubHeaderSize + ); + AsmVectorNumFixup ((VOID *) InterruptEntry, (UINT8) Index, (VOID *) TemplateMap.ExceptionStart); + InterruptEntry += TemplateMap.ExceptionStubHeaderSize; + } + + TemplateMap.ExceptionStart = (UINTN) InterruptEntryCode; + mExceptionHandlerData.IdtEntryCount = CPU_INTERRUPT_NUM; + mExceptionHandlerData.ReservedVectors = ReservedVectors; + mExceptionHandlerData.ExternalInterruptHandler = ExternalInterruptHandler; + InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); + + UpdateIdtTable (IdtTable, &TemplateMap, &mExceptionHandlerData); + + // + // Load Interrupt Descriptor Table + // + IdtDescriptor.Base = (UINTN) IdtTable; + IdtDescriptor.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM - 1); + AsmWriteIdtr ((IA32_DESCRIPTOR *) &IdtDescriptor); + + return EFI_SUCCESS; +} + +/** + Registers a function to be called from the processor interrupt handler. + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or + InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +EFIAPI +RegisterCpuInterruptHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData); +} diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c new file mode 100644 index 0000000000..f2c39eb193 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c @@ -0,0 +1,230 @@ +/** @file + IA32 CPU Exception Handler functons. + + Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuExceptionCommon.h" + +/** + Return address map of exception handler template so that C code can generate + exception tables. + + @param IdtEntry Pointer to IDT entry to be updated. + @param InterruptHandler IDT handler value. + +**/ +VOID +ArchUpdateIdtEntry ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler + ) +{ + IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; + IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); + IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; +} + +/** + Read IDT handler value from IDT entry. + + @param IdtEntry Pointer to IDT entry to be read. + +**/ +UINTN +ArchGetIdtHandler ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry + ) +{ + return (UINTN)IdtEntry->Bits.OffsetLow + (((UINTN)IdtEntry->Bits.OffsetHigh) << 16); +} + +/** + Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchSaveExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + IA32_EFLAGS32 Eflags; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + // + // Save Exception context in global variable + // + ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags; + ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs; + ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextIa32->Eip; + ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextIa32->ExceptionData; + // + // Clear IF flag to avoid old IDT handler enable interrupt by IRET + // + Eflags.UintN = SystemContext.SystemContextIa32->Eflags; + Eflags.Bits.IF = 0; + SystemContext.SystemContextIa32->Eflags = Eflags.UintN; + // + // Modify the EIP in stack, then old IDT handler will return to the stub code + // + SystemContext.SystemContextIa32->Eip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode; +} + +/** + Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchRestoreExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + SystemContext.SystemContextIa32->Eflags = ReservedVectors[ExceptionType].OldFlags; + SystemContext.SystemContextIa32->Cs = ReservedVectors[ExceptionType].OldCs; + SystemContext.SystemContextIa32->Eip = ReservedVectors[ExceptionType].OldIp; + SystemContext.SystemContextIa32->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; +} + +/** + Display processor context. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Processor context to be display. +**/ +VOID +EFIAPI +DumpCpuContext ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + InternalPrintMessage ( + "!!!! IA32 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n", + ExceptionType, + GetExceptionNameStr (ExceptionType), + GetApicId () + ); + if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) { + InternalPrintMessage ( + "ExceptionData - %08x", + SystemContext.SystemContextIa32->ExceptionData + ); + if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) { + InternalPrintMessage ( + " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_RSVD) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_US) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_WR) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_P) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_PK) != 0, + (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_SGX) != 0 + ); + } + InternalPrintMessage ("\n"); + } + InternalPrintMessage ( + "EIP - %08x, CS - %08x, EFLAGS - %08x\n", + SystemContext.SystemContextIa32->Eip, + SystemContext.SystemContextIa32->Cs, + SystemContext.SystemContextIa32->Eflags + ); + InternalPrintMessage ( + "EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n", + SystemContext.SystemContextIa32->Eax, + SystemContext.SystemContextIa32->Ecx, + SystemContext.SystemContextIa32->Edx, + SystemContext.SystemContextIa32->Ebx + ); + InternalPrintMessage ( + "ESP - %08x, EBP - %08x, ESI - %08x, EDI - %08x\n", + SystemContext.SystemContextIa32->Esp, + SystemContext.SystemContextIa32->Ebp, + SystemContext.SystemContextIa32->Esi, + SystemContext.SystemContextIa32->Edi + ); + InternalPrintMessage ( + "DS - %08x, ES - %08x, FS - %08x, GS - %08x, SS - %08x\n", + SystemContext.SystemContextIa32->Ds, + SystemContext.SystemContextIa32->Es, + SystemContext.SystemContextIa32->Fs, + SystemContext.SystemContextIa32->Gs, + SystemContext.SystemContextIa32->Ss + ); + InternalPrintMessage ( + "CR0 - %08x, CR2 - %08x, CR3 - %08x, CR4 - %08x\n", + SystemContext.SystemContextIa32->Cr0, + SystemContext.SystemContextIa32->Cr2, + SystemContext.SystemContextIa32->Cr3, + SystemContext.SystemContextIa32->Cr4 + ); + InternalPrintMessage ( + "DR0 - %08x, DR1 - %08x, DR2 - %08x, DR3 - %08x\n", + SystemContext.SystemContextIa32->Dr0, + SystemContext.SystemContextIa32->Dr1, + SystemContext.SystemContextIa32->Dr2, + SystemContext.SystemContextIa32->Dr3 + ); + InternalPrintMessage ( + "DR6 - %08x, DR7 - %08x\n", + SystemContext.SystemContextIa32->Dr6, + SystemContext.SystemContextIa32->Dr7 + ); + InternalPrintMessage ( + "GDTR - %08x %08x, IDTR - %08x %08x\n", + SystemContext.SystemContextIa32->Gdtr[0], + SystemContext.SystemContextIa32->Gdtr[1], + SystemContext.SystemContextIa32->Idtr[0], + SystemContext.SystemContextIa32->Idtr[1] + ); + InternalPrintMessage ( + "LDTR - %08x, TR - %08x\n", + SystemContext.SystemContextIa32->Ldtr, + SystemContext.SystemContextIa32->Tr + ); + InternalPrintMessage ( + "FXSAVE_STATE - %08x\n", + &SystemContext.SystemContextIa32->FxSaveState + ); +} + +/** + Display CPU information. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +DumpImageAndCpuContent ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + DumpCpuContext (ExceptionType, SystemContext); + // + // Dump module image base and module entry point by EIP + // + DumpModuleImageInfo (SystemContext.SystemContextIa32->Eip); +} diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h new file mode 100644 index 0000000000..a8d3556a80 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h @@ -0,0 +1,44 @@ +/** @file + Ia32 arch definition for CPU Exception Handler Library. + + Copyright (c) 2013, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _ARCH_CPU_INTERRUPT_DEFS_H_ +#define _ARCH_CPU_INTERRUPT_DEFS_H_ + +typedef struct { + EFI_SYSTEM_CONTEXT_IA32 SystemContext; + BOOLEAN ExceptionDataFlag; + UINTN OldIdtHandler; +} EXCEPTION_HANDLER_CONTEXT; + +// +// Register Structure Definitions +// +typedef struct { + EFI_STATUS_CODE_DATA Header; + EFI_SYSTEM_CONTEXT_IA32 SystemContext; +} CPU_STATUS_CODE_TEMPLATE; + +typedef struct { + SPIN_LOCK SpinLock; + UINT32 ApicId; + UINT32 Attribute; + UINTN ExceptonHandler; + UINTN OldFlags; + UINTN OldCs; + UINTN OldIp; + UINTN ExceptionData; + UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; +} RESERVED_VECTORS_DATA; + +#endif diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S new file mode 100644 index 0000000000..c134257d9d --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S @@ -0,0 +1,667 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* ExceptionHandlerAsm.S +#* +#* Abstract: +#* +#* IA32 CPU Exception Handler +# +#------------------------------------------------------------------------------ + + +#.MMX +#.XMM + +ASM_GLOBAL ASM_PFX(CommonExceptionHandler) +ASM_GLOBAL ASM_PFX(CommonInterruptEntry) +ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) + +#EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions +#EXTRN ASM_PFX(mDoFarReturnFlag):DWORD # Do far return flag + +.text + +# +# exception handler stub table +# +Exception0Handle: + .byte 0x6a # push #VectorNum + .byte 0 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception1Handle: + .byte 0x6a # push #VectorNum + .byte 1 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception2Handle: + .byte 0x6a # push #VectorNum + .byte 2 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception3Handle: + .byte 0x6a # push #VectorNum + .byte 3 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception4Handle: + .byte 0x6a # push #VectorNum + .byte 4 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception5Handle: + .byte 0x6a # push #VectorNum + .byte 5 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception6Handle: + .byte 0x6a # push #VectorNum + .byte 6 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception7Handle: + .byte 0x6a # push #VectorNum + .byte 7 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception8Handle: + .byte 0x6a # push #VectorNum + .byte 8 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception9Handle: + .byte 0x6a # push #VectorNum + .byte 9 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception10Handle: + .byte 0x6a # push #VectorNum + .byte 10 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception11Handle: + .byte 0x6a # push #VectorNum + .byte 11 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception12Handle: + .byte 0x6a # push #VectorNum + .byte 12 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception13Handle: + .byte 0x6a # push #VectorNum + .byte 13 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception14Handle: + .byte 0x6a # push #VectorNum + .byte 14 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception15Handle: + .byte 0x6a # push #VectorNum + .byte 15 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception16Handle: + .byte 0x6a # push #VectorNum + .byte 16 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception17Handle: + .byte 0x6a # push #VectorNum + .byte 17 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception18Handle: + .byte 0x6a # push #VectorNum + .byte 18 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception19Handle: + .byte 0x6a # push #VectorNum + .byte 19 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception20Handle: + .byte 0x6a # push #VectorNum + .byte 20 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception21Handle: + .byte 0x6a # push #VectorNum + .byte 21 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception22Handle: + .byte 0x6a # push #VectorNum + .byte 22 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception23Handle: + .byte 0x6a # push #VectorNum + .byte 23 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception24Handle: + .byte 0x6a # push #VectorNum + .byte 24 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception25Handle: + .byte 0x6a # push #VectorNum + .byte 25 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception26Handle: + .byte 0x6a # push #VectorNum + .byte 26 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception27Handle: + .byte 0x6a # push #VectorNum + .byte 27 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception28Handle: + .byte 0x6a # push #VectorNum + .byte 28 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception29Handle: + .byte 0x6a # push #VectorNum + .byte 29 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception30Handle: + .byte 0x6a # push #VectorNum + .byte 30 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax +Exception31Handle: + .byte 0x6a # push #VectorNum + .byte 31 + pushl %eax + .byte 0xB8 + .long ASM_PFX(CommonInterruptEntry) + jmp *%eax + +HookAfterStubBegin: + .byte 0x6a # push +VectorNum: + .byte 0 # 0 will be fixed + pushl %eax + .byte 0xB8 # movl ASM_PFX(HookAfterStubHeaderEnd), %eax + .long ASM_PFX(HookAfterStubHeaderEnd) + jmp *%eax +ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) +ASM_PFX(HookAfterStubHeaderEnd): + popl %eax + subl $8, %esp # reserve room for filling exception data later + pushl 8(%esp) + xchgl (%esp), %ecx # get vector number + bt %ecx, ASM_PFX(mErrorCodeFlag) + jnc NoErrorData + pushl (%esp) # addition push if exception data needed +NoErrorData: + xchg (%esp), %ecx # restore ecx + pushl %eax + +#---------------------------------------; +# CommonInterruptEntry ; +#---------------------------------------; +# The follow algorithm is used for the common interrupt routine. + +ASM_GLOBAL ASM_PFX(CommonInterruptEntry) +ASM_PFX(CommonInterruptEntry): + cli + popl %eax + # + # All interrupt handlers are invoked through interrupt gates, so + # IF flag automatically cleared at the entry point + # + + # + # Get vector number from top of stack + # + xchgl (%esp), %ecx + andl $0x0FF, %ecx # Vector number should be less than 256 + cmpl $32, %ecx # Intel reserved vector for exceptions? + jae NoErrorCode + bt %ecx, ASM_PFX(mErrorCodeFlag) + jc HasErrorCode + +NoErrorCode: + + # + # Stack: + # +---------------------+ + # + EFlags + + # +---------------------+ + # + CS + + # +---------------------+ + # + EIP + + # +---------------------+ + # + ECX + + # +---------------------+ <-- ESP + # + # Registers: + # ECX - Vector Number + # + + # + # Put Vector Number on stack + # + pushl %ecx + + # + # Put 0 (dummy) error code on stack, and restore ECX + # + xorl %ecx, %ecx # ECX = 0 + xchgl 4(%esp), %ecx + + jmp ErrorCodeAndVectorOnStack + +HasErrorCode: + + # + # Stack: + # +---------------------+ + # + EFlags + + # +---------------------+ + # + CS + + # +---------------------+ + # + EIP + + # +---------------------+ + # + Error Code + + # +---------------------+ + # + ECX + + # +---------------------+ <-- ESP + # + # Registers: + # ECX - Vector Number + # + + # + # Put Vector Number on stack and restore ECX + # + xchgl (%esp), %ecx + +ErrorCodeAndVectorOnStack: + pushl %ebp + movl %esp, %ebp + + # + # Stack: + # +---------------------+ + # + EFlags + + # +---------------------+ + # + CS + + # +---------------------+ + # + EIP + + # +---------------------+ + # + Error Code + + # +---------------------+ + # + Vector Number + + # +---------------------+ + # + EBP + + # +---------------------+ <-- EBP + # + + # + # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + # is 16-byte aligned + # + andl $0x0fffffff0, %esp + subl $12, %esp + + subl $8, %esp + pushl $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + pushl $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + +#; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pushl %eax + pushl %ecx + pushl %edx + pushl %ebx + leal 24(%ebp), %ecx + pushl %ecx # ESP + pushl (%ebp) # EBP + pushl %esi + pushl %edi + +#; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + movl %ss, %eax + pushl %eax + movzwl 16(%ebp), %eax + pushl %eax + movl %ds, %eax + pushl %eax + movl %es, %eax + pushl %eax + movl %fs, %eax + pushl %eax + movl %gs, %eax + pushl %eax + +#; UINT32 Eip; + movl 12(%ebp), %eax + pushl %eax + +#; UINT32 Gdtr[2], Idtr[2]; + subl $8, %esp + sidt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0x0FFFF, %eax + movl %eax, 4(%esp) + + subl $8, %esp + sgdt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0x0FFFF, %eax + movl %eax, 4(%esp) + +#; UINT32 Ldtr, Tr; + xorl %eax, %eax + str %ax + pushl %eax + sldt %ax + pushl %eax + +#; UINT32 EFlags; + movl 20(%ebp), %eax + pushl %eax + +#; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; +## insure FXSAVE/FXRSTOR is enabled in CR4... +## ... while we're at it, make sure DE is also enabled... + mov $1, %eax + pushl %ebx # temporarily save value of ebx on stack + cpuid # use CPUID to determine if FXSAVE/FXRESTOR + # and DE are supported + popl %ebx # retore value of ebx that was overwritten + # by CPUID + movl %cr4, %eax + pushl %eax # push cr4 firstly + testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support + jz L1 + orl $BIT9, %eax # Set CR4.OSFXSR +L1: + testl $BIT2, %edx # Test for Debugging Extensions support + jz L2 + orl $BIT3, %eax # Set CR4.DE +L2: + movl %eax, %cr4 + movl %cr3, %eax + pushl %eax + movl %cr2, %eax + pushl %eax + xorl %eax, %eax + pushl %eax + movl %cr0, %eax + pushl %eax + +#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + movl %dr7, %eax + pushl %eax + movl %dr6, %eax + pushl %eax + movl %dr3, %eax + pushl %eax + movl %dr2, %eax + pushl %eax + movl %dr1, %eax + pushl %eax + movl %dr0, %eax + pushl %eax + +#; FX_SAVE_STATE_IA32 FxSaveState; + subl $512, %esp + movl %esp, %edi + testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support. + # edx still contains result from CPUID above + jz L3 + .byte 0x0f, 0x0ae, 0x07 #fxsave [edi] +L3: + +#; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +#; UINT32 ExceptionData; + pushl 8(%ebp) + +#; Prepare parameter and call + movl %esp, %edx + pushl %edx + movl 4(%ebp), %edx + pushl %edx + + # + # Call External Exception Handler + # + call ASM_PFX(CommonExceptionHandler) + addl $8, %esp + + cli +#; UINT32 ExceptionData; + addl $4, %esp + +#; FX_SAVE_STATE_IA32 FxSaveState; + movl %esp, %esi + movl $1, %eax + cpuid # use CPUID to determine if FXSAVE/FXRESTOR + # are supported + testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support + jz L4 + .byte 0x0f, 0x0ae, 0x0e # fxrstor [esi] +L4: + addl $512, %esp + +#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +#; Skip restoration of DRx registers to support in-circuit emualators +#; or debuggers set breakpoint in interrupt/exception context + addl $24, %esp + +#; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + popl %eax + movl %eax, %cr0 + addl $4, %esp # not for Cr1 + popl %eax + movl %eax, %cr2 + popl %eax + movl %eax, %cr3 + popl %eax + movl %eax, %cr4 + +#; UINT32 EFlags; + popl 20(%ebp) + +#; UINT32 Ldtr, Tr; +#; UINT32 Gdtr[2], Idtr[2]; +#; Best not let anyone mess with these particular registers... + addl $24, %esp + +#; UINT32 Eip; + popl 12(%ebp) + +#; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +#; NOTE - modified segment registers could hang the debugger... We +#; could attempt to insulate ourselves against this possibility, +#; but that poses risks as well. +#; + popl %gs + popl %fs + popl %es + popl %ds + popl 16(%ebp) + popl %ss + +#; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + popl %edi + popl %esi + addl $4, %esp # not for ebp + addl $4, %esp # not for esp + popl %ebx + popl %edx + popl %ecx + popl %eax + + popl -8(%ebp) + popl -4(%ebp) + movl %ebp, %esp + popl %ebp + addl $8, %esp + cmpl $0, -16(%esp) # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn + cmpl $1, -20(%esp) # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + jz ErrorCode + jmp *-16(%esp) +ErrorCode: + subl $4, %esp + jmp *-12(%esp) + +DoReturn: + cmpl $0, ASM_PFX(mDoFarReturnFlag) + jz DoIret + pushl 8(%esp) # save EFLAGS + addl $16, %esp + pushl -8(%esp) # save CS in new location + pushl -8(%esp) # save EIP in new location + pushl -8(%esp) # save EFLAGS in new location + popfl # restore EFLAGS + lret # far return + +DoIret: + iretl + + +#---------------------------------------; +# _AsmGetTemplateAddressMap ; +#---------------------------------------; +# +# Protocol prototype +# AsmGetTemplateAddressMap ( +# EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap +# ); +# +# Routine Description: +# +# Return address map of interrupt handler template so that C code can generate +# interrupt table. +# +# Arguments: +# +# +# Returns: +# +# Nothing +# +# +# Input: [ebp][0] = Original ebp +# [ebp][4] = Return address +# +# Output: Nothing +# +# Destroys: Nothing +#-----------------------------------------------------------------------------; +#------------------------------------------------------------------------------------- +# AsmGetAddressMap (&AddressMap); +#------------------------------------------------------------------------------------- +ASM_GLOBAL ASM_PFX(AsmGetTemplateAddressMap) +ASM_PFX(AsmGetTemplateAddressMap): + + pushl %ebp + movl %esp,%ebp + pushal + + movl 0x8(%ebp), %ebx + movl $Exception0Handle, (%ebx) + movl $(Exception1Handle - Exception0Handle), 0x4(%ebx) + movl $(HookAfterStubBegin), 0x8(%ebx) + + popal + popl %ebp + ret +#------------------------------------------------------------------------------------- +# AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); +#------------------------------------------------------------------------------------- +ASM_GLOBAL ASM_PFX(AsmVectorNumFixup) +ASM_PFX(AsmVectorNumFixup): + movl 8(%esp), %eax + movl 4(%esp), %ecx + movb %al, (VectorNum - HookAfterStubBegin)(%ecx) + ret diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm new file mode 100644 index 0000000000..126680ea47 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm @@ -0,0 +1,467 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ExceptionHandlerAsm.Asm +; +; Abstract: +; +; IA32 CPU Exception Handler +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + +; +; CommonExceptionHandler() +; +CommonExceptionHandler PROTO C + +.data + +EXTRN mErrorCodeFlag:DWORD ; Error code flags for exceptions +EXTRN mDoFarReturnFlag:DWORD ; Do far return flag + +.code + +ALIGN 8 + +; +; exception handler stub table +; +AsmIdtVectorBegin: +REPEAT 32 + db 6ah ; push #VectorNum + db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum + push eax + mov eax, CommonInterruptEntry + jmp eax +ENDM +AsmIdtVectorEnd: + +HookAfterStubBegin: + db 6ah ; push +VectorNum: + db 0 ; 0 will be fixed + push eax + mov eax, HookAfterStubHeaderEnd + jmp eax +HookAfterStubHeaderEnd: + pop eax + sub esp, 8 ; reserve room for filling exception data later + push [esp + 8] + xchg ecx, [esp] ; get vector number + bt mErrorCodeFlag, ecx + jnc @F + push [esp] ; addition push if exception data needed +@@: + xchg ecx, [esp] ; restore ecx + push eax + +;----------------------------------------------------------------------------; +; CommonInterruptEntry ; +;----------------------------------------------------------------------------; +; The follow algorithm is used for the common interrupt routine. +; Entry from each interrupt with a push eax and eax=interrupt number +; Stack: +; +---------------------+ +; + EFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + EIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + EBP + +; +---------------------+ <-- EBP +CommonInterruptEntry PROC PUBLIC + cli + pop eax + ; + ; All interrupt handlers are invoked through interrupt gates, so + ; IF flag automatically cleared at the entry point + ; + + ; + ; Get vector number from top of stack + ; + xchg ecx, [esp] + and ecx, 0FFh ; Vector number should be less than 256 + cmp ecx, 32 ; Intel reserved vector for exceptions? + jae NoErrorCode + bt mErrorCodeFlag, ecx + jc HasErrorCode + +NoErrorCode: + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + ECX + + ; +---------------------+ <-- ESP + ; + ; Registers: + ; ECX - Vector Number + ; + + ; + ; Put Vector Number on stack + ; + push ecx + + ; + ; Put 0 (dummy) error code on stack, and restore ECX + ; + xor ecx, ecx ; ECX = 0 + xchg ecx, [esp+4] + + jmp ErrorCodeAndVectorOnStack + +HasErrorCode: + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + ECX + + ; +---------------------+ <-- ESP + ; + ; Registers: + ; ECX - Vector Number + ; + + ; + ; Put Vector Number on stack and restore ECX + ; + xchg ecx, [esp] + +ErrorCodeAndVectorOnStack: + push ebp + mov ebp, esp + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + Vector Number + + ; +---------------------+ + ; + EBP + + ; +---------------------+ <-- EBP + ; + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0fffffff0h + sub esp, 12 + + sub esp, 8 + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push eax + push ecx + push edx + push ebx + lea ecx, [ebp + 6 * 4] + push ecx ; ESP + push dword ptr [ebp] ; EBP + push esi + push edi + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + mov eax, ss + push eax + movzx eax, word ptr [ebp + 4 * 4] + push eax + mov eax, ds + push eax + mov eax, es + push eax + mov eax, fs + push eax + mov eax, gs + push eax + +;; UINT32 Eip; + mov eax, [ebp + 3 * 4] + push eax + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + xor eax, eax + str ax + push eax + sldt ax + push eax + +;; UINT32 EFlags; + mov eax, [ebp + 5 * 4] + push eax + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, 1 + push ebx ; temporarily save value of ebx on stack + cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE + ; are supported + pop ebx ; retore value of ebx that was overwritten by CPUID + mov eax, cr4 + push eax ; push cr4 firstly + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support + jz @F + or eax, BIT9 ; Set CR4.OSFXSR +@@: + test edx, BIT2 ; Test for Debugging Extensions support + jz @F + or eax, BIT3 ; Set CR4.DE +@@: + mov cr4, eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; + sub esp, 512 + mov edi, esp + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support. + ; edx still contains result from CPUID above + jz @F + db 0fh, 0aeh, 07h ;fxsave [edi] +@@: + +;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword ptr [ebp + 2 * 4] + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, dword ptr [ebp + 1 * 4] + push edx + + ; + ; Call External Exception Handler + ; + mov eax, CommonExceptionHandler + call eax + add esp, 8 + + cli +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + mov eax, 1 + cpuid ; use CPUID to determine if FXSAVE/FXRESTOR + ; are supported + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support + jz @F + db 0fh, 0aeh, 0eh ; fxrstor [esi] +@@: + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support in-circuit emualators +;; or debuggers set breakpoint in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov cr3, eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop dword ptr [ebp + 5 * 4] + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop dword ptr [ebp + 3 * 4] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop gs + pop fs + pop es + pop ds + pop dword ptr [ebp + 4 * 4] + pop ss + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop edi + pop esi + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop ebx + pop edx + pop ecx + pop eax + + pop dword ptr [ebp - 8] + pop dword ptr [ebp - 4] + mov esp, ebp + pop ebp + add esp, 8 + cmp dword ptr [esp - 16], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn + cmp dword ptr [esp - 20], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + jz ErrorCode + jmp dword ptr [esp - 16] +ErrorCode: + sub esp, 4 + jmp dword ptr [esp - 12] + +DoReturn: + cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET + jz DoIret + push [esp + 8] ; save EFLAGS + add esp, 16 + push [esp - 8] ; save CS in new location + push [esp - 8] ; save EIP in new location + push [esp - 8] ; save EFLAGS in new location + popfd ; restore EFLAGS + retf ; far return + +DoIret: + iretd + +CommonInterruptEntry ENDP + +;---------------------------------------; +; _AsmGetTemplateAddressMap ; +;----------------------------------------------------------------------------; +; +; Protocol prototype +; AsmGetTemplateAddressMap ( +; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap +; ); +; +; Routine Description: +; +; Return address map of interrupt handler template so that C code can generate +; interrupt table. +; +; Arguments: +; +; +; Returns: +; +; Nothing +; +; +; Input: [ebp][0] = Original ebp +; [ebp][4] = Return address +; +; Output: Nothing +; +; Destroys: Nothing +;-----------------------------------------------------------------------------; +AsmGetTemplateAddressMap proc near public + push ebp ; C prolog + mov ebp, esp + pushad + + mov ebx, dword ptr [ebp + 08h] + mov dword ptr [ebx], AsmIdtVectorBegin + mov dword ptr [ebx + 4h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 + mov dword ptr [ebx + 8h], HookAfterStubBegin + + popad + pop ebp + ret +AsmGetTemplateAddressMap ENDP + +;------------------------------------------------------------------------------------- +; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); +;------------------------------------------------------------------------------------- +AsmVectorNumFixup proc near public + mov eax, dword ptr [esp + 8] + mov ecx, [esp + 4] + mov [ecx + (VectorNum - HookAfterStubBegin)], al + ret +AsmVectorNumFixup ENDP +END diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm new file mode 100644 index 0000000000..45d6474091 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm @@ -0,0 +1,462 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ExceptionHandlerAsm.Asm +; +; Abstract: +; +; IA32 CPU Exception Handler +; +; Notes: +; +;------------------------------------------------------------------------------ + +; +; CommonExceptionHandler() +; +extern ASM_PFX(CommonExceptionHandler) + +SECTION .data + +extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions +extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag + +SECTION .text + +ALIGN 8 + +; +; exception handler stub table +; +AsmIdtVectorBegin: +%rep 32 + db 0x6a ; push #VectorNum + db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum + push eax + mov eax, ASM_PFX(CommonInterruptEntry) + jmp eax +%endrep +AsmIdtVectorEnd: + +HookAfterStubBegin: + db 0x6a ; push +VectorNum: + db 0 ; 0 will be fixed + push eax + mov eax, HookAfterStubHeaderEnd + jmp eax +HookAfterStubHeaderEnd: + pop eax + sub esp, 8 ; reserve room for filling exception data later + push dword [esp + 8] + xchg ecx, [esp] ; get vector number + bt [ASM_PFX(mErrorCodeFlag)], ecx + jnc .0 + push dword [esp] ; addition push if exception data needed +.0: + xchg ecx, [esp] ; restore ecx + push eax + +;----------------------------------------------------------------------------; +; CommonInterruptEntry ; +;----------------------------------------------------------------------------; +; The follow algorithm is used for the common interrupt routine. +; Entry from each interrupt with a push eax and eax=interrupt number +; Stack: +; +---------------------+ +; + EFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + EIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + EBP + +; +---------------------+ <-- EBP +global ASM_PFX(CommonInterruptEntry) +ASM_PFX(CommonInterruptEntry): + cli + pop eax + ; + ; All interrupt handlers are invoked through interrupt gates, so + ; IF flag automatically cleared at the entry point + ; + + ; + ; Get vector number from top of stack + ; + xchg ecx, [esp] + and ecx, 0xFF ; Vector number should be less than 256 + cmp ecx, 32 ; Intel reserved vector for exceptions? + jae NoErrorCode + bt [ASM_PFX(mErrorCodeFlag)], ecx + jc HasErrorCode + +NoErrorCode: + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + ECX + + ; +---------------------+ <-- ESP + ; + ; Registers: + ; ECX - Vector Number + ; + + ; + ; Put Vector Number on stack + ; + push ecx + + ; + ; Put 0 (dummy) error code on stack, and restore ECX + ; + xor ecx, ecx ; ECX = 0 + xchg ecx, [esp+4] + + jmp ErrorCodeAndVectorOnStack + +HasErrorCode: + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + ECX + + ; +---------------------+ <-- ESP + ; + ; Registers: + ; ECX - Vector Number + ; + + ; + ; Put Vector Number on stack and restore ECX + ; + xchg ecx, [esp] + +ErrorCodeAndVectorOnStack: + push ebp + mov ebp, esp + + ; + ; Stack: + ; +---------------------+ + ; + EFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + EIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + Vector Number + + ; +---------------------+ + ; + EBP + + ; +---------------------+ <-- EBP + ; + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0xfffffff0 + sub esp, 12 + + sub esp, 8 + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push eax + push ecx + push edx + push ebx + lea ecx, [ebp + 6 * 4] + push ecx ; ESP + push dword [ebp] ; EBP + push esi + push edi + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + mov eax, ss + push eax + movzx eax, word [ebp + 4 * 4] + push eax + mov eax, ds + push eax + mov eax, es + push eax + mov eax, fs + push eax + mov eax, gs + push eax + +;; UINT32 Eip; + mov eax, [ebp + 3 * 4] + push eax + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + xor eax, eax + str ax + push eax + sldt ax + push eax + +;; UINT32 EFlags; + mov eax, [ebp + 5 * 4] + push eax + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, 1 + push ebx ; temporarily save value of ebx on stack + cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE + ; are supported + pop ebx ; retore value of ebx that was overwritten by CPUID + mov eax, cr4 + push eax ; push cr4 firstly + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support + jz .1 + or eax, BIT9 ; Set CR4.OSFXSR +.1: + test edx, BIT2 ; Test for Debugging Extensions support + jz .2 + or eax, BIT3 ; Set CR4.DE +.2: + mov cr4, eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; + sub esp, 512 + mov edi, esp + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support. + ; edx still contains result from CPUID above + jz .3 + db 0xf, 0xae, 0x7 ;fxsave [edi] +.3: + +;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword [ebp + 2 * 4] + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, dword [ebp + 1 * 4] + push edx + + ; + ; Call External Exception Handler + ; + mov eax, ASM_PFX(CommonExceptionHandler) + call eax + add esp, 8 + + cli +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + mov eax, 1 + cpuid ; use CPUID to determine if FXSAVE/FXRESTOR + ; are supported + test edx, BIT24 ; Test for FXSAVE/FXRESTOR support + jz .4 + db 0xf, 0xae, 0xe ; fxrstor [esi] +.4: + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support in-circuit emualators +;; or debuggers set breakpoint in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov cr3, eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop dword [ebp + 5 * 4] + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop dword [ebp + 3 * 4] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop gs + pop fs + pop es + pop ds + pop dword [ebp + 4 * 4] + pop ss + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop edi + pop esi + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop ebx + pop edx + pop ecx + pop eax + + pop dword [ebp - 8] + pop dword [ebp - 4] + mov esp, ebp + pop ebp + add esp, 8 + cmp dword [esp - 16], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn + cmp dword [esp - 20], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + jz ErrorCode + jmp dword [esp - 16] +ErrorCode: + sub esp, 4 + jmp dword [esp - 12] + +DoReturn: + cmp dword [ASM_PFX(mDoFarReturnFlag)], 0 ; Check if need to do far return instead of IRET + jz DoIret + push dword [esp + 8] ; save EFLAGS + add esp, 16 + push dword [esp - 8] ; save CS in new location + push dword [esp - 8] ; save EIP in new location + push dword [esp - 8] ; save EFLAGS in new location + popfd ; restore EFLAGS + retf ; far return + +DoIret: + iretd + +;---------------------------------------; +; _AsmGetTemplateAddressMap ; +;----------------------------------------------------------------------------; +; +; Protocol prototype +; AsmGetTemplateAddressMap ( +; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap +; ); +; +; Routine Description: +; +; Return address map of interrupt handler template so that C code can generate +; interrupt table. +; +; Arguments: +; +; +; Returns: +; +; Nothing +; +; +; Input: [ebp][0] = Original ebp +; [ebp][4] = Return address +; +; Output: Nothing +; +; Destroys: Nothing +;-----------------------------------------------------------------------------; +global ASM_PFX(AsmGetTemplateAddressMap) +ASM_PFX(AsmGetTemplateAddressMap): + push ebp ; C prolog + mov ebp, esp + pushad + + mov ebx, dword [ebp + 0x8] + mov dword [ebx], AsmIdtVectorBegin + mov dword [ebx + 0x4], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 + mov dword [ebx + 0x8], HookAfterStubBegin + + popad + pop ebp + ret + +;------------------------------------------------------------------------------------- +; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmVectorNumFixup) +ASM_PFX(AsmVectorNumFixup): + mov eax, dword [esp + 8] + mov ecx, [esp + 4] + mov [ecx + (VectorNum - HookAfterStubBegin)], al + ret diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c new file mode 100644 index 0000000000..8d8d16ecbd --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c @@ -0,0 +1,180 @@ +/** @file + CPU exception handler library implementation for PEIM module. + +Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include "CpuExceptionCommon.h" +#include +#include +#include + +CONST UINTN mDoFarReturnFlag = 0; + +EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID; + +/** + Get exception handler data pointer from GUIDed HOb. + + @return pointer to exception handler data. +**/ +EXCEPTION_HANDLER_DATA * +GetExceptionHandlerData ( + VOID + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + EXCEPTION_HANDLER_DATA *ExceptionHandlerData; + + ExceptionHandlerData = NULL; + GuidHob = GetFirstGuidHob (&mCpuExceptrionHandlerLibHobGuid); + if (GuidHob != NULL) { + DataInHob = GET_GUID_HOB_DATA (GuidHob); + ExceptionHandlerData = (EXCEPTION_HANDLER_DATA *)(*(UINTN *)DataInHob); + } + ASSERT (ExceptionHandlerData != NULL); + return ExceptionHandlerData; +} + +/** + Common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +CommonExceptionHandler ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + EXCEPTION_HANDLER_DATA *ExceptionHandlerData; + + ExceptionHandlerData = GetExceptionHandlerData (); + CommonExceptionHandlerWorker (ExceptionType, SystemContext, ExceptionHandlerData); +} + +/** + Initializes all CPU exceptions entries and provides the default exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + Note: Before invoking this API, caller must allocate memory for IDT table and load + IDTR by AsmWriteIdtr(). + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuExceptionHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + EFI_STATUS Status; + EXCEPTION_HANDLER_DATA *ExceptionHandlerData; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM); + ASSERT (ReservedVectors != NULL); + + ExceptionHandlerData = AllocatePool (sizeof (EXCEPTION_HANDLER_DATA)); + ASSERT (ExceptionHandlerData != NULL); + ExceptionHandlerData->ReservedVectors = ReservedVectors; + ExceptionHandlerData->ExternalInterruptHandler = NULL; + InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); + + Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData); + if (EFI_ERROR (Status)) { + FreePool (ReservedVectors); + FreePool (ExceptionHandlerData); + return Status; + } + + // + // Build location of CPU MP DATA buffer in HOB + // + BuildGuidDataHob ( + &mCpuExceptrionHandlerLibHobGuid, + (VOID *)&ExceptionHandlerData, + sizeof(UINT64) + ); + + return EFI_SUCCESS; +} + +/** + Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized + with default interrupt/exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuInterruptHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Registers a function to be called from the processor interrupt handler. + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or + InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +EFIAPI +RegisterCpuInterruptHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return EFI_UNSUPPORTED; +} \ No newline at end of file diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf new file mode 100644 index 0000000000..75443288a9 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf @@ -0,0 +1,63 @@ +## @file +# CPU Exception Handler library instance for PEI module. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PeiCpuExceptionHandlerLib + MODULE_UNI_FILE = PeiCpuExceptionHandlerLib.uni + FILE_GUID = 980DDA67-44A6-4897-99E6-275290B71F9E + MODULE_TYPE = PEIM + VERSION_STRING = 1.1 + LIBRARY_CLASS = CpuExceptionHandlerLib|PEI_CORE PEIM + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.Ia32] + Ia32/ExceptionHandlerAsm.asm + Ia32/ExceptionHandlerAsm.nasm + Ia32/ExceptionHandlerAsm.S + Ia32/ArchExceptionHandler.c + Ia32/ArchInterruptDefs.h + +[Sources.X64] + X64/ExceptionHandlerAsm.asm + X64/ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.S + X64/ArchExceptionHandler.c + X64/ArchInterruptDefs.h + +[Sources.common] + CpuExceptionCommon.h + CpuExceptionCommon.c + PeiCpuException.c + PeiDxeSmmCpuException.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + SerialPortLib + PrintLib + LocalApicLib + PeCoffGetEntryPointLib + HobLib + MemoryAllocationLib + SynchronizationLib diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni new file mode 100644 index 0000000000..a89537f7ff --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Exception Handler library instance for PEI module. +// +// CPU Exception Handler library instance for PEI module. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for PEI module." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for PEI module." + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c new file mode 100644 index 0000000000..0facfde5dd --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -0,0 +1,294 @@ +/** @file + CPU Exception Library provides PEI/DXE/SMM CPU common exception handler. + +Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuExceptionCommon.h" +#include + +/** + Internal worker function for common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +CommonExceptionHandlerWorker ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + EXCEPTION_HANDLER_CONTEXT *ExceptionHandlerContext; + RESERVED_VECTORS_DATA *ReservedVectors; + EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; + + ExceptionHandlerContext = (EXCEPTION_HANDLER_CONTEXT *) (UINTN) (SystemContext.SystemContextIa32); + ReservedVectors = ExceptionHandlerData->ReservedVectors; + ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler; + + switch (ReservedVectors[ExceptionType].Attribute) { + case EFI_VECTOR_HANDOFF_HOOK_BEFORE: + // + // Need to jmp to old IDT handler after this exception handler + // + ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE; + ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler; + break; + case EFI_VECTOR_HANDOFF_HOOK_AFTER: + while (TRUE) { + // + // If if anyone has gotten SPIN_LOCK for owner running hook after + // + if (AcquireSpinLockOrFail (&ReservedVectors[ExceptionType].SpinLock)) { + // + // Need to execute old IDT handler before running this exception handler + // + ReservedVectors[ExceptionType].ApicId = GetApicId (); + ArchSaveExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData); + ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE; + ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler; + return; + } + // + // If failed to acquire SPIN_LOCK, check if it was locked by processor itself + // + if (ReservedVectors[ExceptionType].ApicId == GetApicId ()) { + // + // Old IDT handler has been executed, then restore CPU exception content to + // run new exception handler. + // + ArchRestoreExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData); + // + // Rlease spin lock for ApicId + // + ReleaseSpinLock (&ReservedVectors[ExceptionType].SpinLock); + break; + } + CpuPause (); + } + break; + case 0xffffffff: + break; + default: + // + // It should never reach here + // + CpuDeadLoop (); + break; + } + + if (ExternalInterruptHandler != NULL && + ExternalInterruptHandler[ExceptionType] != NULL) { + (ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContext); + } else if (ExceptionType < CPU_EXCEPTION_NUM) { + // + // Get Spinlock to display CPU information + // + while (!AcquireSpinLockOrFail (&ExceptionHandlerData->DisplayMessageSpinLock)) { + CpuPause (); + } + // + // Display ExceptionType, CPU information and Image information + // + DumpImageAndCpuContent (ExceptionType, SystemContext); + // + // Release Spinlock of output message + // + ReleaseSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); + // + // Enter a dead loop if needn't to execute old IDT handler further + // + if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE) { + CpuDeadLoop (); + } + } +} + +/** + Internal worker function to update IDT entries accordling to vector attributes. + + @param[in] IdtTable Pointer to IDT table. + @param[in] TemplateMap Pointer to a buffer where the address map is + returned. + @param[in] ExceptionHandlerData Pointer to exception handler data. + +**/ +VOID +UpdateIdtTable ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtTable, + IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + UINT16 CodeSegment; + UINTN Index; + UINTN InterruptHandler; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + // + // Use current CS as the segment selector of interrupt gate in IDT + // + CodeSegment = AsmReadCs (); + + for (Index = 0; Index < ExceptionHandlerData->IdtEntryCount; Index ++) { + IdtTable[Index].Bits.Selector = CodeSegment; + // + // Check reserved vectors attributes + // + switch (ReservedVectors[Index].Attribute) { + case EFI_VECTOR_HANDOFF_DO_NOT_HOOK: + // + // Keep original IDT entry + // + continue; + case EFI_VECTOR_HANDOFF_HOOK_AFTER: + InitializeSpinLock (&ReservedVectors[Index].SpinLock); + CopyMem ( + (VOID *) ReservedVectors[Index].HookAfterStubHeaderCode, + (VOID *) TemplateMap->HookAfterStubHeaderStart, + TemplateMap->ExceptionStubHeaderSize + ); + AsmVectorNumFixup ( + (VOID *) ReservedVectors[Index].HookAfterStubHeaderCode, + (UINT8) Index, + (VOID *) TemplateMap->HookAfterStubHeaderStart + ); + // + // Go on the following code + // + case EFI_VECTOR_HANDOFF_HOOK_BEFORE: + // + // Save original IDT handler address + // + ReservedVectors[Index].ExceptonHandler = ArchGetIdtHandler (&IdtTable[Index]); + // + // Go on the following code + // + default: + // + // Update new IDT entry + // + InterruptHandler = TemplateMap->ExceptionStart + Index * TemplateMap->ExceptionStubHeaderSize; + ArchUpdateIdtEntry (&IdtTable[Index], InterruptHandler); + break; + } + } +} + +/** + Internal worker function to initialize exception handler. + + @param[in] VectorInfo Pointer to reserved vector list. + @param[in, out] ExceptionHandlerData Pointer to exception handler data. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +InitializeCpuExceptionHandlersWorker ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, + IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + EFI_STATUS Status; + IA32_DESCRIPTOR IdtDescriptor; + UINTN IdtEntryCount; + EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; + IA32_IDT_GATE_DESCRIPTOR *IdtTable; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM, 0xff); + if (VectorInfo != NULL) { + Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, CPU_EXCEPTION_NUM); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + } + + // + // Read IDT descriptor and calculate IDT size + // + AsmReadIdtr (&IdtDescriptor); + IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); + if (IdtEntryCount > CPU_EXCEPTION_NUM) { + // + // CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at most + // + IdtEntryCount = CPU_EXCEPTION_NUM; + } + + IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base; + AsmGetTemplateAddressMap (&TemplateMap); + ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE); + + ExceptionHandlerData->IdtEntryCount = IdtEntryCount; + UpdateIdtTable (IdtTable, &TemplateMap, ExceptionHandlerData); + + return EFI_SUCCESS; +} + +/** + Registers a function to be called from the processor interrupt handler. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled + @param[in] ExceptionHandlerData Pointer to exception handler data. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +RegisterCpuInterruptHandlerWorker ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + UINTN EnabledInterruptNum; + RESERVED_VECTORS_DATA *ReservedVectors; + EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; + + EnabledInterruptNum = ExceptionHandlerData->IdtEntryCount; + ReservedVectors = ExceptionHandlerData->ReservedVectors; + ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler; + + if (InterruptType < 0 || InterruptType >= (EFI_EXCEPTION_TYPE)EnabledInterruptNum || + ReservedVectors[InterruptType].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) { + return EFI_UNSUPPORTED; + } + + if (InterruptHandler == NULL && ExternalInterruptHandler[InterruptType] == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (InterruptHandler != NULL && ExternalInterruptHandler[InterruptType] != NULL) { + return EFI_ALREADY_STARTED; + } + + ExternalInterruptHandler[InterruptType] = InterruptHandler; + return EFI_SUCCESS; +} + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c new file mode 100644 index 0000000000..af608bffb6 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -0,0 +1,179 @@ +/** @file + CPU exception handler library implemenation for SEC/PEIM modules. + +Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include "CpuExceptionCommon.h" + +CONST UINTN mDoFarReturnFlag = 0; + +/** + Common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +CommonExceptionHandler ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + // + // Display ExceptionType, CPU information and Image information + // + DumpImageAndCpuContent (ExceptionType, SystemContext); + + // + // Enter a dead loop. + // + CpuDeadLoop (); +} + +/** + Initializes all CPU exceptions entries and provides the default exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + Note: Before invoking this API, caller must allocate memory for IDT table and load + IDTR by AsmWriteIdtr(). + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuExceptionHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + EFI_STATUS Status; + RESERVED_VECTORS_DATA ReservedVectorData[CPU_EXCEPTION_NUM]; + IA32_DESCRIPTOR IdtDescriptor; + UINTN IdtEntryCount; + UINT16 CodeSegment; + EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; + IA32_IDT_GATE_DESCRIPTOR *IdtTable; + UINTN Index; + UINTN InterruptHandler; + + if (VectorInfo != NULL) { + SetMem ((VOID *) ReservedVectorData, sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM, 0xff); + Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectorData, CPU_EXCEPTION_NUM); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + } + // + // Read IDT descriptor and calculate IDT size + // + AsmReadIdtr (&IdtDescriptor); + IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); + if (IdtEntryCount > CPU_EXCEPTION_NUM) { + // + // CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at most + // + IdtEntryCount = CPU_EXCEPTION_NUM; + } + // + // Use current CS as the segment selector of interrupt gate in IDT + // + CodeSegment = AsmReadCs (); + + AsmGetTemplateAddressMap (&TemplateMap); + IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base; + for (Index = 0; Index < IdtEntryCount; Index ++) { + IdtTable[Index].Bits.Selector = CodeSegment; + // + // Check reserved vectors attributes if has, only EFI_VECTOR_HANDOFF_DO_NOT_HOOK + // supported in this instance + // + if (VectorInfo != NULL) { + if (ReservedVectorData[Index].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) { + continue; + } + } + // + // Update IDT entry + // + InterruptHandler = TemplateMap.ExceptionStart + Index * TemplateMap.ExceptionStubHeaderSize; + ArchUpdateIdtEntry (&IdtTable[Index], InterruptHandler); + } + return EFI_SUCCESS; +} + +/** + Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized + with default interrupt/exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuInterruptHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Registers a function to be called from the processor interrupt handler. + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or + InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +EFIAPI +RegisterCpuInterruptHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return EFI_UNSUPPORTED; +} \ No newline at end of file diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf new file mode 100644 index 0000000000..d70a99c100 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf @@ -0,0 +1,59 @@ +## @file +# CPU Exception Handler library instance for SEC/PEI modules. +# +# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SecPeiCpuExceptionHandlerLib + MODULE_UNI_FILE = SecPeiCpuExceptionHandlerLib.uni + FILE_GUID = CA4BBC99-DFC6-4234-B553-8B6586B7B113 + MODULE_TYPE = PEIM + VERSION_STRING = 1.1 + LIBRARY_CLASS = CpuExceptionHandlerLib|SEC PEI_CORE PEIM + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.Ia32] + Ia32/ExceptionHandlerAsm.asm + Ia32/ExceptionHandlerAsm.nasm + Ia32/ExceptionHandlerAsm.S + Ia32/ArchExceptionHandler.c + Ia32/ArchInterruptDefs.h + +[Sources.X64] + X64/ExceptionHandlerAsm.asm + X64/ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.S + X64/ArchExceptionHandler.c + X64/ArchInterruptDefs.h + +[Sources.common] + CpuExceptionCommon.h + CpuExceptionCommon.c + SecPeiCpuException.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + SerialPortLib + PrintLib + LocalApicLib + PeCoffGetEntryPointLib diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni new file mode 100644 index 0000000000..de8b846a67 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Exception Handler library instance for SEC/PEI modules. +// +// CPU Exception Handler library instance for SEC/PEI modules. +// +// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for SEC/PEI modules." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for SEC/PEI modules." + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf new file mode 100644 index 0000000000..634ffcb21d --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf @@ -0,0 +1,63 @@ +## @file +# CPU Exception Handler library instance for SMM modules. +# +# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmCpuExceptionHandlerLib + MODULE_UNI_FILE = SmmCpuExceptionHandlerLib.uni + FILE_GUID = 8D2C439B-3981-42ff-9CE5-1B50ECA502D6 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.1 + LIBRARY_CLASS = CpuExceptionHandlerLib|DXE_SMM_DRIVER + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.Ia32] + Ia32/ExceptionHandlerAsm.asm + Ia32/ExceptionHandlerAsm.nasm + Ia32/ExceptionHandlerAsm.S + Ia32/ArchExceptionHandler.c + Ia32/ArchInterruptDefs.h + +[Sources.X64] + X64/ExceptionHandlerAsm.asm + X64/ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.S + X64/ArchExceptionHandler.c + X64/ArchInterruptDefs.h + +[Sources.common] + CpuExceptionCommon.h + CpuExceptionCommon.c + PeiDxeSmmCpuException.c + SmmException.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + SerialPortLib + PrintLib + SynchronizationLib + LocalApicLib + PeCoffGetEntryPointLib + DebugLib + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni new file mode 100644 index 0000000000..3dfa69547b --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Exception Handler library instance for SMM modules. +// +// CPU Exception Handler library instance for SMM modules. +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for SMM modules." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for SMM modules." + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c new file mode 100644 index 0000000000..7414d3f773 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c @@ -0,0 +1,128 @@ +/** @file + CPU exception handler library implemenation for SMM modules. + + Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include "CpuExceptionCommon.h" + +CONST UINTN mDoFarReturnFlag = 1; + +// +// Spin lock for CPU information display +// +SPIN_LOCK mDisplayMessageSpinLock; + +RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM]; +EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM]; +EXCEPTION_HANDLER_DATA mExceptionHandlerData; +/** + Common exception handler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +CommonExceptionHandler ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData); +} + +/** + Initializes all CPU exceptions entries and provides the default exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized + with default exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuExceptionHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + mExceptionHandlerData.ReservedVectors = mReservedVectorsData; + mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable; + InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); + return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData); +} + +/** + Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. + + Caller should try to get an array of interrupt and/or exception vectors that are in use and need to + persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. + If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. + If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. + + @param[in] VectorInfo Pointer to reserved vector list. + + @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized + with default interrupt/exception handlers. + @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +InitializeCpuInterruptHandlers ( + IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Registers a function to be called from the processor interrupt handler. + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or + InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +EFIAPI +RegisterCpuInterruptHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData); +} \ No newline at end of file diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c new file mode 100644 index 0000000000..65f0cff680 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -0,0 +1,262 @@ +/** @file + x64 CPU Exception Handler. + + Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "CpuExceptionCommon.h" + +/** + Return address map of exception handler template so that C code can generate + exception tables. + + @param IdtEntry Pointer to IDT entry to be updated. + @param InterruptHandler IDT handler value. +**/ +VOID +ArchUpdateIdtEntry ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler + ) +{ + IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; + IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); + IdtEntry->Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32); + IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; +} + +/** + Read IDT handler value from IDT entry. + + @param IdtEntry Pointer to IDT entry to be read. + +**/ +UINTN +ArchGetIdtHandler ( + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry + ) +{ + return IdtEntry->Bits.OffsetLow + (((UINTN) IdtEntry->Bits.OffsetHigh) << 16) + + (((UINTN) IdtEntry->Bits.OffsetUpper) << 32); +} + +/** + Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchSaveExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + IA32_EFLAGS32 Eflags; + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + // + // Save Exception context in global variable + // + ReservedVectors[ExceptionType].OldSs = SystemContext.SystemContextX64->Ss; + ReservedVectors[ExceptionType].OldSp = SystemContext.SystemContextX64->Rsp; + ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextX64->Rflags; + ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextX64->Cs; + ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextX64->Rip; + ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextX64->ExceptionData; + // + // Clear IF flag to avoid old IDT handler enable interrupt by IRET + // + Eflags.UintN = SystemContext.SystemContextX64->Rflags; + Eflags.Bits.IF = 0; + SystemContext.SystemContextX64->Rflags = Eflags.UintN; + // + // Modify the EIP in stack, then old IDT handler will return to the stub code + // + SystemContext.SystemContextX64->Rip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode; +} + +/** + Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. + + @param[in] ExceptionType Exception type. + @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. + @param[in] ExceptionHandlerData Pointer to exception handler data. +**/ +VOID +ArchRestoreExceptionContext ( + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + ) +{ + RESERVED_VECTORS_DATA *ReservedVectors; + + ReservedVectors = ExceptionHandlerData->ReservedVectors; + SystemContext.SystemContextX64->Ss = ReservedVectors[ExceptionType].OldSs; + SystemContext.SystemContextX64->Rsp = ReservedVectors[ExceptionType].OldSp; + SystemContext.SystemContextX64->Rflags = ReservedVectors[ExceptionType].OldFlags; + SystemContext.SystemContextX64->Cs = ReservedVectors[ExceptionType].OldCs; + SystemContext.SystemContextX64->Rip = ReservedVectors[ExceptionType].OldIp; + SystemContext.SystemContextX64->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; +} + +/** + Display CPU information. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +DumpCpuContext ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + InternalPrintMessage ( + "!!!! X64 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n", + ExceptionType, + GetExceptionNameStr (ExceptionType), + GetApicId () + ); + if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) { + InternalPrintMessage ( + "ExceptionData - %016lx", + SystemContext.SystemContextX64->ExceptionData + ); + if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) { + InternalPrintMessage ( + " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_RSVD) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_US) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_WR) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_P) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_PK) != 0, + (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_SGX) != 0 + ); + } + InternalPrintMessage ("\n"); + } + InternalPrintMessage ( + "RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n", + SystemContext.SystemContextX64->Rip, + SystemContext.SystemContextX64->Cs, + SystemContext.SystemContextX64->Rflags + ); + InternalPrintMessage ( + "RAX - %016lx, RCX - %016lx, RDX - %016lx\n", + SystemContext.SystemContextX64->Rax, + SystemContext.SystemContextX64->Rcx, + SystemContext.SystemContextX64->Rdx + ); + InternalPrintMessage ( + "RBX - %016lx, RSP - %016lx, RBP - %016lx\n", + SystemContext.SystemContextX64->Rbx, + SystemContext.SystemContextX64->Rsp, + SystemContext.SystemContextX64->Rbp + ); + InternalPrintMessage ( + "RSI - %016lx, RDI - %016lx\n", + SystemContext.SystemContextX64->Rsi, + SystemContext.SystemContextX64->Rdi + ); + InternalPrintMessage ( + "R8 - %016lx, R9 - %016lx, R10 - %016lx\n", + SystemContext.SystemContextX64->R8, + SystemContext.SystemContextX64->R9, + SystemContext.SystemContextX64->R10 + ); + InternalPrintMessage ( + "R11 - %016lx, R12 - %016lx, R13 - %016lx\n", + SystemContext.SystemContextX64->R11, + SystemContext.SystemContextX64->R12, + SystemContext.SystemContextX64->R13 + ); + InternalPrintMessage ( + "R14 - %016lx, R15 - %016lx\n", + SystemContext.SystemContextX64->R14, + SystemContext.SystemContextX64->R15 + ); + InternalPrintMessage ( + "DS - %016lx, ES - %016lx, FS - %016lx\n", + SystemContext.SystemContextX64->Ds, + SystemContext.SystemContextX64->Es, + SystemContext.SystemContextX64->Fs + ); + InternalPrintMessage ( + "GS - %016lx, SS - %016lx\n", + SystemContext.SystemContextX64->Gs, + SystemContext.SystemContextX64->Ss + ); + InternalPrintMessage ( + "CR0 - %016lx, CR2 - %016lx, CR3 - %016lx\n", + SystemContext.SystemContextX64->Cr0, + SystemContext.SystemContextX64->Cr2, + SystemContext.SystemContextX64->Cr3 + ); + InternalPrintMessage ( + "CR4 - %016lx, CR8 - %016lx\n", + SystemContext.SystemContextX64->Cr4, + SystemContext.SystemContextX64->Cr8 + ); + InternalPrintMessage ( + "DR0 - %016lx, DR1 - %016lx, DR2 - %016lx\n", + SystemContext.SystemContextX64->Dr0, + SystemContext.SystemContextX64->Dr1, + SystemContext.SystemContextX64->Dr2 + ); + InternalPrintMessage ( + "DR3 - %016lx, DR6 - %016lx, DR7 - %016lx\n", + SystemContext.SystemContextX64->Dr3, + SystemContext.SystemContextX64->Dr6, + SystemContext.SystemContextX64->Dr7 + ); + InternalPrintMessage ( + "GDTR - %016lx %016lx, LDTR - %016lx\n", + SystemContext.SystemContextX64->Gdtr[0], + SystemContext.SystemContextX64->Gdtr[1], + SystemContext.SystemContextX64->Ldtr + ); + InternalPrintMessage ( + "IDTR - %016lx %016lx, TR - %016lx\n", + SystemContext.SystemContextX64->Idtr[0], + SystemContext.SystemContextX64->Idtr[1], + SystemContext.SystemContextX64->Tr + ); + InternalPrintMessage ( + "FXSAVE_STATE - %016lx\n", + &SystemContext.SystemContextX64->FxSaveState + ); +} + +/** + Display CPU information. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +DumpImageAndCpuContent ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + DumpCpuContext (ExceptionType, SystemContext); + // + // Dump module image base and module entry point by RIP + // + DumpModuleImageInfo (SystemContext.SystemContextX64->Rip); +} diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h new file mode 100644 index 0000000000..906480134a --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h @@ -0,0 +1,46 @@ +/** @file + X64 arch definition for CPU Exception Handler Library. + + Copyright (c) 2013, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _ARCH_CPU_INTERRUPT_DEFS_H_ +#define _ARCH_CPU_INTERRUPT_DEFS_H_ + +typedef struct { + EFI_SYSTEM_CONTEXT_X64 SystemContext; + BOOLEAN ExceptionDataFlag; + UINTN OldIdtHandler; +} EXCEPTION_HANDLER_CONTEXT; + +// +// Register Structure Definitions +// +typedef struct { + EFI_STATUS_CODE_DATA Header; + EFI_SYSTEM_CONTEXT_X64 SystemContext; +} CPU_STATUS_CODE_TEMPLATE; + +typedef struct { + SPIN_LOCK SpinLock; + UINT32 ApicId; + UINT32 Attribute; + UINTN ExceptonHandler; + UINTN OldSs; + UINTN OldSp; + UINTN OldFlags; + UINTN OldCs; + UINTN OldIp; + UINTN ExceptionData; + UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; +} RESERVED_VECTORS_DATA; + +#endif diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S new file mode 100644 index 0000000000..edd363cdaa --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S @@ -0,0 +1,434 @@ +#------------------------------------------------------------------------------ ; +# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# ExceptionHandlerAsm.S +# +# Abstract: +# +# x64 CPU Exception Handler +# +# Notes: +# +#------------------------------------------------------------------------------ + + + +ASM_GLOBAL ASM_PFX(CommonExceptionHandler) + +#EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions +#EXTRN ASM_PFX(mDoFarReturnFlag):QWORD # Do far return flag +.text + +#ifdef __APPLE__ +# macros are different between GNU and Xcode as. +.macro IDT_MACRO + push $0 +#else +.macro IDT_MACRO arg + push \arg +#endif + .byte 0xe9 # jmp ASM_PFX(CommonInterruptEntry) + .long ASM_PFX(CommonInterruptEntry) - . - 4 +.endm + +AsmIdtVectorBegin: + IDT_MACRO $0 + IDT_MACRO $1 + IDT_MACRO $2 + IDT_MACRO $3 + IDT_MACRO $4 + IDT_MACRO $5 + IDT_MACRO $6 + IDT_MACRO $7 + IDT_MACRO $8 + IDT_MACRO $9 + IDT_MACRO $10 + IDT_MACRO $11 + IDT_MACRO $12 + IDT_MACRO $13 + IDT_MACRO $14 + IDT_MACRO $15 + IDT_MACRO $16 + IDT_MACRO $17 + IDT_MACRO $18 + IDT_MACRO $19 + IDT_MACRO $20 + IDT_MACRO $21 + IDT_MACRO $22 + IDT_MACRO $23 + IDT_MACRO $24 + IDT_MACRO $25 + IDT_MACRO $26 + IDT_MACRO $27 + IDT_MACRO $28 + IDT_MACRO $29 + IDT_MACRO $30 + IDT_MACRO $31 +AsmIdtVectorEnd: + +HookAfterStubHeaderBegin: + .byte 0x6a # push +PatchVectorNum: + .byte 0 # 0 will be fixed + .byte 0xe9 # jmp ASM_PFX(HookAfterStubHeaderEnd) +PatchFuncAddress: + .set HOOK_ADDRESS, ASM_PFX(HookAfterStubHeaderEnd) - . - 4 + .long HOOK_ADDRESS # will be fixed +ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) +ASM_PFX(HookAfterStubHeaderEnd): + pushq %rax + movq %rsp, %rax + andl $0x0fffffff0, %esp # make sure 16-byte aligned for exception context + subq $0x18, %rsp # reserve room for filling exception data later + pushq %rcx + movq 8(%rax), %rcx + bt %ecx, ASM_PFX(mErrorCodeFlag)(%rip) + jnc NoErrorData + pushq (%rsp) # push additional rcx to make stack alignment +NoErrorData: + xchgq (%rsp), %rcx # restore rcx, save Exception Number in stack + movq (%rax), %rax # restore rax + +#---------------------------------------; +# CommonInterruptEntry ; +#---------------------------------------; +# The follow algorithm is used for the common interrupt routine. + +ASM_GLOBAL ASM_PFX(CommonInterruptEntry) +ASM_PFX(CommonInterruptEntry): + cli + # + # All interrupt handlers are invoked through interrupt gates, so + # IF flag automatically cleared at the entry point + # + # + # Calculate vector number + # + xchgq (%rsp), %rcx # get the return address of call, actually, it is the address of vector number. + andq $0x0FF, %rcx + cmp $32, %ecx # Intel reserved vector for exceptions? + jae NoErrorCode + pushq %rax + movl ASM_PFX(mErrorCodeFlag)(%rip), %eax + bt %ecx, %eax + popq %rax + jc CommonInterruptEntry_al_0000 + +NoErrorCode: + + # + # Push a dummy error code on the stack + # to maintain coherent stack map + # + pushq (%rsp) + movq $0, 8(%rsp) +CommonInterruptEntry_al_0000: + pushq %rbp + movq %rsp, %rbp + pushq $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + pushq $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + + # + # Stack: + # +---------------------+ <-- 16-byte aligned ensured by processor + # + Old SS + + # +---------------------+ + # + Old RSP + + # +---------------------+ + # + RFlags + + # +---------------------+ + # + CS + + # +---------------------+ + # + RIP + + # +---------------------+ + # + Error Code + + # +---------------------+ + # + RCX / Vector Number + + # +---------------------+ + # + RBP + + # +---------------------+ <-- RBP, 16-byte aligned + # + + + # + # Since here the stack pointer is 16-byte aligned, so + # EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + # is 16-byte aligned + # + +#; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +#; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pushq %r15 + pushq %r14 + pushq %r13 + pushq %r12 + pushq %r11 + pushq %r10 + pushq %r9 + pushq %r8 + pushq %rax + pushq 8(%rbp) # RCX + pushq %rdx + pushq %rbx + pushq 48(%rbp) # RSP + pushq (%rbp) # RBP + pushq %rsi + pushq %rdi + +#; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzwq 56(%rbp), %rax + pushq %rax # for ss + movzwq 32(%rbp), %rax + pushq %rax # for cs + mov %ds, %rax + pushq %rax + mov %es, %rax + pushq %rax + mov %fs, %rax + pushq %rax + mov %gs, %rax + pushq %rax + + movq %rcx, 8(%rbp) # save vector number + +#; UINT64 Rip; + pushq 24(%rbp) + +#; UINT64 Gdtr[2], Idtr[2]; + xorq %rax, %rax + pushq %rax + pushq %rax + sidt (%rsp) + xchgq 2(%rsp), %rax + xchgq (%rsp), %rax + xchgq 8(%rsp), %rax + + xorq %rax, %rax + pushq %rax + pushq %rax + sgdt (%rsp) + xchgq 2(%rsp), %rax + xchgq (%rsp), %rax + xchgq 8(%rsp), %rax + +#; UINT64 Ldtr, Tr; + xorq %rax, %rax + str %ax + pushq %rax + sldt %ax + pushq %rax + +#; UINT64 RFlags; + pushq 40(%rbp) + +#; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + movq %cr8, %rax + pushq %rax + movq %cr4, %rax + orq $0x208, %rax + movq %rax, %cr4 + pushq %rax + mov %cr3, %rax + pushq %rax + mov %cr2, %rax + pushq %rax + xorq %rax, %rax + pushq %rax + mov %cr0, %rax + pushq %rax + +#; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + movq %dr7, %rax + pushq %rax + movq %dr6, %rax + pushq %rax + movq %dr3, %rax + pushq %rax + movq %dr2, %rax + pushq %rax + movq %dr1, %rax + pushq %rax + movq %dr0, %rax + pushq %rax + +#; FX_SAVE_STATE_X64 FxSaveState; + subq $512, %rsp + movq %rsp, %rdi + .byte 0x0f, 0x0ae, 0x07 #fxsave [rdi] + +#; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +#; UINT32 ExceptionData; + pushq 16(%rbp) + +#; Prepare parameter and call + mov 8(%rbp), %rcx + mov %rsp, %rdx + # + # Per X64 calling convention, allocate maximum parameter stack space + # and make sure RSP is 16-byte aligned + # + subq $40, %rsp + call ASM_PFX(CommonExceptionHandler) + addq $40, %rsp + + cli +#; UINT64 ExceptionData; + addq $8, %rsp + +#; FX_SAVE_STATE_X64 FxSaveState; + + movq %rsp, %rsi + .byte 0x0f, 0x0ae, 0x0E # fxrstor [rsi] + addq $512, %rsp + +#; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +#; Skip restoration of DRx registers to support in-circuit emualators +#; or debuggers set breakpoint in interrupt/exception context + addq $48, %rsp + +#; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + popq %rax + movq %rax, %cr0 + addq $8, %rsp # not for Cr1 + popq %rax + movq %rax, %cr2 + popq %rax + movq %rax, %cr3 + popq %rax + movq %rax, %cr4 + popq %rax + movq %rax, %cr8 + +#; UINT64 RFlags; + popq 40(%rbp) + +#; UINT64 Ldtr, Tr; +#; UINT64 Gdtr[2], Idtr[2]; +#; Best not let anyone mess with these particular registers... + addq $48, %rsp + +#; UINT64 Rip; + popq 24(%rbp) + +#; UINT64 Gs, Fs, Es, Ds, Cs, Ss; + popq %rax + # mov %rax, %gs ; not for gs + popq %rax + # mov %rax, %fs ; not for fs + # (X64 will not use fs and gs, so we do not restore it) + popq %rax + mov %rax, %es + popq %rax + mov %rax, %ds + popq 32(%rbp) # for cs + popq 56(%rbp) # for ss + +#; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +#; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + popq %rdi + popq %rsi + addq $8, %rsp # not for rbp + popq 48(%rbp) # for rsp + popq %rbx + popq %rdx + popq %rcx + popq %rax + popq %r8 + popq %r9 + popq %r10 + popq %r11 + popq %r12 + popq %r13 + popq %r14 + popq %r15 + + movq %rbp, %rsp + popq %rbp + addq $16, %rsp + cmpq $0, -32(%rsp) # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + cmpb $1, -40(%rsp) + jz ErrorCode + jmp *-32(%rsp) +ErrorCode: + subq $8, %rsp + jmp *-24(%rsp) + +DoReturn: + pushq %rax + movq ASM_PFX(mDoFarReturnFlag)(%rip), %rax + cmpq $0, %rax # Check if need to do far return instead of IRET + popq %rax + jz DoIret + pushq %rax + movq %rsp, %rax # save old RSP to rax + movq 0x20(%rsp), %rsp + pushq 0x10(%rax) # save CS in new location + pushq 0x8(%rax) # save EIP in new location + pushq 0x18(%rax) # save EFLAGS in new location + movq (%rax), %rax # restore rax + popfq # restore EFLAGS + lretq # far return +DoIret: + iretq + + +#------------------------------------------------------------------------------------- +# AsmGetTemplateAddressMap (&AddressMap); +#------------------------------------------------------------------------------------- +# comments here for definition of address map +ASM_GLOBAL ASM_PFX(AsmGetTemplateAddressMap) +ASM_PFX(AsmGetTemplateAddressMap): + pushq %rbp + movq %rsp, %rbp + + leaq AsmIdtVectorBegin(%rip), %rax + movq %rax, (%rcx) + .set ENTRY_SIZE, ASM_PFX(HookAfterStubHeaderEnd) - HookAfterStubHeaderBegin + movq $(ENTRY_SIZE), 0x08(%rcx) + leaq HookAfterStubHeaderBegin(%rip), %rax + movq %rax, 0x10(%rcx) + + popq %rbp + ret + +#------------------------------------------------------------------------------------- +# VOID +# EFIAPI +# AsmVectorNumFixup ( +# IN VOID *NewVectorAddr, // RCX +# IN UINT8 VectorNum // RDX +# IN VOID *OldVectorAddr, // R8 +# ); +#------------------------------------------------------------------------------------- +ASM_GLOBAL ASM_PFX(AsmVectorNumFixup) +ASM_PFX(AsmVectorNumFixup): + pushq %rbp + movq %rsp, %rbp + +# Patch vector # + movb %dl, (PatchVectorNum - HookAfterStubHeaderBegin)(%rcx) + +# Patch Function address + subq %rcx, %r8 # Calculate the offset value + movl (PatchFuncAddress - HookAfterStubHeaderBegin)(%rcx), %eax + addq %r8, %rax + movl %eax, (PatchFuncAddress - HookAfterStubHeaderBegin)(%rcx) + + popq %rbp + ret + +#END + + diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm new file mode 100644 index 0000000000..726c64a140 --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm @@ -0,0 +1,389 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ExceptionHandlerAsm.Asm +; +; Abstract: +; +; x64 CPU Exception Handler +; +; Notes: +; +;------------------------------------------------------------------------------ + +; +; CommonExceptionHandler() +; +externdef CommonExceptionHandler:near + +EXTRN mErrorCodeFlag:DWORD ; Error code flags for exceptions +EXTRN mDoFarReturnFlag:QWORD ; Do far return flag + +data SEGMENT + +.code + +ALIGN 8 + +AsmIdtVectorBegin: +REPEAT 32 + db 6ah ; push #VectorNum + db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum + push rax + mov rax, CommonInterruptEntry + jmp rax +ENDM +AsmIdtVectorEnd: + +HookAfterStubHeaderBegin: + db 6ah ; push +@VectorNum: + db 0 ; 0 will be fixed + push rax + mov rax, HookAfterStubHeaderEnd + jmp rax +HookAfterStubHeaderEnd: + mov rax, rsp + and sp, 0fff0h ; make sure 16-byte aligned for exception context + sub rsp, 18h ; reserve room for filling exception data later + push rcx + mov rcx, [rax + 8] + bt mErrorCodeFlag, ecx + jnc @F + push [rsp] ; push additional rcx to make stack alignment +@@: + xchg rcx, [rsp] ; restore rcx, save Exception Number in stack + push [rax] ; push rax into stack to keep code consistence + +;---------------------------------------; +; CommonInterruptEntry ; +;---------------------------------------; +; The follow algorithm is used for the common interrupt routine. +; Entry from each interrupt with a push eax and eax=interrupt number +; Stack frame would be as follows as specified in IA32 manuals: +; +; +---------------------+ <-- 16-byte aligned ensured by processor +; + Old SS + +; +---------------------+ +; + Old RSP + +; +---------------------+ +; + RFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + RIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + RBP + +; +---------------------+ <-- RBP, 16-byte aligned +; The follow algorithm is used for the common interrupt routine. +CommonInterruptEntry PROC PUBLIC + cli + pop rax + ; + ; All interrupt handlers are invoked through interrupt gates, so + ; IF flag automatically cleared at the entry point + ; + xchg rcx, [rsp] ; Save rcx into stack and save vector number into rcx + and rcx, 0FFh + cmp ecx, 32 ; Intel reserved vector for exceptions? + jae NoErrorCode + bt mErrorCodeFlag, ecx + jc @F + +NoErrorCode: + + ; + ; Push a dummy error code on the stack + ; to maintain coherent stack map + ; + push [rsp] + mov qword ptr [rsp + 8], 0 +@@: + push rbp + mov rbp, rsp + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + + ; + ; Stack: + ; +---------------------+ <-- 16-byte aligned ensured by processor + ; + Old SS + + ; +---------------------+ + ; + Old RSP + + ; +---------------------+ + ; + RFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + RIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + RCX / Vector Number + + ; +---------------------+ + ; + RBP + + ; +---------------------+ <-- RBP, 16-byte aligned + ; + + + ; + ; Since here the stack pointer is 16-byte aligned, so + ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + ; is 16-byte aligned + ; + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + push r15 + push r14 + push r13 + push r12 + push r11 + push r10 + push r9 + push r8 + push rax + push qword ptr [rbp + 8] ; RCX + push rdx + push rbx + push qword ptr [rbp + 48] ; RSP + push qword ptr [rbp] ; RBP + push rsi + push rdi + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzx rax, word ptr [rbp + 56] + push rax ; for ss + movzx rax, word ptr [rbp + 32] + push rax ; for cs + mov rax, ds + push rax + mov rax, es + push rax + mov rax, fs + push rax + mov rax, gs + push rax + + mov [rbp + 8], rcx ; save vector number + +;; UINT64 Rip; + push qword ptr [rbp + 24] + +;; UINT64 Gdtr[2], Idtr[2]; + xor rax, rax + push rax + push rax + sidt [rsp] + xchg rax, [rsp + 2] + xchg rax, [rsp] + xchg rax, [rsp + 8] + + xor rax, rax + push rax + push rax + sgdt [rsp] + xchg rax, [rsp + 2] + xchg rax, [rsp] + xchg rax, [rsp + 8] + +;; UINT64 Ldtr, Tr; + xor rax, rax + str ax + push rax + sldt ax + push rax + +;; UINT64 RFlags; + push qword ptr [rbp + 40] + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + mov rax, cr8 + push rax + mov rax, cr4 + or rax, 208h + mov cr4, rax + push rax + mov rax, cr3 + push rax + mov rax, cr2 + push rax + xor rax, rax + push rax + mov rax, cr0 + push rax + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov rax, dr7 + push rax + mov rax, dr6 + push rax + mov rax, dr3 + push rax + mov rax, dr2 + push rax + mov rax, dr1 + push rax + mov rax, dr0 + push rax + +;; FX_SAVE_STATE_X64 FxSaveState; + sub rsp, 512 + mov rdi, rsp + db 0fh, 0aeh, 07h ;fxsave [rdi] + +;; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push qword ptr [rbp + 16] + +;; Prepare parameter and call + mov rcx, [rbp + 8] + mov rdx, rsp + ; + ; Per X64 calling convention, allocate maximum parameter stack space + ; and make sure RSP is 16-byte aligned + ; + sub rsp, 4 * 8 + 8 + mov rax, CommonExceptionHandler + call rax + add rsp, 4 * 8 + 8 + + cli +;; UINT64 ExceptionData; + add rsp, 8 + +;; FX_SAVE_STATE_X64 FxSaveState; + + mov rsi, rsp + db 0fh, 0aeh, 0Eh ; fxrstor [rsi] + add rsp, 512 + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support in-circuit emualators +;; or debuggers set breakpoint in interrupt/exception context + add rsp, 8 * 6 + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + pop rax + mov cr0, rax + add rsp, 8 ; not for Cr1 + pop rax + mov cr2, rax + pop rax + mov cr3, rax + pop rax + mov cr4, rax + pop rax + mov cr8, rax + +;; UINT64 RFlags; + pop qword ptr [rbp + 40] + +;; UINT64 Ldtr, Tr; +;; UINT64 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add rsp, 48 + +;; UINT64 Rip; + pop qword ptr [rbp + 24] + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; + pop rax + ; mov gs, rax ; not for gs + pop rax + ; mov fs, rax ; not for fs + ; (X64 will not use fs and gs, so we do not restore it) + pop rax + mov es, rax + pop rax + mov ds, rax + pop qword ptr [rbp + 32] ; for cs + pop qword ptr [rbp + 56] ; for ss + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pop rdi + pop rsi + add rsp, 8 ; not for rbp + pop qword ptr [rbp + 48] ; for rsp + pop rbx + pop rdx + pop rcx + pop rax + pop r8 + pop r9 + pop r10 + pop r11 + pop r12 + pop r13 + pop r14 + pop r15 + + mov rsp, rbp + pop rbp + add rsp, 16 + cmp qword ptr [rsp - 32], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn + cmp qword ptr [rsp - 40], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + jz ErrorCode + jmp qword ptr [rsp - 32] +ErrorCode: + sub rsp, 8 + jmp qword ptr [rsp - 24] + +DoReturn: + cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET + jz DoIret + push rax + mov rax, rsp ; save old RSP to rax + mov rsp, [rsp + 20h] + push [rax + 10h] ; save CS in new location + push [rax + 8h] ; save EIP in new location + push [rax + 18h] ; save EFLAGS in new location + mov rax, [rax] ; restore rax + popfq ; restore EFLAGS + DB 48h ; prefix to composite "retq" with next "retf" + retf ; far return +DoIret: + iretq + +CommonInterruptEntry ENDP + +;------------------------------------------------------------------------------------- +; GetTemplateAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +; comments here for definition of address map +AsmGetTemplateAddressMap PROC + mov rax, offset AsmIdtVectorBegin + mov qword ptr [rcx], rax + mov qword ptr [rcx + 8h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 + mov rax, offset HookAfterStubHeaderBegin + mov qword ptr [rcx + 10h], rax + ret +AsmGetTemplateAddressMap ENDP + +;------------------------------------------------------------------------------------- +; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); +;------------------------------------------------------------------------------------- +AsmVectorNumFixup PROC + mov rax, rdx + mov [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al + ret +AsmVectorNumFixup ENDP + +END diff --git a/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm new file mode 100644 index 0000000000..ba8993d84b --- /dev/null +++ b/Core/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm @@ -0,0 +1,387 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ExceptionHandlerAsm.Asm +; +; Abstract: +; +; x64 CPU Exception Handler +; +; Notes: +; +;------------------------------------------------------------------------------ + +; +; CommonExceptionHandler() +; + +extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions +extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag +extern ASM_PFX(CommonExceptionHandler) + +SECTION .data + +DEFAULT REL +SECTION .text + +ALIGN 8 + +AsmIdtVectorBegin: +%rep 32 + db 0x6a ; push #VectorNum + db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum + push rax + mov rax, ASM_PFX(CommonInterruptEntry) + jmp rax +%endrep +AsmIdtVectorEnd: + +HookAfterStubHeaderBegin: + db 0x6a ; push +@VectorNum: + db 0 ; 0 will be fixed + push rax + mov rax, HookAfterStubHeaderEnd + jmp rax +HookAfterStubHeaderEnd: + mov rax, rsp + and sp, 0xfff0 ; make sure 16-byte aligned for exception context + sub rsp, 0x18 ; reserve room for filling exception data later + push rcx + mov rcx, [rax + 8] + bt [ASM_PFX(mErrorCodeFlag)], ecx + jnc .0 + push qword [rsp] ; push additional rcx to make stack alignment +.0: + xchg rcx, [rsp] ; restore rcx, save Exception Number in stack + push qword [rax] ; push rax into stack to keep code consistence + +;---------------------------------------; +; CommonInterruptEntry ; +;---------------------------------------; +; The follow algorithm is used for the common interrupt routine. +; Entry from each interrupt with a push eax and eax=interrupt number +; Stack frame would be as follows as specified in IA32 manuals: +; +; +---------------------+ <-- 16-byte aligned ensured by processor +; + Old SS + +; +---------------------+ +; + Old RSP + +; +---------------------+ +; + RFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + RIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + RBP + +; +---------------------+ <-- RBP, 16-byte aligned +; The follow algorithm is used for the common interrupt routine. +global ASM_PFX(CommonInterruptEntry) +ASM_PFX(CommonInterruptEntry): + cli + pop rax + ; + ; All interrupt handlers are invoked through interrupt gates, so + ; IF flag automatically cleared at the entry point + ; + xchg rcx, [rsp] ; Save rcx into stack and save vector number into rcx + and rcx, 0xFF + cmp ecx, 32 ; Intel reserved vector for exceptions? + jae NoErrorCode + bt [ASM_PFX(mErrorCodeFlag)], ecx + jc HasErrorCode + +NoErrorCode: + + ; + ; Push a dummy error code on the stack + ; to maintain coherent stack map + ; + push qword [rsp] + mov qword [rsp + 8], 0 +HasErrorCode: + push rbp + mov rbp, rsp + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + + ; + ; Stack: + ; +---------------------+ <-- 16-byte aligned ensured by processor + ; + Old SS + + ; +---------------------+ + ; + Old RSP + + ; +---------------------+ + ; + RFlags + + ; +---------------------+ + ; + CS + + ; +---------------------+ + ; + RIP + + ; +---------------------+ + ; + Error Code + + ; +---------------------+ + ; + RCX / Vector Number + + ; +---------------------+ + ; + RBP + + ; +---------------------+ <-- RBP, 16-byte aligned + ; + + ; + ; Since here the stack pointer is 16-byte aligned, so + ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + ; is 16-byte aligned + ; + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + push r15 + push r14 + push r13 + push r12 + push r11 + push r10 + push r9 + push r8 + push rax + push qword [rbp + 8] ; RCX + push rdx + push rbx + push qword [rbp + 48] ; RSP + push qword [rbp] ; RBP + push rsi + push rdi + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzx rax, word [rbp + 56] + push rax ; for ss + movzx rax, word [rbp + 32] + push rax ; for cs + mov rax, ds + push rax + mov rax, es + push rax + mov rax, fs + push rax + mov rax, gs + push rax + + mov [rbp + 8], rcx ; save vector number + +;; UINT64 Rip; + push qword [rbp + 24] + +;; UINT64 Gdtr[2], Idtr[2]; + xor rax, rax + push rax + push rax + sidt [rsp] + xchg rax, [rsp + 2] + xchg rax, [rsp] + xchg rax, [rsp + 8] + + xor rax, rax + push rax + push rax + sgdt [rsp] + xchg rax, [rsp + 2] + xchg rax, [rsp] + xchg rax, [rsp + 8] + +;; UINT64 Ldtr, Tr; + xor rax, rax + str ax + push rax + sldt ax + push rax + +;; UINT64 RFlags; + push qword [rbp + 40] + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + mov rax, cr8 + push rax + mov rax, cr4 + or rax, 0x208 + mov cr4, rax + push rax + mov rax, cr3 + push rax + mov rax, cr2 + push rax + xor rax, rax + push rax + mov rax, cr0 + push rax + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov rax, dr7 + push rax + mov rax, dr6 + push rax + mov rax, dr3 + push rax + mov rax, dr2 + push rax + mov rax, dr1 + push rax + mov rax, dr0 + push rax + +;; FX_SAVE_STATE_X64 FxSaveState; + sub rsp, 512 + mov rdi, rsp + db 0xf, 0xae, 0x7 ;fxsave [rdi] + +;; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push qword [rbp + 16] + +;; Prepare parameter and call + mov rcx, [rbp + 8] + mov rdx, rsp + ; + ; Per X64 calling convention, allocate maximum parameter stack space + ; and make sure RSP is 16-byte aligned + ; + sub rsp, 4 * 8 + 8 + mov rax, ASM_PFX(CommonExceptionHandler) + call rax + add rsp, 4 * 8 + 8 + + cli +;; UINT64 ExceptionData; + add rsp, 8 + +;; FX_SAVE_STATE_X64 FxSaveState; + + mov rsi, rsp + db 0xf, 0xae, 0xE ; fxrstor [rsi] + add rsp, 512 + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support in-circuit emualators +;; or debuggers set breakpoint in interrupt/exception context + add rsp, 8 * 6 + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + pop rax + mov cr0, rax + add rsp, 8 ; not for Cr1 + pop rax + mov cr2, rax + pop rax + mov cr3, rax + pop rax + mov cr4, rax + pop rax + mov cr8, rax + +;; UINT64 RFlags; + pop qword [rbp + 40] + +;; UINT64 Ldtr, Tr; +;; UINT64 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add rsp, 48 + +;; UINT64 Rip; + pop qword [rbp + 24] + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; + pop rax + ; mov gs, rax ; not for gs + pop rax + ; mov fs, rax ; not for fs + ; (X64 will not use fs and gs, so we do not restore it) + pop rax + mov es, rax + pop rax + mov ds, rax + pop qword [rbp + 32] ; for cs + pop qword [rbp + 56] ; for ss + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pop rdi + pop rsi + add rsp, 8 ; not for rbp + pop qword [rbp + 48] ; for rsp + pop rbx + pop rdx + pop rcx + pop rax + pop r8 + pop r9 + pop r10 + pop r11 + pop r12 + pop r13 + pop r14 + pop r15 + + mov rsp, rbp + pop rbp + add rsp, 16 + cmp qword [rsp - 32], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler + jz DoReturn + cmp qword [rsp - 40], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag + jz ErrorCode + jmp qword [rsp - 32] +ErrorCode: + sub rsp, 8 + jmp qword [rsp - 24] + +DoReturn: + cmp qword [ASM_PFX(mDoFarReturnFlag)], 0 ; Check if need to do far return instead of IRET + jz DoIret + push rax + mov rax, rsp ; save old RSP to rax + mov rsp, [rsp + 0x20] + push qword [rax + 0x10] ; save CS in new location + push qword [rax + 0x8] ; save EIP in new location + push qword [rax + 0x18] ; save EFLAGS in new location + mov rax, [rax] ; restore rax + popfq ; restore EFLAGS + DB 0x48 ; prefix to composite "retq" with next "retf" + retf ; far return +DoIret: + iretq + +;------------------------------------------------------------------------------------- +; GetTemplateAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +; comments here for definition of address map +global ASM_PFX(AsmGetTemplateAddressMap) +ASM_PFX(AsmGetTemplateAddressMap): + mov rax, AsmIdtVectorBegin + mov qword [rcx], rax + mov qword [rcx + 0x8], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 + mov rax, HookAfterStubHeaderBegin + mov qword [rcx + 0x10], rax + ret + +;------------------------------------------------------------------------------------- +; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmVectorNumFixup) +ASM_PFX(AsmVectorNumFixup): + mov rax, rdx + mov [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al + ret + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf new file mode 100644 index 0000000000..9751ba1f0d --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -0,0 +1,75 @@ +## @file +# MP Initialize Library instance for DXE driver. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxeMpInitLib + MODULE_UNI_FILE = DxeMpInitLib.uni + FILE_GUID = B88F7146-9834-4c55-BFAC-481CC0C33736 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.1 + LIBRARY_CLASS = MpInitLib|DXE_DRIVER + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.IA32] + Ia32/MpEqu.inc + Ia32/MpFuncs.nasm + +[Sources.X64] + X64/MpEqu.inc + X64/MpFuncs.nasm + +[Sources.common] + DxeMpLib.c + MpLib.c + MpLib.h + Microcode.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + LocalApicLib + MemoryAllocationLib + HobLib + MtrrLib + CpuLib + UefiCpuLib + UefiBootServicesTableLib + DebugAgentLib + +[Protocols] + gEfiTimerArchProtocolGuid ## SOMETIMES_CONSUMES + +[Guids] + gEfiEventExitBootServicesGuid ## CONSUMES ## Event + gEfiEventLegacyBootGuid ## CONSUMES ## Event + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOMETIMES_CONSUMES + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni new file mode 100644 index 0000000000..99d79974be --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni @@ -0,0 +1,22 @@ +// /** @file +// MP Initialize Library instance for DXE driver. +// +// MP Initialize Library instance for DXE driver. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "MP Initialize Library instance for DXE driver." + +#string STR_MODULE_DESCRIPTION #language en-US "MP Initialize Library instance for DXE driver." + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c new file mode 100644 index 0000000000..b393244e05 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -0,0 +1,743 @@ +/** @file + MP initialize support functions for DXE phase. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MpLib.h" + +#include +#include +#include + +#include + +#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) +#define AP_SAFE_STACK_SIZE 128 + +CPU_MP_DATA *mCpuMpData = NULL; +EFI_EVENT mCheckAllApsEvent = NULL; +EFI_EVENT mMpInitExitBootServicesEvent = NULL; +EFI_EVENT mLegacyBootEvent = NULL; +volatile BOOLEAN mStopCheckAllApsStatus = TRUE; +VOID *mReservedApLoopFunc = NULL; +UINTN mReservedTopOfApStack; +volatile UINT32 mNumberToFinish = 0; + +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ) +{ + // + // Initialize Debug Agent to support source level debug in DXE phase + // + InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_AP, NULL, NULL); +} + +/** + Get the pointer to CPU MP Data structure. + + @return The pointer to CPU MP Data structure. +**/ +CPU_MP_DATA * +GetCpuMpData ( + VOID + ) +{ + ASSERT (mCpuMpData != NULL); + return mCpuMpData; +} + +/** + Save the pointer to CPU MP Data structure. + + @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. +**/ +VOID +SaveCpuMpData ( + IN CPU_MP_DATA *CpuMpData + ) +{ + mCpuMpData = CpuMpData; +} + +/** + Allocate reset vector buffer. + + @param[in, out] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +AllocateResetVector ( + IN OUT CPU_MP_DATA *CpuMpData + ) +{ + EFI_STATUS Status; + UINTN ApResetVectorSize; + EFI_PHYSICAL_ADDRESS StartAddress; + + if (CpuMpData->SaveRestoreFlag) { + BackupAndPrepareWakeupBuffer (CpuMpData); + } else { + ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + + sizeof (MP_CPU_EXCHANGE_INFO); + + StartAddress = BASE_1MB; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (ApResetVectorSize), + &StartAddress + ); + ASSERT_EFI_ERROR (Status); + + CpuMpData->WakeupBuffer = (UINTN) StartAddress; + CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) + (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize); + // + // copy AP reset code in it + // + CopyMem ( + (VOID *) CpuMpData->WakeupBuffer, + (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress, + CpuMpData->AddressMap.RendezvousFunnelSize + ); + } +} + +/** + Free AP reset vector buffer. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +FreeResetVector ( + IN CPU_MP_DATA *CpuMpData + ) +{ + EFI_STATUS Status; + UINTN ApResetVectorSize; + + if (CpuMpData->SaveRestoreFlag) { + RestoreWakeupBuffer (CpuMpData); + } else { + ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + + sizeof (MP_CPU_EXCHANGE_INFO); + Status = gBS->FreePages( + (EFI_PHYSICAL_ADDRESS)CpuMpData->WakeupBuffer, + EFI_SIZE_TO_PAGES (ApResetVectorSize) + ); + ASSERT_EFI_ERROR (Status); + } +} + +/** + Checks APs status and updates APs status if needed. + +**/ +VOID +CheckAndUpdateApsStatus ( + VOID + ) +{ + UINTN ProcessorNumber; + EFI_STATUS Status; + CPU_MP_DATA *CpuMpData; + + CpuMpData = GetCpuMpData (); + + // + // First, check whether pending StartupAllAPs() exists. + // + if (CpuMpData->WaitEvent != NULL) { + + Status = CheckAllAPs (); + // + // If all APs finish for StartupAllAPs(), signal the WaitEvent for it. + // + if (Status != EFI_NOT_READY) { + Status = gBS->SignalEvent (CpuMpData->WaitEvent); + CpuMpData->WaitEvent = NULL; + } + } + + // + // Second, check whether pending StartupThisAPs() callings exist. + // + for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { + + if (CpuMpData->CpuData[ProcessorNumber].WaitEvent == NULL) { + continue; + } + + Status = CheckThisAP (ProcessorNumber); + + if (Status != EFI_NOT_READY) { + gBS->SignalEvent (CpuMpData->CpuData[ProcessorNumber].WaitEvent); + CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL; + } + } +} + +/** + Checks APs' status periodically. + + This function is triggered by timer periodically to check the + state of APs for StartupAllAPs() and StartupThisAP() executed + in non-blocking mode. + + @param[in] Event Event triggered. + @param[in] Context Parameter passed with the event. + +**/ +VOID +EFIAPI +CheckApsStatus ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // If CheckApsStatus() is not stopped, otherwise return immediately. + // + if (!mStopCheckAllApsStatus) { + CheckAndUpdateApsStatus (); + } +} + +/** + Get Protected mode code segment from current GDT table. + + @return Protected mode code segment value. +**/ +UINT16 +GetProtectedModeCS ( + VOID + ) +{ + IA32_DESCRIPTOR GdtrDesc; + IA32_SEGMENT_DESCRIPTOR *GdtEntry; + UINTN GdtEntryCount; + UINT16 Index; + + Index = (UINT16) -1; + AsmReadGdtr (&GdtrDesc); + GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR); + GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base; + for (Index = 0; Index < GdtEntryCount; Index++) { + if (GdtEntry->Bits.L == 0) { + if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.L == 0) { + break; + } + } + GdtEntry++; + } + ASSERT (Index != -1); + return Index * 8; +} + +/** + Do sync on APs. + + @param[in, out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +RelocateApLoop ( + IN OUT VOID *Buffer + ) +{ + CPU_MP_DATA *CpuMpData; + BOOLEAN MwaitSupport; + ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; + UINTN ProcessorNumber; + + MpInitLibWhoAmI (&ProcessorNumber); + CpuMpData = GetCpuMpData (); + MwaitSupport = IsMwaitSupport (); + AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP) (UINTN) mReservedApLoopFunc; + AsmRelocateApLoopFunc ( + MwaitSupport, + CpuMpData->ApTargetCState, + CpuMpData->PmCodeSegment, + mReservedTopOfApStack - ProcessorNumber * AP_SAFE_STACK_SIZE, + (UINTN) &mNumberToFinish + ); + // + // It should never reach here + // + ASSERT (FALSE); +} + +/** + Callback function for ExitBootServices. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context The pointer to the notification function's context, + which is implementation-dependent. + +**/ +VOID +EFIAPI +MpInitChangeApLoopCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData = GetCpuMpData (); + CpuMpData->SaveRestoreFlag = TRUE; + CpuMpData->PmCodeSegment = GetProtectedModeCS (); + CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode); + mNumberToFinish = CpuMpData->CpuCount - 1; + WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL); + while (mNumberToFinish > 0) { + CpuPause (); + } + DEBUG ((DEBUG_INFO, "%a() done!\n", __FUNCTION__)); +} + +/** + Initialize global data for MP support. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +InitMpGlobalData ( + IN CPU_MP_DATA *CpuMpData + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Address; + UINTN ApSafeBufferSize; + + SaveCpuMpData (CpuMpData); + + if (CpuMpData->CpuCount == 1) { + // + // If only BSP exists, return + // + return; + } + + // + // Avoid APs access invalid buffer data which allocated by BootServices, + // so we will allocate reserved data for AP loop code. We also need to + // allocate this buffer below 4GB due to APs may be transferred to 32bit + // protected mode on long mode DXE. + // Allocating it in advance since memory services are not available in + // Exit Boot Services callback function. + // + ApSafeBufferSize = CpuMpData->AddressMap.RelocateApLoopFuncSize; + ApSafeBufferSize += CpuMpData->CpuCount * AP_SAFE_STACK_SIZE; + + Address = BASE_4GB - 1; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (ApSafeBufferSize), + &Address + ); + ASSERT_EFI_ERROR (Status); + mReservedApLoopFunc = (VOID *) (UINTN) Address; + ASSERT (mReservedApLoopFunc != NULL); + mReservedTopOfApStack = (UINTN) Address + EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (ApSafeBufferSize)); + ASSERT ((mReservedTopOfApStack & (UINTN)(CPU_STACK_ALIGNMENT - 1)) == 0); + CopyMem ( + mReservedApLoopFunc, + CpuMpData->AddressMap.RelocateApLoopFuncAddress, + CpuMpData->AddressMap.RelocateApLoopFuncSize + ); + + Status = gBS->CreateEvent ( + EVT_TIMER | EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + CheckApsStatus, + NULL, + &mCheckAllApsEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Set timer to check all APs status. + // + Status = gBS->SetTimer ( + mCheckAllApsEvent, + TimerPeriodic, + AP_CHECK_INTERVAL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + MpInitChangeApLoopCallback, + NULL, + &mMpInitExitBootServicesEvent + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + MpInitChangeApLoopCallback, + NULL, + &gEfiEventLegacyBootGuid, + &mLegacyBootEvent + ); + ASSERT_EFI_ERROR (Status); +} + +/** + This service executes a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure, or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by MpInitLibStartupAllAPs() or + MPInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, + if all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + The buffer is allocated by MP Initialization + library, and it's the caller's responsibility to + free the buffer with FreePool() service. + In blocking mode, it is ready for consumption + when the call returns. In non-blocking mode, + it is ready when WaitEvent is signaled. The + list of failed CPU is terminated by + END_OF_CPU_LIST. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllAPs ( + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ) +{ + EFI_STATUS Status; + + // + // Temporarily stop checkAllApsStatus for avoid resource dead-lock. + // + mStopCheckAllApsStatus = TRUE; + + Status = StartupAllAPsWorker ( + Procedure, + SingleThread, + WaitEvent, + TimeoutInMicroseconds, + ProcedureArgument, + FailedCpuList + ); + + // + // Start checkAllApsStatus + // + mStopCheckAllApsStatus = FALSE; + + return Status; +} + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. + + @param[in] Procedure A pointer to the function to be run on the + designated AP of the system. See type + EFI_AP_PROCEDURE. + @param[in] ProcessorNumber The handle number of the AP. The range is + from 0 to the total number of logical + processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until this AP finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on this AP, + and go on executing immediately. If this AP + return from Procedure or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + this AP to finish this Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + this AP returns from Procedure, then Procedure + on the AP is terminated. The + AP is available for next function assigned + by MpInitLibStartupAllAPs() or + MpInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure on the + specified AP. + @param[out] Finished If NULL, this parameter is ignored. In + blocking mode, this parameter is ignored. + In non-blocking mode, if AP returns from + Procedure before the timeout expires, its + content is set to TRUE. Otherwise, the + value is set to FALSE. The caller can + determine if the AP returned from Procedure + by evaluating this value. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval EFI_SUCCESS In non-blocking mode, the function has been + dispatched to specified AP. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + the specified AP has finished. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupThisAP ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ) +{ + EFI_STATUS Status; + + // + // temporarily stop checkAllApsStatus for avoid resource dead-lock. + // + mStopCheckAllApsStatus = TRUE; + + Status = StartupThisAPWorker ( + Procedure, + ProcessorNumber, + WaitEvent, + TimeoutInMicroseconds, + ProcedureArgument, + Finished + ); + + mStopCheckAllApsStatus = FALSE; + + return Status; +} + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibSwitchBSP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + EFI_STATUS Status; + EFI_TIMER_ARCH_PROTOCOL *Timer; + UINT64 TimerPeriod; + + TimerPeriod = 0; + // + // Locate Timer Arch Protocol + // + Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Timer); + if (EFI_ERROR (Status)) { + Timer = NULL; + } + + if (Timer != NULL) { + // + // Save current rate of DXE Timer + // + Timer->GetTimerPeriod (Timer, &TimerPeriod); + // + // Disable DXE Timer and drain pending interrupts + // + Timer->SetTimerPeriod (Timer, 0); + } + + Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP); + + if (Timer != NULL) { + // + // Enable and restore rate of DXE Timer + // + Timer->SetTimerPeriod (Timer, TimerPeriod); + } + + return Status; +} + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. This flag + corresponds to StatusFlag defined in + EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only + the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter + is ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed + prior to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibEnableDisableAP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + EFI_STATUS Status; + BOOLEAN TempStopCheckState; + + TempStopCheckState = FALSE; + // + // temporarily stop checkAllAPsStatus for initialize parameters. + // + if (!mStopCheckAllApsStatus) { + mStopCheckAllApsStatus = TRUE; + TempStopCheckState = TRUE; + } + + Status = EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); + + if (TempStopCheckState) { + mStopCheckAllApsStatus = FALSE; + } + + return Status; +} diff --git a/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc b/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc new file mode 100644 index 0000000000..62762308e2 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc @@ -0,0 +1,43 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpEqu.inc +; +; Abstract: +; +; This is the equates file for Multiple Processor support +; +;------------------------------------------------------------------------------- + +VacantFlag equ 00h +NotVacantFlag equ 0ffh + +CPU_SWITCH_STATE_IDLE equ 0 +CPU_SWITCH_STATE_STORED equ 1 +CPU_SWITCH_STATE_LOADED equ 2 + +LockLocation equ (RendezvousFunnelProcEnd - RendezvousFunnelProcStart) +StackStartAddressLocation equ LockLocation + 04h +StackSizeLocation equ LockLocation + 08h +ApProcedureLocation equ LockLocation + 0Ch +GdtrLocation equ LockLocation + 10h +IdtrLocation equ LockLocation + 16h +BufferStartLocation equ LockLocation + 1Ch +ModeOffsetLocation equ LockLocation + 20h +NumApsExecutingLocation equ LockLocation + 24h +CodeSegmentLocation equ LockLocation + 28h +DataSegmentLocation equ LockLocation + 2Ch +EnableExecuteDisableLocation equ LockLocation + 30h +Cr3Location equ LockLocation + 34h +InitFlagLocation equ LockLocation + 38h +CpuInfoLocation equ LockLocation + 3Ch + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm b/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm new file mode 100644 index 0000000000..52363e6e08 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm @@ -0,0 +1,339 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.nasm +; +; Abstract: +; +; This is the assembly code for MP support +; +;------------------------------------------------------------------------------- + +%include "MpEqu.inc" +extern ASM_PFX(InitializeFloatingPointUnits) + +SECTION .text + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +global ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: +; At this point CS = 0x(vv00) and ip= 0x0. +BITS 16 + mov ebp, eax ; save BIST information + + mov ax, cs + mov ds, ax + mov es, ax + mov ss, ax + xor ax, ax + mov fs, ax + mov gs, ax + + mov si, BufferStartLocation + mov ebx, [si] + + mov si, ModeOffsetLocation + mov eax, [si] + mov si, CodeSegmentLocation + mov edx, [si] + mov di, ax + sub di, 02h + mov [di], dx + sub di, 04h + add eax, ebx + mov [di],eax + + mov si, DataSegmentLocation + mov edx, [si] + + mov si, GdtrLocation +o32 lgdt [cs:si] + + mov si, IdtrLocation +o32 lidt [cs:si] + + xor ax, ax + mov ds, ax + + mov eax, cr0 ; Get control register 0 + or eax, 000000003h ; Set PE bit (bit #0) & MP + mov cr0, eax + + jmp 0:strict dword 0 ; far jump to protected mode +BITS 32 +Flat32Start: ; protected mode entry point + mov ds, dx + mov es, dx + mov fs, dx + mov gs, dx + mov ss, dx + + mov esi, ebx + + mov edi, esi + add edi, EnableExecuteDisableLocation + cmp byte [edi], 0 + jz SkipEnableExecuteDisable + + ; + ; Enable IA32 PAE execute disable + ; + + mov ecx, 0xc0000080 + rdmsr + bts eax, 11 + wrmsr + + mov edi, esi + add edi, Cr3Location + mov eax, dword [edi] + mov cr3, eax + + mov eax, cr4 + bts eax, 5 + mov cr4, eax + + mov eax, cr0 + bts eax, 31 + mov cr0, eax + +SkipEnableExecuteDisable: + mov edi, esi + add edi, InitFlagLocation + cmp dword [edi], 1 ; 1 == ApInitConfig + jnz GetApicId + + ; AP init + mov edi, esi + add edi, LockLocation + mov eax, NotVacantFlag + +TestLock: + xchg [edi], eax + cmp eax, NotVacantFlag + jz TestLock + + mov ecx, esi + add ecx, NumApsExecutingLocation + inc dword [ecx] + mov ebx, [ecx] + +Releaselock: + mov eax, VacantFlag + xchg [edi], eax + + mov edi, esi + add edi, StackSizeLocation + mov eax, [edi] + mov ecx, ebx + inc ecx + mul ecx ; EAX = StackSize * (CpuNumber + 1) + mov edi, esi + add edi, StackStartAddressLocation + add eax, [edi] + mov esp, eax + jmp CProcedureInvoke + +GetApicId: + mov eax, 0 + cpuid + cmp eax, 0bh + jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY + + mov eax, 0bh + xor ecx, ecx + cpuid + test ebx, 0ffffh + jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero + + ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX + jmp GetProcessorNumber + +NoX2Apic: + ; Processor is not x2APIC capable, so get 8-bit APIC ID + mov eax, 1 + cpuid + shr ebx, 24 + mov edx, ebx + +GetProcessorNumber: + ; + ; Get processor number for this AP + ; Note that BSP may become an AP due to SwitchBsp() + ; + xor ebx, ebx + lea eax, [esi + CpuInfoLocation] + mov edi, [eax] + +GetNextProcNumber: + cmp [edi], edx ; APIC ID match? + jz ProgramStack + add edi, 20 + inc ebx + jmp GetNextProcNumber + +ProgramStack: + mov esp, [edi + 12] + +CProcedureInvoke: + push ebp ; push BIST data at top of AP stack + xor ebp, ebp ; clear ebp for call stack trace + push ebp + mov ebp, esp + + mov eax, ASM_PFX(InitializeFloatingPointUnits) + call eax ; Call assembly function to initialize FPU per UEFI spec + + push ebx ; Push NumApsExecuting + mov eax, esi + add eax, LockLocation + push eax ; push address of exchange info data buffer + + mov edi, esi + add edi, ApProcedureLocation + mov eax, [edi] + + call eax ; Invoke C function + + jmp $ ; Never reach here +RendezvousFunnelProcEnd: + +;------------------------------------------------------------------------------------- +; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmRelocateApLoop) +ASM_PFX(AsmRelocateApLoop): +AsmRelocateApLoopStart: + mov eax, esp + mov esp, [eax + 16] ; TopOfApStack + push dword [eax] ; push return address for stack trace + push ebp + mov ebp, esp + mov ebx, [eax + 8] ; ApTargetCState + mov ecx, [eax + 4] ; MwaitSupport + mov eax, [eax + 20] ; CountTofinish + lock dec dword [eax] ; (*CountTofinish)-- + cmp cl, 1 ; Check mwait-monitor support + jnz HltLoop +MwaitLoop: + mov eax, esp + xor ecx, ecx + xor edx, edx + monitor + mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4] + shl eax, 4 + mwait + jmp MwaitLoop +HltLoop: + cli + hlt + jmp HltLoop +AsmRelocateApLoopEnd: + +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + pushad + mov ebp,esp + + mov ebx, [ebp + 24h] + mov dword [ebx], RendezvousFunnelProcStart + mov dword [ebx + 4h], Flat32Start - RendezvousFunnelProcStart + mov dword [ebx + 8h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + mov dword [ebx + 0Ch], AsmRelocateApLoopStart + mov dword [ebx + 10h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart + + popad + ret + +;------------------------------------------------------------------------------------- +;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is +;about to become an AP. It switches it'stack with the current AP. +;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmExchangeRole) +ASM_PFX(AsmExchangeRole): + ; DO NOT call other functions in this function, since 2 CPU may use 1 stack + ; at the same time. If 1 CPU try to call a function, stack will be corrupted. + pushad + mov ebp,esp + + ; esi contains MyInfo pointer + mov esi, [ebp + 24h] + + ; edi contains OthersInfo pointer + mov edi, [ebp + 28h] + + ;Store EFLAGS, GDTR and IDTR register to stack + pushfd + mov eax, cr4 + push eax ; push cr4 firstly + mov eax, cr0 + push eax + + sgdt [esi + 8] + sidt [esi + 14] + + ; Store the its StackPointer + mov [esi + 4],esp + + ; update its switch state to STORED + mov byte [esi], CPU_SWITCH_STATE_STORED + +WaitForOtherStored: + ; wait until the other CPU finish storing its state + cmp byte [edi], CPU_SWITCH_STATE_STORED + jz OtherStored + pause + jmp WaitForOtherStored + +OtherStored: + ; Since another CPU already stored its state, load them + ; load GDTR value + lgdt [edi + 8] + + ; load IDTR value + lidt [edi + 14] + + ; load its future StackPointer + mov esp, [edi + 4] + + ; update the other CPU's switch state to LOADED + mov byte [edi], CPU_SWITCH_STATE_LOADED + +WaitForOtherLoaded: + ; wait until the other CPU finish loading new state, + ; otherwise the data in stack may corrupt + cmp byte [esi], CPU_SWITCH_STATE_LOADED + jz OtherLoaded + pause + jmp WaitForOtherLoaded + +OtherLoaded: + ; since the other CPU already get the data it want, leave this procedure + pop eax + mov cr0, eax + pop eax + mov cr4, eax + popfd + + popad + ret diff --git a/Core/UefiCpuPkg/Library/MpInitLib/Microcode.c b/Core/UefiCpuPkg/Library/MpInitLib/Microcode.c new file mode 100644 index 0000000000..982995be7d --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -0,0 +1,218 @@ +/** @file + Implementation of loading microcode on processors. + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MpLib.h" + +/** + Get microcode update signature of currently loaded microcode update. + + @return Microcode signature. +**/ +UINT32 +GetCurrentMicrocodeSignature ( + VOID + ) +{ + MSR_IA32_BIOS_SIGN_ID_REGISTER BiosSignIdMsr; + + AsmWriteMsr64 (MSR_IA32_BIOS_SIGN_ID, 0); + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, NULL); + BiosSignIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_BIOS_SIGN_ID); + return BiosSignIdMsr.Bits.MicrocodeUpdateSignature; +} + +/** + Detect whether specified processor can find matching microcode patch and load it. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +MicrocodeDetect ( + IN CPU_MP_DATA *CpuMpData + ) +{ + UINT64 MicrocodePatchAddress; + UINT64 MicrocodePatchRegionSize; + UINT32 ExtendedTableLength; + UINT32 ExtendedTableCount; + CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; + CPU_MICROCODE_EXTENDED_TABLE_HEADER *ExtendedTableHeader; + CPU_MICROCODE_HEADER *MicrocodeEntryPoint; + UINTN MicrocodeEnd; + UINTN Index; + UINT8 PlatformId; + CPUID_VERSION_INFO_EAX Eax; + UINT32 CurrentRevision; + UINT32 LatestRevision; + UINTN TotalSize; + UINT32 CheckSum32; + BOOLEAN CorrectMicrocode; + VOID *MicrocodeData; + MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; + + MicrocodePatchAddress = PcdGet64 (PcdCpuMicrocodePatchAddress); + MicrocodePatchRegionSize = PcdGet64 (PcdCpuMicrocodePatchRegionSize); + if (MicrocodePatchRegionSize == 0) { + // + // There is no microcode patches + // + return; + } + + CurrentRevision = GetCurrentMicrocodeSignature (); + if (CurrentRevision != 0) { + // + // Skip loading microcode if it has been loaded successfully + // + return; + } + + ExtendedTableLength = 0; + // + // Here data of CPUID leafs have not been collected into context buffer, so + // GetProcessorCpuid() cannot be used here to retrieve sCPUID data. + // + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL); + + // + // The index of platform information resides in bits 50:52 of MSR IA32_PLATFORM_ID + // + PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); + PlatformId = (UINT8) PlatformIdMsr.Bits.PlatformId; + + LatestRevision = 0; + MicrocodeData = NULL; + MicrocodeEnd = (UINTN) (MicrocodePatchAddress + MicrocodePatchRegionSize); + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) MicrocodePatchAddress; + do { + // + // Check if the microcode is for the Cpu and the version is newer + // and the update can be processed on the platform + // + CorrectMicrocode = FALSE; + if (MicrocodeEntryPoint->HeaderVersion == 0x1) { + // + // It is the microcode header. It is not the padding data between microcode patches + // because the padding data should not include 0x00000001 and it should be the repeated + // byte format (like 0xXYXYXYXY....). + // + if (MicrocodeEntryPoint->ProcessorSignature.Uint32 == Eax.Uint32 && + MicrocodeEntryPoint->UpdateRevision > LatestRevision && + (MicrocodeEntryPoint->ProcessorFlags & (1 << PlatformId)) + ) { + if (MicrocodeEntryPoint->DataSize == 0) { + CheckSum32 = CalculateSum32 ((UINT32 *) MicrocodeEntryPoint, 2048); + } else { + CheckSum32 = CalculateSum32 ( + (UINT32 *) MicrocodeEntryPoint, + MicrocodeEntryPoint->DataSize + sizeof (CPU_MICROCODE_HEADER) + ); + } + if (CheckSum32 == 0) { + CorrectMicrocode = TRUE; + } + } else if ((MicrocodeEntryPoint->DataSize != 0) && + (MicrocodeEntryPoint->UpdateRevision > LatestRevision)) { + ExtendedTableLength = MicrocodeEntryPoint->TotalSize - (MicrocodeEntryPoint->DataSize + + sizeof (CPU_MICROCODE_HEADER)); + if (ExtendedTableLength != 0) { + // + // Extended Table exist, check if the CPU in support list + // + ExtendedTableHeader = (CPU_MICROCODE_EXTENDED_TABLE_HEADER *) ((UINT8 *) (MicrocodeEntryPoint) + + MicrocodeEntryPoint->DataSize + sizeof (CPU_MICROCODE_HEADER)); + // + // Calculate Extended Checksum + // + if ((ExtendedTableLength % 4) == 0) { + CheckSum32 = CalculateSum32 ((UINT32 *) ExtendedTableHeader, ExtendedTableLength); + if (CheckSum32 == 0) { + // + // Checksum correct + // + ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; + ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *) (ExtendedTableHeader + 1); + for (Index = 0; Index < ExtendedTableCount; Index ++) { + CheckSum32 = CalculateSum32 ((UINT32 *) ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); + if (CheckSum32 == 0) { + // + // Verify Header + // + if ((ExtendedTable->ProcessorSignature.Uint32 == Eax.Uint32) && + (ExtendedTable->ProcessorFlag & (1 << PlatformId)) ) { + // + // Find one + // + CorrectMicrocode = TRUE; + break; + } + } + ExtendedTable ++; + } + } + } + } + } + } else { + // + // It is the padding data between the microcode patches for microcode patches alignment. + // Because the microcode patch is the multiple of 1-KByte, the padding data should not + // exist if the microcode patch alignment value is not larger than 1-KByte. So, the microcode + // alignment value should be larger than 1-KByte. We could skip SIZE_1KB padding data to + // find the next possible microcode patch header. + // + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + SIZE_1KB); + continue; + } + // + // Get the next patch. + // + if (MicrocodeEntryPoint->DataSize == 0) { + TotalSize = 2048; + } else { + TotalSize = MicrocodeEntryPoint->TotalSize; + } + + if (CorrectMicrocode) { + LatestRevision = MicrocodeEntryPoint->UpdateRevision; + MicrocodeData = (VOID *) ((UINTN) MicrocodeEntryPoint + sizeof (CPU_MICROCODE_HEADER)); + } + + MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + TotalSize); + } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd)); + + if (LatestRevision > CurrentRevision) { + // + // BIOS only authenticate updates that contain a numerically larger revision + // than the currently loaded revision, where Current Signature < New Update + // Revision. A processor with no loaded update is considered to have a + // revision equal to zero. + // + ASSERT (MicrocodeData != NULL); + AsmWriteMsr64 ( + MSR_IA32_BIOS_UPDT_TRIG, + (UINT64) (UINTN) MicrocodeData + ); + // + // Get and check new microcode signature + // + CurrentRevision = GetCurrentMicrocodeSignature (); + if (CurrentRevision != LatestRevision) { + AcquireSpinLock(&CpuMpData->MpLock); + DEBUG ((EFI_D_ERROR, "Updated microcode signature [0x%08x] does not match \ + loaded microcode signature [0x%08x]\n", CurrentRevision, LatestRevision)); + ReleaseSpinLock(&CpuMpData->MpLock); + } + } +} diff --git a/Core/UefiCpuPkg/Library/MpInitLib/MpLib.c b/Core/UefiCpuPkg/Library/MpInitLib/MpLib.c new file mode 100644 index 0000000000..03d6c2d89e --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -0,0 +1,2126 @@ +/** @file + CPU MP Initialize Library common functions. + + Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MpLib.h" + +EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID; + +/** + The function will check if BSP Execute Disable is enabled. + + DxeIpl may have enabled Execute Disable for BSP, APs need to + get the status and sync up the settings. + If BSP's CR0.Paging is not set, BSP execute Disble feature is + not working actually. + + @retval TRUE BSP Execute Disable is enabled. + @retval FALSE BSP Execute Disable is not enabled. +**/ +BOOLEAN +IsBspExecuteDisableEnabled ( + VOID + ) +{ + UINT32 Eax; + CPUID_EXTENDED_CPU_SIG_EDX Edx; + MSR_IA32_EFER_REGISTER EferMsr; + BOOLEAN Enabled; + IA32_CR0 Cr0; + + Enabled = FALSE; + Cr0.UintN = AsmReadCr0 (); + if (Cr0.Bits.PG != 0) { + // + // If CR0 Paging bit is set + // + AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); + if (Eax >= CPUID_EXTENDED_CPU_SIG) { + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); + // + // CPUID 0x80000001 + // Bit 20: Execute Disable Bit available. + // + if (Edx.Bits.NX != 0) { + EferMsr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER); + // + // MSR 0xC0000080 + // Bit 11: Execute Disable Bit enable. + // + if (EferMsr.Bits.NXE != 0) { + Enabled = TRUE; + } + } + } + } + + return Enabled; +} + +/** + Worker function for SwitchBSP(). + + Worker function for SwitchBSP(), assigned to the AP which is intended + to become BSP. + + @param[in] Buffer Pointer to CPU MP Data +**/ +VOID +EFIAPI +FutureBSPProc ( + IN VOID *Buffer + ) +{ + CPU_MP_DATA *DataInHob; + + DataInHob = (CPU_MP_DATA *) Buffer; + AsmExchangeRole (&DataInHob->APInfo, &DataInHob->BSPInfo); +} + +/** + Get the Application Processors state. + + @param[in] CpuData The pointer to CPU_AP_DATA of specified AP + + @return The AP status +**/ +CPU_STATE +GetApState ( + IN CPU_AP_DATA *CpuData + ) +{ + return CpuData->State; +} + +/** + Set the Application Processors state. + + @param[in] CpuData The pointer to CPU_AP_DATA of specified AP + @param[in] State The AP status +**/ +VOID +SetApState ( + IN CPU_AP_DATA *CpuData, + IN CPU_STATE State + ) +{ + AcquireSpinLock (&CpuData->ApLock); + CpuData->State = State; + ReleaseSpinLock (&CpuData->ApLock); +} + +/** + Save BSP's local APIC timer setting. + + @param[in] CpuMpData Pointer to CPU MP Data +**/ +VOID +SaveLocalApicTimerSetting ( + IN CPU_MP_DATA *CpuMpData + ) +{ + // + // Record the current local APIC timer setting of BSP + // + GetApicTimerState ( + &CpuMpData->DivideValue, + &CpuMpData->PeriodicMode, + &CpuMpData->Vector + ); + CpuMpData->CurrentTimerCount = GetApicTimerCurrentCount (); + CpuMpData->TimerInterruptState = GetApicTimerInterruptState (); +} + +/** + Sync local APIC timer setting from BSP to AP. + + @param[in] CpuMpData Pointer to CPU MP Data +**/ +VOID +SyncLocalApicTimerSetting ( + IN CPU_MP_DATA *CpuMpData + ) +{ + // + // Sync local APIC timer setting from BSP to AP + // + InitializeApicTimer ( + CpuMpData->DivideValue, + CpuMpData->CurrentTimerCount, + CpuMpData->PeriodicMode, + CpuMpData->Vector + ); + // + // Disable AP's local APIC timer interrupt + // + DisableApicTimerInterrupt (); +} + +/** + Save the volatile registers required to be restored following INIT IPI. + + @param[out] VolatileRegisters Returns buffer saved the volatile resisters +**/ +VOID +SaveVolatileRegisters ( + OUT CPU_VOLATILE_REGISTERS *VolatileRegisters + ) +{ + CPUID_VERSION_INFO_EDX VersionInfoEdx; + + VolatileRegisters->Cr0 = AsmReadCr0 (); + VolatileRegisters->Cr3 = AsmReadCr3 (); + VolatileRegisters->Cr4 = AsmReadCr4 (); + + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); + if (VersionInfoEdx.Bits.DE != 0) { + // + // If processor supports Debugging Extensions feature + // by CPUID.[EAX=01H]:EDX.BIT2 + // + VolatileRegisters->Dr0 = AsmReadDr0 (); + VolatileRegisters->Dr1 = AsmReadDr1 (); + VolatileRegisters->Dr2 = AsmReadDr2 (); + VolatileRegisters->Dr3 = AsmReadDr3 (); + VolatileRegisters->Dr6 = AsmReadDr6 (); + VolatileRegisters->Dr7 = AsmReadDr7 (); + } +} + +/** + Restore the volatile registers following INIT IPI. + + @param[in] VolatileRegisters Pointer to volatile resisters + @param[in] IsRestoreDr TRUE: Restore DRx if supported + FALSE: Do not restore DRx +**/ +VOID +RestoreVolatileRegisters ( + IN CPU_VOLATILE_REGISTERS *VolatileRegisters, + IN BOOLEAN IsRestoreDr + ) +{ + CPUID_VERSION_INFO_EDX VersionInfoEdx; + + AsmWriteCr0 (VolatileRegisters->Cr0); + AsmWriteCr3 (VolatileRegisters->Cr3); + AsmWriteCr4 (VolatileRegisters->Cr4); + + if (IsRestoreDr) { + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); + if (VersionInfoEdx.Bits.DE != 0) { + // + // If processor supports Debugging Extensions feature + // by CPUID.[EAX=01H]:EDX.BIT2 + // + AsmWriteDr0 (VolatileRegisters->Dr0); + AsmWriteDr1 (VolatileRegisters->Dr1); + AsmWriteDr2 (VolatileRegisters->Dr2); + AsmWriteDr3 (VolatileRegisters->Dr3); + AsmWriteDr6 (VolatileRegisters->Dr6); + AsmWriteDr7 (VolatileRegisters->Dr7); + } + } +} + +/** + Detect whether Mwait-monitor feature is supported. + + @retval TRUE Mwait-monitor feature is supported. + @retval FALSE Mwait-monitor feature is not supported. +**/ +BOOLEAN +IsMwaitSupport ( + VOID + ) +{ + CPUID_VERSION_INFO_ECX VersionInfoEcx; + + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &VersionInfoEcx.Uint32, NULL); + return (VersionInfoEcx.Bits.MONITOR == 1) ? TRUE : FALSE; +} + +/** + Get AP loop mode. + + @param[out] MonitorFilterSize Returns the largest monitor-line size in bytes. + + @return The AP loop mode. +**/ +UINT8 +GetApLoopMode ( + OUT UINT32 *MonitorFilterSize + ) +{ + UINT8 ApLoopMode; + CPUID_MONITOR_MWAIT_EBX MonitorMwaitEbx; + + ASSERT (MonitorFilterSize != NULL); + + ApLoopMode = PcdGet8 (PcdCpuApLoopMode); + ASSERT (ApLoopMode >= ApInHltLoop && ApLoopMode <= ApInRunLoop); + if (ApLoopMode == ApInMwaitLoop) { + if (!IsMwaitSupport ()) { + // + // If processor does not support MONITOR/MWAIT feature, + // force AP in Hlt-loop mode + // + ApLoopMode = ApInHltLoop; + } + } + + if (ApLoopMode != ApInMwaitLoop) { + *MonitorFilterSize = sizeof (UINT32); + } else { + // + // CPUID.[EAX=05H]:EBX.BIT0-15: Largest monitor-line size in bytes + // CPUID.[EAX=05H].EDX: C-states supported using MWAIT + // + AsmCpuid (CPUID_MONITOR_MWAIT, NULL, &MonitorMwaitEbx.Uint32, NULL, NULL); + *MonitorFilterSize = MonitorMwaitEbx.Bits.LargestMonitorLineSize; + } + + return ApLoopMode; +} + +/** + Sort the APIC ID of all processors. + + This function sorts the APIC ID of all processors so that processor number is + assigned in the ascending order of APIC ID which eases MP debugging. + + @param[in] CpuMpData Pointer to PEI CPU MP Data +**/ +VOID +SortApicId ( + IN CPU_MP_DATA *CpuMpData + ) +{ + UINTN Index1; + UINTN Index2; + UINTN Index3; + UINT32 ApicId; + CPU_INFO_IN_HOB CpuInfo; + UINT32 ApCount; + CPU_INFO_IN_HOB *CpuInfoInHob; + + ApCount = CpuMpData->CpuCount - 1; + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + if (ApCount != 0) { + for (Index1 = 0; Index1 < ApCount; Index1++) { + Index3 = Index1; + // + // Sort key is the hardware default APIC ID + // + ApicId = CpuInfoInHob[Index1].ApicId; + for (Index2 = Index1 + 1; Index2 <= ApCount; Index2++) { + if (ApicId > CpuInfoInHob[Index2].ApicId) { + Index3 = Index2; + ApicId = CpuInfoInHob[Index2].ApicId; + } + } + if (Index3 != Index1) { + CopyMem (&CpuInfo, &CpuInfoInHob[Index3], sizeof (CPU_INFO_IN_HOB)); + CopyMem ( + &CpuInfoInHob[Index3], + &CpuInfoInHob[Index1], + sizeof (CPU_INFO_IN_HOB) + ); + CopyMem (&CpuInfoInHob[Index1], &CpuInfo, sizeof (CPU_INFO_IN_HOB)); + } + } + + // + // Get the processor number for the BSP + // + ApicId = GetInitialApicId (); + for (Index1 = 0; Index1 < CpuMpData->CpuCount; Index1++) { + if (CpuInfoInHob[Index1].ApicId == ApicId) { + CpuMpData->BspNumber = (UINT32) Index1; + break; + } + } + } +} + +/** + Enable x2APIC mode on APs. + + @param[in, out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +ApFuncEnableX2Apic ( + IN OUT VOID *Buffer + ) +{ + SetApicMode (LOCAL_APIC_MODE_X2APIC); +} + +/** + Do sync on APs. + + @param[in, out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +ApInitializeSync ( + IN OUT VOID *Buffer + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData = (CPU_MP_DATA *) Buffer; + // + // Load microcode on AP + // + MicrocodeDetect (CpuMpData); + // + // Sync BSP's MTRR table to AP + // + MtrrSetAllMtrrs (&CpuMpData->MtrrTable); +} + +/** + Find the current Processor number by APIC ID. + + @param[in] CpuMpData Pointer to PEI CPU MP Data + @param[out] ProcessorNumber Return the pocessor number found + + @retval EFI_SUCCESS ProcessorNumber is found and returned. + @retval EFI_NOT_FOUND ProcessorNumber is not found. +**/ +EFI_STATUS +GetProcessorNumber ( + IN CPU_MP_DATA *CpuMpData, + OUT UINTN *ProcessorNumber + ) +{ + UINTN TotalProcessorNumber; + UINTN Index; + CPU_INFO_IN_HOB *CpuInfoInHob; + + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + + TotalProcessorNumber = CpuMpData->CpuCount; + for (Index = 0; Index < TotalProcessorNumber; Index ++) { + if (CpuInfoInHob[Index].ApicId == GetApicId ()) { + *ProcessorNumber = Index; + return EFI_SUCCESS; + } + } + return EFI_NOT_FOUND; +} + +/** + This function will get CPU count in the system. + + @param[in] CpuMpData Pointer to PEI CPU MP Data + + @return CPU count detected +**/ +UINTN +CollectProcessorCount ( + IN CPU_MP_DATA *CpuMpData + ) +{ + // + // Send 1st broadcast IPI to APs to wakeup APs + // + CpuMpData->InitFlag = ApInitConfig; + CpuMpData->X2ApicEnable = FALSE; + WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL); + CpuMpData->InitFlag = ApInitDone; + ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); + // + // Wait for all APs finished the initialization + // + while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { + CpuPause (); + } + + if (CpuMpData->X2ApicEnable) { + DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n")); + // + // Wakeup all APs to enable x2APIC mode + // + WakeUpAP (CpuMpData, TRUE, 0, ApFuncEnableX2Apic, NULL); + // + // Wait for all known APs finished + // + while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { + CpuPause (); + } + // + // Enable x2APIC on BSP + // + SetApicMode (LOCAL_APIC_MODE_X2APIC); + } + DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ())); + // + // Sort BSP/Aps by CPU APIC ID in ascending order + // + SortApicId (CpuMpData); + + DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount)); + + return CpuMpData->CpuCount; +} + +/** + Initialize CPU AP Data when AP is wakeup at the first time. + + @param[in, out] CpuMpData Pointer to PEI CPU MP Data + @param[in] ProcessorNumber The handle number of processor + @param[in] BistData Processor BIST data + @param[in] ApTopOfStack Top of AP stack + +**/ +VOID +InitializeApData ( + IN OUT CPU_MP_DATA *CpuMpData, + IN UINTN ProcessorNumber, + IN UINT32 BistData, + IN UINT64 ApTopOfStack + ) +{ + CPU_INFO_IN_HOB *CpuInfoInHob; + + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId (); + CpuInfoInHob[ProcessorNumber].ApicId = GetApicId (); + CpuInfoInHob[ProcessorNumber].Health = BistData; + CpuInfoInHob[ProcessorNumber].ApTopOfStack = ApTopOfStack; + + CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; + CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ? TRUE : FALSE; + if (CpuInfoInHob[ProcessorNumber].InitialApicId >= 0xFF) { + // + // Set x2APIC mode if there are any logical processor reporting + // an Initial APIC ID of 255 or greater. + // + AcquireSpinLock(&CpuMpData->MpLock); + CpuMpData->X2ApicEnable = TRUE; + ReleaseSpinLock(&CpuMpData->MpLock); + } + + InitializeSpinLock(&CpuMpData->CpuData[ProcessorNumber].ApLock); + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); +} + +/** + This function will be called from AP reset code if BSP uses WakeUpAP. + + @param[in] ExchangeInfo Pointer to the MP exchange info buffer + @param[in] NumApsExecuting Number of current executing AP +**/ +VOID +EFIAPI +ApWakeupFunction ( + IN MP_CPU_EXCHANGE_INFO *ExchangeInfo, + IN UINTN NumApsExecuting + ) +{ + CPU_MP_DATA *CpuMpData; + UINTN ProcessorNumber; + EFI_AP_PROCEDURE Procedure; + VOID *Parameter; + UINT32 BistData; + volatile UINT32 *ApStartupSignalBuffer; + CPU_INFO_IN_HOB *CpuInfoInHob; + UINT64 ApTopOfStack; + + // + // AP finished assembly code and begin to execute C code + // + CpuMpData = ExchangeInfo->CpuMpData; + + // + // AP's local APIC settings will be lost after received INIT IPI + // We need to re-initialize them at here + // + ProgramVirtualWireMode (); + SyncLocalApicTimerSetting (CpuMpData); + + while (TRUE) { + if (CpuMpData->InitFlag == ApInitConfig) { + // + // Add CPU number + // + InterlockedIncrement ((UINT32 *) &CpuMpData->CpuCount); + ProcessorNumber = NumApsExecuting; + // + // This is first time AP wakeup, get BIST information from AP stack + // + ApTopOfStack = CpuMpData->Buffer + (ProcessorNumber + 1) * CpuMpData->CpuApStackSize; + BistData = *(UINT32 *) ((UINTN) ApTopOfStack - sizeof (UINTN)); + // + // Do some AP initialize sync + // + ApInitializeSync (CpuMpData); + // + // Sync BSP's Control registers to APs + // + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE); + InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack); + ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; + } else { + // + // Execute AP function if AP is ready + // + GetProcessorNumber (CpuMpData, &ProcessorNumber); + // + // Clear AP start-up signal when AP waken up + // + ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; + InterlockedCompareExchange32 ( + (UINT32 *) ApStartupSignalBuffer, + WAKEUP_AP_SIGNAL, + 0 + ); + if (CpuMpData->ApLoopMode == ApInHltLoop) { + // + // Restore AP's volatile registers saved + // + RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, TRUE); + } + + if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateReady) { + Procedure = (EFI_AP_PROCEDURE)CpuMpData->CpuData[ProcessorNumber].ApFunction; + Parameter = (VOID *) CpuMpData->CpuData[ProcessorNumber].ApFunctionArgument; + if (Procedure != NULL) { + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateBusy); + // + // Enable source debugging on AP function + // + EnableDebugAgent (); + // + // Invoke AP function here + // + Procedure (Parameter); + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + if (CpuMpData->SwitchBspFlag) { + // + // Re-get the processor number due to BSP/AP maybe exchange in AP function + // + GetProcessorNumber (CpuMpData, &ProcessorNumber); + CpuMpData->CpuData[ProcessorNumber].ApFunction = 0; + CpuMpData->CpuData[ProcessorNumber].ApFunctionArgument = 0; + ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; + CpuInfoInHob[ProcessorNumber].ApTopOfStack = CpuInfoInHob[CpuMpData->NewBspNumber].ApTopOfStack; + } else { + // + // Re-get the CPU APICID and Initial APICID + // + CpuInfoInHob[ProcessorNumber].ApicId = GetApicId (); + CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId (); + } + } + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateFinished); + } + } + + // + // AP finished executing C code + // + InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount); + + // + // Place AP is specified loop mode + // + if (CpuMpData->ApLoopMode == ApInHltLoop) { + // + // Save AP volatile registers + // + SaveVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters); + // + // Place AP in HLT-loop + // + while (TRUE) { + DisableInterrupts (); + CpuSleep (); + CpuPause (); + } + } + while (TRUE) { + DisableInterrupts (); + if (CpuMpData->ApLoopMode == ApInMwaitLoop) { + // + // Place AP in MWAIT-loop + // + AsmMonitor ((UINTN) ApStartupSignalBuffer, 0, 0); + if (*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) { + // + // Check AP start-up signal again. + // If AP start-up signal is not set, place AP into + // the specified C-state + // + AsmMwait (CpuMpData->ApTargetCState << 4, 0); + } + } else if (CpuMpData->ApLoopMode == ApInRunLoop) { + // + // Place AP in Run-loop + // + CpuPause (); + } else { + ASSERT (FALSE); + } + + // + // If AP start-up signal is written, AP is waken up + // otherwise place AP in loop again + // + if (*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) { + break; + } + } + } +} + +/** + Wait for AP wakeup and write AP start-up signal till AP is waken up. + + @param[in] ApStartupSignalBuffer Pointer to AP wakeup signal +**/ +VOID +WaitApWakeup ( + IN volatile UINT32 *ApStartupSignalBuffer + ) +{ + // + // If AP is waken up, StartupApSignal should be cleared. + // Otherwise, write StartupApSignal again till AP waken up. + // + while (InterlockedCompareExchange32 ( + (UINT32 *) ApStartupSignalBuffer, + WAKEUP_AP_SIGNAL, + WAKEUP_AP_SIGNAL + ) != 0) { + CpuPause (); + } +} + +/** + This function will fill the exchange info structure. + + @param[in] CpuMpData Pointer to CPU MP Data + +**/ +VOID +FillExchangeInfoData ( + IN CPU_MP_DATA *CpuMpData + ) +{ + volatile MP_CPU_EXCHANGE_INFO *ExchangeInfo; + + ExchangeInfo = CpuMpData->MpCpuExchangeInfo; + ExchangeInfo->Lock = 0; + ExchangeInfo->StackStart = CpuMpData->Buffer; + ExchangeInfo->StackSize = CpuMpData->CpuApStackSize; + ExchangeInfo->BufferStart = CpuMpData->WakeupBuffer; + ExchangeInfo->ModeOffset = CpuMpData->AddressMap.ModeEntryOffset; + + ExchangeInfo->CodeSegment = AsmReadCs (); + ExchangeInfo->DataSegment = AsmReadDs (); + + ExchangeInfo->Cr3 = AsmReadCr3 (); + + ExchangeInfo->CFunction = (UINTN) ApWakeupFunction; + ExchangeInfo->NumApsExecuting = 0; + ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag; + ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + ExchangeInfo->CpuMpData = CpuMpData; + + ExchangeInfo->EnableExecuteDisable = IsBspExecuteDisableEnabled (); + + // + // Get the BSP's data of GDT and IDT + // + AsmReadGdtr ((IA32_DESCRIPTOR *) &ExchangeInfo->GdtrProfile); + AsmReadIdtr ((IA32_DESCRIPTOR *) &ExchangeInfo->IdtrProfile); +} + +/** + Helper function that waits until the finished AP count reaches the specified + limit, or the specified timeout elapses (whichever comes first). + + @param[in] CpuMpData Pointer to CPU MP Data. + @param[in] FinishedApLimit The number of finished APs to wait for. + @param[in] TimeLimit The number of microseconds to wait for. +**/ +VOID +TimedWaitForApFinish ( + IN CPU_MP_DATA *CpuMpData, + IN UINT32 FinishedApLimit, + IN UINT32 TimeLimit + ); + +/** + This function will be called by BSP to wakeup AP. + + @param[in] CpuMpData Pointer to CPU MP Data + @param[in] Broadcast TRUE: Send broadcast IPI to all APs + FALSE: Send IPI to AP by ApicId + @param[in] ProcessorNumber The handle number of specified processor + @param[in] Procedure The function to be invoked by AP + @param[in] ProcedureArgument The argument to be passed into AP function +**/ +VOID +WakeUpAP ( + IN CPU_MP_DATA *CpuMpData, + IN BOOLEAN Broadcast, + IN UINTN ProcessorNumber, + IN EFI_AP_PROCEDURE Procedure, OPTIONAL + IN VOID *ProcedureArgument OPTIONAL + ) +{ + volatile MP_CPU_EXCHANGE_INFO *ExchangeInfo; + UINTN Index; + CPU_AP_DATA *CpuData; + BOOLEAN ResetVectorRequired; + CPU_INFO_IN_HOB *CpuInfoInHob; + + CpuMpData->FinishedCount = 0; + ResetVectorRequired = FALSE; + + if (CpuMpData->ApLoopMode == ApInHltLoop || + CpuMpData->InitFlag != ApInitDone) { + ResetVectorRequired = TRUE; + AllocateResetVector (CpuMpData); + FillExchangeInfoData (CpuMpData); + SaveLocalApicTimerSetting (CpuMpData); + } else if (CpuMpData->ApLoopMode == ApInMwaitLoop) { + // + // Get AP target C-state each time when waking up AP, + // for it maybe updated by platform again + // + CpuMpData->ApTargetCState = PcdGet8 (PcdCpuApTargetCstate); + } + + ExchangeInfo = CpuMpData->MpCpuExchangeInfo; + + if (Broadcast) { + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + if (Index != CpuMpData->BspNumber) { + CpuData = &CpuMpData->CpuData[Index]; + CpuData->ApFunction = (UINTN) Procedure; + CpuData->ApFunctionArgument = (UINTN) ProcedureArgument; + SetApState (CpuData, CpuStateReady); + if (CpuMpData->InitFlag != ApInitConfig) { + *(UINT32 *) CpuData->StartupApSignal = WAKEUP_AP_SIGNAL; + } + } + } + if (ResetVectorRequired) { + // + // Wakeup all APs + // + SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferStart); + } + if (CpuMpData->InitFlag == ApInitConfig) { + // + // Wait for all potential APs waken up in one specified period + // + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, + PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) + ); + } else { + // + // Wait all APs waken up if this is not the 1st broadcast of SIPI + // + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + CpuData = &CpuMpData->CpuData[Index]; + if (Index != CpuMpData->BspNumber) { + WaitApWakeup (CpuData->StartupApSignal); + } + } + } + } else { + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + CpuData->ApFunction = (UINTN) Procedure; + CpuData->ApFunctionArgument = (UINTN) ProcedureArgument; + SetApState (CpuData, CpuStateReady); + // + // Wakeup specified AP + // + ASSERT (CpuMpData->InitFlag != ApInitConfig); + *(UINT32 *) CpuData->StartupApSignal = WAKEUP_AP_SIGNAL; + if (ResetVectorRequired) { + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + SendInitSipiSipi ( + CpuInfoInHob[ProcessorNumber].ApicId, + (UINT32) ExchangeInfo->BufferStart + ); + } + // + // Wait specified AP waken up + // + WaitApWakeup (CpuData->StartupApSignal); + } + + if (ResetVectorRequired) { + FreeResetVector (CpuMpData); + } +} + +/** + Calculate timeout value and return the current performance counter value. + + Calculate the number of performance counter ticks required for a timeout. + If TimeoutInMicroseconds is 0, return value is also 0, which is recognized + as infinity. + + @param[in] TimeoutInMicroseconds Timeout value in microseconds. + @param[out] CurrentTime Returns the current value of the performance counter. + + @return Expected time stamp counter for timeout. + If TimeoutInMicroseconds is 0, return value is also 0, which is recognized + as infinity. + +**/ +UINT64 +CalculateTimeout ( + IN UINTN TimeoutInMicroseconds, + OUT UINT64 *CurrentTime + ) +{ + // + // Read the current value of the performance counter + // + *CurrentTime = GetPerformanceCounter (); + + // + // If TimeoutInMicroseconds is 0, return value is also 0, which is recognized + // as infinity. + // + if (TimeoutInMicroseconds == 0) { + return 0; + } + + // + // GetPerformanceCounterProperties () returns the timestamp counter's frequency + // in Hz. So multiply the return value with TimeoutInMicroseconds and then divide + // it by 1,000,000, to get the number of ticks for the timeout value. + // + return DivU64x32 ( + MultU64x64 ( + GetPerformanceCounterProperties (NULL, NULL), + TimeoutInMicroseconds + ), + 1000000 + ); +} + +/** + Checks whether timeout expires. + + Check whether the number of elapsed performance counter ticks required for + a timeout condition has been reached. + If Timeout is zero, which means infinity, return value is always FALSE. + + @param[in, out] PreviousTime On input, the value of the performance counter + when it was last read. + On output, the current value of the performance + counter + @param[in] TotalTime The total amount of elapsed time in performance + counter ticks. + @param[in] Timeout The number of performance counter ticks required + to reach a timeout condition. + + @retval TRUE A timeout condition has been reached. + @retval FALSE A timeout condition has not been reached. + +**/ +BOOLEAN +CheckTimeout ( + IN OUT UINT64 *PreviousTime, + IN UINT64 *TotalTime, + IN UINT64 Timeout + ) +{ + UINT64 Start; + UINT64 End; + UINT64 CurrentTime; + INT64 Delta; + INT64 Cycle; + + if (Timeout == 0) { + return FALSE; + } + GetPerformanceCounterProperties (&Start, &End); + Cycle = End - Start; + if (Cycle < 0) { + Cycle = -Cycle; + } + Cycle++; + CurrentTime = GetPerformanceCounter(); + Delta = (INT64) (CurrentTime - *PreviousTime); + if (Start > End) { + Delta = -Delta; + } + if (Delta < 0) { + Delta += Cycle; + } + *TotalTime += Delta; + *PreviousTime = CurrentTime; + if (*TotalTime > Timeout) { + return TRUE; + } + return FALSE; +} + +/** + Helper function that waits until the finished AP count reaches the specified + limit, or the specified timeout elapses (whichever comes first). + + @param[in] CpuMpData Pointer to CPU MP Data. + @param[in] FinishedApLimit The number of finished APs to wait for. + @param[in] TimeLimit The number of microseconds to wait for. +**/ +VOID +TimedWaitForApFinish ( + IN CPU_MP_DATA *CpuMpData, + IN UINT32 FinishedApLimit, + IN UINT32 TimeLimit + ) +{ + // + // CalculateTimeout() and CheckTimeout() consider a TimeLimit of 0 + // "infinity", so check for (TimeLimit == 0) explicitly. + // + if (TimeLimit == 0) { + return; + } + + CpuMpData->TotalTime = 0; + CpuMpData->ExpectedTime = CalculateTimeout ( + TimeLimit, + &CpuMpData->CurrentTime + ); + while (CpuMpData->FinishedCount < FinishedApLimit && + !CheckTimeout ( + &CpuMpData->CurrentTime, + &CpuMpData->TotalTime, + CpuMpData->ExpectedTime + )) { + CpuPause (); + } + + if (CpuMpData->FinishedCount >= FinishedApLimit) { + DEBUG (( + DEBUG_VERBOSE, + "%a: reached FinishedApLimit=%u in %Lu microseconds\n", + __FUNCTION__, + FinishedApLimit, + DivU64x64Remainder ( + MultU64x32 (CpuMpData->TotalTime, 1000000), + GetPerformanceCounterProperties (NULL, NULL), + NULL + ) + )); + } +} + +/** + Reset an AP to Idle state. + + Any task being executed by the AP will be aborted and the AP + will be waiting for a new task in Wait-For-SIPI state. + + @param[in] ProcessorNumber The handle number of processor. +**/ +VOID +ResetProcessorToIdleState ( + IN UINTN ProcessorNumber + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData = GetCpuMpData (); + + CpuMpData->InitFlag = ApInitReconfig; + WakeUpAP (CpuMpData, FALSE, ProcessorNumber, NULL, NULL); + while (CpuMpData->FinishedCount < 1) { + CpuPause (); + } + CpuMpData->InitFlag = ApInitDone; + + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); +} + +/** + Searches for the next waiting AP. + + Search for the next AP that is put in waiting state by single-threaded StartupAllAPs(). + + @param[out] NextProcessorNumber Pointer to the processor number of the next waiting AP. + + @retval EFI_SUCCESS The next waiting AP has been found. + @retval EFI_NOT_FOUND No waiting AP exists. + +**/ +EFI_STATUS +GetNextWaitingProcessorNumber ( + OUT UINTN *NextProcessorNumber + ) +{ + UINTN ProcessorNumber; + CPU_MP_DATA *CpuMpData; + + CpuMpData = GetCpuMpData (); + + for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { + if (CpuMpData->CpuData[ProcessorNumber].Waiting) { + *NextProcessorNumber = ProcessorNumber; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** Checks status of specified AP. + + This function checks whether the specified AP has finished the task assigned + by StartupThisAP(), and whether timeout expires. + + @param[in] ProcessorNumber The handle number of processor. + + @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs(). + @retval EFI_TIMEOUT The timeout expires. + @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired. +**/ +EFI_STATUS +CheckThisAP ( + IN UINTN ProcessorNumber + ) +{ + CPU_MP_DATA *CpuMpData; + CPU_AP_DATA *CpuData; + + CpuMpData = GetCpuMpData (); + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + + // + // Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task. + // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the + // value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value. + // + // + // If the AP finishes for StartupThisAP(), return EFI_SUCCESS. + // + if (GetApState(CpuData) == CpuStateFinished) { + if (CpuData->Finished != NULL) { + *(CpuData->Finished) = TRUE; + } + SetApState (CpuData, CpuStateIdle); + return EFI_SUCCESS; + } else { + // + // If timeout expires for StartupThisAP(), report timeout. + // + if (CheckTimeout (&CpuData->CurrentTime, &CpuData->TotalTime, CpuData->ExpectedTime)) { + if (CpuData->Finished != NULL) { + *(CpuData->Finished) = FALSE; + } + // + // Reset failed AP to idle state + // + ResetProcessorToIdleState (ProcessorNumber); + + return EFI_TIMEOUT; + } + } + return EFI_NOT_READY; +} + +/** + Checks status of all APs. + + This function checks whether all APs have finished task assigned by StartupAllAPs(), + and whether timeout expires. + + @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs(). + @retval EFI_TIMEOUT The timeout expires. + @retval EFI_NOT_READY APs have not finished task and timeout has not expired. +**/ +EFI_STATUS +CheckAllAPs ( + VOID + ) +{ + UINTN ProcessorNumber; + UINTN NextProcessorNumber; + UINTN ListIndex; + EFI_STATUS Status; + CPU_MP_DATA *CpuMpData; + CPU_AP_DATA *CpuData; + + CpuMpData = GetCpuMpData (); + + NextProcessorNumber = 0; + + // + // Go through all APs that are responsible for the StartupAllAPs(). + // + for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { + if (!CpuMpData->CpuData[ProcessorNumber].Waiting) { + continue; + } + + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + // + // Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task. + // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the + // value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value. + // + if (GetApState(CpuData) == CpuStateFinished) { + CpuMpData->RunningCount ++; + CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; + SetApState(CpuData, CpuStateIdle); + + // + // If in Single Thread mode, then search for the next waiting AP for execution. + // + if (CpuMpData->SingleThread) { + Status = GetNextWaitingProcessorNumber (&NextProcessorNumber); + + if (!EFI_ERROR (Status)) { + WakeUpAP ( + CpuMpData, + FALSE, + (UINT32) NextProcessorNumber, + CpuMpData->Procedure, + CpuMpData->ProcArguments + ); + } + } + } + } + + // + // If all APs finish, return EFI_SUCCESS. + // + if (CpuMpData->RunningCount == CpuMpData->StartCount) { + return EFI_SUCCESS; + } + + // + // If timeout expires, report timeout. + // + if (CheckTimeout ( + &CpuMpData->CurrentTime, + &CpuMpData->TotalTime, + CpuMpData->ExpectedTime) + ) { + // + // If FailedCpuList is not NULL, record all failed APs in it. + // + if (CpuMpData->FailedCpuList != NULL) { + *CpuMpData->FailedCpuList = + AllocatePool ((CpuMpData->StartCount - CpuMpData->FinishedCount + 1) * sizeof (UINTN)); + ASSERT (*CpuMpData->FailedCpuList != NULL); + } + ListIndex = 0; + + for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { + // + // Check whether this processor is responsible for StartupAllAPs(). + // + if (CpuMpData->CpuData[ProcessorNumber].Waiting) { + // + // Reset failed APs to idle state + // + ResetProcessorToIdleState (ProcessorNumber); + CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; + if (CpuMpData->FailedCpuList != NULL) { + (*CpuMpData->FailedCpuList)[ListIndex++] = ProcessorNumber; + } + } + } + if (CpuMpData->FailedCpuList != NULL) { + (*CpuMpData->FailedCpuList)[ListIndex] = END_OF_CPU_LIST; + } + return EFI_TIMEOUT; + } + return EFI_NOT_READY; +} + +/** + MP Initialize Library initialization. + + This service will allocate AP reset vector and wakeup all APs to do APs + initialization. + + This service must be invoked before all other MP Initialize Library + service are invoked. + + @retval EFI_SUCCESS MP initialization succeeds. + @retval Others MP initialization fails. + +**/ +EFI_STATUS +EFIAPI +MpInitLibInitialize ( + VOID + ) +{ + CPU_MP_DATA *OldCpuMpData; + CPU_INFO_IN_HOB *CpuInfoInHob; + UINT32 MaxLogicalProcessorNumber; + UINT32 ApStackSize; + MP_ASSEMBLY_ADDRESS_MAP AddressMap; + UINTN BufferSize; + UINT32 MonitorFilterSize; + VOID *MpBuffer; + UINTN Buffer; + CPU_MP_DATA *CpuMpData; + UINT8 ApLoopMode; + UINT8 *MonitorBuffer; + UINTN Index; + UINTN ApResetVectorSize; + UINTN BackupBufferAddr; + + OldCpuMpData = GetCpuMpDataFromGuidedHob (); + if (OldCpuMpData == NULL) { + MaxLogicalProcessorNumber = PcdGet32(PcdCpuMaxLogicalProcessorNumber); + } else { + MaxLogicalProcessorNumber = OldCpuMpData->CpuCount; + } + ASSERT (MaxLogicalProcessorNumber != 0); + + AsmGetAddressMap (&AddressMap); + ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO); + ApStackSize = PcdGet32(PcdCpuApStackSize); + ApLoopMode = GetApLoopMode (&MonitorFilterSize); + + BufferSize = ApStackSize * MaxLogicalProcessorNumber; + BufferSize += MonitorFilterSize * MaxLogicalProcessorNumber; + BufferSize += sizeof (CPU_MP_DATA); + BufferSize += ApResetVectorSize; + BufferSize += (sizeof (CPU_AP_DATA) + sizeof (CPU_INFO_IN_HOB))* MaxLogicalProcessorNumber; + MpBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize)); + ASSERT (MpBuffer != NULL); + ZeroMem (MpBuffer, BufferSize); + Buffer = (UINTN) MpBuffer; + + MonitorBuffer = (UINT8 *) (Buffer + ApStackSize * MaxLogicalProcessorNumber); + BackupBufferAddr = (UINTN) MonitorBuffer + MonitorFilterSize * MaxLogicalProcessorNumber; + CpuMpData = (CPU_MP_DATA *) (BackupBufferAddr + ApResetVectorSize); + CpuMpData->Buffer = Buffer; + CpuMpData->CpuApStackSize = ApStackSize; + CpuMpData->BackupBuffer = BackupBufferAddr; + CpuMpData->BackupBufferSize = ApResetVectorSize; + CpuMpData->SaveRestoreFlag = FALSE; + CpuMpData->WakeupBuffer = (UINTN) -1; + CpuMpData->CpuCount = 1; + CpuMpData->BspNumber = 0; + CpuMpData->WaitEvent = NULL; + CpuMpData->SwitchBspFlag = FALSE; + CpuMpData->CpuData = (CPU_AP_DATA *) (CpuMpData + 1); + CpuMpData->CpuInfoInHob = (UINT64) (UINTN) (CpuMpData->CpuData + MaxLogicalProcessorNumber); + InitializeSpinLock(&CpuMpData->MpLock); + // + // Save BSP's Control registers to APs + // + SaveVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters); + // + // Set BSP basic information + // + InitializeApData (CpuMpData, 0, 0, CpuMpData->Buffer); + // + // Save assembly code information + // + CopyMem (&CpuMpData->AddressMap, &AddressMap, sizeof (MP_ASSEMBLY_ADDRESS_MAP)); + // + // Finally set AP loop mode + // + CpuMpData->ApLoopMode = ApLoopMode; + DEBUG ((DEBUG_INFO, "AP Loop Mode is %d\n", CpuMpData->ApLoopMode)); + // + // Set up APs wakeup signal buffer + // + for (Index = 0; Index < MaxLogicalProcessorNumber; Index++) { + CpuMpData->CpuData[Index].StartupApSignal = + (UINT32 *)(MonitorBuffer + MonitorFilterSize * Index); + } + // + // Load Microcode on BSP + // + MicrocodeDetect (CpuMpData); + // + // Store BSP's MTRR setting + // + MtrrGetAllMtrrs (&CpuMpData->MtrrTable); + + if (OldCpuMpData == NULL) { + if (MaxLogicalProcessorNumber > 1) { + // + // Wakeup all APs and calculate the processor count in system + // + CollectProcessorCount (CpuMpData); + } + } else { + // + // APs have been wakeup before, just get the CPU Information + // from HOB + // + CpuMpData->CpuCount = OldCpuMpData->CpuCount; + CpuMpData->BspNumber = OldCpuMpData->BspNumber; + CpuMpData->InitFlag = ApInitReconfig; + CpuMpData->CpuInfoInHob = OldCpuMpData->CpuInfoInHob; + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock); + if (CpuInfoInHob[Index].InitialApicId >= 255) { + CpuMpData->X2ApicEnable = TRUE; + } + CpuMpData->CpuData[Index].CpuHealthy = (CpuInfoInHob[Index].Health == 0)? TRUE:FALSE; + CpuMpData->CpuData[Index].ApFunction = 0; + CopyMem ( + &CpuMpData->CpuData[Index].VolatileRegisters, + &CpuMpData->CpuData[0].VolatileRegisters, + sizeof (CPU_VOLATILE_REGISTERS) + ); + } + if (MaxLogicalProcessorNumber > 1) { + // + // Wakeup APs to do some AP initialize sync + // + WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData); + // + // Wait for all APs finished initialization + // + while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { + CpuPause (); + } + CpuMpData->InitFlag = ApInitDone; + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); + } + } + } + + // + // Initialize global data for MP support + // + InitMpGlobalData (CpuMpData); + + return EFI_SUCCESS; +} + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + @param[out] HealthData Return processor health data. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibGetProcessorInfo ( + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, + OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL + ) +{ + CPU_MP_DATA *CpuMpData; + UINTN CallerNumber; + CPU_INFO_IN_HOB *CpuInfoInHob; + + CpuMpData = GetCpuMpData (); + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_DEVICE_ERROR; + } + + if (ProcessorInfoBuffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (ProcessorNumber >= CpuMpData->CpuCount) { + return EFI_NOT_FOUND; + } + + ProcessorInfoBuffer->ProcessorId = (UINT64) CpuInfoInHob[ProcessorNumber].ApicId; + ProcessorInfoBuffer->StatusFlag = 0; + if (ProcessorNumber == CpuMpData->BspNumber) { + ProcessorInfoBuffer->StatusFlag |= PROCESSOR_AS_BSP_BIT; + } + if (CpuMpData->CpuData[ProcessorNumber].CpuHealthy) { + ProcessorInfoBuffer->StatusFlag |= PROCESSOR_HEALTH_STATUS_BIT; + } + if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateDisabled) { + ProcessorInfoBuffer->StatusFlag &= ~PROCESSOR_ENABLED_BIT; + } else { + ProcessorInfoBuffer->StatusFlag |= PROCESSOR_ENABLED_BIT; + } + + // + // Get processor location information + // + GetProcessorLocationByApicId ( + CpuInfoInHob[ProcessorNumber].ApicId, + &ProcessorInfoBuffer->Location.Package, + &ProcessorInfoBuffer->Location.Core, + &ProcessorInfoBuffer->Location.Thread + ); + + if (HealthData != NULL) { + HealthData->Uint32 = CpuInfoInHob[ProcessorNumber].Health; + } + + return EFI_SUCCESS; +} + +/** + Worker function to switch the requested AP to be the BSP from that point onward. + + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval others Failed to switch BSP. + +**/ +EFI_STATUS +SwitchBSPWorker ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + CPU_MP_DATA *CpuMpData; + UINTN CallerNumber; + CPU_STATE State; + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + BOOLEAN OldInterruptState; + BOOLEAN OldTimerInterruptState; + + // + // Save and Disable Local APIC timer interrupt + // + OldTimerInterruptState = GetApicTimerInterruptState (); + DisableApicTimerInterrupt (); + // + // Before send both BSP and AP to a procedure to exchange their roles, + // interrupt must be disabled. This is because during the exchange role + // process, 2 CPU may use 1 stack. If interrupt happens, the stack will + // be corrupted, since interrupt return address will be pushed to stack + // by hardware. + // + OldInterruptState = SaveAndDisableInterrupts (); + + // + // Mask LINT0 & LINT1 for the old BSP + // + DisableLvtInterrupts (); + + CpuMpData = GetCpuMpData (); + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_SUCCESS; + } + + if (ProcessorNumber >= CpuMpData->CpuCount) { + return EFI_NOT_FOUND; + } + + // + // Check whether specified AP is disabled + // + State = GetApState (&CpuMpData->CpuData[ProcessorNumber]); + if (State == CpuStateDisabled) { + return EFI_INVALID_PARAMETER; + } + + // + // Check whether ProcessorNumber specifies the current BSP + // + if (ProcessorNumber == CpuMpData->BspNumber) { + return EFI_INVALID_PARAMETER; + } + + // + // Check whether specified AP is busy + // + if (State == CpuStateBusy) { + return EFI_NOT_READY; + } + + CpuMpData->BSPInfo.State = CPU_SWITCH_STATE_IDLE; + CpuMpData->APInfo.State = CPU_SWITCH_STATE_IDLE; + CpuMpData->SwitchBspFlag = TRUE; + CpuMpData->NewBspNumber = ProcessorNumber; + + // + // Clear the BSP bit of MSR_IA32_APIC_BASE + // + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + ApicBaseMsr.Bits.BSP = 0; + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); + + // + // Need to wakeUp AP (future BSP). + // + WakeUpAP (CpuMpData, FALSE, ProcessorNumber, FutureBSPProc, CpuMpData); + + AsmExchangeRole (&CpuMpData->BSPInfo, &CpuMpData->APInfo); + + // + // Set the BSP bit of MSR_IA32_APIC_BASE on new BSP + // + ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); + ApicBaseMsr.Bits.BSP = 1; + AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); + + // + // Wait for old BSP finished AP task + // + while (GetApState (&CpuMpData->CpuData[CallerNumber]) != CpuStateFinished) { + CpuPause (); + } + + CpuMpData->SwitchBspFlag = FALSE; + // + // Set old BSP enable state + // + if (!EnableOldBSP) { + SetApState (&CpuMpData->CpuData[CallerNumber], CpuStateDisabled); + } else { + SetApState (&CpuMpData->CpuData[CallerNumber], CpuStateIdle); + } + // + // Save new BSP number + // + CpuMpData->BspNumber = (UINT32) ProcessorNumber; + + // + // Restore interrupt state. + // + SetInterruptState (OldInterruptState); + + if (OldTimerInterruptState) { + EnableApicTimerInterrupt (); + } + + return EFI_SUCCESS; +} + +/** + Worker function to let the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of AP. + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval others Failed to Enable/Disable AP. + +**/ +EFI_STATUS +EnableDisableApWorker ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + CPU_MP_DATA *CpuMpData; + UINTN CallerNumber; + + CpuMpData = GetCpuMpData (); + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_DEVICE_ERROR; + } + + if (ProcessorNumber == CpuMpData->BspNumber) { + return EFI_INVALID_PARAMETER; + } + + if (ProcessorNumber >= CpuMpData->CpuCount) { + return EFI_NOT_FOUND; + } + + if (!EnableAP) { + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateDisabled); + } else { + SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); + } + + if (HealthFlag != NULL) { + CpuMpData->CpuData[ProcessorNumber].CpuHealthy = + (BOOLEAN) ((*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT) != 0); + } + + return EFI_SUCCESS; +} + +/** + This return the handle number for the calling processor. This service may be + called from the BSP and APs. + + @param[out] ProcessorNumber Pointer to the handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibWhoAmI ( + OUT UINTN *ProcessorNumber + ) +{ + CPU_MP_DATA *CpuMpData; + + if (ProcessorNumber == NULL) { + return EFI_INVALID_PARAMETER; + } + + CpuMpData = GetCpuMpData (); + + return GetProcessorNumber (CpuMpData, ProcessorNumber); +} + +/** + Retrieves the number of logical processor in the platform and the number of + those logical processors that are enabled on this boot. This service may only + be called from the BSP. + + @param[out] NumberOfProcessors Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. + + @retval EFI_SUCCESS The number of logical processors and enabled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors + is NULL. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibGetNumberOfProcessors ( + OUT UINTN *NumberOfProcessors, OPTIONAL + OUT UINTN *NumberOfEnabledProcessors OPTIONAL + ) +{ + CPU_MP_DATA *CpuMpData; + UINTN CallerNumber; + UINTN ProcessorNumber; + UINTN EnabledProcessorNumber; + UINTN Index; + + CpuMpData = GetCpuMpData (); + + if ((NumberOfProcessors == NULL) && (NumberOfEnabledProcessors == NULL)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_DEVICE_ERROR; + } + + ProcessorNumber = CpuMpData->CpuCount; + EnabledProcessorNumber = 0; + for (Index = 0; Index < ProcessorNumber; Index++) { + if (GetApState (&CpuMpData->CpuData[Index]) != CpuStateDisabled) { + EnabledProcessorNumber ++; + } + } + + if (NumberOfProcessors != NULL) { + *NumberOfProcessors = ProcessorNumber; + } + if (NumberOfEnabledProcessors != NULL) { + *NumberOfEnabledProcessors = EnabledProcessorNumber; + } + + return EFI_SUCCESS; +} + + +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval others Failed to Startup all APs. + +**/ +EFI_STATUS +StartupAllAPsWorker ( + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ) +{ + EFI_STATUS Status; + CPU_MP_DATA *CpuMpData; + UINTN ProcessorCount; + UINTN ProcessorNumber; + UINTN CallerNumber; + CPU_AP_DATA *CpuData; + BOOLEAN HasEnabledAp; + CPU_STATE ApState; + + CpuMpData = GetCpuMpData (); + + if (FailedCpuList != NULL) { + *FailedCpuList = NULL; + } + + if (CpuMpData->CpuCount == 1) { + return EFI_NOT_STARTED; + } + + if (Procedure == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_DEVICE_ERROR; + } + + // + // Update AP state + // + CheckAndUpdateApsStatus (); + + ProcessorCount = CpuMpData->CpuCount; + HasEnabledAp = FALSE; + // + // Check whether all enabled APs are idle. + // If any enabled AP is not idle, return EFI_NOT_READY. + // + for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + if (ProcessorNumber != CpuMpData->BspNumber) { + ApState = GetApState (CpuData); + if (ApState != CpuStateDisabled) { + HasEnabledAp = TRUE; + if (ApState != CpuStateIdle) { + // + // If any enabled APs are busy, return EFI_NOT_READY. + // + return EFI_NOT_READY; + } + } + } + } + + if (!HasEnabledAp) { + // + // If no enabled AP exists, return EFI_NOT_STARTED. + // + return EFI_NOT_STARTED; + } + + CpuMpData->StartCount = 0; + for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + CpuData->Waiting = FALSE; + if (ProcessorNumber != CpuMpData->BspNumber) { + if (CpuData->State == CpuStateIdle) { + // + // Mark this processor as responsible for current calling. + // + CpuData->Waiting = TRUE; + CpuMpData->StartCount++; + } + } + } + + CpuMpData->Procedure = Procedure; + CpuMpData->ProcArguments = ProcedureArgument; + CpuMpData->SingleThread = SingleThread; + CpuMpData->FinishedCount = 0; + CpuMpData->RunningCount = 0; + CpuMpData->FailedCpuList = FailedCpuList; + CpuMpData->ExpectedTime = CalculateTimeout ( + TimeoutInMicroseconds, + &CpuMpData->CurrentTime + ); + CpuMpData->TotalTime = 0; + CpuMpData->WaitEvent = WaitEvent; + + if (!SingleThread) { + WakeUpAP (CpuMpData, TRUE, 0, Procedure, ProcedureArgument); + } else { + for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { + if (ProcessorNumber == CallerNumber) { + continue; + } + if (CpuMpData->CpuData[ProcessorNumber].Waiting) { + WakeUpAP (CpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument); + break; + } + } + } + + Status = EFI_SUCCESS; + if (WaitEvent == NULL) { + do { + Status = CheckAllAPs (); + } while (Status == EFI_NOT_READY); + } + + return Status; +} + +/** + Worker function to let the caller get one enabled AP to execute a caller-provided + function. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. + @param[in] ProcessorNumber The handle number of the AP. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] Finished If AP returns from Procedure before the + timeout expires, its content is set to TRUE. + Otherwise, the value is set to FALSE. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval others Failed to Startup AP. + +**/ +EFI_STATUS +StartupThisAPWorker ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ) +{ + EFI_STATUS Status; + CPU_MP_DATA *CpuMpData; + CPU_AP_DATA *CpuData; + UINTN CallerNumber; + + CpuMpData = GetCpuMpData (); + + if (Finished != NULL) { + *Finished = FALSE; + } + + // + // Check whether caller processor is BSP + // + MpInitLibWhoAmI (&CallerNumber); + if (CallerNumber != CpuMpData->BspNumber) { + return EFI_DEVICE_ERROR; + } + + // + // Check whether processor with the handle specified by ProcessorNumber exists + // + if (ProcessorNumber >= CpuMpData->CpuCount) { + return EFI_NOT_FOUND; + } + + // + // Check whether specified processor is BSP + // + if (ProcessorNumber == CpuMpData->BspNumber) { + return EFI_INVALID_PARAMETER; + } + + // + // Check parameter Procedure + // + if (Procedure == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Update AP state + // + CheckAndUpdateApsStatus (); + + // + // Check whether specified AP is disabled + // + if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateDisabled) { + return EFI_INVALID_PARAMETER; + } + + // + // If WaitEvent is not NULL, execute in non-blocking mode. + // BSP saves data for CheckAPsStatus(), and returns EFI_SUCCESS. + // CheckAPsStatus() will check completion and timeout periodically. + // + CpuData = &CpuMpData->CpuData[ProcessorNumber]; + CpuData->WaitEvent = WaitEvent; + CpuData->Finished = Finished; + CpuData->ExpectedTime = CalculateTimeout (TimeoutInMicroseconds, &CpuData->CurrentTime); + CpuData->TotalTime = 0; + + WakeUpAP (CpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument); + + // + // If WaitEvent is NULL, execute in blocking mode. + // BSP checks AP's state until it finishes or TimeoutInMicrosecsond expires. + // + Status = EFI_SUCCESS; + if (WaitEvent == NULL) { + do { + Status = CheckThisAP (ProcessorNumber); + } while (Status == EFI_NOT_READY); + } + + return Status; +} + +/** + Get pointer to CPU MP Data structure from GUIDed HOB. + + @return The pointer to CPU MP Data structure. +**/ +CPU_MP_DATA * +GetCpuMpDataFromGuidedHob ( + VOID + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + CPU_MP_DATA *CpuMpData; + + CpuMpData = NULL; + GuidHob = GetFirstGuidHob (&mCpuInitMpLibHobGuid); + if (GuidHob != NULL) { + DataInHob = GET_GUID_HOB_DATA (GuidHob); + CpuMpData = (CPU_MP_DATA *) (*(UINTN *) DataInHob); + } + return CpuMpData; +} + +/** + Get available system memory below 1MB by specified size. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +BackupAndPrepareWakeupBuffer( + IN CPU_MP_DATA *CpuMpData + ) +{ + CopyMem ( + (VOID *) CpuMpData->BackupBuffer, + (VOID *) CpuMpData->WakeupBuffer, + CpuMpData->BackupBufferSize + ); + CopyMem ( + (VOID *) CpuMpData->WakeupBuffer, + (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress, + CpuMpData->AddressMap.RendezvousFunnelSize + ); +} + +/** + Restore wakeup buffer data. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +RestoreWakeupBuffer( + IN CPU_MP_DATA *CpuMpData + ) +{ + CopyMem ( + (VOID *) CpuMpData->WakeupBuffer, + (VOID *) CpuMpData->BackupBuffer, + CpuMpData->BackupBufferSize + ); +} diff --git a/Core/UefiCpuPkg/Library/MpInitLib/MpLib.h b/Core/UefiCpuPkg/Library/MpInitLib/MpLib.h new file mode 100644 index 0000000000..7a272d78ec --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -0,0 +1,594 @@ +/** @file + Common header file for MP Initialize Library. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _MP_LIB_H_ +#define _MP_LIB_H_ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P') + +#define CPU_INIT_MP_LIB_HOB_GUID \ + { \ + 0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \ + } + +// +// The MP data for switch BSP +// +#define CPU_SWITCH_STATE_IDLE 0 +#define CPU_SWITCH_STATE_STORED 1 +#define CPU_SWITCH_STATE_LOADED 2 + +// +// CPU exchange information for switch BSP +// +typedef struct { + UINT8 State; // offset 0 + UINTN StackPointer; // offset 4 / 8 + IA32_DESCRIPTOR Gdtr; // offset 8 / 16 + IA32_DESCRIPTOR Idtr; // offset 14 / 26 +} CPU_EXCHANGE_ROLE_INFO; + +// +// AP loop state when APs are in idle state +// It's value is the same with PcdCpuApLoopMode +// +typedef enum { + ApInHltLoop = 1, + ApInMwaitLoop = 2, + ApInRunLoop = 3 +} AP_LOOP_MODE; + +// +// AP initialization state during APs wakeup +// +typedef enum { + ApInitConfig = 1, + ApInitReconfig = 2, + ApInitDone = 3 +} AP_INIT_STATE; + +// +// AP state +// +typedef enum { + CpuStateIdle, + CpuStateReady, + CpuStateBusy, + CpuStateFinished, + CpuStateDisabled +} CPU_STATE; + +// +// CPU volatile registers around INIT-SIPI-SIPI +// +typedef struct { + UINTN Cr0; + UINTN Cr3; + UINTN Cr4; + UINTN Dr0; + UINTN Dr1; + UINTN Dr2; + UINTN Dr3; + UINTN Dr6; + UINTN Dr7; +} CPU_VOLATILE_REGISTERS; + +// +// AP related data +// +typedef struct { + SPIN_LOCK ApLock; + volatile UINT32 *StartupApSignal; + volatile UINTN ApFunction; + volatile UINTN ApFunctionArgument; + BOOLEAN CpuHealthy; + volatile CPU_STATE State; + CPU_VOLATILE_REGISTERS VolatileRegisters; + BOOLEAN Waiting; + BOOLEAN *Finished; + UINT64 ExpectedTime; + UINT64 CurrentTime; + UINT64 TotalTime; + EFI_EVENT WaitEvent; +} CPU_AP_DATA; + +// +// Basic CPU information saved in Guided HOB. +// Because the contents will be shard between PEI and DXE, +// we need to make sure the each fields offset same in different +// architecture. +// +#pragma pack (1) +typedef struct { + UINT32 InitialApicId; + UINT32 ApicId; + UINT32 Health; + UINT64 ApTopOfStack; +} CPU_INFO_IN_HOB; +#pragma pack () + +// +// AP reset code information including code address and size, +// this structure will be shared be C code and assembly code. +// It is natural aligned by design. +// +typedef struct { + UINT8 *RendezvousFunnelAddress; + UINTN ModeEntryOffset; + UINTN RendezvousFunnelSize; + UINT8 *RelocateApLoopFuncAddress; + UINTN RelocateApLoopFuncSize; +} MP_ASSEMBLY_ADDRESS_MAP; + +typedef struct _CPU_MP_DATA CPU_MP_DATA; + +#pragma pack(1) + +// +// MP CPU exchange information for AP reset code +// This structure is required to be packed because fixed field offsets +// into this structure are used in assembly code in this module +// +typedef struct { + UINTN Lock; + UINTN StackStart; + UINTN StackSize; + UINTN CFunction; + IA32_DESCRIPTOR GdtrProfile; + IA32_DESCRIPTOR IdtrProfile; + UINTN BufferStart; + UINTN ModeOffset; + UINTN NumApsExecuting; + UINTN CodeSegment; + UINTN DataSegment; + UINTN EnableExecuteDisable; + UINTN Cr3; + UINTN InitFlag; + CPU_INFO_IN_HOB *CpuInfo; + CPU_MP_DATA *CpuMpData; +} MP_CPU_EXCHANGE_INFO; + +#pragma pack() + +// +// CPU MP Data save in memory +// +struct _CPU_MP_DATA { + UINT64 CpuInfoInHob; + UINT32 CpuCount; + UINT32 BspNumber; + // + // The above fields data will be passed from PEI to DXE + // Please make sure the fields offset same in the different + // architecture. + // + SPIN_LOCK MpLock; + UINTN Buffer; + UINTN CpuApStackSize; + MP_ASSEMBLY_ADDRESS_MAP AddressMap; + UINTN WakeupBuffer; + UINTN BackupBuffer; + UINTN BackupBufferSize; + BOOLEAN SaveRestoreFlag; + + volatile UINT32 StartCount; + volatile UINT32 FinishedCount; + volatile UINT32 RunningCount; + BOOLEAN SingleThread; + EFI_AP_PROCEDURE Procedure; + VOID *ProcArguments; + BOOLEAN *Finished; + UINT64 ExpectedTime; + UINT64 CurrentTime; + UINT64 TotalTime; + EFI_EVENT WaitEvent; + UINTN **FailedCpuList; + + AP_INIT_STATE InitFlag; + BOOLEAN X2ApicEnable; + BOOLEAN SwitchBspFlag; + UINTN NewBspNumber; + CPU_EXCHANGE_ROLE_INFO BSPInfo; + CPU_EXCHANGE_ROLE_INFO APInfo; + MTRR_SETTINGS MtrrTable; + UINT8 ApLoopMode; + UINT8 ApTargetCState; + UINT16 PmCodeSegment; + CPU_AP_DATA *CpuData; + volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo; + + UINT32 CurrentTimerCount; + UINTN DivideValue; + UINT8 Vector; + BOOLEAN PeriodicMode; + BOOLEAN TimerInterruptState; +}; + +extern EFI_GUID mCpuInitMpLibHobGuid; + +/** + Assembly code to place AP into safe loop mode. + + Place AP into targeted C-State if MONITOR is supported, otherwise + place AP into hlt state. + Place AP in protected mode if the current is long mode. Due to AP maybe + wakeup by some hardware event. It could avoid accessing page table that + may not available during booting to OS. + + @param[in] MwaitSupport TRUE indicates MONITOR is supported. + FALSE indicates MONITOR is not supported. + @param[in] ApTargetCState Target C-State value. + @param[in] PmCodeSegment Protected mode code segment value. +**/ +typedef +VOID +(EFIAPI * ASM_RELOCATE_AP_LOOP) ( + IN BOOLEAN MwaitSupport, + IN UINTN ApTargetCState, + IN UINTN PmCodeSegment, + IN UINTN TopOfApStack, + IN UINTN NumberToFinish + ); + +/** + Assembly code to get starting address and size of the rendezvous entry for APs. + Information for fixing a jump instruction in the code is also returned. + + @param[out] AddressMap Output buffer for address map information. +**/ +VOID +EFIAPI +AsmGetAddressMap ( + OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap + ); + +/** + This function is called by both the BSP and the AP which is to become the BSP to + Exchange execution context including stack between them. After return from this + function, the BSP becomes AP and the AP becomes the BSP. + + @param[in] MyInfo Pointer to buffer holding the exchanging information for the executing processor. + @param[in] OthersInfo Pointer to buffer holding the exchanging information for the peer. + +**/ +VOID +EFIAPI +AsmExchangeRole ( + IN CPU_EXCHANGE_ROLE_INFO *MyInfo, + IN CPU_EXCHANGE_ROLE_INFO *OthersInfo + ); + +/** + Get the pointer to CPU MP Data structure. + + @return The pointer to CPU MP Data structure. +**/ +CPU_MP_DATA * +GetCpuMpData ( + VOID + ); + +/** + Save the pointer to CPU MP Data structure. + + @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. +**/ +VOID +SaveCpuMpData ( + IN CPU_MP_DATA *CpuMpData + ); + +/** + Allocate reset vector buffer. + + @param[in, out] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +AllocateResetVector ( + IN OUT CPU_MP_DATA *CpuMpData + ); + +/** + Free AP reset vector buffer. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +FreeResetVector ( + IN CPU_MP_DATA *CpuMpData + ); + +/** + This function will be called by BSP to wakeup AP. + + @param[in] CpuMpData Pointer to CPU MP Data + @param[in] Broadcast TRUE: Send broadcast IPI to all APs + FALSE: Send IPI to AP by ApicId + @param[in] ProcessorNumber The handle number of specified processor + @param[in] Procedure The function to be invoked by AP + @param[in] ProcedureArgument The argument to be passed into AP function +**/ +VOID +WakeUpAP ( + IN CPU_MP_DATA *CpuMpData, + IN BOOLEAN Broadcast, + IN UINTN ProcessorNumber, + IN EFI_AP_PROCEDURE Procedure, OPTIONAL + IN VOID *ProcedureArgument OPTIONAL + ); + +/** + Initialize global data for MP support. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +InitMpGlobalData ( + IN CPU_MP_DATA *CpuMpData + ); + +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval others Failed to Startup all APs. + +**/ +EFI_STATUS +StartupAllAPsWorker ( + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ); + +/** + Worker function to let the caller get one enabled AP to execute a caller-provided + function. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. + @param[in] ProcessorNumber The handle number of the AP. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] Finished If AP returns from Procedure before the + timeout expires, its content is set to TRUE. + Otherwise, the value is set to FALSE. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval others Failed to Startup AP. + +**/ +EFI_STATUS +StartupThisAPWorker ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ); + +/** + Worker function to switch the requested AP to be the BSP from that point onward. + + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval others Failed to switch BSP. + +**/ +EFI_STATUS +SwitchBSPWorker ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ); + +/** + Worker function to let the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of AP. + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval others Failed to Enable/Disable AP. + +**/ +EFI_STATUS +EnableDisableApWorker ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ); + +/** + Get pointer to CPU MP Data structure from GUIDed HOB. + + @return The pointer to CPU MP Data structure. +**/ +CPU_MP_DATA * +GetCpuMpDataFromGuidedHob ( + VOID + ); + +/** Checks status of specified AP. + + This function checks whether the specified AP has finished the task assigned + by StartupThisAP(), and whether timeout expires. + + @param[in] ProcessorNumber The handle number of processor. + + @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs(). + @retval EFI_TIMEOUT The timeout expires. + @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired. +**/ +EFI_STATUS +CheckThisAP ( + IN UINTN ProcessorNumber + ); + +/** + Checks status of all APs. + + This function checks whether all APs have finished task assigned by StartupAllAPs(), + and whether timeout expires. + + @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs(). + @retval EFI_TIMEOUT The timeout expires. + @retval EFI_NOT_READY APs have not finished task and timeout has not expired. +**/ +EFI_STATUS +CheckAllAPs ( + VOID + ); + +/** + Checks APs status and updates APs status if needed. + +**/ +VOID +CheckAndUpdateApsStatus ( + VOID + ); + +/** + Detect whether specified processor can find matching microcode patch and load it. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +MicrocodeDetect ( + IN CPU_MP_DATA *CpuMpData + ); + +/** + Detect whether Mwait-monitor feature is supported. + + @retval TRUE Mwait-monitor feature is supported. + @retval FALSE Mwait-monitor feature is not supported. +**/ +BOOLEAN +IsMwaitSupport ( + VOID + ); + +/** + Notify function on End Of PEI PPI. + + On S3 boot, this function will restore wakeup buffer data. + On normal boot, this function will flag wakeup buffer to be un-used type. + + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] NotifyDescriptor Address of the notification descriptor data structure. + @param[in] Ppi Address of the PPI that was installed. + + @retval EFI_SUCCESS When everything is OK. +**/ +EFI_STATUS +EFIAPI +CpuMpEndOfPeiCallback ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ); + +/** + Get available system memory below 1MB by specified size. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +BackupAndPrepareWakeupBuffer( + IN CPU_MP_DATA *CpuMpData + ); + +/** + Restore wakeup buffer data. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +RestoreWakeupBuffer( + IN CPU_MP_DATA *CpuMpData + ); + +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ); + +#endif + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf new file mode 100644 index 0000000000..0c6873da79 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf @@ -0,0 +1,70 @@ +## @file +# MP Initialize Library instance for PEI driver. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PeiMpInitLib + MODULE_UNI_FILE = PeiMpInitLib.uni + FILE_GUID = B00F6090-7739-4830-B906-E0032D388987 + MODULE_TYPE = PEIM + VERSION_STRING = 1.1 + LIBRARY_CLASS = MpInitLib|PEIM + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.IA32] + Ia32/MpEqu.inc + Ia32/MpFuncs.nasm + +[Sources.X64] + X64/MpEqu.inc + X64/MpFuncs.nasm + +[Sources.common] + PeiMpLib.c + MpLib.c + MpLib.h + Microcode.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + LocalApicLib + MemoryAllocationLib + HobLib + PeiServicesLib + MtrrLib + CpuLib + UefiCpuLib + SynchronizationLib + +[Ppis] + gEfiEndOfPeiSignalPpiGuid ## NOTIFY + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOMETIMES_CONSUMES + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni new file mode 100644 index 0000000000..d16f306685 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni @@ -0,0 +1,22 @@ +// /** @file +// MP Initialize Library instance for PEI driver. +// +// MP Initialize Library instance for PEI driver. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "MP Initialize Library instance for PEI driver." + +#string STR_MODULE_DESCRIPTION #language en-US "MP Initialize Library instance for PEI driver." + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c new file mode 100644 index 0000000000..fb1d48fad8 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c @@ -0,0 +1,624 @@ +/** @file + MP initialize support functions for PEI phase. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "MpLib.h" +#include +#include + +// +// Global PEI notify function descriptor on EndofPei event +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMpInitLibNotifyList = { + (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiEndOfPeiSignalPpiGuid, + CpuMpEndOfPeiCallback +}; + + +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ) +{ +} + +/** + Get pointer to CPU MP Data structure. + + @return The pointer to CPU MP Data structure. +**/ +CPU_MP_DATA * +GetCpuMpData ( + VOID + ) +{ + CPU_MP_DATA *CpuMpData; + + CpuMpData = GetCpuMpDataFromGuidedHob (); + ASSERT (CpuMpData != NULL); + return CpuMpData; +} + +/** + Save the pointer to CPU MP Data structure. + + @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. +**/ +VOID +SaveCpuMpData ( + IN CPU_MP_DATA *CpuMpData + ) +{ + UINT64 Data64; + // + // Build location of CPU MP DATA buffer in HOB + // + Data64 = (UINT64) (UINTN) CpuMpData; + BuildGuidDataHob ( + &mCpuInitMpLibHobGuid, + (VOID *) &Data64, + sizeof (UINT64) + ); +} + +/** + Notify function on End Of PEI PPI. + + On S3 boot, this function will restore wakeup buffer data. + On normal boot, this function will flag wakeup buffer to be un-used type. + + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] NotifyDescriptor Address of the notification descriptor data structure. + @param[in] Ppi Address of the PPI that was installed. + + @retval EFI_SUCCESS When everything is OK. +**/ +EFI_STATUS +EFIAPI +CpuMpEndOfPeiCallback ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + CPU_MP_DATA *CpuMpData; + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_MEMORY_ALLOCATION *MemoryHob; + + DEBUG ((DEBUG_INFO, "PeiMpInitLib: CpuMpEndOfPeiCallback () invoked\n")); + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + CpuMpData = GetCpuMpData (); + if (BootMode != BOOT_ON_S3_RESUME) { + // + // Get the HOB list for processing + // + Hob.Raw = GetHobList (); + // + // Collect memory ranges + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) { + MemoryHob = Hob.MemoryAllocation; + if (MemoryHob->AllocDescriptor.MemoryBaseAddress == CpuMpData->WakeupBuffer) { + // + // Flag this HOB type to un-used + // + GET_HOB_TYPE (Hob) = EFI_HOB_TYPE_UNUSED; + break; + } + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + } else { + CpuMpData->SaveRestoreFlag = TRUE; + RestoreWakeupBuffer (CpuMpData); + } + return EFI_SUCCESS; +} + +/** + Check if AP wakeup buffer is overlapped with existing allocated buffer. + + @param[in] WakeupBufferStart AP wakeup buffer start address. + @param[in] WakeupBufferEnd AP wakeup buffer end address. + + @retval TRUE There is overlap. + @retval FALSE There is no overlap. +**/ +BOOLEAN +CheckOverlapWithAllocatedBuffer ( + IN UINTN WakeupBufferStart, + IN UINTN WakeupBufferEnd + ) +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_MEMORY_ALLOCATION *MemoryHob; + BOOLEAN Overlapped; + UINTN MemoryStart; + UINTN MemoryEnd; + + Overlapped = FALSE; + // + // Get the HOB list for processing + // + Hob.Raw = GetHobList (); + // + // Collect memory ranges + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) { + MemoryHob = Hob.MemoryAllocation; + MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress; + MemoryEnd = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress + + MemoryHob->AllocDescriptor.MemoryLength); + if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) { + Overlapped = TRUE; + break; + } + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return Overlapped; +} + +/** + Get available system memory below 1MB by specified size. + + @param[in] WakeupBufferSize Wakeup buffer size required + + @retval other Return wakeup buffer address below 1MB. + @retval -1 Cannot find free memory below 1MB. +**/ +UINTN +GetWakeupBuffer ( + IN UINTN WakeupBufferSize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN WakeupBufferStart; + UINTN WakeupBufferEnd; + + WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1); + + // + // Get the HOB list for processing + // + Hob.Raw = GetHobList (); + + // + // Collect memory ranges + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { + if ((Hob.ResourceDescriptor->PhysicalStart < BASE_1MB) && + (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) && + ((Hob.ResourceDescriptor->ResourceAttribute & + (EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | + EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | + EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED + )) == 0) + ) { + // + // Need memory under 1MB to be collected here + // + WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength); + if (WakeupBufferEnd > BASE_1MB) { + // + // Wakeup buffer should be under 1MB + // + WakeupBufferEnd = BASE_1MB; + } + while (WakeupBufferEnd > WakeupBufferSize) { + // + // Wakeup buffer should be aligned on 4KB + // + WakeupBufferStart = (WakeupBufferEnd - WakeupBufferSize) & ~(SIZE_4KB - 1); + if (WakeupBufferStart < Hob.ResourceDescriptor->PhysicalStart) { + break; + } + if (CheckOverlapWithAllocatedBuffer (WakeupBufferStart, WakeupBufferEnd)) { + // + // If this range is overlapped with existing allocated buffer, skip it + // and find the next range + // + WakeupBufferEnd -= WakeupBufferSize; + continue; + } + DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n", + WakeupBufferStart, WakeupBufferSize)); + // + // Create a memory allocation HOB. + // + BuildMemoryAllocationHob ( + WakeupBufferStart, + WakeupBufferSize, + EfiBootServicesData + ); + return WakeupBufferStart; + } + } + } + // + // Find the next HOB + // + Hob.Raw = GET_NEXT_HOB (Hob); + } + + return (UINTN) -1; +} + +/** + Allocate reset vector buffer. + + @param[in, out] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +AllocateResetVector ( + IN OUT CPU_MP_DATA *CpuMpData + ) +{ + UINTN ApResetVectorSize; + + if (CpuMpData->WakeupBuffer == (UINTN) -1) { + ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + + sizeof (MP_CPU_EXCHANGE_INFO); + + CpuMpData->WakeupBuffer = GetWakeupBuffer (ApResetVectorSize); + CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) + (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize); + BackupAndPrepareWakeupBuffer (CpuMpData); + } + + if (CpuMpData->SaveRestoreFlag) { + BackupAndPrepareWakeupBuffer (CpuMpData); + } +} + +/** + Free AP reset vector buffer. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +FreeResetVector ( + IN CPU_MP_DATA *CpuMpData + ) +{ + if (CpuMpData->SaveRestoreFlag) { + RestoreWakeupBuffer (CpuMpData); + } +} + +/** + Checks APs status and updates APs status if needed. + +**/ +VOID +CheckAndUpdateApsStatus ( + VOID + ) +{ +} + +/** + Initialize global data for MP support. + + @param[in] CpuMpData The pointer to CPU MP Data structure. +**/ +VOID +InitMpGlobalData ( + IN CPU_MP_DATA *CpuMpData + ) +{ + EFI_STATUS Status; + + SaveCpuMpData (CpuMpData); + + if (CpuMpData->CpuCount == 1) { + // + // If only BSP exists, return + // + return; + } + + // + // Register an event for EndOfPei + // + Status = PeiServicesNotifyPpi (&mMpInitLibNotifyList); + ASSERT_EFI_ERROR (Status); +} + +/** + This service executes a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] SingleThread If TRUE, then all the enabled APs execute + the function specified by Procedure one by + one, in ascending order of processor handle + number. If FALSE, then all the enabled APs + execute the function specified by Procedure + simultaneously. + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until all APs finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on all the enabled + APs, and go on executing immediately. If + all return from Procedure, or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + APs to return from Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + all APs return from Procedure, then Procedure + on the failed APs is terminated. All enabled + APs are available for next function assigned + by MpInitLibStartupAllAPs() or + MPInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure for + all APs. + @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, + if all APs finish successfully, then its + content is set to NULL. If not all APs + finish before timeout expires, then its + content is set to address of the buffer + holding handle numbers of the failed APs. + The buffer is allocated by MP Initialization + library, and it's the caller's responsibility to + free the buffer with FreePool() service. + In blocking mode, it is ready for consumption + when the call returns. In non-blocking mode, + it is ready when WaitEvent is signaled. The + list of failed CPU is terminated by + END_OF_CPU_LIST. + + @retval EFI_SUCCESS In blocking mode, all APs have finished before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been dispatched + to all enabled APs. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllAPs ( + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT UINTN **FailedCpuList OPTIONAL + ) +{ + if (WaitEvent != NULL) { + return EFI_UNSUPPORTED; + } + + return StartupAllAPsWorker ( + Procedure, + SingleThread, + NULL, + TimeoutInMicroseconds, + ProcedureArgument, + FailedCpuList + ); +} + +/** + This service lets the caller get one enabled AP to execute a caller-provided + function. + + @param[in] Procedure A pointer to the function to be run on the + designated AP of the system. See type + EFI_AP_PROCEDURE. + @param[in] ProcessorNumber The handle number of the AP. The range is + from 0 to the total number of logical + processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] WaitEvent The event created by the caller with CreateEvent() + service. If it is NULL, then execute in + blocking mode. BSP waits until this AP finish + or TimeoutInMicroSeconds expires. If it's + not NULL, then execute in non-blocking mode. + BSP requests the function specified by + Procedure to be started on this AP, + and go on executing immediately. If this AP + return from Procedure or TimeoutInMicroSeconds + expires, this event is signaled. The BSP + can use the CheckEvent() or WaitForEvent() + services to check the state of event. Type + EFI_EVENT is defined in CreateEvent() in + the Unified Extensible Firmware Interface + Specification. + @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for + this AP to finish this Procedure, either for + blocking or non-blocking mode. Zero means + infinity. If the timeout expires before + this AP returns from Procedure, then Procedure + on the AP is terminated. The + AP is available for next function assigned + by MpInitLibStartupAllAPs() or + MpInitLibStartupThisAP(). + If the timeout expires in blocking mode, + BSP returns EFI_TIMEOUT. If the timeout + expires in non-blocking mode, WaitEvent + is signaled with SignalEvent(). + @param[in] ProcedureArgument The parameter passed into Procedure on the + specified AP. + @param[out] Finished If NULL, this parameter is ignored. In + blocking mode, this parameter is ignored. + In non-blocking mode, if AP returns from + Procedure before the timeout expires, its + content is set to TRUE. Otherwise, the + value is set to FALSE. The caller can + determine if the AP returned from Procedure + by evaluating this value. + + @retval EFI_SUCCESS In blocking mode, specified AP finished before + the timeout expires. + @retval EFI_SUCCESS In non-blocking mode, the function has been + dispatched to specified AP. + @retval EFI_UNSUPPORTED A non-blocking mode request was made after the + UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was + signaled. + @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not + supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired before + the specified AP has finished. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupThisAP ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN EFI_EVENT WaitEvent OPTIONAL, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL, + OUT BOOLEAN *Finished OPTIONAL + ) +{ + if (WaitEvent != NULL) { + return EFI_UNSUPPORTED; + } + + return StartupThisAPWorker ( + Procedure, + ProcessorNumber, + NULL, + TimeoutInMicroseconds, + ProcedureArgument, + Finished + ); +} + +/** + This service switches the requested AP to be the BSP from that point onward. + This service changes the BSP for all purposes. This call can only be performed + by the current BSP. + + @param[in] ProcessorNumber The handle number of AP that is to become the new + BSP. The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an + enabled AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to + this service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or + a disabled AP. + @retval EFI_NOT_READY The specified AP is busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibSwitchBSP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + return SwitchBSPWorker (ProcessorNumber, EnableOldBSP); +} + +/** + This service lets the caller enable or disable an AP from this point onward. + This service may only be called from the BSP. + + @param[in] ProcessorNumber The handle number of AP. + The range is from 0 to the total number of + logical processors minus 1. The total number of + logical processors can be retrieved by + MpInitLibGetNumberOfProcessors(). + @param[in] EnableAP Specifies the new state for the processor for + enabled, FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that specifies + the new health status of the AP. This flag + corresponds to StatusFlag defined in + EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only + the PROCESSOR_HEALTH_STATUS_BIT is used. All other + bits are ignored. If it is NULL, this parameter + is ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed + prior to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + +**/ +EFI_STATUS +EFIAPI +MpInitLibEnableDisableAP ( + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); +} + + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc b/Core/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc new file mode 100644 index 0000000000..a63cd23a40 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc @@ -0,0 +1,43 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpEqu.inc +; +; Abstract: +; +; This is the equates file for Multiple Processor support +; +;------------------------------------------------------------------------------- + +VacantFlag equ 00h +NotVacantFlag equ 0ffh + +CPU_SWITCH_STATE_IDLE equ 0 +CPU_SWITCH_STATE_STORED equ 1 +CPU_SWITCH_STATE_LOADED equ 2 + +LockLocation equ (RendezvousFunnelProcEnd - RendezvousFunnelProcStart) +StackStartAddressLocation equ LockLocation + 08h +StackSizeLocation equ LockLocation + 10h +ApProcedureLocation equ LockLocation + 18h +GdtrLocation equ LockLocation + 20h +IdtrLocation equ LockLocation + 2Ah +BufferStartLocation equ LockLocation + 34h +ModeOffsetLocation equ LockLocation + 3Ch +NumApsExecutingLocation equ LockLocation + 44h +CodeSegmentLocation equ LockLocation + 4Ch +DataSegmentLocation equ LockLocation + 54h +EnableExecuteDisableLocation equ LockLocation + 5Ch +Cr3Location equ LockLocation + 64h +InitFlagLocation equ LockLocation + 6Ch +CpuInfoLocation equ LockLocation + 74h + diff --git a/Core/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/Core/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm new file mode 100644 index 0000000000..fa54d01542 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm @@ -0,0 +1,398 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.nasm +; +; Abstract: +; +; This is the assembly code for MP support +; +;------------------------------------------------------------------------------- + +%include "MpEqu.inc" +extern ASM_PFX(InitializeFloatingPointUnits) + +DEFAULT REL + +SECTION .text + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +global ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: +; At this point CS = 0x(vv00) and ip= 0x0. +; Save BIST information to ebp firstly + +BITS 16 + mov ebp, eax ; Save BIST information + + mov ax, cs + mov ds, ax + mov es, ax + mov ss, ax + xor ax, ax + mov fs, ax + mov gs, ax + + mov si, BufferStartLocation + mov ebx, [si] + + mov di, ModeOffsetLocation + mov eax, [di] + mov di, CodeSegmentLocation + mov edx, [di] + mov di, ax + sub di, 02h + mov [di],dx ; Patch long mode CS + sub di, 04h + add eax, ebx + mov [di],eax ; Patch address + + mov si, GdtrLocation +o32 lgdt [cs:si] + + mov si, IdtrLocation +o32 lidt [cs:si] + + mov si, EnableExecuteDisableLocation + cmp byte [si], 0 + jz SkipEnableExecuteDisableBit + + ; + ; Enable execute disable bit + ; + mov ecx, 0c0000080h ; EFER MSR number + rdmsr ; Read EFER + bts eax, 11 ; Enable Execute Disable Bit + wrmsr ; Write EFER + +SkipEnableExecuteDisableBit: + + mov di, DataSegmentLocation + mov edi, [di] ; Save long mode DS in edi + + mov si, Cr3Location ; Save CR3 in ecx + mov ecx, [si] + + xor ax, ax + mov ds, ax ; Clear data segment + + mov eax, cr0 ; Get control register 0 + or eax, 000000003h ; Set PE bit (bit #0) & MP + mov cr0, eax + + mov eax, cr4 + bts eax, 5 + mov cr4, eax + + mov cr3, ecx ; Load CR3 + + mov ecx, 0c0000080h ; EFER MSR number + rdmsr ; Read EFER + bts eax, 8 ; Set LME=1 + wrmsr ; Write EFER + + mov eax, cr0 ; Read CR0 + bts eax, 31 ; Set PG=1 + mov cr0, eax ; Write CR0 + + jmp 0:strict dword 0 ; far jump to long mode +BITS 64 +LongModeStart: + mov eax, edi + mov ds, ax + mov es, ax + mov ss, ax + + mov esi, ebx + lea edi, [esi + InitFlagLocation] + cmp qword [edi], 1 ; ApInitConfig + jnz GetApicId + + ; AP init + mov edi, esi + add edi, LockLocation + mov rax, NotVacantFlag + +TestLock: + xchg qword [edi], rax + cmp rax, NotVacantFlag + jz TestLock + + lea ecx, [esi + NumApsExecutingLocation] + inc dword [ecx] + mov ebx, [ecx] + +Releaselock: + mov rax, VacantFlag + xchg qword [edi], rax + ; program stack + mov edi, esi + add edi, StackSizeLocation + mov eax, dword [edi] + mov ecx, ebx + inc ecx + mul ecx ; EAX = StackSize * (CpuNumber + 1) + mov edi, esi + add edi, StackStartAddressLocation + add rax, qword [edi] + mov rsp, rax + jmp CProcedureInvoke + +GetApicId: + mov eax, 0 + cpuid + cmp eax, 0bh + jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY + + mov eax, 0bh + xor ecx, ecx + cpuid + test ebx, 0ffffh + jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero + + ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX + jmp GetProcessorNumber + +NoX2Apic: + ; Processor is not x2APIC capable, so get 8-bit APIC ID + mov eax, 1 + cpuid + shr ebx, 24 + mov edx, ebx + +GetProcessorNumber: + ; + ; Get processor number for this AP + ; Note that BSP may become an AP due to SwitchBsp() + ; + xor ebx, ebx + lea eax, [esi + CpuInfoLocation] + mov edi, [eax] + +GetNextProcNumber: + cmp dword [edi], edx ; APIC ID match? + jz ProgramStack + add edi, 20 + inc ebx + jmp GetNextProcNumber + +ProgramStack: + mov rsp, qword [edi + 12] + +CProcedureInvoke: + push rbp ; Push BIST data at top of AP stack + xor rbp, rbp ; Clear ebp for call stack trace + push rbp + mov rbp, rsp + + mov rax, ASM_PFX(InitializeFloatingPointUnits) + sub rsp, 20h + call rax ; Call assembly function to initialize FPU per UEFI spec + add rsp, 20h + + mov edx, ebx ; edx is NumApsExecuting + mov ecx, esi + add ecx, LockLocation ; rcx is address of exchange info data buffer + + mov edi, esi + add edi, ApProcedureLocation + mov rax, qword [edi] + + sub rsp, 20h + call rax ; Invoke C function + add rsp, 20h + jmp $ ; Should never reach here + +RendezvousFunnelProcEnd: + +;------------------------------------------------------------------------------------- +; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmRelocateApLoop) +ASM_PFX(AsmRelocateApLoop): +AsmRelocateApLoopStart: + mov rax, [rsp + 40] ; CountTofinish + lock dec dword [rax] ; (*CountTofinish)-- + mov rsp, r9 + push rcx + push rdx + + lea rsi, [PmEntry] ; rsi <- The start address of transition code + + push r8 + push rsi + DB 0x48 + retf +BITS 32 +PmEntry: + mov eax, cr0 + btr eax, 31 ; Clear CR0.PG + mov cr0, eax ; Disable paging and caches + + mov ebx, edx ; Save EntryPoint to rbx, for rdmsr will overwrite rdx + mov ecx, 0xc0000080 + rdmsr + and ah, ~ 1 ; Clear LME + wrmsr + mov eax, cr4 + and al, ~ (1 << 5) ; Clear PAE + mov cr4, eax + + pop edx + add esp, 4 + pop ecx, + add esp, 4 + cmp cl, 1 ; Check mwait-monitor support + jnz HltLoop + mov ebx, edx ; Save C-State to ebx +MwaitLoop: + mov eax, esp ; Set Monitor Address + xor ecx, ecx ; ecx = 0 + xor edx, edx ; edx = 0 + monitor + mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4] + shl eax, 4 + mwait + jmp MwaitLoop +HltLoop: + cli + hlt + jmp HltLoop +BITS 64 +AsmRelocateApLoopEnd: + +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + mov rax, ASM_PFX(RendezvousFunnelProc) + mov qword [rcx], rax + mov qword [rcx + 8h], LongModeStart - RendezvousFunnelProcStart + mov qword [rcx + 10h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + mov rax, ASM_PFX(AsmRelocateApLoop) + mov qword [rcx + 18h], rax + mov qword [rcx + 20h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart + ret + +;------------------------------------------------------------------------------------- +;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is +;about to become an AP. It switches its stack with the current AP. +;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmExchangeRole) +ASM_PFX(AsmExchangeRole): + ; DO NOT call other functions in this function, since 2 CPU may use 1 stack + ; at the same time. If 1 CPU try to call a function, stack will be corrupted. + + push rax + push rbx + push rcx + push rdx + push rsi + push rdi + push rbp + push r8 + push r9 + push r10 + push r11 + push r12 + push r13 + push r14 + push r15 + + mov rax, cr0 + push rax + + mov rax, cr4 + push rax + + ; rsi contains MyInfo pointer + mov rsi, rcx + + ; rdi contains OthersInfo pointer + mov rdi, rdx + + ;Store EFLAGS, GDTR and IDTR regiter to stack + pushfq + sgdt [rsi + 16] + sidt [rsi + 26] + + ; Store the its StackPointer + mov [rsi + 8], rsp + + ; update its switch state to STORED + mov byte [rsi], CPU_SWITCH_STATE_STORED + +WaitForOtherStored: + ; wait until the other CPU finish storing its state + cmp byte [rdi], CPU_SWITCH_STATE_STORED + jz OtherStored + pause + jmp WaitForOtherStored + +OtherStored: + ; Since another CPU already stored its state, load them + ; load GDTR value + lgdt [rdi + 16] + + ; load IDTR value + lidt [rdi + 26] + + ; load its future StackPointer + mov rsp, [rdi + 8] + + ; update the other CPU's switch state to LOADED + mov byte [rdi], CPU_SWITCH_STATE_LOADED + +WaitForOtherLoaded: + ; wait until the other CPU finish loading new state, + ; otherwise the data in stack may corrupt + cmp byte [rsi], CPU_SWITCH_STATE_LOADED + jz OtherLoaded + pause + jmp WaitForOtherLoaded + +OtherLoaded: + ; since the other CPU already get the data it want, leave this procedure + popfq + + pop rax + mov cr4, rax + + pop rax + mov cr0, rax + + pop r15 + pop r14 + pop r13 + pop r12 + pop r11 + pop r10 + pop r9 + pop r8 + pop rbp + pop rdi + pop rsi + pop rdx + pop rcx + pop rbx + pop rax + + ret diff --git a/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.c new file mode 100644 index 0000000000..c38191a7ef --- /dev/null +++ b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -0,0 +1,2441 @@ +/** @file + MTRR setting library + + @par Note: + Most of services in this library instance are suggested to be invoked by BSP only, + except for MtrrSetAllMtrrs() which is used to sync BSP's MTRR setting to APs. + + Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#define OR_SEED 0x0101010101010101ull +#define CLEAR_SEED 0xFFFFFFFFFFFFFFFFull + +#define MTRR_LIB_ASSERT_ALIGNED(B, L) ASSERT ((B & ~(L - 1)) == B); +// +// Context to save and restore when MTRRs are programmed +// +typedef struct { + UINTN Cr4; + BOOLEAN InterruptState; +} MTRR_CONTEXT; + +typedef struct { + UINT64 BaseAddress; + UINT64 Length; + MTRR_MEMORY_CACHE_TYPE Type; +} MEMORY_RANGE; + +// +// This table defines the offset, base and length of the fixed MTRRs +// +CONST FIXED_MTRR mMtrrLibFixedMtrrTable[] = { + { + MSR_IA32_MTRR_FIX64K_00000, + 0, + SIZE_64KB + }, + { + MSR_IA32_MTRR_FIX16K_80000, + 0x80000, + SIZE_16KB + }, + { + MSR_IA32_MTRR_FIX16K_A0000, + 0xA0000, + SIZE_16KB + }, + { + MSR_IA32_MTRR_FIX4K_C0000, + 0xC0000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_C8000, + 0xC8000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_D0000, + 0xD0000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_D8000, + 0xD8000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_E0000, + 0xE0000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_E8000, + 0xE8000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_F0000, + 0xF0000, + SIZE_4KB + }, + { + MSR_IA32_MTRR_FIX4K_F8000, + 0xF8000, + SIZE_4KB + } +}; + +// +// Lookup table used to print MTRRs +// +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mMtrrMemoryCacheTypeShortName[] = { + "UC", // CacheUncacheable + "WC", // CacheWriteCombining + "R*", // Invalid + "R*", // Invalid + "WT", // CacheWriteThrough + "WP", // CacheWriteProtected + "WB", // CacheWriteBack + "R*" // Invalid +}; + +/** + Worker function returns the variable MTRR count for the CPU. + + @return Variable MTRR count + +**/ +UINT32 +GetVariableMtrrCountWorker ( + VOID + ) +{ + MSR_IA32_MTRRCAP_REGISTER MtrrCap; + + MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); + ASSERT (MtrrCap.Bits.VCNT <= MTRR_NUMBER_OF_VARIABLE_MTRR); + return MtrrCap.Bits.VCNT; +} + +/** + Returns the variable MTRR count for the CPU. + + @return Variable MTRR count + +**/ +UINT32 +EFIAPI +GetVariableMtrrCount ( + VOID + ) +{ + if (!IsMtrrSupported ()) { + return 0; + } + return GetVariableMtrrCountWorker (); +} + +/** + Worker function returns the firmware usable variable MTRR count for the CPU. + + @return Firmware usable variable MTRR count + +**/ +UINT32 +GetFirmwareVariableMtrrCountWorker ( + VOID + ) +{ + UINT32 VariableMtrrCount; + UINT32 ReservedMtrrNumber; + + VariableMtrrCount = GetVariableMtrrCountWorker (); + ReservedMtrrNumber = PcdGet32 (PcdCpuNumberOfReservedVariableMtrrs); + if (VariableMtrrCount < ReservedMtrrNumber) { + return 0; + } + + return VariableMtrrCount - ReservedMtrrNumber; +} + +/** + Returns the firmware usable variable MTRR count for the CPU. + + @return Firmware usable variable MTRR count + +**/ +UINT32 +EFIAPI +GetFirmwareVariableMtrrCount ( + VOID + ) +{ + if (!IsMtrrSupported ()) { + return 0; + } + return GetFirmwareVariableMtrrCountWorker (); +} + +/** + Worker function returns the default MTRR cache type for the system. + + If MtrrSetting is not NULL, returns the default MTRR cache type from input + MTRR settings buffer. + If MtrrSetting is NULL, returns the default MTRR cache type from MSR. + + @param[in] MtrrSetting A buffer holding all MTRRs content. + + @return The default MTRR cache type. + +**/ +MTRR_MEMORY_CACHE_TYPE +MtrrGetDefaultMemoryTypeWorker ( + IN MTRR_SETTINGS *MtrrSetting + ) +{ + MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; + + if (MtrrSetting == NULL) { + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + } else { + DefType.Uint64 = MtrrSetting->MtrrDefType; + } + + return (MTRR_MEMORY_CACHE_TYPE) DefType.Bits.Type; +} + + +/** + Returns the default MTRR cache type for the system. + + @return The default MTRR cache type. + +**/ +MTRR_MEMORY_CACHE_TYPE +EFIAPI +MtrrGetDefaultMemoryType ( + VOID + ) +{ + if (!IsMtrrSupported ()) { + return CacheUncacheable; + } + return MtrrGetDefaultMemoryTypeWorker (NULL); +} + +/** + Preparation before programming MTRR. + + This function will do some preparation for programming MTRRs: + disable cache, invalid cache and disable MTRR caching functionality + + @param[out] MtrrContext Pointer to context to save + +**/ +VOID +MtrrLibPreMtrrChange ( + OUT MTRR_CONTEXT *MtrrContext + ) +{ + MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; + // + // Disable interrupts and save current interrupt state + // + MtrrContext->InterruptState = SaveAndDisableInterrupts(); + + // + // Enter no fill cache mode, CD=1(Bit30), NW=0 (Bit29) + // + AsmDisableCache (); + + // + // Save original CR4 value and clear PGE flag (Bit 7) + // + MtrrContext->Cr4 = AsmReadCr4 (); + AsmWriteCr4 (MtrrContext->Cr4 & (~BIT7)); + + // + // Flush all TLBs + // + CpuFlushTlb (); + + // + // Disable MTRRs + // + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + DefType.Bits.E = 0; + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); +} + +/** + Cleaning up after programming MTRRs. + + This function will do some clean up after programming MTRRs: + Flush all TLBs, re-enable caching, restore CR4. + + @param[in] MtrrContext Pointer to context to restore + +**/ +VOID +MtrrLibPostMtrrChangeEnableCache ( + IN MTRR_CONTEXT *MtrrContext + ) +{ + // + // Flush all TLBs + // + CpuFlushTlb (); + + // + // Enable Normal Mode caching CD=NW=0, CD(Bit30), NW(Bit29) + // + AsmEnableCache (); + + // + // Restore original CR4 value + // + AsmWriteCr4 (MtrrContext->Cr4); + + // + // Restore original interrupt state + // + SetInterruptState (MtrrContext->InterruptState); +} + +/** + Cleaning up after programming MTRRs. + + This function will do some clean up after programming MTRRs: + enable MTRR caching functionality, and enable cache + + @param[in] MtrrContext Pointer to context to restore + +**/ +VOID +MtrrLibPostMtrrChange ( + IN MTRR_CONTEXT *MtrrContext + ) +{ + MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; + // + // Enable Cache MTRR + // + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + DefType.Bits.E = 1; + DefType.Bits.FE = 1; + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); + + MtrrLibPostMtrrChangeEnableCache (MtrrContext); +} + +/** + Worker function gets the content in fixed MTRRs + + @param[out] FixedSettings A buffer to hold fixed MTRRs content. + + @retval The pointer of FixedSettings + +**/ +MTRR_FIXED_SETTINGS* +MtrrGetFixedMtrrWorker ( + OUT MTRR_FIXED_SETTINGS *FixedSettings + ) +{ + UINT32 Index; + + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + FixedSettings->Mtrr[Index] = + AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr); + } + + return FixedSettings; +} + + +/** + This function gets the content in fixed MTRRs + + @param[out] FixedSettings A buffer to hold fixed MTRRs content. + + @retval The pointer of FixedSettings + +**/ +MTRR_FIXED_SETTINGS* +EFIAPI +MtrrGetFixedMtrr ( + OUT MTRR_FIXED_SETTINGS *FixedSettings + ) +{ + if (!IsMtrrSupported ()) { + return FixedSettings; + } + + return MtrrGetFixedMtrrWorker (FixedSettings); +} + + +/** + Worker function will get the raw value in variable MTRRs + + If MtrrSetting is not NULL, gets the variable MTRRs raw value from input + MTRR settings buffer. + If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. + + @param[in] MtrrSetting A buffer holding all MTRRs content. + @param[in] VariableMtrrCount Number of variable MTRRs. + @param[out] VariableSettings A buffer to hold variable MTRRs content. + + @return The VariableSettings input pointer + +**/ +MTRR_VARIABLE_SETTINGS* +MtrrGetVariableMtrrWorker ( + IN MTRR_SETTINGS *MtrrSetting, + IN UINT32 VariableMtrrCount, + OUT MTRR_VARIABLE_SETTINGS *VariableSettings + ) +{ + UINT32 Index; + + ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); + + for (Index = 0; Index < VariableMtrrCount; Index++) { + if (MtrrSetting == NULL) { + VariableSettings->Mtrr[Index].Base = + AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1)); + VariableSettings->Mtrr[Index].Mask = + AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1)); + } else { + VariableSettings->Mtrr[Index].Base = MtrrSetting->Variables.Mtrr[Index].Base; + VariableSettings->Mtrr[Index].Mask = MtrrSetting->Variables.Mtrr[Index].Mask; + } + } + + return VariableSettings; +} + +/** + This function will get the raw value in variable MTRRs + + @param[out] VariableSettings A buffer to hold variable MTRRs content. + + @return The VariableSettings input pointer + +**/ +MTRR_VARIABLE_SETTINGS* +EFIAPI +MtrrGetVariableMtrr ( + OUT MTRR_VARIABLE_SETTINGS *VariableSettings + ) +{ + if (!IsMtrrSupported ()) { + return VariableSettings; + } + + return MtrrGetVariableMtrrWorker ( + NULL, + GetVariableMtrrCountWorker (), + VariableSettings + ); +} + +/** + Programs fixed MTRRs registers. + + @param[in] Type The memory type to set. + @param[in, out] Base The base address of memory range. + @param[in, out] Length The length of memory range. + @param[in, out] LastMsrNum On input, the last index of the fixed MTRR MSR to program. + On return, the current index of the fixed MTRR MSR to program. + @param[out] ReturnClearMask The bits to clear in the fixed MTRR MSR. + @param[out] ReturnOrMask The bits to set in the fixed MTRR MSR. + + @retval RETURN_SUCCESS The cache type was updated successfully + @retval RETURN_UNSUPPORTED The requested range or cache type was invalid + for the fixed MTRRs. + +**/ +RETURN_STATUS +MtrrLibProgramFixedMtrr ( + IN MTRR_MEMORY_CACHE_TYPE Type, + IN OUT UINT64 *Base, + IN OUT UINT64 *Length, + IN OUT UINT32 *LastMsrNum, + OUT UINT64 *ReturnClearMask, + OUT UINT64 *ReturnOrMask + ) +{ + UINT32 MsrNum; + UINT32 LeftByteShift; + UINT32 RightByteShift; + UINT64 OrMask; + UINT64 ClearMask; + UINT64 SubLength; + + // + // Find the fixed MTRR index to be programmed + // + for (MsrNum = *LastMsrNum + 1; MsrNum < MTRR_NUMBER_OF_FIXED_MTRR; MsrNum++) { + if ((*Base >= mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) && + (*Base < + ( + mMtrrLibFixedMtrrTable[MsrNum].BaseAddress + + (8 * mMtrrLibFixedMtrrTable[MsrNum].Length) + ) + ) + ) { + break; + } + } + + if (MsrNum == MTRR_NUMBER_OF_FIXED_MTRR) { + return RETURN_UNSUPPORTED; + } + + // + // Find the begin offset in fixed MTRR and calculate byte offset of left shift + // + LeftByteShift = ((UINT32)*Base - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) + / mMtrrLibFixedMtrrTable[MsrNum].Length; + + if (LeftByteShift >= 8) { + return RETURN_UNSUPPORTED; + } + + // + // Find the end offset in fixed MTRR and calculate byte offset of right shift + // + SubLength = mMtrrLibFixedMtrrTable[MsrNum].Length * (8 - LeftByteShift); + if (*Length >= SubLength) { + RightByteShift = 0; + } else { + RightByteShift = 8 - LeftByteShift - + (UINT32)(*Length) / mMtrrLibFixedMtrrTable[MsrNum].Length; + if ((LeftByteShift >= 8) || + (((UINT32)(*Length) % mMtrrLibFixedMtrrTable[MsrNum].Length) != 0) + ) { + return RETURN_UNSUPPORTED; + } + // + // Update SubLength by actual length + // + SubLength = *Length; + } + + ClearMask = CLEAR_SEED; + OrMask = MultU64x32 (OR_SEED, (UINT32) Type); + + if (LeftByteShift != 0) { + // + // Clear the low bits by LeftByteShift + // + ClearMask &= LShiftU64 (ClearMask, LeftByteShift * 8); + OrMask &= LShiftU64 (OrMask, LeftByteShift * 8); + } + + if (RightByteShift != 0) { + // + // Clear the high bits by RightByteShift + // + ClearMask &= RShiftU64 (ClearMask, RightByteShift * 8); + OrMask &= RShiftU64 (OrMask, RightByteShift * 8); + } + + *Length -= SubLength; + *Base += SubLength; + + *LastMsrNum = MsrNum; + *ReturnClearMask = ClearMask; + *ReturnOrMask = OrMask; + + return RETURN_SUCCESS; +} + + +/** + Worker function gets the attribute of variable MTRRs. + + This function shadows the content of variable MTRRs into an + internal array: VariableMtrr. + + @param[in] VariableSettings The variable MTRR values to shadow + @param[in] VariableMtrrCount The number of variable MTRRs + @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[in] MtrrValidAddressMask The valid address mask for MTRR + @param[out] VariableMtrr The array to shadow variable MTRRs content + + @return Number of MTRRs which has been used. + +**/ +UINT32 +MtrrGetMemoryAttributeInVariableMtrrWorker ( + IN MTRR_VARIABLE_SETTINGS *VariableSettings, + IN UINTN VariableMtrrCount, + IN UINT64 MtrrValidBitsMask, + IN UINT64 MtrrValidAddressMask, + OUT VARIABLE_MTRR *VariableMtrr + ) +{ + UINTN Index; + UINT32 UsedMtrr; + + ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * MTRR_NUMBER_OF_VARIABLE_MTRR); + for (Index = 0, UsedMtrr = 0; Index < VariableMtrrCount; Index++) { + if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *) &VariableSettings->Mtrr[Index].Mask)->Bits.V != 0) { + VariableMtrr[Index].Msr = (UINT32)Index; + VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base & MtrrValidAddressMask); + VariableMtrr[Index].Length = ((~(VariableSettings->Mtrr[Index].Mask & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1; + VariableMtrr[Index].Type = (VariableSettings->Mtrr[Index].Base & 0x0ff); + VariableMtrr[Index].Valid = TRUE; + VariableMtrr[Index].Used = TRUE; + UsedMtrr++; + } + } + return UsedMtrr; +} + + +/** + Gets the attribute of variable MTRRs. + + This function shadows the content of variable MTRRs into an + internal array: VariableMtrr. + + @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[in] MtrrValidAddressMask The valid address mask for MTRR + @param[out] VariableMtrr The array to shadow variable MTRRs content + + @return The return value of this parameter indicates the + number of MTRRs which has been used. + +**/ +UINT32 +EFIAPI +MtrrGetMemoryAttributeInVariableMtrr ( + IN UINT64 MtrrValidBitsMask, + IN UINT64 MtrrValidAddressMask, + OUT VARIABLE_MTRR *VariableMtrr + ) +{ + MTRR_VARIABLE_SETTINGS VariableSettings; + + if (!IsMtrrSupported ()) { + return 0; + } + + MtrrGetVariableMtrrWorker ( + NULL, + GetVariableMtrrCountWorker (), + &VariableSettings + ); + + return MtrrGetMemoryAttributeInVariableMtrrWorker ( + &VariableSettings, + GetFirmwareVariableMtrrCountWorker (), + MtrrValidBitsMask, + MtrrValidAddressMask, + VariableMtrr + ); +} + +/** + Return the least alignment of address. + + @param Address The address to return the alignment. + @param Alignment0 The alignment to return when Address is 0. + + @return The least alignment of the Address. +**/ +UINT64 +MtrrLibLeastAlignment ( + UINT64 Address, + UINT64 Alignment0 +) +{ + if (Address == 0) { + return Alignment0; + } + + return LShiftU64 (1, (UINTN) LowBitSet64 (Address)); +} + +/** + Return the number of required variable MTRRs to positively cover the + specified range. + + @param BaseAddress Base address of the range. + @param Length Length of the range. + @param Alignment0 Alignment of 0. + + @return The number of the required variable MTRRs. +**/ +UINT32 +MtrrLibGetPositiveMtrrNumber ( + IN UINT64 BaseAddress, + IN UINT64 Length, + IN UINT64 Alignment0 +) +{ + UINT64 SubLength; + UINT32 MtrrNumber; + BOOLEAN UseLeastAlignment; + + UseLeastAlignment = TRUE; + SubLength = 0; + + // + // Calculate the alignment of the base address. + // + for (MtrrNumber = 0; Length != 0; MtrrNumber++) { + if (UseLeastAlignment) { + SubLength = MtrrLibLeastAlignment (BaseAddress, Alignment0); + + if (SubLength > Length) { + // + // Set a flag when remaining length is too small + // so that MtrrLibLeastAlignment() is not called in following loops. + // + UseLeastAlignment = FALSE; + } + } + + if (!UseLeastAlignment) { + SubLength = GetPowerOfTwo64 (Length); + } + + BaseAddress += SubLength; + Length -= SubLength; + } + + return MtrrNumber; +} + +/** + Return whether the left MTRR type precedes the right MTRR type. + + The MTRR type precedence rules are: + 1. UC precedes any other type + 2. WT precedes WB + For further details, please refer the IA32 Software Developer's Manual, + Volume 3, Section "MTRR Precedences". + + @param Left The left MTRR type. + @param Right The right MTRR type. + + @retval TRUE Left precedes Right. + @retval FALSE Left doesn't precede Right. +**/ +BOOLEAN +MtrrLibTypeLeftPrecedeRight ( + IN MTRR_MEMORY_CACHE_TYPE Left, + IN MTRR_MEMORY_CACHE_TYPE Right +) +{ + return (BOOLEAN) (Left == CacheUncacheable || (Left == CacheWriteThrough && Right == CacheWriteBack)); +} + + +/** + Return whether the type of the specified range can precede the specified type. + + @param Ranges Memory range array holding memory type settings for all + the memory address. + @param RangeCount Count of memory ranges. + @param Type Type to check precedence. + @param SubBase Base address of the specified range. + @param SubLength Length of the specified range. + + @retval TRUE The type of the specified range can precede the Type. + @retval FALSE The type of the specified range cannot precede the Type. + So the subtraction is not applicable. +**/ +BOOLEAN +MtrrLibSubstractable ( + IN CONST MEMORY_RANGE *Ranges, + IN UINT32 RangeCount, + IN MTRR_MEMORY_CACHE_TYPE Type, + IN UINT64 SubBase, + IN UINT64 SubLength +) +{ + UINT32 Index; + UINT64 Length; + // WT > WB + // UC > * + for (Index = 0; Index < RangeCount; Index++) { + if (Ranges[Index].BaseAddress <= SubBase && SubBase < Ranges[Index].BaseAddress + Ranges[Index].Length) { + + if (Ranges[Index].BaseAddress + Ranges[Index].Length >= SubBase + SubLength) { + return MtrrLibTypeLeftPrecedeRight (Ranges[Index].Type, Type); + + } else { + if (!MtrrLibTypeLeftPrecedeRight (Ranges[Index].Type, Type)) { + return FALSE; + } + + Length = Ranges[Index].BaseAddress + Ranges[Index].Length - SubBase; + SubBase += Length; + SubLength -= Length; + } + } + } + + ASSERT (FALSE); + return FALSE; +} + +/** + Return the number of required variable MTRRs to cover the specified range. + + The routine considers subtraction in the both side of the range to find out + the most optimal solution (which uses the least MTRRs). + + @param Ranges Array holding memory type settings of all memory + address. + @param RangeCount Count of memory ranges. + @param VariableMtrr Array holding allocated variable MTRRs. + @param VariableMtrrCount Count of allocated variable MTRRs. + @param BaseAddress Base address of the specified range. + @param Length Length of the specified range. + @param Type MTRR type of the specified range. + @param Alignment0 Alignment of 0. + @param SubLeft Return the count of left subtraction. + @param SubRight Return the count of right subtraction. + + @return Number of required variable MTRRs. +**/ +UINT32 +MtrrLibGetMtrrNumber ( + IN CONST MEMORY_RANGE *Ranges, + IN UINT32 RangeCount, + IN CONST VARIABLE_MTRR *VariableMtrr, + IN UINT32 VariableMtrrCount, + IN UINT64 BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type, + IN UINT64 Alignment0, + OUT UINT32 *SubLeft, // subtractive from BaseAddress to get more aligned address, to save MTRR + OUT UINT32 *SubRight // subtractive from BaseAddress + Length, to save MTRR + ) +{ + UINT64 Alignment; + UINT32 LeastLeftMtrrNumber; + UINT32 MiddleMtrrNumber; + UINT32 LeastRightMtrrNumber; + UINT32 CurrentMtrrNumber; + UINT32 SubtractiveCount; + UINT32 SubtractiveMtrrNumber; + UINT32 LeastSubtractiveMtrrNumber; + UINT64 SubtractiveBaseAddress; + UINT64 SubtractiveLength; + UINT64 BaseAlignment; + UINT32 Index; + + *SubLeft = 0; + *SubRight = 0; + LeastSubtractiveMtrrNumber = 0; + BaseAlignment = 0; + + // + // Get the optimal left subtraction solution. + // + if (BaseAddress != 0) { + SubtractiveBaseAddress = 0; + SubtractiveLength = 0; + // + // Get the MTRR number needed without left subtraction. + // + LeastLeftMtrrNumber = MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); + + // + // Left subtraction bit by bit, to find the optimal left subtraction solution. + // + for (SubtractiveMtrrNumber = 0, SubtractiveCount = 1; BaseAddress != 0; SubtractiveCount++) { + Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); + + // + // Check whether the memory type of [BaseAddress - Alignment, BaseAddress) can override Type. + // IA32 Manual defines the following override rules: + // WT > WB + // UC > * (any) + // + if (!MtrrLibSubstractable (Ranges, RangeCount, Type, BaseAddress - Alignment, Alignment)) { + break; + } + + for (Index = 0; Index < VariableMtrrCount; Index++) { + if ((VariableMtrr[Index].BaseAddress == BaseAddress - Alignment) && + (VariableMtrr[Index].Length == Alignment)) { + break; + } + } + if (Index == VariableMtrrCount) { + // + // Increment SubtractiveMtrrNumber when [BaseAddress - Alignment, BaseAddress) is not be planed as a MTRR + // + SubtractiveMtrrNumber++; + } + + BaseAddress -= Alignment; + Length += Alignment; + + CurrentMtrrNumber = SubtractiveMtrrNumber + MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); + if (CurrentMtrrNumber <= LeastLeftMtrrNumber) { + LeastLeftMtrrNumber = CurrentMtrrNumber; + LeastSubtractiveMtrrNumber = SubtractiveMtrrNumber; + *SubLeft = SubtractiveCount; + SubtractiveBaseAddress = BaseAddress; + SubtractiveLength = Length; + } + } + + // + // If left subtraction is better, subtract BaseAddress to left, and enlarge Length + // + if (*SubLeft != 0) { + BaseAddress = SubtractiveBaseAddress; + Length = SubtractiveLength; + } + } + + // + // Increment BaseAddress greedily until (BaseAddress + Alignment) exceeds (BaseAddress + Length) + // + MiddleMtrrNumber = 0; + while (Length != 0) { + BaseAlignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); + if (BaseAlignment > Length) { + break; + } + BaseAddress += BaseAlignment; + Length -= BaseAlignment; + MiddleMtrrNumber++; + } + + + if (Length == 0) { + return LeastSubtractiveMtrrNumber + MiddleMtrrNumber; + } + + + // + // Get the optimal right subtraction solution. + // + + // + // Get the MTRR number needed without right subtraction. + // + LeastRightMtrrNumber = MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); + + for (SubtractiveCount = 1; Length < BaseAlignment; SubtractiveCount++) { + Alignment = MtrrLibLeastAlignment (BaseAddress + Length, Alignment0); + if (!MtrrLibSubstractable (Ranges, RangeCount, Type, BaseAddress + Length, Alignment)) { + break; + } + + Length += Alignment; + + // + // SubtractiveCount = Number of MTRRs used for subtraction + // + CurrentMtrrNumber = SubtractiveCount + MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); + if (CurrentMtrrNumber <= LeastRightMtrrNumber) { + LeastRightMtrrNumber = CurrentMtrrNumber; + *SubRight = SubtractiveCount; + SubtractiveLength = Length; + } + } + + return LeastSubtractiveMtrrNumber + MiddleMtrrNumber + LeastRightMtrrNumber; +} + +/** + Initializes the valid bits mask and valid address mask for MTRRs. + + This function initializes the valid bits mask and valid address mask for MTRRs. + + @param[out] MtrrValidBitsMask The mask for the valid bit of the MTRR + @param[out] MtrrValidAddressMask The valid address mask for the MTRR + +**/ +VOID +MtrrLibInitializeMtrrMask ( + OUT UINT64 *MtrrValidBitsMask, + OUT UINT64 *MtrrValidAddressMask + ) +{ + UINT32 MaxExtendedFunction; + CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize; + + + AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NULL); + + if (MaxExtendedFunction >= CPUID_VIR_PHY_ADDRESS_SIZE) { + AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &VirPhyAddressSize.Uint32, NULL, NULL, NULL); + } else { + VirPhyAddressSize.Bits.PhysicalAddressBits = 36; + } + + *MtrrValidBitsMask = LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalAddressBits) - 1; + *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL; +} + + +/** + Determines the real attribute of a memory range. + + This function is to arbitrate the real attribute of the memory when + there are 2 MTRRs covers the same memory range. For further details, + please refer the IA32 Software Developer's Manual, Volume 3, + Section "MTRR Precedences". + + @param[in] MtrrType1 The first kind of Memory type + @param[in] MtrrType2 The second kind of memory type + +**/ +MTRR_MEMORY_CACHE_TYPE +MtrrLibPrecedence ( + IN MTRR_MEMORY_CACHE_TYPE MtrrType1, + IN MTRR_MEMORY_CACHE_TYPE MtrrType2 + ) +{ + if (MtrrType1 == MtrrType2) { + return MtrrType1; + } + + ASSERT ( + MtrrLibTypeLeftPrecedeRight (MtrrType1, MtrrType2) || + MtrrLibTypeLeftPrecedeRight (MtrrType2, MtrrType1) + ); + + if (MtrrLibTypeLeftPrecedeRight (MtrrType1, MtrrType2)) { + return MtrrType1; + } else { + return MtrrType2; + } +} + +/** + Worker function will get the memory cache type of the specific address. + + If MtrrSetting is not NULL, gets the memory cache type from input + MTRR settings buffer. + If MtrrSetting is NULL, gets the memory cache type from MTRRs. + + @param[in] MtrrSetting A buffer holding all MTRRs content. + @param[in] Address The specific address + + @return Memory cache type of the specific address + +**/ +MTRR_MEMORY_CACHE_TYPE +MtrrGetMemoryAttributeByAddressWorker ( + IN MTRR_SETTINGS *MtrrSetting, + IN PHYSICAL_ADDRESS Address + ) +{ + MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; + UINT64 FixedMtrr; + UINTN Index; + UINTN SubIndex; + MTRR_MEMORY_CACHE_TYPE MtrrType; + VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; + UINT64 MtrrValidBitsMask; + UINT64 MtrrValidAddressMask; + UINT32 VariableMtrrCount; + MTRR_VARIABLE_SETTINGS VariableSettings; + + // + // Check if MTRR is enabled, if not, return UC as attribute + // + if (MtrrSetting == NULL) { + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + } else { + DefType.Uint64 = MtrrSetting->MtrrDefType; + } + + if (DefType.Bits.E == 0) { + return CacheUncacheable; + } + + // + // If address is less than 1M, then try to go through the fixed MTRR + // + if (Address < BASE_1MB) { + if (DefType.Bits.FE != 0) { + // + // Go through the fixed MTRR + // + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + if (Address >= mMtrrLibFixedMtrrTable[Index].BaseAddress && + Address < mMtrrLibFixedMtrrTable[Index].BaseAddress + + (mMtrrLibFixedMtrrTable[Index].Length * 8)) { + SubIndex = + ((UINTN) Address - mMtrrLibFixedMtrrTable[Index].BaseAddress) / + mMtrrLibFixedMtrrTable[Index].Length; + if (MtrrSetting == NULL) { + FixedMtrr = AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr); + } else { + FixedMtrr = MtrrSetting->Fixed.Mtrr[Index]; + } + return (MTRR_MEMORY_CACHE_TYPE) (RShiftU64 (FixedMtrr, SubIndex * 8) & 0xFF); + } + } + } + } + + VariableMtrrCount = GetVariableMtrrCountWorker (); + ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); + MtrrGetVariableMtrrWorker (MtrrSetting, VariableMtrrCount, &VariableSettings); + + MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); + MtrrGetMemoryAttributeInVariableMtrrWorker ( + &VariableSettings, + VariableMtrrCount, + MtrrValidBitsMask, + MtrrValidAddressMask, + VariableMtrr + ); + + // + // Go through the variable MTRR + // + MtrrType = CacheInvalid; + for (Index = 0; Index < VariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid) { + if (Address >= VariableMtrr[Index].BaseAddress && + Address < VariableMtrr[Index].BaseAddress + VariableMtrr[Index].Length) { + if (MtrrType == CacheInvalid) { + MtrrType = (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type; + } else { + MtrrType = MtrrLibPrecedence (MtrrType, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type); + } + } + } + } + + // + // If there is no MTRR which covers the Address, use the default MTRR type. + // + if (MtrrType == CacheInvalid) { + MtrrType = (MTRR_MEMORY_CACHE_TYPE) DefType.Bits.Type; + } + + return MtrrType; +} + + +/** + This function will get the memory cache type of the specific address. + + This function is mainly for debug purpose. + + @param[in] Address The specific address + + @return Memory cache type of the specific address + +**/ +MTRR_MEMORY_CACHE_TYPE +EFIAPI +MtrrGetMemoryAttribute ( + IN PHYSICAL_ADDRESS Address + ) +{ + if (!IsMtrrSupported ()) { + return CacheUncacheable; + } + + return MtrrGetMemoryAttributeByAddressWorker (NULL, Address); +} + +/** + Worker function prints all MTRRs for debugging. + + If MtrrSetting is not NULL, print MTRR settings from input MTRR + settings buffer. + If MtrrSetting is NULL, print MTRR settings from MTRRs. + + @param MtrrSetting A buffer holding all MTRRs content. +**/ +VOID +MtrrDebugPrintAllMtrrsWorker ( + IN MTRR_SETTINGS *MtrrSetting + ) +{ + DEBUG_CODE ( + MTRR_SETTINGS LocalMtrrs; + MTRR_SETTINGS *Mtrrs; + UINTN Index; + UINTN Index1; + UINTN VariableMtrrCount; + UINT64 Base; + UINT64 Limit; + UINT64 MtrrBase; + UINT64 MtrrLimit; + UINT64 RangeBase; + UINT64 RangeLimit; + UINT64 NoRangeBase; + UINT64 NoRangeLimit; + UINT32 RegEax; + UINTN MemoryType; + UINTN PreviousMemoryType; + BOOLEAN Found; + + if (!IsMtrrSupported ()) { + return; + } + + DEBUG((DEBUG_CACHE, "MTRR Settings\n")); + DEBUG((DEBUG_CACHE, "=============\n")); + + if (MtrrSetting != NULL) { + Mtrrs = MtrrSetting; + } else { + MtrrGetAllMtrrs (&LocalMtrrs); + Mtrrs = &LocalMtrrs; + } + + DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType)); + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + DEBUG((DEBUG_CACHE, "Fixed MTRR[%02d] : %016lx\n", Index, Mtrrs->Fixed.Mtrr[Index])); + } + + VariableMtrrCount = GetVariableMtrrCount (); + for (Index = 0; Index < VariableMtrrCount; Index++) { + DEBUG((DEBUG_CACHE, "Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n", + Index, + Mtrrs->Variables.Mtrr[Index].Base, + Mtrrs->Variables.Mtrr[Index].Mask + )); + } + DEBUG((DEBUG_CACHE, "\n")); + DEBUG((DEBUG_CACHE, "MTRR Ranges\n")); + DEBUG((DEBUG_CACHE, "====================================\n")); + + Base = 0; + PreviousMemoryType = MTRR_CACHE_INVALID_TYPE; + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + Base = mMtrrLibFixedMtrrTable[Index].BaseAddress; + for (Index1 = 0; Index1 < 8; Index1++) { + MemoryType = (UINTN)(RShiftU64 (Mtrrs->Fixed.Mtrr[Index], Index1 * 8) & 0xff); + if (MemoryType > CacheWriteBack) { + MemoryType = MTRR_CACHE_INVALID_TYPE; + } + if (MemoryType != PreviousMemoryType) { + if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) { + DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); + } + PreviousMemoryType = MemoryType; + DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base)); + } + Base += mMtrrLibFixedMtrrTable[Index].Length; + } + } + DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); + + VariableMtrrCount = GetVariableMtrrCount (); + + Limit = BIT36 - 1; + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + Limit = LShiftU64 (1, RegEax & 0xff) - 1; + } + Base = BASE_1MB; + PreviousMemoryType = MTRR_CACHE_INVALID_TYPE; + do { + MemoryType = MtrrGetMemoryAttributeByAddressWorker (Mtrrs, Base); + if (MemoryType > CacheWriteBack) { + MemoryType = MTRR_CACHE_INVALID_TYPE; + } + + if (MemoryType != PreviousMemoryType) { + if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) { + DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); + } + PreviousMemoryType = MemoryType; + DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base)); + } + + RangeBase = BASE_1MB; + NoRangeBase = BASE_1MB; + RangeLimit = Limit; + NoRangeLimit = Limit; + + for (Index = 0, Found = FALSE; Index < VariableMtrrCount; Index++) { + if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) { + // + // If mask is not valid, then do not display range + // + continue; + } + MtrrBase = (Mtrrs->Variables.Mtrr[Index].Base & (~(SIZE_4KB - 1))); + MtrrLimit = MtrrBase + ((~(Mtrrs->Variables.Mtrr[Index].Mask & (~(SIZE_4KB - 1)))) & Limit); + + if (Base >= MtrrBase && Base < MtrrLimit) { + Found = TRUE; + } + + if (Base >= MtrrBase && MtrrBase > RangeBase) { + RangeBase = MtrrBase; + } + if (Base > MtrrLimit && MtrrLimit > RangeBase) { + RangeBase = MtrrLimit + 1; + } + if (Base < MtrrBase && MtrrBase < RangeLimit) { + RangeLimit = MtrrBase - 1; + } + if (Base < MtrrLimit && MtrrLimit <= RangeLimit) { + RangeLimit = MtrrLimit; + } + + if (Base > MtrrLimit && NoRangeBase < MtrrLimit) { + NoRangeBase = MtrrLimit + 1; + } + if (Base < MtrrBase && NoRangeLimit > MtrrBase) { + NoRangeLimit = MtrrBase - 1; + } + } + + if (Found) { + Base = RangeLimit + 1; + } else { + Base = NoRangeLimit + 1; + } + } while (Base < Limit); + DEBUG((DEBUG_CACHE, "%016lx\n\n", Base - 1)); + ); +} + + +/** + This function prints all MTRRs for debugging. +**/ +VOID +EFIAPI +MtrrDebugPrintAllMtrrs ( + VOID + ) +{ + MtrrDebugPrintAllMtrrsWorker (NULL); +} + +/** + Update the Ranges array to change the specified range identified by + BaseAddress and Length to Type. + + @param Ranges Array holding memory type settings for all memory regions. + @param Capacity The maximum count of memory ranges the array can hold. + @param Count Return the new memory range count in the array. + @param BaseAddress The base address of the memory range to change type. + @param Length The length of the memory range to change type. + @param Type The new type of the specified memory range. + + @retval RETURN_SUCCESS The type of the specified memory range is + changed successfully. + @retval RETURN_OUT_OF_RESOURCES The new type set causes the count of memory + range exceeds capacity. +**/ +RETURN_STATUS +MtrrLibSetMemoryType ( + IN MEMORY_RANGE *Ranges, + IN UINT32 Capacity, + IN OUT UINT32 *Count, + IN UINT64 BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type + ) +{ + UINT32 Index; + UINT64 Limit; + UINT64 LengthLeft; + UINT64 LengthRight; + UINT32 StartIndex; + UINT32 EndIndex; + UINT32 DeltaCount; + + LengthRight = 0; + LengthLeft = 0; + Limit = BaseAddress + Length; + StartIndex = *Count; + EndIndex = *Count; + for (Index = 0; Index < *Count; Index++) { + if ((StartIndex == *Count) && + (Ranges[Index].BaseAddress <= BaseAddress) && + (BaseAddress < Ranges[Index].BaseAddress + Ranges[Index].Length)) { + StartIndex = Index; + LengthLeft = BaseAddress - Ranges[Index].BaseAddress; + } + + if ((EndIndex == *Count) && + (Ranges[Index].BaseAddress < Limit) && + (Limit <= Ranges[Index].BaseAddress + Ranges[Index].Length)) { + EndIndex = Index; + LengthRight = Ranges[Index].BaseAddress + Ranges[Index].Length - Limit; + break; + } + } + + ASSERT (StartIndex != *Count && EndIndex != *Count); + if (StartIndex == EndIndex && Ranges[StartIndex].Type == Type) { + return RETURN_SUCCESS; + } + + // + // The type change may cause merging with previous range or next range. + // Update the StartIndex, EndIndex, BaseAddress, Length so that following + // logic doesn't need to consider merging. + // + if (StartIndex != 0) { + if (LengthLeft == 0 && Ranges[StartIndex - 1].Type == Type) { + StartIndex--; + Length += Ranges[StartIndex].Length; + BaseAddress -= Ranges[StartIndex].Length; + } + } + if (EndIndex != (*Count) - 1) { + if (LengthRight == 0 && Ranges[EndIndex + 1].Type == Type) { + EndIndex++; + Length += Ranges[EndIndex].Length; + } + } + + // + // |- 0 -|- 1 -|- 2 -|- 3 -| StartIndex EndIndex DeltaCount Count (Count = 4) + // |++++++++++++++++++| 0 3 1=3-0-2 3 + // |+++++++| 0 1 -1=1-0-2 5 + // |+| 0 0 -2=0-0-2 6 + // |+++| 0 0 -1=0-0-2+1 5 + // + // + DeltaCount = EndIndex - StartIndex - 2; + if (LengthLeft == 0) { + DeltaCount++; + } + if (LengthRight == 0) { + DeltaCount++; + } + if (*Count - DeltaCount > Capacity) { + return RETURN_OUT_OF_RESOURCES; + } + + // + // Reserve (-DeltaCount) space + // + CopyMem (&Ranges[EndIndex + 1 - DeltaCount], &Ranges[EndIndex + 1], (*Count - EndIndex - 1) * sizeof (Ranges[0])); + *Count -= DeltaCount; + + if (LengthLeft != 0) { + Ranges[StartIndex].Length = LengthLeft; + StartIndex++; + } + if (LengthRight != 0) { + Ranges[EndIndex - DeltaCount].BaseAddress = BaseAddress + Length; + Ranges[EndIndex - DeltaCount].Length = LengthRight; + Ranges[EndIndex - DeltaCount].Type = Ranges[EndIndex].Type; + } + Ranges[StartIndex].BaseAddress = BaseAddress; + Ranges[StartIndex].Length = Length; + Ranges[StartIndex].Type = Type; + return RETURN_SUCCESS; +} + +/** + Allocate one or more variable MTRR to cover the range identified by + BaseAddress and Length. + + @param Ranges Memory range array holding the memory type + settings for all memory address. + @param RangeCount Count of memory ranges. + @param VariableMtrr Variable MTRR array. + @param VariableMtrrCapacity Capacity of variable MTRR array. + @param VariableMtrrCount Count of variable MTRR. + @param BaseAddress Base address of the memory range. + @param Length Length of the memory range. + @param Type MTRR type of the memory range. + @param Alignment0 Alignment of 0. + + @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. + @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. +**/ +RETURN_STATUS +MtrrLibSetMemoryAttributeInVariableMtrr ( + IN CONST MEMORY_RANGE *Ranges, + IN UINT32 RangeCount, + IN OUT VARIABLE_MTRR *VariableMtrr, + IN UINT32 VariableMtrrCapacity, + IN OUT UINT32 *VariableMtrrCount, + IN UINT64 BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type, + IN UINT64 Alignment0 + ); + +/** + Allocate one or more variable MTRR to cover the range identified by + BaseAddress and Length. + + The routine recursively calls MtrrLibSetMemoryAttributeInVariableMtrr() + to allocate variable MTRRs when the range contains several sub-ranges + with different attributes. + + @param Ranges Memory range array holding the memory type + settings for all memory address. + @param RangeCount Count of memory ranges. + @param VariableMtrr Variable MTRR array. + @param VariableMtrrCapacity Capacity of variable MTRR array. + @param VariableMtrrCount Count of variable MTRR. + @param BaseAddress Base address of the memory range. + @param Length Length of the memory range. + @param Type MTRR type of the range. + If it's CacheInvalid, the memory range may + contains several sub-ranges with different + attributes. + @param Alignment0 Alignment of 0. + + @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. + @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. +**/ +RETURN_STATUS +MtrrLibAddVariableMtrr ( + IN CONST MEMORY_RANGE *Ranges, + IN UINT32 RangeCount, + IN OUT VARIABLE_MTRR *VariableMtrr, + IN UINT32 VariableMtrrCapacity, + IN OUT UINT32 *VariableMtrrCount, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type, + IN UINT64 Alignment0 +) +{ + RETURN_STATUS Status; + UINT32 Index; + UINT64 SubLength; + + MTRR_LIB_ASSERT_ALIGNED (BaseAddress, Length); + if (Type == CacheInvalid) { + for (Index = 0; Index < RangeCount; Index++) { + if (Ranges[Index].BaseAddress <= BaseAddress && BaseAddress < Ranges[Index].BaseAddress + Ranges[Index].Length) { + + // + // Because the Length may not be aligned to BaseAddress, below code calls + // MtrrLibSetMemoryAttributeInVariableMtrr() instead of itself. + // MtrrLibSetMemoryAttributeInVariableMtrr() splits the range to several + // aligned ranges. + // + if (Ranges[Index].BaseAddress + Ranges[Index].Length >= BaseAddress + Length) { + return MtrrLibSetMemoryAttributeInVariableMtrr ( + Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress, Length, Ranges[Index].Type, Alignment0 + ); + } else { + SubLength = Ranges[Index].BaseAddress + Ranges[Index].Length - BaseAddress; + Status = MtrrLibSetMemoryAttributeInVariableMtrr ( + Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress, SubLength, Ranges[Index].Type, Alignment0 + ); + if (RETURN_ERROR (Status)) { + return Status; + } + BaseAddress += SubLength; + Length -= SubLength; + } + } + } + + // + // Because memory ranges cover all the memory addresses, it's impossible to be here. + // + ASSERT (FALSE); + return RETURN_DEVICE_ERROR; + } else { + for (Index = 0; Index < *VariableMtrrCount; Index++) { + if (VariableMtrr[Index].BaseAddress == BaseAddress && VariableMtrr[Index].Length == Length) { + ASSERT (VariableMtrr[Index].Type == Type); + break; + } + } + if (Index == *VariableMtrrCount) { + if (*VariableMtrrCount == VariableMtrrCapacity) { + return RETURN_OUT_OF_RESOURCES; + } + VariableMtrr[Index].BaseAddress = BaseAddress; + VariableMtrr[Index].Length = Length; + VariableMtrr[Index].Type = Type; + VariableMtrr[Index].Valid = TRUE; + VariableMtrr[Index].Used = TRUE; + (*VariableMtrrCount)++; + } + return RETURN_SUCCESS; + } +} + +/** + Allocate one or more variable MTRR to cover the range identified by + BaseAddress and Length. + + @param Ranges Memory range array holding the memory type + settings for all memory address. + @param RangeCount Count of memory ranges. + @param VariableMtrr Variable MTRR array. + @param VariableMtrrCapacity Capacity of variable MTRR array. + @param VariableMtrrCount Count of variable MTRR. + @param BaseAddress Base address of the memory range. + @param Length Length of the memory range. + @param Type MTRR type of the memory range. + @param Alignment0 Alignment of 0. + + @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. + @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. +**/ +RETURN_STATUS +MtrrLibSetMemoryAttributeInVariableMtrr ( + IN CONST MEMORY_RANGE *Ranges, + IN UINT32 RangeCount, + IN OUT VARIABLE_MTRR *VariableMtrr, + IN UINT32 VariableMtrrCapacity, + IN OUT UINT32 *VariableMtrrCount, + IN UINT64 BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type, + IN UINT64 Alignment0 +) +{ + UINT64 Alignment; + UINT32 MtrrNumber; + UINT32 SubtractiveLeft; + UINT32 SubtractiveRight; + BOOLEAN UseLeastAlignment; + + Alignment = 0; + + MtrrNumber = MtrrLibGetMtrrNumber (Ranges, RangeCount, VariableMtrr, *VariableMtrrCount, + BaseAddress, Length, Type, Alignment0, &SubtractiveLeft, &SubtractiveRight); + + if (MtrrNumber + *VariableMtrrCount > VariableMtrrCapacity) { + return RETURN_OUT_OF_RESOURCES; + } + + while (SubtractiveLeft-- != 0) { + Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); + ASSERT (Alignment <= Length); + + MtrrLibAddVariableMtrr (Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress - Alignment, Alignment, CacheInvalid, Alignment0); + BaseAddress -= Alignment; + Length += Alignment; + } + + while (Length != 0) { + Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); + if (Alignment > Length) { + break; + } + MtrrLibAddVariableMtrr (NULL, 0, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress, Alignment, Type, Alignment0); + BaseAddress += Alignment; + Length -= Alignment; + } + + while (SubtractiveRight-- != 0) { + Alignment = MtrrLibLeastAlignment (BaseAddress + Length, Alignment0); + MtrrLibAddVariableMtrr (Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress + Length, Alignment, CacheInvalid, Alignment0); + Length += Alignment; + } + + UseLeastAlignment = TRUE; + while (Length != 0) { + if (UseLeastAlignment) { + Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); + if (Alignment > Length) { + UseLeastAlignment = FALSE; + } + } + + if (!UseLeastAlignment) { + Alignment = GetPowerOfTwo64 (Length); + } + + MtrrLibAddVariableMtrr (NULL, 0, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, + BaseAddress, Alignment, Type, Alignment0); + BaseAddress += Alignment; + Length -= Alignment; + } + return RETURN_SUCCESS; +} + +/** + Return an array of memory ranges holding memory type settings for all memory + address. + + @param DefaultType The default memory type. + @param TotalLength The total length of the memory. + @param VariableMtrr The variable MTRR array. + @param VariableMtrrCount The count of variable MTRRs. + @param Ranges Return the memory range array holding memory type + settings for all memory address. + @param RangeCapacity The capacity of memory range array. + @param RangeCount Return the count of memory range. + + @retval RETURN_SUCCESS The memory range array is returned successfully. + @retval RETURN_OUT_OF_RESOURCES The count of memory ranges exceeds capacity. +**/ +RETURN_STATUS +MtrrLibGetMemoryTypes ( + IN MTRR_MEMORY_CACHE_TYPE DefaultType, + IN UINT64 TotalLength, + IN CONST VARIABLE_MTRR *VariableMtrr, + IN UINT32 VariableMtrrCount, + OUT MEMORY_RANGE *Ranges, + IN UINT32 RangeCapacity, + OUT UINT32 *RangeCount +) +{ + RETURN_STATUS Status; + UINTN Index; + + // + // WT > WB + // UC > * + // UC > * (except WB, UC) > WB + // + + // + // 0. Set whole range as DefaultType + // + *RangeCount = 1; + Ranges[0].BaseAddress = 0; + Ranges[0].Length = TotalLength; + Ranges[0].Type = DefaultType; + + // + // 1. Set WB + // + for (Index = 0; Index < VariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type == CacheWriteBack) { + Status = MtrrLibSetMemoryType ( + Ranges, RangeCapacity, RangeCount, + VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type + ); + if (RETURN_ERROR (Status)) { + return Status; + } + } + } + + // + // 2. Set other types than WB or UC + // + for (Index = 0; Index < VariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type != CacheWriteBack && VariableMtrr[Index].Type != CacheUncacheable) { + Status = MtrrLibSetMemoryType ( + Ranges, RangeCapacity, RangeCount, + VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type + ); + if (RETURN_ERROR (Status)) { + return Status; + } + } + } + + // + // 3. Set UC + // + for (Index = 0; Index < VariableMtrrCount; Index++) { + if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type == CacheUncacheable) { + Status = MtrrLibSetMemoryType ( + Ranges, RangeCapacity, RangeCount, + VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type + ); + if (RETURN_ERROR (Status)) { + return Status; + } + } + } + return RETURN_SUCCESS; +} + +/** + Worker function attempts to set the attributes for a memory range. + + If MtrrSetting is not NULL, set the attributes into the input MTRR + settings buffer. + If MtrrSetting is NULL, set the attributes into MTRRs registers. + + @param[in, out] MtrrSetting A buffer holding all MTRRs content. + @param[in] BaseAddress The physical address that is the start + address of a memory range. + @param[in] Length The size in bytes of the memory range. + @param[in] Type The MTRR type to set for the memory range. + + @retval RETURN_SUCCESS The attributes were set for the memory + range. + @retval RETURN_INVALID_PARAMETER Length is zero. + @retval RETURN_UNSUPPORTED The processor does not support one or + more bytes of the memory resource range + specified by BaseAddress and Length. + @retval RETURN_UNSUPPORTED The MTRR type is not support for the + memory resource range specified + by BaseAddress and Length. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to + modify the attributes of the memory + resource range. + +**/ +RETURN_STATUS +MtrrSetMemoryAttributeWorker ( + IN OUT MTRR_SETTINGS *MtrrSetting, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Type + ) +{ + RETURN_STATUS Status; + UINT32 Index; + UINT32 WorkingIndex; + // + // N variable MTRRs can maximumly separate (2N + 1) Ranges, plus 1 range for [0, 1M). + // + MEMORY_RANGE Ranges[MTRR_NUMBER_OF_VARIABLE_MTRR * 2 + 2]; + UINT32 RangeCount; + UINT64 MtrrValidBitsMask; + UINT64 MtrrValidAddressMask; + UINT64 Alignment0; + MTRR_CONTEXT MtrrContext; + BOOLEAN MtrrContextValid; + + MTRR_MEMORY_CACHE_TYPE DefaultType; + + UINT32 MsrIndex; + UINT64 ClearMask; + UINT64 OrMask; + UINT64 NewValue; + BOOLEAN FixedSettingsValid[MTRR_NUMBER_OF_FIXED_MTRR]; + BOOLEAN FixedSettingsModified[MTRR_NUMBER_OF_FIXED_MTRR]; + MTRR_FIXED_SETTINGS WorkingFixedSettings; + + UINT32 FirmwareVariableMtrrCount; + MTRR_VARIABLE_SETTINGS *VariableSettings; + MTRR_VARIABLE_SETTINGS OriginalVariableSettings; + UINT32 OriginalVariableMtrrCount; + VARIABLE_MTRR OriginalVariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; + UINT32 WorkingVariableMtrrCount; + VARIABLE_MTRR WorkingVariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; + BOOLEAN VariableSettingModified[MTRR_NUMBER_OF_VARIABLE_MTRR]; + UINTN FreeVariableMtrrCount; + + if (Length == 0) { + return RETURN_INVALID_PARAMETER; + } + + MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); + if (((BaseAddress & ~MtrrValidAddressMask) != 0) || (Length & ~MtrrValidAddressMask) != 0) { + return RETURN_UNSUPPORTED; + } + OriginalVariableMtrrCount = 0; + VariableSettings = NULL; + + ZeroMem (&WorkingFixedSettings, sizeof (WorkingFixedSettings)); + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + FixedSettingsValid[Index] = FALSE; + FixedSettingsModified[Index] = FALSE; + } + + // + // Check if Fixed MTRR + // + if (BaseAddress < BASE_1MB) { + MsrIndex = (UINT32)-1; + while ((BaseAddress < BASE_1MB) && (Length != 0)) { + Status = MtrrLibProgramFixedMtrr (Type, &BaseAddress, &Length, &MsrIndex, &ClearMask, &OrMask); + if (RETURN_ERROR (Status)) { + return Status; + } + if (MtrrSetting != NULL) { + MtrrSetting->Fixed.Mtrr[MsrIndex] = (MtrrSetting->Fixed.Mtrr[MsrIndex] & ~ClearMask) | OrMask; + ((MSR_IA32_MTRR_DEF_TYPE_REGISTER *) &MtrrSetting->MtrrDefType)->Bits.FE = 1; + } else { + if (!FixedSettingsValid[MsrIndex]) { + WorkingFixedSettings.Mtrr[MsrIndex] = AsmReadMsr64 (mMtrrLibFixedMtrrTable[MsrIndex].Msr); + FixedSettingsValid[MsrIndex] = TRUE; + } + NewValue = (WorkingFixedSettings.Mtrr[MsrIndex] & ~ClearMask) | OrMask; + if (WorkingFixedSettings.Mtrr[MsrIndex] != NewValue) { + WorkingFixedSettings.Mtrr[MsrIndex] = NewValue; + FixedSettingsModified[MsrIndex] = TRUE; + } + } + } + + if (Length == 0) { + // + // A Length of 0 can only make sense for fixed MTTR ranges. + // Since we just handled the fixed MTRRs, we can skip the + // variable MTRR section. + // + goto Done; + } + } + + // + // Read the default MTRR type + // + DefaultType = MtrrGetDefaultMemoryTypeWorker (MtrrSetting); + + // + // Read all variable MTRRs and convert to Ranges. + // + OriginalVariableMtrrCount = GetVariableMtrrCountWorker (); + if (MtrrSetting == NULL) { + ZeroMem (&OriginalVariableSettings, sizeof (OriginalVariableSettings)); + MtrrGetVariableMtrrWorker (NULL, OriginalVariableMtrrCount, &OriginalVariableSettings); + VariableSettings = &OriginalVariableSettings; + } else { + VariableSettings = &MtrrSetting->Variables; + } + MtrrGetMemoryAttributeInVariableMtrrWorker (VariableSettings, OriginalVariableMtrrCount, MtrrValidBitsMask, MtrrValidAddressMask, OriginalVariableMtrr); + + Status = MtrrLibGetMemoryTypes ( + DefaultType, MtrrValidBitsMask + 1, OriginalVariableMtrr, OriginalVariableMtrrCount, + Ranges, 2 * OriginalVariableMtrrCount + 1, &RangeCount + ); + ASSERT (Status == RETURN_SUCCESS); + + FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCountWorker (); + ASSERT (RangeCount <= 2 * FirmwareVariableMtrrCount + 1); + + // + // Force [0, 1M) to UC, so that it doesn't impact left subtraction algorithm. + // + Status = MtrrLibSetMemoryType (Ranges, 2 * FirmwareVariableMtrrCount + 2, &RangeCount, 0, SIZE_1MB, CacheUncacheable); + ASSERT (Status == RETURN_SUCCESS); + // + // Apply Type to [BaseAddress, BaseAddress + Length) + // + Status = MtrrLibSetMemoryType (Ranges, 2 * FirmwareVariableMtrrCount + 2, &RangeCount, BaseAddress, Length, Type); + if (RETURN_ERROR (Status)) { + return Status; + } + + Alignment0 = LShiftU64 (1, (UINTN) HighBitSet64 (MtrrValidBitsMask)); + WorkingVariableMtrrCount = 0; + ZeroMem (&WorkingVariableMtrr, sizeof (WorkingVariableMtrr)); + for (Index = 0; Index < RangeCount; Index++) { + if (Ranges[Index].Type != DefaultType) { + // + // Maximum allowed MTRR count is (FirmwareVariableMtrrCount + 1) + // Because potentially the range [0, 1MB) is not merged, but can be ignored because fixed MTRR covers that + // + Status = MtrrLibSetMemoryAttributeInVariableMtrr ( + Ranges, RangeCount, + WorkingVariableMtrr, FirmwareVariableMtrrCount + 1, &WorkingVariableMtrrCount, + Ranges[Index].BaseAddress, Ranges[Index].Length, + Ranges[Index].Type, Alignment0 + ); + if (RETURN_ERROR (Status)) { + return Status; + } + } + } + + // + // Remove the [0, 1MB) MTRR if it still exists (not merged with other range) + // + if (WorkingVariableMtrr[0].BaseAddress == 0 && WorkingVariableMtrr[0].Length == SIZE_1MB) { + ASSERT (WorkingVariableMtrr[0].Type == CacheUncacheable); + WorkingVariableMtrrCount--; + CopyMem (&WorkingVariableMtrr[0], &WorkingVariableMtrr[1], WorkingVariableMtrrCount * sizeof (VARIABLE_MTRR)); + } + + if (WorkingVariableMtrrCount > FirmwareVariableMtrrCount) { + return RETURN_OUT_OF_RESOURCES; + } + + for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { + VariableSettingModified[Index] = FALSE; + + if (!OriginalVariableMtrr[Index].Valid) { + continue; + } + for (WorkingIndex = 0; WorkingIndex < WorkingVariableMtrrCount; WorkingIndex++) { + if (OriginalVariableMtrr[Index].BaseAddress == WorkingVariableMtrr[WorkingIndex].BaseAddress && + OriginalVariableMtrr[Index].Length == WorkingVariableMtrr[WorkingIndex].Length && + OriginalVariableMtrr[Index].Type == WorkingVariableMtrr[WorkingIndex].Type) { + break; + } + } + + if (WorkingIndex == WorkingVariableMtrrCount) { + // + // Remove the one from OriginalVariableMtrr which is not in WorkingVariableMtrr + // + OriginalVariableMtrr[Index].Valid = FALSE; + VariableSettingModified[Index] = TRUE; + } else { + // + // Remove the one from WorkingVariableMtrr which is also in OriginalVariableMtrr + // + WorkingVariableMtrr[WorkingIndex].Valid = FALSE; + } + // + // The above two operations cause that valid MTRR only exists in either OriginalVariableMtrr or WorkingVariableMtrr. + // + } + + // + // Merge remaining MTRRs from WorkingVariableMtrr to OriginalVariableMtrr + // + for (FreeVariableMtrrCount = 0, WorkingIndex = 0, Index = 0; Index < OriginalVariableMtrrCount; Index++) { + if (!OriginalVariableMtrr[Index].Valid) { + for (; WorkingIndex < WorkingVariableMtrrCount; WorkingIndex++) { + if (WorkingVariableMtrr[WorkingIndex].Valid) { + break; + } + } + if (WorkingIndex == WorkingVariableMtrrCount) { + FreeVariableMtrrCount++; + } else { + CopyMem (&OriginalVariableMtrr[Index], &WorkingVariableMtrr[WorkingIndex], sizeof (VARIABLE_MTRR)); + VariableSettingModified[Index] = TRUE; + WorkingIndex++; + } + } + } + ASSERT (OriginalVariableMtrrCount - FreeVariableMtrrCount <= FirmwareVariableMtrrCount); + + // + // Move MTRRs after the FirmwraeVariableMtrrCount position to beginning + // + WorkingIndex = FirmwareVariableMtrrCount; + for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { + if (!OriginalVariableMtrr[Index].Valid) { + // + // Found an empty MTRR in WorkingIndex position + // + for (; WorkingIndex < OriginalVariableMtrrCount; WorkingIndex++) { + if (OriginalVariableMtrr[WorkingIndex].Valid) { + break; + } + } + + if (WorkingIndex != OriginalVariableMtrrCount) { + CopyMem (&OriginalVariableMtrr[Index], &OriginalVariableMtrr[WorkingIndex], sizeof (VARIABLE_MTRR)); + VariableSettingModified[Index] = TRUE; + VariableSettingModified[WorkingIndex] = TRUE; + OriginalVariableMtrr[WorkingIndex].Valid = FALSE; + } + } + } + + // + // Convert OriginalVariableMtrr to VariableSettings + // NOTE: MTRR from FirmwareVariableMtrr to OriginalVariableMtrr need to update as well. + // + for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { + if (VariableSettingModified[Index]) { + if (OriginalVariableMtrr[Index].Valid) { + VariableSettings->Mtrr[Index].Base = (OriginalVariableMtrr[Index].BaseAddress & MtrrValidAddressMask) | (UINT8) OriginalVariableMtrr[Index].Type; + VariableSettings->Mtrr[Index].Mask = ((~(OriginalVariableMtrr[Index].Length - 1)) & MtrrValidAddressMask) | BIT11; + } else { + VariableSettings->Mtrr[Index].Base = 0; + VariableSettings->Mtrr[Index].Mask = 0; + } + } + } + +Done: + if (MtrrSetting != NULL) { + ((MSR_IA32_MTRR_DEF_TYPE_REGISTER *) &MtrrSetting->MtrrDefType)->Bits.E = 1; + return RETURN_SUCCESS; + } + + MtrrContextValid = FALSE; + // + // Write fixed MTRRs that have been modified + // + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + if (FixedSettingsModified[Index]) { + if (!MtrrContextValid) { + MtrrLibPreMtrrChange (&MtrrContext); + MtrrContextValid = TRUE; + } + AsmWriteMsr64 ( + mMtrrLibFixedMtrrTable[Index].Msr, + WorkingFixedSettings.Mtrr[Index] + ); + } + } + + // + // Write variable MTRRs + // When only fixed MTRRs were changed, below loop doesn't run + // because OriginalVariableMtrrCount equals to 0. + // + for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { + if (VariableSettingModified[Index]) { + if (!MtrrContextValid) { + MtrrLibPreMtrrChange (&MtrrContext); + MtrrContextValid = TRUE; + } + AsmWriteMsr64 ( + MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), + VariableSettings->Mtrr[Index].Base + ); + AsmWriteMsr64 ( + MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), + VariableSettings->Mtrr[Index].Mask + ); + } + } + if (MtrrContextValid) { + MtrrLibPostMtrrChange (&MtrrContext); + } + + return RETURN_SUCCESS; +} + +/** + This function attempts to set the attributes for a memory range. + + @param[in] BaseAddress The physical address that is the start + address of a memory range. + @param[in] Length The size in bytes of the memory range. + @param[in] Attributes The bit mask of attributes to set for the + memory range. + + @retval RETURN_SUCCESS The attributes were set for the memory + range. + @retval RETURN_INVALID_PARAMETER Length is zero. + @retval RETURN_UNSUPPORTED The processor does not support one or + more bytes of the memory resource range + specified by BaseAddress and Length. + @retval RETURN_UNSUPPORTED The bit mask of attributes is not support + for the memory resource range specified + by BaseAddress and Length. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource + range specified by BaseAddress and Length + cannot be modified. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to + modify the attributes of the memory + resource range. + +**/ +RETURN_STATUS +EFIAPI +MtrrSetMemoryAttribute ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Attribute + ) +{ + RETURN_STATUS Status; + + if (!IsMtrrSupported ()) { + return RETURN_UNSUPPORTED; + } + + Status = MtrrSetMemoryAttributeWorker (NULL, BaseAddress, Length, Attribute); + DEBUG ((DEBUG_CACHE, "MtrrSetMemoryAttribute() %a: [%016lx, %016lx) - %r\n", + mMtrrMemoryCacheTypeShortName[Attribute], BaseAddress, BaseAddress + Length, Status)); + + if (!RETURN_ERROR (Status)) { + MtrrDebugPrintAllMtrrsWorker (NULL); + } + return Status; +} + +/** + This function attempts to set the attributes into MTRR setting buffer for a memory range. + + @param[in, out] MtrrSetting MTRR setting buffer to be set. + @param[in] BaseAddress The physical address that is the start address + of a memory range. + @param[in] Length The size in bytes of the memory range. + @param[in] Attribute The bit mask of attributes to set for the + memory range. + + @retval RETURN_SUCCESS The attributes were set for the memory range. + @retval RETURN_INVALID_PARAMETER Length is zero. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the + memory resource range specified by BaseAddress and Length. + @retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + +**/ +RETURN_STATUS +EFIAPI +MtrrSetMemoryAttributeInMtrrSettings ( + IN OUT MTRR_SETTINGS *MtrrSetting, + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN MTRR_MEMORY_CACHE_TYPE Attribute + ) +{ + RETURN_STATUS Status; + Status = MtrrSetMemoryAttributeWorker (MtrrSetting, BaseAddress, Length, Attribute); + DEBUG((DEBUG_CACHE, "MtrrSetMemoryAttributeMtrrSettings(%p) %a: [%016lx, %016lx) - %r\n", + MtrrSetting, mMtrrMemoryCacheTypeShortName[Attribute], BaseAddress, BaseAddress + Length, Status)); + + if (!RETURN_ERROR (Status)) { + MtrrDebugPrintAllMtrrsWorker (MtrrSetting); + } + + return Status; +} + +/** + Worker function setting variable MTRRs + + @param[in] VariableSettings A buffer to hold variable MTRRs content. + +**/ +VOID +MtrrSetVariableMtrrWorker ( + IN MTRR_VARIABLE_SETTINGS *VariableSettings + ) +{ + UINT32 Index; + UINT32 VariableMtrrCount; + + VariableMtrrCount = GetVariableMtrrCountWorker (); + ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); + + for (Index = 0; Index < VariableMtrrCount; Index++) { + AsmWriteMsr64 ( + MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), + VariableSettings->Mtrr[Index].Base + ); + AsmWriteMsr64 ( + MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), + VariableSettings->Mtrr[Index].Mask + ); + } +} + + +/** + This function sets variable MTRRs + + @param[in] VariableSettings A buffer to hold variable MTRRs content. + + @return The pointer of VariableSettings + +**/ +MTRR_VARIABLE_SETTINGS* +EFIAPI +MtrrSetVariableMtrr ( + IN MTRR_VARIABLE_SETTINGS *VariableSettings + ) +{ + MTRR_CONTEXT MtrrContext; + + if (!IsMtrrSupported ()) { + return VariableSettings; + } + + MtrrLibPreMtrrChange (&MtrrContext); + MtrrSetVariableMtrrWorker (VariableSettings); + MtrrLibPostMtrrChange (&MtrrContext); + MtrrDebugPrintAllMtrrs (); + + return VariableSettings; +} + +/** + Worker function setting fixed MTRRs + + @param[in] FixedSettings A buffer to hold fixed MTRRs content. + +**/ +VOID +MtrrSetFixedMtrrWorker ( + IN MTRR_FIXED_SETTINGS *FixedSettings + ) +{ + UINT32 Index; + + for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { + AsmWriteMsr64 ( + mMtrrLibFixedMtrrTable[Index].Msr, + FixedSettings->Mtrr[Index] + ); + } +} + + +/** + This function sets fixed MTRRs + + @param[in] FixedSettings A buffer to hold fixed MTRRs content. + + @retval The pointer of FixedSettings + +**/ +MTRR_FIXED_SETTINGS* +EFIAPI +MtrrSetFixedMtrr ( + IN MTRR_FIXED_SETTINGS *FixedSettings + ) +{ + MTRR_CONTEXT MtrrContext; + + if (!IsMtrrSupported ()) { + return FixedSettings; + } + + MtrrLibPreMtrrChange (&MtrrContext); + MtrrSetFixedMtrrWorker (FixedSettings); + MtrrLibPostMtrrChange (&MtrrContext); + MtrrDebugPrintAllMtrrs (); + + return FixedSettings; +} + + +/** + This function gets the content in all MTRRs (variable and fixed) + + @param[out] MtrrSetting A buffer to hold all MTRRs content. + + @retval the pointer of MtrrSetting + +**/ +MTRR_SETTINGS * +EFIAPI +MtrrGetAllMtrrs ( + OUT MTRR_SETTINGS *MtrrSetting + ) +{ + if (!IsMtrrSupported ()) { + return MtrrSetting; + } + + // + // Get fixed MTRRs + // + MtrrGetFixedMtrrWorker (&MtrrSetting->Fixed); + + // + // Get variable MTRRs + // + MtrrGetVariableMtrrWorker ( + NULL, + GetVariableMtrrCountWorker (), + &MtrrSetting->Variables + ); + + // + // Get MTRR_DEF_TYPE value + // + MtrrSetting->MtrrDefType = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); + + return MtrrSetting; +} + + +/** + This function sets all MTRRs (variable and fixed) + + @param[in] MtrrSetting A buffer holding all MTRRs content. + + @retval The pointer of MtrrSetting + +**/ +MTRR_SETTINGS * +EFIAPI +MtrrSetAllMtrrs ( + IN MTRR_SETTINGS *MtrrSetting + ) +{ + MTRR_CONTEXT MtrrContext; + + if (!IsMtrrSupported ()) { + return MtrrSetting; + } + + MtrrLibPreMtrrChange (&MtrrContext); + + // + // Set fixed MTRRs + // + MtrrSetFixedMtrrWorker (&MtrrSetting->Fixed); + + // + // Set variable MTRRs + // + MtrrSetVariableMtrrWorker (&MtrrSetting->Variables); + + // + // Set MTRR_DEF_TYPE value + // + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, MtrrSetting->MtrrDefType); + + MtrrLibPostMtrrChangeEnableCache (&MtrrContext); + + return MtrrSetting; +} + + +/** + Checks if MTRR is supported. + + @retval TRUE MTRR is supported. + @retval FALSE MTRR is not supported. + +**/ +BOOLEAN +EFIAPI +IsMtrrSupported ( + VOID + ) +{ + CPUID_VERSION_INFO_EDX Edx; + MSR_IA32_MTRRCAP_REGISTER MtrrCap; + + // + // Check CPUID(1).EDX[12] for MTRR capability + // + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32); + if (Edx.Bits.MTRR == 0) { + return FALSE; + } + + // + // Check number of variable MTRRs and fixed MTRRs existence. + // If number of variable MTRRs is zero, or fixed MTRRs do not + // exist, return false. + // + MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); + if ((MtrrCap.Bits.VCNT == 0) || (MtrrCap.Bits.FIX == 0)) { + return FALSE; + } + return TRUE; +} + diff --git a/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf new file mode 100644 index 0000000000..01a4d84da0 --- /dev/null +++ b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf @@ -0,0 +1,46 @@ +## @file +# MTRR library provides APIs for MTRR operation. +# +# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MtrrLib + MODULE_UNI_FILE = MtrrLib.uni + FILE_GUID = 6826b408-f4f3-47ee-917f-af7047f9d937 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = MtrrLib + + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + MtrrLib.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseMemoryLib + BaseLib + CpuLib + DebugLib + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs ## SOMETIMES_CONSUMES + diff --git a/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni new file mode 100644 index 0000000000..34753a089a --- /dev/null +++ b/Core/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni @@ -0,0 +1,22 @@ +// /** @file +// MTRR library provides APIs for MTRR operation. +// +// MTRR library provides APIs for MTRR operation. +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "MTRR library provides APIs for MTRR operation" + +#string STR_MODULE_DESCRIPTION #language en-US "MTRR library provides APIs for MTRR operation." + diff --git a/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c new file mode 100644 index 0000000000..ad3e9090c6 --- /dev/null +++ b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c @@ -0,0 +1,90 @@ +/** @file +Null instance of Platform Sec Lib. + +Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include + +/** + A developer supplied function to perform platform specific operations. + + It's a developer supplied function to perform any operations appropriate to a + given platform. It's invoked just before passing control to PEI core by SEC + core. Platform developer may modify the SecCoreData passed to PEI Core. + It returns a platform specific PPI list that platform wishes to pass to PEI core. + The Generic SEC core module will merge this list to join the final list passed to + PEI core. + + @param SecCoreData The same parameter as passing to PEI core. It + could be overridden by this function. + + @return The platform specific PPI list to be passed to PEI core or + NULL if there is no need of such platform specific PPI list. + +**/ +EFI_PEI_PPI_DESCRIPTOR * +EFIAPI +SecPlatformMain ( + IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData + ) +{ + return NULL; +} + +/** + This interface conveys state information out of the Security (SEC) phase into PEI. + + @param PeiServices Pointer to the PEI Services Table. + @param StructureSize Pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ) +{ + return EFI_SUCCESS; +} + +/** + This interface disables temporary memory in SEC Phase. +**/ +VOID +EFIAPI +SecPlatformDisableTemporaryMemory ( + VOID + ) +{ +} + +/** + This function provides dummy function so that SecCore can pass build + validation. All real platform library instances need to implement the real + entry point in assembly. +**/ +VOID +EFIAPI +_ModuleEntryPoint ( + VOID + ) +{ + return; +} diff --git a/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf new file mode 100644 index 0000000000..3f8868adee --- /dev/null +++ b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf @@ -0,0 +1,37 @@ +## @file +# Library functions for PlatformSecLib. +# +# Null instance of Platform Sec Lib. +# +# Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformSecLibNull + MODULE_UNI_FILE = PlatformSecLibNull.uni + FILE_GUID = 6695974D-968C-420b-80B9-7870CD20118F + MODULE_TYPE = SEC + VERSION_STRING = 1.0 + LIBRARY_CLASS = PlatformSecLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + PlatformSecLibNull.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec diff --git a/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni new file mode 100644 index 0000000000..d7212f0351 --- /dev/null +++ b/Core/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni @@ -0,0 +1,20 @@ +// /** @file +// Library functions for PlatformSecLib. +// +// Null instance of Platform Sec Library. +// +// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Library functions for PlatformSecLib" + +#string STR_MODULE_DESCRIPTION #language en-US "Null instance of Platform Sec Library." diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c new file mode 100644 index 0000000000..5e11b2b21c --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -0,0 +1,751 @@ +/** @file + CPU Features Initialize functions. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "RegisterCpuFeatures.h" + +/** + Worker function to save PcdCpuFeaturesCapability. + + @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer +**/ +VOID +SetCapabilityPcd ( + IN UINT8 *SupportedFeatureMask + ) +{ + EFI_STATUS Status; + UINTN BitMaskSize; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability); + Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, SupportedFeatureMask); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to save PcdCpuFeaturesSetting. + + @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer +**/ +VOID +SetSettingPcd ( + IN UINT8 *SupportedFeatureMask + ) +{ + EFI_STATUS Status; + UINTN BitMaskSize; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSetting); + Status = PcdSetPtrS (PcdCpuFeaturesSetting, &BitMaskSize, SupportedFeatureMask); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to get PcdCpuFeaturesSupport. + + @return The pointer to CPU feature bits mask buffer. +**/ +UINT8 * +GetSupportPcds ( + VOID + ) +{ + UINTN BitMaskSize; + UINT8 *SupportBitMask; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + SupportBitMask = AllocateZeroPool (BitMaskSize); + ASSERT (SupportBitMask != NULL); + SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); + + return SupportBitMask; +} + +/** + Worker function to get PcdCpuFeaturesUserConfiguration. + + @return The pointer to CPU feature bits mask buffer. +**/ +UINT8 * +GetConfigurationPcds ( + VOID + ) +{ + UINTN BitMaskSize; + UINT8 *SupportBitMask; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration); + SupportBitMask = AllocateZeroPool (BitMaskSize); + ASSERT (SupportBitMask != NULL); + SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration); + + return SupportBitMask; +} + +/** + Collects CPU type and feature information. + + @param[in, out] CpuInfo The pointer to CPU feature information +**/ +VOID +FillProcessorInfo ( + IN OUT REGISTER_CPU_FEATURE_INFORMATION *CpuInfo + ) +{ + CPUID_VERSION_INFO_EAX Eax; + CPUID_VERSION_INFO_ECX Ecx; + CPUID_VERSION_INFO_EDX Edx; + UINT32 DisplayedFamily; + UINT32 DisplayedModel; + + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, &Ecx.Uint32, &Edx.Uint32); + + DisplayedFamily = Eax.Bits.FamilyId; + if (Eax.Bits.FamilyId == 0x0F) { + DisplayedFamily |= (Eax.Bits.ExtendedFamilyId << 4); + } + + DisplayedModel = Eax.Bits.Model; + if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) { + DisplayedModel |= (Eax.Bits.ExtendedModelId << 4); + } + + CpuInfo->DisplayFamily = DisplayedFamily; + CpuInfo->DisplayModel = DisplayedModel; + CpuInfo->SteppingId = Eax.Bits.SteppingId; + CpuInfo->ProcessorType = Eax.Bits.ProcessorType; + CpuInfo->CpuIdVersionInfoEcx.Uint32 = Ecx.Uint32; + CpuInfo->CpuIdVersionInfoEdx.Uint32 = Edx.Uint32; +} + +/** + Prepares for private data used for CPU features. + + @param[in] NumberOfCpus Number of processor in system +**/ +VOID +CpuInitDataInitialize ( + IN UINTN NumberOfCpus + ) +{ + EFI_STATUS Status; + UINTN ProcessorNumber; + EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; + CPU_FEATURES_ENTRY *CpuFeature; + CPU_FEATURES_INIT_ORDER *InitOrder; + CPU_FEATURES_DATA *CpuFeaturesData; + LIST_ENTRY *Entry; + + CpuFeaturesData = GetCpuFeaturesData (); + CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus); + ASSERT (CpuFeaturesData->InitOrder != NULL); + CpuFeaturesData->BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + + // + // Collect CPU Features information + // + Entry = GetFirstNode (&CpuFeaturesData->FeatureList); + while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { + CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + ASSERT (CpuFeature->InitializeFunc != NULL); + if (CpuFeature->GetConfigDataFunc != NULL) { + CpuFeature->ConfigData = CpuFeature->GetConfigDataFunc (NumberOfCpus); + } + Entry = Entry->ForwardLink; + } + + for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { + InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; + InitOrder->FeaturesSupportedMask = AllocateZeroPool (CpuFeaturesData->BitMaskSize); + ASSERT (InitOrder->FeaturesSupportedMask != NULL); + InitializeListHead (&InitOrder->OrderList); + Status = GetProcessorInformation (ProcessorNumber, &ProcessorInfoBuffer); + ASSERT_EFI_ERROR (Status); + CopyMem ( + &InitOrder->CpuInfo.ProcessorInfo, + &ProcessorInfoBuffer, + sizeof (EFI_PROCESSOR_INFORMATION) + ); + } + // + // Get support and configuration PCDs + // + CpuFeaturesData->SupportPcds = GetSupportPcds (); + CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds (); +} + +/** + Worker function to do OR operation on CPU feature supported bits mask buffer. + + @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer + @param[in] OrFeatureBitMask The feature bit mask to do OR operation +**/ +VOID +SupportedMaskOr ( + IN UINT8 *SupportedFeatureMask, + IN UINT8 *OrFeatureBitMask + ) +{ + UINTN Index; + UINTN BitMaskSize; + UINT8 *Data1; + UINT8 *Data2; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + Data1 = SupportedFeatureMask; + Data2 = OrFeatureBitMask; + for (Index = 0; Index < BitMaskSize; Index++) { + *(Data1++) |= *(Data2++); + } +} + +/** + Worker function to do AND operation on CPU feature supported bits mask buffer. + + @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer + @param[in] AndFeatureBitMask The feature bit mask to do AND operation +**/ +VOID +SupportedMaskAnd ( + IN UINT8 *SupportedFeatureMask, + IN UINT8 *AndFeatureBitMask + ) +{ + UINTN Index; + UINTN BitMaskSize; + UINT8 *Data1; + UINT8 *Data2; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + Data1 = SupportedFeatureMask; + Data2 = AndFeatureBitMask; + for (Index = 0; Index < BitMaskSize; Index++) { + *(Data1++) &= *(Data2++); + } +} + +/** + Worker function to check if the compared CPU feature set in the CPU feature + supported bits mask buffer. + + @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer + @param[in] ComparedFeatureBitMask The feature bit mask to be compared + + @retval TRUE The ComparedFeatureBitMask is set in CPU feature supported bits + mask buffer. + @retval FALSE The ComparedFeatureBitMask is not set in CPU feature supported bits + mask buffer. +**/ +BOOLEAN +IsBitMaskMatch ( + IN UINT8 *SupportedFeatureMask, + IN UINT8 *ComparedFeatureBitMask + ) +{ + UINTN Index; + UINTN BitMaskSize; + UINT8 *Data1; + UINT8 *Data2; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + + Data1 = SupportedFeatureMask; + Data2 = ComparedFeatureBitMask; + for (Index = 0; Index < BitMaskSize; Index++) { + if (((*(Data1++)) & (*(Data2++))) != 0) { + return TRUE; + } + } + return FALSE; +} + +/** + Collects processor data for calling processor. + + @param[in,out] Buffer The pointer to private data buffer. +**/ +VOID +EFIAPI +CollectProcessorData ( + IN OUT VOID *Buffer + ) +{ + UINTN ProcessorNumber; + CPU_FEATURES_ENTRY *CpuFeature; + REGISTER_CPU_FEATURE_INFORMATION *CpuInfo; + LIST_ENTRY *Entry; + CPU_FEATURES_DATA *CpuFeaturesData; + + CpuFeaturesData = GetCpuFeaturesData (); + ProcessorNumber = GetProcessorIndex (); + CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo; + // + // collect processor information + // + FillProcessorInfo (CpuInfo); + Entry = GetFirstNode (&CpuFeaturesData->FeatureList); + while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { + CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + if (IsBitMaskMatch (CpuFeaturesData->SupportPcds, CpuFeature->FeatureMask)) { + if (CpuFeature->SupportFunc == NULL) { + // + // If SupportFunc is NULL, then the feature is supported. + // + SupportedMaskOr ( + CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, + CpuFeature->FeatureMask + ); + } else if (CpuFeature->SupportFunc (ProcessorNumber, CpuInfo, CpuFeature->ConfigData)) { + SupportedMaskOr ( + CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, + CpuFeature->FeatureMask + ); + } + } + Entry = Entry->ForwardLink; + } +} + +/** + Dump the contents of a CPU register table. + + @param[in] ProcessorNumber The index of the CPU to show the register table contents + + @note This service could be called by BSP only. +**/ +VOID +DumpRegisterTableOnProcessor ( + IN UINTN ProcessorNumber + ) +{ + CPU_FEATURES_DATA *CpuFeaturesData; + UINTN FeatureIndex; + CPU_REGISTER_TABLE *RegisterTable; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead; + UINT32 DebugPrintErrorLevel; + + DebugPrintErrorLevel = (ProcessorNumber == 0) ? DEBUG_INFO : DEBUG_VERBOSE; + CpuFeaturesData = GetCpuFeaturesData (); + // + // Debug information + // + RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; + DEBUG ((DebugPrintErrorLevel, "RegisterTable->TableLength = %d\n", RegisterTable->TableLength)); + + RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; + + for (FeatureIndex = 0; FeatureIndex < RegisterTable->TableLength; FeatureIndex++) { + RegisterTableEntry = &RegisterTableEntryHead[FeatureIndex]; + switch (RegisterTableEntry->RegisterType) { + case Msr: + DEBUG (( + DebugPrintErrorLevel, + "Processor: %d: MSR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", + ProcessorNumber, + RegisterTableEntry->Index, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitLength, + RegisterTableEntry->Value + )); + break; + case ControlRegister: + DEBUG (( + DebugPrintErrorLevel, + "Processor: %d: CR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", + ProcessorNumber, + RegisterTableEntry->Index, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitLength, + RegisterTableEntry->Value + )); + break; + case MemoryMapped: + DEBUG (( + DebugPrintErrorLevel, + "Processor: %d: MMIO: %lx, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", + ProcessorNumber, + RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32), + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitLength, + RegisterTableEntry->Value + )); + break; + case CacheControl: + DEBUG (( + DebugPrintErrorLevel, + "Processor: %d: CACHE: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", + ProcessorNumber, + RegisterTableEntry->Index, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitLength, + RegisterTableEntry->Value + )); + break; + default: + break; + } + } +} + +/** + Analysis register CPU features on each processor and save CPU setting in CPU register table. + + @param[in] NumberOfCpus Number of processor in system + +**/ +VOID +AnalysisProcessorFeatures ( + IN UINTN NumberOfCpus + ) +{ + EFI_STATUS Status; + UINTN ProcessorNumber; + CPU_FEATURES_ENTRY *CpuFeature; + CPU_FEATURES_ENTRY *CpuFeatureInOrder; + CPU_FEATURES_INIT_ORDER *CpuInitOrder; + REGISTER_CPU_FEATURE_INFORMATION *CpuInfo; + LIST_ENTRY *Entry; + CPU_FEATURES_DATA *CpuFeaturesData; + + CpuFeaturesData = GetCpuFeaturesData (); + CpuFeaturesData->CapabilityPcds = AllocatePool (CpuFeaturesData->BitMaskSize); + ASSERT (CpuFeaturesData->CapabilityPcds != NULL); + SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF); + for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { + CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; + // + // Calculate the last capability on all processors + // + SupportedMaskAnd (CpuFeaturesData->CapabilityPcds, CpuInitOrder->FeaturesSupportedMask); + } + // + // Calculate the last setting + // + + CpuFeaturesData->SettingPcds = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds); + ASSERT (CpuFeaturesData->SettingPcds != NULL); + SupportedMaskAnd (CpuFeaturesData->SettingPcds, CpuFeaturesData->ConfigurationPcds); + + // + // Save PCDs and display CPU PCDs + // + SetCapabilityPcd (CpuFeaturesData->CapabilityPcds); + SetSettingPcd (CpuFeaturesData->SettingPcds); + + // + // Dump the last CPU feature list + // + DEBUG_CODE ( + DEBUG ((DEBUG_INFO, "Last CPU features list...\n")); + Entry = GetFirstNode (&CpuFeaturesData->FeatureList); + while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { + CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) { + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcds)) { + DEBUG ((DEBUG_INFO, "[Enable ] ")); + } else { + DEBUG ((DEBUG_INFO, "[Disable ] ")); + } + } else { + DEBUG ((DEBUG_INFO, "[Unsupport] ")); + } + DumpCpuFeature (CpuFeature); + Entry = Entry->ForwardLink; + } + DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n")); + DumpCpuFeatureMask (CpuFeaturesData->SupportPcds); + DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n")); + DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcds); + DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n")); + DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcds); + DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n")); + DumpCpuFeatureMask (CpuFeaturesData->SettingPcds); + ); + + for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { + CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; + Entry = GetFirstNode (&CpuFeaturesData->FeatureList); + while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { + // + // Insert each feature into processor's order list + // + CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) { + CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), CpuFeature); + ASSERT (CpuFeatureInOrder != NULL); + InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Link); + } + Entry = Entry->ForwardLink; + } + // + // Go through ordered feature list to initialize CPU features + // + CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo; + Entry = GetFirstNode (&CpuInitOrder->OrderList); + while (!IsNull (&CpuInitOrder->OrderList, Entry)) { + CpuFeatureInOrder = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcds)) { + Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, TRUE); + } else { + Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, FALSE); + } + ASSERT_EFI_ERROR (Status); + Entry = Entry->ForwardLink; + } + // + // Dump the RegisterTable + // + DumpRegisterTableOnProcessor (ProcessorNumber); + } +} + +/** + Initialize the CPU registers from a register table. + + @param[in] ProcessorNumber The index of the CPU executing this function. + + @note This service could be called by BSP/APs. +**/ +VOID +ProgramProcessorRegister ( + IN UINTN ProcessorNumber + ) +{ + CPU_FEATURES_DATA *CpuFeaturesData; + CPU_REGISTER_TABLE *RegisterTable; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; + UINTN Index; + UINTN Value; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead; + + CpuFeaturesData = GetCpuFeaturesData (); + RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; + + // + // Traverse Register Table of this logical processor + // + RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; + + for (Index = 0; Index < RegisterTable->TableLength; Index++) { + + RegisterTableEntry = &RegisterTableEntryHead[Index]; + + // + // Check the type of specified register + // + switch (RegisterTableEntry->RegisterType) { + // + // The specified register is Control Register + // + case ControlRegister: + switch (RegisterTableEntry->Index) { + case 0: + Value = AsmReadCr0 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + AsmWriteCr0 (Value); + break; + case 2: + Value = AsmReadCr2 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + AsmWriteCr2 (Value); + break; + case 3: + Value = AsmReadCr3 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + AsmWriteCr3 (Value); + break; + case 4: + Value = AsmReadCr4 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + AsmWriteCr4 (Value); + break; + case 8: + // + // Do we need to support CR8? + // + break; + default: + break; + } + break; + // + // The specified register is Model Specific Register + // + case Msr: + // + // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode + // + AcquireSpinLock (&CpuFeaturesData->MsrLock); + if (RegisterTableEntry->ValidBitLength >= 64) { + // + // If length is not less than 64 bits, then directly write without reading + // + AsmWriteMsr64 ( + RegisterTableEntry->Index, + RegisterTableEntry->Value + ); + } else { + // + // Set the bit section according to bit start and length + // + AsmMsrBitFieldWrite64 ( + RegisterTableEntry->Index, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + } + ReleaseSpinLock (&CpuFeaturesData->MsrLock); + break; + // + // MemoryMapped operations + // + case MemoryMapped: + AcquireSpinLock (&CpuFeaturesData->MemoryMappedLock); + MmioBitFieldWrite32 ( + (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)), + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINT32)RegisterTableEntry->Value + ); + ReleaseSpinLock (&CpuFeaturesData->MemoryMappedLock); + break; + // + // Enable or disable cache + // + case CacheControl: + // + // If value of the entry is 0, then disable cache. Otherwise, enable cache. + // + if (RegisterTableEntry->Value == 0) { + AsmDisableCache (); + } else { + AsmEnableCache (); + } + break; + + default: + break; + } + } +} + +/** + Programs registers for the calling processor. + + @param[in,out] Buffer The pointer to private data buffer. + +**/ +VOID +EFIAPI +SetProcessorRegister ( + IN OUT VOID *Buffer + ) +{ + UINTN ProcessorNumber; + + ProcessorNumber = GetProcessorIndex (); + ProgramProcessorRegister (ProcessorNumber); +} + +/** + Performs CPU features detection. + + This service will invoke MP service to check CPU features' + capabilities on BSP/APs. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuFeaturesDetect ( + VOID + ) +{ + UINTN NumberOfCpus; + UINTN NumberOfEnabledProcessors; + + GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors); + + CpuInitDataInitialize (NumberOfCpus); + + // + // Wakeup all APs for data collection. + // + StartupAPsWorker (CollectProcessorData); + + // + // Collect data on BSP + // + CollectProcessorData (NULL); + + AnalysisProcessorFeatures (NumberOfCpus); +} + +/** + Performs CPU features Initialization. + + This service will invoke MP service to perform CPU features + initialization on BSP/APs per user configuration. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuFeaturesInitialize ( + VOID + ) +{ + CPU_FEATURES_DATA *CpuFeaturesData; + UINTN OldBspNumber; + + CpuFeaturesData = GetCpuFeaturesData (); + + OldBspNumber = GetProcessorIndex(); + CpuFeaturesData->BspNumber = OldBspNumber; + // + // Wakeup all APs for programming. + // + StartupAPsWorker (SetProcessorRegister); + // + // Programming BSP + // + SetProcessorRegister (NULL); + // + // Switch to new BSP if required + // + if (CpuFeaturesData->BspNumber != OldBspNumber) { + SwitchNewBsp (CpuFeaturesData->BspNumber); + } +} diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c new file mode 100644 index 0000000000..902a339529 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c @@ -0,0 +1,266 @@ +/** @file + CPU Register Table Library functions. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include + +#include "RegisterCpuFeatures.h" + +CPU_FEATURES_DATA mCpuFeaturesData = {0}; +EFI_MP_SERVICES_PROTOCOL *mCpuFeaturesMpServices = NULL; + +/** + Worker function to get CPU_FEATURES_DATA pointer. + + @return Pointer to CPU_FEATURES_DATA. +**/ +CPU_FEATURES_DATA * +GetCpuFeaturesData ( + VOID + ) +{ + return &mCpuFeaturesData; +} + +/** + Worker function to get EFI_MP_SERVICES_PROTOCOL pointer. + + @return Pointer to EFI_MP_SERVICES_PROTOCOL. +**/ +EFI_MP_SERVICES_PROTOCOL * +GetMpProtocol ( + VOID + ) +{ + EFI_STATUS Status; + + if (mCpuFeaturesMpServices == NULL) { + // + // Get MP Services Protocol + // + Status = gBS->LocateProtocol ( + &gEfiMpServiceProtocolGuid, + NULL, + (VOID **)&mCpuFeaturesMpServices + ); + ASSERT_EFI_ERROR (Status); + } + + ASSERT (mCpuFeaturesMpServices != NULL); + return mCpuFeaturesMpServices; +} + +/** + Worker function to return processor index. + + @return The processor index. +**/ +UINTN +GetProcessorIndex ( + VOID + ) +{ + EFI_STATUS Status; + UINTN ProcessorIndex; + EFI_MP_SERVICES_PROTOCOL *MpServices; + + MpServices = GetMpProtocol (); + Status = MpServices->WhoAmI(MpServices, &ProcessorIndex); + ASSERT_EFI_ERROR (Status); + return ProcessorIndex; +} + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. + + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @return Status of MpServices->GetProcessorInfo(). +**/ +EFI_STATUS +GetProcessorInformation ( + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpServices; + + MpServices = GetMpProtocol (); + Status = MpServices->GetProcessorInfo ( + MpServices, + ProcessorNumber, + ProcessorInfoBuffer + ); + return Status; +} + +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. +**/ +VOID +StartupAPsWorker ( + IN EFI_AP_PROCEDURE Procedure + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpServices; + + MpServices = GetMpProtocol (); + // + // Wakeup all APs + // + Status = MpServices->StartupAllAPs ( + MpServices, + Procedure, + FALSE, + NULL, + 0, + NULL, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to switch the requested AP to be the BSP from that point onward. + + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. +**/ +VOID +SwitchNewBsp ( + IN UINTN ProcessorNumber + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpServices; + + MpServices = GetMpProtocol (); + // + // Wakeup all APs + // + Status = MpServices->SwitchBSP ( + MpServices, + ProcessorNumber, + TRUE + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to retrieve the number of logical processor in the platform. + + @param[out] NumberOfCpus Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. +**/ +VOID +GetNumberOfProcessor ( + OUT UINTN *NumberOfCpus, + OUT UINTN *NumberOfEnabledProcessors + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpServices; + + MpServices = GetMpProtocol (); + + // + // Get the number of CPUs + // + Status = MpServices->GetNumberOfProcessors ( + MpServices, + NumberOfCpus, + NumberOfEnabledProcessors + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates ACPI NVS memory to save ACPI_CPU_DATA. + + @return Pointer to allocated ACPI_CPU_DATA. +**/ +ACPI_CPU_DATA * +AllocateAcpiCpuData ( + VOID + ) +{ + // + // CpuS3DataDxe will do it. + // + ASSERT (FALSE); + return NULL; +} + +/** + Enlarges CPU register table for each processor. + + @param[in, out] RegisterTable Pointer processor's CPU register table +**/ +VOID +EnlargeRegisterTable ( + IN OUT CPU_REGISTER_TABLE *RegisterTable + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Address; + UINTN AllocatePages; + + Address = BASE_4GB - 1; + AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + AllocatePages + 1, + &Address + ); + ASSERT_EFI_ERROR (Status); + + // + // If there are records existing in the register table, then copy its contents + // to new region and free the old one. + // + if (RegisterTable->AllocatedSize > 0) { + CopyMem ( + (VOID *) (UINTN) Address, + (VOID *) (UINTN) RegisterTable->RegisterTableEntry, + RegisterTable->AllocatedSize + ); + // + // RegisterTableEntry is allocated by gBS->AllocatePages() service. + // So, gBS->FreePages() service is used to free it. + // + gBS->FreePages ( + RegisterTable->RegisterTableEntry, + AllocatePages + ); + } + + // + // Adjust the allocated size and register table base address. + // + RegisterTable->AllocatedSize += EFI_PAGE_SIZE; + RegisterTable->RegisterTableEntry = Address; +} diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf new file mode 100644 index 0000000000..62ac8a9635 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf @@ -0,0 +1,62 @@ +## @file +# Register CPU Features Library DXE instance. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxeRegisterCpuFeaturesLib + MODULE_UNI_FILE = DxeRegisterCpuFeaturesLib.uni + FILE_GUID = ADE8F745-AA2E-49f6-8ED4-746B34867E52 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = RegisterCpuFeaturesLib|DXE_DRIVER + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.common] + DxeRegisterCpuFeaturesLib.c + RegisterCpuFeaturesLib.c + RegisterCpuFeatures.h + CpuFeaturesInitialize.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PcdLib + LocalApicLib + BaseMemoryLib + MemoryAllocationLib + SynchronizationLib + UefiBootServicesTableLib + IoLib + +[Protocols] + gEfiMpServiceProtocolGuid ## CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES + +[Depex] + gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c new file mode 100644 index 0000000000..6804eddf65 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c @@ -0,0 +1,390 @@ +/** @file + CPU Register Table Library functions. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include "RegisterCpuFeatures.h" + +#define REGISTER_CPU_FEATURES_GUID \ + { \ + 0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \ + } + +EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID; + +/** + Worker function to get CPU_FEATURES_DATA pointer. + + @return Pointer to CPU_FEATURES_DATA. +**/ +CPU_FEATURES_DATA * +GetCpuFeaturesData ( + VOID + ) +{ + CPU_FEATURES_DATA *CpuInitData; + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + UINT64 Data64; + + CpuInitData = NULL; + GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid); + if (GuidHob != NULL) { + DataInHob = GET_GUID_HOB_DATA (GuidHob); + CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob); + ASSERT (CpuInitData != NULL); + } else { + CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA)); + ASSERT (CpuInitData != NULL); + // + // Build location of CPU MP DATA buffer in HOB + // + Data64 = (UINT64) (UINTN) CpuInitData; + BuildGuidDataHob ( + &mRegisterCpuFeaturesHobGuid, + (VOID *) &Data64, + sizeof (UINT64) + ); + } + + return CpuInitData; +} + +/** + Worker function to get MP PPI service pointer. + + @return PEI PPI service pointer. +**/ +EFI_PEI_MP_SERVICES_PPI * +GetMpPpi ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + + // + // Get MP Services Protocol + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMpServicesPpiGuid, + 0, + NULL, + (VOID **)&CpuMpPpi + ); + ASSERT_EFI_ERROR (Status); + return CpuMpPpi; +} + +/** + Worker function to return processor index. + + @return The processor index. +**/ +UINTN +GetProcessorIndex ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + UINTN ProcessorIndex; + + CpuMpPpi = GetMpPpi (); + + Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex); + ASSERT_EFI_ERROR (Status); + return ProcessorIndex; +} + +/** + Worker function to MP-related information on the requested processor at the + instant this call is made. + + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @return Status of MpServices->GetProcessorInfo(). +**/ +EFI_STATUS +GetProcessorInformation ( + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + EFI_STATUS Status; + + CpuMpPpi = GetMpPpi (); + Status = CpuMpPpi->GetProcessorInfo ( + GetPeiServicesTablePointer(), + CpuMpPpi, + ProcessorNumber, + ProcessorInfoBuffer + ); + return Status; +} + +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. +**/ +VOID +StartupAPsWorker ( + IN EFI_AP_PROCEDURE Procedure + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + + // + // Get MP Services Protocol + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMpServicesPpiGuid, + 0, + NULL, + (VOID **)&CpuMpPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Wakeup all APs for data collection. + // + Status = CpuMpPpi->StartupAllAPs ( + GetPeiServicesTablePointer (), + CpuMpPpi, + Procedure, + FALSE, + 0, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to switch the requested AP to be the BSP from that point onward. + + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. +**/ +VOID +SwitchNewBsp ( + IN UINTN ProcessorNumber + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + + // + // Get MP Services Protocol + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMpServicesPpiGuid, + 0, + NULL, + (VOID **)&CpuMpPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Wakeup all APs for data collection. + // + Status = CpuMpPpi->SwitchBSP ( + GetPeiServicesTablePointer (), + CpuMpPpi, + ProcessorNumber, + TRUE + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Worker function to retrieve the number of logical processor in the platform. + + @param[out] NumberOfCpus Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. +**/ +VOID +GetNumberOfProcessor ( + OUT UINTN *NumberOfCpus, + OUT UINTN *NumberOfEnabledProcessors + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + + // + // Get MP Services Protocol + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMpServicesPpiGuid, + 0, + NULL, + (VOID **)&CpuMpPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Get the number of CPUs + // + Status = CpuMpPpi->GetNumberOfProcessors ( + GetPeiServicesTablePointer (), + CpuMpPpi, + NumberOfCpus, + NumberOfEnabledProcessors + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates ACPI NVS memory to save ACPI_CPU_DATA. + + @return Pointer to allocated ACPI_CPU_DATA. +**/ +ACPI_CPU_DATA * +AllocateAcpiCpuData ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; + UINTN NumberOfCpus; + UINTN NumberOfEnabledProcessors; + ACPI_CPU_DATA *AcpiCpuData; + EFI_PHYSICAL_ADDRESS Address; + UINTN TableSize; + CPU_REGISTER_TABLE *RegisterTable; + UINTN Index; + EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; + + Status = PeiServicesAllocatePages ( + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)), + &Address + ); + ASSERT_EFI_ERROR (Status); + AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address; + ASSERT (AcpiCpuData != NULL); + + // + // Get MP Services Protocol + // + Status = PeiServicesLocatePpi ( + &gEfiPeiMpServicesPpiGuid, + 0, + NULL, + (VOID **)&CpuMpPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Get the number of CPUs + // + Status = CpuMpPpi->GetNumberOfProcessors ( + GetPeiServicesTablePointer (), + CpuMpPpi, + &NumberOfCpus, + &NumberOfEnabledProcessors + ); + ASSERT_EFI_ERROR (Status); + AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; + + // + // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs + // + TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); + Status = PeiServicesAllocatePages ( + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (TableSize), + &Address + ); + ASSERT_EFI_ERROR (Status); + RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address; + + for (Index = 0; Index < NumberOfCpus; Index++) { + Status = CpuMpPpi->GetProcessorInfo ( + GetPeiServicesTablePointer (), + CpuMpPpi, + Index, + &ProcessorInfoBuffer + ); + ASSERT_EFI_ERROR (Status); + + RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; + RegisterTable[Index].TableLength = 0; + RegisterTable[Index].AllocatedSize = 0; + RegisterTable[Index].RegisterTableEntry = 0; + + RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; + RegisterTable[NumberOfCpus + Index].TableLength = 0; + RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; + RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; + } + AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; + AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); + + return AcpiCpuData; +} + +/** + Enlarges CPU register table for each processor. + + @param[in, out] RegisterTable Pointer processor's CPU register table +**/ +VOID +EnlargeRegisterTable ( + IN OUT CPU_REGISTER_TABLE *RegisterTable + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Address; + UINTN AllocatePages; + + AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; + Status = PeiServicesAllocatePages ( + EfiACPIMemoryNVS, + AllocatePages + 1, + &Address + ); + ASSERT_EFI_ERROR (Status); + + // + // If there are records existing in the register table, then copy its contents + // to new region and free the old one. + // + if (RegisterTable->AllocatedSize > 0) { + CopyMem ( + (VOID *) (UINTN) Address, + (VOID *) (UINTN) RegisterTable->RegisterTableEntry, + RegisterTable->AllocatedSize + ); + } + + // + // Adjust the allocated size and register table base address. + // + RegisterTable->AllocatedSize += EFI_PAGE_SIZE; + RegisterTable->RegisterTableEntry = Address; +} diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf new file mode 100644 index 0000000000..5e9ab2c304 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf @@ -0,0 +1,64 @@ +## @file +# Register CPU Features Library PEI instance. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PeiRegisterCpuFeaturesLib + MODULE_UNI_FILE = PeiRegisterCpuFeaturesLib.uni + FILE_GUID = D8855DB3-8348-41B5-BDA4-385351767D41 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + LIBRARY_CLASS = RegisterCpuFeaturesLib|PEIM + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources.common] + PeiRegisterCpuFeaturesLib.c + RegisterCpuFeaturesLib.c + RegisterCpuFeatures.h + CpuFeaturesInitialize.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PcdLib + LocalApicLib + BaseMemoryLib + MemoryAllocationLib + SynchronizationLib + HobLib + PeiServicesLib + PeiServicesTablePointerLib + IoLib + +[Ppis] + gEfiPeiMpServicesPpiGuid ## CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES + +[Depex] + gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h new file mode 100644 index 0000000000..7731f885b3 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h @@ -0,0 +1,193 @@ +/** @file + CPU Register Table Library definitions. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _REGISTER_CPU_FEATURES_H_ +#define _REGISTER_CPU_FEATURES_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S') + +#define CPU_FEATURE_NAME_SIZE 128 + +typedef struct { + REGISTER_CPU_FEATURE_INFORMATION CpuInfo; + UINT8 *FeaturesSupportedMask; + LIST_ENTRY OrderList; +} CPU_FEATURES_INIT_ORDER; + +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + UINT8 *FeatureMask; + CHAR8 *FeatureName; + CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc; + CPU_FEATURE_SUPPORT SupportFunc; + CPU_FEATURE_INITIALIZE InitializeFunc; + UINT8 *BeforeFeatureBitMask; + UINT8 *AfterFeatureBitMask; + VOID *ConfigData; + BOOLEAN BeforeAll; + BOOLEAN AfterAll; +} CPU_FEATURES_ENTRY; + +typedef struct { + UINTN FeaturesCount; + UINT32 BitMaskSize; + SPIN_LOCK MsrLock; + SPIN_LOCK MemoryMappedLock; + LIST_ENTRY FeatureList; + + CPU_FEATURES_INIT_ORDER *InitOrder; + UINT8 *SupportPcds; + UINT8 *CapabilityPcds; + UINT8 *ConfigurationPcds; + UINT8 *SettingPcds; + + CPU_REGISTER_TABLE *RegisterTable; + CPU_REGISTER_TABLE *PreSmmRegisterTable; + UINTN BspNumber; +} CPU_FEATURES_DATA; + +#define CPU_FEATURE_ENTRY_FROM_LINK(a) \ + CR ( \ + (a), \ + CPU_FEATURES_ENTRY, \ + Link, \ + CPU_FEATURE_ENTRY_SIGNATURE \ + ) + +/** + Worker function to get CPU_FEATURES_DATA pointer. + + @return Pointer to CPU_FEATURES_DATA. +**/ +CPU_FEATURES_DATA * +GetCpuFeaturesData ( + VOID + ); + +/** + Enlarges CPU register table for each processor. + + @param[in, out] RegisterTable Pointer processor's CPU register table +**/ +VOID +EnlargeRegisterTable ( + IN OUT CPU_REGISTER_TABLE *RegisterTable + ); + +/** + Allocates ACPI NVS memory to save ACPI_CPU_DATA. + + @return Pointer to allocated ACPI_CPU_DATA. +**/ +ACPI_CPU_DATA * +AllocateAcpiCpuData ( + VOID + ); + +/** + Worker function to return processor index. + + @return The processor index. +**/ +UINTN +GetProcessorIndex ( + VOID + ); + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. + + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @return Status of MpServices->GetProcessorInfo(). +**/ +EFI_STATUS +GetProcessorInformation ( + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run on + enabled APs of the system. +**/ +VOID +StartupAPsWorker ( + IN EFI_AP_PROCEDURE Procedure + ); + +/** + Worker function to retrieve the number of logical processor in the platform. + + @param[out] NumberOfCpus Pointer to the total number of logical + processors in the system, including the BSP + and disabled APs. + @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical + processors that exist in system, including + the BSP. +**/ +VOID +GetNumberOfProcessor ( + OUT UINTN *NumberOfCpus, + OUT UINTN *NumberOfEnabledProcessors + ); + +/** + Worker function to switch the requested AP to be the BSP from that point onward. + + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. +**/ +VOID +SwitchNewBsp ( + IN UINTN ProcessorNumber + ); + +/** + Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask. + + @param[in] FeatureMask A pointer to the CPU feature bit mask. +**/ +VOID +DumpCpuFeatureMask ( + IN UINT8 *FeatureMask + ); + +/** + Dump CPU feature name or CPU feature bit mask. + + @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY +**/ +VOID +DumpCpuFeature ( + IN CPU_FEATURES_ENTRY *CpuFeature + ); + +#endif diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni new file mode 100644 index 0000000000..d928952551 --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Register Table Library instance. +// +// CPU Register Table Library instance. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Register Table Library instance" + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Register Table Library instance." + diff --git a/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c new file mode 100644 index 0000000000..338f1a495c --- /dev/null +++ b/Core/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c @@ -0,0 +1,775 @@ +/** @file + CPU Register Table Library functions. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "RegisterCpuFeatures.h" + +/** + Checks if two CPU feature bit masks are equal. + + @param[in] FirstFeatureMask The first input CPU feature bit mask + @param[in] SecondFeatureMask The second input CPU feature bit mask + + @retval TRUE Two CPU feature bit masks are equal. + @retval FALSE Two CPU feature bit masks are not equal. +**/ +BOOLEAN +IsCpuFeatureMatch ( + IN UINT8 *FirstFeatureMask, + IN UINT8 *SecondFeatureMask + ) +{ + UINT32 BitMaskSize; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + if (CompareMem (FirstFeatureMask, SecondFeatureMask, BitMaskSize) == 0) { + return TRUE; + } else { + return FALSE; + } +} + +/** + Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask. + + @param[in] FeatureMask A pointer to the CPU feature bit mask. +**/ +VOID +DumpCpuFeatureMask ( + IN UINT8 *FeatureMask + ) +{ + UINTN Index; + UINT8 *Data8; + UINT32 BitMaskSize; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + Data8 = (UINT8 *) FeatureMask; + for (Index = 0; Index < BitMaskSize; Index++) { + DEBUG ((DEBUG_INFO, " %02x ", *Data8++)); + } + DEBUG ((DEBUG_INFO, "\n")); +} + +/** + Dump CPU feature name or CPU feature bit mask. + + @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY +**/ +VOID +DumpCpuFeature ( + IN CPU_FEATURES_ENTRY *CpuFeature + ) +{ + + if (CpuFeature->FeatureName != NULL) { + DEBUG ((DEBUG_INFO, "FeatureName: %a\n", CpuFeature->FeatureName)); + } else { + DEBUG ((DEBUG_INFO, "FeatureMask = ")); + DumpCpuFeatureMask (CpuFeature->FeatureMask); + } +} + +/** + Determines if the feature bit mask is in dependent CPU feature bit mask buffer. + + @param[in] FeatureMask Pointer to CPU feature bit mask + @param[in] DependentBitMask Pointer to dependent CPU feature bit mask buffer + + @retval TRUE The feature bit mask is in dependent CPU feature bit mask buffer. + @retval FALSE The feature bit mask is not in dependent CPU feature bit mask buffer. +**/ +BOOLEAN +IsBitMaskMatchCheck ( + IN UINT8 *FeatureMask, + IN UINT8 *DependentBitMask + ) +{ + UINTN Index; + UINTN BitMaskSize; + UINT8 *Data1; + UINT8 *Data2; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + + Data1 = FeatureMask; + Data2 = DependentBitMask; + for (Index = 0; Index < BitMaskSize; Index++) { + if (((*(Data1++)) & (*(Data2++))) != 0) { + return TRUE; + } + } + return FALSE; +} + +/** + Checks and adjusts CPU features order per dependency relationship. + + @param[in] FeatureList Pointer to CPU feature list +**/ +VOID +CheckCpuFeaturesDependency ( + IN LIST_ENTRY *FeatureList + ) +{ + LIST_ENTRY *CurrentEntry; + CPU_FEATURES_ENTRY *CpuFeature; + LIST_ENTRY *CheckEntry; + CPU_FEATURES_ENTRY *CheckFeature; + BOOLEAN Swapped; + LIST_ENTRY *TempEntry; + + CurrentEntry = GetFirstNode (FeatureList); + while (!IsNull (FeatureList, CurrentEntry)) { + Swapped = FALSE; + CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (CurrentEntry); + if (CpuFeature->BeforeAll) { + // + // Check all features dispatched before this entry + // + CheckEntry = GetFirstNode (FeatureList); + while (CheckEntry != CurrentEntry) { + CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); + if (!CheckFeature->BeforeAll) { + // + // If this feature has no BeforeAll flag and is dispatched before CpuFeature, + // insert currentEntry before Checked feature + // + RemoveEntryList (CurrentEntry); + InsertTailList (CheckEntry, CurrentEntry); + Swapped = TRUE; + break; + } + CheckEntry = CheckEntry->ForwardLink; + } + if (Swapped) { + continue; + } + } + + if (CpuFeature->AfterAll) { + // + // Check all features dispatched after this entry + // + CheckEntry = GetNextNode (FeatureList, CurrentEntry); + while (!IsNull (FeatureList, CheckEntry)) { + CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); + if (!CheckFeature->AfterAll) { + // + // If this feature has no AfterAll flag and is dispatched after CpuFeature, + // insert currentEntry after Checked feature + // + TempEntry = GetNextNode (FeatureList, CurrentEntry); + RemoveEntryList (CurrentEntry); + InsertHeadList (CheckEntry, CurrentEntry); + CurrentEntry = TempEntry; + Swapped = TRUE; + break; + } + CheckEntry = CheckEntry->ForwardLink; + } + if (Swapped) { + continue; + } + } + + if (CpuFeature->BeforeFeatureBitMask != NULL) { + // + // Check all features dispatched before this entry + // + CheckEntry = GetFirstNode (FeatureList); + while (CheckEntry != CurrentEntry) { + CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); + if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->BeforeFeatureBitMask)) { + // + // If there is dependency, swap them + // + RemoveEntryList (CurrentEntry); + InsertTailList (CheckEntry, CurrentEntry); + Swapped = TRUE; + break; + } + CheckEntry = CheckEntry->ForwardLink; + } + if (Swapped) { + continue; + } + } + + if (CpuFeature->AfterFeatureBitMask != NULL) { + // + // Check all features dispatched after this entry + // + CheckEntry = GetNextNode (FeatureList, CurrentEntry); + while (!IsNull (FeatureList, CheckEntry)) { + CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); + if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->AfterFeatureBitMask)) { + // + // If there is dependency, swap them + // + TempEntry = GetNextNode (FeatureList, CurrentEntry); + RemoveEntryList (CurrentEntry); + InsertHeadList (CheckEntry, CurrentEntry); + CurrentEntry = TempEntry; + Swapped = TRUE; + break; + } + CheckEntry = CheckEntry->ForwardLink; + } + if (Swapped) { + continue; + } + } + // + // No swap happened, check the next feature + // + CurrentEntry = CurrentEntry->ForwardLink; + } +} + +/** + Worker function to register CPU Feature. + + @param[in] CpuFeature Pointer to CPU feature entry + + @retval RETURN_SUCCESS The CPU feature was successfully registered. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register + the CPU feature. + @retval RETURN_UNSUPPORTED Registration of the CPU feature is not + supported due to a circular dependency between + BEFORE and AFTER features. +**/ +RETURN_STATUS +RegisterCpuFeatureWorker ( + IN CPU_FEATURES_ENTRY *CpuFeature + ) +{ + EFI_STATUS Status; + CPU_FEATURES_DATA *CpuFeaturesData; + CPU_FEATURES_ENTRY *CpuFeatureEntry; + LIST_ENTRY *Entry; + UINT32 BitMaskSize; + BOOLEAN FeatureExist; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + CpuFeaturesData = GetCpuFeaturesData (); + if (CpuFeaturesData->FeaturesCount == 0) { + InitializeListHead (&CpuFeaturesData->FeatureList); + InitializeSpinLock (&CpuFeaturesData->MsrLock); + InitializeSpinLock (&CpuFeaturesData->MemoryMappedLock); + CpuFeaturesData->BitMaskSize = BitMaskSize; + } + ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize); + + FeatureExist = FALSE; + CpuFeatureEntry = NULL; + Entry = GetFirstNode (&CpuFeaturesData->FeatureList); + while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { + CpuFeatureEntry = CPU_FEATURE_ENTRY_FROM_LINK (Entry); + if (IsCpuFeatureMatch (CpuFeature->FeatureMask, CpuFeatureEntry->FeatureMask)) { + // + // If this feature already registered + // + FeatureExist = TRUE; + break; + } + Entry = Entry->ForwardLink; + } + + if (!FeatureExist) { + DEBUG ((DEBUG_INFO, "[NEW] ")); + DumpCpuFeature (CpuFeature); + InsertTailList (&CpuFeaturesData->FeatureList, &CpuFeature->Link); + CpuFeaturesData->FeaturesCount++; + } else { + DEBUG ((DEBUG_INFO, "[OVERRIDE] ")); + DumpCpuFeature (CpuFeature); + ASSERT (CpuFeatureEntry != NULL); + // + // Overwrite original parameters of CPU feature + // + if (CpuFeature->GetConfigDataFunc != NULL) { + CpuFeatureEntry->GetConfigDataFunc = CpuFeature->GetConfigDataFunc; + } + if (CpuFeature->SupportFunc != NULL) { + CpuFeatureEntry->SupportFunc = CpuFeature->SupportFunc; + } + if (CpuFeature->InitializeFunc != NULL) { + CpuFeatureEntry->InitializeFunc = CpuFeature->InitializeFunc; + } + if (CpuFeature->FeatureName != NULL) { + if (CpuFeatureEntry->FeatureName == NULL) { + CpuFeatureEntry->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE); + ASSERT (CpuFeatureEntry->FeatureName != NULL); + } + Status = AsciiStrCpyS (CpuFeatureEntry->FeatureName, CPU_FEATURE_NAME_SIZE, CpuFeature->FeatureName); + ASSERT_EFI_ERROR (Status); + FreePool (CpuFeature->FeatureName); + } + if (CpuFeature->BeforeFeatureBitMask != NULL) { + if (CpuFeatureEntry->BeforeFeatureBitMask != NULL) { + FreePool (CpuFeatureEntry->BeforeFeatureBitMask); + } + CpuFeatureEntry->BeforeFeatureBitMask = CpuFeature->BeforeFeatureBitMask; + } + if (CpuFeature->AfterFeatureBitMask != NULL) { + if (CpuFeatureEntry->AfterFeatureBitMask != NULL) { + FreePool (CpuFeatureEntry->AfterFeatureBitMask); + } + CpuFeatureEntry->AfterFeatureBitMask = CpuFeature->AfterFeatureBitMask; + } + CpuFeatureEntry->BeforeAll = CpuFeature->BeforeAll; + CpuFeatureEntry->AfterAll = CpuFeature->AfterAll; + + FreePool (CpuFeature->FeatureMask); + FreePool (CpuFeature); + } + // + // Verify CPU features dependency can change CPU feature order + // + CheckCpuFeaturesDependency (&CpuFeaturesData->FeatureList); + return RETURN_SUCCESS; +} + +/** + Sets CPU feature bit mask in CPU feature bit mask buffer. + + @param[in] FeaturesBitMask Pointer to CPU feature bit mask buffer + @param[in] Feature The bit number of the CPU feature + @param[in] BitMaskSize CPU feature bit mask buffer size +**/ +VOID +SetCpuFeaturesBitMask ( + IN UINT8 **FeaturesBitMask, + IN UINT32 Feature, + IN UINTN BitMaskSize + ) +{ + UINT8 *CpuFeaturesBitMask; + + ASSERT (FeaturesBitMask != NULL); + CpuFeaturesBitMask = *FeaturesBitMask; + if (CpuFeaturesBitMask == NULL) { + CpuFeaturesBitMask = AllocateZeroPool (BitMaskSize); + ASSERT (CpuFeaturesBitMask != NULL); + *FeaturesBitMask = CpuFeaturesBitMask; + } + + CpuFeaturesBitMask += (Feature / 8); + *CpuFeaturesBitMask |= (UINT8) (1 << (Feature % 8)); +} + +/** + Registers a CPU Feature. + + @param[in] FeatureName A Null-terminated Ascii string indicates CPU feature + name. + @param[in] GetConfigDataFunc CPU feature get configuration data function. This + is an optional parameter that may be NULL. If NULL, + then the most recently registered function for the + CPU feature is used. If no functions are registered + for a CPU feature, then the CPU configuration data + for the registered feature is NULL. + @param[in] SupportFunc CPU feature support function. This is an optional + parameter that may be NULL. If NULL, then the most + recently registered function for the CPU feature is + used. If no functions are registered for a CPU + feature, then the CPU feature is assumed to be + supported by all CPUs. + @param[in] InitializeFunc CPU feature initialize function. This is an optional + parameter that may be NULL. If NULL, then the most + recently registered function for the CPU feature is + used. If no functions are registered for a CPU + feature, then the CPU feature initialization is + skipped. + @param[in] ... Variable argument list of UINT32 CPU feature value. + Values with no modifiers are the features provided + by the registered functions. + Values with CPU_FEATURE_BEFORE modifier are features + that must be initialized after the features provided + by the registered functions are used. + Values with CPU_FEATURE_AFTER modifier are features + that must be initialized before the features provided + by the registered functions are used. + The last argument in this variable argument list must + always be CPU_FEATURE_END. + + @retval RETURN_SUCCESS The CPU feature was successfully registered. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register + the CPU feature. + @retval RETURN_UNSUPPORTED Registration of the CPU feature is not + supported due to a circular dependency between + BEFORE and AFTER features. + + @note This service could be called by BSP only. +**/ +RETURN_STATUS +EFIAPI +RegisterCpuFeature ( + IN CHAR8 *FeatureName, OPTIONAL + IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc, OPTIONAL + IN CPU_FEATURE_SUPPORT SupportFunc, OPTIONAL + IN CPU_FEATURE_INITIALIZE InitializeFunc, OPTIONAL + ... + ) +{ + EFI_STATUS Status; + VA_LIST Marker; + UINT32 Feature; + UINTN BitMaskSize; + CPU_FEATURES_ENTRY *CpuFeature; + UINT8 *FeatureMask; + UINT8 *BeforeFeatureBitMask; + UINT8 *AfterFeatureBitMask; + BOOLEAN BeforeAll; + BOOLEAN AfterAll; + + FeatureMask = NULL; + BeforeFeatureBitMask = NULL; + AfterFeatureBitMask = NULL; + BeforeAll = FALSE; + AfterAll = FALSE; + + BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); + + VA_START (Marker, InitializeFunc); + Feature = VA_ARG (Marker, UINT32); + while (Feature != CPU_FEATURE_END) { + ASSERT ((Feature & (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER)) + != (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER)); + ASSERT ((Feature & (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL)) + != (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL)); + if (Feature < CPU_FEATURE_BEFORE) { + BeforeAll = ((Feature & CPU_FEATURE_BEFORE_ALL) != 0) ? TRUE : FALSE; + AfterAll = ((Feature & CPU_FEATURE_AFTER_ALL) != 0) ? TRUE : FALSE; + Feature &= ~(CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL); + ASSERT (FeatureMask == NULL); + SetCpuFeaturesBitMask (&FeatureMask, Feature, BitMaskSize); + } else if ((Feature & CPU_FEATURE_BEFORE) != 0) { + SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATURE_BEFORE, BitMaskSize); + } else if ((Feature & CPU_FEATURE_AFTER) != 0) { + SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATURE_AFTER, BitMaskSize); + } + Feature = VA_ARG (Marker, UINT32); + } + VA_END (Marker); + + CpuFeature = AllocateZeroPool (sizeof (CPU_FEATURES_ENTRY)); + ASSERT (CpuFeature != NULL); + CpuFeature->Signature = CPU_FEATURE_ENTRY_SIGNATURE; + CpuFeature->FeatureMask = FeatureMask; + CpuFeature->BeforeFeatureBitMask = BeforeFeatureBitMask; + CpuFeature->AfterFeatureBitMask = AfterFeatureBitMask; + CpuFeature->BeforeAll = BeforeAll; + CpuFeature->AfterAll = AfterAll; + CpuFeature->GetConfigDataFunc = GetConfigDataFunc; + CpuFeature->SupportFunc = SupportFunc; + CpuFeature->InitializeFunc = InitializeFunc; + if (FeatureName != NULL) { + CpuFeature->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE); + ASSERT (CpuFeature->FeatureName != NULL); + Status = AsciiStrCpyS (CpuFeature->FeatureName, CPU_FEATURE_NAME_SIZE, FeatureName); + ASSERT_EFI_ERROR (Status); + } + + Status = RegisterCpuFeatureWorker (CpuFeature); + ASSERT_EFI_ERROR (Status); + + return RETURN_SUCCESS; +} + +/** + Add an entry in specified register table. + + This function adds an entry in specified register table, with given register type, + register index, bit section and value. + + @param[in] PreSmmFlag If TRUE, entry will be added into PreSmm register table + If FALSE, entry will be added into register table + @param[in] ProcessorNumber The index of the CPU to add a register table entry + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] ValidBitStart Start of the bit section + @param[in] ValidBitLength Length of the bit section + @param[in] Value Value to write +**/ +VOID +CpuRegisterTableWriteWorker ( + IN BOOLEAN PreSmmFlag, + IN UINTN ProcessorNumber, + IN REGISTER_TYPE RegisterType, + IN UINT64 Index, + IN UINT8 ValidBitStart, + IN UINT8 ValidBitLength, + IN UINT64 Value + ) +{ + EFI_STATUS Status; + CPU_FEATURES_DATA *CpuFeaturesData; + ACPI_CPU_DATA *AcpiCpuData; + CPU_REGISTER_TABLE *RegisterTable; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; + + CpuFeaturesData = GetCpuFeaturesData (); + if (CpuFeaturesData->RegisterTable == NULL) { + AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress); + if (AcpiCpuData == NULL) { + AcpiCpuData = AllocateAcpiCpuData (); + ASSERT (AcpiCpuData != NULL); + // + // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure + // + Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData); + ASSERT_EFI_ERROR (Status); + } + ASSERT (AcpiCpuData->RegisterTable != 0); + CpuFeaturesData->RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->RegisterTable; + CpuFeaturesData->PreSmmRegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->PreSmmInitRegisterTable; + } + + if (PreSmmFlag) { + RegisterTable = &CpuFeaturesData->PreSmmRegisterTable[ProcessorNumber]; + } else { + RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; + } + + if (RegisterTable->TableLength == RegisterTable->AllocatedSize / sizeof (CPU_REGISTER_TABLE_ENTRY)) { + EnlargeRegisterTable (RegisterTable); + } + + // + // Append entry in the register table. + // + RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; + RegisterTableEntry[RegisterTable->TableLength].RegisterType = RegisterType; + RegisterTableEntry[RegisterTable->TableLength].Index = (UINT32) Index; + RegisterTableEntry[RegisterTable->TableLength].HighIndex = (UINT32) RShiftU64 (Index, 32); + RegisterTableEntry[RegisterTable->TableLength].ValidBitStart = ValidBitStart; + RegisterTableEntry[RegisterTable->TableLength].ValidBitLength = ValidBitLength; + RegisterTableEntry[RegisterTable->TableLength].Value = Value; + + RegisterTable->TableLength++; +} + +/** + Adds an entry in specified register table. + + This function adds an entry in specified register table, with given register type, + register index, bit section and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] ValueMask Mask of bits in register to write + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +CpuRegisterTableWrite ( + IN UINTN ProcessorNumber, + IN REGISTER_TYPE RegisterType, + IN UINT64 Index, + IN UINT64 ValueMask, + IN UINT64 Value + ) +{ + UINT8 Start; + UINT8 End; + UINT8 Length; + + Start = (UINT8)LowBitSet64 (ValueMask); + End = (UINT8)HighBitSet64 (ValueMask); + Length = End - Start + 1; + CpuRegisterTableWriteWorker (FALSE, ProcessorNumber, RegisterType, Index, Start, Length, Value); +} + +/** + Adds an entry in specified Pre-SMM register table. + + This function adds an entry in specified register table, with given register type, + register index, bit section and value. + + @param[in] ProcessorNumber The index of the CPU to add a register table entry. + @param[in] RegisterType Type of the register to program + @param[in] Index Index of the register to program + @param[in] ValueMask Mask of bits in register to write + @param[in] Value Value to write + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +PreSmmCpuRegisterTableWrite ( + IN UINTN ProcessorNumber, + IN REGISTER_TYPE RegisterType, + IN UINT64 Index, + IN UINT64 ValueMask, + IN UINT64 Value + ) +{ + UINT8 Start; + UINT8 End; + UINT8 Length; + + Start = (UINT8)LowBitSet64 (ValueMask); + End = (UINT8)HighBitSet64 (ValueMask); + Length = End - Start + 1; + CpuRegisterTableWriteWorker (TRUE, ProcessorNumber, RegisterType, Index, Start, Length, Value); +} + +/** + Worker function to determine if a CPU feature is set in input CPU feature bit mask buffer. + + @param[in] CpuBitMask CPU feature bit mask buffer + @param[in] CpuBitMaskSize The size of CPU feature bit mask buffer + @param[in] Feature The bit number of the CPU feature + + @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. + +**/ +BOOLEAN +IsCpuFeatureSetInCpuPcd ( + IN UINT8 *CpuBitMask, + IN UINTN CpuBitMaskSize, + IN UINT32 Feature + ) +{ + if ((Feature >> 3) >= CpuBitMaskSize) { + return FALSE; + } + return ((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 0x07))) != 0); +} + +/** + Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask. + If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data + associated with that feature should be optimized away if compiler + optimizations are enabled. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesSupport + + @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureSupported ( + IN UINT32 Feature + ) +{ + return IsCpuFeatureSetInCpuPcd ( + (UINT8 *)PcdGetPtr (PcdCpuFeaturesSupport), + PcdGetSize (PcdCpuFeaturesSupport), + Feature + ); +} + +/** + Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesSetting + + @retval TRUE The CPU feature is set in PcdCpuFeaturesSetting. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesSetting. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureInSetting ( + IN UINT32 Feature + ) +{ + return IsCpuFeatureSetInCpuPcd ( + (UINT8 *)PcdGetPtr (PcdCpuFeaturesSetting), + PcdGetSize (PcdCpuFeaturesSetting), + Feature + ); +} + +/** + Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesCapability + + @retval TRUE The CPU feature is set in PcdCpuFeaturesCapability. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesCapability. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureCapability ( + IN UINT32 Feature + ) +{ + return IsCpuFeatureSetInCpuPcd ( + (UINT8 *)PcdGetPtr (PcdCpuFeaturesCapability), + PcdGetSize (PcdCpuFeaturesCapability), + Feature + ); + +} + +/** + Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask. + + @param[in] Feature The bit number of the CPU feature to check in the PCD + PcdCpuFeaturesUserConfiguration + + @retval TRUE The CPU feature is set in PcdCpuFeaturesUserConfiguration. + @retval FALSE The CPU feature is not set in PcdCpuFeaturesUserConfiguration. + + @note This service could be called by BSP only. +**/ +BOOLEAN +EFIAPI +IsCpuFeatureUserConfiguration ( + IN UINT32 Feature + ) +{ + return IsCpuFeatureSetInCpuPcd ( + (UINT8 *)PcdGetPtr (PcdCpuFeaturesUserConfiguration), + PcdGetSize (PcdCpuFeaturesUserConfiguration), + Feature + ); + +} + +/** + Switches to assigned BSP after CPU features initialization. + + @param[in] ProcessorNumber The index of the CPU executing this function. + + @note This service could be called by BSP only. +**/ +VOID +EFIAPI +SwitchBspAfterFeaturesInitialize ( + IN UINTN ProcessorNumber + ) +{ + CPU_FEATURES_DATA *CpuFeaturesData; + + CpuFeaturesData = GetCpuFeaturesData (); + CpuFeaturesData->BspNumber = ProcessorNumber; +} + diff --git a/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c new file mode 100644 index 0000000000..714b99eec4 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c @@ -0,0 +1,216 @@ +/** @file + Timer Library functions built upon ITC on IPF. + + Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include + + +/** + Performs a delay measured as number of ticks. + + An internal function to perform a delay measured as number of ticks. It's + invoked by MicroSecondDelay() and NanoSecondDelay(). + + @param Delay The number of ticks to delay. + +**/ +VOID +EFIAPI +InternalIpfDelay ( + IN INT64 Delay + ) +{ + INT64 Ticks; + + // + // The target timer count is calculated here + // + Ticks = (INT64)AsmReadItc () + Delay; + + // + // Wait until time out + // Delay > 2^63 could not be handled by this function + // Timer wrap-arounds are handled correctly by this function + // + while (Ticks - (INT64)AsmReadItc() >= 0); +} + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return The value of MicroSeconds inputted. + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + InternalIpfDelay ( + GetPerformanceCounterProperties (NULL, NULL) * + MicroSeconds / + 1000000 + ); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return The value of NanoSeconds inputted. + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + InternalIpfDelay ( + GetPerformanceCounterProperties (NULL, NULL) * + NanoSeconds / + 1000000000 + ); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + The counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + return AsmReadItc (); +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ) +{ + PAL_CALL_RETURN PalRet; + UINT64 BaseFrequence; + + if (StartValue != NULL) { + *StartValue = 0; + } + + if (EndValue != NULL) { + *EndValue = (UINT64)(-1); + } + + PalRet = PalCall (PAL_FREQ_BASE, 0, 0, 0); + if (PalRet.Status != 0) { + return 1000000; + } + BaseFrequence = PalRet.r9; + + PalRet = PalCall (PAL_FREQ_RATIOS, 0, 0, 0); + if (PalRet.Status != 0) { + return 1000000; + } + + return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11; +} + +/** + Converts elapsed ticks of performance counter to time in nanoseconds. + + This function converts the elapsed ticks of running performance counter to + time value in unit of nanoseconds. + + @param Ticks The number of elapsed ticks of running performance counter. + + @return The elapsed time in nanoseconds. + +**/ +UINT64 +EFIAPI +GetTimeInNanoSecond ( + IN UINT64 Ticks + ) +{ + UINT64 Frequency; + UINT64 NanoSeconds; + UINT64 Remainder; + INTN Shift; + + Frequency = GetPerformanceCounterProperties (NULL, NULL); + + // + // Ticks + // Time = --------- x 1,000,000,000 + // Frequency + // + NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u); + + // + // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit. + // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34, + // i.e. highest bit set in Remainder should <= 33. + // + Shift = MAX (0, HighBitSet64 (Remainder) - 33); + Remainder = RShiftU64 (Remainder, (UINTN) Shift); + Frequency = RShiftU64 (Frequency, (UINTN) Shift); + NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); + + return NanoSeconds; +} diff --git a/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf new file mode 100644 index 0000000000..a25e94a61a --- /dev/null +++ b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf @@ -0,0 +1,67 @@ +## @file +# Instance of Timer Library only using CPU resources. +# +# Timer Library that only uses CPU resources to provide calibrated delays +# on IA-32, x64, and IPF. +# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib +# in their initialization without any issues. They only have to be careful in +# the implementation of runtime services and SMI handlers. +# Because CPU Local APIC and ITC could be programmed by OS, it cannot be +# used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM +# drivers and runtime drivers. +# +# This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in +# that it uses the local APIC library so that it supports x2APIC mode. +# +# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SecPeiDxeTimerLibUefiCpu + MODULE_UNI_FILE = SecPeiDxeTimerLibUefiCpu.uni + FILE_GUID = 4FFF2014-2086-4ee6-9B58-886D1967861C + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = TimerLib + + +# +# VALID_ARCHITECTURES = IA32 X64 IPF +# + +[Sources.Ia32, Sources.X64] + X86TimerLib.c + +[Sources.IPF] + IpfTimerLib.c + + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + +[LibraryClasses.IA32, LibraryClasses.X64] + PcdLib + DebugLib + LocalApicLib + +[LibraryClasses.IPF] + PalLib + + +[Pcd.IA32, Pcd.X64] + gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## SOMETIMES_CONSUMES + diff --git a/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni new file mode 100644 index 0000000000..da9e4d8191 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni @@ -0,0 +1,31 @@ +// /** @file +// Instance of Timer Library only using CPU resources. +// +// Timer Library that only uses CPU resources to provide calibrated delays +// on IA-32, x64, and IPF. +// Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib +// in their initialization without any issues. They only have to be careful in +// the implementation of runtime services and SMI handlers. +// Because CPU Local APIC and ITC could be programmed by OS, it cannot be +// used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM +// drivers and runtime drivers. +// +// This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in +// that it uses the local APIC library so that it supports x2APIC mode. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php. +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Instance of Timer Library only using CPU resources" + +#string STR_MODULE_DESCRIPTION #language en-US "Timer Library that only uses CPU resources to provide calibrated delays on IA-32, x64, and IPF. Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib in their initialization without any issues. They only have to be careful in the implementation of runtime services and SMI handlers. Because CPU Local APIC and ITC could be programmed by OS, it cannot be used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM drivers and runtime drivers. This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in that it uses the local APIC library so that it supports x2APIC mode." + diff --git a/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c new file mode 100644 index 0000000000..f703d7e477 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c @@ -0,0 +1,266 @@ +/** @file + Timer Library functions built upon local APIC on IA32/x64. + + This library uses the local APIC library so that it supports x2APIC mode. + + Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include + +/** + Internal function to return the frequency of the local APIC timer. + + @return The frequency of the timer in Hz. + +**/ +UINT32 +EFIAPI +InternalX86GetTimerFrequency ( + VOID + ) +{ + UINTN Divisor; + + GetApicTimerState (&Divisor, NULL, NULL); + return PcdGet32(PcdFSBClock) / (UINT32)Divisor; +} + +/** + Stalls the CPU for at least the given number of ticks. + + Stalls the CPU for at least the given number of ticks. It's invoked by + MicroSecondDelay() and NanoSecondDelay(). + + This function will ASSERT if the APIC timer intial count returned from + GetApicTimerInitCount() is zero. + + @param Delay A period of time to delay in ticks. + +**/ +VOID +EFIAPI +InternalX86Delay ( + IN UINT32 Delay + ) +{ + INT32 Ticks; + UINT32 Times; + UINT32 InitCount; + UINT32 StartTick; + + // + // In case Delay is too larger, separate it into several small delay slot. + // Devided Delay by half value of Init Count is to avoid Delay close to + // the Init Count, timeout maybe missing if the time consuming between 2 + // GetApicTimerCurrentCount() invoking is larger than the time gap between + // Delay and the Init Count. + // + InitCount = GetApicTimerInitCount (); + ASSERT (InitCount != 0); + Times = Delay / (InitCount / 2); + Delay = Delay % (InitCount / 2); + + // + // Get Start Tick and do delay + // + StartTick = GetApicTimerCurrentCount (); + do { + // + // Wait until time out by Delay value + // + do { + CpuPause (); + // + // Get Ticks from Start to Current. + // + Ticks = StartTick - GetApicTimerCurrentCount (); + // + // Ticks < 0 means Timer wrap-arounds happens. + // + if (Ticks < 0) { + Ticks += InitCount; + } + } while ((UINT32)Ticks < Delay); + + // + // Update StartTick and Delay for next delay slot + // + StartTick -= (StartTick > Delay) ? Delay : (Delay - InitCount); + Delay = InitCount / 2; + } while (Times-- > 0); +} + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return The value of MicroSeconds inputted. + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + InternalX86Delay ( + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (), + MicroSeconds + ), + 1000000u + ) + ); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return The value of NanoSeconds inputted. + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + InternalX86Delay ( + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (), + NanoSeconds + ), + 1000000000u + ) + ); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + The counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + return (UINT64)GetApicTimerCurrentCount (); +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ) +{ + if (StartValue != NULL) { + *StartValue = (UINT64)GetApicTimerInitCount (); + } + + if (EndValue != NULL) { + *EndValue = 0; + } + + return (UINT64) InternalX86GetTimerFrequency (); +} + +/** + Converts elapsed ticks of performance counter to time in nanoseconds. + + This function converts the elapsed ticks of running performance counter to + time value in unit of nanoseconds. + + @param Ticks The number of elapsed ticks of running performance counter. + + @return The elapsed time in nanoseconds. + +**/ +UINT64 +EFIAPI +GetTimeInNanoSecond ( + IN UINT64 Ticks + ) +{ + UINT64 Frequency; + UINT64 NanoSeconds; + UINT64 Remainder; + INTN Shift; + + Frequency = GetPerformanceCounterProperties (NULL, NULL); + + // + // Ticks + // Time = --------- x 1,000,000,000 + // Frequency + // + NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u); + + // + // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit. + // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34, + // i.e. highest bit set in Remainder should <= 33. + // + Shift = MAX (0, HighBitSet64 (Remainder) - 33); + Remainder = RShiftU64 (Remainder, (UINTN) Shift); + Frequency = RShiftU64 (Frequency, (UINTN) Shift); + NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); + + return NanoSeconds; +} diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S new file mode 100644 index 0000000000..4c0f8c8933 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S @@ -0,0 +1,278 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiEntry.S +# +# Abstract: +# +# Code template of the SMI handler for a particular processor +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerTemplate) +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerSize) +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerOffset) +ASM_GLOBAL ASM_PFX(gStmSmiCr3) +ASM_GLOBAL ASM_PFX(gStmSmiStack) +ASM_GLOBAL ASM_PFX(gStmSmbase) +ASM_GLOBAL ASM_PFX(gStmXdSupported) +ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) +ASM_GLOBAL ASM_PFX(gStmSmiHandlerIdtr) + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0xc0000080 +.equ MSR_EFER_XD, 0x800 + +# +# Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +# +.equ DSC_OFFSET, 0xfb00 +.equ DSC_GDTPTR, 0x48 +.equ DSC_GDTSIZ, 0x50 +.equ DSC_CS, 0x14 +.equ DSC_DS, 0x16 +.equ DSC_SS, 0x18 +.equ DSC_OTHERSEG, 0x1A + +.equ PROTECT_MODE_CS, 0x08 +.equ PROTECT_MODE_DS, 0x20 +.equ TSS_SEGMENT, 0x40 + + .text +ASM_PFX(gcStmSmiHandlerTemplate): + +_StmSmiEntryPoint: + .byte 0xbb # mov bx, imm16 + .word _StmGdtDesc - _StmSmiEntryPoint + 0x8000 + .byte 0x2e,0xa1 # mov ax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTSIZ + decl %eax + movl %eax, %cs:(%edi) # mov cs:[bx], ax + .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTPTR + movw %ax, %cs:2(%edi) + movw %ax, %bp # ebp = GDT base + .byte 0x66 + lgdt %cs:(%edi) +# Patch ProtectedMode Segment + .byte 0xb8 # mov ax, imm16 + .word PROTECT_MODE_CS # set AX for segment directly + movl %eax, %cs:-2(%edi) # mov cs:[bx - 2], ax +# Patch ProtectedMode entry + .byte 0x66, 0xbf # mov edi, SMBASE +ASM_PFX(gStmSmbase): .space 4 + .byte 0x67 + lea ((Start32bit - _StmSmiEntryPoint) + 0x8000)(%edi), %ax + movw %ax, %cs:-6(%edi) + movl %cr0, %ebx + .byte 0x66 + andl $0x9ffafff3, %ebx + .byte 0x66 + orl $0x23, %ebx + movl %ebx, %cr0 + .byte 0x66,0xea + .space 4 + .space 2 +_StmGdtDesc: .space 4 + .space 2 + +Start32bit: + movw $PROTECT_MODE_DS, %ax + movl %eax,%ds + movl %eax,%es + movl %eax,%fs + movl %eax,%gs + movl %eax,%ss + .byte 0xbc # mov esp, imm32 +ASM_PFX(gStmSmiStack): .space 4 + movl $ASM_PFX(gStmSmiHandlerIdtr), %eax + lidt (%eax) + jmp ProtFlatMode + +ProtFlatMode: + .byte 0xb8 # mov eax, imm32 +ASM_PFX(gStmSmiCr3): .space 4 + movl %eax, %cr3 +# +# Need to test for CR4 specific bit support +# + movl $1, %eax + cpuid # use CPUID to determine if specific CR4 bits are supported + xorl %eax, %eax # Clear EAX + testl $BIT2, %edx # Check for DE capabilities + jz L8 + orl $BIT3, %eax +L8: + testl $BIT6, %edx # Check for PAE capabilities + jz L9 + orl $BIT5, %eax +L9: + testl $BIT7, %edx # Check for MCE capabilities + jz L10 + orl $BIT6, %eax +L10: + testl $BIT24, %edx # Check for FXSR capabilities + jz L11 + orl $BIT9, %eax +L11: + testl $BIT25, %edx # Check for SSE capabilities + jz L12 + orl $BIT10, %eax +L12: # as cr4.PGE is not set here, refresh cr3 + movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. + + cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) + jz L5 +# Load TSS + movb $0x89, (TSS_SEGMENT + 5)(%ebp) # clear busy flag + movl $TSS_SEGMENT, %eax + ltrw %ax +L5: + +# enable NXE if supported + .byte 0xb0 # mov al, imm8 +ASM_PFX(gStmXdSupported): .byte 1 + cmpb $0, %al + jz SkipXd +# +# Check XD disable bit +# + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + pushl %edx # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr + jmp XdDone +SkipXd: + subl $4, %esp +XdDone: + + movl %cr0, %ebx + orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE + movl %ebx, %cr0 + leal DSC_OFFSET(%edi),%ebx + movw DSC_DS(%ebx),%ax + movl %eax, %ds + movw DSC_OTHERSEG(%ebx),%ax + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + movw DSC_SS(%ebx),%ax + movl %eax, %ss + +CommonHandler: + movl 4(%esp), %ebx + + pushl %ebx + movl $ASM_PFX(CpuSmmDebugEntry), %eax + call *%eax + addl $4, %esp + + pushl %ebx + movl $ASM_PFX(SmiRendezvous), %eax + call *%eax + addl $4, %esp + + pushl %ebx + movl $ASM_PFX(CpuSmmDebugExit), %eax + call *%eax + addl $4, %esp + + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz L16 + popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr + +L16: + rsm + +_StmSmiHandler: +# +# Check XD disable bit +# + xorl %esi, %esi + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz StmXdDone + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L14 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L14: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone: + push %esi + + # below step is needed, because STM does not run above code. + # we have to run below code to set IDT/CR0/CR4 + movl $ASM_PFX(gStmSmiHandlerIdtr), %eax + lidt (%eax) + + movl %cr0, %eax + orl $0x80010023, %eax # enable paging + WP + NE + MP + PE + movl %eax, %cr0 +# +# Need to test for CR4 specific bit support +# + movl $1, %eax + cpuid # use CPUID to determine if specific CR4 bits are supported + movl %cr4, %eax # init EAX + testl $BIT2, %edx # Check for DE capabilities + jz L28 + orl $BIT3, %eax +L28: + testl $BIT6, %edx # Check for PAE capabilities + jz L29 + orl $BIT5, %eax +L29: + testl $BIT7, %edx # Check for MCE capabilities + jz L30 + orl $BIT6, %eax +L30: + testl $BIT24, %edx # Check for FXSR capabilities + jz L31 + orl $BIT9, %eax +L31: + testl $BIT25, %edx # Check for SSE capabilities + jz L32 + orl $BIT10, %eax +L32: # as cr4.PGE is not set here, refresh cr3 + movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. + # STM init finish + jmp CommonHandler + + +ASM_PFX(gcStmSmiHandlerSize) : .word . - _StmSmiEntryPoint +ASM_PFX(gcStmSmiHandlerOffset): .word _StmSmiHandler - _StmSmiEntryPoint + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm new file mode 100644 index 0000000000..94888d5aec --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm @@ -0,0 +1,285 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.asm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + + .686p + .model flat,C + .xmm + +MSR_IA32_MISC_ENABLE EQU 1A0h +MSR_EFER EQU 0c0000080h +MSR_EFER_XD EQU 0800h + +; +; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +; +DSC_OFFSET EQU 0fb00h +DSC_GDTPTR EQU 48h +DSC_GDTSIZ EQU 50h +DSC_CS EQU 14h +DSC_DS EQU 16h +DSC_SS EQU 18h +DSC_OTHERSEG EQU 1Ah + +PROTECT_MODE_CS EQU 08h +PROTECT_MODE_DS EQU 20h +TSS_SEGMENT EQU 40h + +SmiRendezvous PROTO C +CpuSmmDebugEntry PROTO C +CpuSmmDebugExit PROTO C + +EXTERNDEF gcStmSmiHandlerTemplate:BYTE +EXTERNDEF gcStmSmiHandlerSize:WORD +EXTERNDEF gcStmSmiHandlerOffset:WORD +EXTERNDEF gStmSmiCr3:DWORD +EXTERNDEF gStmSmiStack:DWORD +EXTERNDEF gStmSmbase:DWORD +EXTERNDEF gStmXdSupported:BYTE +EXTERNDEF FeaturePcdGet (PcdCpuSmmStackGuard):BYTE +EXTERNDEF gStmSmiHandlerIdtr:FWORD + + .code + +gcStmSmiHandlerTemplate LABEL BYTE + +_StmSmiEntryPoint: + DB 0bbh ; mov bx, imm16 + DW offset _StmGdtDesc - _StmSmiEntryPoint + 8000h + DB 2eh, 0a1h ; mov ax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTSIZ + dec eax + mov cs:[edi], eax ; mov cs:[bx], ax + DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTPTR + mov cs:[edi + 2], ax ; mov cs:[bx + 2], eax + mov bp, ax ; ebp = GDT base + DB 66h + lgdt fword ptr cs:[edi] ; lgdt fword ptr cs:[bx] +; Patch ProtectedMode Segment + DB 0b8h ; mov ax, imm16 + DW PROTECT_MODE_CS ; set AX for segment directly + mov cs:[edi - 2], eax ; mov cs:[bx - 2], ax +; Patch ProtectedMode entry + DB 66h, 0bfh ; mov edi, SMBASE +gStmSmbase DD ? + DB 67h + lea ax, [edi + (@32bit - _StmSmiEntryPoint) + 8000h] + mov cs:[edi - 6], ax ; mov cs:[bx - 6], eax + mov ebx, cr0 + DB 66h + and ebx, 9ffafff3h + DB 66h + or ebx, 23h + mov cr0, ebx + DB 66h, 0eah + DD ? + DW ? +_StmGdtDesc FWORD ? + +@32bit: + mov ax, PROTECT_MODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + DB 0bch ; mov esp, imm32 +gStmSmiStack DD ? + mov eax, offset gStmSmiHandlerIdtr + lidt fword ptr [eax] + jmp ProtFlatMode + +ProtFlatMode: + DB 0b8h ; mov eax, imm32 +gStmSmiCr3 DD ? + mov cr3, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + xor eax, eax ; Clear EAX + test edx, BIT2 ; Check for DE capabilities + jz @f + or eax, BIT3 +@@: + test edx, BIT6 ; Check for PAE capabilities + jz @f + or eax, BIT5 +@@: + test edx, BIT7 ; Check for MCE capabilities + jz @f + or eax, BIT6 +@@: + test edx, BIT24 ; Check for FXSR capabilities + jz @f + or eax, BIT9 +@@: + test edx, BIT25 ; Check for SSE capabilities + jz @f + or eax, BIT10 +@@: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + + cmp FeaturePcdGet (PcdCpuSmmStackGuard), 0 + jz @F +; Load TSS + mov byte ptr [ebp + TSS_SEGMENT + 5], 89h ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax +@@: + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +gStmXdSupported DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + push edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 4 +@XdDone: + + mov ebx, cr0 + or ebx, 080010023h ; enable paging + WP + NE + MP + PE + mov cr0, ebx + lea ebx, [edi + DSC_OFFSET] + mov ax, [ebx + DSC_DS] + mov ds, eax + mov ax, [ebx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [ebx + DSC_SS] + mov ss, eax + +CommonHandler: + mov ebx, [esp + 4] ; CPU Index + push ebx + mov eax, CpuSmmDebugEntry + call eax + add esp, 4 + + push ebx + mov eax, SmiRendezvous + call eax + add esp, 4 + + push ebx + mov eax, CpuSmmDebugExit + call eax + add esp, 4 + + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @f + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +@@: + rsm + +_StmSmiHandler: +; +; Check XD disable bit +; + xor esi, esi + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @StmXdDone + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone: + push esi + + ; below step is needed, because STM does not run above code. + ; we have to run below code to set IDT/CR0/CR4 + mov eax, offset gStmSmiHandlerIdtr + lidt fword ptr [eax] + + + mov eax, cr0 + or eax, 80010023h ; enable paging + WP + NE + MP + PE + mov cr0, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + mov eax, cr4 ; init EAX + test edx, BIT2 ; Check for DE capabilities + jz @f + or eax, BIT3 +@@: + test edx, BIT6 ; Check for PAE capabilities + jz @f + or eax, BIT5 +@@: + test edx, BIT7 ; Check for MCE capabilities + jz @f + or eax, BIT6 +@@: + test edx, BIT24 ; Check for FXSR capabilities + jz @f + or eax, BIT9 +@@: + test edx, BIT25 ; Check for SSE capabilities + jz @f + or eax, BIT10 +@@: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + ; STM init finish + jmp CommonHandler + +gcStmSmiHandlerSize DW $ - _StmSmiEntryPoint +gcStmSmiHandlerOffset DW _StmSmiHandler - _StmSmiEntryPoint + + END diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm new file mode 100644 index 0000000000..b1c84a494f --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm @@ -0,0 +1,271 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.nasm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +; +; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +; +%define DSC_OFFSET 0xfb00 +%define DSC_GDTPTR 0x48 +%define DSC_GDTSIZ 0x50 +%define DSC_CS 0x14 +%define DSC_DS 0x16 +%define DSC_SS 0x18 +%define DSC_OTHERSEG 0x1a + +%define PROTECT_MODE_CS 0x8 +%define PROTECT_MODE_DS 0x20 +%define TSS_SEGMENT 0x40 + +extern ASM_PFX(SmiRendezvous) +extern ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) +extern ASM_PFX(CpuSmmDebugEntry) +extern ASM_PFX(CpuSmmDebugExit) + +global ASM_PFX(gcStmSmiHandlerTemplate) +global ASM_PFX(gcStmSmiHandlerSize) +global ASM_PFX(gcStmSmiHandlerOffset) +global ASM_PFX(gStmSmiCr3) +global ASM_PFX(gStmSmiStack) +global ASM_PFX(gStmSmbase) +global ASM_PFX(gStmXdSupported) +extern ASM_PFX(gStmSmiHandlerIdtr) + + SECTION .text + +BITS 16 +ASM_PFX(gcStmSmiHandlerTemplate): +_StmSmiEntryPoint: + mov bx, _StmGdtDesc - _StmSmiEntryPoint + 0x8000 + mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] + dec ax + mov [cs:bx], ax + mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] + mov [cs:bx + 2], eax + mov ebp, eax ; ebp = GDT base +o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] + mov ax, PROTECT_MODE_CS + mov [cs:bx-0x2],ax + DB 0x66, 0xbf ; mov edi, SMBASE +ASM_PFX(gStmSmbase): DD 0 + lea eax, [edi + (@32bit - _StmSmiEntryPoint) + 0x8000] + mov [cs:bx-0x6],eax + mov ebx, cr0 + and ebx, 0x9ffafff3 + or ebx, 0x23 + mov cr0, ebx + jmp dword 0x0:0x0 +_StmGdtDesc: + DW 0 + DD 0 + +BITS 32 +@32bit: + mov ax, PROTECT_MODE_DS +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax + DB 0xbc ; mov esp, imm32 +ASM_PFX(gStmSmiStack): DD 0 + mov eax, ASM_PFX(gStmSmiHandlerIdtr) + lidt [eax] + jmp ProtFlatMode + +ProtFlatMode: + DB 0xb8 ; mov eax, imm32 +ASM_PFX(gStmSmiCr3): DD 0 + mov cr3, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + xor eax, eax ; Clear EAX + test edx, BIT2 ; Check for DE capabilities + jz .0 + or eax, BIT3 +.0: + test edx, BIT6 ; Check for PAE capabilities + jz .1 + or eax, BIT5 +.1: + test edx, BIT7 ; Check for MCE capabilities + jz .2 + or eax, BIT6 +.2: + test edx, BIT24 ; Check for FXSR capabilities + jz .3 + or eax, BIT9 +.3: + test edx, BIT25 ; Check for SSE capabilities + jz .4 + or eax, BIT10 +.4: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + + cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))], 0 + jz .6 +; Load TSS + mov byte [ebp + TSS_SEGMENT + 5], 0x89 ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax +.6: + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +ASM_PFX(gStmXdSupported): DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + push edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .5 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.5: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 4 +@XdDone: + + mov ebx, cr0 + or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, ebx + lea ebx, [edi + DSC_OFFSET] + mov ax, [ebx + DSC_DS] + mov ds, eax + mov ax, [ebx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [ebx + DSC_SS] + mov ss, eax + +CommonHandler: + mov ebx, [esp + 4] ; CPU Index + push ebx + mov eax, ASM_PFX(CpuSmmDebugEntry) + call eax + add esp, 4 + + push ebx + mov eax, ASM_PFX(SmiRendezvous) + call eax + add esp, 4 + + push ebx + mov eax, ASM_PFX(CpuSmmDebugExit) + call eax + add esp, 4 + + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz .7 + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .7 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.7: + rsm + + +_StmSmiHandler: +; +; Check XD disable bit +; + xor esi, esi + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz @StmXdDone + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .5 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.5: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone: + push esi + + ; below step is needed, because STM does not run above code. + ; we have to run below code to set IDT/CR0/CR4 + mov eax, ASM_PFX(gStmSmiHandlerIdtr) + lidt [eax] + + mov eax, cr0 + or eax, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + mov eax, cr4 ; init EAX + test edx, BIT2 ; Check for DE capabilities + jz .0 + or eax, BIT3 +.0: + test edx, BIT6 ; Check for PAE capabilities + jz .1 + or eax, BIT5 +.1: + test edx, BIT7 ; Check for MCE capabilities + jz .2 + or eax, BIT6 +.2: + test edx, BIT24 ; Check for FXSR capabilities + jz .3 + or eax, BIT9 +.3: + test edx, BIT25 ; Check for SSE capabilities + jz .4 + or eax, BIT10 +.4: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + ; STM init finish + jmp CommonHandler + +ASM_PFX(gcStmSmiHandlerSize) : DW $ - _StmSmiEntryPoint +ASM_PFX(gcStmSmiHandlerOffset) : DW _StmSmiHandler - _StmSmiEntryPoint + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S new file mode 100644 index 0000000000..7d0057af80 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S @@ -0,0 +1,174 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiException.S +# +# Abstract: +# +# Exception handlers used in SM mode +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcStmPsd) + +ASM_GLOBAL ASM_PFX(SmmStmExceptionHandler) +ASM_GLOBAL ASM_PFX(SmmStmSetup) +ASM_GLOBAL ASM_PFX(SmmStmTeardown) + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0xc0000080 +.equ MSR_EFER_XD, 0x800 + +.equ CODE_SEL, 0x08 +.equ DATA_SEL, 0x20 +.equ TSS_SEL, 0x40 + + .data + +ASM_PFX(gcStmPsd): + .ascii "TXTPSSIG" + .word PSD_SIZE + .word 1 # Version + .long 0 # LocalApicId + .byte 0x5 # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + .byte 0 # BIOS to STM + .byte 0 # STM to BIOS + .byte 0 + .word CODE_SEL + .word DATA_SEL + .word DATA_SEL + .word DATA_SEL + .word TSS_SEL + .word 0 + .quad 0 # SmmCr3 + .long ASM_PFX(_OnStmSetup) + .long 0 + .long ASM_PFX(_OnStmTeardown) + .long 0 + .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint + .quad 0 # SmmSmiHandlerRsp + .quad 0 + .long 0 + .long 0x80010100 # RequiredStmSmmRevId + .long ASM_PFX(_OnException) + .long 0 + .quad 0 # ExceptionStack + .word DATA_SEL + .word 0x1F # ExceptionFilter + .long 0 + .quad 0 + .quad 0 # BiosHwResourceRequirementsPtr + .quad 0 # AcpiRsdp + .byte 0 # PhysicalAddressBits +.equ PSD_SIZE, . - ASM_PFX(gcStmPsd) + + .text + +#------------------------------------------------------------------------------ +# SMM Exception handlers +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(_OnException) +ASM_PFX(_OnException): + movl %esp, %ecx + pushl %ecx + call ASM_PFX(SmmStmExceptionHandler) + addl $4, %esp + + movl %eax, %ebx + movl $4, %eax + .byte 0xf, 0x1, 0xc1 # VMCALL + jmp . + +ASM_GLOBAL ASM_PFX(_OnStmSetup) +ASM_PFX(_OnStmSetup): +# +# Check XD disable bit +# + xorl %esi, %esi + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz StmXdDone1 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone1: + push %esi + + call ASM_PFX(SmmStmSetup) + + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz L14 + popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L14 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr +L14: + + rsm + +ASM_GLOBAL ASM_PFX(_OnStmTeardown) +ASM_PFX(_OnStmTeardown): +# +# Check XD disable bit +# + xorl %esi, %esi + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz StmXdDone2 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L15 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L15: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone2: + push %esi + + call ASM_PFX(SmmStmTeardown) + + movl $ASM_PFX(gStmXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz L16 + popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr +L16: + + rsm diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm new file mode 100644 index 0000000000..7c04ad91f2 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm @@ -0,0 +1,170 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.asm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + + .686p + .model flat,C + +EXTERNDEF gcStmPsd:BYTE + +EXTERNDEF SmmStmExceptionHandler:PROC +EXTERNDEF SmmStmSetup:PROC +EXTERNDEF SmmStmTeardown:PROC + +CODE_SEL = 08h +DATA_SEL = 20h +TSS_SEL = 40h + + .data + +gcStmPsd LABEL BYTE + DB 'TXTPSSIG' + DW PSD_SIZE + DW 1 ; Version + DD 0 ; LocalApicId + DB 05h ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + DB 0 ; BIOS to STM + DB 0 ; STM to BIOS + DB 0 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW TSS_SEL + DW 0 + DQ 0 ; SmmCr3 + DQ _OnStmSetup + DQ _OnStmTeardown + DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint + DQ 0 ; SmmSmiHandlerRsp + DQ 0 + DD 0 + DD 80010100h ; RequiredStmSmmRevId + DQ _OnException + DQ 0 ; ExceptionStack + DW DATA_SEL + DW 01Fh ; ExceptionFilter + DD 0 + DQ 0 + DQ 0 ; BiosHwResourceRequirementsPtr + DQ 0 ; AcpiRsdp + DB 0 ; PhysicalAddressBits +PSD_SIZE = $ - offset gcStmPsd + + .code +;------------------------------------------------------------------------------ +; SMM Exception handlers +;------------------------------------------------------------------------------ +_OnException PROC + mov ecx, esp + push ecx + call SmmStmExceptionHandler + add esp, 4 + + mov ebx, eax + mov eax, 4 + DB 0fh, 01h, 0c1h ; VMCALL + jmp $ +_OnException ENDP + +_OnStmSetup PROC +; +; Check XD disable bit +; + xor esi, esi + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @StmXdDone1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone1: + push esi + + call SmmStmSetup + + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @f + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr +@@: + + rsm +_OnStmSetup ENDP + +_OnStmTeardown PROC +; +; Check XD disable bit +; + xor esi, esi + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @StmXdDone2 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone2: + push esi + + call SmmStmTeardown + + mov eax, gStmXdSupported + mov al, [eax] + cmp al, 0 + jz @f + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr +@@: + + rsm +_OnStmTeardown ENDP + + END diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm new file mode 100644 index 0000000000..0ce8501ba9 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm @@ -0,0 +1,176 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.nasm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +global ASM_PFX(gcStmPsd) + +extern ASM_PFX(SmmStmExceptionHandler) +extern ASM_PFX(SmmStmSetup) +extern ASM_PFX(SmmStmTeardown) +extern ASM_PFX(gStmXdSupported) +extern ASM_PFX(gStmSmiHandlerIdtr) + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +CODE_SEL equ 0x08 +DATA_SEL equ 0x20 +TSS_SEL equ 0x40 + + SECTION .data + +ASM_PFX(gcStmPsd): + DB 'TXTPSSIG' + DW PSD_SIZE + DW 1 ; Version + DD 0 ; LocalApicId + DB 0x05 ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + DB 0 ; BIOS to STM + DB 0 ; STM to BIOS + DB 0 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW TSS_SEL + DW 0 + DQ 0 ; SmmCr3 + DD ASM_PFX(OnStmSetup) + DD 0 + DD ASM_PFX(OnStmTeardown) + DD 0 + DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint + DQ 0 ; SmmSmiHandlerRsp + DQ 0 + DD 0 + DD 0x80010100 ; RequiredStmSmmRevId + DD ASM_PFX(OnException) + DD 0 + DQ 0 ; ExceptionStack + DW DATA_SEL + DW 0x01F ; ExceptionFilter + DD 0 + DD 0 + DD 0 + DQ 0 ; BiosHwResourceRequirementsPtr + DQ 0 ; AcpiRsdp + DB 0 ; PhysicalAddressBits +PSD_SIZE equ $ - ASM_PFX(gcStmPsd) + + SECTION .text +;------------------------------------------------------------------------------ +; SMM Exception handlers +;------------------------------------------------------------------------------ +global ASM_PFX(OnException) +ASM_PFX(OnException): + mov ecx, esp + push ecx + call ASM_PFX(SmmStmExceptionHandler) + add esp, 4 + + mov ebx, eax + mov eax, 4 + DB 0x0f, 0x01, 0x0c1 ; VMCALL + jmp $ + +global ASM_PFX(OnStmSetup) +ASM_PFX(OnStmSetup): +; +; Check XD disable bit +; + xor esi, esi + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz @StmXdDone1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .51 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.51: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone1: + push esi + + call ASM_PFX(SmmStmSetup) + + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz .71 + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .71 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.71: + rsm + +global ASM_PFX(OnStmTeardown) +ASM_PFX(OnStmTeardown): +; +; Check XD disable bit +; + xor esi, esi + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz @StmXdDone2 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .52 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.52: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone2: + push esi + + call ASM_PFX(SmmStmTeardown) + + mov eax, ASM_PFX(gStmXdSupported) + mov al, [eax] + cmp al, 0 + jz .72 + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .72 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.72: + rsm + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c new file mode 100644 index 0000000000..0154c7c0f8 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c @@ -0,0 +1,83 @@ +/** @file + SMM STM support functions + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#include "SmmStm.h" + +/// +/// Page Table Entry +/// +#define IA32_PG_P BIT0 +#define IA32_PG_RW BIT1 +#define IA32_PG_PS BIT7 + +/** + + Create 4G page table for STM. + 4M Non-PAE page table in IA32 version. + + @param PageTableBase The page table base in MSEG + +**/ +VOID +StmGen4GPageTable ( + IN UINTN PageTableBase + ) +{ + UINTN Index; + UINT32 *Pte; + UINT32 Address; + + Pte = (UINT32*)(UINTN)PageTableBase; + + Address = 0; + for (Index = 0; Index < SIZE_4KB / sizeof (*Pte); Index++) { + *Pte = Address | IA32_PG_PS | IA32_PG_RW | IA32_PG_P; + Pte++; + Address += SIZE_4MB; + } +} + +/** + This is SMM exception handle. + Consumed by STM when exception happen. + + @param Context STM protection exception stack frame + + @return the EBX value for STM reference. + EBX = 0: resume SMM guest using register state found on exception stack. + EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the + TXT.ERRORCODE register and subsequently reset the system via + TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as + follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC + EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. + +**/ +UINT32 +EFIAPI +SmmStmExceptionHandler ( + IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context + ) +{ + // TBD - SmmStmExceptionHandler, record information + DEBUG ((DEBUG_ERROR, "SmmStmExceptionHandler ...\n")); + // + // Skip this instruction and continue; + // + Context.Ia32StackFrame->Rip += Context.Ia32StackFrame->VmcsExitInstructionLength; + + return 0; +} diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c new file mode 100644 index 0000000000..079baa4ae1 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -0,0 +1,630 @@ +/** @file +The CPU specific programming for PiSmmCpuDxeSmm module. + +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// Machine Specific Registers (MSRs) +// +#define SMM_FEATURES_LIB_IA32_MTRR_CAP 0x0FE +#define SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A +#define SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE 0x1F2 +#define SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK 0x1F3 +#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE 0x0A0 +#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK 0x0A1 +#define EFI_MSR_SMRR_MASK 0xFFFFF000 +#define EFI_MSR_SMRR_PHYS_MASK_VALID BIT11 +#define SMM_FEATURES_LIB_SMM_FEATURE_CONTROL 0x4E0 + +// +// MSRs required for configuration of SMM Code Access Check +// +#define SMM_FEATURES_LIB_IA32_MCA_CAP 0x17D +#define SMM_CODE_ACCESS_CHK_BIT BIT58 + +/** + Internal worker function that is called to complete CPU initialization at the + end of SmmCpuFeaturesInitializeProcessor(). + +**/ +VOID +FinishSmmCpuFeaturesInitializeProcessor ( + VOID + ); + +// +// Set default value to assume SMRR is not supported +// +BOOLEAN mSmrrSupported = FALSE; + +// +// Set default value to assume MSR_SMM_FEATURE_CONTROL is not supported +// +BOOLEAN mSmmFeatureControlSupported = FALSE; + +// +// Set default value to assume IA-32 Architectural MSRs are used +// +UINT32 mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE; +UINT32 mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK; + +// +// Set default value to assume MTRRs need to be configured on each SMI +// +BOOLEAN mNeedConfigureMtrrs = TRUE; + +// +// Array for state of SMRR enable on all CPUs +// +BOOLEAN *mSmrrEnabled; + +/** + The constructor function + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINT32 RegEax; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + + // + // Retrieve CPU Family and Model + // + AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); + FamilyId = (RegEax >> 8) & 0xf; + ModelId = (RegEax >> 4) & 0xf; + if (FamilyId == 0x06 || FamilyId == 0x0f) { + ModelId = ModelId | ((RegEax >> 12) & 0xf0); + } + + // + // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability + // + if ((RegEdx & BIT12) != 0) { + // + // Check MTRR_CAP MSR bit 11 for SMRR support + // + if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) != 0) { + mSmrrSupported = TRUE; + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Family + // + // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then + // SMRR Physical Base and SMM Physical Mask MSRs are not available. + // + if (FamilyId == 0x06) { + if (ModelId == 0x1C || ModelId == 0x26 || ModelId == 0x27 || ModelId == 0x35 || ModelId == 0x36) { + mSmrrSupported = FALSE; + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family + // + // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2 + // Processor Family MSRs + // + if (FamilyId == 0x06) { + if (ModelId == 0x17 || ModelId == 0x0f) { + mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE; + mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK; + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 34.4.2 SMRAM Caching + // An IA-32 processor does not automatically write back and invalidate its + // caches before entering SMM or before exiting SMM. Because of this behavior, + // care must be taken in the placement of the SMRAM in system memory and in + // the caching of the SMRAM to prevent cache incoherence when switching back + // and forth between SMM and protected mode operation. + // + // An IA-32 processor is a processor that does not support the Intel 64 + // Architecture. Support for the Intel 64 Architecture can be detected from + // CPUID(CPUID_EXTENDED_CPU_SIG).EDX[29] + // + // If an IA-32 processor is detected, then set mNeedConfigureMtrrs to TRUE, + // so caches are flushed on SMI entry and SMI exit, the interrupted code + // MTRRs are saved/restored, and MTRRs for SMM are loaded. + // + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax >= CPUID_EXTENDED_CPU_SIG) { + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & BIT29) != 0) { + mNeedConfigureMtrrs = FALSE; + } + } + + // + // Allocate array for state of SMRR enable on all CPUs + // + mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); + ASSERT (mSmrrEnabled != NULL); + + return EFI_SUCCESS; +} + +/** + Called during the very first SMI into System Management Mode to initialize + CPU features, including SMBASE, for the currently executing CPU. Since this + is the first SMI, the SMRAM Save State Map is at the default address of + SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executing + CPU is specified by CpuIndex and CpuIndex can be used to access information + about the currently executing CPU in the ProcessorInfo array and the + HotPlugCpuData data structure. + + @param[in] CpuIndex The index of the CPU to initialize. The value + must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU that + was elected as monarch during System Management + Mode initialization. + FALSE if the CpuIndex is not the index of the CPU + that was elected as monarch during System + Management Mode initialization. + @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMATION + structures. ProcessorInfo[CpuIndex] contains the + information for the currently executing CPU. + @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure that + contains the ApidId and SmBase arrays. +**/ +VOID +EFIAPI +SmmCpuFeaturesInitializeProcessor ( + IN UINTN CpuIndex, + IN BOOLEAN IsMonarch, + IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, + IN CPU_HOT_PLUG_DATA *CpuHotPlugData + ) +{ + SMRAM_SAVE_STATE_MAP *CpuState; + UINT64 FeatureControl; + UINT32 RegEax; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + + // + // Configure SMBASE. + // + CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); + CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family + // + // If Intel(R) Core(TM) Core(TM) 2 Processor Family MSRs are being used, then + // make sure SMRR Enable(BIT3) of MSR_FEATURE_CONTROL MSR(0x3A) is set before + // accessing SMRR base/mask MSRs. If Lock(BIT0) of MSR_FEATURE_CONTROL MSR(0x3A) + // is set, then the MSR is locked and can not be modified. + // + if (mSmrrSupported && mSmrrPhysBaseMsr == SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE) { + FeatureControl = AsmReadMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL); + if ((FeatureControl & BIT3) == 0) { + if ((FeatureControl & BIT0) == 0) { + AsmWriteMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL, FeatureControl | BIT3); + } else { + mSmrrSupported = FALSE; + } + } + } + + // + // If SMRR is supported, then program SMRR base/mask MSRs. + // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first normal SMI. + // The code that initializes SMM environment is running in normal mode + // from SMRAM region. If SMRR is enabled here, then the SMRAM region + // is protected and the normal mode code execution will fail. + // + if (mSmrrSupported) { + // + // SMRR size cannot be less than 4-KBytes + // SMRR size must be of length 2^n + // SMRR base alignment cannot be less than SMRR length + // + if ((CpuHotPlugData->SmrrSize < SIZE_4KB) || + (CpuHotPlugData->SmrrSize != GetPowerOfTwo32 (CpuHotPlugData->SmrrSize)) || + ((CpuHotPlugData->SmrrBase & ~(CpuHotPlugData->SmrrSize - 1)) != CpuHotPlugData->SmrrBase)) { + // + // Print message and halt if CPU is Monarch + // + if (IsMonarch) { + DEBUG ((DEBUG_ERROR, "SMM Base/Size does not meet alignment/size requirement!\n")); + CpuDeadLoop (); + } + } else { + AsmWriteMsr64 (mSmrrPhysBaseMsr, CpuHotPlugData->SmrrBase | MTRR_CACHE_WRITE_BACK); + AsmWriteMsr64 (mSmrrPhysMaskMsr, (~(CpuHotPlugData->SmrrSize - 1) & EFI_MSR_SMRR_MASK)); + mSmrrEnabled[CpuIndex] = FALSE; + } + } + + // + // Retrieve CPU Family and Model + // + AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); + FamilyId = (RegEax >> 8) & 0xf; + ModelId = (RegEax >> 4) & 0xf; + if (FamilyId == 0x06 || FamilyId == 0x0f) { + ModelId = ModelId | ((RegEax >> 12) & 0xf0); + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.10.1 MSRs in 4th Generation Intel(R) Core(TM) + // Processor Family. + // + // If CPU Family/Model is 06_3C, 06_45, or 06_46 then use 4th Generation + // Intel(R) Core(TM) Processor Family MSRs. + // + if (FamilyId == 0x06) { + if (ModelId == 0x3C || ModelId == 0x45 || ModelId == 0x46) { + // + // Check to see if the CPU supports the SMM Code Access Check feature + // Do not access this MSR unless the CPU supports the SmmRegFeatureControl + // + if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) != 0) { + mSmmFeatureControlSupported = TRUE; + } + } + } + + // + // Call internal worker function that completes the CPU initialization + // + FinishSmmCpuFeaturesInitializeProcessor (); +} + +/** + This function updates the SMRAM save state on the currently executing CPU + to resume execution at a specific address after an RSM instruction. This + function must evaluate the SMRAM save state to determine the execution mode + the RSM instruction resumes and update the resume execution address with + either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart + flag in the SMRAM save state must always be cleared. This function returns + the value of the instruction pointer from the SMRAM save state that was + replaced. If this function returns 0, then the SMRAM save state was not + modified. + + This function is called during the very first SMI on each CPU after + SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode + to signal that the SMBASE of each CPU has been updated before the default + SMBASE address is used for the first SMI to the next CPU. + + @param[in] CpuIndex The index of the CPU to hook. The value + must be between 0 and the NumberOfCpus + field in the System Management System Table + (SMST). + @param[in] CpuState Pointer to SMRAM Save State Map for the + currently executing CPU. + @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to + 32-bit execution mode from 64-bit SMM. + @param[in] NewInstructionPointer Instruction pointer to use if resuming to + same execution mode as SMM. + + @retval 0 This function did modify the SMRAM save state. + @retval > 0 The original instruction pointer value from the SMRAM save state + before it was replaced. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesHookReturnFromSmm ( + IN UINTN CpuIndex, + IN SMRAM_SAVE_STATE_MAP *CpuState, + IN UINT64 NewInstructionPointer32, + IN UINT64 NewInstructionPointer + ) +{ + return 0; +} + +/** + Hook point in normal execution mode that allows the one CPU that was elected + as monarch during System Management Mode initialization to perform additional + initialization actions immediately after all of the CPUs have processed their + first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE + into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). +**/ +VOID +EFIAPI +SmmCpuFeaturesSmmRelocationComplete ( + VOID + ) +{ +} + +/** + Determines if MTRR registers must be configured to set SMRAM cache-ability + when executing in System Management Mode. + + @retval TRUE MTRR registers must be configured to set SMRAM cache-ability. + @retval FALSE MTRR registers do not need to be configured to set SMRAM + cache-ability. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesNeedConfigureMtrrs ( + VOID + ) +{ + return mNeedConfigureMtrrs; +} + +/** + Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesDisableSmrr ( + VOID + ) +{ + if (mSmrrSupported && mNeedConfigureMtrrs) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64(mSmrrPhysMaskMsr) & ~EFI_MSR_SMRR_PHYS_MASK_VALID); + } +} + +/** + Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesReenableSmrr ( + VOID + ) +{ + if (mSmrrSupported && mNeedConfigureMtrrs) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64(mSmrrPhysMaskMsr) | EFI_MSR_SMRR_PHYS_MASK_VALID); + } +} + +/** + Processor specific hook point each time a CPU enters System Management Mode. + + @param[in] CpuIndex The index of the CPU that has entered SMM. The value + must be between 0 and the NumberOfCpus field in the + System Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousEntry ( + IN UINTN CpuIndex + ) +{ + // + // If SMRR is supported and this is the first normal SMI, then enable SMRR + // + if (mSmrrSupported && !mSmrrEnabled[CpuIndex]) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI_MSR_SMRR_PHYS_MASK_VALID); + mSmrrEnabled[CpuIndex] = TRUE; + } +} + +/** + Processor specific hook point each time a CPU exits System Management Mode. + + @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must + be between 0 and the NumberOfCpus field in the System + Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousExit ( + IN UINTN CpuIndex + ) +{ +} + +/** + Check to see if an SMM register is supported by a specified CPU. + + @param[in] CpuIndex The index of the CPU to check for SMM register support. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to check for support. + + @retval TRUE The SMM register specified by RegName is supported by the CPU + specified by CpuIndex. + @retval FALSE The SMM register specified by RegName is not supported by the + CPU specified by CpuIndex. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesIsSmmRegisterSupported ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ) +{ + if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { + return TRUE; + } + return FALSE; +} + +/** + Returns the current value of the SMM register for the specified CPU. + If the SMM register is not supported, then 0 is returned. + + @param[in] CpuIndex The index of the CPU to read the SMM register. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to read. + + @return The value of the SMM register specified by RegName from the CPU + specified by CpuIndex. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesGetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ) +{ + if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { + return AsmReadMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL); + } + return 0; +} + +/** + Sets the value of an SMM register on a specified CPU. + If the SMM register is not supported, then no action is performed. + + @param[in] CpuIndex The index of the CPU to write the SMM register. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to write. + registers are read-only. + @param[in] Value The value to write to the SMM register. +**/ +VOID +EFIAPI +SmmCpuFeaturesSetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName, + IN UINT64 Value + ) +{ + if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { + AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value); + } +} + +/** + Read an SMM Save State register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for reading the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to read the SMM Save State. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to read. + @param[in] Width The number of bytes to read from the CPU save state. + @param[out] Buffer Upon return, this holds the CPU register value read + from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support reading Register. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesReadSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ) +{ + return EFI_UNSUPPORTED; +} + +/** + Writes an SMM Save State register on the target processor. If this function + returns EFI_UNSUPPORTED, then the caller is responsible for writing the + SMM Save Sate register. + + @param[in] CpuIndex The index of the CPU to write the SMM Save State. The + value must be between 0 and the NumberOfCpus field in + the System Management System Table (SMST). + @param[in] Register The SMM Save State register to write. + @param[in] Width The number of bytes to write to the CPU save state. + @param[in] Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written to Save State. + @retval EFI_INVALID_PARAMTER Buffer is NULL. + @retval EFI_UNSUPPORTED This function does not support writing Register. +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesWriteSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ) +{ + return EFI_UNSUPPORTED; +} + +/** + This function is hook point called after the gEfiSmmReadyToLockProtocolGuid + notification is completely processed. +**/ +VOID +EFIAPI +SmmCpuFeaturesCompleteSmmReadyToLock ( + VOID + ) +{ +} + +/** + This API provides a method for a CPU to allocate a specific region for storing page tables. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer for page tables. + @retval NULL Fail to allocate a specific region for storing page tables, + Or there is no preference on where the page tables are allocated in SMRAM. + +**/ +VOID * +EFIAPI +SmmCpuFeaturesAllocatePageTableMemory ( + IN UINTN Pages + ) +{ + return NULL; +} + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf new file mode 100644 index 0000000000..77908b0366 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -0,0 +1,40 @@ +## @file +# The CPU specific programming for PiSmmCpuDxeSmm module. +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmCpuFeaturesLib + MODULE_UNI_FILE = SmmCpuFeaturesLib.uni + FILE_GUID = FC3DC10D-D271-422a-AFF3-CBCF70344431 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = SmmCpuFeaturesLib + CONSTRUCTOR = SmmCpuFeaturesLibConstructor + +[Sources] + SmmCpuFeaturesLib.c + SmmCpuFeaturesLibNoStm.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + PcdLib + MemoryAllocationLib + DebugLib + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni new file mode 100644 index 0000000000..322aa8bb5a --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni @@ -0,0 +1,18 @@ +// /** @file +// The CPU specific programming for PiSmmCpuDxeSmm module. +// +// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "The CPU specific programming for PiSmmCpuDxeSmm module." + +#string STR_MODULE_DESCRIPTION #language en-US "The CPU specific programming for PiSmmCpuDxeSmm module." diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c new file mode 100644 index 0000000000..5276856797 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c @@ -0,0 +1,89 @@ +/** @file +The CPU specific programming for PiSmmCpuDxeSmm module when STM support +is not included. + +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +/** + Internal worker function that is called to complete CPU initialization at the + end of SmmCpuFeaturesInitializeProcessor(). + +**/ +VOID +FinishSmmCpuFeaturesInitializeProcessor ( + VOID + ) +{ +} + +/** + Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is + returned, then a custom SMI handler is not provided by this library, + and the default SMI handler must be used. + + @retval 0 Use the default SMI handler. + @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() + The caller is required to allocate enough SMRAM for each CPU to + support the size of the custom SMI handler. +**/ +UINTN +EFIAPI +SmmCpuFeaturesGetSmiHandlerSize ( + VOID + ) +{ + return 0; +} + +/** + Install a custom SMI handler for the CPU specified by CpuIndex. This function + is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater + than zero and is called by the CPU that was elected as monarch during System + Management Mode initialization. + + @param[in] CpuIndex The index of the CPU to install the custom SMI handler. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. + @param[in] SmiStack The stack to use when an SMI is processed by the + the CPU specified by CpuIndex. + @param[in] StackSize The size, in bytes, if the stack used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtBase The base address of the GDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtBase The base address of the IDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] Cr3 The base address of the page tables to use when an SMI + is processed by the CPU specified by CpuIndex. +**/ +VOID +EFIAPI +SmmCpuFeaturesInstallSmiHandler ( + IN UINTN CpuIndex, + IN UINT32 SmBase, + IN VOID *SmiStack, + IN UINTN StackSize, + IN UINTN GdtBase, + IN UINTN GdtSize, + IN UINTN IdtBase, + IN UINTN IdtSize, + IN UINT32 Cr3 + ) +{ +} diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf new file mode 100644 index 0000000000..db8dcdcff4 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -0,0 +1,88 @@ +## @file +# The CPU specific programming for PiSmmCpuDxeSmm module when STM support +# is included. +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmCpuFeaturesLibStm + MODULE_UNI_FILE = SmmCpuFeaturesLib.uni + FILE_GUID = 374DE830-81C5-4CC8-B2AB-28F0AB73710B + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = SmmCpuFeaturesLib + CONSTRUCTOR = SmmCpuFeaturesLibStmConstructor + +[Sources] + SmmCpuFeaturesLib.c + SmmStm.c + SmmStm.h + +[Sources.Ia32] + Ia32/SmmStmSupport.c + + Ia32/SmiEntry.asm + Ia32/SmiException.asm + + Ia32/SmiEntry.nasm + Ia32/SmiException.nasm + + Ia32/SmiEntry.S + Ia32/SmiException.S + +[Sources.X64] + X64/SmmStmSupport.c + + X64/SmiEntry.asm + X64/SmiException.asm + + X64/SmiEntry.nasm + X64/SmiException.nasm + + X64/SmiEntry.S + X64/SmiException.S + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + PcdLib + HobLib + MemoryAllocationLib + DebugLib + UefiBootServicesTableLib + SmmServicesTableLib + TpmMeasurementLib + +[Protocols] + gEfiMpServiceProtocolGuid ## CONSUMES + gEfiSmmEndOfDxeProtocolGuid ## CONSUMES + gEfiSmMonitorInitProtocolGuid ## PRODUCES + +[Guids] + gMsegSmramGuid ## SOMETIMES_CONSUMES ## HOB + gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuMsegSize ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStmExceptionStackSize ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES + +[Depex] + gEfiMpServiceProtocolGuid diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c new file mode 100644 index 0000000000..03937dcbe2 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c @@ -0,0 +1,1299 @@ +/** @file + SMM STM support functions + + Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "SmmStm.h" + +#define TXT_EVTYPE_BASE 0x400 +#define TXT_EVTYPE_STM_HASH (TXT_EVTYPE_BASE + 14) + +#define RDWR_ACCS 3 +#define FULL_ACCS 7 + +/** + The constructor function + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_HANDLE mStmSmmCpuHandle = NULL; + +BOOLEAN mLockLoadMonitor = FALSE; + +// +// Template of STM_RSC_END structure for copying. +// +GLOBAL_REMOVE_IF_UNREFERENCED STM_RSC_END mRscEndNode = { + {END_OF_RESOURCES, sizeof (STM_RSC_END)}, +}; + +GLOBAL_REMOVE_IF_UNREFERENCED UINT8 *mStmResourcesPtr = NULL; +GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceTotalSize = 0x0; +GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeUsed = 0x0; +GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeAvailable = 0x0; + +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mStmState = 0; + +// +// System Configuration Table pointing to STM Configuration Table +// +GLOBAL_REMOVE_IF_UNREFERENCED +EFI_SM_MONITOR_INIT_PROTOCOL mSmMonitorInitProtocol = { + LoadMonitor, + AddPiResource, + DeletePiResource, + GetPiResource, + GetMonitorState, +}; + + + + +#define CPUID1_EDX_XD_SUPPORT 0x100000 + +// +// External global variables associated with SMI Handler Template +// +extern CONST TXT_PROCESSOR_SMM_DESCRIPTOR gcStmPsd; +extern UINT32 gStmSmbase; +extern volatile UINT32 gStmSmiStack; +extern UINT32 gStmSmiCr3; +extern volatile UINT8 gcStmSmiHandlerTemplate[]; +extern CONST UINT16 gcStmSmiHandlerSize; +extern UINT16 gcStmSmiHandlerOffset; +extern BOOLEAN gStmXdSupported; + +// +// Variables used by SMI Handler +// +IA32_DESCRIPTOR gStmSmiHandlerIdtr; + +// +// MP Services Protocol +// +EFI_MP_SERVICES_PROTOCOL *mSmmCpuFeaturesLibMpService = NULL; + +// +// MSEG Base and Length in SMRAM +// +UINTN mMsegBase = 0; +UINTN mMsegSize = 0; + +BOOLEAN mStmConfigurationTableInitialized = FALSE; + + +/** + The constructor function + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesLibStmConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + CPUID_VERSION_INFO_ECX RegEcx; + EFI_HOB_GUID_TYPE *GuidHob; + EFI_SMRAM_DESCRIPTOR *SmramDescriptor; + + // + // Call the common constructor function + // + Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); + + // + // Lookup the MP Services Protocol + // + Status = gBS->LocateProtocol ( + &gEfiMpServiceProtocolGuid, + NULL, + (VOID **)&mSmmCpuFeaturesLibMpService + ); + ASSERT_EFI_ERROR (Status); + + // + // If CPU supports VMX, then determine SMRAM range for MSEG. + // + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &RegEcx.Uint32, NULL); + if (RegEcx.Bits.VMX == 1) { + GuidHob = GetFirstGuidHob (&gMsegSmramGuid); + if (GuidHob != NULL) { + // + // Retrieve MSEG location from MSEG SRAM HOB + // + SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); + if (SmramDescriptor->PhysicalSize > 0) { + mMsegBase = (UINTN)SmramDescriptor->CpuStart; + mMsegSize = (UINTN)SmramDescriptor->PhysicalSize; + } + } else if (PcdGet32 (PcdCpuMsegSize) > 0) { + // + // Allocate MSEG from SMRAM memory + // + mMsegBase = (UINTN)AllocatePages (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuMsegSize))); + if (mMsegBase > 0) { + mMsegSize = ALIGN_VALUE (PcdGet32 (PcdCpuMsegSize), EFI_PAGE_SIZE); + } else { + DEBUG ((DEBUG_ERROR, "Not enough SMRAM resource to allocate MSEG size %08x\n", PcdGet32 (PcdCpuMsegSize))); + } + } + if (mMsegBase > 0) { + DEBUG ((DEBUG_INFO, "MsegBase: 0x%08x, MsegSize: 0x%08x\n", mMsegBase, mMsegSize)); + } + } + + return EFI_SUCCESS; +} + +/** + Internal worker function that is called to complete CPU initialization at the + end of SmmCpuFeaturesInitializeProcessor(). + +**/ +VOID +FinishSmmCpuFeaturesInitializeProcessor ( + VOID + ) +{ + MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; + + // + // Set MSEG Base Address in SMM Monitor Control MSR. + // + if (mMsegBase > 0) { + SmmMonitorCtl.Uint64 = 0; + SmmMonitorCtl.Bits.MsegBase = (UINT32)mMsegBase >> 12; + SmmMonitorCtl.Bits.Valid = 1; + AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, SmmMonitorCtl.Uint64); + } +} + +/** + Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is + returned, then a custom SMI handler is not provided by this library, + and the default SMI handler must be used. + + @retval 0 Use the default SMI handler. + @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() + The caller is required to allocate enough SMRAM for each CPU to + support the size of the custom SMI handler. +**/ +UINTN +EFIAPI +SmmCpuFeaturesGetSmiHandlerSize ( + VOID + ) +{ + return gcStmSmiHandlerSize; +} + +/** + Install a custom SMI handler for the CPU specified by CpuIndex. This function + is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater + than zero and is called by the CPU that was elected as monarch during System + Management Mode initialization. + + @param[in] CpuIndex The index of the CPU to install the custom SMI handler. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. + @param[in] SmiStack The stack to use when an SMI is processed by the + the CPU specified by CpuIndex. + @param[in] StackSize The size, in bytes, if the stack used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtBase The base address of the GDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtBase The base address of the IDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] Cr3 The base address of the page tables to use when an SMI + is processed by the CPU specified by CpuIndex. +**/ +VOID +EFIAPI +SmmCpuFeaturesInstallSmiHandler ( + IN UINTN CpuIndex, + IN UINT32 SmBase, + IN VOID *SmiStack, + IN UINTN StackSize, + IN UINTN GdtBase, + IN UINTN GdtSize, + IN UINTN IdtBase, + IN UINTN IdtSize, + IN UINT32 Cr3 + ) +{ + EFI_STATUS Status; + TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; + VOID *Hob; + UINT32 RegEax; + UINT32 RegEdx; + EFI_PROCESSOR_INFORMATION ProcessorInfo; + + CopyMem ((VOID *)((UINTN)SmBase + TXT_SMM_PSD_OFFSET), &gcStmPsd, sizeof (gcStmPsd)); + Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + TXT_SMM_PSD_OFFSET); + Psd->SmmGdtPtr = GdtBase; + Psd->SmmGdtSize = (UINT32)GdtSize; + + // + // Initialize values in template before copy + // + gStmSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); + gStmSmiCr3 = Cr3; + gStmSmbase = SmBase; + gStmSmiHandlerIdtr.Base = IdtBase; + gStmSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1); + + if (gStmXdSupported) { + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax <= CPUID_EXTENDED_FUNCTION) { + // + // Extended CPUID functions are not supported on this processor. + // + gStmXdSupported = FALSE; + } + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & CPUID1_EDX_XD_SUPPORT) == 0) { + // + // Execute Disable Bit feature is not supported on this processor. + // + gStmXdSupported = FALSE; + } + } + + // + // Set the value at the top of the CPU stack to the CPU Index + // + *(UINTN*)(UINTN)gStmSmiStack = CpuIndex; + + // + // Copy template to CPU specific SMI handler location + // + CopyMem ( + (VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET), + (VOID*)gcStmSmiHandlerTemplate, + gcStmSmiHandlerSize + ); + + Psd->SmmSmiHandlerRip = SmBase + SMM_HANDLER_OFFSET + gcStmSmiHandlerOffset; + Psd->SmmSmiHandlerRsp = (UINTN)SmiStack + StackSize - sizeof(UINTN); + Psd->SmmCr3 = Cr3; + + DEBUG((DEBUG_ERROR, "CpuSmmStmExceptionStackSize - %x\n", PcdGet32(PcdCpuSmmStmExceptionStackSize))); + DEBUG((DEBUG_ERROR, "Pages - %x\n", EFI_SIZE_TO_PAGES(PcdGet32(PcdCpuSmmStmExceptionStackSize)))); + Psd->StmProtectionExceptionHandler.SpeRsp = (UINT64)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStmExceptionStackSize))); + Psd->StmProtectionExceptionHandler.SpeRsp += EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStmExceptionStackSize))); + + Psd->BiosHwResourceRequirementsPtr = (UINT64)(UINTN)GetStmResource (); + + // + // Get the APIC ID for the CPU specified by CpuIndex + // + Status = mSmmCpuFeaturesLibMpService->GetProcessorInfo ( + mSmmCpuFeaturesLibMpService, + CpuIndex, + &ProcessorInfo + ); + ASSERT_EFI_ERROR (Status); + + Psd->LocalApicId = (UINT32)ProcessorInfo.ProcessorId; + Psd->AcpiRsdp = 0; + + Hob = GetFirstHob (EFI_HOB_TYPE_CPU); + if (Hob != NULL) { + Psd->PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; + } else { + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + Psd->PhysicalAddressBits = (UINT8) RegEax; + } else { + Psd->PhysicalAddressBits = 36; + } + } + + if (!mStmConfigurationTableInitialized) { + StmSmmConfigurationTableInit (); + mStmConfigurationTableInitialized = TRUE; + } +} + +/** + SMM End Of Dxe event notification handler. + + STM support need patch AcpiRsdp in TXT_PROCESSOR_SMM_DESCRIPTOR. + + @param[in] Protocol Points to the protocol's unique identifier. + @param[in] Interface Points to the interface instance. + @param[in] Handle The handle on which the interface was installed. + + @retval EFI_SUCCESS Notification handler runs successfully. +**/ +EFI_STATUS +EFIAPI +SmmEndOfDxeEventNotify ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + VOID *Rsdp; + UINTN Index; + TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; + + DEBUG ((DEBUG_INFO, "SmmEndOfDxeEventNotify\n")); + + // + // found ACPI table RSD_PTR from system table + // + Rsdp = NULL; + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi20TableGuid)) { + // + // A match was found. + // + Rsdp = gST->ConfigurationTable[Index].VendorTable; + break; + } + } + if (Rsdp == NULL) { + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi10TableGuid)) { + // + // A match was found. + // + Rsdp = gST->ConfigurationTable[Index].VendorTable; + break; + } + } + } + + for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { + Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)((UINTN)gSmst->CpuSaveState[Index] - SMRAM_SAVE_STATE_MAP_OFFSET + TXT_SMM_PSD_OFFSET); + DEBUG ((DEBUG_INFO, "Index=%d Psd=%p Rsdp=%p\n", Index, Psd, Rsdp)); + Psd->AcpiRsdp = (UINT64)(UINTN)Rsdp; + } + + mLockLoadMonitor = TRUE; + + return EFI_SUCCESS; +} + +/** + This function initializes the STM configuration table. +**/ +VOID +StmSmmConfigurationTableInit ( + VOID + ) +{ + EFI_STATUS Status; + VOID *Registration; + + Status = gSmst->SmmInstallProtocolInterface ( + &mStmSmmCpuHandle, + &gEfiSmMonitorInitProtocolGuid, + EFI_NATIVE_INTERFACE, + &mSmMonitorInitProtocol + ); + ASSERT_EFI_ERROR (Status); + + // + // + // Register SMM End of DXE Event + // + Status = gSmst->SmmRegisterProtocolNotify ( + &gEfiSmmEndOfDxeProtocolGuid, + SmmEndOfDxeEventNotify, + &Registration + ); + ASSERT_EFI_ERROR (Status); +} + +/** + + Get STM state. + + @return STM state + +**/ +EFI_SM_MONITOR_STATE +EFIAPI +GetMonitorState ( + VOID + ) +{ + return mStmState; +} + +/** + + Handle single Resource to see if it can be merged into Record. + + @param Resource A pointer to resource node to be added + @param Record A pointer to record node to be merged + + @retval TRUE resource handled + @retval FALSE resource is not handled + +**/ +BOOLEAN +HandleSingleResource ( + IN STM_RSC *Resource, + IN STM_RSC *Record + ) +{ + UINT64 ResourceLo; + UINT64 ResourceHi; + UINT64 RecordLo; + UINT64 RecordHi; + + ResourceLo = 0; + ResourceHi = 0; + RecordLo = 0; + RecordHi = 0; + + // + // Calling code is responsible for making sure that + // Resource->Header.RscType == (*Record)->Header.RscType + // thus we use just one of them as switch variable. + // + switch (Resource->Header.RscType) { + case MEM_RANGE: + case MMIO_RANGE: + ResourceLo = Resource->Mem.Base; + ResourceHi = Resource->Mem.Base + Resource->Mem.Length; + RecordLo = Record->Mem.Base; + RecordHi = Record->Mem.Base + Record->Mem.Length; + if (Resource->Mem.RWXAttributes != Record->Mem.RWXAttributes) { + if ((ResourceLo == RecordLo) && (ResourceHi == RecordHi)) { + Record->Mem.RWXAttributes = Resource->Mem.RWXAttributes | Record->Mem.RWXAttributes; + return TRUE; + } else { + return FALSE; + } + } + break; + case IO_RANGE: + case TRAPPED_IO_RANGE: + ResourceLo = (UINT64) Resource->Io.Base; + ResourceHi = (UINT64) Resource->Io.Base + (UINT64) Resource->Io.Length; + RecordLo = (UINT64) Record->Io.Base; + RecordHi = (UINT64) Record->Io.Base + (UINT64) Record->Io.Length; + break; + case PCI_CFG_RANGE: + if ((Resource->PciCfg.OriginatingBusNumber != Record->PciCfg.OriginatingBusNumber) || + (Resource->PciCfg.LastNodeIndex != Record->PciCfg.LastNodeIndex)) { + return FALSE; + } + if (CompareMem (Resource->PciCfg.PciDevicePath, Record->PciCfg.PciDevicePath, sizeof(STM_PCI_DEVICE_PATH_NODE) * (Resource->PciCfg.LastNodeIndex + 1)) != 0) { + return FALSE; + } + ResourceLo = (UINT64) Resource->PciCfg.Base; + ResourceHi = (UINT64) Resource->PciCfg.Base + (UINT64) Resource->PciCfg.Length; + RecordLo = (UINT64) Record->PciCfg.Base; + RecordHi = (UINT64) Record->PciCfg.Base + (UINT64) Record->PciCfg.Length; + if (Resource->PciCfg.RWAttributes != Record->PciCfg.RWAttributes) { + if ((ResourceLo == RecordLo) && (ResourceHi == RecordHi)) { + Record->PciCfg.RWAttributes = Resource->PciCfg.RWAttributes | Record->PciCfg.RWAttributes; + return TRUE; + } else { + return FALSE; + } + } + break; + case MACHINE_SPECIFIC_REG: + // + // Special case - merge MSR masks in place. + // + if (Resource->Msr.MsrIndex != Record->Msr.MsrIndex) { + return FALSE; + } + Record->Msr.ReadMask |= Resource->Msr.ReadMask; + Record->Msr.WriteMask |= Resource->Msr.WriteMask; + return TRUE; + default: + return FALSE; + } + // + // If resources are disjoint + // + if ((ResourceHi < RecordLo) || (ResourceLo > RecordHi)) { + return FALSE; + } + + // + // If resource is consumed by record. + // + if ((ResourceLo >= RecordLo) && (ResourceHi <= RecordHi)) { + return TRUE; + } + // + // Resources are overlapping. + // Resource and record are merged. + // + ResourceLo = (ResourceLo < RecordLo) ? ResourceLo : RecordLo; + ResourceHi = (ResourceHi > RecordHi) ? ResourceHi : RecordHi; + + switch (Resource->Header.RscType) { + case MEM_RANGE: + case MMIO_RANGE: + Record->Mem.Base = ResourceLo; + Record->Mem.Length = ResourceHi - ResourceLo; + break; + case IO_RANGE: + case TRAPPED_IO_RANGE: + Record->Io.Base = (UINT16) ResourceLo; + Record->Io.Length = (UINT16) (ResourceHi - ResourceLo); + break; + case PCI_CFG_RANGE: + Record->PciCfg.Base = (UINT16) ResourceLo; + Record->PciCfg.Length = (UINT16) (ResourceHi - ResourceLo); + break; + default: + return FALSE; + } + + return TRUE; +} + +/** + + Add resource node. + + @param Resource A pointer to resource node to be added + +**/ +VOID +AddSingleResource ( + IN STM_RSC *Resource + ) +{ + STM_RSC *Record; + + Record = (STM_RSC *)mStmResourcesPtr; + + while (TRUE) { + if (Record->Header.RscType == END_OF_RESOURCES) { + break; + } + // + // Go to next record if resource and record types don't match. + // + if (Resource->Header.RscType != Record->Header.RscType) { + Record = (STM_RSC *)((UINTN)Record + Record->Header.Length); + continue; + } + // + // Record is handled inside of procedure - don't adjust. + // + if (HandleSingleResource (Resource, Record)) { + return ; + } + Record = (STM_RSC *)((UINTN)Record + Record->Header.Length); + } + + // + // Add resource to the end of area. + // + CopyMem ( + mStmResourcesPtr + mStmResourceSizeUsed - sizeof(mRscEndNode), + Resource, + Resource->Header.Length + ); + CopyMem ( + mStmResourcesPtr + mStmResourceSizeUsed - sizeof(mRscEndNode) + Resource->Header.Length, + &mRscEndNode, + sizeof(mRscEndNode) + ); + mStmResourceSizeUsed += Resource->Header.Length; + mStmResourceSizeAvailable = mStmResourceTotalSize - mStmResourceSizeUsed; + + return ; +} + +/** + + Add resource list. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + +**/ +VOID +AddResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ) +{ + UINT32 Count; + UINTN Index; + STM_RSC *Resource; + + if (NumEntries == 0) { + Count = 0xFFFFFFFF; + } else { + Count = NumEntries; + } + + Resource = ResourceList; + + for (Index = 0; Index < Count; Index++) { + if (Resource->Header.RscType == END_OF_RESOURCES) { + return ; + } + AddSingleResource (Resource); + Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); + } + return ; +} + +/** + + Validate resource list. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval TRUE resource valid + @retval FALSE resource invalid + +**/ +BOOLEAN +ValidateResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ) +{ + UINT32 Count; + UINTN Index; + STM_RSC *Resource; + UINTN SubIndex; + + // + // If NumEntries == 0 make it very big. Scan will be terminated by + // END_OF_RESOURCES. + // + if (NumEntries == 0) { + Count = 0xFFFFFFFF; + } else { + Count = NumEntries; + } + + // + // Start from beginning of resource list. + // + Resource = ResourceList; + + for (Index = 0; Index < Count; Index++) { + DEBUG ((DEBUG_ERROR, "ValidateResource (%d) - RscType(%x)\n", Index, Resource->Header.RscType)); + // + // Validate resource. + // + switch (Resource->Header.RscType) { + case END_OF_RESOURCES: + if (Resource->Header.Length != sizeof (STM_RSC_END)) { + return FALSE; + } + // + // If we are passed actual number of resources to add, + // END_OF_RESOURCES structure between them is considered an + // error. If NumEntries == 0 END_OF_RESOURCES is a termination. + // + if (NumEntries != 0) { + return FALSE; + } else { + // + // If NumEntries == 0 and list reached end - return success. + // + return TRUE; + } + break; + + case MEM_RANGE: + case MMIO_RANGE: + if (Resource->Header.Length != sizeof (STM_RSC_MEM_DESC)) { + return FALSE; + } + + if (Resource->Mem.RWXAttributes > FULL_ACCS) { + return FALSE; + } + break; + + case IO_RANGE: + case TRAPPED_IO_RANGE: + if (Resource->Header.Length != sizeof (STM_RSC_IO_DESC)) { + return FALSE; + } + + if ((Resource->Io.Base + Resource->Io.Length) > 0xFFFF) { + return FALSE; + } + break; + + case PCI_CFG_RANGE: + DEBUG ((DEBUG_ERROR, "ValidateResource - PCI (0x%02x, 0x%08x, 0x%02x, 0x%02x)\n", Resource->PciCfg.OriginatingBusNumber, Resource->PciCfg.LastNodeIndex, Resource->PciCfg.PciDevicePath[0].PciDevice, Resource->PciCfg.PciDevicePath[0].PciFunction)); + if (Resource->Header.Length != sizeof (STM_RSC_PCI_CFG_DESC) + (sizeof(STM_PCI_DEVICE_PATH_NODE) * Resource->PciCfg.LastNodeIndex)) { + return FALSE; + } + for (SubIndex = 0; SubIndex <= Resource->PciCfg.LastNodeIndex; SubIndex++) { + if ((Resource->PciCfg.PciDevicePath[SubIndex].PciDevice > 0x1F) || (Resource->PciCfg.PciDevicePath[SubIndex].PciFunction > 7)) { + return FALSE; + } + } + if ((Resource->PciCfg.Base + Resource->PciCfg.Length) > 0x1000) { + return FALSE; + } + break; + + case MACHINE_SPECIFIC_REG: + if (Resource->Header.Length != sizeof (STM_RSC_MSR_DESC)) { + return FALSE; + } + break; + + default : + DEBUG ((DEBUG_ERROR, "ValidateResource - Unknown RscType(%x)\n", Resource->Header.RscType)); + return FALSE; + } + Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); + } + return TRUE; +} + +/** + + Get resource list. + EndResource is excluded. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval TRUE resource valid + @retval FALSE resource invalid + +**/ +UINTN +GetResourceSize ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ) +{ + UINT32 Count; + UINTN Index; + STM_RSC *Resource; + + Resource = ResourceList; + + // + // If NumEntries == 0 make it very big. Scan will be terminated by + // END_OF_RESOURCES. + // + if (NumEntries == 0) { + Count = 0xFFFFFFFF; + } else { + Count = NumEntries; + } + + // + // Start from beginning of resource list. + // + Resource = ResourceList; + + for (Index = 0; Index < Count; Index++) { + if (Resource->Header.RscType == END_OF_RESOURCES) { + break; + } + Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); + } + + return (UINTN)Resource - (UINTN)ResourceList; +} + +/** + + Add resources in list to database. Allocate new memory areas as needed. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are added + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. + +**/ +EFI_STATUS +EFIAPI +AddPiResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ) +{ + EFI_STATUS Status; + UINTN ResourceSize; + EFI_PHYSICAL_ADDRESS NewResource; + UINTN NewResourceSize; + + DEBUG ((DEBUG_INFO, "AddPiResource - Enter\n")); + + if (!ValidateResource (ResourceList, NumEntries)) { + return EFI_INVALID_PARAMETER; + } + + ResourceSize = GetResourceSize (ResourceList, NumEntries); + DEBUG ((DEBUG_INFO, "ResourceSize - 0x%08x\n", ResourceSize)); + if (ResourceSize == 0) { + return EFI_INVALID_PARAMETER; + } + + if (mStmResourcesPtr == NULL) { + // + // First time allocation + // + NewResourceSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (ResourceSize + sizeof(mRscEndNode))); + DEBUG ((DEBUG_INFO, "Allocate - 0x%08x\n", NewResourceSize)); + Status = gSmst->SmmAllocatePages ( + AllocateAnyPages, + EfiRuntimeServicesData, + EFI_SIZE_TO_PAGES (NewResourceSize), + &NewResource + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Copy EndResource for intialization + // + mStmResourcesPtr = (UINT8 *)(UINTN)NewResource; + mStmResourceTotalSize = NewResourceSize; + CopyMem (mStmResourcesPtr, &mRscEndNode, sizeof(mRscEndNode)); + mStmResourceSizeUsed = sizeof(mRscEndNode); + mStmResourceSizeAvailable = mStmResourceTotalSize - sizeof(mRscEndNode); + + // + // Let SmmCore change resource ptr + // + NotifyStmResourceChange (mStmResourcesPtr); + } else if (mStmResourceSizeAvailable < ResourceSize) { + // + // Need enlarge + // + NewResourceSize = mStmResourceTotalSize + (ResourceSize - mStmResourceSizeAvailable); + NewResourceSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (NewResourceSize)); + DEBUG ((DEBUG_INFO, "ReAllocate - 0x%08x\n", NewResourceSize)); + Status = gSmst->SmmAllocatePages ( + AllocateAnyPages, + EfiRuntimeServicesData, + EFI_SIZE_TO_PAGES (NewResourceSize), + &NewResource + ); + if (EFI_ERROR (Status)) { + return Status; + } + CopyMem ((VOID *)(UINTN)NewResource, mStmResourcesPtr, mStmResourceSizeUsed); + mStmResourceSizeAvailable = NewResourceSize - mStmResourceSizeUsed; + + gSmst->SmmFreePages ( + (EFI_PHYSICAL_ADDRESS)(UINTN)mStmResourcesPtr, + EFI_SIZE_TO_PAGES (mStmResourceTotalSize) + ); + + mStmResourceTotalSize = NewResourceSize; + mStmResourcesPtr = (UINT8 *)(UINTN)NewResource; + + // + // Let SmmCore change resource ptr + // + NotifyStmResourceChange (mStmResourcesPtr); + } + + // + // Check duplication + // + AddResource (ResourceList, NumEntries); + + return EFI_SUCCESS; +} + +/** + + Delete resources in list to database. + + @param ResourceList A pointer to resource list to be deleted + NULL means delete all resources. + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are deleted + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + +**/ +EFI_STATUS +EFIAPI +DeletePiResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ) +{ + if (ResourceList != NULL) { + // TBD + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + // + // Delete all + // + CopyMem (mStmResourcesPtr, &mRscEndNode, sizeof(mRscEndNode)); + mStmResourceSizeUsed = sizeof(mRscEndNode); + mStmResourceSizeAvailable = mStmResourceTotalSize - sizeof(mRscEndNode); + return EFI_SUCCESS; +} + +/** + + Get BIOS resources. + + @param ResourceList A pointer to resource list to be filled + @param ResourceSize On input it means size of resource list input. + On output it means size of resource list filled, + or the size of resource list to be filled if size of too small. + + @retval EFI_SUCCESS If resources are returned. + @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. + +**/ +EFI_STATUS +EFIAPI +GetPiResource ( + OUT STM_RSC *ResourceList, + IN OUT UINT32 *ResourceSize + ) +{ + if (*ResourceSize < mStmResourceSizeUsed) { + *ResourceSize = (UINT32)mStmResourceSizeUsed; + return EFI_BUFFER_TOO_SMALL; + } + + CopyMem (ResourceList, mStmResourcesPtr, mStmResourceSizeUsed); + *ResourceSize = (UINT32)mStmResourceSizeUsed; + return EFI_SUCCESS; +} + +/** + + Set valid bit for MSEG MSR. + + @param Buffer Ap function buffer. (not used) + +**/ +VOID +EFIAPI +EnableMsegMsr ( + IN VOID *Buffer + ) +{ + MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; + + SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); + SmmMonitorCtl.Bits.Valid = 1; + AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, SmmMonitorCtl.Uint64); +} + +/** + + Get 4K page aligned VMCS size. + + @return 4K page aligned VMCS size + +**/ +UINT32 +GetVmcsSize ( + VOID + ) +{ + MSR_IA32_VMX_BASIC_REGISTER VmxBasic; + + // + // Read VMCS size and and align to 4KB + // + VmxBasic.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_BASIC); + return ALIGN_VALUE (VmxBasic.Bits.VmcsSize, SIZE_4KB); +} + +/** + + Check STM image size. + + @param StmImage STM image + @param StmImageSize STM image size + + @retval TRUE check pass + @retval FALSE check fail +**/ +BOOLEAN +StmCheckStmImage ( + IN EFI_PHYSICAL_ADDRESS StmImage, + IN UINTN StmImageSize + ) +{ + UINTN MinMsegSize; + STM_HEADER *StmHeader; + IA32_VMX_MISC_REGISTER VmxMiscMsr; + + // + // Check to see if STM image is compatible with CPU + // + StmHeader = (STM_HEADER *)(UINTN)StmImage; + VmxMiscMsr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_MISC); + if (StmHeader->HwStmHdr.MsegHeaderRevision != VmxMiscMsr.Bits.MsegRevisionIdentifier) { + DEBUG ((DEBUG_ERROR, "STM Image not compatible with CPU\n")); + DEBUG ((DEBUG_ERROR, " StmHeader->HwStmHdr.MsegHeaderRevision = %08x\n", StmHeader->HwStmHdr.MsegHeaderRevision)); + DEBUG ((DEBUG_ERROR, " VmxMiscMsr.Bits.MsegRevisionIdentifier = %08x\n", VmxMiscMsr.Bits.MsegRevisionIdentifier)); + return FALSE; + } + + // + // Get Minimal required Mseg size + // + MinMsegSize = (EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (StmHeader->SwStmHdr.StaticImageSize)) + + StmHeader->SwStmHdr.AdditionalDynamicMemorySize + + (StmHeader->SwStmHdr.PerProcDynamicMemorySize + GetVmcsSize () * 2) * gSmst->NumberOfCpus); + if (MinMsegSize < StmImageSize) { + MinMsegSize = StmImageSize; + } + + if (StmHeader->HwStmHdr.Cr3Offset >= StmHeader->SwStmHdr.StaticImageSize) { + // + // We will create page table, just in case that SINIT does not create it. + // + if (MinMsegSize < StmHeader->HwStmHdr.Cr3Offset + EFI_PAGES_TO_SIZE(6)) { + MinMsegSize = StmHeader->HwStmHdr.Cr3Offset + EFI_PAGES_TO_SIZE(6); + } + } + + // + // Check if it exceeds MSEG size + // + if (MinMsegSize > mMsegSize) { + DEBUG ((DEBUG_ERROR, "MSEG too small. Min MSEG Size = %08x Current MSEG Size = %08x\n", MinMsegSize, mMsegSize)); + DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.StaticImageSize = %08x\n", StmHeader->SwStmHdr.StaticImageSize)); + DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.AdditionalDynamicMemorySize = %08x\n", StmHeader->SwStmHdr.AdditionalDynamicMemorySize)); + DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.PerProcDynamicMemorySize = %08x\n", StmHeader->SwStmHdr.PerProcDynamicMemorySize)); + DEBUG ((DEBUG_ERROR, " VMCS Size = %08x\n", GetVmcsSize ())); + DEBUG ((DEBUG_ERROR, " Max CPUs = %08x\n", gSmst->NumberOfCpus)); + DEBUG ((DEBUG_ERROR, " StmHeader->HwStmHdr.Cr3Offset = %08x\n", StmHeader->HwStmHdr.Cr3Offset)); + return FALSE; + } + + return TRUE; +} + +/** + + Load STM image to MSEG. + + @param StmImage STM image + @param StmImageSize STM image size + +**/ +VOID +StmLoadStmImage ( + IN EFI_PHYSICAL_ADDRESS StmImage, + IN UINTN StmImageSize + ) +{ + MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; + UINT32 MsegBase; + STM_HEADER *StmHeader; + + // + // Get MSEG base address from MSR_IA32_SMM_MONITOR_CTL + // + SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); + MsegBase = SmmMonitorCtl.Bits.MsegBase << 12; + + // + // Zero all of MSEG base address + // + ZeroMem ((VOID *)(UINTN)MsegBase, mMsegSize); + + // + // Copy STM Image into MSEG + // + CopyMem ((VOID *)(UINTN)MsegBase, (VOID *)(UINTN)StmImage, StmImageSize); + + // + // STM Header is at the beginning of the STM Image + // + StmHeader = (STM_HEADER *)(UINTN)StmImage; + + StmGen4GPageTable ((UINTN)MsegBase + StmHeader->HwStmHdr.Cr3Offset); +} + +/** + + Load STM image to MSEG. + + @param StmImage STM image + @param StmImageSize STM image size + + @retval EFI_SUCCESS Load STM to MSEG successfully + @retval EFI_ALREADY_STARTED STM image is already loaded to MSEG + @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image + @retval EFI_UNSUPPORTED MSEG is not enabled + +**/ +EFI_STATUS +EFIAPI +LoadMonitor ( + IN EFI_PHYSICAL_ADDRESS StmImage, + IN UINTN StmImageSize + ) +{ + MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; + + if (mLockLoadMonitor) { + return EFI_ACCESS_DENIED; + } + + SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); + if (SmmMonitorCtl.Bits.MsegBase == 0) { + return EFI_UNSUPPORTED; + } + + if (!StmCheckStmImage (StmImage, StmImageSize)) { + return EFI_BUFFER_TOO_SMALL; + } + + // Record STM_HASH to PCR 0, just in case it is NOT TXT launch, we still need provide the evidence. + TpmMeasureAndLogData( + 0, // PcrIndex + TXT_EVTYPE_STM_HASH, // EventType + NULL, // EventLog + 0, // LogLen + (VOID *)(UINTN)StmImage, // HashData + StmImageSize // HashDataLen + ); + + StmLoadStmImage (StmImage, StmImageSize); + + mStmState |= EFI_SM_MONITOR_STATE_ENABLED; + + return EFI_SUCCESS; +} + +/** + This function return BIOS STM resource. + Produced by SmmStm. + Comsumed by SmmMpService when Init. + + @return BIOS STM resource + +**/ +VOID * +GetStmResource( + VOID + ) +{ + return mStmResourcesPtr; +} + +/** + This function notify STM resource change. + + @param StmResource BIOS STM resource + +**/ +VOID +NotifyStmResourceChange ( + VOID *StmResource + ) +{ + UINTN Index; + TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; + + for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { + Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)((UINTN)gSmst->CpuSaveState[Index] - SMRAM_SAVE_STATE_MAP_OFFSET + TXT_SMM_PSD_OFFSET); + Psd->BiosHwResourceRequirementsPtr = (UINT64)(UINTN)StmResource; + } + return ; +} + + +/** + This is STM setup BIOS callback. +**/ +VOID +EFIAPI +SmmStmSetup ( + VOID + ) +{ + mStmState |= EFI_SM_MONITOR_STATE_ACTIVATED; +} + +/** + This is STM teardown BIOS callback. +**/ +VOID +EFIAPI +SmmStmTeardown ( + VOID + ) +{ + mStmState &= ~EFI_SM_MONITOR_STATE_ACTIVATED; +} + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h new file mode 100644 index 0000000000..92a4dc00eb --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h @@ -0,0 +1,176 @@ +/** @file + SMM STM support + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_STM_H_ +#define _SMM_STM_H_ + +#include + +/** + + Create 4G page table for STM. + 2M PAE page table in X64 version. + + @param PageTableBase The page table base in MSEG + +**/ +VOID +StmGen4GPageTable ( + IN UINTN PageTableBase + ); + +/** + This is SMM exception handle. + Consumed by STM when exception happen. + + @param Context STM protection exception stack frame + + @return the EBX value for STM reference. + EBX = 0: resume SMM guest using register state found on exception stack. + EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the + TXT.ERRORCODE register and subsequently reset the system via + TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as + follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC + EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. + +**/ +UINT32 +EFIAPI +SmmStmExceptionHandler ( + IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context + ); + + +/** + + Get STM state. + + @return STM state + +**/ +EFI_SM_MONITOR_STATE +EFIAPI +GetMonitorState ( + VOID + ); + +/** + + Load STM image to MSEG. + + @param StmImage STM image + @param StmImageSize STM image size + + @retval EFI_SUCCESS Load STM to MSEG successfully + @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image + +**/ +EFI_STATUS +EFIAPI +LoadMonitor ( + IN EFI_PHYSICAL_ADDRESS StmImage, + IN UINTN StmImageSize + ); + +/** + + Add resources in list to database. Allocate new memory areas as needed. + + @param ResourceList A pointer to resource list to be added + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are added + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. + +**/ +EFI_STATUS +EFIAPI +AddPiResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ); + +/** + + Delete resources in list to database. + + @param ResourceList A pointer to resource list to be deleted + NULL means delete all resources. + @param NumEntries Optional number of entries. + If 0, list must be terminated by END_OF_RESOURCES. + + @retval EFI_SUCCESS If resources are deleted + @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer + +**/ +EFI_STATUS +EFIAPI +DeletePiResource ( + IN STM_RSC *ResourceList, + IN UINT32 NumEntries OPTIONAL + ); + +/** + + Get BIOS resources. + + @param ResourceList A pointer to resource list to be filled + @param ResourceSize On input it means size of resource list input. + On output it means size of resource list filled, + or the size of resource list to be filled if size of too small. + + @retval EFI_SUCCESS If resources are returned. + @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. + +**/ +EFI_STATUS +EFIAPI +GetPiResource ( + OUT STM_RSC *ResourceList, + IN OUT UINT32 *ResourceSize + ); + +/** + This functin initialize STM configuration table. +**/ +VOID +StmSmmConfigurationTableInit ( + VOID + ); + +/** + This function notify STM resource change. + + @param StmResource BIOS STM resource + +**/ +VOID +NotifyStmResourceChange ( + IN VOID *StmResource + ); + +/** + This function return BIOS STM resource. + + @return BIOS STM resource + +**/ +VOID * +GetStmResource ( + VOID + ); + +#endif diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S new file mode 100644 index 0000000000..1f9f91ce10 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S @@ -0,0 +1,282 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiEntry.S +# +# Abstract: +# +# Code template of the SMI handler for a particular processor +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerTemplate) +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerSize) +ASM_GLOBAL ASM_PFX(gcStmSmiHandlerOffset) +ASM_GLOBAL ASM_PFX(gStmSmiCr3) +ASM_GLOBAL ASM_PFX(gStmSmiStack) +ASM_GLOBAL ASM_PFX(gStmSmbase) +ASM_GLOBAL ASM_PFX(gStmXdSupported) +ASM_GLOBAL ASM_PFX(gStmSmiHandlerIdtr) + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0xc0000080 +.equ MSR_EFER_XD, 0x800 + +# +# Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +# +.equ DSC_OFFSET, 0xfb00 +.equ DSC_GDTPTR, 0x48 +.equ DSC_GDTSIZ, 0x50 +.equ DSC_CS, 0x14 +.equ DSC_DS, 0x16 +.equ DSC_SS, 0x18 +.equ DSC_OTHERSEG, 0x1a +# +# Constants relating to CPU State Save Area +# +.equ SSM_DR6, 0xffd0 +.equ SSM_DR7, 0xffc8 + +.equ PROTECT_MODE_CS, 0x08 +.equ PROTECT_MODE_DS, 0x20 +.equ LONG_MODE_CS, 0x38 +.equ TSS_SEGMENT, 0x40 +.equ GDT_SIZE, 0x50 + + .text + +ASM_PFX(gcStmSmiHandlerTemplate): + +_StmSmiEntryPoint: + # + # The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- + # bit addressing mode. And that coincidence has been used in the following + # "64-bit like" 16-bit code. Be aware that once RDI is referenced as a + # base address register, it is actually BX that is referenced. + # + .byte 0xbb # mov bx, imm16 + .word _StmGdtDesc - _StmSmiEntryPoint + 0x8000 + # + # fix GDT descriptor + # + .byte 0x2e,0xa1 # mov ax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTSIZ + .byte 0x48 # dec ax + .byte 0x2e + movl %eax, (%rdi) # mov cs:[bx], ax + .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTPTR + .byte 0x2e + movw %ax, 2(%rdi) + .byte 0x66,0x2e + lgdt (%rdi) + # + # Patch ProtectedMode Segment + # + .byte 0xb8 + .word PROTECT_MODE_CS + .byte 0x2e + movl %eax, -2(%rdi) + # + # Patch ProtectedMode entry + # + .byte 0x66, 0xbf # mov edi, SMBASE +ASM_PFX(gStmSmbase): .space 4 + lea ((ProtectedMode - _StmSmiEntryPoint) + 0x8000)(%edi), %ax + .byte 0x2e + movw %ax, -6(%rdi) + # + # Switch into ProtectedMode + # + movq %cr0, %rbx + .byte 0x66 + andl $0x9ffafff3, %ebx + .byte 0x66 + orl $0x00000023, %ebx + + movq %rbx, %cr0 + .byte 0x66, 0xea + .space 6 + +_StmGdtDesc: .space 6 + +ProtectedMode: + movw $PROTECT_MODE_DS, %ax + movl %eax, %ds + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + movl %eax, %ss + .byte 0xbc # mov esp, imm32 +ASM_PFX(gStmSmiStack): .space 4 + jmp ProtFlatMode + +ProtFlatMode: + .byte 0xb8 +ASM_PFX(gStmSmiCr3): .space 4 + movq %rax, %cr3 + movl $0x668,%eax # as cr4.PGE is not set here, refresh cr3 + movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. +# Load TSS + subl $8, %esp # reserve room in stack + sgdt (%rsp) + movl 2(%rsp), %eax # eax = GDT base + addl $8, %esp + movb $0x89, %dl + movb %dl, (TSS_SEGMENT + 5)(%rax) # clear busy flag + movl $TSS_SEGMENT, %eax + ltr %ax + +# enable NXE if supported + .byte 0xb0 # mov al, imm8 +ASM_PFX(gStmXdSupported): .byte 1 + cmpb $0, %al + jz SkipXd +# +# Check XD disable bit +# + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + subl $4, %esp + pushq %rdx # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr + jmp XdDone +SkipXd: + subl $8, %esp +XdDone: + + # + # Switch to LongMode + # + pushq $LONG_MODE_CS # push cs hardcore here + call Base # push return address for retf later +Base: + addl $(LongMode - Base), (%rsp) # offset for far retf, seg is the 1st arg + + movl $MSR_EFER, %ecx + rdmsr + orb $1,%ah # enable LME + wrmsr + movq %cr0, %rbx + orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE + movq %rbx, %cr0 + retf +LongMode: # long mode (64-bit code) starts here + movabsq $ASM_PFX(gStmSmiHandlerIdtr), %rax + lidt (%rax) + lea (DSC_OFFSET)(%rdi), %ebx + movw DSC_DS(%rbx), %ax + movl %eax,%ds + movw DSC_OTHERSEG(%rbx), %ax + movl %eax,%es + movl %eax,%fs + movl %eax,%gs + movw DSC_SS(%rbx), %ax + movl %eax,%ss + +CommonHandler: + movq 8(%rsp), %rbx + # Save FP registers + + subq $0x200, %rsp + .byte 0x48 # FXSAVE64 + fxsave (%rsp) + + addq $-0x20, %rsp + + movq %rbx, %rcx + movabsq $ASM_PFX(CpuSmmDebugEntry), %rax + call *%rax + + movq %rbx, %rcx + movabsq $ASM_PFX(SmiRendezvous), %rax + call *%rax + + movq %rbx, %rcx + movabsq $ASM_PFX(CpuSmmDebugExit), %rax + call *%rax + + addq $0x20, %rsp + + # + # Restore FP registers + # + .byte 0x48 # FXRSTOR64 + fxrstor (%rsp) + + addq $0x200, %rsp + + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz L16 + popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr + +L16: + rsm + +_StmSmiHandler: +# +# Check XD disable bit +# + xorq %r8, %r8 + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz StmXdDone + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L14 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L14: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone: + pushq %r8 + + # below step is needed, because STM does not run above code. + # we have to run below code to set IDT/CR0/CR4 + movabsq $ASM_PFX(gStmSmiHandlerIdtr), %rax + lidt (%rax) + + movq %cr0, %rax + orl $0x80010023, %eax + movq %rax, %cr0 + movq %cr4, %rax + movl $0x668, %eax # as cr4.PGE is not set here, refresh cr3 + movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. + # STM init finish + jmp CommonHandler + +ASM_PFX(gcStmSmiHandlerSize) : .word . - _StmSmiEntryPoint +ASM_PFX(gcStmSmiHandlerOffset): .word _StmSmiHandler - _StmSmiEntryPoint diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm new file mode 100644 index 0000000000..ad51e07079 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm @@ -0,0 +1,281 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.asm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +; +; Variables referenced by C code +; +EXTERNDEF SmiRendezvous:PROC +EXTERNDEF CpuSmmDebugEntry:PROC +EXTERNDEF CpuSmmDebugExit:PROC +EXTERNDEF gcStmSmiHandlerTemplate:BYTE +EXTERNDEF gcStmSmiHandlerSize:WORD +EXTERNDEF gcStmSmiHandlerOffset:WORD +EXTERNDEF gStmSmiCr3:DWORD +EXTERNDEF gStmSmiStack:DWORD +EXTERNDEF gStmSmbase:DWORD +EXTERNDEF gStmXdSupported:BYTE +EXTERNDEF gStmSmiHandlerIdtr:FWORD + +MSR_IA32_MISC_ENABLE EQU 1A0h +MSR_EFER EQU 0c0000080h +MSR_EFER_XD EQU 0800h + +; +; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +; +DSC_OFFSET EQU 0fb00h +DSC_GDTPTR EQU 48h +DSC_GDTSIZ EQU 50h +DSC_CS EQU 14h +DSC_DS EQU 16h +DSC_SS EQU 18h +DSC_OTHERSEG EQU 1ah +; +; Constants relating to CPU State Save Area +; +SSM_DR6 EQU 0ffd0h +SSM_DR7 EQU 0ffc8h + +PROTECT_MODE_CS EQU 08h +PROTECT_MODE_DS EQU 20h +LONG_MODE_CS EQU 38h +TSS_SEGMENT EQU 40h +GDT_SIZE EQU 50h + + .code + +gcStmSmiHandlerTemplate LABEL BYTE + +_StmSmiEntryPoint: + ; + ; The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- + ; bit addressing mode. And that coincidence has been used in the following + ; "64-bit like" 16-bit code. Be aware that once RDI is referenced as a + ; base address register, it is actually BX that is referenced. + ; + DB 0bbh ; mov bx, imm16 + DW offset _StmGdtDesc - _StmSmiEntryPoint + 8000h ; bx = GdtDesc offset +; fix GDT descriptor + DB 2eh, 0a1h ; mov ax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTSIZ + DB 48h ; dec ax + DB 2eh + mov [rdi], eax ; mov cs:[bx], ax + DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTPTR + DB 2eh + mov [rdi + 2], ax ; mov cs:[bx + 2], eax + DB 66h, 2eh + lgdt fword ptr [rdi] ; lgdt fword ptr cs:[bx] +; Patch ProtectedMode Segment + DB 0b8h ; mov ax, imm16 + DW PROTECT_MODE_CS ; set AX for segment directly + DB 2eh + mov [rdi - 2], eax ; mov cs:[bx - 2], ax +; Patch ProtectedMode entry + DB 66h, 0bfh ; mov edi, SMBASE +gStmSmbase DD ? + lea ax, [edi + (@ProtectedMode - _StmSmiEntryPoint) + 8000h] + DB 2eh + mov [rdi - 6], ax ; mov cs:[bx - 6], eax +; Switch into @ProtectedMode + mov rbx, cr0 + DB 66h + and ebx, 9ffafff3h + DB 66h + or ebx, 00000023h + + mov cr0, rbx + DB 66h, 0eah + DD ? + DW ? + +_StmGdtDesc FWORD ? +@ProtectedMode: + mov ax, PROTECT_MODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + DB 0bch ; mov esp, imm32 +gStmSmiStack DD ? + jmp ProtFlatMode + +ProtFlatMode: + DB 0b8h ; mov eax, offset gStmSmiCr3 +gStmSmiCr3 DD ? + mov cr3, rax + mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. +; Load TSS + sub esp, 8 ; reserve room in stack + sgdt fword ptr [rsp] + mov eax, [rsp + 2] ; eax = GDT base + add esp, 8 + mov dl, 89h + mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +gStmXdSupported DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + sub esp, 4 + push rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 8 +@XdDone: + +; Switch into @LongMode + push LONG_MODE_CS ; push cs hardcore here + call Base ; push return address for retf later +Base: + add dword ptr [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg + + mov ecx, MSR_EFER + rdmsr + or ah, 1 ; enable LME + wrmsr + mov rbx, cr0 + or ebx, 080010023h ; enable paging + WP + NE + MP + PE + mov cr0, rbx + retf +@LongMode: ; long mode (64-bit code) starts here + mov rax, offset gStmSmiHandlerIdtr + lidt fword ptr [rax] + lea ebx, [rdi + DSC_OFFSET] + mov ax, [rbx + DSC_DS] + mov ds, eax + mov ax, [rbx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [rbx + DSC_SS] + mov ss, eax + +CommonHandler: + mov rbx, [rsp + 0x08] ; rbx <- CpuIndex + + ; + ; Save FP registers + ; + sub rsp, 200h + DB 48h ; FXSAVE64 + fxsave [rsp] + + add rsp, -20h + + mov rcx, rbx + mov rax, CpuSmmDebugEntry + call rax + + mov rcx, rbx + mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous + call rax + + mov rcx, rbx + mov rax, CpuSmmDebugExit + call rax + + add rsp, 20h + + ; + ; Restore FP registers + ; + DB 48h ; FXRSTOR64 + fxrstor [rsp] + + add rsp, 200h + + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @f + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +@@: + rsm + +_StmSmiHandler: +; +; Check XD disable bit +; + xor r8, r8 + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone: + push r8 + + ; below step is needed, because STM does not run above code. + ; we have to run below code to set IDT/CR0/CR4 + mov rax, offset gStmSmiHandlerIdtr + lidt fword ptr [rax] + + mov rax, cr0 + or eax, 80010023h ; enable paging + WP + NE + MP + PE + mov cr0, rax + mov rax, cr4 + mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. + ; STM init finish + jmp CommonHandler + +gcStmSmiHandlerSize DW $ - _StmSmiEntryPoint +gcStmSmiHandlerOffset DW _StmSmiHandler - _StmSmiEntryPoint + + END diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm new file mode 100644 index 0000000000..c801591fc7 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm @@ -0,0 +1,263 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.nasm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +; +; Variables referrenced by C code +; + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +; +; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR +; +%define DSC_OFFSET 0xfb00 +%define DSC_GDTPTR 0x48 +%define DSC_GDTSIZ 0x50 +%define DSC_CS 0x14 +%define DSC_DS 0x16 +%define DSC_SS 0x18 +%define DSC_OTHERSEG 0x1a +; +; Constants relating to CPU State Save Area +; +%define SSM_DR6 0xffd0 +%define SSM_DR7 0xffc8 + +%define PROTECT_MODE_CS 0x8 +%define PROTECT_MODE_DS 0x20 +%define LONG_MODE_CS 0x38 +%define TSS_SEGMENT 0x40 +%define GDT_SIZE 0x50 + +extern ASM_PFX(SmiRendezvous) +extern ASM_PFX(gStmSmiHandlerIdtr) +extern ASM_PFX(CpuSmmDebugEntry) +extern ASM_PFX(CpuSmmDebugExit) + +global ASM_PFX(gStmSmbase) +global ASM_PFX(gStmXdSupported) +global ASM_PFX(gStmSmiStack) +global ASM_PFX(gStmSmiCr3) +global ASM_PFX(gcStmSmiHandlerTemplate) +global ASM_PFX(gcStmSmiHandlerSize) +global ASM_PFX(gcStmSmiHandlerOffset) + + DEFAULT REL + SECTION .text + +BITS 16 +ASM_PFX(gcStmSmiHandlerTemplate): +_StmSmiEntryPoint: + mov bx, _StmGdtDesc - _StmSmiEntryPoint + 0x8000 + mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] + dec ax + mov [cs:bx], ax + mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] + mov [cs:bx + 2], eax +o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] + mov ax, PROTECT_MODE_CS + mov [cs:bx-0x2],ax + DB 0x66, 0xbf ; mov edi, SMBASE +ASM_PFX(gStmSmbase): DD 0 + lea eax, [edi + (@ProtectedMode - _StmSmiEntryPoint) + 0x8000] + mov [cs:bx-0x6],eax + mov ebx, cr0 + and ebx, 0x9ffafff3 + or ebx, 0x23 + mov cr0, ebx + jmp dword 0x0:0x0 +_StmGdtDesc: + DW 0 + DD 0 + +BITS 32 +@ProtectedMode: + mov ax, PROTECT_MODE_DS +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax + DB 0xbc ; mov esp, imm32 +ASM_PFX(gStmSmiStack): DD 0 + jmp ProtFlatMode + +BITS 64 +ProtFlatMode: + DB 0xb8 ; mov eax, offset gStmSmiCr3 +ASM_PFX(gStmSmiCr3): DD 0 + mov cr3, rax + mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. +; Load TSS + sub esp, 8 ; reserve room in stack + sgdt [rsp] + mov eax, [rsp + 2] ; eax = GDT base + add esp, 8 + mov dl, 0x89 + mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax + +; enable NXE if supported + DB 0xb0 ; mov al, imm8 +ASM_PFX(gStmXdSupported): DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + sub esp, 4 + push rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .0 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.0: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 8 +@XdDone: + +; Switch into @LongMode + push LONG_MODE_CS ; push cs hardcore here + call Base ; push return address for retf later +Base: + add dword [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg + + mov ecx, MSR_EFER + rdmsr + or ah, 1 ; enable LME + wrmsr + mov rbx, cr0 + or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, rbx + retf +@LongMode: ; long mode (64-bit code) starts here + mov rax, ASM_PFX(gStmSmiHandlerIdtr) + lidt [rax] + lea ebx, [rdi + DSC_OFFSET] + mov ax, [rbx + DSC_DS] + mov ds, eax + mov ax, [rbx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [rbx + DSC_SS] + mov ss, eax + +CommonHandler: + mov rbx, [rsp + 0x08] ; rbx <- CpuIndex + + ; + ; Save FP registers + ; + sub rsp, 0x200 + DB 0x48 ; FXSAVE64 + fxsave [rsp] + + add rsp, -0x20 + + mov rcx, rbx + mov rax, CpuSmmDebugEntry + call rax + + mov rcx, rbx + mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous + call rax + + mov rcx, rbx + mov rax, CpuSmmDebugExit + call rax + + add rsp, 0x20 + + ; + ; Restore FP registers + ; + DB 0x48 ; FXRSTOR64 + fxrstor [rsp] + + add rsp, 0x200 + + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz .1 + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.1: + rsm + +_StmSmiHandler: +; +; Check XD disable bit +; + xor r8, r8 + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .0 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.0: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone: + push r8 + + ; below step is needed, because STM does not run above code. + ; we have to run below code to set IDT/CR0/CR4 + + mov rax, ASM_PFX(gStmSmiHandlerIdtr) + lidt [rax] + + mov rax, cr0 + or eax, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, rax + mov rax, cr4 + mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. + ; STM init finish + jmp CommonHandler + +ASM_PFX(gcStmSmiHandlerSize) : DW $ - _StmSmiEntryPoint +ASM_PFX(gcStmSmiHandlerOffset) : DW _StmSmiHandler - _StmSmiEntryPoint diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S new file mode 100644 index 0000000000..4d0cd9ac6f --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S @@ -0,0 +1,178 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiException.S +# +# Abstract: +# +# Exception handlers used in SM mode +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcStmPsd) + +ASM_GLOBAL ASM_PFX(SmmStmExceptionHandler) +ASM_GLOBAL ASM_PFX(SmmStmSetup) +ASM_GLOBAL ASM_PFX(SmmStmTeardown) + +.equ CODE_SEL, 0x38 +.equ DATA_SEL, 0x20 +.equ TR_SEL, 0x40 + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0x0c0000080 +.equ MSR_EFER_XD, 0x0800 + + .data + +# +# This structure serves as a template for all processors. +# +ASM_PFX(gcStmPsd): + .ascii "TXTPSSIG" + .word PSD_SIZE + .word 1 # Version + .long 0 # LocalApicId + .byte 0xF # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + .byte 0 # BIOS to STM + .byte 0 # STM to BIOS + .byte 0 + .word CODE_SEL + .word DATA_SEL + .word DATA_SEL + .word DATA_SEL + .word TR_SEL + .word 0 + .quad 0 # SmmCr3 + .quad ASM_PFX(_OnStmSetup) + .quad ASM_PFX(_OnStmTeardown) + .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint + .quad 0 # SmmSmiHandlerRsp + .quad 0 + .long 0 + .long 0x80010100 # RequiredStmSmmRevId + .quad ASM_PFX(_OnException) + .quad 0 # ExceptionStack + .word DATA_SEL + .word 0x1F # ExceptionFilter + .long 0 + .quad 0 + .quad 0 # BiosHwResourceRequirementsPtr + .quad 0 # AcpiRsdp + .byte 0 # PhysicalAddressBits +.equ PSD_SIZE, . - ASM_PFX(gcStmPsd) + + .text +#------------------------------------------------------------------------------ +# SMM Exception handlers +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(_OnException) +ASM_PFX(_OnException): + movq %rsp, %rcx + subq $0x28, %rsp + call ASM_PFX(SmmStmExceptionHandler) + addq $0x28, %rsp + movl %eax, %ebx + movl $4, %eax + .byte 0xf, 0x1, 0xc1 # VMCALL + jmp . + +ASM_GLOBAL ASM_PFX(_OnStmSetup) +ASM_PFX(_OnStmSetup): +# +# Check XD disable bit +# + xorq %r8, %r8 + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz StmXdDone1 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone1: + pushq %r8 + + subq $0x20, %rsp + call ASM_PFX(SmmStmSetup) + addq 0x20, %rsp + + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz L14 + popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L14 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr +L14: + + rsm + +ASM_GLOBAL ASM_PFX(_OnStmTeardown) +ASM_PFX(_OnStmTeardown): +# +# Check XD disable bit +# + xorq %r8, %r8 + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz StmXdDone2 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L15 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L15: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +StmXdDone2: + pushq %r8 + + subq $0x20, %rsp + call ASM_PFX(SmmStmTeardown) + addq $0x20, %rsp + + movabsq $ASM_PFX(gStmXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz L16 + popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr +L16: + + rsm + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm new file mode 100644 index 0000000000..33e9860160 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm @@ -0,0 +1,178 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.asm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +EXTERNDEF gcStmPsd:BYTE + +EXTERNDEF SmmStmExceptionHandler:PROC +EXTERNDEF SmmStmSetup:PROC +EXTERNDEF SmmStmTeardown:PROC +EXTERNDEF gStmXdSupported:BYTE + +CODE_SEL EQU 38h +DATA_SEL EQU 20h +TR_SEL EQU 40h + +MSR_IA32_MISC_ENABLE EQU 1A0h +MSR_EFER EQU 0c0000080h +MSR_EFER_XD EQU 0800h + + .data + +; +; This structure serves as a template for all processors. +; +gcStmPsd LABEL BYTE + DB 'TXTPSSIG' + DW PSD_SIZE + DW 1 ; Version + DD 0 ; LocalApicId + DB 0Fh ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + DB 0 ; BIOS to STM + DB 0 ; STM to BIOS + DB 0 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW TR_SEL + DW 0 + DQ 0 ; SmmCr3 + DQ _OnStmSetup + DQ _OnStmTeardown + DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint + DQ 0 ; SmmSmiHandlerRsp + DQ 0 + DD 0 + DD 80010100h ; RequiredStmSmmRevId + DQ _OnException + DQ 0 ; ExceptionStack + DW DATA_SEL + DW 01Fh ; ExceptionFilter + DD 0 + DQ 0 + DQ 0 ; BiosHwResourceRequirementsPtr + DQ 0 ; AcpiRsdp + DB 0 ; PhysicalAddressBits +PSD_SIZE = $ - offset gcStmPsd + + .code +;------------------------------------------------------------------------------ +; SMM Exception handlers +;------------------------------------------------------------------------------ +_OnException PROC + mov rcx, rsp + add rsp, -28h + call SmmStmExceptionHandler + add rsp, 28h + mov ebx, eax + mov eax, 4 + DB 0fh, 01h, 0c1h ; VMCALL + jmp $ +_OnException ENDP + +_OnStmSetup PROC +; +; Check XD disable bit +; + xor r8, r8 + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone1: + push r8 + + add rsp, -20h + call SmmStmSetup + add rsp, 20h + + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @f + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr +@@: + + rsm +_OnStmSetup ENDP + +_OnStmTeardown PROC +; +; Check XD disable bit +; + xor r8, r8 + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone2 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone2: + push r8 + + add rsp, -20h + call SmmStmTeardown + add rsp, 20h + + mov rax, offset ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @f + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr +@@: + + rsm +_OnStmTeardown ENDP + + END diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm new file mode 100644 index 0000000000..fe1bf3f165 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm @@ -0,0 +1,179 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.nasm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +global ASM_PFX(gcStmPsd) + +extern ASM_PFX(SmmStmExceptionHandler) +extern ASM_PFX(SmmStmSetup) +extern ASM_PFX(SmmStmTeardown) +extern ASM_PFX(gStmXdSupported) +extern ASM_PFX(gStmSmiHandlerIdtr) + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +CODE_SEL equ 0x38 +DATA_SEL equ 0x20 +TR_SEL equ 0x40 + + SECTION .data + +; +; This structure serves as a template for all processors. +; +ASM_PFX(gcStmPsd): + DB 'TXTPSSIG' + DW PSD_SIZE + DW 1 ; Version + DD 0 ; LocalApicId + DB 0x0F ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr + DB 0 ; BIOS to STM + DB 0 ; STM to BIOS + DB 0 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW TR_SEL + DW 0 + DQ 0 ; SmmCr3 + DQ ASM_PFX(OnStmSetup) + DQ ASM_PFX(OnStmTeardown) + DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint + DQ 0 ; SmmSmiHandlerRsp + DQ 0 + DD 0 + DD 0x80010100 ; RequiredStmSmmRevId + DQ ASM_PFX(OnException) + DQ 0 ; ExceptionStack + DW DATA_SEL + DW 0x01F ; ExceptionFilter + DD 0 + DQ 0 + DQ 0 ; BiosHwResourceRequirementsPtr + DQ 0 ; AcpiRsdp + DB 0 ; PhysicalAddressBits +PSD_SIZE equ $ - ASM_PFX(gcStmPsd) + + DEFAULT REL + SECTION .text +;------------------------------------------------------------------------------ +; SMM Exception handlers +;------------------------------------------------------------------------------ +global ASM_PFX(OnException) +ASM_PFX(OnException): + mov rcx, rsp + add rsp, -0x28 + call ASM_PFX(SmmStmExceptionHandler) + add rsp, 0x28 + mov ebx, eax + mov eax, 4 + DB 0x0f, 0x01, 0x0c1 ; VMCALL + jmp $ + +global ASM_PFX(OnStmSetup) +ASM_PFX(OnStmSetup): +; +; Check XD disable bit +; + xor r8, r8 + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .01 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.01: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone1: + push r8 + + add rsp, -0x20 + call ASM_PFX(SmmStmSetup) + add rsp, 0x20 + + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz .11 + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .11 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.11: + rsm + +global ASM_PFX(OnStmTeardown) +ASM_PFX(OnStmTeardown): +; +; Check XD disable bit +; + xor r8, r8 + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz @StmXdDone2 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .02 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.02: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr +@StmXdDone2: + push r8 + + add rsp, -0x20 + call ASM_PFX(SmmStmTeardown) + add rsp, 0x20 + + mov rax, ASM_PFX(gStmXdSupported) + mov al, [rax] + cmp al, 0 + jz .12 + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .12 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.12: + rsm + diff --git a/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c new file mode 100644 index 0000000000..6681234783 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c @@ -0,0 +1,95 @@ +/** @file + SMM STM support functions + + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#include "SmmStm.h" + +/// +/// Page Table Entry +/// +#define IA32_PG_P BIT0 +#define IA32_PG_RW BIT1 +#define IA32_PG_PS BIT7 + +/** + + Create 4G page table for STM. + 2M PAE page table in X64 version. + + @param PageTableBase The page table base in MSEG + +**/ +VOID +StmGen4GPageTable ( + IN UINTN PageTableBase + ) +{ + UINTN Index; + UINTN SubIndex; + UINT64 *Pde; + UINT64 *Pte; + UINT64 *Pml4; + + Pml4 = (UINT64*)(UINTN)PageTableBase; + PageTableBase += SIZE_4KB; + *Pml4 = PageTableBase | IA32_PG_RW | IA32_PG_P; + + Pde = (UINT64*)(UINTN)PageTableBase; + PageTableBase += SIZE_4KB; + Pte = (UINT64 *)(UINTN)PageTableBase; + + for (Index = 0; Index < 4; Index++) { + *Pde = PageTableBase | IA32_PG_RW | IA32_PG_P; + Pde++; + PageTableBase += SIZE_4KB; + + for (SubIndex = 0; SubIndex < SIZE_4KB / sizeof (*Pte); SubIndex++) { + *Pte = (((Index << 9) + SubIndex) << 21) | IA32_PG_PS | IA32_PG_RW | IA32_PG_P; + Pte++; + } + } +} + +/** + This is SMM exception handle. + Consumed by STM when exception happen. + + @param Context STM protection exception stack frame + + @return the EBX value for STM reference. + EBX = 0: resume SMM guest using register state found on exception stack. + EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the + TXT.ERRORCODE register and subsequently reset the system via + TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as + follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC + EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. + +**/ +UINT32 +EFIAPI +SmmStmExceptionHandler ( + IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context + ) +{ + // TBD - SmmStmExceptionHandler, record information + DEBUG ((DEBUG_ERROR, "SmmStmExceptionHandler ...\n")); + // + // Skip this instruction and continue; + // + Context.X64StackFrame->Rip += Context.X64StackFrame->VmcsExitInstructionLength; + + return 0; +} diff --git a/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c new file mode 100644 index 0000000000..efb61fa6f8 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c @@ -0,0 +1,108 @@ +/** @file +SMM CPU Platform Hook NULL library instance. + +Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#include +#include + +/** + Checks if platform produces a valid SMI. + + This function checks if platform produces a valid SMI. This function is + called at SMM entry to detect if this is a spurious SMI. This function + must be implemented in an MP safe way because it is called by multiple CPU + threads. + + @retval TRUE There is a valid SMI + @retval FALSE There is no valid SMI + +**/ +BOOLEAN +EFIAPI +PlatformValidSmi ( + VOID + ) +{ + return TRUE; +} + +/** + Clears platform top level SMI status bit. + + This function clears platform top level SMI status bit. + + @retval TRUE The platform top level SMI status is cleared. + @retval FALSE The platform top level SMI status cannot be cleared. + +**/ +BOOLEAN +EFIAPI +ClearTopLevelSmiStatus ( + VOID + ) +{ + return TRUE; +} + +/** + Performs platform specific way of SMM BSP election. + + This function performs platform specific way of SMM BSP election. + + @param IsBsp Output parameter. TRUE: the CPU this function executes + on is elected to be the SMM BSP. FALSE: the CPU this + function executes on is to be SMM AP. + + @retval EFI_SUCCESS The function executes successfully. + @retval EFI_NOT_READY The function does not determine whether this CPU should be + BSP or AP. This may occur if hardware init sequence to + enable the determination is yet to be done, or the function + chooses not to do BSP election and will let SMM CPU driver to + use its default BSP election process. + @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU should be + BSP or AP due to hardware error. + +**/ +EFI_STATUS +EFIAPI +PlatformSmmBspElection ( + OUT BOOLEAN *IsBsp + ) +{ + return EFI_NOT_READY; +} + +/** + Get platform page table attribute. + + This function gets page table attribute of platform. + + @param Address Input parameter. Obtain the page table entries attribute on this address. + @param PageSize Output parameter. The size of the page. + @param NumOfPages Output parameter. Number of page. + @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc). + + @retval EFI_SUCCESS The platform page table attribute from the address is determined. + @retval EFI_UNSUPPORTED The platform does not support getting page table attribute for the address. + +**/ +EFI_STATUS +EFIAPI +GetPlatformPageTableAttribute ( + IN UINT64 Address, + IN OUT SMM_PAGE_SIZE_TYPE *PageSize, + IN OUT UINTN *NumOfPages, + IN OUT UINTN *PageAttribute + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf new file mode 100644 index 0000000000..4dea5fb4e1 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf @@ -0,0 +1,40 @@ +## @file +# SMM CPU Platform Hook NULL library instance. +# +# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmCpuPlatformHookLibNull + MODULE_UNI_FILE = SmmCpuPlatformHookLibNull.uni + FILE_GUID = D6494E1B-E06F-4ab5-B64D-48B25AA9EB33 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = SmmCpuPlatformHookLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + SmmCpuPlatformHookLibNull.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec diff --git a/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni new file mode 100644 index 0000000000..46de9f3494 --- /dev/null +++ b/Core/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni @@ -0,0 +1,18 @@ +// /** @file +// SMM CPU Platform Hook NULL library instance. +// +// Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "SMM CPU Platform Hook NULL library instance" + +#string STR_MODULE_DESCRIPTION #language en-US "SMM CPU Platform Hook NULL library instance." diff --git a/Core/UefiCpuPkg/License.txt b/Core/UefiCpuPkg/License.txt new file mode 100644 index 0000000000..be68999be6 --- /dev/null +++ b/Core/UefiCpuPkg/License.txt @@ -0,0 +1,25 @@ +Copyright (c) 2012, Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c new file mode 100644 index 0000000000..aaeaa06729 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c @@ -0,0 +1,425 @@ +/** @file +PiSmmCommunication PEI Driver. + +Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PiSmmCommunicationPrivate.h" + +/** + the whole picture is below: + + +----------------------------------+ + | ACPI_VARIABLE_HOB | + | SmramDescriptor | <- DRAM + | CpuStart |--- + +----------------------------------+ | + | + +----------------------------------+<-- + | SMM_S3_RESUME_STATE | + | Signature | <- SMRAM + | Smst |--- + +----------------------------------+ | + | + +----------------------------------+<-- + | EFI_SMM_SYSTEM_TABLE2 | + | NumberOfTableEntries | <- SMRAM + | SmmConfigurationTable |--- + +----------------------------------+ | + | + +----------------------------------+<-- + | EFI_SMM_COMMUNICATION_CONTEXT | + | SwSmiNumber | <- SMRAM + | BufferPtrAddress |---------------- + +----------------------------------+ | + | + +----------------------------------+ | + | EFI_SMM_COMMUNICATION_ACPI_TABLE | | + | SwSmiNumber | <- AcpiTable | + | BufferPtrAddress |--- | + +----------------------------------+ | | + | | + +----------------------------------+<--------------- + | Communication Buffer Pointer | <- AcpiNvs + +----------------------------------+--- + | + +----------------------------------+<-- + | EFI_SMM_COMMUNICATE_HEADER | + | HeaderGuid | <- DRAM + | MessageLength | + +----------------------------------+ + +**/ + +#if defined (MDE_CPU_IA32) +typedef struct { + EFI_TABLE_HEADER Hdr; + UINT64 SmmFirmwareVendor; + UINT64 SmmFirmwareRevision; + UINT64 SmmInstallConfigurationTable; + UINT64 SmmIoMemRead; + UINT64 SmmIoMemWrite; + UINT64 SmmIoIoRead; + UINT64 SmmIoIoWrite; + UINT64 SmmAllocatePool; + UINT64 SmmFreePool; + UINT64 SmmAllocatePages; + UINT64 SmmFreePages; + UINT64 SmmStartupThisAp; + UINT64 CurrentlyExecutingCpu; + UINT64 NumberOfCpus; + UINT64 CpuSaveStateSize; + UINT64 CpuSaveState; + UINT64 NumberOfTableEntries; + UINT64 SmmConfigurationTable; +} EFI_SMM_SYSTEM_TABLE2_64; + +typedef struct { + EFI_GUID VendorGuid; + UINT64 VendorTable; +} EFI_CONFIGURATION_TABLE64; +#endif + +#if defined (MDE_CPU_X64) +typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64; +typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64; +#endif + +/** + Communicates with a registered handler. + + This function provides a service to send and receive messages from a registered UEFI service. + + @param[in] This The EFI_PEI_SMM_COMMUNICATION_PPI instance. + @param[in, out] CommBuffer A pointer to the buffer to convey into SMRAM. + @param[in, out] CommSize The size of the data buffer being passed in.On exit, the size of data + being returned. Zero if the handler does not wish to reply with any data. + + @retval EFI_SUCCESS The message was successfully posted. + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. + @retval EFI_NOT_STARTED The service is NOT started. +**/ +EFI_STATUS +EFIAPI +Communicate ( + IN CONST EFI_PEI_SMM_COMMUNICATION_PPI *This, + IN OUT VOID *CommBuffer, + IN OUT UINTN *CommSize + ); + +EFI_PEI_SMM_COMMUNICATION_PPI mSmmCommunicationPpi = { Communicate }; + +EFI_PEI_PPI_DESCRIPTOR mPpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiSmmCommunicationPpiGuid, + &mSmmCommunicationPpi +}; + +/** + Get SMM communication context. + + @return SMM communication context. +**/ +EFI_SMM_COMMUNICATION_CONTEXT * +GetCommunicationContext ( + VOID + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; + + GuidHob = GetFirstGuidHob (&gEfiPeiSmmCommunicationPpiGuid); + ASSERT (GuidHob != NULL); + + SmmCommunicationContext = (EFI_SMM_COMMUNICATION_CONTEXT *)GET_GUID_HOB_DATA (GuidHob); + + return SmmCommunicationContext; +} + +/** + Set SMM communication context. + + @param SmmCommunicationContext SMM communication context. +**/ +VOID +SetCommunicationContext ( + IN EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN BufferSize; + + BufferSize = sizeof (*SmmCommunicationContext); + Hob.Raw = BuildGuidHob ( + &gEfiPeiSmmCommunicationPpiGuid, + BufferSize + ); + ASSERT (Hob.Raw); + + CopyMem ((VOID *)Hob.Raw, SmmCommunicationContext, sizeof(*SmmCommunicationContext)); +} + +/** + Get VendorTable by VendorGuid in Smst. + + @param Signature Signature of SMM_S3_RESUME_STATE + @param Smst SMM system table + @param VendorGuid vendor guid + + @return vendor table. +**/ +VOID * +InternalSmstGetVendorTableByGuid ( + IN UINT64 Signature, + IN EFI_SMM_SYSTEM_TABLE2 *Smst, + IN EFI_GUID *VendorGuid + ) +{ + EFI_CONFIGURATION_TABLE *SmmConfigurationTable; + UINTN NumberOfTableEntries; + UINTN Index; + EFI_SMM_SYSTEM_TABLE2_64 *Smst64; + EFI_CONFIGURATION_TABLE64 *SmmConfigurationTable64; + + if ((sizeof(UINTN) == sizeof(UINT32)) && (Signature == SMM_S3_RESUME_SMM_64)) { + // + // 32 PEI + 64 DXE + // + Smst64 = (EFI_SMM_SYSTEM_TABLE2_64 *)Smst; + DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmConfigurationTable: %x\n", Smst64->SmmConfigurationTable)); + DEBUG ((EFI_D_INFO, "InitCommunicationContext - NumberOfTableEntries: %x\n", Smst64->NumberOfTableEntries)); + SmmConfigurationTable64 = (EFI_CONFIGURATION_TABLE64 *)(UINTN)Smst64->SmmConfigurationTable; + NumberOfTableEntries = (UINTN)Smst64->NumberOfTableEntries; + for (Index = 0; Index < NumberOfTableEntries; Index++) { + if (CompareGuid (&SmmConfigurationTable64[Index].VendorGuid, VendorGuid)) { + return (VOID *)(UINTN)SmmConfigurationTable64[Index].VendorTable; + } + } + return NULL; + } else { + DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmConfigurationTable: %x\n", Smst->SmmConfigurationTable)); + DEBUG ((EFI_D_INFO, "InitCommunicationContext - NumberOfTableEntries: %x\n", Smst->NumberOfTableEntries)); + SmmConfigurationTable = Smst->SmmConfigurationTable; + NumberOfTableEntries = Smst->NumberOfTableEntries; + for (Index = 0; Index < NumberOfTableEntries; Index++) { + if (CompareGuid (&SmmConfigurationTable[Index].VendorGuid, VendorGuid)) { + return (VOID *)SmmConfigurationTable[Index].VendorTable; + } + } + return NULL; + } +} + +/** + Init SMM communication context. +**/ +VOID +InitCommunicationContext ( + VOID + ) +{ + EFI_SMRAM_DESCRIPTOR *SmramDescriptor; + SMM_S3_RESUME_STATE *SmmS3ResumeState; + VOID *GuidHob; + EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; + + GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); + ASSERT (GuidHob != NULL); + SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); + SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; + + DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmS3ResumeState: %x\n", SmmS3ResumeState)); + DEBUG ((EFI_D_INFO, "InitCommunicationContext - Smst: %x\n", SmmS3ResumeState->Smst)); + + SmmCommunicationContext = (EFI_SMM_COMMUNICATION_CONTEXT *)InternalSmstGetVendorTableByGuid ( + SmmS3ResumeState->Signature, + (EFI_SMM_SYSTEM_TABLE2 *)(UINTN)SmmS3ResumeState->Smst, + &gEfiPeiSmmCommunicationPpiGuid + ); + ASSERT (SmmCommunicationContext != NULL); + + SetCommunicationContext (SmmCommunicationContext); + + return ; +} + +/** + Communicates with a registered handler. + + This function provides a service to send and receive messages from a registered UEFI service. + + @param[in] This The EFI_PEI_SMM_COMMUNICATION_PPI instance. + @param[in, out] CommBuffer A pointer to the buffer to convey into SMRAM. + @param[in, out] CommSize The size of the data buffer being passed in.On exit, the size of data + being returned. Zero if the handler does not wish to reply with any data. + + @retval EFI_SUCCESS The message was successfully posted. + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. + @retval EFI_NOT_STARTED The service is NOT started. +**/ +EFI_STATUS +EFIAPI +Communicate ( + IN CONST EFI_PEI_SMM_COMMUNICATION_PPI *This, + IN OUT VOID *CommBuffer, + IN OUT UINTN *CommSize + ) +{ + EFI_STATUS Status; + PEI_SMM_CONTROL_PPI *SmmControl; + PEI_SMM_ACCESS_PPI *SmmAccess; + UINT8 SmiCommand; + UINTN Size; + EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; + + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei Communicate Enter\n")); + + if (CommBuffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Get needed resource + // + Status = PeiServicesLocatePpi ( + &gPeiSmmControlPpiGuid, + 0, + NULL, + (VOID **)&SmmControl + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_STARTED; + } + + Status = PeiServicesLocatePpi ( + &gPeiSmmAccessPpiGuid, + 0, + NULL, + (VOID **)&SmmAccess + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_STARTED; + } + + // + // Check SMRAM locked, it should be done after SMRAM lock. + // + if (!SmmAccess->LockState) { + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei LockState - %x\n", (UINTN)SmmAccess->LockState)); + return EFI_NOT_STARTED; + } + + SmmCommunicationContext = GetCommunicationContext (); + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei BufferPtrAddress - 0x%016lx, BufferPtr: 0x%016lx\n", SmmCommunicationContext->BufferPtrAddress, *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress)); + + // + // No need to check if BufferPtr is 0, because it is in PEI phase. + // + *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer; + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei CommBuffer - %x\n", (UINTN)CommBuffer)); + + // + // Send command + // + SmiCommand = (UINT8)SmmCommunicationContext->SwSmiNumber; + Size = sizeof(SmiCommand); + Status = SmmControl->Trigger ( + (EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), + SmmControl, + (INT8 *)&SmiCommand, + &Size, + FALSE, + 0 + ); + ASSERT_EFI_ERROR (Status); + + // + // Setting BufferPtr to 0 means this transaction is done. + // + *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress = 0; + + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei Communicate Exit\n")); + + return EFI_SUCCESS; +} + +/** + Entry Point for PI SMM communication PEIM. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Pointer to PEI Services table. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +PiSmmCommunicationPeiEntryPoint ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + PEI_SMM_ACCESS_PPI *SmmAccess; + EFI_BOOT_MODE BootMode; + UINTN Index; + + BootMode = GetBootModeHob (); + if (BootMode != BOOT_ON_S3_RESUME) { + return EFI_UNSUPPORTED; + } + + Status = PeiServicesLocatePpi ( + &gPeiSmmAccessPpiGuid, + 0, + NULL, + (VOID **)&SmmAccess + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_STARTED; + } + + // + // Check SMRAM locked, it should be done before SMRAM lock. + // + if (SmmAccess->LockState) { + DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei LockState - %x\n", (UINTN)SmmAccess->LockState)); + return EFI_ACCESS_DENIED; + } + + // + // Open all SMRAM + // + for (Index = 0; !EFI_ERROR (Status); Index++) { + Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); + } + + InitCommunicationContext (); + + PeiServicesInstallPpi (&mPpiList); + + return RETURN_SUCCESS; +} diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf new file mode 100644 index 0000000000..5cb596c564 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf @@ -0,0 +1,70 @@ +## @file +# PI SMM Communication PEIM which produces PEI SMM Communication PPI. +# +# This PEIM retrieves the SMM communication context and produces PEI SMM +# Communication PPIin the S3 boot mode. +# +# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PiSmmCommunicationPei + MODULE_UNI_FILE = PiSmmCommunicationPei.uni + FILE_GUID = 1C8B7F78-1699-40e6-AF33-9B995D16B043 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = PiSmmCommunicationPeiEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + PiSmmCommunicationPei.c + PiSmmCommunicationPrivate.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + PeimEntryPoint + PeiServicesTablePointerLib + PeiServicesLib + BaseLib + BaseMemoryLib + HobLib + DebugLib + +[Guids] + gEfiAcpiVariableGuid ## CONSUMES ## HOB + +[Ppis] + ## PRODUCES + ## UNDEFINED # HOB # SMM Configuration Table + gEfiPeiSmmCommunicationPpiGuid + gPeiSmmAccessPpiGuid ## CONSUMES + gPeiSmmControlPpiGuid ## CONSUMES + +# [BootMode] +# S3_RESUME ## CONSUMES + +[Depex] + gPeiSmmAccessPpiGuid AND + gPeiSmmControlPpiGuid AND + gEfiPeiMasterBootModePpiGuid + +[UserExtensions.TianoCore."ExtraFiles"] + PiSmmCommunicationPeiExtra.uni diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni new file mode 100644 index 0000000000..697bb2b3d9 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni @@ -0,0 +1,21 @@ +// /** @file +// PI SMM Communication PEIM which produces PEI SMM Communication PPI. +// +// This PEIM retrieves the SMM communication context and produces PEI SMM +// Communication PPIin the S3 boot mode. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "PI SMM Communication PEIM that produces PEI SMM Communication PPI" + +#string STR_MODULE_DESCRIPTION #language en-US "This PEIM retrieves the SMM communication context and produces PEI SMM Communication PPI in the S3 boot mode." diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni new file mode 100644 index 0000000000..62e3f97928 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni @@ -0,0 +1,18 @@ +// /** @file +// PiSmmCommunicationPei Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"SMM Communication PEI Module" diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h new file mode 100644 index 0000000000..3dd5ac6e38 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h @@ -0,0 +1,30 @@ +/** @file +PiSmmCommunication private data structure + +Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_COMMUNICATION_PRIVATE_H_ +#define _SMM_COMMUNICATION_PRIVATE_H_ + +#pragma pack(push, 1) + +#define SMM_COMMUNICATION_SIGNATURE SIGNATURE_32 ('S','M','M','C') + +typedef struct { + UINT32 Signature; + UINT32 SwSmiNumber; + EFI_PHYSICAL_ADDRESS BufferPtrAddress; +} EFI_SMM_COMMUNICATION_CONTEXT; + +#pragma pack(pop) + +#endif diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c new file mode 100644 index 0000000000..077eacce88 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c @@ -0,0 +1,269 @@ +/** @file +PiSmmCommunication SMM Driver. + +Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "PiSmmCommunicationPrivate.h" + +EFI_SMM_COMMUNICATION_CONTEXT mSmmCommunicationContext = { + SMM_COMMUNICATION_SIGNATURE +}; + +EFI_SMM_COMMUNICATION_ACPI_TABLE mSmmCommunicationAcpiTable = { + { + { + EFI_ACPI_4_0_UEFI_ACPI_DATA_TABLE_SIGNATURE, + sizeof (EFI_SMM_COMMUNICATION_ACPI_TABLE), + 0x1, // Revision + 0x0, // Checksum + {0x0}, // OemId[6] + 0x0, // OemTableId + 0x0, // OemRevision + 0x0, // CreatorId + 0x0 // CreatorRevision + }, + {0x0}, // Identifier + OFFSET_OF (EFI_SMM_COMMUNICATION_ACPI_TABLE, SwSmiNumber) // DataOffset + }, + 0x0, // SwSmiNumber + 0x0 // BufferPtrAddress +}; + +/** + Set SMM communication context. +**/ +VOID +SetCommunicationContext ( + VOID + ) +{ + EFI_STATUS Status; + + Status = gSmst->SmmInstallConfigurationTable ( + gSmst, + &gEfiPeiSmmCommunicationPpiGuid, + &mSmmCommunicationContext, + sizeof(mSmmCommunicationContext) + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Dispatch function for a Software SMI handler. + + @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). + @param Context Points to an optional handler context which was specified when the + handler was registered. + @param CommBuffer A pointer to a collection of data in memory that will + be conveyed from a non-SMM environment into an SMM environment. + @param CommBufferSize The size of the CommBuffer. + + @retval EFI_SUCCESS Command is handled successfully. + +**/ +EFI_STATUS +EFIAPI +PiSmmCommunicationHandler ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL + ) +{ + UINTN CommSize; + EFI_STATUS Status; + EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader; + EFI_PHYSICAL_ADDRESS *BufferPtrAddress; + + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Enter\n")); + + BufferPtrAddress = (EFI_PHYSICAL_ADDRESS *)(UINTN)mSmmCommunicationContext.BufferPtrAddress; + CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)(UINTN)*BufferPtrAddress; + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateHeader - %x\n", CommunicateHeader)); + if (CommunicateHeader == NULL) { + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler is NULL, needn't to call dispatch function\n")); + Status = EFI_SUCCESS; + } else { + if (!SmmIsBufferOutsideSmmValid ((UINTN)CommunicateHeader, OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))) { + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateHeader invalid - 0x%x\n", CommunicateHeader)); + Status = EFI_SUCCESS; + goto Done; + } + + CommSize = (UINTN)CommunicateHeader->MessageLength; + if (!SmmIsBufferOutsideSmmValid ((UINTN)&CommunicateHeader->Data[0], CommSize)) { + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateData invalid - 0x%x\n", &CommunicateHeader->Data[0])); + Status = EFI_SUCCESS; + goto Done; + } + + // + // Call dispatch function + // + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Data - %x\n", &CommunicateHeader->Data[0])); + Status = gSmst->SmiManage ( + &CommunicateHeader->HeaderGuid, + NULL, + &CommunicateHeader->Data[0], + &CommSize + ); + } + +Done: + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler %r\n", Status)); + DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Exit\n")); + + return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_INTERRUPT_PENDING; +} + +/** + Allocate EfiACPIMemoryNVS below 4G memory address. + + This function allocates EfiACPIMemoryNVS below 4G memory address. + + @param Size Size of memory to allocate. + + @return Allocated address for output. + +**/ +VOID* +AllocateAcpiNvsMemoryBelow4G ( + IN UINTN Size + ) +{ + UINTN Pages; + EFI_PHYSICAL_ADDRESS Address; + EFI_STATUS Status; + VOID* Buffer; + + Pages = EFI_SIZE_TO_PAGES (Size); + Address = 0xffffffff; + + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + Pages, + &Address + ); + ASSERT_EFI_ERROR (Status); + + Buffer = (VOID *) (UINTN) Address; + ZeroMem (Buffer, Size); + + return Buffer; +} + +/** + Entry Point for PI SMM communication SMM driver. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +PiSmmCommunicationSmmEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_SMM_SW_DISPATCH2_PROTOCOL *SmmSwDispatch2; + EFI_SMM_SW_REGISTER_CONTEXT SmmSwDispatchContext; + EFI_HANDLE DispatchHandle; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; + UINTN TableKey; + UINT64 OemTableId; + EFI_PHYSICAL_ADDRESS *BufferPtrAddress; + + CopyMem ( + mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemId, + PcdGetPtr (PcdAcpiDefaultOemId), + sizeof (mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemId) + ); + OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId); + CopyMem (&mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemTableId, &OemTableId, sizeof (UINT64)); + mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); + mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId); + mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision); + + // + // Register software SMI handler + // + Status = gSmst->SmmLocateProtocol ( + &gEfiSmmSwDispatch2ProtocolGuid, + NULL, + (VOID **)&SmmSwDispatch2 + ); + ASSERT_EFI_ERROR (Status); + + SmmSwDispatchContext.SwSmiInputValue = (UINTN)-1; + Status = SmmSwDispatch2->Register ( + SmmSwDispatch2, + PiSmmCommunicationHandler, + &SmmSwDispatchContext, + &DispatchHandle + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((EFI_D_INFO, "SmmCommunication SwSmi: %x\n", (UINTN)SmmSwDispatchContext.SwSmiInputValue)); + + // + // Set ACPI table + // + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); + ASSERT_EFI_ERROR (Status); + + mSmmCommunicationAcpiTable.SwSmiNumber = (UINT32)SmmSwDispatchContext.SwSmiInputValue; + BufferPtrAddress = AllocateAcpiNvsMemoryBelow4G (sizeof(EFI_PHYSICAL_ADDRESS)); + ASSERT (BufferPtrAddress != NULL); + DEBUG ((EFI_D_INFO, "SmmCommunication BufferPtrAddress: 0x%016lx, BufferPtr: 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)BufferPtrAddress, *BufferPtrAddress)); + mSmmCommunicationAcpiTable.BufferPtrAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)BufferPtrAddress; + CopyMem (&mSmmCommunicationAcpiTable.UefiAcpiDataTable.Identifier, &gEfiSmmCommunicationProtocolGuid, sizeof(gEfiSmmCommunicationProtocolGuid)); + + Status = AcpiTableProtocol->InstallAcpiTable ( + AcpiTableProtocol, + &mSmmCommunicationAcpiTable, + sizeof(mSmmCommunicationAcpiTable), + &TableKey + ); + ASSERT_EFI_ERROR (Status); + + // + // Save context + // + mSmmCommunicationContext.SwSmiNumber = (UINT32)SmmSwDispatchContext.SwSmiInputValue; + mSmmCommunicationContext.BufferPtrAddress = mSmmCommunicationAcpiTable.BufferPtrAddress; + SetCommunicationContext (); + + return Status; +} diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf new file mode 100644 index 0000000000..9b03837cf3 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf @@ -0,0 +1,82 @@ +## @file +# PI SMM Communication SMM driver that installs the SMM Communication ACPI Table. +# +# This SMM driver installs the SMM Communication ACPI Table defined in the UEFI spec +# which provides a mechanism that can be used in the OS present environment by +# non-firmware agents for inter-mode communication with SMM agents. It also saves +# SMM communication context for use by SMM Communication PEIM in the S3 boot mode. +# +# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PiSmmCommunicationSmm + MODULE_UNI_FILE = PiSmmCommunicationSmm.uni + FILE_GUID = E21F35A8-42FF-4050-82D6-93F7CDFA7073 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x0001000A + ENTRY_POINT = PiSmmCommunicationSmmEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + PiSmmCommunicationSmm.c + PiSmmCommunicationPrivate.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + SmmServicesTableLib + BaseLib + BaseMemoryLib + HobLib + DebugLib + SmmMemLib + PcdLib + +[Guids] + gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## SystemTable + +[Ppis] + gEfiPeiSmmCommunicationPpiGuid ## UNDEFINED # SMM Configuration Table + +[Protocols] + gEfiSmmSwDispatch2ProtocolGuid ## CONSUMES + gEfiSmmCommunicationProtocolGuid ## UNDEFINED # SMM Communication ACPI Table GUID + gEfiAcpiTableProtocolGuid ## CONSUMES + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES + +[Depex] + gEfiSmmSwDispatch2ProtocolGuid AND + gEfiAcpiTableProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + PiSmmCommunicationSmmExtra.uni diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni new file mode 100644 index 0000000000..55df3905df --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni @@ -0,0 +1,23 @@ +// /** @file +// PI SMM Communication SMM driver that installs the SMM Communication ACPI Table. +// +// This SMM driver installs the SMM Communication ACPI Table defined in the UEFI spec +// which provides a mechanism that can be used in the OS present environment by +// non-firmware agents for inter-mode communication with SMM agents. It also saves +// SMM communication context for use by SMM Communication PEIM in the S3 boot mode. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "PI SMM Communication SMM driver that installs the SMM Communication ACPI Table" + +#string STR_MODULE_DESCRIPTION #language en-US "This SMM driver installs the SMM Communication ACPI Table defined in the UEFI Specification, which provides a mechanism that can be used in the OS-present environment by non-firmware agents for inter-mode communication with SMM agents. It also saves an SMM communication context for use by SMM Communication PEIM in the S3 boot mode." diff --git a/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni new file mode 100644 index 0000000000..34e7731fb5 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni @@ -0,0 +1,18 @@ +// /** @file +// PiSmmCommunicationSmm Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"SMM Communication ACPI Table DXE Driver" diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c new file mode 100644 index 0000000000..9404501498 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -0,0 +1,945 @@ +/** @file +Code for Processor S3 restoration + +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +typedef struct { + UINTN Lock; + VOID *StackStart; + UINTN StackSize; + VOID *ApFunction; + IA32_DESCRIPTOR GdtrProfile; + IA32_DESCRIPTOR IdtrProfile; + UINT32 BufferStart; + UINT32 Cr3; +} MP_CPU_EXCHANGE_INFO; + +typedef struct { + UINT8 *RendezvousFunnelAddress; + UINTN PModeEntryOffset; + UINTN FlatJumpOffset; + UINTN Size; + UINTN LModeEntryOffset; + UINTN LongJumpOffset; +} MP_ASSEMBLY_ADDRESS_MAP; + +// +// Spin lock used to serialize MemoryMapped operation +// +SPIN_LOCK *mMemoryMappedLock = NULL; + +/** + Get starting address and size of the rendezvous entry for APs. + Information for fixing a jump instruction in the code is also returned. + + @param AddressMap Output buffer for address map information. +**/ +VOID * +EFIAPI +AsmGetAddressMap ( + MP_ASSEMBLY_ADDRESS_MAP *AddressMap + ); + +#define LEGACY_REGION_SIZE (2 * 0x1000) +#define LEGACY_REGION_BASE (0xA0000 - LEGACY_REGION_SIZE) + +ACPI_CPU_DATA mAcpiCpuData; +volatile UINT32 mNumberToFinish; +MP_CPU_EXCHANGE_INFO *mExchangeInfo; +BOOLEAN mRestoreSmmConfigurationInS3 = FALSE; +VOID *mGdtForAp = NULL; +VOID *mIdtForAp = NULL; +VOID *mMachineCheckHandlerForAp = NULL; +MP_MSR_LOCK *mMsrSpinLocks = NULL; +UINTN mMsrSpinLockCount; +UINTN mMsrCount = 0; + +// +// S3 boot flag +// +BOOLEAN mSmmS3Flag = FALSE; + +// +// Pointer to structure used during S3 Resume +// +SMM_S3_RESUME_STATE *mSmmS3ResumeState = NULL; + +BOOLEAN mAcpiS3Enable = TRUE; + +UINT8 *mApHltLoopCode = NULL; +UINT8 mApHltLoopCodeTemplate[] = { + 0x8B, 0x44, 0x24, 0x04, // mov eax, dword ptr [esp+4] + 0xF0, 0xFF, 0x08, // lock dec dword ptr [eax] + 0xFA, // cli + 0xF4, // hlt + 0xEB, 0xFC // jmp $-2 + }; + +/** + Get MSR spin lock by MSR index. + + @param MsrIndex MSR index value. + + @return Pointer to MSR spin lock. + +**/ +SPIN_LOCK * +GetMsrSpinLockByIndex ( + IN UINT32 MsrIndex + ) +{ + UINTN Index; + for (Index = 0; Index < mMsrCount; Index++) { + if (MsrIndex == mMsrSpinLocks[Index].MsrIndex) { + return mMsrSpinLocks[Index].SpinLock; + } + } + return NULL; +} + +/** + Initialize MSR spin lock by MSR index. + + @param MsrIndex MSR index value. + +**/ +VOID +InitMsrSpinLockByIndex ( + IN UINT32 MsrIndex + ) +{ + UINTN MsrSpinLockCount; + UINTN NewMsrSpinLockCount; + UINTN Index; + UINTN AddedSize; + + if (mMsrSpinLocks == NULL) { + MsrSpinLockCount = mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter; + mMsrSpinLocks = (MP_MSR_LOCK *) AllocatePool (sizeof (MP_MSR_LOCK) * MsrSpinLockCount); + ASSERT (mMsrSpinLocks != NULL); + for (Index = 0; Index < MsrSpinLockCount; Index++) { + mMsrSpinLocks[Index].SpinLock = + (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreMsr.Msr + Index * mSemaphoreSize); + mMsrSpinLocks[Index].MsrIndex = (UINT32)-1; + } + mMsrSpinLockCount = MsrSpinLockCount; + mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter = 0; + } + if (GetMsrSpinLockByIndex (MsrIndex) == NULL) { + // + // Initialize spin lock for MSR programming + // + mMsrSpinLocks[mMsrCount].MsrIndex = MsrIndex; + InitializeSpinLock (mMsrSpinLocks[mMsrCount].SpinLock); + mMsrCount ++; + if (mMsrCount == mMsrSpinLockCount) { + // + // If MSR spin lock buffer is full, enlarge it + // + AddedSize = SIZE_4KB; + mSmmCpuSemaphores.SemaphoreMsr.Msr = + AllocatePages (EFI_SIZE_TO_PAGES(AddedSize)); + ASSERT (mSmmCpuSemaphores.SemaphoreMsr.Msr != NULL); + NewMsrSpinLockCount = mMsrSpinLockCount + AddedSize / mSemaphoreSize; + mMsrSpinLocks = ReallocatePool ( + sizeof (MP_MSR_LOCK) * mMsrSpinLockCount, + sizeof (MP_MSR_LOCK) * NewMsrSpinLockCount, + mMsrSpinLocks + ); + ASSERT (mMsrSpinLocks != NULL); + mMsrSpinLockCount = NewMsrSpinLockCount; + for (Index = mMsrCount; Index < mMsrSpinLockCount; Index++) { + mMsrSpinLocks[Index].SpinLock = + (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreMsr.Msr + + (Index - mMsrCount) * mSemaphoreSize); + mMsrSpinLocks[Index].MsrIndex = (UINT32)-1; + } + } + } +} + +/** + Sync up the MTRR values for all processors. + + @param MtrrTable Table holding fixed/variable MTRR values to be loaded. +**/ +VOID +EFIAPI +LoadMtrrData ( + EFI_PHYSICAL_ADDRESS MtrrTable + ) +/*++ + +Routine Description: + + Sync up the MTRR values for all processors. + +Arguments: + +Returns: + None + +--*/ +{ + MTRR_SETTINGS *MtrrSettings; + + MtrrSettings = (MTRR_SETTINGS *) (UINTN) MtrrTable; + MtrrSetAllMtrrs (MtrrSettings); +} + +/** + Programs registers for the calling processor. + + This function programs registers for the calling processor. + + @param RegisterTable Pointer to register table of the running processor. + +**/ +VOID +SetProcessorRegister ( + IN CPU_REGISTER_TABLE *RegisterTable + ) +{ + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; + UINTN Index; + UINTN Value; + SPIN_LOCK *MsrSpinLock; + + // + // Traverse Register Table of this logical processor + // + RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; + for (Index = 0; Index < RegisterTable->TableLength; Index++, RegisterTableEntry++) { + // + // Check the type of specified register + // + switch (RegisterTableEntry->RegisterType) { + // + // The specified register is Control Register + // + case ControlRegister: + switch (RegisterTableEntry->Index) { + case 0: + Value = AsmReadCr0 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINTN) RegisterTableEntry->Value + ); + AsmWriteCr0 (Value); + break; + case 2: + Value = AsmReadCr2 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINTN) RegisterTableEntry->Value + ); + AsmWriteCr2 (Value); + break; + case 3: + Value = AsmReadCr3 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINTN) RegisterTableEntry->Value + ); + AsmWriteCr3 (Value); + break; + case 4: + Value = AsmReadCr4 (); + Value = (UINTN) BitFieldWrite64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINTN) RegisterTableEntry->Value + ); + AsmWriteCr4 (Value); + break; + default: + break; + } + break; + // + // The specified register is Model Specific Register + // + case Msr: + // + // If this function is called to restore register setting after INIT signal, + // there is no need to restore MSRs in register table. + // + if (RegisterTableEntry->ValidBitLength >= 64) { + // + // If length is not less than 64 bits, then directly write without reading + // + AsmWriteMsr64 ( + RegisterTableEntry->Index, + RegisterTableEntry->Value + ); + } else { + // + // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode + // to make sure MSR read/write operation is atomic. + // + MsrSpinLock = GetMsrSpinLockByIndex (RegisterTableEntry->Index); + AcquireSpinLock (MsrSpinLock); + // + // Set the bit section according to bit start and length + // + AsmMsrBitFieldWrite64 ( + RegisterTableEntry->Index, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + RegisterTableEntry->Value + ); + ReleaseSpinLock (MsrSpinLock); + } + break; + // + // MemoryMapped operations + // + case MemoryMapped: + AcquireSpinLock (mMemoryMappedLock); + MmioBitFieldWrite32 ( + (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)), + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, + (UINT32)RegisterTableEntry->Value + ); + ReleaseSpinLock (mMemoryMappedLock); + break; + // + // Enable or disable cache + // + case CacheControl: + // + // If value of the entry is 0, then disable cache. Otherwise, enable cache. + // + if (RegisterTableEntry->Value == 0) { + AsmDisableCache (); + } else { + AsmEnableCache (); + } + break; + + default: + break; + } + } +} + +/** + AP initialization before SMBASE relocation in the S3 boot path. +**/ +VOID +EarlyMPRendezvousProcedure ( + VOID + ) +{ + CPU_REGISTER_TABLE *RegisterTableList; + UINT32 InitApicId; + UINTN Index; + + LoadMtrrData (mAcpiCpuData.MtrrTable); + + // + // Find processor number for this CPU. + // + RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.PreSmmInitRegisterTable; + InitApicId = GetInitialApicId (); + for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { + if (RegisterTableList[Index].InitialApicId == InitApicId) { + SetProcessorRegister (&RegisterTableList[Index]); + break; + } + } + + // + // Count down the number with lock mechanism. + // + InterlockedDecrement (&mNumberToFinish); +} + +/** + AP initialization after SMBASE relocation in the S3 boot path. +**/ +VOID +MPRendezvousProcedure ( + VOID + ) +{ + CPU_REGISTER_TABLE *RegisterTableList; + UINT32 InitApicId; + UINTN Index; + UINTN TopOfStack; + UINT8 Stack[128]; + + ProgramVirtualWireMode (); + DisableLvtInterrupts (); + + RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.RegisterTable; + InitApicId = GetInitialApicId (); + for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { + if (RegisterTableList[Index].InitialApicId == InitApicId) { + SetProcessorRegister (&RegisterTableList[Index]); + break; + } + } + + // + // Place AP into the safe code, count down the number with lock mechanism in the safe code. + // + TopOfStack = (UINTN) Stack + sizeof (Stack); + TopOfStack &= ~(UINTN) (CPU_STACK_ALIGNMENT - 1); + CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate)); + TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish); +} + +/** + Prepares startup vector for APs. + + This function prepares startup vector for APs. + + @param WorkingBuffer The address of the work buffer. +**/ +VOID +PrepareApStartupVector ( + EFI_PHYSICAL_ADDRESS WorkingBuffer + ) +{ + EFI_PHYSICAL_ADDRESS StartupVector; + MP_ASSEMBLY_ADDRESS_MAP AddressMap; + + // + // Get the address map of startup code for AP, + // including code size, and offset of long jump instructions to redirect. + // + ZeroMem (&AddressMap, sizeof (AddressMap)); + AsmGetAddressMap (&AddressMap); + + StartupVector = WorkingBuffer; + + // + // Copy AP startup code to startup vector, and then redirect the long jump + // instructions for mode switching. + // + CopyMem ((VOID *) (UINTN) StartupVector, AddressMap.RendezvousFunnelAddress, AddressMap.Size); + *(UINT32 *) (UINTN) (StartupVector + AddressMap.FlatJumpOffset + 3) = (UINT32) (StartupVector + AddressMap.PModeEntryOffset); + if (AddressMap.LongJumpOffset != 0) { + *(UINT32 *) (UINTN) (StartupVector + AddressMap.LongJumpOffset + 2) = (UINT32) (StartupVector + AddressMap.LModeEntryOffset); + } + + // + // Get the start address of exchange data between BSP and AP. + // + mExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) (StartupVector + AddressMap.Size); + ZeroMem ((VOID *) mExchangeInfo, sizeof (MP_CPU_EXCHANGE_INFO)); + + CopyMem ((VOID *) (UINTN) &mExchangeInfo->GdtrProfile, (VOID *) (UINTN) mAcpiCpuData.GdtrProfile, sizeof (IA32_DESCRIPTOR)); + CopyMem ((VOID *) (UINTN) &mExchangeInfo->IdtrProfile, (VOID *) (UINTN) mAcpiCpuData.IdtrProfile, sizeof (IA32_DESCRIPTOR)); + + // + // Copy AP's GDT, IDT and Machine Check handler from SMRAM to ACPI NVS memory + // + CopyMem ((VOID *) mExchangeInfo->GdtrProfile.Base, mGdtForAp, mExchangeInfo->GdtrProfile.Limit + 1); + CopyMem ((VOID *) mExchangeInfo->IdtrProfile.Base, mIdtForAp, mExchangeInfo->IdtrProfile.Limit + 1); + CopyMem ((VOID *)(UINTN) mAcpiCpuData.ApMachineCheckHandlerBase, mMachineCheckHandlerForAp, mAcpiCpuData.ApMachineCheckHandlerSize); + + mExchangeInfo->StackStart = (VOID *) (UINTN) mAcpiCpuData.StackAddress; + mExchangeInfo->StackSize = mAcpiCpuData.StackSize; + mExchangeInfo->BufferStart = (UINT32) StartupVector; + mExchangeInfo->Cr3 = (UINT32) (AsmReadCr3 ()); +} + +/** + The function is invoked before SMBASE relocation in S3 path to restores CPU status. + + The function is invoked before SMBASE relocation in S3 path. It does first time microcode load + and restores MTRRs for both BSP and APs. + +**/ +VOID +EarlyInitializeCpu ( + VOID + ) +{ + CPU_REGISTER_TABLE *RegisterTableList; + UINT32 InitApicId; + UINTN Index; + + LoadMtrrData (mAcpiCpuData.MtrrTable); + + // + // Find processor number for this CPU. + // + RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.PreSmmInitRegisterTable; + InitApicId = GetInitialApicId (); + for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { + if (RegisterTableList[Index].InitialApicId == InitApicId) { + SetProcessorRegister (&RegisterTableList[Index]); + break; + } + } + + ProgramVirtualWireMode (); + + PrepareApStartupVector (mAcpiCpuData.StartupVector); + + mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; + mExchangeInfo->ApFunction = (VOID *) (UINTN) EarlyMPRendezvousProcedure; + + // + // Send INIT IPI - SIPI to all APs + // + SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + + while (mNumberToFinish > 0) { + CpuPause (); + } +} + +/** + The function is invoked after SMBASE relocation in S3 path to restores CPU status. + + The function is invoked after SMBASE relocation in S3 path. It restores configuration according to + data saved by normal boot path for both BSP and APs. + +**/ +VOID +InitializeCpu ( + VOID + ) +{ + CPU_REGISTER_TABLE *RegisterTableList; + UINT32 InitApicId; + UINTN Index; + + RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.RegisterTable; + InitApicId = GetInitialApicId (); + for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { + if (RegisterTableList[Index].InitialApicId == InitApicId) { + SetProcessorRegister (&RegisterTableList[Index]); + break; + } + } + + mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; + // + // StackStart was updated when APs were waken up in EarlyInitializeCpu. + // Re-initialize StackAddress to original beginning address. + // + mExchangeInfo->StackStart = (VOID *) (UINTN) mAcpiCpuData.StackAddress; + mExchangeInfo->ApFunction = (VOID *) (UINTN) MPRendezvousProcedure; + + // + // Send INIT IPI - SIPI to all APs + // + SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + + while (mNumberToFinish > 0) { + CpuPause (); + } +} + +/** + Restore SMM Configuration in S3 boot path. + +**/ +VOID +RestoreSmmConfigurationInS3 ( + VOID + ) +{ + if (!mAcpiS3Enable) { + return; + } + + // + // Restore SMM Configuration in S3 boot path. + // + if (mRestoreSmmConfigurationInS3) { + // + // Need make sure gSmst is correct because below function may use them. + // + gSmst->SmmStartupThisAp = gSmmCpuPrivate->SmmCoreEntryContext.SmmStartupThisAp; + gSmst->CurrentlyExecutingCpu = gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu; + gSmst->NumberOfCpus = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + gSmst->CpuSaveStateSize = gSmmCpuPrivate->SmmCoreEntryContext.CpuSaveStateSize; + gSmst->CpuSaveState = gSmmCpuPrivate->SmmCoreEntryContext.CpuSaveState; + + // + // Configure SMM Code Access Check feature if available. + // + ConfigSmmCodeAccessCheck (); + + SmmCpuFeaturesCompleteSmmReadyToLock (); + + mRestoreSmmConfigurationInS3 = FALSE; + } +} + +/** + Perform SMM initialization for all processors in the S3 boot path. + + For a native platform, MP initialization in the S3 boot path is also performed in this function. +**/ +VOID +EFIAPI +SmmRestoreCpu ( + VOID + ) +{ + SMM_S3_RESUME_STATE *SmmS3ResumeState; + IA32_DESCRIPTOR Ia32Idtr; + IA32_DESCRIPTOR X64Idtr; + IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER]; + EFI_STATUS Status; + + DEBUG ((EFI_D_INFO, "SmmRestoreCpu()\n")); + + mSmmS3Flag = TRUE; + + InitializeSpinLock (mMemoryMappedLock); + + // + // See if there is enough context to resume PEI Phase + // + if (mSmmS3ResumeState == NULL) { + DEBUG ((EFI_D_ERROR, "No context to return to PEI Phase\n")); + CpuDeadLoop (); + } + + SmmS3ResumeState = mSmmS3ResumeState; + ASSERT (SmmS3ResumeState != NULL); + + if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { + // + // Save the IA32 IDT Descriptor + // + AsmReadIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); + + // + // Setup X64 IDT table + // + ZeroMem (IdtEntryTable, sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32); + X64Idtr.Base = (UINTN) IdtEntryTable; + X64Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32 - 1); + AsmWriteIdtr ((IA32_DESCRIPTOR *) &X64Idtr); + + // + // Setup the default exception handler + // + Status = InitializeCpuExceptionHandlers (NULL); + ASSERT_EFI_ERROR (Status); + + // + // Initialize Debug Agent to support source level debug + // + InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL); + } + + // + // Skip initialization if mAcpiCpuData is not valid + // + if (mAcpiCpuData.NumberOfCpus > 0) { + // + // First time microcode load and restore MTRRs + // + EarlyInitializeCpu (); + } + + // + // Restore SMBASE for BSP and all APs + // + SmmRelocateBases (); + + // + // Skip initialization if mAcpiCpuData is not valid + // + if (mAcpiCpuData.NumberOfCpus > 0) { + // + // Restore MSRs for BSP and all APs + // + InitializeCpu (); + } + + // + // Set a flag to restore SMM configuration in S3 path. + // + mRestoreSmmConfigurationInS3 = TRUE; + + DEBUG (( EFI_D_INFO, "SMM S3 Return CS = %x\n", SmmS3ResumeState->ReturnCs)); + DEBUG (( EFI_D_INFO, "SMM S3 Return Entry Point = %x\n", SmmS3ResumeState->ReturnEntryPoint)); + DEBUG (( EFI_D_INFO, "SMM S3 Return Context1 = %x\n", SmmS3ResumeState->ReturnContext1)); + DEBUG (( EFI_D_INFO, "SMM S3 Return Context2 = %x\n", SmmS3ResumeState->ReturnContext2)); + DEBUG (( EFI_D_INFO, "SMM S3 Return Stack Pointer = %x\n", SmmS3ResumeState->ReturnStackPointer)); + + // + // If SMM is in 32-bit mode, then use SwitchStack() to resume PEI Phase + // + if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) { + DEBUG ((EFI_D_INFO, "Call SwitchStack() to return to S3 Resume in PEI Phase\n")); + + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->ReturnEntryPoint, + (VOID *)(UINTN)SmmS3ResumeState->ReturnContext1, + (VOID *)(UINTN)SmmS3ResumeState->ReturnContext2, + (VOID *)(UINTN)SmmS3ResumeState->ReturnStackPointer + ); + } + + // + // If SMM is in 64-bit mode, then use AsmDisablePaging64() to resume PEI Phase + // + if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { + DEBUG ((EFI_D_INFO, "Call AsmDisablePaging64() to return to S3 Resume in PEI Phase\n")); + // + // Disable interrupt of Debug timer, since new IDT table is for IA32 and will not work in long mode. + // + SaveAndSetDebugTimerInterrupt (FALSE); + // + // Restore IA32 IDT table + // + AsmWriteIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); + AsmDisablePaging64 ( + SmmS3ResumeState->ReturnCs, + (UINT32)SmmS3ResumeState->ReturnEntryPoint, + (UINT32)SmmS3ResumeState->ReturnContext1, + (UINT32)SmmS3ResumeState->ReturnContext2, + (UINT32)SmmS3ResumeState->ReturnStackPointer + ); + } + + // + // Can not resume PEI Phase + // + DEBUG ((EFI_D_ERROR, "No context to return to PEI Phase\n")); + CpuDeadLoop (); +} + +/** + Initialize SMM S3 resume state structure used during S3 Resume. + + @param[in] Cr3 The base address of the page tables to use in SMM. + +**/ +VOID +InitSmmS3ResumeState ( + IN UINT32 Cr3 + ) +{ + VOID *GuidHob; + EFI_SMRAM_DESCRIPTOR *SmramDescriptor; + SMM_S3_RESUME_STATE *SmmS3ResumeState; + EFI_PHYSICAL_ADDRESS Address; + EFI_STATUS Status; + + if (!mAcpiS3Enable) { + return; + } + + GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); + if (GuidHob != NULL) { + SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); + + DEBUG ((EFI_D_INFO, "SMM S3 SMRAM Structure = %x\n", SmramDescriptor)); + DEBUG ((EFI_D_INFO, "SMM S3 Structure = %x\n", SmramDescriptor->CpuStart)); + + SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; + ZeroMem (SmmS3ResumeState, sizeof (SMM_S3_RESUME_STATE)); + + mSmmS3ResumeState = SmmS3ResumeState; + SmmS3ResumeState->Smst = (EFI_PHYSICAL_ADDRESS)(UINTN)gSmst; + + SmmS3ResumeState->SmmS3ResumeEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)SmmRestoreCpu; + + SmmS3ResumeState->SmmS3StackSize = SIZE_32KB; + SmmS3ResumeState->SmmS3StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)SmmS3ResumeState->SmmS3StackSize)); + if (SmmS3ResumeState->SmmS3StackBase == 0) { + SmmS3ResumeState->SmmS3StackSize = 0; + } + + SmmS3ResumeState->SmmS3Cr0 = gSmmCr0; + SmmS3ResumeState->SmmS3Cr3 = Cr3; + SmmS3ResumeState->SmmS3Cr4 = gSmmCr4; + + if (sizeof (UINTN) == sizeof (UINT64)) { + SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_64; + } + if (sizeof (UINTN) == sizeof (UINT32)) { + SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_32; + } + } + + // + // Patch SmmS3ResumeState->SmmS3Cr3 + // + InitSmmS3Cr3 (); + + // + // Allocate safe memory in ACPI NVS for AP to execute hlt loop in + // protected mode on S3 path + // + Address = BASE_4GB - 1; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + EFI_SIZE_TO_PAGES (sizeof (mApHltLoopCodeTemplate)), + &Address + ); + ASSERT_EFI_ERROR (Status); + mApHltLoopCode = (UINT8 *) (UINTN) Address; +} + +/** + Copy register table from ACPI NVS memory into SMRAM. + + @param[in] DestinationRegisterTableList Points to destination register table. + @param[in] SourceRegisterTableList Points to source register table. + @param[in] NumberOfCpus Number of CPUs. + +**/ +VOID +CopyRegisterTable ( + IN CPU_REGISTER_TABLE *DestinationRegisterTableList, + IN CPU_REGISTER_TABLE *SourceRegisterTableList, + IN UINT32 NumberOfCpus + ) +{ + UINTN Index; + UINTN Index1; + CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; + + CopyMem (DestinationRegisterTableList, SourceRegisterTableList, NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); + for (Index = 0; Index < NumberOfCpus; Index++) { + if (DestinationRegisterTableList[Index].AllocatedSize != 0) { + RegisterTableEntry = AllocateCopyPool ( + DestinationRegisterTableList[Index].AllocatedSize, + (VOID *)(UINTN)SourceRegisterTableList[Index].RegisterTableEntry + ); + ASSERT (RegisterTableEntry != NULL); + DestinationRegisterTableList[Index].RegisterTableEntry = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTableEntry; + // + // Go though all MSRs in register table to initialize MSR spin lock + // + for (Index1 = 0; Index1 < DestinationRegisterTableList[Index].TableLength; Index1++, RegisterTableEntry++) { + if ((RegisterTableEntry->RegisterType == Msr) && (RegisterTableEntry->ValidBitLength < 64)) { + // + // Initialize MSR spin lock only for those MSRs need bit field writing + // + InitMsrSpinLockByIndex (RegisterTableEntry->Index); + } + } + } + } +} + +/** + Get ACPI CPU data. + +**/ +VOID +GetAcpiCpuData ( + VOID + ) +{ + ACPI_CPU_DATA *AcpiCpuData; + IA32_DESCRIPTOR *Gdtr; + IA32_DESCRIPTOR *Idtr; + + if (!mAcpiS3Enable) { + return; + } + + // + // Prevent use of mAcpiCpuData by initialize NumberOfCpus to 0 + // + mAcpiCpuData.NumberOfCpus = 0; + + // + // If PcdCpuS3DataAddress was never set, then do not copy CPU S3 Data into SMRAM + // + AcpiCpuData = (ACPI_CPU_DATA *)(UINTN)PcdGet64 (PcdCpuS3DataAddress); + if (AcpiCpuData == 0) { + return; + } + + // + // For a native platform, copy the CPU S3 data into SMRAM for use on CPU S3 Resume. + // + CopyMem (&mAcpiCpuData, AcpiCpuData, sizeof (mAcpiCpuData)); + + mAcpiCpuData.MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (MTRR_SETTINGS)); + ASSERT (mAcpiCpuData.MtrrTable != 0); + + CopyMem ((VOID *)(UINTN)mAcpiCpuData.MtrrTable, (VOID *)(UINTN)AcpiCpuData->MtrrTable, sizeof (MTRR_SETTINGS)); + + mAcpiCpuData.GdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (IA32_DESCRIPTOR)); + ASSERT (mAcpiCpuData.GdtrProfile != 0); + + CopyMem ((VOID *)(UINTN)mAcpiCpuData.GdtrProfile, (VOID *)(UINTN)AcpiCpuData->GdtrProfile, sizeof (IA32_DESCRIPTOR)); + + mAcpiCpuData.IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (IA32_DESCRIPTOR)); + ASSERT (mAcpiCpuData.IdtrProfile != 0); + + CopyMem ((VOID *)(UINTN)mAcpiCpuData.IdtrProfile, (VOID *)(UINTN)AcpiCpuData->IdtrProfile, sizeof (IA32_DESCRIPTOR)); + + mAcpiCpuData.PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); + ASSERT (mAcpiCpuData.PreSmmInitRegisterTable != 0); + + CopyRegisterTable ( + (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.PreSmmInitRegisterTable, + (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->PreSmmInitRegisterTable, + mAcpiCpuData.NumberOfCpus + ); + + mAcpiCpuData.RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); + ASSERT (mAcpiCpuData.RegisterTable != 0); + + CopyRegisterTable ( + (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.RegisterTable, + (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->RegisterTable, + mAcpiCpuData.NumberOfCpus + ); + + // + // Copy AP's GDT, IDT and Machine Check handler into SMRAM. + // + Gdtr = (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.GdtrProfile; + Idtr = (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.IdtrProfile; + + mGdtForAp = AllocatePool ((Gdtr->Limit + 1) + (Idtr->Limit + 1) + mAcpiCpuData.ApMachineCheckHandlerSize); + ASSERT (mGdtForAp != NULL); + mIdtForAp = (VOID *) ((UINTN)mGdtForAp + (Gdtr->Limit + 1)); + mMachineCheckHandlerForAp = (VOID *) ((UINTN)mIdtForAp + (Idtr->Limit + 1)); + + CopyMem (mGdtForAp, (VOID *)Gdtr->Base, Gdtr->Limit + 1); + CopyMem (mIdtForAp, (VOID *)Idtr->Base, Idtr->Limit + 1); + CopyMem (mMachineCheckHandlerForAp, (VOID *)(UINTN)mAcpiCpuData.ApMachineCheckHandlerBase, mAcpiCpuData.ApMachineCheckHandlerSize); +} + +/** + Get ACPI S3 enable flag. + +**/ +VOID +GetAcpiS3EnableFlag ( + VOID + ) +{ + mAcpiS3Enable = PcdGetBool (PcdAcpiS3Enable); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c new file mode 100644 index 0000000000..29f3a58939 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c @@ -0,0 +1,372 @@ +/** @file +Implementation of SMM CPU Services Protocol. + +Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +// +// SMM CPU Service Protocol instance +// +EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService = { + SmmGetProcessorInfo, + SmmSwitchBsp, + SmmAddProcessor, + SmmRemoveProcessor, + SmmWhoAmI, + SmmRegisterExceptionHandler +}; + +/** + Gets processor information on the requested processor at the instant this call is made. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + +**/ +EFI_STATUS +EFIAPI +SmmGetProcessorInfo ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + // + // Check parameter + // + if (ProcessorNumber >= mMaxNumberOfCpus || ProcessorInfoBuffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { + return EFI_NOT_FOUND; + } + + // + // Fill in processor information + // + CopyMem (ProcessorInfoBuffer, &gSmmCpuPrivate->ProcessorInfo[ProcessorNumber], sizeof (EFI_PROCESSOR_INFORMATION)); + return EFI_SUCCESS; +} + +/** + This service switches the requested AP to be the BSP since the next SMI. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. + + @retval EFI_SUCCESS BSP will be switched in next SMI. + @retval EFI_UNSUPPORTED Switching the BSP or a processor to be hot-removed is not supported. + @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. +**/ +EFI_STATUS +EFIAPI +SmmSwitchBsp ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ) +{ + // + // Check parameter + // + if (ProcessorNumber >= mMaxNumberOfCpus) { + return EFI_INVALID_PARAMETER; + } + + if (gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { + return EFI_NOT_FOUND; + } + + if (gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone || + gSmst->CurrentlyExecutingCpu == ProcessorNumber) { + return EFI_UNSUPPORTED; + } + + // + // Setting of the BSP for next SMI is pending until all SMI handlers are finished + // + gSmmCpuPrivate->Operation[ProcessorNumber] = SmmCpuSwitchBsp; + return EFI_SUCCESS; +} + +/** + Notify that a processor was hot-added. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorId Local APIC ID of the hot-added processor. + @param[out] ProcessorNumber The handle number of the hot-added processor. + + @retval EFI_SUCCESS The hot-addition of the specified processors was successfully notified. + @retval EFI_UNSUPPORTED Hot addition of processor is not supported. + @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. + @retval EFI_ALREADY_STARTED The processor is already online in the system. +**/ +EFI_STATUS +EFIAPI +SmmAddProcessor ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINT64 ProcessorId, + OUT UINTN *ProcessorNumber + ) +{ + UINTN Index; + + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + return EFI_UNSUPPORTED; + } + + // + // Check parameter + // + if (ProcessorNumber == NULL || ProcessorId == INVALID_APIC_ID) { + return EFI_INVALID_PARAMETER; + } + + // + // Check if the processor already exists + // + + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ProcessorId) { + return EFI_ALREADY_STARTED; + } + } + + // + // Check CPU hot plug data. The CPU RAS handler should have created the mapping + // of the APIC ID to SMBASE. + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (mCpuHotPlugData.ApicId[Index] == ProcessorId && + gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == INVALID_APIC_ID) { + gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = ProcessorId; + gSmmCpuPrivate->ProcessorInfo[Index].StatusFlag = 0; + GetProcessorLocationByApicId ( + (UINT32)ProcessorId, + &gSmmCpuPrivate->ProcessorInfo[Index].Location.Package, + &gSmmCpuPrivate->ProcessorInfo[Index].Location.Core, + &gSmmCpuPrivate->ProcessorInfo[Index].Location.Thread + ); + + *ProcessorNumber = Index; + gSmmCpuPrivate->Operation[Index] = SmmCpuAdd; + return EFI_SUCCESS; + } + } + + return EFI_INVALID_PARAMETER; +} + +/** + Notify that a processor was hot-removed. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of the hot-added processor. + + @retval EFI_SUCCESS The hot-removal of the specified processors was successfully notified. + @retval EFI_UNSUPPORTED Hot removal of processor is not supported. + @retval EFI_UNSUPPORTED Hot removal of BSP is not supported. + @retval EFI_UNSUPPORTED Hot removal of a processor with pending hot-plug operation is not supported. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. +**/ +EFI_STATUS +EFIAPI +SmmRemoveProcessor ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ) +{ + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + return EFI_UNSUPPORTED; + } + + // + // Check parameter + // + if (ProcessorNumber >= mMaxNumberOfCpus || + gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { + return EFI_INVALID_PARAMETER; + } + + // + // Can't remove BSP + // + if (ProcessorNumber == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { + return EFI_UNSUPPORTED; + } + + if (gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone) { + return EFI_UNSUPPORTED; + } + + gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId = INVALID_APIC_ID; + mCpuHotPlugData.ApicId[ProcessorNumber] = INVALID_APIC_ID; + + // + // Removal of the processor from the CPU list is pending until all SMI handlers are finished + // + gSmmCpuPrivate->Operation[ProcessorNumber] = SmmCpuRemove; + return EFI_SUCCESS; +} + +/** + This return the handle number for the calling processor. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[out] ProcessorNumber The handle number of currently executing processor. + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + +**/ +EFI_STATUS +EFIAPI +SmmWhoAmI ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + OUT UINTN *ProcessorNumber + ) +{ + UINTN Index; + UINT64 ApicId; + + // + // Check parameter + // + if (ProcessorNumber == NULL) { + return EFI_INVALID_PARAMETER; + } + + ApicId = GetApicId (); + + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ApicId) { + *ProcessorNumber = Index; + return EFI_SUCCESS; + } + } + // + // This should not happen + // + ASSERT (FALSE); + return EFI_NOT_FOUND; +} + +/** + Update the SMM CPU list per the pending operation. + + This function is called after return from SMI handlers. +**/ +VOID +SmmCpuUpdate ( + VOID + ) +{ + UINTN Index; + + // + // Handle pending BSP switch operations + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->Operation[Index] == SmmCpuSwitchBsp) { + gSmmCpuPrivate->Operation[Index] = SmmCpuNone; + mSmmMpSyncData->SwitchBsp = TRUE; + mSmmMpSyncData->CandidateBsp[Index] = TRUE; + } + } + + // + // Handle pending hot-add operations + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->Operation[Index] == SmmCpuAdd) { + gSmmCpuPrivate->Operation[Index] = SmmCpuNone; + mNumberOfCpus++; + } + } + + // + // Handle pending hot-remove operations + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->Operation[Index] == SmmCpuRemove) { + gSmmCpuPrivate->Operation[Index] = SmmCpuNone; + mNumberOfCpus--; + } + } +} + +/** + Register exception handler. + + @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. + @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and + the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL + of the UEFI 2.0 specification. + @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER + that is called when a processor interrupt occurs. + If this parameter is NULL, then the handler will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. + +**/ +EFI_STATUS +EFIAPI +SmmRegisterExceptionHandler ( + IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + return RegisterCpuInterruptHandler (ExceptionType, InterruptHandler); +} + +/** + Initialize SMM CPU Services. + + It installs EFI SMM CPU Services Protocol. + + @param ImageHandle The firmware allocated handle for the EFI image. + + @retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully. +**/ +EFI_STATUS +InitializeSmmCpuServices ( + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + + Status = gSmst->SmmInstallProtocolInterface ( + &Handle, + &gEfiSmmCpuServiceProtocolGuid, + EFI_NATIVE_INTERFACE, + &mSmmCpuService + ); + ASSERT_EFI_ERROR (Status); + return Status; +} + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h new file mode 100644 index 0000000000..9fe3f45b02 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h @@ -0,0 +1,181 @@ +/** @file +Include file for SMM CPU Services protocol implementation. + +Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_SERVICE_H_ +#define _CPU_SERVICE_H_ + +typedef enum { + SmmCpuNone, + SmmCpuAdd, + SmmCpuRemove, + SmmCpuSwitchBsp +} SMM_CPU_OPERATION; + +// +// SMM CPU Service Protocol function prototypes. +// + +/** + Gets processor information on the requested processor at the instant this call is made. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of processor. + @param[out] ProcessorInfoBuffer A pointer to the buffer where information for + the requested processor is deposited. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. + @retval EFI_NOT_FOUND The processor with the handle specified by + ProcessorNumber does not exist in the platform. + +**/ +EFI_STATUS +EFIAPI +SmmGetProcessorInfo ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + This service switches the requested AP to be the BSP since the next SMI. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. + + @retval EFI_SUCCESS BSP will be switched in next SMI. + @retval EFI_UNSUPPORTED Switching the BSP or a processor to be hot-removed is not supported. + @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. +**/ +EFI_STATUS +EFIAPI +SmmSwitchBsp ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ); + +/** + Notify that a processor was hot-added. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorId Local APIC ID of the hot-added processor. + @param[out] ProcessorNumber The handle number of the hot-added processor. + + @retval EFI_SUCCESS The hot-addition of the specified processors was successfully notified. + @retval EFI_UNSUPPORTED Hot addition of processor is not supported. + @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. + @retval EFI_ALREADY_STARTED The processor is already online in the system. +**/ +EFI_STATUS +EFIAPI +SmmAddProcessor ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINT64 ProcessorId, + OUT UINTN *ProcessorNumber + ); + +/** + Notify that a processor was hot-removed. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[in] ProcessorNumber The handle number of the hot-added processor. + + @retval EFI_SUCCESS The hot-removal of the specified processors was successfully notified. + @retval EFI_UNSUPPORTED Hot removal of processor is not supported. + @retval EFI_UNSUPPORTED Hot removal of BSP is not supported. + @retval EFI_UNSUPPORTED Hot removal of a processor with pending hot-plug operation is not supported. + @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. +**/ +EFI_STATUS +EFIAPI +SmmRemoveProcessor ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN UINTN ProcessorNumber + ); + +/** + This return the handle number for the calling processor. + + @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. + @param[out] ProcessorNumber The handle number of currently executing processor. + + @retval EFI_SUCCESS The current processor handle number was returned + in ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. + +**/ +EFI_STATUS +EFIAPI +SmmWhoAmI ( + IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, + OUT UINTN *ProcessorNumber + ); + +/** + Register exception handler. + + @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. + @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and + the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL + of the UEFI 2.0 specification. + @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER + that is called when a processor interrupt occurs. + If this parameter is NULL, then the handler will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. + +**/ +EFI_STATUS +EFIAPI +SmmRegisterExceptionHandler ( + IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ); + +// +// Internal function prototypes +// + +/** + Update the SMM CPU list per the pending operation. + + This function is called after return from SMI handlers. +**/ +VOID +SmmCpuUpdate ( + VOID + ); + +/** + Initialize SMM CPU Services. + + It installs EFI SMM CPU Services Protocol. + + @param ImageHandle The firmware allocated handle for the EFI image. + + @retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully. +**/ +EFI_STATUS +InitializeSmmCpuServices ( + IN EFI_HANDLE Handle + ); + +#endif diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S new file mode 100644 index 0000000000..75aa312a6e --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S @@ -0,0 +1,165 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MpFuncs.S +# +# Abstract: +# +# This is the assembly code for Multi-processor S3 support +# +#------------------------------------------------------------------------------ + +.equ VacantFlag, 0x0 +.equ NotVacantFlag, 0xff + +.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart +.equ StackStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x04 +.equ StackSize, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08 +.equ RendezvousProc, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x0C +.equ GdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10 +.equ IdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16 +.equ BufferStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C + +#------------------------------------------------------------------------------------- +#RendezvousFunnelProc procedure follows. All APs execute their procedure. This +#procedure serializes all the AP processors through an Init sequence. It must be +#noted that APs arrive here very raw...ie: real mode, no stack. +#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +#IS IN MACHINE CODE. +#------------------------------------------------------------------------------------- +#RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +ASM_GLOBAL ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: + +# At this point CS = 0x(vv00) and ip= 0x0. + + .byte 0x8c,0xc8 # mov ax, cs + .byte 0x8e,0xd8 # mov ds, ax + .byte 0x8e,0xc0 # mov es, ax + .byte 0x8e,0xd0 # mov ss, ax + .byte 0x33,0xc0 # xor ax, ax + .byte 0x8e,0xe0 # mov fs, ax + .byte 0x8e,0xe8 # mov gs, ax + +flat32Start: + + .byte 0xBE + .word BufferStart + .byte 0x66,0x8B,0x14 # mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer + + .byte 0xBE + .word GdtrProfile + .byte 0x66 # db 66h + .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si] + + .byte 0xBE + .word IdtrProfile + .byte 0x66 # db 66h + .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si] + + .byte 0x33,0xC0 # xor ax, ax + .byte 0x8E,0xD8 # mov ds, ax + + .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0 + .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0) + .byte 0xF,0x22,0xC0 # mov cr0, eax + +FLAT32_JUMP: + + .byte 0x66,0x67,0xEA # far jump + .long 0x0 # 32-bit offset + .word 0x20 # 16-bit selector + +PMODE_ENTRY: # protected mode entry point + + movw $0x8,%ax + .byte 0x66 + movw %ax,%ds + .byte 0x66 + movw %ax,%es + .byte 0x66 + movw %ax,%fs + .byte 0x66 + movw %ax,%gs + .byte 0x66 + movw %ax,%ss # Flat mode setup. + + movl %edx,%esi + + movl %esi,%edi + addl $LockLocation, %edi + movb $NotVacantFlag, %al +TestLock: + xchgb (%edi), %al + cmpb $NotVacantFlag, %al + jz TestLock + +ProgramStack: + + movl %esi,%edi + addl $StackSize, %edi + movl (%edi),%eax + movl %esi,%edi + addl $StackStart, %edi + addl (%edi),%eax + movl %eax,%esp + movl %eax,(%edi) + +Releaselock: + + movb $VacantFlag, %al + movl %esi,%edi + addl $LockLocation, %edi + xchgb (%edi), %al + + # + # Call assembly function to initialize FPU. + # + lea ASM_PFX(InitializeFloatingPointUnits), %ebx + call *%ebx + # + # Call C Function + # + movl %esi,%edi + addl $RendezvousProc, %edi + movl (%edi),%eax + + testl %eax,%eax + jz GoToSleep + call *%eax # Call C function + +GoToSleep: + cli + hlt + jmp GoToSleep + +RendezvousFunnelProcEnd: +#------------------------------------------------------------------------------------- +# AsmGetAddressMap (&AddressMap); +#------------------------------------------------------------------------------------- +ASM_GLOBAL ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + + pushal + movl %esp,%ebp + + movl 0x24(%ebp), %ebx + movl $RendezvousFunnelProcStart, (%ebx) + movl $(PMODE_ENTRY - RendezvousFunnelProcStart), 0x4(%ebx) + movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx) + movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x0c(%ebx) + + popal + ret diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm new file mode 100644 index 0000000000..70e24a8270 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm @@ -0,0 +1,168 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.asm +; +; Abstract: +; +; This is the assembly code for Multi-processor S3 support +; +;------------------------------------------------------------------------------- + +.686p +.model flat,C +.code + +EXTERN InitializeFloatingPointUnits:PROC + +VacantFlag Equ 00h +NotVacantFlag Equ 0ffh + +LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart +StackStart equ LockLocation + 4h +StackSize equ LockLocation + 8h +RendezvousProc equ LockLocation + 0Ch +GdtrProfile equ LockLocation + 10h +IdtrProfile equ LockLocation + 16h +BufferStart equ LockLocation + 1Ch + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +RendezvousFunnelProc PROC near C PUBLIC +RendezvousFunnelProcStart:: + +; At this point CS = 0x(vv00) and ip= 0x0. + + db 8ch, 0c8h ; mov ax, cs + db 8eh, 0d8h ; mov ds, ax + db 8eh, 0c0h ; mov es, ax + db 8eh, 0d0h ; mov ss, ax + db 33h, 0c0h ; xor ax, ax + db 8eh, 0e0h ; mov fs, ax + db 8eh, 0e8h ; mov gs, ax + +flat32Start:: + + db 0BEh + dw BufferStart ; mov si, BufferStart + db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer + + db 0BEh + dw GdtrProfile ; mov si, GdtrProfile + db 66h ; db 66h + db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si] + + db 0BEh + dw IdtrProfile ; mov si, IdtrProfile + db 66h ; db 66h + db 2Eh, 0Fh, 01h, 1Ch ; lidt fword ptr cs:[si] + + db 33h, 0C0h ; xor ax, ax + db 8Eh, 0D8h ; mov ds, ax + + db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0 + db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0) + db 0Fh, 22h, 0C0h ; mov cr0, eax + +FLAT32_JUMP:: + + db 66h, 67h, 0EAh ; far jump + dd 0h ; 32-bit offset + dw 20h ; 16-bit selector + +PMODE_ENTRY:: ; protected mode entry point + + mov ax, 8h + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax ; Flat mode setup. + + mov esi, edx + + mov edi, esi + add edi, LockLocation + mov al, NotVacantFlag +TestLock:: + xchg byte ptr [edi], al + cmp al, NotVacantFlag + jz TestLock + +ProgramStack:: + + mov edi, esi + add edi, StackSize + mov eax, dword ptr [edi] + mov edi, esi + add edi, StackStart + add eax, dword ptr [edi] + mov esp, eax + mov dword ptr [edi], eax + +Releaselock:: + + mov al, VacantFlag + mov edi, esi + add edi, LockLocation + xchg byte ptr [edi], al + + ; + ; Call assembly function to initialize FPU. + ; + mov ebx, InitializeFloatingPointUnits + call ebx + ; + ; Call C Function + ; + mov edi, esi + add edi, RendezvousProc + mov eax, dword ptr [edi] + + test eax, eax + jz GoToSleep + call eax ; Call C function + +GoToSleep:: + cli + hlt + jmp $-2 + +RendezvousFunnelProc ENDP +RendezvousFunnelProcEnd:: +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +AsmGetAddressMap PROC near C PUBLIC + + pushad + mov ebp,esp + + mov ebx, dword ptr [ebp+24h] + mov dword ptr [ebx], RendezvousFunnelProcStart + mov dword ptr [ebx+4h], PMODE_ENTRY - RendezvousFunnelProcStart + mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart + mov dword ptr [ebx+0ch], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + + popad + ret + +AsmGetAddressMap ENDP + +END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm new file mode 100644 index 0000000000..f7cdcce9a7 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm @@ -0,0 +1,159 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.nasm +; +; Abstract: +; +; This is the assembly code for Multi-processor S3 support +; +;------------------------------------------------------------------------------- + +SECTION .text + +extern ASM_PFX(InitializeFloatingPointUnits) + +%define VacantFlag 0x0 +%define NotVacantFlag 0xff + +%define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart +%define StackStart LockLocation + 0x4 +%define StackSize LockLocation + 0x8 +%define RendezvousProc LockLocation + 0xC +%define GdtrProfile LockLocation + 0x10 +%define IdtrProfile LockLocation + 0x16 +%define BufferStart LockLocation + 0x1C + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +BITS 16 +global ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: + +; At this point CS = 0x(vv00) and ip= 0x0. + + mov ax, cs + mov ds, ax + mov es, ax + mov ss, ax + xor ax, ax + mov fs, ax + mov gs, ax + +flat32Start: + + mov si, BufferStart + mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer + + mov si, GdtrProfile +o32 lgdt [cs:si] + + mov si, IdtrProfile +o32 lidt [cs:si] + + xor ax, ax + mov ds, ax + + mov eax, cr0 ; Get control register 0 + or eax, 0x000000001 ; Set PE bit (bit #0) + mov cr0, eax + +FLAT32_JUMP: + +a32 jmp dword 0x20:0x0 + +BITS 32 +PMODE_ENTRY: ; protected mode entry point + + mov ax, 0x8 +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax ; Flat mode setup. + + mov esi, edx + + mov edi, esi + add edi, LockLocation + mov al, NotVacantFlag +TestLock: + xchg byte [edi], al + cmp al, NotVacantFlag + jz TestLock + +ProgramStack: + + mov edi, esi + add edi, StackSize + mov eax, dword [edi] + mov edi, esi + add edi, StackStart + add eax, dword [edi] + mov esp, eax + mov dword [edi], eax + +Releaselock: + + mov al, VacantFlag + mov edi, esi + add edi, LockLocation + xchg byte [edi], al + + ; + ; Call assembly function to initialize FPU. + ; + mov ebx, ASM_PFX(InitializeFloatingPointUnits) + call ebx + ; + ; Call C Function + ; + mov edi, esi + add edi, RendezvousProc + mov eax, dword [edi] + + test eax, eax + jz GoToSleep + call eax ; Call C function + +GoToSleep: + cli + hlt + jmp $-2 + +RendezvousFunnelProcEnd: +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +global ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + + pushad + mov ebp,esp + + mov ebx, dword [ebp+0x24] + mov dword [ebx], RendezvousFunnelProcStart + mov dword [ebx+0x4], PMODE_ENTRY - RendezvousFunnelProcStart + mov dword [ebx+0x8], FLAT32_JUMP - RendezvousFunnelProcStart + mov dword [ebx+0xc], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + + popad + ret + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c new file mode 100644 index 0000000000..32ce5958c5 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c @@ -0,0 +1,232 @@ +/** @file +Page table manipulation functions for IA-32 processors + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +/** + Create PageTable for SMM use. + + @return PageTable Address + +**/ +UINT32 +SmmInitPageTable ( + VOID + ) +{ + UINTN PageFaultHandlerHookAddress; + IA32_IDT_GATE_DESCRIPTOR *IdtEntry; + EFI_STATUS Status; + + // + // Initialize spin lock + // + InitializeSpinLock (mPFLock); + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + // + // Set own Page Fault entry instead of the default one, because SMM Profile + // feature depends on IRET instruction to do Single Step + // + PageFaultHandlerHookAddress = (UINTN)PageFaultIdtHandlerSmmProfile; + IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) gcSmiIdtr.Base; + IdtEntry += EXCEPT_IA32_PAGE_FAULT; + IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress; + IdtEntry->Bits.Reserved_0 = 0; + IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; + IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16); + } else { + // + // Register SMM Page Fault Handler + // + Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT, SmiPFHandler); + ASSERT_EFI_ERROR (Status); + } + + // + // Additional SMM IDT initialization for SMM stack guard + // + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + InitializeIDTSmmStackGuard (); + } + return Gen4GPageTable (TRUE); +} + +/** + Page Fault handler for SMM use. + +**/ +VOID +SmiDefaultPFHandler ( + VOID + ) +{ + CpuDeadLoop (); +} + +/** + ThePage Fault handler wrapper for SMM use. + + @param InterruptType Defines the type of interrupt or exception that + occurred on the processor.This parameter is processor architecture specific. + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. +**/ +VOID +EFIAPI +SmiPFHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + UINTN PFAddress; + UINTN GuardPageAddress; + UINTN CpuIndex; + + ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT); + + AcquireSpinLock (mPFLock); + + PFAddress = AsmReadCr2 (); + + // + // If a page fault occurs in SMRAM range, it might be in a SMM stack guard page, + // or SMM page protection violation. + // + if ((PFAddress >= mCpuHotPlugData.SmrrBase) && + (PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))) { + DumpCpuContext (InterruptType, SystemContext); + CpuIndex = GetCpuIndex (); + GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize); + if ((FeaturePcdGet (PcdCpuSmmStackGuard)) && + (PFAddress >= GuardPageAddress) && + (PFAddress < (GuardPageAddress + EFI_PAGE_SIZE))) { + DEBUG ((DEBUG_ERROR, "SMM stack overflow!\n")); + } else { + if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) { + DEBUG ((DEBUG_ERROR, "SMM exception at execution (0x%x)\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp); + ); + } else { + DEBUG ((DEBUG_ERROR, "SMM exception at access (0x%x)\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); + ); + } + } + CpuDeadLoop (); + } + + // + // If a page fault occurs in SMM range + // + if ((PFAddress < mCpuHotPlugData.SmrrBase) || + (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { + DumpCpuContext (InterruptType, SystemContext); + if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) { + DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%x) out of SMM range after SMM is locked!\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp); + ); + CpuDeadLoop (); + } + if (IsSmmCommBufferForbiddenAddress (PFAddress)) { + DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%x)!\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); + ); + CpuDeadLoop (); + } + } + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + SmmProfilePFHandler ( + SystemContext.SystemContextIa32->Eip, + SystemContext.SystemContextIa32->ExceptionData + ); + } else { + DumpCpuContext (InterruptType, SystemContext); + SmiDefaultPFHandler (); + } + + ReleaseSpinLock (mPFLock); +} + +/** + This function sets memory attribute for page table. +**/ +VOID +SetPageTableAttributes ( + VOID + ) +{ + UINTN Index2; + UINTN Index3; + UINT64 *L1PageTable; + UINT64 *L2PageTable; + UINT64 *L3PageTable; + BOOLEAN IsSplitted; + BOOLEAN PageTableSplitted; + + DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n")); + + // + // Disable write protection, because we need mark page table to be write protected. + // We need *write* page table memory, to mark itself to be *read only*. + // + AsmWriteCr0 (AsmReadCr0() & ~CR0_WP); + + do { + DEBUG ((DEBUG_INFO, "Start...\n")); + PageTableSplitted = FALSE; + + L3PageTable = (UINT64 *)GetPageTableBase (); + + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L3PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + + for (Index3 = 0; Index3 < 4; Index3++) { + L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L2PageTable == NULL) { + continue; + } + + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + + for (Index2 = 0; Index2 < SIZE_4KB/sizeof(UINT64); Index2++) { + if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { + // 2M + continue; + } + L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L1PageTable == NULL) { + continue; + } + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + } + } + } while (PageTableSplitted); + + // + // Enable write protection, after page table updated. + // + AsmWriteCr0 (AsmReadCr0() | CR0_WP); + + return ; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c new file mode 100644 index 0000000000..02a866b430 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c @@ -0,0 +1,48 @@ +/** @file +Semaphore mechanism to indicate to the BSP that an AP has exited SMM +after SMBASE relocation. + +Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +UINTN mSmmRelocationOriginalAddress; +volatile BOOLEAN *mRebasedFlag; + +/** + Hook return address of SMM Save State so that semaphore code + can be executed immediately after AP exits SMM to indicate to + the BSP that an AP has exited SMM after SMBASE relocation. + + @param[in] CpuIndex The processor index. + @param[in] RebasedFlag A pointer to a flag that is set to TRUE + immediately after AP exits SMM. + +**/ +VOID +SemaphoreHook ( + IN UINTN CpuIndex, + IN volatile BOOLEAN *RebasedFlag + ) +{ + SMRAM_SAVE_STATE_MAP *CpuState; + + mRebasedFlag = RebasedFlag; + + CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); + mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm ( + CpuIndex, + CpuState, + (UINT64)(UINTN)&SmmRelocationSemaphoreComplete, + (UINT64)(UINTN)&SmmRelocationSemaphoreComplete + ); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S new file mode 100644 index 0000000000..62f1697efa --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S @@ -0,0 +1,214 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiEntry.S +# +# Abstract: +# +# Code template of the SMI handler for a particular processor +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcSmiHandlerTemplate) +ASM_GLOBAL ASM_PFX(gcSmiHandlerSize) +ASM_GLOBAL ASM_PFX(gSmiCr3) +ASM_GLOBAL ASM_PFX(gSmiStack) +ASM_GLOBAL ASM_PFX(gSmbase) +ASM_GLOBAL ASM_PFX(mXdSupported) +ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) +ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr) + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0xc0000080 +.equ MSR_EFER_XD, 0x800 + +# +# Constants relating to PROCESSOR_SMM_DESCRIPTOR +# +.equ DSC_OFFSET, 0xfb00 +.equ DSC_GDTPTR, 0x30 +.equ DSC_GDTSIZ, 0x38 +.equ DSC_CS, 14 +.equ DSC_DS, 16 +.equ DSC_SS, 18 +.equ DSC_OTHERSEG, 20 + +.equ PROTECT_MODE_CS, 0x08 +.equ PROTECT_MODE_DS, 0x20 +.equ TSS_SEGMENT, 0x40 + + .text + +ASM_PFX(gcSmiHandlerTemplate): + +_SmiEntryPoint: + .byte 0xbb # mov bx, imm16 + .word _GdtDesc - _SmiEntryPoint + 0x8000 + .byte 0x2e,0xa1 # mov ax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTSIZ + decl %eax + movl %eax, %cs:(%edi) # mov cs:[bx], ax + .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTPTR + movw %ax, %cs:2(%edi) + movw %ax, %bp # ebp = GDT base + .byte 0x66 + lgdt %cs:(%edi) +# Patch ProtectedMode Segment + .byte 0xb8 # mov ax, imm16 + .word PROTECT_MODE_CS # set AX for segment directly + movl %eax, %cs:-2(%edi) # mov cs:[bx - 2], ax +# Patch ProtectedMode entry + .byte 0x66, 0xbf # mov edi, SMBASE +ASM_PFX(gSmbase): .space 4 + .byte 0x67 + lea ((Start32bit - _SmiEntryPoint) + 0x8000)(%edi), %ax + movw %ax, %cs:-6(%edi) + movl %cr0, %ebx + .byte 0x66 + andl $0x9ffafff3, %ebx + .byte 0x66 + orl $0x23, %ebx + movl %ebx, %cr0 + .byte 0x66,0xea + .space 4 + .space 2 +_GdtDesc: .space 4 + .space 2 + +Start32bit: + movw $PROTECT_MODE_DS, %ax + movl %eax,%ds + movl %eax,%es + movl %eax,%fs + movl %eax,%gs + movl %eax,%ss + .byte 0xbc # mov esp, imm32 +ASM_PFX(gSmiStack): .space 4 + movl $ASM_PFX(gSmiHandlerIdtr), %eax + lidt (%eax) + jmp ProtFlatMode + +ProtFlatMode: + .byte 0xb8 # mov eax, imm32 +ASM_PFX(gSmiCr3): .space 4 + movl %eax, %cr3 +# +# Need to test for CR4 specific bit support +# + movl $1, %eax + cpuid # use CPUID to determine if specific CR4 bits are supported + xorl %eax, %eax # Clear EAX + testl $BIT2, %edx # Check for DE capabilities + jz L8 + orl $BIT3, %eax +L8: + testl $BIT6, %edx # Check for PAE capabilities + jz L9 + orl $BIT5, %eax +L9: + testl $BIT7, %edx # Check for MCE capabilities + jz L10 + orl $BIT6, %eax +L10: + testl $BIT24, %edx # Check for FXSR capabilities + jz L11 + orl $BIT9, %eax +L11: + testl $BIT25, %edx # Check for SSE capabilities + jz L12 + orl $BIT10, %eax +L12: # as cr4.PGE is not set here, refresh cr3 + movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. + + cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) + jz L5 +# Load TSS + movb $0x89, (TSS_SEGMENT + 5)(%ebp) # clear busy flag + movl $TSS_SEGMENT, %eax + ltrw %ax +L5: + +# enable NXE if supported + .byte 0xb0 # mov al, imm8 +ASM_PFX(mXdSupported): .byte 1 + cmpb $0, %al + jz SkipNxe +# +# Check XD disable bit +# + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + pushl %edx # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr +SkipNxe: + subl $4, %esp +NxeDone: + + movl %cr0, %ebx + orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE + movl %ebx, %cr0 + leal DSC_OFFSET(%edi),%ebx + movw DSC_DS(%ebx),%ax + movl %eax, %ds + movw DSC_OTHERSEG(%ebx),%ax + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + movw DSC_SS(%ebx),%ax + movl %eax, %ss + +# jmp _SmiHandler # instruction is not needed + +_SmiHandler: + movl 4(%esp), %ebx + + pushl %ebx + movl $ASM_PFX(CpuSmmDebugEntry), %eax + call *%eax + addl $4, %esp + + pushl %ebx + movl $ASM_PFX(SmiRendezvous), %eax + call *%eax + addl $4, %esp + + pushl %ebx + movl $ASM_PFX(CpuSmmDebugExit), %eax + call *%eax + addl $4, %esp + + movl $ASM_PFX(mXdSupported), %eax + movb (%eax), %al + cmpb $0, %al + jz L16 + popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr + +L16: + rsm + +ASM_PFX(gcSmiHandlerSize): .word . - _SmiEntryPoint diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm new file mode 100644 index 0000000000..8296f36d26 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm @@ -0,0 +1,223 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.asm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + + .686p + .model flat,C + .xmm + +MSR_IA32_MISC_ENABLE EQU 1A0h +MSR_EFER EQU 0c0000080h +MSR_EFER_XD EQU 0800h + +; +; Constants relating to PROCESSOR_SMM_DESCRIPTOR +; +DSC_OFFSET EQU 0fb00h +DSC_GDTPTR EQU 30h +DSC_GDTSIZ EQU 38h +DSC_CS EQU 14 +DSC_DS EQU 16 +DSC_SS EQU 18 +DSC_OTHERSEG EQU 20 + +PROTECT_MODE_CS EQU 08h +PROTECT_MODE_DS EQU 20h +TSS_SEGMENT EQU 40h + +SmiRendezvous PROTO C +CpuSmmDebugEntry PROTO C +CpuSmmDebugExit PROTO C + +EXTERNDEF gcSmiHandlerTemplate:BYTE +EXTERNDEF gcSmiHandlerSize:WORD +EXTERNDEF gSmiCr3:DWORD +EXTERNDEF gSmiStack:DWORD +EXTERNDEF gSmbase:DWORD +EXTERNDEF mXdSupported:BYTE +EXTERNDEF FeaturePcdGet (PcdCpuSmmStackGuard):BYTE +EXTERNDEF gSmiHandlerIdtr:FWORD + + .code + +gcSmiHandlerTemplate LABEL BYTE + +_SmiEntryPoint: + DB 0bbh ; mov bx, imm16 + DW offset _GdtDesc - _SmiEntryPoint + 8000h + DB 2eh, 0a1h ; mov ax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTSIZ + dec eax + mov cs:[edi], eax ; mov cs:[bx], ax + DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTPTR + mov cs:[edi + 2], ax ; mov cs:[bx + 2], eax + mov bp, ax ; ebp = GDT base + DB 66h + lgdt fword ptr cs:[edi] ; lgdt fword ptr cs:[bx] +; Patch ProtectedMode Segment + DB 0b8h ; mov ax, imm16 + DW PROTECT_MODE_CS ; set AX for segment directly + mov cs:[edi - 2], eax ; mov cs:[bx - 2], ax +; Patch ProtectedMode entry + DB 66h, 0bfh ; mov edi, SMBASE +gSmbase DD ? + DB 67h + lea ax, [edi + (@32bit - _SmiEntryPoint) + 8000h] + mov cs:[edi - 6], ax ; mov cs:[bx - 6], eax + mov ebx, cr0 + DB 66h + and ebx, 9ffafff3h + DB 66h + or ebx, 23h + mov cr0, ebx + DB 66h, 0eah + DD ? + DW ? +_GdtDesc FWORD ? + +@32bit: + mov ax, PROTECT_MODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + DB 0bch ; mov esp, imm32 +gSmiStack DD ? + mov eax, offset gSmiHandlerIdtr + lidt fword ptr [eax] + jmp ProtFlatMode + +ProtFlatMode: + DB 0b8h ; mov eax, imm32 +gSmiCr3 DD ? + mov cr3, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + xor eax, eax ; Clear EAX + test edx, BIT2 ; Check for DE capabilities + jz @f + or eax, BIT3 +@@: + test edx, BIT6 ; Check for PAE capabilities + jz @f + or eax, BIT5 +@@: + test edx, BIT7 ; Check for MCE capabilities + jz @f + or eax, BIT6 +@@: + test edx, BIT24 ; Check for FXSR capabilities + jz @f + or eax, BIT9 +@@: + test edx, BIT25 ; Check for SSE capabilities + jz @f + or eax, BIT10 +@@: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + + cmp FeaturePcdGet (PcdCpuSmmStackGuard), 0 + jz @F +; Load TSS + mov byte ptr [ebp + TSS_SEGMENT + 5], 89h ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax +@@: + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +mXdSupported DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + push edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 4 +@XdDone: + + mov ebx, cr0 + or ebx, 080010023h ; enable paging + WP + NE + MP + PE + mov cr0, ebx + lea ebx, [edi + DSC_OFFSET] + mov ax, [ebx + DSC_DS] + mov ds, eax + mov ax, [ebx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [ebx + DSC_SS] + mov ss, eax + +; jmp _SmiHandler ; instruction is not needed + +_SmiHandler PROC + mov ebx, [esp + 4] ; CPU Index + push ebx + mov eax, CpuSmmDebugEntry + call eax + add esp, 4 + + push ebx + mov eax, SmiRendezvous + call eax + add esp, 4 + + push ebx + mov eax, CpuSmmDebugExit + call eax + add esp, 4 + + mov eax, offset mXdSupported + mov al, [eax] + cmp al, 0 + jz @f + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +@@: + rsm +_SmiHandler ENDP + +gcSmiHandlerSize DW $ - _SmiEntryPoint + + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm new file mode 100644 index 0000000000..4d2383ff97 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm @@ -0,0 +1,209 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.nasm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +; +; Constants relating to PROCESSOR_SMM_DESCRIPTOR +; +%define DSC_OFFSET 0xfb00 +%define DSC_GDTPTR 0x30 +%define DSC_GDTSIZ 0x38 +%define DSC_CS 14 +%define DSC_DS 16 +%define DSC_SS 18 +%define DSC_OTHERSEG 20 + +%define PROTECT_MODE_CS 0x8 +%define PROTECT_MODE_DS 0x20 +%define TSS_SEGMENT 0x40 + +extern ASM_PFX(SmiRendezvous) +extern ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) +extern ASM_PFX(CpuSmmDebugEntry) +extern ASM_PFX(CpuSmmDebugExit) + +global ASM_PFX(gcSmiHandlerTemplate) +global ASM_PFX(gcSmiHandlerSize) +global ASM_PFX(gSmiCr3) +global ASM_PFX(gSmiStack) +global ASM_PFX(gSmbase) +global ASM_PFX(mXdSupported) +extern ASM_PFX(gSmiHandlerIdtr) + + SECTION .text + +BITS 16 +ASM_PFX(gcSmiHandlerTemplate): +_SmiEntryPoint: + mov bx, _GdtDesc - _SmiEntryPoint + 0x8000 + mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] + dec ax + mov [cs:bx], ax + mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] + mov [cs:bx + 2], eax + mov ebp, eax ; ebp = GDT base +o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] + mov ax, PROTECT_MODE_CS + mov [cs:bx-0x2],ax + DB 0x66, 0xbf ; mov edi, SMBASE +ASM_PFX(gSmbase): DD 0 + lea eax, [edi + (@32bit - _SmiEntryPoint) + 0x8000] + mov [cs:bx-0x6],eax + mov ebx, cr0 + and ebx, 0x9ffafff3 + or ebx, 0x23 + mov cr0, ebx + jmp dword 0x0:0x0 +_GdtDesc: + DW 0 + DD 0 + +BITS 32 +@32bit: + mov ax, PROTECT_MODE_DS +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax + DB 0xbc ; mov esp, imm32 +ASM_PFX(gSmiStack): DD 0 + mov eax, ASM_PFX(gSmiHandlerIdtr) + lidt [eax] + jmp ProtFlatMode + +ProtFlatMode: + DB 0xb8 ; mov eax, imm32 +ASM_PFX(gSmiCr3): DD 0 + mov cr3, eax +; +; Need to test for CR4 specific bit support +; + mov eax, 1 + cpuid ; use CPUID to determine if specific CR4 bits are supported + xor eax, eax ; Clear EAX + test edx, BIT2 ; Check for DE capabilities + jz .0 + or eax, BIT3 +.0: + test edx, BIT6 ; Check for PAE capabilities + jz .1 + or eax, BIT5 +.1: + test edx, BIT7 ; Check for MCE capabilities + jz .2 + or eax, BIT6 +.2: + test edx, BIT24 ; Check for FXSR capabilities + jz .3 + or eax, BIT9 +.3: + test edx, BIT25 ; Check for SSE capabilities + jz .4 + or eax, BIT10 +.4: ; as cr4.PGE is not set here, refresh cr3 + mov cr4, eax ; in PreModifyMtrrs() to flush TLB. + + cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))], 0 + jz .6 +; Load TSS + mov byte [ebp + TSS_SEGMENT + 5], 0x89 ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax +.6: + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +ASM_PFX(mXdSupported): DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + push edx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .5 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.5: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 4 +@XdDone: + + mov ebx, cr0 + or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, ebx + lea ebx, [edi + DSC_OFFSET] + mov ax, [ebx + DSC_DS] + mov ds, eax + mov ax, [ebx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [ebx + DSC_SS] + mov ss, eax + +; jmp _SmiHandler ; instruction is not needed + +global ASM_PFX(SmiHandler) +ASM_PFX(SmiHandler): + mov ebx, [esp + 4] ; CPU Index + push ebx + mov eax, ASM_PFX(CpuSmmDebugEntry) + call eax + add esp, 4 + + push ebx + mov eax, ASM_PFX(SmiRendezvous) + call eax + add esp, 4 + + push ebx + mov eax, ASM_PFX(CpuSmmDebugExit) + call eax + add esp, 4 + + mov eax, ASM_PFX(mXdSupported) + mov al, [eax] + cmp al, 0 + jz .7 + pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .7 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.7: + rsm + +ASM_PFX(gcSmiHandlerSize): DW $ - _SmiEntryPoint + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S new file mode 100644 index 0000000000..4600c7c36e --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S @@ -0,0 +1,696 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiException.S +# +# Abstract: +# +# Exception handlers used in SM mode +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(SmiPFHandler) +ASM_GLOBAL ASM_PFX(PageFaultStubFunction) +ASM_GLOBAL ASM_PFX(gcSmiIdtr) +ASM_GLOBAL ASM_PFX(gcSmiGdtr) +ASM_GLOBAL ASM_PFX(gTaskGateDescriptor) +ASM_GLOBAL ASM_PFX(gcPsd) +ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) + + .data + +NullSeg: .quad 0 # reserved by architecture +CodeSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +ProtModeCodeSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +ProtModeSsSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x93 + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +DataSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x93 + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +CodeSeg16: + .word -1 + .word 0 + .byte 0 + .byte 0x9b + .byte 0x8f + .byte 0 +DataSeg16: + .word -1 + .word 0 + .byte 0 + .byte 0x93 + .byte 0x8f + .byte 0 +CodeSeg64: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xaf # LimitHigh + .byte 0 # BaseHigh +.equ GDT_SIZE, .- NullSeg + +TssSeg: + .word TSS_DESC_SIZE -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x89 + .byte 0x00 # LimitHigh + .byte 0 # BaseHigh +ExceptionTssSeg: + .word TSS_DESC_SIZE - 1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x89 + .byte 0x00 # LimitHigh + .byte 0 # BaseHigh + +.equ CODE_SEL, CodeSeg32 - NullSeg +.equ DATA_SEL, DataSeg32 - NullSeg +.equ TSS_SEL, TssSeg - NullSeg +.equ EXCEPTION_TSS_SEL, ExceptionTssSeg - NullSeg + +# IA32 TSS fields +.equ TSS_ESP0, 4 +.equ TSS_SS0, 8 +.equ TSS_ESP1, 12 +.equ TSS_SS1, 16 +.equ TSS_ESP2, 20 +.equ TSS_SS2, 24 +.equ TSS_CR3, 28 +.equ TSS_EIP, 32 +.equ TSS_EFLAGS, 36 +.equ TSS_EAX, 40 +.equ TSS_ECX, 44 +.equ TSS_EDX, 48 +.equ TSS_EBX, 52 +.equ TSS_ESP, 56 +.equ TSS_EBP, 60 +.equ TSS_ESI, 64 +.equ TSS_EDI, 68 +.equ TSS_ES, 72 +.equ TSS_CS, 76 +.equ TSS_SS, 80 +.equ TSS_DS, 84 +.equ TSS_FS, 88 +.equ TSS_GS, 92 +.equ TSS_LDT, 96 + +# Create 2 TSS segments just after GDT +TssDescriptor: + .word 0 # PreviousTaskLink + .word 0 # Reserved + .long 0 # ESP0 + .word 0 # SS0 + .word 0 # Reserved + .long 0 # ESP1 + .word 0 # SS1 + .word 0 # Reserved + .long 0 # ESP2 + .word 0 # SS2 + .word 0 # Reserved + .long 0 # CR3 + .long 0 # EIP + .long 0 # EFLAGS + .long 0 # EAX + .long 0 # ECX + .long 0 # EDX + .long 0 # EBX + .long 0 # ESP + .long 0 # EBP + .long 0 # ESI + .long 0 # EDI + .word 0 # ES + .word 0 # Reserved + .word 0 # CS + .word 0 # Reserved + .word 0 # SS + .word 0 # Reserved + .word 0 # DS + .word 0 # Reserved + .word 0 # FS + .word 0 # Reserved + .word 0 # GS + .word 0 # Reserved + .word 0 # LDT Selector + .word 0 # Reserved + .word 0 # T + .word 0 # I/O Map Base +.equ TSS_DESC_SIZE, . - TssDescriptor + +ExceptionTssDescriptor: + .word 0 # PreviousTaskLink + .word 0 # Reserved + .long 0 # ESP0 + .word 0 # SS0 + .word 0 # Reserved + .long 0 # ESP1 + .word 0 # SS1 + .word 0 # Reserved + .long 0 # ESP2 + .word 0 # SS2 + .word 0 # Reserved + .long 0 # CR3 + .long PFHandlerEntry # EIP + .long 00000002 # EFLAGS + .long 0 # EAX + .long 0 # ECX + .long 0 # EDX + .long 0 # EBX + .long 0 # ESP + .long 0 # EBP + .long 0 # ESI + .long 0 # EDI + .word DATA_SEL # ES + .word 0 # Reserved + .word CODE_SEL # CS + .word 0 # Reserved + .word DATA_SEL # SS + .word 0 # Reserved + .word DATA_SEL # DS + .word 0 # Reserved + .word DATA_SEL # FS + .word 0 # Reserved + .word DATA_SEL # GS + .word 0 # Reserved + .word 0 # LDT Selector + .word 0 # Reserved + .word 0 # T + .word 0 # I/O Map Base + +ASM_PFX(gcPsd): + .ascii "PSDSIG " + .word PSD_SIZE + .word 2 + .word 1 << 2 + .word CODE_SEL + .word DATA_SEL + .word DATA_SEL + .word DATA_SEL + .word 0 + .long 0 + .long 0 + .long 0 + .long 0 + .quad 0 + .long NullSeg + .long 0 + .long GDT_SIZE + .long 0 + .space 24, 0 + .long 0 + .long 0 +.equ PSD_SIZE, . - ASM_PFX(gcPsd) + +ASM_PFX(gcSmiGdtr): .word GDT_SIZE - 1 + .long NullSeg + +ASM_PFX(gcSmiIdtr): .word 0 + .long 0 + +ASM_PFX(gTaskGateDescriptor): + .word 0 # Reserved + .word EXCEPTION_TSS_SEL # TSS Segment selector + .byte 0 # Reserved + .byte 0x85 # Task Gate, present, DPL = 0 + .word 0 # Reserved + + .text + +#------------------------------------------------------------------------------ +# PageFaultIdtHandlerSmmProfile is the entry point for all exceptions +# +# Stack: +#+---------------------+ +#+ EFlags + +#+---------------------+ +#+ CS + +#+---------------------+ +#+ EIP + +#+---------------------+ +#+ Error Code + +#+---------------------+ +#+ Vector Number + +#+---------------------+ +#+ EBP + +#+---------------------+ <-- EBP +# +# RSP set to odd multiple of 8 means ErrCode PRESENT +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(PageFaultIdtHandlerSmmProfile) +ASM_PFX(PageFaultIdtHandlerSmmProfile): + pushl $0x0e # Page Fault + pushl %ebp + movl %esp, %ebp + + + # + # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + # is 16-byte aligned + # + andl $0xfffffff0, %esp + subl $12, %esp + +## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pushl %eax + pushl %ecx + pushl %edx + pushl %ebx + leal (6*4)(%ebp), %ecx + pushl %ecx # ESP + pushl (%ebp) # EBP + pushl %esi + pushl %edi + +## UINT32 Gs, Fs, Es, Ds, Cs, Ss; + movl %ss, %eax + pushl %eax + movzwl (4*4)(%ebp), %eax + pushl %eax + movl %ds, %eax + pushl %eax + movl %es, %eax + pushl %eax + movl %fs, %eax + pushl %eax + movl %gs, %eax + pushl %eax + +## UINT32 Eip; + movl (3*4)(%ebp), %eax + pushl %eax + +## UINT32 Gdtr[2], Idtr[2]; + subl $8, %esp + sidt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0xffff, %eax + movl %eax, 4(%esp) + + subl $8, %esp + sgdt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0xffff, %eax + movl %eax, 4(%esp) + +## UINT32 Ldtr, Tr; + xorl %eax, %eax + strw %ax + pushl %eax + sldtw %ax + pushl %eax + +## UINT32 EFlags; + movl (5*4)(%ebp), %eax + pushl %eax + +## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + movl %cr4, %eax + orl $0x208, %eax + movl %eax, %cr4 + pushl %eax + movl %cr3, %eax + pushl %eax + movl %cr2, %eax + pushl %eax + xorl %eax, %eax + pushl %eax + movl %cr0, %eax + pushl %eax + +## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + movl %dr7, %eax + pushl %eax + movl %dr6, %eax + pushl %eax + movl %dr3, %eax + pushl %eax + movl %dr2, %eax + pushl %eax + movl %dr1, %eax + pushl %eax + movl %dr0, %eax + pushl %eax + +## FX_SAVE_STATE_IA32 FxSaveState; + subl $512, %esp + movl %esp, %edi + .byte 0x0f, 0xae, 0x07 #fxsave [edi] + +# UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +## UINT32 ExceptionData; + pushl (2*4)(%ebp) + +## call into exception handler + +## Prepare parameter and call + movl %esp, %edx + pushl %edx + movl (1*4)(%ebp), %edx + pushl %edx + + # + # Call External Exception Handler + # + movl $ASM_PFX(SmiPFHandler), %eax + call *%eax + addl $8, %esp + jmp L4 + +L4: +## UINT32 ExceptionData; + addl $4, %esp + +## FX_SAVE_STATE_IA32 FxSaveState; + movl %esp, %esi + .byte 0xf, 0xae, 0xe # fxrstor [esi] + addl $512, %esp + +## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +## Skip restoration of DRx registers to support debuggers +## that set breakpoints in interrupt/exception context + addl $4*6, %esp + +## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + popl %eax + movl %eax, %cr0 + addl $4, %esp # not for Cr1 + popl %eax + movl %eax, %cr2 + popl %eax + movl %eax, %cr3 + popl %eax + movl %eax, %cr4 + +## UINT32 EFlags; + popl (5*4)(%ebp) + +## UINT32 Ldtr, Tr; +## UINT32 Gdtr[2], Idtr[2]; +## Best not let anyone mess with these particular registers... + addl $24, %esp + +## UINT32 Eip; + popl (3*4)(%ebp) + +## UINT32 Gs, Fs, Es, Ds, Cs, Ss; +## NOTE - modified segment registers could hang the debugger... We +## could attempt to insulate ourselves against this possibility, +## but that poses risks as well. +## + popl %gs + popl %fs + popl %es + popl %ds + popl (4*4)(%ebp) + popl %ss + +## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + popl %edi + popl %esi + addl $4, %esp # not for ebp + addl $4, %esp # not for esp + popl %ebx + popl %edx + popl %ecx + popl %eax + + movl %ebp, %esp + popl %ebp + +# Enable TF bit after page fault handler runs + btsl $8, 16(%esp) # EFLAGS + + addl $8, %esp # skip INT# & ErrCode +Return: + iret +# +# Page Fault Exception Handler entry when SMM Stack Guard is enabled +# Executiot starts here after a task switch +# +PFHandlerEntry: +# +# Get this processor's TSS +# + subl $8, %esp + sgdt 2(%esp) + movl 4(%esp), %eax # GDT base + addl $8, %esp + movl (TSS_SEL+2)(%eax), %ecx + shll $8, %ecx + movb (TSS_SEL+7)(%eax), %cl + rorl $8, %ecx # ecx = TSS base + + movl %esp, %ebp + + # + # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + # is 16-byte aligned + # + andl $0xfffffff0, %esp + subl $12, %esp + +## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pushl TSS_EAX(%ecx) + pushl TSS_ECX(%ecx) + pushl TSS_EDX(%ecx) + pushl TSS_EBX(%ecx) + pushl TSS_ESP(%ecx) + pushl TSS_EBP(%ecx) + pushl TSS_ESI(%ecx) + pushl TSS_EDI(%ecx) + +## UINT32 Gs, Fs, Es, Ds, Cs, Ss; + movzwl TSS_SS(%ecx), %eax + pushl %eax + movzwl TSS_CS(%ecx), %eax + pushl %eax + movzwl TSS_DS(%ecx), %eax + pushl %eax + movzwl TSS_ES(%ecx), %eax + pushl %eax + movzwl TSS_FS(%ecx), %eax + pushl %eax + movzwl TSS_GS(%ecx), %eax + pushl %eax + +## UINT32 Eip; + pushl TSS_EIP(%ecx) + +## UINT32 Gdtr[2], Idtr[2]; + subl $8, %esp + sidt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0xFFFF, %eax + movl %eax, 4(%esp) + + subl $8, %esp + sgdt (%esp) + movl 2(%esp), %eax + xchgl (%esp), %eax + andl $0xFFFF, %eax + movl %eax, 4(%esp) + +## UINT32 Ldtr, Tr; + movl $TSS_SEL, %eax + pushl %eax + movzwl TSS_LDT(%ecx), %eax + pushl %eax + +## UINT32 EFlags; + pushl TSS_EFLAGS(%ecx) + +## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + movl %cr4, %eax + orl $0x208, %eax + movl %eax, %cr4 + pushl %eax + movl %cr3, %eax + pushl %eax + movl %cr2, %eax + pushl %eax + xorl %eax, %eax + pushl %eax + movl %cr0, %eax + pushl %eax + +## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + movl %dr7, %eax + pushl %eax + movl %dr6, %eax + pushl %eax + movl %dr3, %eax + pushl %eax + movl %dr2, %eax + pushl %eax + movl %dr1, %eax + pushl %eax + movl %dr0, %eax + pushl %eax + +## FX_SAVE_STATE_IA32 FxSaveState; +## Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) +## when executing fxsave/fxrstor instruction + clts + subl $512, %esp + movl %esp, %edi + .byte 0x0f, 0xae, 0x07 #fxsave [edi] + +# UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +## UINT32 ExceptionData; + pushl (%ebp) + +## call into exception handler + movl %ecx, %ebx + movl $ASM_PFX(SmiPFHandler), %eax + +## Prepare parameter and call + movl %esp, %edx + pushl %edx + movl $14, %edx + pushl %edx + + # + # Call External Exception Handler + # + call *%eax + addl $8, %esp + + movl %ebx, %ecx +## UINT32 ExceptionData; + addl $4, %esp + +## FX_SAVE_STATE_IA32 FxSaveState; + movl %esp, %esi + .byte 0xf, 0xae, 0xe # fxrstor [esi] + addl $512, %esp + +## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +## Skip restoration of DRx registers to support debuggers +## that set breakpoints in interrupt/exception context + addl $4*6, %esp + +## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + popl %eax + movl %eax, %cr0 + addl $4, %esp # not for Cr1 + popl %eax + movl %eax, %cr2 + popl %eax + movl %eax, TSS_CR3(%ecx) + popl %eax + movl %eax, %cr4 + +## UINT32 EFlags; + popl TSS_EFLAGS(%ecx) + +## UINT32 Ldtr, Tr; +## UINT32 Gdtr[2], Idtr[2]; +## Best not let anyone mess with these particular registers... + addl $24, %esp + +## UINT32 Eip; + popl TSS_EIP(%ecx) + +## UINT32 Gs, Fs, Es, Ds, Cs, Ss; +## NOTE - modified segment registers could hang the debugger... We +## could attempt to insulate ourselves against this possibility, +## but that poses risks as well. +## + popl %eax + movw %ax, TSS_GS(%ecx) + popl %eax + movw %ax, TSS_FS(%ecx) + popl %eax + movw %ax, TSS_ES(%ecx) + popl %eax + movw %ax, TSS_DS(%ecx) + popl %eax + movw %ax, TSS_CS(%ecx) + popl %eax + movw %ax, TSS_SS(%ecx) + +## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + popl TSS_EDI(%ecx) + popl TSS_ESI(%ecx) + addl $4, %esp # not for ebp + addl $4, %esp # not for esp + popl TSS_EBX(%ecx) + popl TSS_EDX(%ecx) + popl TSS_ECX(%ecx) + popl TSS_EAX(%ecx) + + movl %ebp, %esp + +# Set single step DB# if SMM profile is enabled and page fault exception happens + cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) + jz Done2 +# Create return context for iret in stub function + movl TSS_ESP(%ecx), %eax # Get old stack pointer + movl TSS_EIP(%ecx), %ebx + movl %ebx, -0xc(%eax) # create EIP in old stack + movzwl TSS_CS(%ecx), %ebx + movl %ebx, -0x8(%eax) # create CS in old stack + movl TSS_EFLAGS(%ecx), %ebx + btsl $8,%ebx + movl %ebx, -0x4(%eax) # create eflags in old stack + movl TSS_ESP(%ecx), %eax # Get old stack pointer + subl $12, %eax # minus 12 byte + movl %eax, TSS_ESP(%ecx) # Set new stack pointer + +# Replace the EIP of interrupted task with stub function + movl $ASM_PFX(PageFaultStubFunction), %eax + movl %eax, TSS_EIP(%ecx) +# Jump to the iret so next page fault handler as a task will start again after iret. + +Done2: + + addl $4, %esp # skip ErrCode + + jmp Return + +ASM_PFX(PageFaultStubFunction): +# +# we need clean TS bit in CR0 to execute +# x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. +# + clts + iret diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm new file mode 100644 index 0000000000..80a44b861f --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm @@ -0,0 +1,713 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.asm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + + .686p + .model flat,C + +EXTERNDEF SmiPFHandler:PROC +EXTERNDEF PageFaultStubFunction:PROC +EXTERNDEF gcSmiIdtr:FWORD +EXTERNDEF gcSmiGdtr:FWORD +EXTERNDEF gTaskGateDescriptor:QWORD +EXTERNDEF gcPsd:BYTE +EXTERNDEF FeaturePcdGet (PcdCpuSmmProfileEnable):BYTE + + + .data + +NullSeg DQ 0 ; reserved by architecture +CodeSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +ProtModeCodeSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +ProtModeSsSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 93h + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +DataSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 93h + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +CodeSeg16 LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh + DB 0 +DataSeg16 LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh + DB 0 +CodeSeg64 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0afh ; LimitHigh + DB 0 ; BaseHigh +GDT_SIZE = $ - offset NullSeg + +TssSeg LABEL QWORD + DW TSS_DESC_SIZE - 1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 89h + DB 00h ; LimitHigh + DB 0 ; BaseHigh +ExceptionTssSeg LABEL QWORD + DW TSS_DESC_SIZE - 1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 89h + DB 00h ; LimitHigh + DB 0 ; BaseHigh + +CODE_SEL = offset CodeSeg32 - offset NullSeg +DATA_SEL = offset DataSeg32 - offset NullSeg +TSS_SEL = offset TssSeg - offset NullSeg +EXCEPTION_TSS_SEL = offset ExceptionTssSeg - offset NullSeg + +IA32_TSS STRUC + DW ? + DW ? + ESP0 DD ? + SS0 DW ? + DW ? + ESP1 DD ? + SS1 DW ? + DW ? + ESP2 DD ? + SS2 DW ? + DW ? + _CR3 DD ? + EIP DD ? + EFLAGS DD ? + _EAX DD ? + _ECX DD ? + _EDX DD ? + _EBX DD ? + _ESP DD ? + _EBP DD ? + _ESI DD ? + _EDI DD ? + _ES DW ? + DW ? + _CS DW ? + DW ? + _SS DW ? + DW ? + _DS DW ? + DW ? + _FS DW ? + DW ? + _GS DW ? + DW ? + LDT DW ? + DW ? + DW ? + DW ? +IA32_TSS ENDS + +; Create 2 TSS segments just after GDT +TssDescriptor LABEL BYTE + DW 0 ; PreviousTaskLink + DW 0 ; Reserved + DD 0 ; ESP0 + DW 0 ; SS0 + DW 0 ; Reserved + DD 0 ; ESP1 + DW 0 ; SS1 + DW 0 ; Reserved + DD 0 ; ESP2 + DW 0 ; SS2 + DW 0 ; Reserved + DD 0 ; CR3 + DD 0 ; EIP + DD 0 ; EFLAGS + DD 0 ; EAX + DD 0 ; ECX + DD 0 ; EDX + DD 0 ; EBX + DD 0 ; ESP + DD 0 ; EBP + DD 0 ; ESI + DD 0 ; EDI + DW 0 ; ES + DW 0 ; Reserved + DW 0 ; CS + DW 0 ; Reserved + DW 0 ; SS + DW 0 ; Reserved + DW 0 ; DS + DW 0 ; Reserved + DW 0 ; FS + DW 0 ; Reserved + DW 0 ; GS + DW 0 ; Reserved + DW 0 ; LDT Selector + DW 0 ; Reserved + DW 0 ; T + DW 0 ; I/O Map Base +TSS_DESC_SIZE = $ - offset TssDescriptor + +ExceptionTssDescriptor LABEL BYTE + DW 0 ; PreviousTaskLink + DW 0 ; Reserved + DD 0 ; ESP0 + DW 0 ; SS0 + DW 0 ; Reserved + DD 0 ; ESP1 + DW 0 ; SS1 + DW 0 ; Reserved + DD 0 ; ESP2 + DW 0 ; SS2 + DW 0 ; Reserved + DD 0 ; CR3 + DD offset PFHandlerEntry ; EIP + DD 00000002 ; EFLAGS + DD 0 ; EAX + DD 0 ; ECX + DD 0 ; EDX + DD 0 ; EBX + DD 0 ; ESP + DD 0 ; EBP + DD 0 ; ESI + DD 0 ; EDI + DW DATA_SEL ; ES + DW 0 ; Reserved + DW CODE_SEL ; CS + DW 0 ; Reserved + DW DATA_SEL ; SS + DW 0 ; Reserved + DW DATA_SEL ; DS + DW 0 ; Reserved + DW DATA_SEL ; FS + DW 0 ; Reserved + DW DATA_SEL ; GS + DW 0 ; Reserved + DW 0 ; LDT Selector + DW 0 ; Reserved + DW 0 ; T + DW 0 ; I/O Map Base + +gcPsd LABEL BYTE + DB 'PSDSIG ' + DW PSD_SIZE + DW 2 + DW 1 SHL 2 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW 0 + DQ 0 + DQ 0 + DQ 0 + DQ offset NullSeg + DD GDT_SIZE + DD 0 + DB 24 dup (0) + DQ 0 +PSD_SIZE = $ - offset gcPsd + +gcSmiGdtr LABEL FWORD + DW GDT_SIZE - 1 + DD offset NullSeg + +gcSmiIdtr LABEL FWORD + DW 0 + DD 0 + +gTaskGateDescriptor LABEL QWORD + DW 0 ; Reserved + DW EXCEPTION_TSS_SEL ; TSS Segment selector + DB 0 ; Reserved + DB 85h ; Task Gate, present, DPL = 0 + DW 0 ; Reserved + + + .code +;------------------------------------------------------------------------------ +; PageFaultIdtHandlerSmmProfile is the entry point page fault only +; +; +; Stack: +; +---------------------+ +; + EFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + EIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + EBP + +; +---------------------+ <-- EBP +; +; +;------------------------------------------------------------------------------ +PageFaultIdtHandlerSmmProfile PROC + push 0eh ; Page Fault + + push ebp + mov ebp, esp + + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0fffffff0h + sub esp, 12 + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push eax + push ecx + push edx + push ebx + lea ecx, [ebp + 6 * 4] + push ecx ; ESP + push dword ptr [ebp] ; EBP + push esi + push edi + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + mov eax, ss + push eax + movzx eax, word ptr [ebp + 4 * 4] + push eax + mov eax, ds + push eax + mov eax, es + push eax + mov eax, fs + push eax + mov eax, gs + push eax + +;; UINT32 Eip; + mov eax, [ebp + 3 * 4] + push eax + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + xor eax, eax + str ax + push eax + sldt ax + push eax + +;; UINT32 EFlags; + mov eax, [ebp + 5 * 4] + push eax + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, cr4 + or eax, 208h + mov cr4, eax + push eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; + sub esp, 512 + mov edi, esp + db 0fh, 0aeh, 07h ;fxsave [edi] + +; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword ptr [ebp + 2 * 4] + +;; call into exception handler + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, dword ptr [ebp + 1 * 4] + push edx + + ; + ; Call External Exception Handler + ; + mov eax, SmiPFHandler + call eax + add esp, 8 + +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + db 0fh, 0aeh, 0eh ; fxrstor [esi] + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoint in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov cr3, eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop dword ptr [ebp + 5 * 4] + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop dword ptr [ebp + 3 * 4] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop gs + pop fs + pop es + pop ds + pop dword ptr [ebp + 4 * 4] + pop ss + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop edi + pop esi + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop ebx + pop edx + pop ecx + pop eax + + mov esp, ebp + pop ebp + +; Enable TF bit after page fault handler runs + bts dword ptr [esp + 16], 8 ; EFLAGS + + add esp, 8 ; skip INT# & ErrCode +Return: + iretd +; +; Page Fault Exception Handler entry when SMM Stack Guard is enabled +; Executiot starts here after a task switch +; +PFHandlerEntry:: +; +; Get this processor's TSS +; + sub esp, 8 + sgdt [esp + 2] + mov eax, [esp + 4] ; GDT base + add esp, 8 + mov ecx, [eax + TSS_SEL + 2] + shl ecx, 8 + mov cl, [eax + TSS_SEL + 7] + ror ecx, 8 ; ecx = TSS base + + mov ebp, esp + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0fffffff0h + sub esp, 12 + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push (IA32_TSS ptr [ecx])._EAX + push (IA32_TSS ptr [ecx])._ECX + push (IA32_TSS ptr [ecx])._EDX + push (IA32_TSS ptr [ecx])._EBX + push (IA32_TSS ptr [ecx])._ESP + push (IA32_TSS ptr [ecx])._EBP + push (IA32_TSS ptr [ecx])._ESI + push (IA32_TSS ptr [ecx])._EDI + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + movzx eax, (IA32_TSS ptr [ecx])._SS + push eax + movzx eax, (IA32_TSS ptr [ecx])._CS + push eax + movzx eax, (IA32_TSS ptr [ecx])._DS + push eax + movzx eax, (IA32_TSS ptr [ecx])._ES + push eax + movzx eax, (IA32_TSS ptr [ecx])._FS + push eax + movzx eax, (IA32_TSS ptr [ecx])._GS + push eax + +;; UINT32 Eip; + push (IA32_TSS ptr [ecx]).EIP + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0FFFFh + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + mov eax, TSS_SEL + push eax + movzx eax, (IA32_TSS ptr [ecx]).LDT + push eax + +;; UINT32 EFlags; + push (IA32_TSS ptr [ecx]).EFLAGS + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, cr4 + or eax, 208h + mov cr4, eax + push eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; +;; Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) +;; when executing fxsave/fxrstor instruction + clts + sub esp, 512 + mov edi, esp + db 0fh, 0aeh, 07h ;fxsave [edi] + +; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword ptr [ebp] + +;; call into exception handler + mov ebx, ecx + mov eax, SmiPFHandler + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, 14 + push edx + + ; + ; Call External Exception Handler + ; + call eax + add esp, 8 + + mov ecx, ebx +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + db 0fh, 0aeh, 0eh ; fxrstor [esi] + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoints in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov (IA32_TSS ptr [ecx])._CR3, eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop (IA32_TSS ptr [ecx]).EFLAGS + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop (IA32_TSS ptr [ecx]).EIP + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop eax + mov (IA32_TSS ptr [ecx])._GS, ax + pop eax + mov (IA32_TSS ptr [ecx])._FS, ax + pop eax + mov (IA32_TSS ptr [ecx])._ES, ax + pop eax + mov (IA32_TSS ptr [ecx])._DS, ax + pop eax + mov (IA32_TSS ptr [ecx])._CS, ax + pop eax + mov (IA32_TSS ptr [ecx])._SS, ax + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop (IA32_TSS ptr [ecx])._EDI + pop (IA32_TSS ptr [ecx])._ESI + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop (IA32_TSS ptr [ecx])._EBX + pop (IA32_TSS ptr [ecx])._EDX + pop (IA32_TSS ptr [ecx])._ECX + pop (IA32_TSS ptr [ecx])._EAX + + mov esp, ebp + +; Set single step DB# if SMM profile is enabled and page fault exception happens + cmp FeaturePcdGet (PcdCpuSmmProfileEnable), 0 + jz @Done2 + +; Create return context for iretd in stub function + mov eax, (IA32_TSS ptr [ecx])._ESP ; Get old stack pointer + mov ebx, (IA32_TSS ptr [ecx]).EIP + mov [eax - 0ch], ebx ; create EIP in old stack + movzx ebx, (IA32_TSS ptr [ecx])._CS + mov [eax - 08h], ebx ; create CS in old stack + mov ebx, (IA32_TSS ptr [ecx]).EFLAGS + bts ebx, 8 + mov [eax - 04h], ebx ; create eflags in old stack + mov eax, (IA32_TSS ptr [ecx])._ESP ; Get old stack pointer + sub eax, 0ch ; minus 12 byte + mov (IA32_TSS ptr [ecx])._ESP, eax ; Set new stack pointer +; Replace the EIP of interrupted task with stub function + mov eax, PageFaultStubFunction + mov (IA32_TSS ptr [ecx]).EIP, eax +; Jump to the iretd so next page fault handler as a task will start again after iretd. +@Done2: + add esp, 4 ; skip ErrCode + + jmp Return +PageFaultIdtHandlerSmmProfile ENDP + +PageFaultStubFunction PROC +; +; we need clean TS bit in CR0 to execute +; x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. +; + clts + iretd +PageFaultStubFunction ENDP + + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm new file mode 100644 index 0000000000..7c80a6ae91 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm @@ -0,0 +1,708 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.nasm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +extern ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) +extern ASM_PFX(SmiPFHandler) + +global ASM_PFX(gcSmiIdtr) +global ASM_PFX(gcSmiGdtr) +global ASM_PFX(gTaskGateDescriptor) +global ASM_PFX(gcPsd) + + SECTION .data + +NullSeg: DQ 0 ; reserved by architecture +CodeSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +ProtModeCodeSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +ProtModeSsSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x93 + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +DataSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x93 + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +CodeSeg16: + DW -1 + DW 0 + DB 0 + DB 0x9b + DB 0x8f + DB 0 +DataSeg16: + DW -1 + DW 0 + DB 0 + DB 0x93 + DB 0x8f + DB 0 +CodeSeg64: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xaf ; LimitHigh + DB 0 ; BaseHigh +GDT_SIZE equ $ - NullSeg + +TssSeg: + DW TSS_DESC_SIZE ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x89 + DB 0x80 ; LimitHigh + DB 0 ; BaseHigh +ExceptionTssSeg: + DW TSS_DESC_SIZE ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x89 + DB 0x80 ; LimitHigh + DB 0 ; BaseHigh + +CODE_SEL equ CodeSeg32 - NullSeg +DATA_SEL equ DataSeg32 - NullSeg +TSS_SEL equ TssSeg - NullSeg +EXCEPTION_TSS_SEL equ ExceptionTssSeg - NullSeg + +struc IA32_TSS + resw 1 + resw 1 + .ESP0: resd 1 + .SS0: resw 1 + resw 1 + .ESP1: resd 1 + .SS1: resw 1 + resw 1 + .ESP2: resd 1 + .SS2: resw 1 + resw 1 + ._CR3: resd 1 + .EIP: resd 1 + .EFLAGS: resd 1 + ._EAX: resd 1 + ._ECX: resd 1 + ._EDX: resd 1 + ._EBX: resd 1 + ._ESP: resd 1 + ._EBP: resd 1 + ._ESI: resd 1 + ._EDI: resd 1 + ._ES: resw 1 + resw 1 + ._CS: resw 1 + resw 1 + ._SS: resw 1 + resw 1 + ._DS: resw 1 + resw 1 + ._FS: resw 1 + resw 1 + ._GS: resw 1 + resw 1 + .LDT: resw 1 + resw 1 + resw 1 + resw 1 +endstruc + +; Create 2 TSS segments just after GDT +TssDescriptor: + DW 0 ; PreviousTaskLink + DW 0 ; Reserved + DD 0 ; ESP0 + DW 0 ; SS0 + DW 0 ; Reserved + DD 0 ; ESP1 + DW 0 ; SS1 + DW 0 ; Reserved + DD 0 ; ESP2 + DW 0 ; SS2 + DW 0 ; Reserved + DD 0 ; CR3 + DD 0 ; EIP + DD 0 ; EFLAGS + DD 0 ; EAX + DD 0 ; ECX + DD 0 ; EDX + DD 0 ; EBX + DD 0 ; ESP + DD 0 ; EBP + DD 0 ; ESI + DD 0 ; EDI + DW 0 ; ES + DW 0 ; Reserved + DW 0 ; CS + DW 0 ; Reserved + DW 0 ; SS + DW 0 ; Reserved + DW 0 ; DS + DW 0 ; Reserved + DW 0 ; FS + DW 0 ; Reserved + DW 0 ; GS + DW 0 ; Reserved + DW 0 ; LDT Selector + DW 0 ; Reserved + DW 0 ; T + DW 0 ; I/O Map Base +TSS_DESC_SIZE equ $ - TssDescriptor + +ExceptionTssDescriptor: + DW 0 ; PreviousTaskLink + DW 0 ; Reserved + DD 0 ; ESP0 + DW 0 ; SS0 + DW 0 ; Reserved + DD 0 ; ESP1 + DW 0 ; SS1 + DW 0 ; Reserved + DD 0 ; ESP2 + DW 0 ; SS2 + DW 0 ; Reserved + DD 0 ; CR3 + DD PFHandlerEntry ; EIP + DD 00000002 ; EFLAGS + DD 0 ; EAX + DD 0 ; ECX + DD 0 ; EDX + DD 0 ; EBX + DD 0 ; ESP + DD 0 ; EBP + DD 0 ; ESI + DD 0 ; EDI + DW DATA_SEL ; ES + DW 0 ; Reserved + DW CODE_SEL ; CS + DW 0 ; Reserved + DW DATA_SEL ; SS + DW 0 ; Reserved + DW DATA_SEL ; DS + DW 0 ; Reserved + DW DATA_SEL ; FS + DW 0 ; Reserved + DW DATA_SEL ; GS + DW 0 ; Reserved + DW 0 ; LDT Selector + DW 0 ; Reserved + DW 0 ; T + DW 0 ; I/O Map Base + +ASM_PFX(gcPsd): + DB 'PSDSIG ' + DW PSD_SIZE + DW 2 + DW 1 << 2 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW 0 + DQ 0 + DQ 0 + DQ 0 + DD 0 + DD NullSeg + DD GDT_SIZE + DD 0 + times 24 DB 0 + DD 0 + DD 0 +PSD_SIZE equ $ - ASM_PFX(gcPsd) + +ASM_PFX(gcSmiGdtr): + DW GDT_SIZE - 1 + DD NullSeg + +ASM_PFX(gcSmiIdtr): + DW 0 + DD 0 + +ASM_PFX(gTaskGateDescriptor): + DW 0 ; Reserved + DW EXCEPTION_TSS_SEL ; TSS Segment selector + DB 0 ; Reserved + DB 0x85 ; Task Gate, present, DPL = 0 + DW 0 ; Reserved + + SECTION .text +;------------------------------------------------------------------------------ +; PageFaultIdtHandlerSmmProfile is the entry point page fault only +; +; +; Stack: +; +---------------------+ +; + EFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + EIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + EBP + +; +---------------------+ <-- EBP +; +; +;------------------------------------------------------------------------------ +global ASM_PFX(PageFaultIdtHandlerSmmProfile) +ASM_PFX(PageFaultIdtHandlerSmmProfile): + push 0xe ; Page Fault + + push ebp + mov ebp, esp + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0xfffffff0 + sub esp, 12 + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push eax + push ecx + push edx + push ebx + lea ecx, [ebp + 6 * 4] + push ecx ; ESP + push dword [ebp] ; EBP + push esi + push edi + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + mov eax, ss + push eax + movzx eax, word [ebp + 4 * 4] + push eax + mov eax, ds + push eax + mov eax, es + push eax + mov eax, fs + push eax + mov eax, gs + push eax + +;; UINT32 Eip; + mov eax, [ebp + 3 * 4] + push eax + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + xor eax, eax + str ax + push eax + sldt ax + push eax + +;; UINT32 EFlags; + mov eax, [ebp + 5 * 4] + push eax + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, cr4 + or eax, 0x208 + mov cr4, eax + push eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; + sub esp, 512 + mov edi, esp + db 0xf, 0xae, 0x7 ;fxsave [edi] + +; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword [ebp + 2 * 4] + +;; call into exception handler + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, dword [ebp + 1 * 4] + push edx + + ; + ; Call External Exception Handler + ; + mov eax, ASM_PFX(SmiPFHandler) + call eax + add esp, 8 + +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + db 0xf, 0xae, 0xe ; fxrstor [esi] + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoint in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov cr3, eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop dword [ebp + 5 * 4] + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop dword [ebp + 3 * 4] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop gs + pop fs + pop es + pop ds + pop dword [ebp + 4 * 4] + pop ss + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop edi + pop esi + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop ebx + pop edx + pop ecx + pop eax + + mov esp, ebp + pop ebp + +; Enable TF bit after page fault handler runs + bts dword [esp + 16], 8 ; EFLAGS + + add esp, 8 ; skip INT# & ErrCode +Return: + iretd +; +; Page Fault Exception Handler entry when SMM Stack Guard is enabled +; Executiot starts here after a task switch +; +PFHandlerEntry: +; +; Get this processor's TSS +; + sub esp, 8 + sgdt [esp + 2] + mov eax, [esp + 4] ; GDT base + add esp, 8 + mov ecx, [eax + TSS_SEL + 2] + shl ecx, 8 + mov cl, [eax + TSS_SEL + 7] + ror ecx, 8 ; ecx = TSS base + + mov ebp, esp + + ; + ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 + ; is 16-byte aligned + ; + and esp, 0xfffffff0 + sub esp, 12 + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + push dword [ecx + IA32_TSS._EAX] + push dword [ecx + IA32_TSS._ECX] + push dword [ecx + IA32_TSS._EDX] + push dword [ecx + IA32_TSS._EBX] + push dword [ecx + IA32_TSS._ESP] + push dword [ecx + IA32_TSS._EBP] + push dword [ecx + IA32_TSS._ESI] + push dword [ecx + IA32_TSS._EDI] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; + movzx eax, word [ecx + IA32_TSS._SS] + push eax + movzx eax, word [ecx + IA32_TSS._CS] + push eax + movzx eax, word [ecx + IA32_TSS._DS] + push eax + movzx eax, word [ecx + IA32_TSS._ES] + push eax + movzx eax, word [ecx + IA32_TSS._FS] + push eax + movzx eax, word [ecx + IA32_TSS._GS] + push eax + +;; UINT32 Eip; + push dword [ecx + IA32_TSS.EIP] + +;; UINT32 Gdtr[2], Idtr[2]; + sub esp, 8 + sidt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + + sub esp, 8 + sgdt [esp] + mov eax, [esp + 2] + xchg eax, [esp] + and eax, 0xFFFF + mov [esp+4], eax + +;; UINT32 Ldtr, Tr; + mov eax, TSS_SEL + push eax + movzx eax, word [ecx + IA32_TSS.LDT] + push eax + +;; UINT32 EFlags; + push dword [ecx + IA32_TSS.EFLAGS] + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + mov eax, cr4 + or eax, 0x208 + mov cr4, eax + push eax + mov eax, cr3 + push eax + mov eax, cr2 + push eax + xor eax, eax + push eax + mov eax, cr0 + push eax + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov eax, dr7 + push eax + mov eax, dr6 + push eax + mov eax, dr3 + push eax + mov eax, dr2 + push eax + mov eax, dr1 + push eax + mov eax, dr0 + push eax + +;; FX_SAVE_STATE_IA32 FxSaveState; +;; Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) +;; when executing fxsave/fxrstor instruction + clts + sub esp, 512 + mov edi, esp + db 0xf, 0xae, 0x7 ;fxsave [edi] + +; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push dword [ebp] + +;; call into exception handler + mov ebx, ecx + mov eax, ASM_PFX(SmiPFHandler) + +;; Prepare parameter and call + mov edx, esp + push edx + mov edx, 14 + push edx + + ; + ; Call External Exception Handler + ; + call eax + add esp, 8 + + mov ecx, ebx +;; UINT32 ExceptionData; + add esp, 4 + +;; FX_SAVE_STATE_IA32 FxSaveState; + mov esi, esp + db 0xf, 0xae, 0xe ; fxrstor [esi] + add esp, 512 + +;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoints in interrupt/exception context + add esp, 4 * 6 + +;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; + pop eax + mov cr0, eax + add esp, 4 ; not for Cr1 + pop eax + mov cr2, eax + pop eax + mov dword [ecx + IA32_TSS._CR3], eax + pop eax + mov cr4, eax + +;; UINT32 EFlags; + pop dword [ecx + IA32_TSS.EFLAGS] + +;; UINT32 Ldtr, Tr; +;; UINT32 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add esp, 24 + +;; UINT32 Eip; + pop dword [ecx + IA32_TSS.EIP] + +;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; +;; NOTE - modified segment registers could hang the debugger... We +;; could attempt to insulate ourselves against this possibility, +;; but that poses risks as well. +;; + pop eax +o16 mov [ecx + IA32_TSS._GS], ax + pop eax +o16 mov [ecx + IA32_TSS._FS], ax + pop eax +o16 mov [ecx + IA32_TSS._ES], ax + pop eax +o16 mov [ecx + IA32_TSS._DS], ax + pop eax +o16 mov [ecx + IA32_TSS._CS], ax + pop eax +o16 mov [ecx + IA32_TSS._SS], ax + +;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; + pop dword [ecx + IA32_TSS._EDI] + pop dword [ecx + IA32_TSS._ESI] + add esp, 4 ; not for ebp + add esp, 4 ; not for esp + pop dword [ecx + IA32_TSS._EBX] + pop dword [ecx + IA32_TSS._EDX] + pop dword [ecx + IA32_TSS._ECX] + pop dword [ecx + IA32_TSS._EAX] + + mov esp, ebp + +; Set single step DB# if SMM profile is enabled and page fault exception happens + cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable))], 0 + jz @Done2 + +; Create return context for iretd in stub function + mov eax, dword [ecx + IA32_TSS._ESP] ; Get old stack pointer + mov ebx, dword [ecx + IA32_TSS.EIP] + mov [eax - 0xc], ebx ; create EIP in old stack + movzx ebx, word [ecx + IA32_TSS._CS] + mov [eax - 0x8], ebx ; create CS in old stack + mov ebx, dword [ecx + IA32_TSS.EFLAGS] + bts ebx, 8 + mov [eax - 0x4], ebx ; create eflags in old stack + mov eax, dword [ecx + IA32_TSS._ESP] ; Get old stack pointer + sub eax, 0xc ; minus 12 byte + mov dword [ecx + IA32_TSS._ESP], eax ; Set new stack pointer +; Replace the EIP of interrupted task with stub function + mov eax, ASM_PFX(PageFaultStubFunction) + mov dword [ecx + IA32_TSS.EIP], eax +; Jump to the iretd so next page fault handler as a task will start again after iretd. +@Done2: + add esp, 4 ; skip ErrCode + + jmp Return + +global ASM_PFX(PageFaultStubFunction) +ASM_PFX(PageFaultStubFunction): +; +; we need clean TS bit in CR0 to execute +; x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. +; + clts + iretd + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c new file mode 100644 index 0000000000..3c68c97024 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c @@ -0,0 +1,209 @@ +/** @file + SMM CPU misc functions for Ia32 arch specific. + +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +extern UINT64 gTaskGateDescriptor; + +EFI_PHYSICAL_ADDRESS mGdtBuffer; +UINTN mGdtBufferSize; + +/** + Initialize IDT for SMM Stack Guard. + +**/ +VOID +EFIAPI +InitializeIDTSmmStackGuard ( + VOID + ) +{ + IA32_IDT_GATE_DESCRIPTOR *IdtGate; + + // + // If SMM Stack Guard feature is enabled, the Page Fault Exception entry in IDT + // is a Task Gate Descriptor so that when a Page Fault Exception occurs, + // the processors can use a known good stack in case stack is ran out. + // + IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base; + IdtGate += EXCEPT_IA32_PAGE_FAULT; + IdtGate->Uint64 = gTaskGateDescriptor; +} + +/** + Initialize Gdt for all processors. + + @param[in] Cr3 CR3 value. + @param[out] GdtStepSize The step size for GDT table. + + @return GdtBase for processor 0. + GdtBase for processor X is: GdtBase + (GdtStepSize * X) +**/ +VOID * +InitGdt ( + IN UINTN Cr3, + OUT UINTN *GdtStepSize + ) +{ + UINTN Index; + IA32_SEGMENT_DESCRIPTOR *GdtDescriptor; + UINTN TssBase; + UINTN GdtTssTableSize; + UINT8 *GdtTssTables; + UINTN GdtTableStepSize; + + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + // + // For IA32 SMM, if SMM Stack Guard feature is enabled, we use 2 TSS. + // in this case, we allocate separate GDT/TSS for each CPUs to avoid TSS load contention + // on each SMI entry. + // + + // + // Enlarge GDT to contain 2 TSS descriptors + // + gcSmiGdtr.Limit += (UINT16)(2 * sizeof (IA32_SEGMENT_DESCRIPTOR)); + + GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE * 2 + 7) & ~7; // 8 bytes aligned + mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); + ASSERT (GdtTssTables != NULL); + mGdtBuffer = (UINTN)GdtTssTables; + GdtTableStepSize = GdtTssTableSize; + + for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { + CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE * 2); + // + // Fixup TSS descriptors + // + TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1); + GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2; + GdtDescriptor->Bits.BaseLow = (UINT16)TssBase; + GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16); + GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24); + + TssBase += TSS_SIZE; + GdtDescriptor++; + GdtDescriptor->Bits.BaseLow = (UINT16)TssBase; + GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16); + GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24); + // + // Fixup TSS segments + // + // ESP as known good stack + // + *(UINTN *)(TssBase + TSS_IA32_ESP_OFFSET) = mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize; + *(UINT32 *)(TssBase + TSS_IA32_CR3_OFFSET) = Cr3; + } + } else { + // + // Just use original table, AllocatePage and copy them here to make sure GDTs are covered in page memory. + // + GdtTssTableSize = gcSmiGdtr.Limit + 1; + mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); + ASSERT (GdtTssTables != NULL); + mGdtBuffer = (UINTN)GdtTssTables; + GdtTableStepSize = GdtTssTableSize; + + for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { + CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1); + } + } + + *GdtStepSize = GdtTableStepSize; + return GdtTssTables; +} + +/** + This function sets GDT/IDT buffer to be RO and XP. +**/ +VOID +PatchGdtIdtMap ( + VOID + ) +{ + EFI_PHYSICAL_ADDRESS BaseAddress; + UINTN Size; + + // + // GDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n")); + + BaseAddress = mGdtBuffer; + Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB); + if (!FeaturePcdGet (PcdCpuSmmStackGuard)) { + // + // Do not set RO for IA32 when stack guard feature is enabled. + // Stack Guard need use task switch to switch stack. + // It need write GDT and TSS. + // + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_RO + ); + } + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); + + // + // IDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n")); + + BaseAddress = gcSmiIdtr.Base; + Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_RO + ); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); +} + +/** + Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. + + @param[in] ApHltLoopCode The address of the safe hlt-loop function. + @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. + @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. + +**/ +VOID +TransferApToSafeState ( + IN UINTN ApHltLoopCode, + IN UINTN TopOfStack, + IN UINTN NumberToFinishAddress + ) +{ + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT)ApHltLoopCode, + (VOID *)NumberToFinishAddress, + NULL, + (VOID *)TopOfStack + ); + // + // It should never reach here + // + ASSERT (FALSE); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S new file mode 100644 index 0000000000..e8db33a45a --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S @@ -0,0 +1,84 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmmInit.S +# +# Abstract: +# +# Functions for relocating SMBASE's for all processors +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gSmmCr0) +ASM_GLOBAL ASM_PFX(gSmmCr3) +ASM_GLOBAL ASM_PFX(gSmmCr4) +ASM_GLOBAL ASM_PFX(gcSmmInitTemplate) +ASM_GLOBAL ASM_PFX(gcSmmInitSize) +ASM_GLOBAL ASM_PFX(gSmmJmpAddr) +ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete) +ASM_GLOBAL ASM_PFX(gSmmInitStack) +ASM_GLOBAL ASM_PFX(gcSmiInitGdtr) + +.equ PROTECT_MODE_CS, 0x08 +.equ PROTECT_MODE_DS, 0x20 + + .text + +ASM_PFX(gcSmiInitGdtr): + .word 0 + .quad 0 + +SmmStartup: + .byte 0x66,0xb8 +ASM_PFX(gSmmCr3): .space 4 + movl %eax, %cr3 + .byte 0x67,0x66 + lgdt %cs:(ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp) + .byte 0x66,0xb8 +ASM_PFX(gSmmCr4): .space 4 + movl %eax, %cr4 + .byte 0x66,0xb8 +ASM_PFX(gSmmCr0): .space 4 + .byte 0xbf, PROTECT_MODE_DS, 0 # mov di, PROTECT_MODE_DS + movl %eax, %cr0 + .byte 0x66,0xea # jmp far [ptr48] +ASM_PFX(gSmmJmpAddr): .long Start32bit + .word PROTECT_MODE_CS +Start32bit: + movl %edi,%ds + movl %edi,%es + movl %edi,%fs + movl %edi,%gs + movl %edi,%ss + .byte 0xbc # mov esp, imm32 +ASM_PFX(gSmmInitStack): .space 4 + call ASM_PFX(SmmInitHandler) + rsm + +ASM_PFX(gcSmmInitTemplate): + +_SmmInitTemplate: + .byte 0x66 + movl $SmmStartup, %ebp + .byte 0x66, 0x81, 0xed, 0, 0, 3, 0 # sub ebp, 0x30000 + jmp *%bp # jmp ebp actually + +ASM_PFX(gcSmmInitSize): .word . - ASM_PFX(gcSmmInitTemplate) + + +ASM_PFX(SmmRelocationSemaphoreComplete): + pushl %eax + movl ASM_PFX(mRebasedFlag), %eax + movb $1, (%eax) + popl %eax + jmp *ASM_PFX(mSmmRelocationOriginalAddress) diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm new file mode 100644 index 0000000000..9ba2aebe69 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm @@ -0,0 +1,94 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmmInit.Asm +; +; Abstract: +; +; Functions for relocating SMBASE's for all processors +; +;------------------------------------------------------------------------------- + + .686p + .xmm + .model flat,C + +SmmInitHandler PROTO C + +EXTERNDEF C gSmmCr0:DWORD +EXTERNDEF C gSmmCr3:DWORD +EXTERNDEF C gSmmCr4:DWORD +EXTERNDEF C gcSmmInitTemplate:BYTE +EXTERNDEF C gcSmmInitSize:WORD +EXTERNDEF C gSmmJmpAddr:QWORD +EXTERNDEF C mRebasedFlag:PTR BYTE +EXTERNDEF C mSmmRelocationOriginalAddress:DWORD +EXTERNDEF C gSmmInitStack:DWORD +EXTERNDEF C gcSmiInitGdtr:FWORD + +PROTECT_MODE_CS EQU 08h +PROTECT_MODE_DS EQU 20h + + .code + +gcSmiInitGdtr LABEL FWORD + DW 0 + DQ 0 + +SmmStartup PROC + DB 66h, 0b8h +gSmmCr3 DD ? + mov cr3, eax + DB 67h, 66h + lgdt fword ptr cs:[ebp + (offset gcSmiInitGdtr - SmmStartup)] + DB 66h, 0b8h +gSmmCr4 DD ? + mov cr4, eax + DB 66h, 0b8h +gSmmCr0 DD ? + DB 0bfh, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS + mov cr0, eax + DB 66h, 0eah ; jmp far [ptr48] +gSmmJmpAddr LABEL QWORD + DD @32bit + DW PROTECT_MODE_CS +@32bit: + mov ds, edi + mov es, edi + mov fs, edi + mov gs, edi + mov ss, edi + DB 0bch ; mov esp, imm32 +gSmmInitStack DD ? + call SmmInitHandler + rsm +SmmStartup ENDP + +gcSmmInitTemplate LABEL BYTE + +_SmmInitTemplate PROC + DB 66h + mov ebp, SmmStartup + DB 66h, 81h, 0edh, 00h, 00h, 03h, 00 ; sub ebp, 30000h + jmp bp ; jmp ebp actually +_SmmInitTemplate ENDP + +gcSmmInitSize DW $ - gcSmmInitTemplate + +SmmRelocationSemaphoreComplete PROC + push eax + mov eax, mRebasedFlag + mov byte ptr [eax], 1 + pop eax + jmp [mSmmRelocationOriginalAddress] +SmmRelocationSemaphoreComplete ENDP + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm new file mode 100644 index 0000000000..d9df3626c7 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm @@ -0,0 +1,87 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmmInit.nasm +; +; Abstract: +; +; Functions for relocating SMBASE's for all processors +; +;------------------------------------------------------------------------------- + +extern ASM_PFX(SmmInitHandler) +extern ASM_PFX(mRebasedFlag) +extern ASM_PFX(mSmmRelocationOriginalAddress) + +global ASM_PFX(gSmmCr3) +global ASM_PFX(gSmmCr4) +global ASM_PFX(gSmmCr0) +global ASM_PFX(gSmmJmpAddr) +global ASM_PFX(gSmmInitStack) +global ASM_PFX(gcSmiInitGdtr) +global ASM_PFX(gcSmmInitSize) +global ASM_PFX(gcSmmInitTemplate) + +%define PROTECT_MODE_CS 0x8 +%define PROTECT_MODE_DS 0x20 + + SECTION .text + +ASM_PFX(gcSmiInitGdtr): + DW 0 + DQ 0 + +global ASM_PFX(SmmStartup) +ASM_PFX(SmmStartup): + DB 0x66, 0xb8 +ASM_PFX(gSmmCr3): DD 0 + mov cr3, eax + DB 0x67, 0x66 + lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] + DB 0x66, 0xb8 +ASM_PFX(gSmmCr4): DD 0 + mov cr4, eax + DB 0x66, 0xb8 +ASM_PFX(gSmmCr0): DD 0 + DB 0xbf, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS + mov cr0, eax + DB 0x66, 0xea ; jmp far [ptr48] +ASM_PFX(gSmmJmpAddr): + DD @32bit + DW PROTECT_MODE_CS +@32bit: + mov ds, edi + mov es, edi + mov fs, edi + mov gs, edi + mov ss, edi + DB 0xbc ; mov esp, imm32 +ASM_PFX(gSmmInitStack): DD 0 + call ASM_PFX(SmmInitHandler) + rsm + +BITS 16 +ASM_PFX(gcSmmInitTemplate): + mov ebp, ASM_PFX(SmmStartup) + sub ebp, 0x30000 + jmp ebp + +ASM_PFX(gcSmmInitSize): DW $ - ASM_PFX(gcSmmInitTemplate) + +BITS 32 +global ASM_PFX(SmmRelocationSemaphoreComplete) +ASM_PFX(SmmRelocationSemaphoreComplete): + push eax + mov eax, [ASM_PFX(mRebasedFlag)] + mov byte [eax], 1 + pop eax + jmp [ASM_PFX(mSmmRelocationOriginalAddress)] diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c new file mode 100644 index 0000000000..724cd92c9c --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c @@ -0,0 +1,80 @@ +/** @file +IA-32 processor specific functions to enable SMM profile. + +Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" +#include "SmmProfileInternal.h" + +/** + Create SMM page table for S3 path. + +**/ +VOID +InitSmmS3Cr3 ( + VOID + ) +{ + mSmmS3ResumeState->SmmS3Cr3 = Gen4GPageTable (TRUE); + + return ; +} + +/** + Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. + 32-bit firmware does not need it. + +**/ +VOID +InitPagesForPFHandler ( + VOID + ) +{ +} + +/** + Update page table to map the memory correctly in order to make the instruction + which caused page fault execute successfully. And it also save the original page + table to be restored in single-step exception. 32-bit firmware does not need it. + + @param PageTable PageTable Address. + @param PFAddress The memory address which caused page fault exception. + @param CpuIndex The index of the processor. + @param ErrorCode The Error code of exception. + @param IsValidPFAddress The flag indicates if SMM profile data need be added. + +**/ +VOID +RestorePageTableAbove4G ( + UINT64 *PageTable, + UINT64 PFAddress, + UINTN CpuIndex, + UINTN ErrorCode, + BOOLEAN *IsValidPFAddress + ) +{ +} + +/** + Clear TF in FLAGS. + + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. + +**/ +VOID +ClearTrapFlag ( + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ) +{ + SystemContext.SystemContextIa32->Eflags &= (UINTN) ~BIT8; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h new file mode 100644 index 0000000000..3e15bffc60 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h @@ -0,0 +1,97 @@ +/** @file +IA-32 processor specific header file to enable SMM profile. + +Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_PROFILE_ARCH_H_ +#define _SMM_PROFILE_ARCH_H_ + +#pragma pack (1) + +typedef struct _MSR_DS_AREA_STRUCT { + UINT32 BTSBufferBase; + UINT32 BTSIndex; + UINT32 BTSAbsoluteMaximum; + UINT32 BTSInterruptThreshold; + UINT32 PEBSBufferBase; + UINT32 PEBSIndex; + UINT32 PEBSAbsoluteMaximum; + UINT32 PEBSInterruptThreshold; + UINT32 PEBSCounterReset[4]; + UINT32 Reserved; +} MSR_DS_AREA_STRUCT; + +typedef struct _BRANCH_TRACE_RECORD { + UINT32 LastBranchFrom; + UINT32 LastBranchTo; + UINT32 Rsvd0 : 4; + UINT32 BranchPredicted : 1; + UINT32 Rsvd1 : 27; +} BRANCH_TRACE_RECORD; + +typedef struct _PEBS_RECORD { + UINT32 Eflags; + UINT32 LinearIP; + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + UINT32 Esi; + UINT32 Edi; + UINT32 Ebp; + UINT32 Esp; +} PEBS_RECORD; + +#pragma pack () + +#define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB) + +/** + Update page table to map the memory correctly in order to make the instruction + which caused page fault execute successfully. And it also save the original page + table to be restored in single-step exception. 32-bit firmware does not need it. + + @param PageTable PageTable Address. + @param PFAddress The memory address which caused page fault exception. + @param CpuIndex The index of the processor. + @param ErrorCode The Error code of exception. + @param IsValidPFAddress The flag indicates if SMM profile data need be added. + +**/ +VOID +RestorePageTableAbove4G ( + UINT64 *PageTable, + UINT64 PFAddress, + UINTN CpuIndex, + UINTN ErrorCode, + BOOLEAN *IsValidPFAddress + ); + +/** + Create SMM page table for S3 path. + +**/ +VOID +InitSmmS3Cr3 ( + VOID + ); + +/** + Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. + +**/ +VOID +InitPagesForPFHandler ( + VOID + ); + +#endif // _SMM_PROFILE_ARCH_H_ diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c new file mode 100644 index 0000000000..a1d16b4570 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -0,0 +1,1390 @@ +/** @file +SMM MP service implementation + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +// +// Slots for all MTRR( FIXED MTRR + VARIABLE MTRR + MTRR_LIB_IA32_MTRR_DEF_TYPE) +// +MTRR_SETTINGS gSmiMtrrs; +UINT64 gPhyMask; +SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData = NULL; +UINTN mSmmMpSyncDataSize; +SMM_CPU_SEMAPHORES mSmmCpuSemaphores; +UINTN mSemaphoreSize; +SPIN_LOCK *mPFLock = NULL; +SMM_CPU_SYNC_MODE mCpuSmmSyncMode; + +/** + Performs an atomic compare exchange operation to get semaphore. + The compare exchange operation must be performed using + MP safe mechanisms. + + @param Sem IN: 32-bit unsigned integer + OUT: original integer - 1 + @return Original integer - 1 + +**/ +UINT32 +WaitForSemaphore ( + IN OUT volatile UINT32 *Sem + ) +{ + UINT32 Value; + + do { + Value = *Sem; + } while (Value == 0 || + InterlockedCompareExchange32 ( + (UINT32*)Sem, + Value, + Value - 1 + ) != Value); + return Value - 1; +} + + +/** + Performs an atomic compare exchange operation to release semaphore. + The compare exchange operation must be performed using + MP safe mechanisms. + + @param Sem IN: 32-bit unsigned integer + OUT: original integer + 1 + @return Original integer + 1 + +**/ +UINT32 +ReleaseSemaphore ( + IN OUT volatile UINT32 *Sem + ) +{ + UINT32 Value; + + do { + Value = *Sem; + } while (Value + 1 != 0 && + InterlockedCompareExchange32 ( + (UINT32*)Sem, + Value, + Value + 1 + ) != Value); + return Value + 1; +} + +/** + Performs an atomic compare exchange operation to lock semaphore. + The compare exchange operation must be performed using + MP safe mechanisms. + + @param Sem IN: 32-bit unsigned integer + OUT: -1 + @return Original integer + +**/ +UINT32 +LockdownSemaphore ( + IN OUT volatile UINT32 *Sem + ) +{ + UINT32 Value; + + do { + Value = *Sem; + } while (InterlockedCompareExchange32 ( + (UINT32*)Sem, + Value, (UINT32)-1 + ) != Value); + return Value; +} + +/** + Wait all APs to performs an atomic compare exchange operation to release semaphore. + + @param NumberOfAPs AP number + +**/ +VOID +WaitForAllAPs ( + IN UINTN NumberOfAPs + ) +{ + UINTN BspIndex; + + BspIndex = mSmmMpSyncData->BspIndex; + while (NumberOfAPs-- > 0) { + WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + } +} + +/** + Performs an atomic compare exchange operation to release semaphore + for each AP. + +**/ +VOID +ReleaseAllAPs ( + VOID + ) +{ + UINTN Index; + UINTN BspIndex; + + BspIndex = mSmmMpSyncData->BspIndex; + for (Index = mMaxNumberOfCpus; Index-- > 0;) { + if (Index != BspIndex && *(mSmmMpSyncData->CpuData[Index].Present)) { + ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run); + } + } +} + +/** + Checks if all CPUs (with certain exceptions) have checked in for this SMI run + + @param Exceptions CPU Arrival exception flags. + + @retval TRUE if all CPUs the have checked in. + @retval FALSE if at least one Normal AP hasn't checked in. + +**/ +BOOLEAN +AllCpusInSmmWithExceptions ( + SMM_CPU_ARRIVAL_EXCEPTIONS Exceptions + ) +{ + UINTN Index; + SMM_CPU_DATA_BLOCK *CpuData; + EFI_PROCESSOR_INFORMATION *ProcessorInfo; + + ASSERT (*mSmmMpSyncData->Counter <= mNumberOfCpus); + + if (*mSmmMpSyncData->Counter == mNumberOfCpus) { + return TRUE; + } + + CpuData = mSmmMpSyncData->CpuData; + ProcessorInfo = gSmmCpuPrivate->ProcessorInfo; + for (Index = mMaxNumberOfCpus; Index-- > 0;) { + if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { + if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmDelayed) != 0) { + continue; + } + if (((Exceptions & ARRIVAL_EXCEPTION_BLOCKED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmBlocked) != 0) { + continue; + } + if (((Exceptions & ARRIVAL_EXCEPTION_SMI_DISABLED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmEnable) != 0) { + continue; + } + return FALSE; + } + } + + + return TRUE; +} + + +/** + Given timeout constraint, wait for all APs to arrive, and insure when this function returns, no AP will execute normal mode code before + entering SMM, except SMI disabled APs. + +**/ +VOID +SmmWaitForApArrival ( + VOID + ) +{ + UINT64 Timer; + UINTN Index; + + ASSERT (*mSmmMpSyncData->Counter <= mNumberOfCpus); + + // + // Platform implementor should choose a timeout value appropriately: + // - The timeout value should balance the SMM time constrains and the likelihood that delayed CPUs are excluded in the SMM run. Note + // the SMI Handlers must ALWAYS take into account the cases that not all APs are available in an SMI run. + // - The timeout value must, in the case of 2nd timeout, be at least long enough to give time for all APs to receive the SMI IPI + // and either enter SMM or buffer the SMI, to insure there is no CPU running normal mode code when SMI handling starts. This will + // be TRUE even if a blocked CPU is brought out of the blocked state by a normal mode CPU (before the normal mode CPU received the + // SMI IPI), because with a buffered SMI, and CPU will enter SMM immediately after it is brought out of the blocked state. + // - The timeout value must be longer than longest possible IO operation in the system + // + + // + // Sync with APs 1st timeout + // + for (Timer = StartSyncTimer (); + !IsSyncTimerTimeout (Timer) && + !AllCpusInSmmWithExceptions (ARRIVAL_EXCEPTION_BLOCKED | ARRIVAL_EXCEPTION_SMI_DISABLED ); + ) { + CpuPause (); + } + + // + // Not all APs have arrived, so we need 2nd round of timeout. IPIs should be sent to ALL none present APs, + // because: + // a) Delayed AP may have just come out of the delayed state. Blocked AP may have just been brought out of blocked state by some AP running + // normal mode code. These APs need to be guaranteed to have an SMI pending to insure that once they are out of delayed / blocked state, they + // enter SMI immediately without executing instructions in normal mode. Note traditional flow requires there are no APs doing normal mode + // work while SMI handling is on-going. + // b) As a consequence of SMI IPI sending, (spurious) SMI may occur after this SMM run. + // c) ** NOTE **: Use SMI disabling feature VERY CAREFULLY (if at all) for traditional flow, because a processor in SMI-disabled state + // will execute normal mode code, which breaks the traditional SMI handlers' assumption that no APs are doing normal + // mode work while SMI handling is on-going. + // d) We don't add code to check SMI disabling status to skip sending IPI to SMI disabled APs, because: + // - In traditional flow, SMI disabling is discouraged. + // - In relaxed flow, CheckApArrival() will check SMI disabling status before calling this function. + // In both cases, adding SMI-disabling checking code increases overhead. + // + if (*mSmmMpSyncData->Counter < mNumberOfCpus) { + // + // Send SMI IPIs to bring outside processors in + // + for (Index = mMaxNumberOfCpus; Index-- > 0;) { + if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { + SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId); + } + } + + // + // Sync with APs 2nd timeout. + // + for (Timer = StartSyncTimer (); + !IsSyncTimerTimeout (Timer) && + !AllCpusInSmmWithExceptions (ARRIVAL_EXCEPTION_BLOCKED | ARRIVAL_EXCEPTION_SMI_DISABLED ); + ) { + CpuPause (); + } + } + + return; +} + + +/** + Replace OS MTRR's with SMI MTRR's. + + @param CpuIndex Processor Index + +**/ +VOID +ReplaceOSMtrrs ( + IN UINTN CpuIndex + ) +{ + SmmCpuFeaturesDisableSmrr (); + + // + // Replace all MTRRs registers + // + MtrrSetAllMtrrs (&gSmiMtrrs); +} + +/** + SMI handler for BSP. + + @param CpuIndex BSP processor Index + @param SyncMode SMM MP sync mode + +**/ +VOID +BSPHandler ( + IN UINTN CpuIndex, + IN SMM_CPU_SYNC_MODE SyncMode + ) +{ + UINTN Index; + MTRR_SETTINGS Mtrrs; + UINTN ApCount; + BOOLEAN ClearTopLevelSmiResult; + UINTN PresentCount; + + ASSERT (CpuIndex == mSmmMpSyncData->BspIndex); + ApCount = 0; + + // + // Flag BSP's presence + // + *mSmmMpSyncData->InsideSmm = TRUE; + + // + // Initialize Debug Agent to start source level debug in BSP handler + // + InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL); + + // + // Mark this processor's presence + // + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; + + // + // Clear platform top level SMI status bit before calling SMI handlers. If + // we cleared it after SMI handlers are run, we would miss the SMI that + // occurs after SMI handlers are done and before SMI status bit is cleared. + // + ClearTopLevelSmiResult = ClearTopLevelSmiStatus(); + ASSERT (ClearTopLevelSmiResult == TRUE); + + // + // Set running processor index + // + gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu = CpuIndex; + + // + // If Traditional Sync Mode or need to configure MTRRs: gather all available APs. + // + if (SyncMode == SmmCpuSyncModeTradition || SmmCpuFeaturesNeedConfigureMtrrs()) { + + // + // Wait for APs to arrive + // + SmmWaitForApArrival(); + + // + // Lock the counter down and retrieve the number of APs + // + *mSmmMpSyncData->AllCpusInSync = TRUE; + ApCount = LockdownSemaphore (mSmmMpSyncData->Counter) - 1; + + // + // Wait for all APs to get ready for programming MTRRs + // + WaitForAllAPs (ApCount); + + if (SmmCpuFeaturesNeedConfigureMtrrs()) { + // + // Signal all APs it's time for backup MTRRs + // + ReleaseAllAPs (); + + // + // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at + // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been set + // to a large enough value to avoid this situation. + // Note: For HT capable CPUs, threads within a core share the same set of MTRRs. + // We do the backup first and then set MTRR to avoid race condition for threads + // in the same core. + // + MtrrGetAllMtrrs(&Mtrrs); + + // + // Wait for all APs to complete their MTRR saving + // + WaitForAllAPs (ApCount); + + // + // Let all processors program SMM MTRRs together + // + ReleaseAllAPs (); + + // + // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at + // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been set + // to a large enough value to avoid this situation. + // + ReplaceOSMtrrs (CpuIndex); + + // + // Wait for all APs to complete their MTRR programming + // + WaitForAllAPs (ApCount); + } + } + + // + // The BUSY lock is initialized to Acquired state + // + AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy); + + // + // Perform the pre tasks + // + PerformPreTasks (); + + // + // Invoke SMM Foundation EntryPoint with the processor information context. + // + gSmmCpuPrivate->SmmCoreEntry (&gSmmCpuPrivate->SmmCoreEntryContext); + + // + // Make sure all APs have completed their pending none-block tasks + // + for (Index = mMaxNumberOfCpus; Index-- > 0;) { + if (Index != CpuIndex && *(mSmmMpSyncData->CpuData[Index].Present)) { + AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy); + ReleaseSpinLock (mSmmMpSyncData->CpuData[Index].Busy); + } + } + + // + // Perform the remaining tasks + // + PerformRemainingTasks (); + + // + // If Relaxed-AP Sync Mode: gather all available APs after BSP SMM handlers are done, and + // make those APs to exit SMI synchronously. APs which arrive later will be excluded and + // will run through freely. + // + if (SyncMode != SmmCpuSyncModeTradition && !SmmCpuFeaturesNeedConfigureMtrrs()) { + + // + // Lock the counter down and retrieve the number of APs + // + *mSmmMpSyncData->AllCpusInSync = TRUE; + ApCount = LockdownSemaphore (mSmmMpSyncData->Counter) - 1; + // + // Make sure all APs have their Present flag set + // + while (TRUE) { + PresentCount = 0; + for (Index = mMaxNumberOfCpus; Index-- > 0;) { + if (*(mSmmMpSyncData->CpuData[Index].Present)) { + PresentCount ++; + } + } + if (PresentCount > ApCount) { + break; + } + } + } + + // + // Notify all APs to exit + // + *mSmmMpSyncData->InsideSmm = FALSE; + ReleaseAllAPs (); + + // + // Wait for all APs to complete their pending tasks + // + WaitForAllAPs (ApCount); + + if (SmmCpuFeaturesNeedConfigureMtrrs()) { + // + // Signal APs to restore MTRRs + // + ReleaseAllAPs (); + + // + // Restore OS MTRRs + // + SmmCpuFeaturesReenableSmrr (); + MtrrSetAllMtrrs(&Mtrrs); + + // + // Wait for all APs to complete MTRR programming + // + WaitForAllAPs (ApCount); + } + + // + // Stop source level debug in BSP handler, the code below will not be + // debugged. + // + InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); + + // + // Signal APs to Reset states/semaphore for this processor + // + ReleaseAllAPs (); + + // + // Perform pending operations for hot-plug + // + SmmCpuUpdate (); + + // + // Clear the Present flag of BSP + // + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; + + // + // Gather APs to exit SMM synchronously. Note the Present flag is cleared by now but + // WaitForAllAps does not depend on the Present flag. + // + WaitForAllAPs (ApCount); + + // + // Reset BspIndex to -1, meaning BSP has not been elected. + // + if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { + mSmmMpSyncData->BspIndex = (UINT32)-1; + } + + // + // Allow APs to check in from this point on + // + *mSmmMpSyncData->Counter = 0; + *mSmmMpSyncData->AllCpusInSync = FALSE; +} + +/** + SMI handler for AP. + + @param CpuIndex AP processor Index. + @param ValidSmi Indicates that current SMI is a valid SMI or not. + @param SyncMode SMM MP sync mode. + +**/ +VOID +APHandler ( + IN UINTN CpuIndex, + IN BOOLEAN ValidSmi, + IN SMM_CPU_SYNC_MODE SyncMode + ) +{ + UINT64 Timer; + UINTN BspIndex; + MTRR_SETTINGS Mtrrs; + + // + // Timeout BSP + // + for (Timer = StartSyncTimer (); + !IsSyncTimerTimeout (Timer) && + !(*mSmmMpSyncData->InsideSmm); + ) { + CpuPause (); + } + + if (!(*mSmmMpSyncData->InsideSmm)) { + // + // BSP timeout in the first round + // + if (mSmmMpSyncData->BspIndex != -1) { + // + // BSP Index is known + // + BspIndex = mSmmMpSyncData->BspIndex; + ASSERT (CpuIndex != BspIndex); + + // + // Send SMI IPI to bring BSP in + // + SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[BspIndex].ProcessorId); + + // + // Now clock BSP for the 2nd time + // + for (Timer = StartSyncTimer (); + !IsSyncTimerTimeout (Timer) && + !(*mSmmMpSyncData->InsideSmm); + ) { + CpuPause (); + } + + if (!(*mSmmMpSyncData->InsideSmm)) { + // + // Give up since BSP is unable to enter SMM + // and signal the completion of this AP + WaitForSemaphore (mSmmMpSyncData->Counter); + return; + } + } else { + // + // Don't know BSP index. Give up without sending IPI to BSP. + // + WaitForSemaphore (mSmmMpSyncData->Counter); + return; + } + } + + // + // BSP is available + // + BspIndex = mSmmMpSyncData->BspIndex; + ASSERT (CpuIndex != BspIndex); + + // + // Mark this processor's presence + // + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; + + if (SyncMode == SmmCpuSyncModeTradition || SmmCpuFeaturesNeedConfigureMtrrs()) { + // + // Notify BSP of arrival at this point + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + } + + if (SmmCpuFeaturesNeedConfigureMtrrs()) { + // + // Wait for the signal from BSP to backup MTRRs + // + WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + // + // Backup OS MTRRs + // + MtrrGetAllMtrrs(&Mtrrs); + + // + // Signal BSP the completion of this AP + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + + // + // Wait for BSP's signal to program MTRRs + // + WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + // + // Replace OS MTRRs with SMI MTRRs + // + ReplaceOSMtrrs (CpuIndex); + + // + // Signal BSP the completion of this AP + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + } + + while (TRUE) { + // + // Wait for something to happen + // + WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + // + // Check if BSP wants to exit SMM + // + if (!(*mSmmMpSyncData->InsideSmm)) { + break; + } + + // + // BUSY should be acquired by SmmStartupThisAp() + // + ASSERT ( + !AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy) + ); + + // + // Invoke the scheduled procedure + // + (*mSmmMpSyncData->CpuData[CpuIndex].Procedure) ( + (VOID*)mSmmMpSyncData->CpuData[CpuIndex].Parameter + ); + + // + // Release BUSY + // + ReleaseSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + } + + if (SmmCpuFeaturesNeedConfigureMtrrs()) { + // + // Notify BSP the readiness of this AP to program MTRRs + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + + // + // Wait for the signal from BSP to program MTRRs + // + WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + // + // Restore OS MTRRs + // + SmmCpuFeaturesReenableSmrr (); + MtrrSetAllMtrrs(&Mtrrs); + } + + // + // Notify BSP the readiness of this AP to Reset states/semaphore for this processor + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + + // + // Wait for the signal from BSP to Reset states/semaphore for this processor + // + WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + // + // Reset states/semaphore for this processor + // + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; + + // + // Notify BSP the readiness of this AP to exit SMM + // + ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); + +} + +/** + Create 4G PageTable in SMRAM. + + @param[in] Is32BitPageTable Whether the page table is 32-bit PAE + @return PageTable Address + +**/ +UINT32 +Gen4GPageTable ( + IN BOOLEAN Is32BitPageTable + ) +{ + VOID *PageTable; + UINTN Index; + UINT64 *Pte; + UINTN PagesNeeded; + UINTN Low2MBoundary; + UINTN High2MBoundary; + UINTN Pages; + UINTN GuardPage; + UINT64 *Pdpte; + UINTN PageIndex; + UINTN PageAddress; + + Low2MBoundary = 0; + High2MBoundary = 0; + PagesNeeded = 0; + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + // + // Add one more page for known good stack, then find the lower 2MB aligned address. + // + Low2MBoundary = (mSmmStackArrayBase + EFI_PAGE_SIZE) & ~(SIZE_2MB-1); + // + // Add two more pages for known good stack and stack guard page, + // then find the lower 2MB aligned address. + // + High2MBoundary = (mSmmStackArrayEnd - mSmmStackSize + EFI_PAGE_SIZE * 2) & ~(SIZE_2MB-1); + PagesNeeded = ((High2MBoundary - Low2MBoundary) / SIZE_2MB) + 1; + } + // + // Allocate the page table + // + PageTable = AllocatePageTableMemory (5 + PagesNeeded); + ASSERT (PageTable != NULL); + + PageTable = (VOID *)((UINTN)PageTable); + Pte = (UINT64*)PageTable; + + // + // Zero out all page table entries first + // + ZeroMem (Pte, EFI_PAGES_TO_SIZE (1)); + + // + // Set Page Directory Pointers + // + for (Index = 0; Index < 4; Index++) { + Pte[Index] = ((UINTN)PageTable + EFI_PAGE_SIZE * (Index + 1)) | mAddressEncMask | + (Is32BitPageTable ? IA32_PAE_PDPTE_ATTRIBUTE_BITS : PAGE_ATTRIBUTE_BITS); + } + Pte += EFI_PAGE_SIZE / sizeof (*Pte); + + // + // Fill in Page Directory Entries + // + for (Index = 0; Index < EFI_PAGE_SIZE * 4 / sizeof (*Pte); Index++) { + Pte[Index] = (Index << 21) | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; + } + + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + Pages = (UINTN)PageTable + EFI_PAGES_TO_SIZE (5); + GuardPage = mSmmStackArrayBase + EFI_PAGE_SIZE; + Pdpte = (UINT64*)PageTable; + for (PageIndex = Low2MBoundary; PageIndex <= High2MBoundary; PageIndex += SIZE_2MB) { + Pte = (UINT64*)(UINTN)(Pdpte[BitFieldRead32 ((UINT32)PageIndex, 30, 31)] & ~mAddressEncMask & ~(EFI_PAGE_SIZE - 1)); + Pte[BitFieldRead32 ((UINT32)PageIndex, 21, 29)] = (UINT64)Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + // + // Fill in Page Table Entries + // + Pte = (UINT64*)Pages; + PageAddress = PageIndex; + for (Index = 0; Index < EFI_PAGE_SIZE / sizeof (*Pte); Index++) { + if (PageAddress == GuardPage) { + // + // Mark the guard page as non-present + // + Pte[Index] = PageAddress | mAddressEncMask; + GuardPage += mSmmStackSize; + if (GuardPage > mSmmStackArrayEnd) { + GuardPage = 0; + } + } else { + Pte[Index] = PageAddress | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + } + PageAddress+= EFI_PAGE_SIZE; + } + Pages += EFI_PAGE_SIZE; + } + } + + return (UINT32)(UINTN)PageTable; +} + +/** + Schedule a procedure to run on the specified CPU. + + @param[in] Procedure The address of the procedure to run + @param[in] CpuIndex Target CPU Index + @param[in, out] ProcArguments The parameter to pass to the procedure + @param[in] BlockingMode Startup AP in blocking mode or not + + @retval EFI_INVALID_PARAMETER CpuNumber not valid + @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy + @retval EFI_SUCCESS The procedure has been successfully scheduled + +**/ +EFI_STATUS +InternalSmmStartupThisAp ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuIndex, + IN OUT VOID *ProcArguments OPTIONAL, + IN BOOLEAN BlockingMode + ) +{ + if (CpuIndex >= gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus) { + DEBUG((DEBUG_ERROR, "CpuIndex(%d) >= gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus(%d)\n", CpuIndex, gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus)); + return EFI_INVALID_PARAMETER; + } + if (CpuIndex == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { + DEBUG((DEBUG_ERROR, "CpuIndex(%d) == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu\n", CpuIndex)); + return EFI_INVALID_PARAMETER; + } + if (!(*(mSmmMpSyncData->CpuData[CpuIndex].Present))) { + if (mSmmMpSyncData->EffectiveSyncMode == SmmCpuSyncModeTradition) { + DEBUG((DEBUG_ERROR, "!mSmmMpSyncData->CpuData[%d].Present\n", CpuIndex)); + } + return EFI_INVALID_PARAMETER; + } + if (gSmmCpuPrivate->Operation[CpuIndex] == SmmCpuRemove) { + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + DEBUG((DEBUG_ERROR, "gSmmCpuPrivate->Operation[%d] == SmmCpuRemove\n", CpuIndex)); + } + return EFI_INVALID_PARAMETER; + } + + if (BlockingMode) { + AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + } else { + if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy)) { + DEBUG((DEBUG_ERROR, "mSmmMpSyncData->CpuData[%d].Busy\n", CpuIndex)); + return EFI_INVALID_PARAMETER; + } + } + + mSmmMpSyncData->CpuData[CpuIndex].Procedure = Procedure; + mSmmMpSyncData->CpuData[CpuIndex].Parameter = ProcArguments; + ReleaseSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); + + if (BlockingMode) { + AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + ReleaseSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + } + return EFI_SUCCESS; +} + +/** + Schedule a procedure to run on the specified CPU in blocking mode. + + @param[in] Procedure The address of the procedure to run + @param[in] CpuIndex Target CPU Index + @param[in, out] ProcArguments The parameter to pass to the procedure + + @retval EFI_INVALID_PARAMETER CpuNumber not valid + @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy + @retval EFI_SUCCESS The procedure has been successfully scheduled + +**/ +EFI_STATUS +EFIAPI +SmmBlockingStartupThisAp ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuIndex, + IN OUT VOID *ProcArguments OPTIONAL + ) +{ + return InternalSmmStartupThisAp(Procedure, CpuIndex, ProcArguments, TRUE); +} + +/** + Schedule a procedure to run on the specified CPU. + + @param Procedure The address of the procedure to run + @param CpuIndex Target CPU Index + @param ProcArguments The parameter to pass to the procedure + + @retval EFI_INVALID_PARAMETER CpuNumber not valid + @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy + @retval EFI_SUCCESS The procedure has been successfully scheduled + +**/ +EFI_STATUS +EFIAPI +SmmStartupThisAp ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuIndex, + IN OUT VOID *ProcArguments OPTIONAL + ) +{ + return InternalSmmStartupThisAp(Procedure, CpuIndex, ProcArguments, FeaturePcdGet (PcdCpuSmmBlockStartupThisAp)); +} + +/** + This function sets DR6 & DR7 according to SMM save state, before running SMM C code. + They are useful when you want to enable hardware breakpoints in SMM without entry SMM mode. + + NOTE: It might not be appreciated in runtime since it might + conflict with OS debugging facilities. Turn them off in RELEASE. + + @param CpuIndex CPU Index + +**/ +VOID +EFIAPI +CpuSmmDebugEntry ( + IN UINTN CpuIndex + ) +{ + SMRAM_SAVE_STATE_MAP *CpuSaveState; + + if (FeaturePcdGet (PcdCpuSmmDebug)) { + ASSERT(CpuIndex < mMaxNumberOfCpus); + CpuSaveState = (SMRAM_SAVE_STATE_MAP *)gSmmCpuPrivate->CpuSaveState[CpuIndex]; + if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { + AsmWriteDr6 (CpuSaveState->x86._DR6); + AsmWriteDr7 (CpuSaveState->x86._DR7); + } else { + AsmWriteDr6 ((UINTN)CpuSaveState->x64._DR6); + AsmWriteDr7 ((UINTN)CpuSaveState->x64._DR7); + } + } +} + +/** + This function restores DR6 & DR7 to SMM save state. + + NOTE: It might not be appreciated in runtime since it might + conflict with OS debugging facilities. Turn them off in RELEASE. + + @param CpuIndex CPU Index + +**/ +VOID +EFIAPI +CpuSmmDebugExit ( + IN UINTN CpuIndex + ) +{ + SMRAM_SAVE_STATE_MAP *CpuSaveState; + + if (FeaturePcdGet (PcdCpuSmmDebug)) { + ASSERT(CpuIndex < mMaxNumberOfCpus); + CpuSaveState = (SMRAM_SAVE_STATE_MAP *)gSmmCpuPrivate->CpuSaveState[CpuIndex]; + if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { + CpuSaveState->x86._DR7 = (UINT32)AsmReadDr7 (); + CpuSaveState->x86._DR6 = (UINT32)AsmReadDr6 (); + } else { + CpuSaveState->x64._DR7 = AsmReadDr7 (); + CpuSaveState->x64._DR6 = AsmReadDr6 (); + } + } +} + +/** + C function for SMI entry, each processor comes here upon SMI trigger. + + @param CpuIndex CPU Index + +**/ +VOID +EFIAPI +SmiRendezvous ( + IN UINTN CpuIndex + ) +{ + EFI_STATUS Status; + BOOLEAN ValidSmi; + BOOLEAN IsBsp; + BOOLEAN BspInProgress; + UINTN Index; + UINTN Cr2; + + ASSERT(CpuIndex < mMaxNumberOfCpus); + + // + // Save Cr2 because Page Fault exception in SMM may override its value + // + Cr2 = AsmReadCr2 (); + + // + // Perform CPU specific entry hooks + // + SmmCpuFeaturesRendezvousEntry (CpuIndex); + + // + // Determine if this is a valid SMI + // + ValidSmi = PlatformValidSmi(); + + // + // Determine if BSP has been already in progress. Note this must be checked after + // ValidSmi because BSP may clear a valid SMI source after checking in. + // + BspInProgress = *mSmmMpSyncData->InsideSmm; + + if (!BspInProgress && !ValidSmi) { + // + // If we reach here, it means when we sampled the ValidSmi flag, SMI status had not + // been cleared by BSP in a new SMI run (so we have a truly invalid SMI), or SMI + // status had been cleared by BSP and an existing SMI run has almost ended. (Note + // we sampled ValidSmi flag BEFORE judging BSP-in-progress status.) In both cases, there + // is nothing we need to do. + // + goto Exit; + } else { + // + // Signal presence of this processor + // + if (ReleaseSemaphore (mSmmMpSyncData->Counter) == 0) { + // + // BSP has already ended the synchronization, so QUIT!!! + // + + // + // Wait for BSP's signal to finish SMI + // + while (*mSmmMpSyncData->AllCpusInSync) { + CpuPause (); + } + goto Exit; + } else { + + // + // The BUSY lock is initialized to Released state. + // This needs to be done early enough to be ready for BSP's SmmStartupThisAp() call. + // E.g., with Relaxed AP flow, SmmStartupThisAp() may be called immediately + // after AP's present flag is detected. + // + InitializeSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + } + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + ActivateSmmProfile (CpuIndex); + } + + if (BspInProgress) { + // + // BSP has been elected. Follow AP path, regardless of ValidSmi flag + // as BSP may have cleared the SMI status + // + APHandler (CpuIndex, ValidSmi, mSmmMpSyncData->EffectiveSyncMode); + } else { + // + // We have a valid SMI + // + + // + // Elect BSP + // + IsBsp = FALSE; + if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { + if (!mSmmMpSyncData->SwitchBsp || mSmmMpSyncData->CandidateBsp[CpuIndex]) { + // + // Call platform hook to do BSP election + // + Status = PlatformSmmBspElection (&IsBsp); + if (EFI_SUCCESS == Status) { + // + // Platform hook determines successfully + // + if (IsBsp) { + mSmmMpSyncData->BspIndex = (UINT32)CpuIndex; + } + } else { + // + // Platform hook fails to determine, use default BSP election method + // + InterlockedCompareExchange32 ( + (UINT32*)&mSmmMpSyncData->BspIndex, + (UINT32)-1, + (UINT32)CpuIndex + ); + } + } + } + + // + // "mSmmMpSyncData->BspIndex == CpuIndex" means this is the BSP + // + if (mSmmMpSyncData->BspIndex == CpuIndex) { + + // + // Clear last request for SwitchBsp. + // + if (mSmmMpSyncData->SwitchBsp) { + mSmmMpSyncData->SwitchBsp = FALSE; + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + mSmmMpSyncData->CandidateBsp[Index] = FALSE; + } + } + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + SmmProfileRecordSmiNum (); + } + + // + // BSP Handler is always called with a ValidSmi == TRUE + // + BSPHandler (CpuIndex, mSmmMpSyncData->EffectiveSyncMode); + } else { + APHandler (CpuIndex, ValidSmi, mSmmMpSyncData->EffectiveSyncMode); + } + } + + ASSERT (*mSmmMpSyncData->CpuData[CpuIndex].Run == 0); + + // + // Wait for BSP's signal to exit SMI + // + while (*mSmmMpSyncData->AllCpusInSync) { + CpuPause (); + } + } + +Exit: + SmmCpuFeaturesRendezvousExit (CpuIndex); + // + // Restore Cr2 + // + AsmWriteCr2 (Cr2); +} + +/** + Allocate buffer for all semaphores and spin locks. + +**/ +VOID +InitializeSmmCpuSemaphores ( + VOID + ) +{ + UINTN ProcessorCount; + UINTN TotalSize; + UINTN GlobalSemaphoresSize; + UINTN CpuSemaphoresSize; + UINTN MsrSemahporeSize; + UINTN SemaphoreSize; + UINTN Pages; + UINTN *SemaphoreBlock; + UINTN SemaphoreAddr; + + SemaphoreSize = GetSpinLockProperties (); + ProcessorCount = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + GlobalSemaphoresSize = (sizeof (SMM_CPU_SEMAPHORE_GLOBAL) / sizeof (VOID *)) * SemaphoreSize; + CpuSemaphoresSize = (sizeof (SMM_CPU_SEMAPHORE_CPU) / sizeof (VOID *)) * ProcessorCount * SemaphoreSize; + MsrSemahporeSize = MSR_SPIN_LOCK_INIT_NUM * SemaphoreSize; + TotalSize = GlobalSemaphoresSize + CpuSemaphoresSize + MsrSemahporeSize; + DEBUG((EFI_D_INFO, "One Semaphore Size = 0x%x\n", SemaphoreSize)); + DEBUG((EFI_D_INFO, "Total Semaphores Size = 0x%x\n", TotalSize)); + Pages = EFI_SIZE_TO_PAGES (TotalSize); + SemaphoreBlock = AllocatePages (Pages); + ASSERT (SemaphoreBlock != NULL); + ZeroMem (SemaphoreBlock, TotalSize); + + SemaphoreAddr = (UINTN)SemaphoreBlock; + mSmmCpuSemaphores.SemaphoreGlobal.Counter = (UINT32 *)SemaphoreAddr; + SemaphoreAddr += SemaphoreSize; + mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm = (BOOLEAN *)SemaphoreAddr; + SemaphoreAddr += SemaphoreSize; + mSmmCpuSemaphores.SemaphoreGlobal.AllCpusInSync = (BOOLEAN *)SemaphoreAddr; + SemaphoreAddr += SemaphoreSize; + mSmmCpuSemaphores.SemaphoreGlobal.PFLock = (SPIN_LOCK *)SemaphoreAddr; + SemaphoreAddr += SemaphoreSize; + mSmmCpuSemaphores.SemaphoreGlobal.CodeAccessCheckLock + = (SPIN_LOCK *)SemaphoreAddr; + SemaphoreAddr += SemaphoreSize; + mSmmCpuSemaphores.SemaphoreGlobal.MemoryMappedLock + = (SPIN_LOCK *)SemaphoreAddr; + + SemaphoreAddr = (UINTN)SemaphoreBlock + GlobalSemaphoresSize; + mSmmCpuSemaphores.SemaphoreCpu.Busy = (SPIN_LOCK *)SemaphoreAddr; + SemaphoreAddr += ProcessorCount * SemaphoreSize; + mSmmCpuSemaphores.SemaphoreCpu.Run = (UINT32 *)SemaphoreAddr; + SemaphoreAddr += ProcessorCount * SemaphoreSize; + mSmmCpuSemaphores.SemaphoreCpu.Present = (BOOLEAN *)SemaphoreAddr; + + SemaphoreAddr = (UINTN)SemaphoreBlock + GlobalSemaphoresSize + CpuSemaphoresSize; + mSmmCpuSemaphores.SemaphoreMsr.Msr = (SPIN_LOCK *)SemaphoreAddr; + mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter = + ((UINTN)SemaphoreBlock + Pages * SIZE_4KB - SemaphoreAddr) / SemaphoreSize; + ASSERT (mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter >= MSR_SPIN_LOCK_INIT_NUM); + + mPFLock = mSmmCpuSemaphores.SemaphoreGlobal.PFLock; + mConfigSmmCodeAccessCheckLock = mSmmCpuSemaphores.SemaphoreGlobal.CodeAccessCheckLock; + mMemoryMappedLock = mSmmCpuSemaphores.SemaphoreGlobal.MemoryMappedLock; + + mSemaphoreSize = SemaphoreSize; +} + +/** + Initialize un-cacheable data. + +**/ +VOID +EFIAPI +InitializeMpSyncData ( + VOID + ) +{ + UINTN CpuIndex; + + if (mSmmMpSyncData != NULL) { + // + // mSmmMpSyncDataSize includes one structure of SMM_DISPATCHER_MP_SYNC_DATA, one + // CpuData array of SMM_CPU_DATA_BLOCK and one CandidateBsp array of BOOLEAN. + // + ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize); + mSmmMpSyncData->CpuData = (SMM_CPU_DATA_BLOCK *)((UINT8 *)mSmmMpSyncData + sizeof (SMM_DISPATCHER_MP_SYNC_DATA)); + mSmmMpSyncData->CandidateBsp = (BOOLEAN *)(mSmmMpSyncData->CpuData + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus); + if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { + // + // Enable BSP election by setting BspIndex to -1 + // + mSmmMpSyncData->BspIndex = (UINT32)-1; + } + mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode; + + mSmmMpSyncData->Counter = mSmmCpuSemaphores.SemaphoreGlobal.Counter; + mSmmMpSyncData->InsideSmm = mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm; + mSmmMpSyncData->AllCpusInSync = mSmmCpuSemaphores.SemaphoreGlobal.AllCpusInSync; + ASSERT (mSmmMpSyncData->Counter != NULL && mSmmMpSyncData->InsideSmm != NULL && + mSmmMpSyncData->AllCpusInSync != NULL); + *mSmmMpSyncData->Counter = 0; + *mSmmMpSyncData->InsideSmm = FALSE; + *mSmmMpSyncData->AllCpusInSync = FALSE; + + for (CpuIndex = 0; CpuIndex < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex ++) { + mSmmMpSyncData->CpuData[CpuIndex].Busy = + (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Busy + mSemaphoreSize * CpuIndex); + mSmmMpSyncData->CpuData[CpuIndex].Run = + (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + mSemaphoreSize * CpuIndex); + mSmmMpSyncData->CpuData[CpuIndex].Present = + (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + mSemaphoreSize * CpuIndex); + *(mSmmMpSyncData->CpuData[CpuIndex].Busy) = 0; + *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0; + *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; + } + } +} + +/** + Initialize global data for MP synchronization. + + @param Stacks Base address of SMI stack buffer for all processors. + @param StackSize Stack size for each processor in SMM. + +**/ +UINT32 +InitializeMpServiceData ( + IN VOID *Stacks, + IN UINTN StackSize + ) +{ + UINT32 Cr3; + UINTN Index; + UINT8 *GdtTssTables; + UINTN GdtTableStepSize; + + // + // Allocate memory for all locks and semaphores + // + InitializeSmmCpuSemaphores (); + + // + // Initialize mSmmMpSyncData + // + mSmmMpSyncDataSize = sizeof (SMM_DISPATCHER_MP_SYNC_DATA) + + (sizeof (SMM_CPU_DATA_BLOCK) + sizeof (BOOLEAN)) * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + mSmmMpSyncData = (SMM_DISPATCHER_MP_SYNC_DATA*) AllocatePages (EFI_SIZE_TO_PAGES (mSmmMpSyncDataSize)); + ASSERT (mSmmMpSyncData != NULL); + mCpuSmmSyncMode = (SMM_CPU_SYNC_MODE)PcdGet8 (PcdCpuSmmSyncMode); + InitializeMpSyncData (); + + // + // Initialize physical address mask + // NOTE: Physical memory above virtual address limit is not supported !!! + // + AsmCpuid (0x80000008, (UINT32*)&Index, NULL, NULL, NULL); + gPhyMask = LShiftU64 (1, (UINT8)Index) - 1; + gPhyMask &= (1ull << 48) - EFI_PAGE_SIZE; + + // + // Create page tables + // + Cr3 = SmmInitPageTable (); + + GdtTssTables = InitGdt (Cr3, &GdtTableStepSize); + + // + // Install SMI handler for each CPU + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + InstallSmiHandler ( + Index, + (UINT32)mCpuHotPlugData.SmBase[Index], + (VOID*)((UINTN)Stacks + (StackSize * Index)), + StackSize, + (UINTN)(GdtTssTables + GdtTableStepSize * Index), + gcSmiGdtr.Limit + 1, + gcSmiIdtr.Base, + gcSmiIdtr.Limit + 1, + Cr3 + ); + } + + // + // Record current MTRR settings + // + ZeroMem (&gSmiMtrrs, sizeof (gSmiMtrrs)); + MtrrGetAllMtrrs (&gSmiMtrrs); + + return Cr3; +} + +/** + + Register the SMM Foundation entry point. + + @param This Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance + @param SmmEntryPoint SMM Foundation EntryPoint + + @retval EFI_SUCCESS Successfully to register SMM foundation entry point + +**/ +EFI_STATUS +EFIAPI +RegisterSmmEntry ( + IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This, + IN EFI_SMM_ENTRY_POINT SmmEntryPoint + ) +{ + // + // Record SMM Foundation EntryPoint, later invoke it on SMI entry vector. + // + gSmmCpuPrivate->SmmCoreEntry = SmmEntryPoint; + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c new file mode 100755 index 0000000000..2cb0bbcff6 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -0,0 +1,1340 @@ +/** @file +Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +// +// SMM CPU Private Data structure that contains SMM Configuration Protocol +// along its supporting fields. +// +SMM_CPU_PRIVATE_DATA mSmmCpuPrivateData = { + SMM_CPU_PRIVATE_DATA_SIGNATURE, // Signature + NULL, // SmmCpuHandle + NULL, // Pointer to ProcessorInfo array + NULL, // Pointer to Operation array + NULL, // Pointer to CpuSaveStateSize array + NULL, // Pointer to CpuSaveState array + { {0} }, // SmmReservedSmramRegion + { + SmmStartupThisAp, // SmmCoreEntryContext.SmmStartupThisAp + 0, // SmmCoreEntryContext.CurrentlyExecutingCpu + 0, // SmmCoreEntryContext.NumberOfCpus + NULL, // SmmCoreEntryContext.CpuSaveStateSize + NULL // SmmCoreEntryContext.CpuSaveState + }, + NULL, // SmmCoreEntry + { + mSmmCpuPrivateData.SmmReservedSmramRegion, // SmmConfiguration.SmramReservedRegions + RegisterSmmEntry // SmmConfiguration.RegisterSmmEntry + }, +}; + +CPU_HOT_PLUG_DATA mCpuHotPlugData = { + CPU_HOT_PLUG_DATA_REVISION_1, // Revision + 0, // Array Length of SmBase and APIC ID + NULL, // Pointer to APIC ID array + NULL, // Pointer to SMBASE array + 0, // Reserved + 0, // SmrrBase + 0 // SmrrSize +}; + +// +// Global pointer used to access mSmmCpuPrivateData from outside and inside SMM +// +SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate = &mSmmCpuPrivateData; + +// +// SMM Relocation variables +// +volatile BOOLEAN *mRebased; +volatile BOOLEAN mIsBsp; + +/// +/// Handle for the SMM CPU Protocol +/// +EFI_HANDLE mSmmCpuHandle = NULL; + +/// +/// SMM CPU Protocol instance +/// +EFI_SMM_CPU_PROTOCOL mSmmCpu = { + SmmReadSaveState, + SmmWriteSaveState +}; + +EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER]; + +// +// SMM stack information +// +UINTN mSmmStackArrayBase; +UINTN mSmmStackArrayEnd; +UINTN mSmmStackSize; + +UINTN mMaxNumberOfCpus = 1; +UINTN mNumberOfCpus = 1; + +// +// SMM ready to lock flag +// +BOOLEAN mSmmReadyToLock = FALSE; + +// +// Global used to cache PCD for SMM Code Access Check enable +// +BOOLEAN mSmmCodeAccessCheckEnable = FALSE; + +// +// Global copy of the PcdPteMemoryEncryptionAddressOrMask +// +UINT64 mAddressEncMask = 0; + +// +// Spin lock used to serialize setting of SMM Code Access Check feature +// +SPIN_LOCK *mConfigSmmCodeAccessCheckLock = NULL; + +// +// Saved SMM ranges information +// +EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; +UINTN mSmmCpuSmramRangeCount; + +/** + Initialize IDT to setup exception handlers for SMM. + +**/ +VOID +InitializeSmmIdt ( + VOID + ) +{ + EFI_STATUS Status; + BOOLEAN InterruptState; + IA32_DESCRIPTOR DxeIdtr; + + // + // There are 32 (not 255) entries in it since only processor + // generated exceptions will be handled. + // + gcSmiIdtr.Limit = (sizeof(IA32_IDT_GATE_DESCRIPTOR) * 32) - 1; + // + // Allocate page aligned IDT, because it might be set as read only. + // + gcSmiIdtr.Base = (UINTN)AllocateCodePages (EFI_SIZE_TO_PAGES(gcSmiIdtr.Limit + 1)); + ASSERT (gcSmiIdtr.Base != 0); + ZeroMem ((VOID *)gcSmiIdtr.Base, gcSmiIdtr.Limit + 1); + + // + // Disable Interrupt and save DXE IDT table + // + InterruptState = SaveAndDisableInterrupts (); + AsmReadIdtr (&DxeIdtr); + // + // Load SMM temporary IDT table + // + AsmWriteIdtr (&gcSmiIdtr); + // + // Setup SMM default exception handlers, SMM IDT table + // will be updated and saved in gcSmiIdtr + // + Status = InitializeCpuExceptionHandlers (NULL); + ASSERT_EFI_ERROR (Status); + // + // Restore DXE IDT table and CPU interrupt + // + AsmWriteIdtr ((IA32_DESCRIPTOR *) &DxeIdtr); + SetInterruptState (InterruptState); +} + +/** + Search module name by input IP address and output it. + + @param CallerIpAddress Caller instruction pointer. + +**/ +VOID +DumpModuleInfoByIp ( + IN UINTN CallerIpAddress + ) +{ + UINTN Pe32Data; + VOID *PdbPointer; + + // + // Find Image Base + // + Pe32Data = PeCoffSerachImageBase (CallerIpAddress); + if (Pe32Data != 0) { + DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *) CallerIpAddress)); + PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data); + if (PdbPointer != NULL) { + DEBUG ((DEBUG_ERROR, " in module (%a)\n", PdbPointer)); + } + } +} + +/** + Read information from the CPU save state. + + @param This EFI_SMM_CPU_PROTOCOL instance + @param Width The number of bytes to read from the CPU save state. + @param Register Specifies the CPU register to read form the save state. + @param CpuIndex Specifies the zero-based index of the CPU save state. + @param Buffer Upon return, this holds the CPU register value read from the save state. + + @retval EFI_SUCCESS The register was read from Save State + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor + @retval EFI_INVALID_PARAMTER This or Buffer is NULL. + +**/ +EFI_STATUS +EFIAPI +SmmReadSaveState ( + IN CONST EFI_SMM_CPU_PROTOCOL *This, + IN UINTN Width, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN CpuIndex, + OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + + // + // Retrieve pointer to the specified CPU's SMM Save State buffer + // + if ((CpuIndex >= gSmst->NumberOfCpus) || (Buffer == NULL)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check for special EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID) { + // + // The pseudo-register only supports the 64-bit size specified by Width. + // + if (Width != sizeof (UINT64)) { + return EFI_INVALID_PARAMETER; + } + // + // If the processor is in SMM at the time the SMI occurred, + // the pseudo register value for EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID is returned in Buffer. + // Otherwise, EFI_NOT_FOUND is returned. + // + if (*(mSmmMpSyncData->CpuData[CpuIndex].Present)) { + *(UINT64 *)Buffer = gSmmCpuPrivate->ProcessorInfo[CpuIndex].ProcessorId; + return EFI_SUCCESS; + } else { + return EFI_NOT_FOUND; + } + } + + if (!(*(mSmmMpSyncData->CpuData[CpuIndex].Present))) { + return EFI_INVALID_PARAMETER; + } + + Status = SmmCpuFeaturesReadSaveStateRegister (CpuIndex, Register, Width, Buffer); + if (Status == EFI_UNSUPPORTED) { + Status = ReadSaveStateRegister (CpuIndex, Register, Width, Buffer); + } + return Status; +} + +/** + Write data to the CPU save state. + + @param This EFI_SMM_CPU_PROTOCOL instance + @param Width The number of bytes to read from the CPU save state. + @param Register Specifies the CPU register to write to the save state. + @param CpuIndex Specifies the zero-based index of the CPU save state + @param Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written from Save State + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor + @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct + +**/ +EFI_STATUS +EFIAPI +SmmWriteSaveState ( + IN CONST EFI_SMM_CPU_PROTOCOL *This, + IN UINTN Width, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN CpuIndex, + IN CONST VOID *Buffer + ) +{ + EFI_STATUS Status; + + // + // Retrieve pointer to the specified CPU's SMM Save State buffer + // + if ((CpuIndex >= gSmst->NumberOfCpus) || (Buffer == NULL)) { + return EFI_INVALID_PARAMETER; + } + + // + // Writes to EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID are ignored + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID) { + return EFI_SUCCESS; + } + + if (!mSmmMpSyncData->CpuData[CpuIndex].Present) { + return EFI_INVALID_PARAMETER; + } + + Status = SmmCpuFeaturesWriteSaveStateRegister (CpuIndex, Register, Width, Buffer); + if (Status == EFI_UNSUPPORTED) { + Status = WriteSaveStateRegister (CpuIndex, Register, Width, Buffer); + } + return Status; +} + + +/** + C function for SMI handler. To change all processor's SMMBase Register. + +**/ +VOID +EFIAPI +SmmInitHandler ( + VOID + ) +{ + UINT32 ApicId; + UINTN Index; + + // + // Update SMM IDT entries' code segment and load IDT + // + AsmWriteIdtr (&gcSmiIdtr); + ApicId = GetApicId (); + + ASSERT (mNumberOfCpus <= mMaxNumberOfCpus); + + for (Index = 0; Index < mNumberOfCpus; Index++) { + if (ApicId == (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId) { + // + // Initialize SMM specific features on the currently executing CPU + // + SmmCpuFeaturesInitializeProcessor ( + Index, + mIsBsp, + gSmmCpuPrivate->ProcessorInfo, + &mCpuHotPlugData + ); + + if (!mSmmS3Flag) { + // + // Check XD and BTS features on each processor on normal boot + // + CheckFeatureSupported (); + } + + if (mIsBsp) { + // + // BSP rebase is already done above. + // Initialize private data during S3 resume + // + InitializeMpSyncData (); + } + + // + // Hook return after RSM to set SMM re-based flag + // + SemaphoreHook (Index, &mRebased[Index]); + + return; + } + } + ASSERT (FALSE); +} + +/** + Relocate SmmBases for each processor. + + Execute on first boot and all S3 resumes + +**/ +VOID +EFIAPI +SmmRelocateBases ( + VOID + ) +{ + UINT8 BakBuf[BACK_BUF_SIZE]; + SMRAM_SAVE_STATE_MAP BakBuf2; + SMRAM_SAVE_STATE_MAP *CpuStatePtr; + UINT8 *U8Ptr; + UINT32 ApicId; + UINTN Index; + UINTN BspIndex; + + // + // Make sure the reserved size is large enough for procedure SmmInitTemplate. + // + ASSERT (sizeof (BakBuf) >= gcSmmInitSize); + + // + // Patch ASM code template with current CR0, CR3, and CR4 values + // + gSmmCr0 = (UINT32)AsmReadCr0 (); + gSmmCr3 = (UINT32)AsmReadCr3 (); + gSmmCr4 = (UINT32)AsmReadCr4 (); + + // + // Patch GDTR for SMM base relocation + // + gcSmiInitGdtr.Base = gcSmiGdtr.Base; + gcSmiInitGdtr.Limit = gcSmiGdtr.Limit; + + U8Ptr = (UINT8*)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET); + CpuStatePtr = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); + + // + // Backup original contents at address 0x38000 + // + CopyMem (BakBuf, U8Ptr, sizeof (BakBuf)); + CopyMem (&BakBuf2, CpuStatePtr, sizeof (BakBuf2)); + + // + // Load image for relocation + // + CopyMem (U8Ptr, gcSmmInitTemplate, gcSmmInitSize); + + // + // Retrieve the local APIC ID of current processor + // + ApicId = GetApicId (); + + // + // Relocate SM bases for all APs + // This is APs' 1st SMI - rebase will be done here, and APs' default SMI handler will be overridden by gcSmmInitTemplate + // + mIsBsp = FALSE; + BspIndex = (UINTN)-1; + for (Index = 0; Index < mNumberOfCpus; Index++) { + mRebased[Index] = FALSE; + if (ApicId != (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId) { + SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId); + // + // Wait for this AP to finish its 1st SMI + // + while (!mRebased[Index]); + } else { + // + // BSP will be Relocated later + // + BspIndex = Index; + } + } + + // + // Relocate BSP's SMM base + // + ASSERT (BspIndex != (UINTN)-1); + mIsBsp = TRUE; + SendSmiIpi (ApicId); + // + // Wait for the BSP to finish its 1st SMI + // + while (!mRebased[BspIndex]); + + // + // Restore contents at address 0x38000 + // + CopyMem (CpuStatePtr, &BakBuf2, sizeof (BakBuf2)); + CopyMem (U8Ptr, BakBuf, sizeof (BakBuf)); +} + +/** + SMM Ready To Lock event notification handler. + + The CPU S3 data is copied to SMRAM for security and mSmmReadyToLock is set to + perform additional lock actions that must be performed from SMM on the next SMI. + + @param[in] Protocol Points to the protocol's unique identifier. + @param[in] Interface Points to the interface instance. + @param[in] Handle The handle on which the interface was installed. + + @retval EFI_SUCCESS Notification handler runs successfully. + **/ +EFI_STATUS +EFIAPI +SmmReadyToLockEventNotify ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + GetAcpiCpuData (); + + // + // Cache a copy of UEFI memory map before we start profiling feature. + // + GetUefiMemoryMap (); + + // + // Set SMM ready to lock flag and return + // + mSmmReadyToLock = TRUE; + return EFI_SUCCESS; +} + +/** + The module Entry Point of the CPU SMM driver. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +EFIAPI +PiCpuSmmEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpServices; + UINTN NumberOfEnabledProcessors; + UINTN Index; + VOID *Buffer; + UINTN BufferPages; + UINTN TileCodeSize; + UINTN TileDataSize; + UINTN TileSize; + UINT8 *Stacks; + VOID *Registration; + UINT32 RegEax; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + UINT32 Cr3; + + // + // Initialize Debug Agent to support source level debug in SMM code + // + InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, NULL, NULL); + + // + // Report the start of CPU SMM initialization. + // + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_SMM_INIT + ); + + // + // Fix segment address of the long-mode-switch jump + // + if (sizeof (UINTN) == sizeof (UINT64)) { + gSmmJmpAddr.Segment = LONG_MODE_CODE_SEGMENT; + } + + // + // Find out SMRR Base and SMRR Size + // + FindSmramInfo (&mCpuHotPlugData.SmrrBase, &mCpuHotPlugData.SmrrSize); + + // + // Get MP Services Protocol + // + Status = SystemTable->BootServices->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpServices); + ASSERT_EFI_ERROR (Status); + + // + // Use MP Services Protocol to retrieve the number of processors and number of enabled processors + // + Status = MpServices->GetNumberOfProcessors (MpServices, &mNumberOfCpus, &NumberOfEnabledProcessors); + ASSERT_EFI_ERROR (Status); + ASSERT (mNumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); + + // + // If support CPU hot plug, PcdCpuSmmEnableBspElection should be set to TRUE. + // A constant BSP index makes no sense because it may be hot removed. + // + DEBUG_CODE ( + if (FeaturePcdGet (PcdCpuHotPlugSupport)) { + + ASSERT (FeaturePcdGet (PcdCpuSmmEnableBspElection)); + } + ); + + // + // Save the PcdCpuSmmCodeAccessCheckEnable value into a global variable. + // + mSmmCodeAccessCheckEnable = PcdGetBool (PcdCpuSmmCodeAccessCheckEnable); + DEBUG ((EFI_D_INFO, "PcdCpuSmmCodeAccessCheckEnable = %d\n", mSmmCodeAccessCheckEnable)); + + // + // Save the PcdPteMemoryEncryptionAddressOrMask value into a global variable. + // Make sure AddressEncMask is contained to smallest supported address field. + // + mAddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + DEBUG ((EFI_D_INFO, "mAddressEncMask = 0x%lx\n", mAddressEncMask)); + + // + // If support CPU hot plug, we need to allocate resources for possibly hot-added processors + // + if (FeaturePcdGet (PcdCpuHotPlugSupport)) { + mMaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + } else { + mMaxNumberOfCpus = mNumberOfCpus; + } + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus = mMaxNumberOfCpus; + + // + // The CPU save state and code for the SMI entry point are tiled within an SMRAM + // allocated buffer. The minimum size of this buffer for a uniprocessor system + // is 32 KB, because the entry point is SMBASE + 32KB, and CPU save state area + // just below SMBASE + 64KB. If more than one CPU is present in the platform, + // then the SMI entry point and the CPU save state areas can be tiles to minimize + // the total amount SMRAM required for all the CPUs. The tile size can be computed + // by adding the // CPU save state size, any extra CPU specific context, and + // the size of code that must be placed at the SMI entry point to transfer + // control to a C function in the native SMM execution mode. This size is + // rounded up to the nearest power of 2 to give the tile size for a each CPU. + // The total amount of memory required is the maximum number of CPUs that + // platform supports times the tile size. The picture below shows the tiling, + // where m is the number of tiles that fit in 32KB. + // + // +-----------------------------+ <-- 2^n offset from Base of allocated buffer + // | CPU m+1 Save State | + // +-----------------------------+ + // | CPU m+1 Extra Data | + // +-----------------------------+ + // | Padding | + // +-----------------------------+ + // | CPU 2m SMI Entry | + // +#############################+ <-- Base of allocated buffer + 64 KB + // | CPU m-1 Save State | + // +-----------------------------+ + // | CPU m-1 Extra Data | + // +-----------------------------+ + // | Padding | + // +-----------------------------+ + // | CPU 2m-1 SMI Entry | + // +=============================+ <-- 2^n offset from Base of allocated buffer + // | . . . . . . . . . . . . | + // +=============================+ <-- 2^n offset from Base of allocated buffer + // | CPU 2 Save State | + // +-----------------------------+ + // | CPU 2 Extra Data | + // +-----------------------------+ + // | Padding | + // +-----------------------------+ + // | CPU m+1 SMI Entry | + // +=============================+ <-- Base of allocated buffer + 32 KB + // | CPU 1 Save State | + // +-----------------------------+ + // | CPU 1 Extra Data | + // +-----------------------------+ + // | Padding | + // +-----------------------------+ + // | CPU m SMI Entry | + // +#############################+ <-- Base of allocated buffer + 32 KB == CPU 0 SMBASE + 64 KB + // | CPU 0 Save State | + // +-----------------------------+ + // | CPU 0 Extra Data | + // +-----------------------------+ + // | Padding | + // +-----------------------------+ + // | CPU m-1 SMI Entry | + // +=============================+ <-- 2^n offset from Base of allocated buffer + // | . . . . . . . . . . . . | + // +=============================+ <-- 2^n offset from Base of allocated buffer + // | Padding | + // +-----------------------------+ + // | CPU 1 SMI Entry | + // +=============================+ <-- 2^n offset from Base of allocated buffer + // | Padding | + // +-----------------------------+ + // | CPU 0 SMI Entry | + // +#############################+ <-- Base of allocated buffer == CPU 0 SMBASE + 32 KB + // + + // + // Retrieve CPU Family + // + AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL); + FamilyId = (RegEax >> 8) & 0xf; + ModelId = (RegEax >> 4) & 0xf; + if (FamilyId == 0x06 || FamilyId == 0x0f) { + ModelId = ModelId | ((RegEax >> 12) & 0xf0); + } + + RegEdx = 0; + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax >= CPUID_EXTENDED_CPU_SIG) { + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + } + // + // Determine the mode of the CPU at the time an SMI occurs + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 34.4.1.1 + // + mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT; + if ((RegEdx & BIT29) != 0) { + mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; + } + if (FamilyId == 0x06) { + if (ModelId == 0x17 || ModelId == 0x0f || ModelId == 0x1c) { + mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; + } + } + + // + // Compute tile size of buffer required to hold the CPU SMRAM Save State Map, extra CPU + // specific context start starts at SMBASE + SMM_PSD_OFFSET, and the SMI entry point. + // This size is rounded up to nearest power of 2. + // + TileCodeSize = GetSmiHandlerSize (); + TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB); + TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP); + TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB); + TileSize = TileDataSize + TileCodeSize - 1; + TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize); + DEBUG ((EFI_D_INFO, "SMRAM TileSize = 0x%08x (0x%08x, 0x%08x)\n", TileSize, TileCodeSize, TileDataSize)); + + // + // If the TileSize is larger than space available for the SMI Handler of + // CPU[i], the extra CPU specific context of CPU[i+1], and the SMRAM Save + // State Map of CPU[i+1], then ASSERT(). If this ASSERT() is triggered, then + // the SMI Handler size must be reduced or the size of the extra CPU specific + // context must be reduced. + // + ASSERT (TileSize <= (SMRAM_SAVE_STATE_MAP_OFFSET + sizeof (SMRAM_SAVE_STATE_MAP) - SMM_HANDLER_OFFSET)); + + // + // Allocate buffer for all of the tiles. + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 34.11 SMBASE Relocation + // For Pentium and Intel486 processors, the SMBASE values must be + // aligned on a 32-KByte boundary or the processor will enter shutdown + // state during the execution of a RSM instruction. + // + // Intel486 processors: FamilyId is 4 + // Pentium processors : FamilyId is 5 + // + BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1)); + if ((FamilyId == 4) || (FamilyId == 5)) { + Buffer = AllocateAlignedCodePages (BufferPages, SIZE_32KB); + } else { + Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); + } + ASSERT (Buffer != NULL); + DEBUG ((EFI_D_INFO, "SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE(BufferPages))); + + // + // Allocate buffer for pointers to array in SMM_CPU_PRIVATE_DATA. + // + gSmmCpuPrivate->ProcessorInfo = (EFI_PROCESSOR_INFORMATION *)AllocatePool (sizeof (EFI_PROCESSOR_INFORMATION) * mMaxNumberOfCpus); + ASSERT (gSmmCpuPrivate->ProcessorInfo != NULL); + + gSmmCpuPrivate->Operation = (SMM_CPU_OPERATION *)AllocatePool (sizeof (SMM_CPU_OPERATION) * mMaxNumberOfCpus); + ASSERT (gSmmCpuPrivate->Operation != NULL); + + gSmmCpuPrivate->CpuSaveStateSize = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); + ASSERT (gSmmCpuPrivate->CpuSaveStateSize != NULL); + + gSmmCpuPrivate->CpuSaveState = (VOID **)AllocatePool (sizeof (VOID *) * mMaxNumberOfCpus); + ASSERT (gSmmCpuPrivate->CpuSaveState != NULL); + + mSmmCpuPrivateData.SmmCoreEntryContext.CpuSaveStateSize = gSmmCpuPrivate->CpuSaveStateSize; + mSmmCpuPrivateData.SmmCoreEntryContext.CpuSaveState = gSmmCpuPrivate->CpuSaveState; + + // + // Allocate buffer for pointers to array in CPU_HOT_PLUG_DATA. + // + mCpuHotPlugData.ApicId = (UINT64 *)AllocatePool (sizeof (UINT64) * mMaxNumberOfCpus); + ASSERT (mCpuHotPlugData.ApicId != NULL); + mCpuHotPlugData.SmBase = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); + ASSERT (mCpuHotPlugData.SmBase != NULL); + mCpuHotPlugData.ArrayLength = (UINT32)mMaxNumberOfCpus; + + // + // Retrieve APIC ID of each enabled processor from the MP Services protocol. + // Also compute the SMBASE address, CPU Save State address, and CPU Save state + // size for each CPU in the platform + // + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + mCpuHotPlugData.SmBase[Index] = (UINTN)Buffer + Index * TileSize - SMM_HANDLER_OFFSET; + gSmmCpuPrivate->CpuSaveStateSize[Index] = sizeof(SMRAM_SAVE_STATE_MAP); + gSmmCpuPrivate->CpuSaveState[Index] = (VOID *)(mCpuHotPlugData.SmBase[Index] + SMRAM_SAVE_STATE_MAP_OFFSET); + gSmmCpuPrivate->Operation[Index] = SmmCpuNone; + + if (Index < mNumberOfCpus) { + Status = MpServices->GetProcessorInfo (MpServices, Index, &gSmmCpuPrivate->ProcessorInfo[Index]); + ASSERT_EFI_ERROR (Status); + mCpuHotPlugData.ApicId[Index] = gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId; + + DEBUG ((EFI_D_INFO, "CPU[%03x] APIC ID=%04x SMBASE=%08x SaveState=%08x Size=%08x\n", + Index, + (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId, + mCpuHotPlugData.SmBase[Index], + gSmmCpuPrivate->CpuSaveState[Index], + gSmmCpuPrivate->CpuSaveStateSize[Index] + )); + } else { + gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = INVALID_APIC_ID; + mCpuHotPlugData.ApicId[Index] = INVALID_APIC_ID; + } + } + + // + // Allocate SMI stacks for all processors. + // + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + // + // 2 more pages is allocated for each processor. + // one is guard page and the other is known good stack. + // + // +-------------------------------------------+-----+-------------------------------------------+ + // | Known Good Stack | Guard Page | SMM Stack | ... | Known Good Stack | Guard Page | SMM Stack | + // +-------------------------------------------+-----+-------------------------------------------+ + // | | | | + // |<-------------- Processor 0 -------------->| |<-------------- Processor n -------------->| + // + mSmmStackSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStackSize)) + 2); + Stacks = (UINT8 *) AllocatePages (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStackSize)) + 2)); + ASSERT (Stacks != NULL); + mSmmStackArrayBase = (UINTN)Stacks; + mSmmStackArrayEnd = mSmmStackArrayBase + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * mSmmStackSize - 1; + } else { + mSmmStackSize = PcdGet32 (PcdCpuSmmStackSize); + Stacks = (UINT8 *) AllocatePages (EFI_SIZE_TO_PAGES (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * mSmmStackSize)); + ASSERT (Stacks != NULL); + } + + // + // Set SMI stack for SMM base relocation + // + gSmmInitStack = (UINTN) (Stacks + mSmmStackSize - sizeof (UINTN)); + + // + // Initialize IDT + // + InitializeSmmIdt (); + + // + // Relocate SMM Base addresses to the ones allocated from SMRAM + // + mRebased = (BOOLEAN *)AllocateZeroPool (sizeof (BOOLEAN) * mMaxNumberOfCpus); + ASSERT (mRebased != NULL); + SmmRelocateBases (); + + // + // Call hook for BSP to perform extra actions in normal mode after all + // SMM base addresses have been relocated on all CPUs + // + SmmCpuFeaturesSmmRelocationComplete (); + + DEBUG ((DEBUG_INFO, "mXdSupported - 0x%x\n", mXdSupported)); + + // + // SMM Time initialization + // + InitializeSmmTimer (); + + // + // Initialize MP globals + // + Cr3 = InitializeMpServiceData (Stacks, mSmmStackSize); + + // + // Fill in SMM Reserved Regions + // + gSmmCpuPrivate->SmmReservedSmramRegion[0].SmramReservedStart = 0; + gSmmCpuPrivate->SmmReservedSmramRegion[0].SmramReservedSize = 0; + + // + // Install the SMM Configuration Protocol onto a new handle on the handle database. + // The entire SMM Configuration Protocol is allocated from SMRAM, so only a pointer + // to an SMRAM address will be present in the handle database + // + Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces ( + &gSmmCpuPrivate->SmmCpuHandle, + &gEfiSmmConfigurationProtocolGuid, &gSmmCpuPrivate->SmmConfiguration, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // + // Install the SMM CPU Protocol into SMM protocol database + // + Status = gSmst->SmmInstallProtocolInterface ( + &mSmmCpuHandle, + &gEfiSmmCpuProtocolGuid, + EFI_NATIVE_INTERFACE, + &mSmmCpu + ); + ASSERT_EFI_ERROR (Status); + + // + // Expose address of CPU Hot Plug Data structure if CPU hot plug is supported. + // + if (FeaturePcdGet (PcdCpuHotPlugSupport)) { + Status = PcdSet64S (PcdCpuHotPlugDataAddress, (UINT64)(UINTN)&mCpuHotPlugData); + ASSERT_EFI_ERROR (Status); + } + + // + // Initialize SMM CPU Services Support + // + Status = InitializeSmmCpuServices (mSmmCpuHandle); + ASSERT_EFI_ERROR (Status); + + // + // register SMM Ready To Lock Protocol notification + // + Status = gSmst->SmmRegisterProtocolNotify ( + &gEfiSmmReadyToLockProtocolGuid, + SmmReadyToLockEventNotify, + &Registration + ); + ASSERT_EFI_ERROR (Status); + + // + // Initialize SMM Profile feature + // + InitSmmProfile (Cr3); + + GetAcpiS3EnableFlag (); + InitSmmS3ResumeState (Cr3); + + DEBUG ((EFI_D_INFO, "SMM CPU Module exit from SMRAM with EFI_SUCCESS\n")); + + return EFI_SUCCESS; +} + +/** + + Find out SMRAM information including SMRR base and SMRR size. + + @param SmrrBase SMRR base + @param SmrrSize SMRR size + +**/ +VOID +FindSmramInfo ( + OUT UINT32 *SmrrBase, + OUT UINT32 *SmrrSize + ) +{ + EFI_STATUS Status; + UINTN Size; + EFI_SMM_ACCESS2_PROTOCOL *SmmAccess; + EFI_SMRAM_DESCRIPTOR *CurrentSmramRange; + UINTN Index; + UINT64 MaxSize; + BOOLEAN Found; + + // + // Get SMM Access Protocol + // + Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess); + ASSERT_EFI_ERROR (Status); + + // + // Get SMRAM information + // + Size = 0; + Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + + mSmmCpuSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size); + ASSERT (mSmmCpuSmramRanges != NULL); + + Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmmCpuSmramRanges); + ASSERT_EFI_ERROR (Status); + + mSmmCpuSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR); + + // + // Find the largest SMRAM range between 1MB and 4GB that is at least 256K - 4K in size + // + CurrentSmramRange = NULL; + for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < mSmmCpuSmramRangeCount; Index++) { + // + // Skip any SMRAM region that is already allocated, needs testing, or needs ECC initialization + // + if ((mSmmCpuSmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) { + continue; + } + + if (mSmmCpuSmramRanges[Index].CpuStart >= BASE_1MB) { + if ((mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) <= SMRR_MAX_ADDRESS) { + if (mSmmCpuSmramRanges[Index].PhysicalSize >= MaxSize) { + MaxSize = mSmmCpuSmramRanges[Index].PhysicalSize; + CurrentSmramRange = &mSmmCpuSmramRanges[Index]; + } + } + } + } + + ASSERT (CurrentSmramRange != NULL); + + *SmrrBase = (UINT32)CurrentSmramRange->CpuStart; + *SmrrSize = (UINT32)CurrentSmramRange->PhysicalSize; + + do { + Found = FALSE; + for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { + if (mSmmCpuSmramRanges[Index].CpuStart < *SmrrBase && + *SmrrBase == (mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize)) { + *SmrrBase = (UINT32)mSmmCpuSmramRanges[Index].CpuStart; + *SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize); + Found = TRUE; + } else if ((*SmrrBase + *SmrrSize) == mSmmCpuSmramRanges[Index].CpuStart && mSmmCpuSmramRanges[Index].PhysicalSize > 0) { + *SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize); + Found = TRUE; + } + } + } while (Found); + + DEBUG ((EFI_D_INFO, "SMRR Base: 0x%x, SMRR Size: 0x%x\n", *SmrrBase, *SmrrSize)); +} + +/** +Configure SMM Code Access Check feature on an AP. +SMM Feature Control MSR will be locked after configuration. + +@param[in,out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +ConfigSmmCodeAccessCheckOnCurrentProcessor ( + IN OUT VOID *Buffer + ) +{ + UINTN CpuIndex; + UINT64 SmmFeatureControlMsr; + UINT64 NewSmmFeatureControlMsr; + + // + // Retrieve the CPU Index from the context passed in + // + CpuIndex = *(UINTN *)Buffer; + + // + // Get the current SMM Feature Control MSR value + // + SmmFeatureControlMsr = SmmCpuFeaturesGetSmmRegister (CpuIndex, SmmRegFeatureControl); + + // + // Compute the new SMM Feature Control MSR value + // + NewSmmFeatureControlMsr = SmmFeatureControlMsr; + if (mSmmCodeAccessCheckEnable) { + NewSmmFeatureControlMsr |= SMM_CODE_CHK_EN_BIT; + if (FeaturePcdGet (PcdCpuSmmFeatureControlMsrLock)) { + NewSmmFeatureControlMsr |= SMM_FEATURE_CONTROL_LOCK_BIT; + } + } + + // + // Only set the SMM Feature Control MSR value if the new value is different than the current value + // + if (NewSmmFeatureControlMsr != SmmFeatureControlMsr) { + SmmCpuFeaturesSetSmmRegister (CpuIndex, SmmRegFeatureControl, NewSmmFeatureControlMsr); + } + + // + // Release the spin lock user to serialize the updates to the SMM Feature Control MSR + // + ReleaseSpinLock (mConfigSmmCodeAccessCheckLock); +} + +/** +Configure SMM Code Access Check feature for all processors. +SMM Feature Control MSR will be locked after configuration. +**/ +VOID +ConfigSmmCodeAccessCheck ( + VOID + ) +{ + UINTN Index; + EFI_STATUS Status; + + // + // Check to see if the Feature Control MSR is supported on this CPU + // + Index = gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu; + if (!SmmCpuFeaturesIsSmmRegisterSupported (Index, SmmRegFeatureControl)) { + mSmmCodeAccessCheckEnable = FALSE; + return; + } + + // + // Check to see if the CPU supports the SMM Code Access Check feature + // Do not access this MSR unless the CPU supports the SmmRegFeatureControl + // + if ((AsmReadMsr64 (EFI_MSR_SMM_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) == 0) { + mSmmCodeAccessCheckEnable = FALSE; + return; + } + + // + // Initialize the lock used to serialize the MSR programming in BSP and all APs + // + InitializeSpinLock (mConfigSmmCodeAccessCheckLock); + + // + // Acquire Config SMM Code Access Check spin lock. The BSP will release the + // spin lock when it is done executing ConfigSmmCodeAccessCheckOnCurrentProcessor(). + // + AcquireSpinLock (mConfigSmmCodeAccessCheckLock); + + // + // Enable SMM Code Access Check feature on the BSP. + // + ConfigSmmCodeAccessCheckOnCurrentProcessor (&Index); + + // + // Enable SMM Code Access Check feature for the APs. + // + for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { + if (Index != gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { + + // + // Acquire Config SMM Code Access Check spin lock. The AP will release the + // spin lock when it is done executing ConfigSmmCodeAccessCheckOnCurrentProcessor(). + // + AcquireSpinLock (mConfigSmmCodeAccessCheckLock); + + // + // Call SmmStartupThisAp() to enable SMM Code Access Check on an AP. + // + Status = gSmst->SmmStartupThisAp (ConfigSmmCodeAccessCheckOnCurrentProcessor, Index, &Index); + ASSERT_EFI_ERROR (Status); + + // + // Wait for the AP to release the Config SMM Code Access Check spin lock. + // + while (!AcquireSpinLockOrFail (mConfigSmmCodeAccessCheckLock)) { + CpuPause (); + } + + // + // Release the Config SMM Code Access Check spin lock. + // + ReleaseSpinLock (mConfigSmmCodeAccessCheckLock); + } + } +} + +/** + This API provides a way to allocate memory for page table. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ) +{ + VOID *Buffer; + + Buffer = SmmCpuFeaturesAllocatePageTableMemory (Pages); + if (Buffer != NULL) { + return Buffer; + } + return AllocatePages (Pages); +} + +/** + Allocate pages for code. + + @param[in] Pages Number of pages to be allocated. + + @return Allocated memory. +**/ +VOID * +AllocateCodePages ( + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + + if (Pages == 0) { + return NULL; + } + + Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + return (VOID *) (UINTN) Memory; +} + +/** + Allocate aligned pages for code. + + @param[in] Pages Number of pages to be allocated. + @param[in] Alignment The requested alignment of the allocation. + Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return Allocated memory. +**/ +VOID * +AllocateAlignedCodePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + UINTN AlignedMemory; + UINTN AlignmentMask; + UINTN UnalignedPages; + UINTN RealPages; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + if (Alignment > EFI_PAGE_SIZE) { + // + // Calculate the total number of pages since alignment is larger than page size. + // + AlignmentMask = Alignment - 1; + RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment); + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (RealPages > Pages); + + Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, RealPages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask; + UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory); + if (UnalignedPages > 0) { + // + // Free first unaligned page(s). + // + Status = gSmst->SmmFreePages (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages); + UnalignedPages = RealPages - Pages - UnalignedPages; + if (UnalignedPages > 0) { + // + // Free last unaligned page(s). + // + Status = gSmst->SmmFreePages (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + } else { + // + // Do not over-allocate pages in this case. + // + Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = (UINTN) Memory; + } + return (VOID *) AlignedMemory; +} + +/** + Perform the remaining tasks. + +**/ +VOID +PerformRemainingTasks ( + VOID + ) +{ + if (mSmmReadyToLock) { + // + // Start SMM Profile feature + // + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + SmmProfileStart (); + } + // + // Create a mix of 2MB and 4KB page table. Update some memory ranges absent and execute-disable. + // + InitPaging (); + + // + // Mark critical region to be read-only in page table + // + SetMemMapAttributes (); + + // + // For outside SMRAM, we only map SMM communication buffer or MMIO. + // + SetUefiMemMapAttributes (); + + // + // Set page table itself to be read-only + // + SetPageTableAttributes (); + + // + // Configure SMM Code Access Check feature if available. + // + ConfigSmmCodeAccessCheck (); + + SmmCpuFeaturesCompleteSmmReadyToLock (); + + // + // Clean SMM ready to lock flag + // + mSmmReadyToLock = FALSE; + } +} + +/** + Perform the pre tasks. + +**/ +VOID +PerformPreTasks ( + VOID + ) +{ + RestoreSmmConfigurationInS3 (); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h new file mode 100644 index 0000000000..dbce9ec520 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -0,0 +1,1070 @@ +/** @file +Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _CPU_PISMMCPUDXESMM_H_ +#define _CPU_PISMMCPUDXESMM_H_ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "CpuService.h" +#include "SmmProfile.h" + +// +// MSRs required for configuration of SMM Code Access Check +// +#define EFI_MSR_SMM_MCA_CAP 0x17D +#define SMM_CODE_ACCESS_CHK_BIT BIT58 + +#define SMM_FEATURE_CONTROL_LOCK_BIT BIT0 +#define SMM_CODE_CHK_EN_BIT BIT2 + +/// +/// Page Table Entry +/// +#define IA32_PG_P BIT0 +#define IA32_PG_RW BIT1 +#define IA32_PG_U BIT2 +#define IA32_PG_WT BIT3 +#define IA32_PG_CD BIT4 +#define IA32_PG_A BIT5 +#define IA32_PG_D BIT6 +#define IA32_PG_PS BIT7 +#define IA32_PG_PAT_2M BIT12 +#define IA32_PG_PAT_4K IA32_PG_PS +#define IA32_PG_PMNT BIT62 +#define IA32_PG_NX BIT63 + +#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P) +// +// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE +// X64 PAE PDPTE does not have such restriction +// +#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) + +#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS) + +#define PAGING_4K_MASK 0xFFF +#define PAGING_2M_MASK 0x1FFFFF +#define PAGING_1G_MASK 0x3FFFFFFF + +#define PAGING_PAE_INDEX_MASK 0x1FF + +#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull +#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull +#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull + +#define SMRR_MAX_ADDRESS BASE_4GB + +typedef enum { + PageNone, + Page4K, + Page2M, + Page1G, +} PAGE_ATTRIBUTE; + +typedef struct { + PAGE_ATTRIBUTE Attribute; + UINT64 Length; + UINT64 AddressMask; +} PAGE_ATTRIBUTE_TABLE; + +// +// Size of Task-State Segment defined in IA32 Manual +// +#define TSS_SIZE 104 +#define TSS_X64_IST1_OFFSET 36 +#define TSS_IA32_CR3_OFFSET 28 +#define TSS_IA32_ESP_OFFSET 56 + +#define CR0_WP BIT16 + +// +// Code select value +// +#define PROTECT_MODE_CODE_SEGMENT 0x08 +#define LONG_MODE_CODE_SEGMENT 0x38 + +// +// The size 0x20 must be bigger than +// the size of template code of SmmInit. Currently, +// the size of SmmInit requires the 0x16 Bytes buffer +// at least. +// +#define BACK_BUF_SIZE 0x20 + +#define EXCEPTION_VECTOR_NUMBER 0x20 + +#define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL + +typedef UINT32 SMM_CPU_ARRIVAL_EXCEPTIONS; +#define ARRIVAL_EXCEPTION_BLOCKED 0x1 +#define ARRIVAL_EXCEPTION_DELAYED 0x2 +#define ARRIVAL_EXCEPTION_SMI_DISABLED 0x4 + +// +// Private structure for the SMM CPU module that is stored in DXE Runtime memory +// Contains the SMM Configuration Protocols that is produced. +// Contains a mix of DXE and SMM contents. All the fields must be used properly. +// +#define SMM_CPU_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('s', 'c', 'p', 'u') + +typedef struct { + UINTN Signature; + + EFI_HANDLE SmmCpuHandle; + + EFI_PROCESSOR_INFORMATION *ProcessorInfo; + SMM_CPU_OPERATION *Operation; + UINTN *CpuSaveStateSize; + VOID **CpuSaveState; + + EFI_SMM_RESERVED_SMRAM_REGION SmmReservedSmramRegion[1]; + EFI_SMM_ENTRY_CONTEXT SmmCoreEntryContext; + EFI_SMM_ENTRY_POINT SmmCoreEntry; + + EFI_SMM_CONFIGURATION_PROTOCOL SmmConfiguration; +} SMM_CPU_PRIVATE_DATA; + +extern SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate; +extern CPU_HOT_PLUG_DATA mCpuHotPlugData; +extern UINTN mMaxNumberOfCpus; +extern UINTN mNumberOfCpus; +extern EFI_SMM_CPU_PROTOCOL mSmmCpu; + +/// +/// The mode of the CPU at the time an SMI occurs +/// +extern UINT8 mSmmSaveStateRegisterLma; + +// +// SMM CPU Protocol function prototypes. +// + +/** + Read information from the CPU save state. + + @param This EFI_SMM_CPU_PROTOCOL instance + @param Width The number of bytes to read from the CPU save state. + @param Register Specifies the CPU register to read form the save state. + @param CpuIndex Specifies the zero-based index of the CPU save state + @param Buffer Upon return, this holds the CPU register value read from the save state. + + @retval EFI_SUCCESS The register was read from Save State + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor + @retval EFI_INVALID_PARAMTER This or Buffer is NULL. + +**/ +EFI_STATUS +EFIAPI +SmmReadSaveState ( + IN CONST EFI_SMM_CPU_PROTOCOL *This, + IN UINTN Width, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN CpuIndex, + OUT VOID *Buffer + ); + +/** + Write data to the CPU save state. + + @param This EFI_SMM_CPU_PROTOCOL instance + @param Width The number of bytes to read from the CPU save state. + @param Register Specifies the CPU register to write to the save state. + @param CpuIndex Specifies the zero-based index of the CPU save state + @param Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written from Save State + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor + @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct + +**/ +EFI_STATUS +EFIAPI +SmmWriteSaveState ( + IN CONST EFI_SMM_CPU_PROTOCOL *This, + IN UINTN Width, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN CpuIndex, + IN CONST VOID *Buffer + ); + +/** +Read a CPU Save State register on the target processor. + +This function abstracts the differences that whether the CPU Save State register is in the +IA32 CPU Save State Map or X64 CPU Save State Map. + +This function supports reading a CPU Save State register in SMBase relocation handler. + +@param[in] CpuIndex Specifies the zero-based index of the CPU save state. +@param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. +@param[in] Width The number of bytes to read from the CPU save state. +@param[out] Buffer Upon return, this holds the CPU register value read from the save state. + +@retval EFI_SUCCESS The register was read from Save State. +@retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. +@retval EFI_INVALID_PARAMTER This or Buffer is NULL. + +**/ +EFI_STATUS +EFIAPI +ReadSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ); + +/** +Write value to a CPU Save State register on the target processor. + +This function abstracts the differences that whether the CPU Save State register is in the +IA32 CPU Save State Map or X64 CPU Save State Map. + +This function supports writing a CPU Save State register in SMBase relocation handler. + +@param[in] CpuIndex Specifies the zero-based index of the CPU save state. +@param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. +@param[in] Width The number of bytes to read from the CPU save state. +@param[in] Buffer Upon entry, this holds the new CPU register value. + +@retval EFI_SUCCESS The register was written to Save State. +@retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. +@retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct. + +**/ +EFI_STATUS +EFIAPI +WriteSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ); + +// +// +// +typedef struct { + UINT32 Offset; + UINT16 Segment; + UINT16 Reserved; +} IA32_FAR_ADDRESS; + +extern IA32_FAR_ADDRESS gSmmJmpAddr; + +extern CONST UINT8 gcSmmInitTemplate[]; +extern CONST UINT16 gcSmmInitSize; +extern UINT32 gSmmCr0; +extern UINT32 gSmmCr3; +extern UINT32 gSmmCr4; +extern UINTN gSmmInitStack; + +/** + Semaphore operation for all processor relocate SMMBase. +**/ +VOID +EFIAPI +SmmRelocationSemaphoreComplete ( + VOID + ); + +/// +/// The type of SMM CPU Information +/// +typedef struct { + SPIN_LOCK *Busy; + volatile EFI_AP_PROCEDURE Procedure; + volatile VOID *Parameter; + volatile UINT32 *Run; + volatile BOOLEAN *Present; +} SMM_CPU_DATA_BLOCK; + +typedef enum { + SmmCpuSyncModeTradition, + SmmCpuSyncModeRelaxedAp, + SmmCpuSyncModeMax +} SMM_CPU_SYNC_MODE; + +typedef struct { + // + // Pointer to an array. The array should be located immediately after this structure + // so that UC cache-ability can be set together. + // + SMM_CPU_DATA_BLOCK *CpuData; + volatile UINT32 *Counter; + volatile UINT32 BspIndex; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; + volatile SMM_CPU_SYNC_MODE EffectiveSyncMode; + volatile BOOLEAN SwitchBsp; + volatile BOOLEAN *CandidateBsp; +} SMM_DISPATCHER_MP_SYNC_DATA; + +#define MSR_SPIN_LOCK_INIT_NUM 15 + +typedef struct { + SPIN_LOCK *SpinLock; + UINT32 MsrIndex; +} MP_MSR_LOCK; + +#define SMM_PSD_OFFSET 0xfb00 + +/// +/// All global semaphores' pointer +/// +typedef struct { + volatile UINT32 *Counter; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; + SPIN_LOCK *PFLock; + SPIN_LOCK *CodeAccessCheckLock; + SPIN_LOCK *MemoryMappedLock; +} SMM_CPU_SEMAPHORE_GLOBAL; + +/// +/// All semaphores for each processor +/// +typedef struct { + SPIN_LOCK *Busy; + volatile UINT32 *Run; + volatile BOOLEAN *Present; +} SMM_CPU_SEMAPHORE_CPU; + +/// +/// All MSRs semaphores' pointer and counter +/// +typedef struct { + SPIN_LOCK *Msr; + UINTN AvailableCounter; +} SMM_CPU_SEMAPHORE_MSR; + +/// +/// All semaphores' information +/// +typedef struct { + SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal; + SMM_CPU_SEMAPHORE_CPU SemaphoreCpu; + SMM_CPU_SEMAPHORE_MSR SemaphoreMsr; +} SMM_CPU_SEMAPHORES; + +extern IA32_DESCRIPTOR gcSmiGdtr; +extern EFI_PHYSICAL_ADDRESS mGdtBuffer; +extern UINTN mGdtBufferSize; +extern IA32_DESCRIPTOR gcSmiIdtr; +extern VOID *gcSmiIdtrPtr; +extern UINT64 gPhyMask; +extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData; +extern UINTN mSmmStackArrayBase; +extern UINTN mSmmStackArrayEnd; +extern UINTN mSmmStackSize; +extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService; +extern IA32_DESCRIPTOR gcSmiInitGdtr; +extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores; +extern UINTN mSemaphoreSize; +extern SPIN_LOCK *mPFLock; +extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock; +extern SPIN_LOCK *mMemoryMappedLock; +extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; +extern UINTN mSmmCpuSmramRangeCount; + +// +// Copy of the PcdPteMemoryEncryptionAddressOrMask +// +extern UINT64 mAddressEncMask; + +/** + Create 4G PageTable in SMRAM. + + @param[in] Is32BitPageTable Whether the page table is 32-bit PAE + @return PageTable Address + +**/ +UINT32 +Gen4GPageTable ( + IN BOOLEAN Is32BitPageTable + ); + + +/** + Initialize global data for MP synchronization. + + @param Stacks Base address of SMI stack buffer for all processors. + @param StackSize Stack size for each processor in SMM. + +**/ +UINT32 +InitializeMpServiceData ( + IN VOID *Stacks, + IN UINTN StackSize + ); + +/** + Initialize Timer for SMM AP Sync. + +**/ +VOID +InitializeSmmTimer ( + VOID + ); + +/** + Start Timer for SMM AP Sync. + +**/ +UINT64 +EFIAPI +StartSyncTimer ( + VOID + ); + +/** + Check if the SMM AP Sync timer is timeout. + + @param Timer The start timer from the begin. + +**/ +BOOLEAN +EFIAPI +IsSyncTimerTimeout ( + IN UINT64 Timer + ); + +/** + Initialize IDT for SMM Stack Guard. + +**/ +VOID +EFIAPI +InitializeIDTSmmStackGuard ( + VOID + ); + +/** + Initialize Gdt for all processors. + + @param[in] Cr3 CR3 value. + @param[out] GdtStepSize The step size for GDT table. + + @return GdtBase for processor 0. + GdtBase for processor X is: GdtBase + (GdtStepSize * X) +**/ +VOID * +InitGdt ( + IN UINTN Cr3, + OUT UINTN *GdtStepSize + ); + +/** + This function sets GDT/IDT buffer to be RO and XP. +**/ +VOID +PatchGdtIdtMap ( + VOID + ); + +/** + + Register the SMM Foundation entry point. + + @param This Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance + @param SmmEntryPoint SMM Foundation EntryPoint + + @retval EFI_SUCCESS Successfully to register SMM foundation entry point + +**/ +EFI_STATUS +EFIAPI +RegisterSmmEntry ( + IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This, + IN EFI_SMM_ENTRY_POINT SmmEntryPoint + ); + +/** + Create PageTable for SMM use. + + @return PageTable Address + +**/ +UINT32 +SmmInitPageTable ( + VOID + ); + +/** + Schedule a procedure to run on the specified CPU. + + @param Procedure The address of the procedure to run + @param CpuIndex Target CPU number + @param ProcArguments The parameter to pass to the procedure + + @retval EFI_INVALID_PARAMETER CpuNumber not valid + @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy + @retval EFI_SUCCESS - The procedure has been successfully scheduled + +**/ +EFI_STATUS +EFIAPI +SmmStartupThisAp ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuIndex, + IN OUT VOID *ProcArguments OPTIONAL + ); + +/** + Schedule a procedure to run on the specified CPU in a blocking fashion. + + @param Procedure The address of the procedure to run + @param CpuIndex Target CPU Index + @param ProcArguments The parameter to pass to the procedure + + @retval EFI_INVALID_PARAMETER CpuNumber not valid + @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM + @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy + @retval EFI_SUCCESS The procedure has been successfully scheduled + +**/ +EFI_STATUS +EFIAPI +SmmBlockingStartupThisAp ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuIndex, + IN OUT VOID *ProcArguments OPTIONAL + ); + +/** + This function sets the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to set for the memory region. + + @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmSetMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ); + +/** + This function clears the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to clear for the memory region. + + @retval EFI_SUCCESS The attributes were cleared for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmClearMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ); + +/** + Initialize MP synchronization data. + +**/ +VOID +EFIAPI +InitializeMpSyncData ( + VOID + ); + +/** + + Find out SMRAM information including SMRR base and SMRR size. + + @param SmrrBase SMRR base + @param SmrrSize SMRR size + +**/ +VOID +FindSmramInfo ( + OUT UINT32 *SmrrBase, + OUT UINT32 *SmrrSize + ); + +/** + Relocate SmmBases for each processor. + + Execute on first boot and all S3 resumes + +**/ +VOID +EFIAPI +SmmRelocateBases ( + VOID + ); + +/** + Page Fault handler for SMM use. + + @param InterruptType Defines the type of interrupt or exception that + occurred on the processor.This parameter is processor architecture specific. + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. +**/ +VOID +EFIAPI +SmiPFHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_SYSTEM_CONTEXT SystemContext + ); + +/** + Perform the remaining tasks. + +**/ +VOID +PerformRemainingTasks ( + VOID + ); + +/** + Perform the pre tasks. + +**/ +VOID +PerformPreTasks ( + VOID + ); + +/** + Initialize MSR spin lock by MSR index. + + @param MsrIndex MSR index value. + +**/ +VOID +InitMsrSpinLockByIndex ( + IN UINT32 MsrIndex + ); + +/** + Hook return address of SMM Save State so that semaphore code + can be executed immediately after AP exits SMM to indicate to + the BSP that an AP has exited SMM after SMBASE relocation. + + @param[in] CpuIndex The processor index. + @param[in] RebasedFlag A pointer to a flag that is set to TRUE + immediately after AP exits SMM. + +**/ +VOID +SemaphoreHook ( + IN UINTN CpuIndex, + IN volatile BOOLEAN *RebasedFlag + ); + +/** +Configure SMM Code Access Check feature for all processors. +SMM Feature Control MSR will be locked after configuration. +**/ +VOID +ConfigSmmCodeAccessCheck ( + VOID + ); + +/** + Hook the code executed immediately after an RSM instruction on the currently + executing CPU. The mode of code executed immediately after RSM must be + detected, and the appropriate hook must be selected. Always clear the auto + HALT restart flag if it is set. + + @param[in] CpuIndex The processor index for the currently + executing CPU. + @param[in] CpuState Pointer to SMRAM Save State Map for the + currently executing CPU. + @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to + 32-bit mode from 64-bit SMM. + @param[in] NewInstructionPointer Instruction pointer to use if resuming to + same mode as SMM. + + @retval The value of the original instruction pointer before it was hooked. + +**/ +UINT64 +EFIAPI +HookReturnFromSmm ( + IN UINTN CpuIndex, + SMRAM_SAVE_STATE_MAP *CpuState, + UINT64 NewInstructionPointer32, + UINT64 NewInstructionPointer + ); + +/** + Get the size of the SMI Handler in bytes. + + @retval The size, in bytes, of the SMI Handler. + +**/ +UINTN +EFIAPI +GetSmiHandlerSize ( + VOID + ); + +/** + Install the SMI handler for the CPU specified by CpuIndex. This function + is called by the CPU that was elected as monarch during System Management + Mode initialization. + + @param[in] CpuIndex The index of the CPU to install the custom SMI handler. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. + @param[in] SmiStack The stack to use when an SMI is processed by the + the CPU specified by CpuIndex. + @param[in] StackSize The size, in bytes, if the stack used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtBase The base address of the GDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtBase The base address of the IDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] Cr3 The base address of the page tables to use when an SMI + is processed by the CPU specified by CpuIndex. +**/ +VOID +EFIAPI +InstallSmiHandler ( + IN UINTN CpuIndex, + IN UINT32 SmBase, + IN VOID *SmiStack, + IN UINTN StackSize, + IN UINTN GdtBase, + IN UINTN GdtSize, + IN UINTN IdtBase, + IN UINTN IdtSize, + IN UINT32 Cr3 + ); + +/** + Search module name by input IP address and output it. + + @param CallerIpAddress Caller instruction pointer. + +**/ +VOID +DumpModuleInfoByIp ( + IN UINTN CallerIpAddress + ); + +/** + This function sets memory attribute according to MemoryAttributesTable. +**/ +VOID +SetMemMapAttributes ( + VOID + ); + +/** + This function sets UEFI memory attribute according to UEFI memory map. +**/ +VOID +SetUefiMemMapAttributes ( + VOID + ); + +/** + Return if the Address is forbidden as SMM communication buffer. + + @param[in] Address the address to be checked + + @return TRUE The address is forbidden as SMM communication buffer. + @return FALSE The address is allowed as SMM communication buffer. +**/ +BOOLEAN +IsSmmCommBufferForbiddenAddress ( + IN UINT64 Address + ); + +/** + This function caches the UEFI memory map information. +**/ +VOID +GetUefiMemoryMap ( + VOID + ); + +/** + This function sets memory attribute for page table. +**/ +VOID +SetPageTableAttributes ( + VOID + ); + +/** + Return page table base. + + @return page table base. +**/ +UINTN +GetPageTableBase ( + VOID + ); + +/** + This function sets the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to set for the memory region. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + + @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmSetMemoryAttributesEx ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + OUT BOOLEAN *IsSplitted OPTIONAL + ); + +/** + This function clears the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to clear for the memory region. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + + @retval EFI_SUCCESS The attributes were cleared for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmClearMemoryAttributesEx ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + OUT BOOLEAN *IsSplitted OPTIONAL + ); + +/** + This API provides a way to allocate memory for page table. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ); + +/** + Allocate pages for code. + + @param[in] Pages Number of pages to be allocated. + + @return Allocated memory. +**/ +VOID * +AllocateCodePages ( + IN UINTN Pages + ); + +/** + Allocate aligned pages for code. + + @param[in] Pages Number of pages to be allocated. + @param[in] Alignment The requested alignment of the allocation. + Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return Allocated memory. +**/ +VOID * +AllocateAlignedCodePages ( + IN UINTN Pages, + IN UINTN Alignment + ); + + +// +// S3 related global variable and function prototype. +// + +extern BOOLEAN mSmmS3Flag; + +/** + Initialize SMM S3 resume state structure used during S3 Resume. + + @param[in] Cr3 The base address of the page tables to use in SMM. + +**/ +VOID +InitSmmS3ResumeState ( + IN UINT32 Cr3 + ); + +/** + Get ACPI CPU data. + +**/ +VOID +GetAcpiCpuData ( + VOID + ); + +/** + Restore SMM Configuration in S3 boot path. + +**/ +VOID +RestoreSmmConfigurationInS3 ( + VOID + ); + +/** + Get ACPI S3 enable flag. + +**/ +VOID +GetAcpiS3EnableFlag ( + VOID + ); + +/** + Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. + + @param[in] ApHltLoopCode The address of the safe hlt-loop function. + @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. + @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. + +**/ +VOID +TransferApToSafeState ( + IN UINTN ApHltLoopCode, + IN UINTN TopOfStack, + IN UINTN NumberToFinishAddress + ); + +#endif diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf new file mode 100644 index 0000000000..099792e6ce --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf @@ -0,0 +1,167 @@ +## @file +# CPU SMM driver. +# +# This SMM driver performs SMM initialization, deploy SMM Entry Vector, +# provides CPU specific services in SMM. +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PiSmmCpuDxeSmm + MODULE_UNI_FILE = PiSmmCpuDxeSmm.uni + FILE_GUID = A3FF0EF5-0C28-42f5-B544-8C7DE1E80014 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x0001000A + ENTRY_POINT = PiCpuSmmEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + PiSmmCpuDxeSmm.c + PiSmmCpuDxeSmm.h + MpService.c + SyncTimer.c + CpuS3.c + CpuService.c + CpuService.h + SmmProfile.c + SmmProfile.h + SmmProfileInternal.h + SmramSaveState.c + SmmCpuMemoryManagement.c + +[Sources.Ia32] + Ia32/Semaphore.c + Ia32/PageTbl.c + Ia32/SmmFuncsArch.c + Ia32/SmmProfileArch.c + Ia32/SmmProfileArch.h + Ia32/SmmInit.asm + Ia32/SmiEntry.asm + Ia32/SmiException.asm + Ia32/MpFuncs.asm + + Ia32/SmmInit.nasm + Ia32/SmiEntry.nasm + Ia32/SmiException.nasm + Ia32/MpFuncs.nasm + + Ia32/SmmInit.S + Ia32/SmiEntry.S + Ia32/SmiException.S + Ia32/MpFuncs.S + +[Sources.X64] + X64/Semaphore.c + X64/PageTbl.c + X64/SmmFuncsArch.c + X64/SmmProfileArch.c + X64/SmmProfileArch.h + X64/SmmInit.asm + X64/SmiEntry.asm + X64/SmiException.asm + X64/MpFuncs.asm + + X64/SmmInit.nasm + X64/SmiEntry.nasm + X64/SmiException.nasm + X64/MpFuncs.nasm + + X64/SmmInit.S + X64/SmiEntry.S + X64/SmiException.S + X64/MpFuncs.S + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + UefiRuntimeServicesTableLib + CacheMaintenanceLib + PcdLib + DebugLib + BaseLib + SynchronizationLib + BaseMemoryLib + MtrrLib + IoLib + TimerLib + SmmServicesTableLib + MemoryAllocationLib + DebugAgentLib + HobLib + PciLib + LocalApicLib + UefiCpuLib + SmmCpuPlatformHookLib + CpuExceptionHandlerLib + UefiLib + DxeServicesTableLib + CpuLib + ReportStatusCodeLib + SmmCpuFeaturesLib + PeCoffGetEntryPointLib + +[Protocols] + gEfiSmmAccess2ProtocolGuid ## CONSUMES + gEfiMpServiceProtocolGuid ## CONSUMES + gEfiSmmConfigurationProtocolGuid ## PRODUCES + gEfiSmmCpuProtocolGuid ## PRODUCES + gEfiSmmReadyToLockProtocolGuid ## NOTIFY + gEfiSmmCpuServiceProtocolGuid ## PRODUCES + +[Guids] + gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot. + gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"SmmProfileData" + gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEdkiiPiSmmMemoryAttributesTableGuid ## CONSUMES ## SystemTable + +[FeaturePcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileEnable ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock ## CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## SOMETIMES_CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## SOMETIMES_PRODUCES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode ## CONSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStaticPageTable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES + +[Depex] + gEfiMpServiceProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + PiSmmCpuDxeSmmExtra.uni diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni new file mode 100644 index 0000000000..98eae1d697 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni @@ -0,0 +1,21 @@ +// /** @file +// CPU SMM driver. +// +// This SMM driver performs SMM initialization, deploy SMM Entry Vector, +// provides CPU specific services in SMM. +// +// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "CPU SMM driver" + +#string STR_MODULE_DESCRIPTION #language en-US "This SMM driver performs SMM initialization, deploys SMM Entry Vector, and provides CPU-specific services in SMM." diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni new file mode 100644 index 0000000000..d0a8d54006 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni @@ -0,0 +1,18 @@ +// /** @file +// PiSmmCpuDxeSmm Localized Strings and Content +// +// Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"Processor SMM Initialization DXE Driver" diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c new file mode 100644 index 0000000000..a535389c26 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -0,0 +1,1103 @@ +/** @file + +Copyright (c) 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \ + ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size))) + +#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \ + ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size))) + +EFI_MEMORY_DESCRIPTOR *mUefiMemoryMap; +UINTN mUefiMemoryMapSize; +UINTN mUefiDescriptorSize; + +PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = { + {Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64}, + {Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64}, + {Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64}, +}; + +/** + Return page table base. + + @return page table base. +**/ +UINTN +GetPageTableBase ( + VOID + ) +{ + return (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64); +} + +/** + Return length according to page attributes. + + @param[in] PageAttributes The page attribute of the page entry. + + @return The length of page entry. +**/ +UINTN +PageAttributeToLength ( + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINTN Index; + for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { + if (PageAttribute == mPageAttributeTable[Index].Attribute) { + return (UINTN)mPageAttributeTable[Index].Length; + } + } + return 0; +} + +/** + Return address mask according to page attributes. + + @param[in] PageAttributes The page attribute of the page entry. + + @return The address mask of page entry. +**/ +UINTN +PageAttributeToMask ( + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINTN Index; + for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { + if (PageAttribute == mPageAttributeTable[Index].Attribute) { + return (UINTN)mPageAttributeTable[Index].AddressMask; + } + } + return 0; +} + +/** + Return page table entry to match the address. + + @param[in] Address The address to be checked. + @param[out] PageAttributes The page attribute of the page entry. + + @return The page entry. +**/ +VOID * +GetPageTableEntry ( + IN PHYSICAL_ADDRESS Address, + OUT PAGE_ATTRIBUTE *PageAttribute + ) +{ + UINTN Index1; + UINTN Index2; + UINTN Index3; + UINTN Index4; + UINT64 *L1PageTable; + UINT64 *L2PageTable; + UINT64 *L3PageTable; + UINT64 *L4PageTable; + + Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK; + Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK; + Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK; + Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK; + + if (sizeof(UINTN) == sizeof(UINT64)) { + L4PageTable = (UINT64 *)GetPageTableBase (); + if (L4PageTable[Index4] == 0) { + *PageAttribute = PageNone; + return NULL; + } + + L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + } else { + L3PageTable = (UINT64 *)GetPageTableBase (); + } + if (L3PageTable[Index3] == 0) { + *PageAttribute = PageNone; + return NULL; + } + if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { + // 1G + *PageAttribute = Page1G; + return &L3PageTable[Index3]; + } + + L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L2PageTable[Index2] == 0) { + *PageAttribute = PageNone; + return NULL; + } + if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { + // 2M + *PageAttribute = Page2M; + return &L2PageTable[Index2]; + } + + // 4k + L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if ((L1PageTable[Index1] == 0) && (Address != 0)) { + *PageAttribute = PageNone; + return NULL; + } + *PageAttribute = Page4K; + return &L1PageTable[Index1]; +} + +/** + Return memory attributes of page entry. + + @param[in] PageEntry The page entry. + + @return Memory attributes of page entry. +**/ +UINT64 +GetAttributesFromPageEntry ( + IN UINT64 *PageEntry + ) +{ + UINT64 Attributes; + Attributes = 0; + if ((*PageEntry & IA32_PG_P) == 0) { + Attributes |= EFI_MEMORY_RP; + } + if ((*PageEntry & IA32_PG_RW) == 0) { + Attributes |= EFI_MEMORY_RO; + } + if ((*PageEntry & IA32_PG_NX) != 0) { + Attributes |= EFI_MEMORY_XP; + } + return Attributes; +} + +/** + Modify memory attributes of page entry. + + @param[in] PageEntry The page entry. + @param[in] Attributes The bit mask of attributes to modify for the memory region. + @param[in] IsSet TRUE means to set attributes. FALSE means to clear attributes. + @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. +**/ +VOID +ConvertPageEntryAttribute ( + IN UINT64 *PageEntry, + IN UINT64 Attributes, + IN BOOLEAN IsSet, + OUT BOOLEAN *IsModified + ) +{ + UINT64 CurrentPageEntry; + UINT64 NewPageEntry; + + CurrentPageEntry = *PageEntry; + NewPageEntry = CurrentPageEntry; + if ((Attributes & EFI_MEMORY_RP) != 0) { + if (IsSet) { + NewPageEntry &= ~(UINT64)IA32_PG_P; + } else { + NewPageEntry |= IA32_PG_P; + } + } + if ((Attributes & EFI_MEMORY_RO) != 0) { + if (IsSet) { + NewPageEntry &= ~(UINT64)IA32_PG_RW; + } else { + NewPageEntry |= IA32_PG_RW; + } + } + if ((Attributes & EFI_MEMORY_XP) != 0) { + if (mXdSupported) { + if (IsSet) { + NewPageEntry |= IA32_PG_NX; + } else { + NewPageEntry &= ~IA32_PG_NX; + } + } + } + *PageEntry = NewPageEntry; + if (CurrentPageEntry != NewPageEntry) { + *IsModified = TRUE; + DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry)); + DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry)); + } else { + *IsModified = FALSE; + } +} + +/** + This function returns if there is need to split page entry. + + @param[in] BaseAddress The base address to be checked. + @param[in] Length The length to be checked. + @param[in] PageEntry The page entry to be checked. + @param[in] PageAttribute The page attribute of the page entry. + + @retval SplitAttributes on if there is need to split page entry. +**/ +PAGE_ATTRIBUTE +NeedSplitPage ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 *PageEntry, + IN PAGE_ATTRIBUTE PageAttribute + ) +{ + UINT64 PageEntryLength; + + PageEntryLength = PageAttributeToLength (PageAttribute); + + if (((BaseAddress & (PageEntryLength - 1)) == 0) && (Length >= PageEntryLength)) { + return PageNone; + } + + if (((BaseAddress & PAGING_2M_MASK) != 0) || (Length < SIZE_2MB)) { + return Page4K; + } + + return Page2M; +} + +/** + This function splits one page entry to small page entries. + + @param[in] PageEntry The page entry to be splitted. + @param[in] PageAttribute The page attribute of the page entry. + @param[in] SplitAttribute How to split the page entry. + + @retval RETURN_SUCCESS The page entry is splitted. + @retval RETURN_UNSUPPORTED The page entry does not support to be splitted. + @retval RETURN_OUT_OF_RESOURCES No resource to split page entry. +**/ +RETURN_STATUS +SplitPage ( + IN UINT64 *PageEntry, + IN PAGE_ATTRIBUTE PageAttribute, + IN PAGE_ATTRIBUTE SplitAttribute + ) +{ + UINT64 BaseAddress; + UINT64 *NewPageEntry; + UINTN Index; + + ASSERT (PageAttribute == Page2M || PageAttribute == Page1G); + + if (PageAttribute == Page2M) { + // + // Split 2M to 4K + // + ASSERT (SplitAttribute == Page4K); + if (SplitAttribute == Page4K) { + NewPageEntry = AllocatePageTableMemory (1); + DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry)); + if (NewPageEntry == NULL) { + return RETURN_OUT_OF_RESOURCES; + } + BaseAddress = *PageEntry & PAGING_2M_ADDRESS_MASK_64; + for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { + NewPageEntry[Index] = (BaseAddress + SIZE_4KB * Index) | mAddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); + } + (*PageEntry) = (UINT64)(UINTN)NewPageEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + return RETURN_SUCCESS; + } else { + return RETURN_UNSUPPORTED; + } + } else if (PageAttribute == Page1G) { + // + // Split 1G to 2M + // No need support 1G->4K directly, we should use 1G->2M, then 2M->4K to get more compact page table. + // + ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K); + if ((SplitAttribute == Page2M || SplitAttribute == Page4K)) { + NewPageEntry = AllocatePageTableMemory (1); + DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry)); + if (NewPageEntry == NULL) { + return RETURN_OUT_OF_RESOURCES; + } + BaseAddress = *PageEntry & PAGING_1G_ADDRESS_MASK_64; + for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { + NewPageEntry[Index] = (BaseAddress + SIZE_2MB * Index) | mAddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS); + } + (*PageEntry) = (UINT64)(UINTN)NewPageEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + return RETURN_SUCCESS; + } else { + return RETURN_UNSUPPORTED; + } + } else { + return RETURN_UNSUPPORTED; + } +} + +/** + This function modifies the page attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + Caller should make sure BaseAddress and Length is at page boundary. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to modify for the memory region. + @param[in] IsSet TRUE means to set attributes. FALSE means to clear attributes. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. + + @retval RETURN_SUCCESS The attributes were modified for the memory region. + @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval RETURN_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. +**/ +RETURN_STATUS +EFIAPI +ConvertMemoryPageAttributes ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN BOOLEAN IsSet, + OUT BOOLEAN *IsSplitted, OPTIONAL + OUT BOOLEAN *IsModified OPTIONAL + ) +{ + UINT64 *PageEntry; + PAGE_ATTRIBUTE PageAttribute; + UINTN PageEntryLength; + PAGE_ATTRIBUTE SplitAttribute; + RETURN_STATUS Status; + BOOLEAN IsEntryModified; + + ASSERT (Attributes != 0); + ASSERT ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) == 0); + + ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); + ASSERT ((Length & (SIZE_4KB - 1)) == 0); + + if (Length == 0) { + return RETURN_INVALID_PARAMETER; + } + +// DEBUG ((DEBUG_ERROR, "ConvertMemoryPageAttributes(%x) - %016lx, %016lx, %02lx\n", IsSet, BaseAddress, Length, Attributes)); + + if (IsSplitted != NULL) { + *IsSplitted = FALSE; + } + if (IsModified != NULL) { + *IsModified = FALSE; + } + + // + // Below logic is to check 2M/4K page to make sure we donot waist memory. + // + while (Length != 0) { + PageEntry = GetPageTableEntry (BaseAddress, &PageAttribute); + if (PageEntry == NULL) { + return RETURN_UNSUPPORTED; + } + PageEntryLength = PageAttributeToLength (PageAttribute); + SplitAttribute = NeedSplitPage (BaseAddress, Length, PageEntry, PageAttribute); + if (SplitAttribute == PageNone) { + ConvertPageEntryAttribute (PageEntry, Attributes, IsSet, &IsEntryModified); + if (IsEntryModified) { + if (IsModified != NULL) { + *IsModified = TRUE; + } + } + // + // Convert success, move to next + // + BaseAddress += PageEntryLength; + Length -= PageEntryLength; + } else { + Status = SplitPage (PageEntry, PageAttribute, SplitAttribute); + if (RETURN_ERROR (Status)) { + return RETURN_UNSUPPORTED; + } + if (IsSplitted != NULL) { + *IsSplitted = TRUE; + } + if (IsModified != NULL) { + *IsModified = TRUE; + } + // + // Just split current page + // Convert success in next around + // + } + } + + return RETURN_SUCCESS; +} + +/** + FlushTlb on current processor. + + @param[in,out] Buffer Pointer to private data buffer. +**/ +VOID +EFIAPI +FlushTlbOnCurrentProcessor ( + IN OUT VOID *Buffer + ) +{ + CpuFlushTlb (); +} + +/** + FlushTlb for all processors. +**/ +VOID +FlushTlbForAll ( + VOID + ) +{ + UINTN Index; + + FlushTlbOnCurrentProcessor (NULL); + + for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { + if (Index != gSmst->CurrentlyExecutingCpu) { + // Force to start up AP in blocking mode, + SmmBlockingStartupThisAp (FlushTlbOnCurrentProcessor, Index, NULL); + // Do not check return status, because AP might not be present in some corner cases. + } + } +} + +/** + This function sets the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to set for the memory region. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + + @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmSetMemoryAttributesEx ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + OUT BOOLEAN *IsSplitted OPTIONAL + ) +{ + EFI_STATUS Status; + BOOLEAN IsModified; + + Status = ConvertMemoryPageAttributes (BaseAddress, Length, Attributes, TRUE, IsSplitted, &IsModified); + if (!EFI_ERROR(Status)) { + if (IsModified) { + // + // Flush TLB as last step + // + FlushTlbForAll(); + } + } + + return Status; +} + +/** + This function clears the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to clear for the memory region. + @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. + + @retval EFI_SUCCESS The attributes were cleared for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmClearMemoryAttributesEx ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + OUT BOOLEAN *IsSplitted OPTIONAL + ) +{ + EFI_STATUS Status; + BOOLEAN IsModified; + + Status = ConvertMemoryPageAttributes (BaseAddress, Length, Attributes, FALSE, IsSplitted, &IsModified); + if (!EFI_ERROR(Status)) { + if (IsModified) { + // + // Flush TLB as last step + // + FlushTlbForAll(); + } + } + + return Status; +} + +/** + This function sets the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to set for the memory region. + + @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmSetMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ) +{ + return SmmSetMemoryAttributesEx (BaseAddress, Length, Attributes, NULL); +} + +/** + This function clears the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + + @param[in] BaseAddress The physical address that is the start address of a memory region. + @param[in] Length The size in bytes of the memory region. + @param[in] Attributes The bit mask of attributes to clear for the memory region. + + @retval EFI_SUCCESS The attributes were cleared for the memory region. + @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combination of attributes that + cannot be set together. + @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of + the memory resource range. + @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +**/ +EFI_STATUS +EFIAPI +SmmClearMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ) +{ + return SmmClearMemoryAttributesEx (BaseAddress, Length, Attributes, NULL); +} + + + +/** + Retrieves a pointer to the system configuration table from the SMM System Table + based on a specified GUID. + + @param[in] TableGuid The pointer to table's GUID type. + @param[out] Table The pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +SmmGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +{ + UINTN Index; + + ASSERT (TableGuid != NULL); + ASSERT (Table != NULL); + + *Table = NULL; + for (Index = 0; Index < gSmst->NumberOfTableEntries; Index++) { + if (CompareGuid (TableGuid, &(gSmst->SmmConfigurationTable[Index].VendorGuid))) { + *Table = gSmst->SmmConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + This function sets SMM save state buffer to be RW and XP. +**/ +VOID +PatchSmmSaveStateMap ( + VOID + ) +{ + UINTN Index; + UINTN TileCodeSize; + UINTN TileDataSize; + UINTN TileSize; + + TileCodeSize = GetSmiHandlerSize (); + TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB); + TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP); + TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB); + TileSize = TileDataSize + TileCodeSize - 1; + TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize); + + DEBUG ((DEBUG_INFO, "PatchSmmSaveStateMap:\n")); + for (Index = 0; Index < mMaxNumberOfCpus - 1; Index++) { + // + // Code + // + SmmSetMemoryAttributes ( + mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET, + TileCodeSize, + EFI_MEMORY_RO + ); + SmmClearMemoryAttributes ( + mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET, + TileCodeSize, + EFI_MEMORY_XP + ); + + // + // Data + // + SmmClearMemoryAttributes ( + mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET + TileCodeSize, + TileSize - TileCodeSize, + EFI_MEMORY_RO + ); + SmmSetMemoryAttributes ( + mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET + TileCodeSize, + TileSize - TileCodeSize, + EFI_MEMORY_XP + ); + } + + // + // Code + // + SmmSetMemoryAttributes ( + mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET, + TileCodeSize, + EFI_MEMORY_RO + ); + SmmClearMemoryAttributes ( + mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET, + TileCodeSize, + EFI_MEMORY_XP + ); + + // + // Data + // + SmmClearMemoryAttributes ( + mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET + TileCodeSize, + SIZE_32KB - TileCodeSize, + EFI_MEMORY_RO + ); + SmmSetMemoryAttributes ( + mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET + TileCodeSize, + SIZE_32KB - TileCodeSize, + EFI_MEMORY_XP + ); +} + +/** + This function sets memory attribute according to MemoryAttributesTable. +**/ +VOID +SetMemMapAttributes ( + VOID + ) +{ + EFI_MEMORY_DESCRIPTOR *MemoryMap; + EFI_MEMORY_DESCRIPTOR *MemoryMapStart; + UINTN MemoryMapEntryCount; + UINTN DescriptorSize; + UINTN Index; + EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable; + + SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable); + if (MemoryAttributesTable == NULL) { + DEBUG ((DEBUG_INFO, "MemoryAttributesTable - NULL\n")); + return ; + } + + DEBUG ((DEBUG_INFO, "MemoryAttributesTable:\n")); + DEBUG ((DEBUG_INFO, " Version - 0x%08x\n", MemoryAttributesTable->Version)); + DEBUG ((DEBUG_INFO, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries)); + DEBUG ((DEBUG_INFO, " DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize)); + + MemoryMapEntryCount = MemoryAttributesTable->NumberOfEntries; + DescriptorSize = MemoryAttributesTable->DescriptorSize; + MemoryMapStart = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1); + MemoryMap = MemoryMapStart; + for (Index = 0; Index < MemoryMapEntryCount; Index++) { + DEBUG ((DEBUG_INFO, "Entry (0x%x)\n", MemoryMap)); + DEBUG ((DEBUG_INFO, " Type - 0x%x\n", MemoryMap->Type)); + DEBUG ((DEBUG_INFO, " PhysicalStart - 0x%016lx\n", MemoryMap->PhysicalStart)); + DEBUG ((DEBUG_INFO, " VirtualStart - 0x%016lx\n", MemoryMap->VirtualStart)); + DEBUG ((DEBUG_INFO, " NumberOfPages - 0x%016lx\n", MemoryMap->NumberOfPages)); + DEBUG ((DEBUG_INFO, " Attribute - 0x%016lx\n", MemoryMap->Attribute)); + MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize); + } + + MemoryMap = MemoryMapStart; + for (Index = 0; Index < MemoryMapEntryCount; Index++) { + DEBUG ((DEBUG_VERBOSE, "SetAttribute: Memory Entry - 0x%lx, 0x%x\n", MemoryMap->PhysicalStart, MemoryMap->NumberOfPages)); + switch (MemoryMap->Type) { + case EfiRuntimeServicesCode: + SmmSetMemoryAttributes ( + MemoryMap->PhysicalStart, + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), + EFI_MEMORY_RO + ); + break; + case EfiRuntimeServicesData: + SmmSetMemoryAttributes ( + MemoryMap->PhysicalStart, + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), + EFI_MEMORY_XP + ); + break; + default: + SmmSetMemoryAttributes ( + MemoryMap->PhysicalStart, + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), + EFI_MEMORY_XP + ); + break; + } + MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize); + } + + PatchSmmSaveStateMap (); + PatchGdtIdtMap (); + + return ; +} + +/** + Sort memory map entries based upon PhysicalStart, from low to high. + + @param MemoryMap A pointer to the buffer in which firmware places + the current memory map. + @param MemoryMapSize Size, in bytes, of the MemoryMap buffer. + @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. +**/ +STATIC +VOID +SortMemoryMap ( + IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize + ) +{ + EFI_MEMORY_DESCRIPTOR *MemoryMapEntry; + EFI_MEMORY_DESCRIPTOR *NextMemoryMapEntry; + EFI_MEMORY_DESCRIPTOR *MemoryMapEnd; + EFI_MEMORY_DESCRIPTOR TempMemoryMap; + + MemoryMapEntry = MemoryMap; + NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); + MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize); + while (MemoryMapEntry < MemoryMapEnd) { + while (NextMemoryMapEntry < MemoryMapEnd) { + if (MemoryMapEntry->PhysicalStart > NextMemoryMapEntry->PhysicalStart) { + CopyMem (&TempMemoryMap, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); + CopyMem (MemoryMapEntry, NextMemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); + CopyMem (NextMemoryMapEntry, &TempMemoryMap, sizeof(EFI_MEMORY_DESCRIPTOR)); + } + + NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); + } + + MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); + NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); + } +} + +/** + Return if a UEFI memory page should be marked as not present in SMM page table. + If the memory map entries type is + EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, + EfiUnusableMemory, EfiACPIReclaimMemory, return TRUE. + Or return FALSE. + + @param[in] MemoryMap A pointer to the memory descriptor. + + @return TRUE The memory described will be marked as not present in SMM page table. + @return FALSE The memory described will not be marked as not present in SMM page table. +**/ +BOOLEAN +IsUefiPageNotPresent ( + IN EFI_MEMORY_DESCRIPTOR *MemoryMap + ) +{ + switch (MemoryMap->Type) { + case EfiLoaderCode: + case EfiLoaderData: + case EfiBootServicesCode: + case EfiBootServicesData: + case EfiConventionalMemory: + case EfiUnusableMemory: + case EfiACPIReclaimMemory: + return TRUE; + default: + return FALSE; + } +} + +/** + Merge continous memory map entries whose type is + EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, + EfiUnusableMemory, EfiACPIReclaimMemory, because the memory described by + these entries will be set as NOT present in SMM page table. + + @param[in, out] MemoryMap A pointer to the buffer in which firmware places + the current memory map. + @param[in, out] MemoryMapSize A pointer to the size, in bytes, of the + MemoryMap buffer. On input, this is the size of + the current memory map. On output, + it is the size of new memory map after merge. + @param[in] DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. +**/ +STATIC +VOID +MergeMemoryMapForNotPresentEntry ( + IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, + IN OUT UINTN *MemoryMapSize, + IN UINTN DescriptorSize + ) +{ + EFI_MEMORY_DESCRIPTOR *MemoryMapEntry; + EFI_MEMORY_DESCRIPTOR *MemoryMapEnd; + UINT64 MemoryBlockLength; + EFI_MEMORY_DESCRIPTOR *NewMemoryMapEntry; + EFI_MEMORY_DESCRIPTOR *NextMemoryMapEntry; + + MemoryMapEntry = MemoryMap; + NewMemoryMapEntry = MemoryMap; + MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + *MemoryMapSize); + while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) { + CopyMem (NewMemoryMapEntry, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); + NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); + + do { + MemoryBlockLength = (UINT64) (EFI_PAGES_TO_SIZE((UINTN)MemoryMapEntry->NumberOfPages)); + if (((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) && + IsUefiPageNotPresent(MemoryMapEntry) && IsUefiPageNotPresent(NextMemoryMapEntry) && + ((MemoryMapEntry->PhysicalStart + MemoryBlockLength) == NextMemoryMapEntry->PhysicalStart)) { + MemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages; + if (NewMemoryMapEntry != MemoryMapEntry) { + NewMemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages; + } + + NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); + continue; + } else { + MemoryMapEntry = PREVIOUS_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); + break; + } + } while (TRUE); + + MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); + NewMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NewMemoryMapEntry, DescriptorSize); + } + + *MemoryMapSize = (UINTN)NewMemoryMapEntry - (UINTN)MemoryMap; + + return ; +} + +/** + This function caches the UEFI memory map information. +**/ +VOID +GetUefiMemoryMap ( + VOID + ) +{ + EFI_STATUS Status; + UINTN MapKey; + UINT32 DescriptorVersion; + EFI_MEMORY_DESCRIPTOR *MemoryMap; + UINTN UefiMemoryMapSize; + + DEBUG ((DEBUG_INFO, "GetUefiMemoryMap\n")); + + UefiMemoryMapSize = 0; + MemoryMap = NULL; + Status = gBS->GetMemoryMap ( + &UefiMemoryMapSize, + MemoryMap, + &MapKey, + &mUefiDescriptorSize, + &DescriptorVersion + ); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + + do { + Status = gBS->AllocatePool (EfiBootServicesData, UefiMemoryMapSize, (VOID **)&MemoryMap); + ASSERT (MemoryMap != NULL); + if (MemoryMap == NULL) { + return ; + } + + Status = gBS->GetMemoryMap ( + &UefiMemoryMapSize, + MemoryMap, + &MapKey, + &mUefiDescriptorSize, + &DescriptorVersion + ); + if (EFI_ERROR (Status)) { + gBS->FreePool (MemoryMap); + MemoryMap = NULL; + } + } while (Status == EFI_BUFFER_TOO_SMALL); + + if (MemoryMap == NULL) { + return ; + } + + SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize); + MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize); + + mUefiMemoryMapSize = UefiMemoryMapSize; + mUefiMemoryMap = AllocateCopyPool (UefiMemoryMapSize, MemoryMap); + ASSERT (mUefiMemoryMap != NULL); + + gBS->FreePool (MemoryMap); +} + +/** + This function sets UEFI memory attribute according to UEFI memory map. + + The normal memory region is marked as not present, such as + EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, + EfiUnusableMemory, EfiACPIReclaimMemory. +**/ +VOID +SetUefiMemMapAttributes ( + VOID + ) +{ + EFI_MEMORY_DESCRIPTOR *MemoryMap; + UINTN MemoryMapEntryCount; + UINTN Index; + + DEBUG ((DEBUG_INFO, "SetUefiMemMapAttributes\n")); + + if (mUefiMemoryMap == NULL) { + DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n")); + return ; + } + + MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; + MemoryMap = mUefiMemoryMap; + for (Index = 0; Index < MemoryMapEntryCount; Index++) { + if (IsUefiPageNotPresent(MemoryMap)) { + DEBUG ((DEBUG_INFO, "UefiMemory protection: 0x%lx - 0x%lx\n", MemoryMap->PhysicalStart, MemoryMap->PhysicalStart + (UINT64)EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages))); + SmmSetMemoryAttributes ( + MemoryMap->PhysicalStart, + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), + EFI_MEMORY_RP + ); + } + MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize); + } + + // + // Do free mUefiMemoryMap, it will be checked in IsSmmCommBufferForbiddenAddress(). + // +} + +/** + Return if the Address is forbidden as SMM communication buffer. + + @param[in] Address the address to be checked + + @return TRUE The address is forbidden as SMM communication buffer. + @return FALSE The address is allowed as SMM communication buffer. +**/ +BOOLEAN +IsSmmCommBufferForbiddenAddress ( + IN UINT64 Address + ) +{ + EFI_MEMORY_DESCRIPTOR *MemoryMap; + UINTN MemoryMapEntryCount; + UINTN Index; + + if (mUefiMemoryMap == NULL) { + return FALSE; + } + + MemoryMap = mUefiMemoryMap; + MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; + for (Index = 0; Index < MemoryMapEntryCount; Index++) { + if (IsUefiPageNotPresent (MemoryMap)) { + if ((Address >= MemoryMap->PhysicalStart) && + (Address < MemoryMap->PhysicalStart + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages)) ) { + return TRUE; + } + } + MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize); + } + return FALSE; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c new file mode 100644 index 0000000000..2713b19dd2 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -0,0 +1,1440 @@ +/** @file +Enable SMM profile. + +Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" +#include "SmmProfileInternal.h" + +UINT32 mSmmProfileCr3; + +SMM_PROFILE_HEADER *mSmmProfileBase; +MSR_DS_AREA_STRUCT *mMsrDsAreaBase; +// +// The buffer to store SMM profile data. +// +UINTN mSmmProfileSize; + +// +// The buffer to enable branch trace store. +// +UINTN mMsrDsAreaSize = SMM_PROFILE_DTS_SIZE; + +// +// The flag indicates if execute-disable is enabled on processor. +// +BOOLEAN mXdEnabled = FALSE; + +// +// The flag indicates if BTS is supported by processor. +// +BOOLEAN mBtsSupported = TRUE; + +// +// The flag indicates if SMM profile starts to record data. +// +BOOLEAN mSmmProfileStart = FALSE; + +// +// Record the page fault exception count for one instruction execution. +// +UINTN *mPFEntryCount; + +UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; +UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT]; + +MSR_DS_AREA_STRUCT **mMsrDsArea; +BRANCH_TRACE_RECORD **mMsrBTSRecord; +UINTN mBTSRecordNumber; +PEBS_RECORD **mMsrPEBSRecord; + +// +// These memory ranges are always present, they does not generate the access type of page fault exception, +// but they possibly generate instruction fetch type of page fault exception. +// +MEMORY_PROTECTION_RANGE *mProtectionMemRange = NULL; +UINTN mProtectionMemRangeCount = 0; + +// +// Some predefined memory ranges. +// +MEMORY_PROTECTION_RANGE mProtectionMemRangeTemplate[] = { + // + // SMRAM range (to be fixed in runtime). + // It is always present and instruction fetches are allowed. + // + {{0x00000000, 0x00000000},TRUE,FALSE}, + + // + // SMM profile data range( to be fixed in runtime). + // It is always present and instruction fetches are not allowed. + // + {{0x00000000, 0x00000000},TRUE,TRUE}, + + // + // SMRAM ranges not covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz (to be fixed in runtime). + // It is always present and instruction fetches are allowed. + // {{0x00000000, 0x00000000},TRUE,FALSE}, + // + + // + // Future extended range could be added here. + // + + // + // PCI MMIO ranges (to be added in runtime). + // They are always present and instruction fetches are not allowed. + // +}; + +// +// These memory ranges are mapped by 4KB-page instead of 2MB-page. +// +MEMORY_RANGE *mSplitMemRange = NULL; +UINTN mSplitMemRangeCount = 0; + +// +// SMI command port. +// +UINT32 mSmiCommandPort; + +/** + Disable branch trace store. + +**/ +VOID +DisableBTS ( + VOID + ) +{ + AsmMsrAnd64 (MSR_DEBUG_CTL, ~((UINT64)(MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR))); +} + +/** + Enable branch trace store. + +**/ +VOID +EnableBTS ( + VOID + ) +{ + AsmMsrOr64 (MSR_DEBUG_CTL, (MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR)); +} + +/** + Get CPU Index from APIC ID. + +**/ +UINTN +GetCpuIndex ( + VOID + ) +{ + UINTN Index; + UINT32 ApicId; + + ApicId = GetApicId (); + + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ApicId) { + return Index; + } + } + ASSERT (FALSE); + return 0; +} + +/** + Get the source of IP after execute-disable exception is triggered. + + @param CpuIndex The index of CPU. + @param DestinationIP The destination address. + +**/ +UINT64 +GetSourceFromDestinationOnBts ( + UINTN CpuIndex, + UINT64 DestinationIP + ) +{ + BRANCH_TRACE_RECORD *CurrentBTSRecord; + UINTN Index; + BOOLEAN FirstMatch; + + FirstMatch = FALSE; + + CurrentBTSRecord = (BRANCH_TRACE_RECORD *)mMsrDsArea[CpuIndex]->BTSIndex; + for (Index = 0; Index < mBTSRecordNumber; Index++) { + if ((UINTN)CurrentBTSRecord < (UINTN)mMsrBTSRecord[CpuIndex]) { + // + // Underflow + // + CurrentBTSRecord = (BRANCH_TRACE_RECORD *)((UINTN)mMsrDsArea[CpuIndex]->BTSAbsoluteMaximum - 1); + CurrentBTSRecord --; + } + if (CurrentBTSRecord->LastBranchTo == DestinationIP) { + // + // Good! find 1st one, then find 2nd one. + // + if (!FirstMatch) { + // + // The first one is DEBUG exception + // + FirstMatch = TRUE; + } else { + // + // Good find proper one. + // + return CurrentBTSRecord->LastBranchFrom; + } + } + CurrentBTSRecord--; + } + + return 0; +} + +/** + SMM profile specific INT 1 (single-step) exception handler. + + @param InterruptType Defines the type of interrupt or exception that + occurred on the processor.This parameter is processor architecture specific. + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. +**/ +VOID +EFIAPI +DebugExceptionHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + UINTN CpuIndex; + UINTN PFEntry; + + if (!mSmmProfileStart) { + return; + } + CpuIndex = GetCpuIndex (); + + // + // Clear last PF entries + // + for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) { + *mLastPFEntryPointer[CpuIndex][PFEntry] = mLastPFEntryValue[CpuIndex][PFEntry]; + } + + // + // Reset page fault exception count for next page fault. + // + mPFEntryCount[CpuIndex] = 0; + + // + // Flush TLB + // + CpuFlushTlb (); + + // + // Clear TF in EFLAGS + // + ClearTrapFlag (SystemContext); +} + +/** + Check if the input address is in SMM ranges. + + @param[in] Address The input address. + + @retval TRUE The input address is in SMM. + @retval FALSE The input address is not in SMM. +**/ +BOOLEAN +IsInSmmRanges ( + IN EFI_PHYSICAL_ADDRESS Address + ) +{ + UINTN Index; + + if ((Address < mCpuHotPlugData.SmrrBase) || (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { + return TRUE; + } + for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { + if (Address >= mSmmCpuSmramRanges[Index].CpuStart && + Address < mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) { + return TRUE; + } + } + return FALSE; +} + +/** + Check if the memory address will be mapped by 4KB-page. + + @param Address The address of Memory. + @param Nx The flag indicates if the memory is execute-disable. + +**/ +BOOLEAN +IsAddressValid ( + IN EFI_PHYSICAL_ADDRESS Address, + IN BOOLEAN *Nx + ) +{ + UINTN Index; + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + // + // Check configuration + // + for (Index = 0; Index < mProtectionMemRangeCount; Index++) { + if ((Address >= mProtectionMemRange[Index].Range.Base) && (Address < mProtectionMemRange[Index].Range.Top)) { + *Nx = mProtectionMemRange[Index].Nx; + return mProtectionMemRange[Index].Present; + } + } + *Nx = TRUE; + return FALSE; + + } else { + *Nx = TRUE; + if (IsInSmmRanges (Address)) { + *Nx = FALSE; + } + return TRUE; + } +} + +/** + Check if the memory address will be mapped by 4KB-page. + + @param Address The address of Memory. + +**/ +BOOLEAN +IsAddressSplit ( + IN EFI_PHYSICAL_ADDRESS Address + ) +{ + UINTN Index; + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + // + // Check configuration + // + for (Index = 0; Index < mSplitMemRangeCount; Index++) { + if ((Address >= mSplitMemRange[Index].Base) && (Address < mSplitMemRange[Index].Top)) { + return TRUE; + } + } + } else { + if (Address < mCpuHotPlugData.SmrrBase) { + if ((mCpuHotPlugData.SmrrBase - Address) < BASE_2MB) { + return TRUE; + } + } else if (Address > (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) { + if ((Address - (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) < BASE_2MB) { + return TRUE; + } + } + } + // + // Return default + // + return FALSE; +} + +/** + Initialize the protected memory ranges and the 4KB-page mapped memory ranges. + +**/ +VOID +InitProtectedMemRange ( + VOID + ) +{ + UINTN Index; + UINTN NumberOfDescriptors; + UINTN NumberOfAddedDescriptors; + UINTN NumberOfProtectRange; + UINTN NumberOfSpliteRange; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; + UINTN TotalSize; + EFI_PHYSICAL_ADDRESS ProtectBaseAddress; + EFI_PHYSICAL_ADDRESS ProtectEndAddress; + EFI_PHYSICAL_ADDRESS Top2MBAlignedAddress; + EFI_PHYSICAL_ADDRESS Base2MBAlignedAddress; + UINT64 High4KBPageSize; + UINT64 Low4KBPageSize; + + NumberOfDescriptors = 0; + NumberOfAddedDescriptors = mSmmCpuSmramRangeCount; + NumberOfSpliteRange = 0; + MemorySpaceMap = NULL; + + // + // Get MMIO ranges from GCD and add them into protected memory ranges. + // + gDS->GetMemorySpaceMap ( + &NumberOfDescriptors, + &MemorySpaceMap + ); + for (Index = 0; Index < NumberOfDescriptors; Index++) { + if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) { + NumberOfAddedDescriptors++; + } + } + + if (NumberOfAddedDescriptors != 0) { + TotalSize = NumberOfAddedDescriptors * sizeof (MEMORY_PROTECTION_RANGE) + sizeof (mProtectionMemRangeTemplate); + mProtectionMemRange = (MEMORY_PROTECTION_RANGE *) AllocateZeroPool (TotalSize); + ASSERT (mProtectionMemRange != NULL); + mProtectionMemRangeCount = TotalSize / sizeof (MEMORY_PROTECTION_RANGE); + + // + // Copy existing ranges. + // + CopyMem (mProtectionMemRange, mProtectionMemRangeTemplate, sizeof (mProtectionMemRangeTemplate)); + + // + // Create split ranges which come from protected ranges. + // + TotalSize = (TotalSize / sizeof (MEMORY_PROTECTION_RANGE)) * sizeof (MEMORY_RANGE); + mSplitMemRange = (MEMORY_RANGE *) AllocateZeroPool (TotalSize); + ASSERT (mSplitMemRange != NULL); + + // + // Create SMM ranges which are set to present and execution-enable. + // + NumberOfProtectRange = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE); + for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { + if (mSmmCpuSmramRanges[Index].CpuStart >= mProtectionMemRange[0].Range.Base && + mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize < mProtectionMemRange[0].Range.Top) { + // + // If the address have been already covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz + // + break; + } + mProtectionMemRange[NumberOfProtectRange].Range.Base = mSmmCpuSmramRanges[Index].CpuStart; + mProtectionMemRange[NumberOfProtectRange].Range.Top = mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize; + mProtectionMemRange[NumberOfProtectRange].Present = TRUE; + mProtectionMemRange[NumberOfProtectRange].Nx = FALSE; + NumberOfProtectRange++; + } + + // + // Create MMIO ranges which are set to present and execution-disable. + // + for (Index = 0; Index < NumberOfDescriptors; Index++) { + if (MemorySpaceMap[Index].GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) { + continue; + } + mProtectionMemRange[NumberOfProtectRange].Range.Base = MemorySpaceMap[Index].BaseAddress; + mProtectionMemRange[NumberOfProtectRange].Range.Top = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length; + mProtectionMemRange[NumberOfProtectRange].Present = TRUE; + mProtectionMemRange[NumberOfProtectRange].Nx = TRUE; + NumberOfProtectRange++; + } + + // + // Check and updated actual protected memory ranges count + // + ASSERT (NumberOfProtectRange <= mProtectionMemRangeCount); + mProtectionMemRangeCount = NumberOfProtectRange; + } + + // + // According to protected ranges, create the ranges which will be mapped by 2KB page. + // + NumberOfSpliteRange = 0; + NumberOfProtectRange = mProtectionMemRangeCount; + for (Index = 0; Index < NumberOfProtectRange; Index++) { + // + // If MMIO base address is not 2MB alignment, make 2MB alignment for create 4KB page in page table. + // + ProtectBaseAddress = mProtectionMemRange[Index].Range.Base; + ProtectEndAddress = mProtectionMemRange[Index].Range.Top; + if (((ProtectBaseAddress & (SIZE_2MB - 1)) != 0) || ((ProtectEndAddress & (SIZE_2MB - 1)) != 0)) { + // + // Check if it is possible to create 4KB-page for not 2MB-aligned range and to create 2MB-page for 2MB-aligned range. + // A mix of 4KB and 2MB page could save SMRAM space. + // + Top2MBAlignedAddress = ProtectEndAddress & ~(SIZE_2MB - 1); + Base2MBAlignedAddress = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); + if ((Top2MBAlignedAddress > Base2MBAlignedAddress) && + ((Top2MBAlignedAddress - Base2MBAlignedAddress) >= SIZE_2MB)) { + // + // There is an range which could be mapped by 2MB-page. + // + High4KBPageSize = ((ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectEndAddress & ~(SIZE_2MB - 1)); + Low4KBPageSize = ((ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectBaseAddress & ~(SIZE_2MB - 1)); + if (High4KBPageSize != 0) { + // + // Add not 2MB-aligned range to be mapped by 4KB-page. + // + mSplitMemRange[NumberOfSpliteRange].Base = ProtectEndAddress & ~(SIZE_2MB - 1); + mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); + NumberOfSpliteRange++; + } + if (Low4KBPageSize != 0) { + // + // Add not 2MB-aligned range to be mapped by 4KB-page. + // + mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1); + mSplitMemRange[NumberOfSpliteRange].Top = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); + NumberOfSpliteRange++; + } + } else { + // + // The range could only be mapped by 4KB-page. + // + mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1); + mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); + NumberOfSpliteRange++; + } + } + } + + mSplitMemRangeCount = NumberOfSpliteRange; + + DEBUG ((EFI_D_INFO, "SMM Profile Memory Ranges:\n")); + for (Index = 0; Index < mProtectionMemRangeCount; Index++) { + DEBUG ((EFI_D_INFO, "mProtectionMemRange[%d].Base = %lx\n", Index, mProtectionMemRange[Index].Range.Base)); + DEBUG ((EFI_D_INFO, "mProtectionMemRange[%d].Top = %lx\n", Index, mProtectionMemRange[Index].Range.Top)); + } + for (Index = 0; Index < mSplitMemRangeCount; Index++) { + DEBUG ((EFI_D_INFO, "mSplitMemRange[%d].Base = %lx\n", Index, mSplitMemRange[Index].Base)); + DEBUG ((EFI_D_INFO, "mSplitMemRange[%d].Top = %lx\n", Index, mSplitMemRange[Index].Top)); + } +} + +/** + Update page table according to protected memory ranges and the 4KB-page mapped memory ranges. + +**/ +VOID +InitPaging ( + VOID + ) +{ + UINT64 *Pml4; + UINT64 *Pde; + UINT64 *Pte; + UINT64 *Pt; + UINTN Address; + UINTN Level1; + UINTN Level2; + UINTN Level3; + UINTN Level4; + UINTN NumberOfPdpEntries; + UINTN NumberOfPml4Entries; + UINTN SizeOfMemorySpace; + BOOLEAN Nx; + + if (sizeof (UINTN) == sizeof (UINT64)) { + Pml4 = (UINT64*)(UINTN)mSmmProfileCr3; + SizeOfMemorySpace = HighBitSet64 (gPhyMask) + 1; + // + // Calculate the table entries of PML4E and PDPTE. + // + if (SizeOfMemorySpace <= 39 ) { + NumberOfPml4Entries = 1; + NumberOfPdpEntries = (UINT32)LShiftU64 (1, (SizeOfMemorySpace - 30)); + } else { + NumberOfPml4Entries = (UINT32)LShiftU64 (1, (SizeOfMemorySpace - 39)); + NumberOfPdpEntries = 512; + } + } else { + NumberOfPml4Entries = 1; + NumberOfPdpEntries = 4; + } + + // + // Go through page table and change 2MB-page into 4KB-page. + // + for (Level1 = 0; Level1 < NumberOfPml4Entries; Level1++) { + if (sizeof (UINTN) == sizeof (UINT64)) { + if ((Pml4[Level1] & IA32_PG_P) == 0) { + // + // If Pml4 entry does not exist, skip it + // + continue; + } + Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + } else { + Pde = (UINT64*)(UINTN)mSmmProfileCr3; + } + for (Level2 = 0; Level2 < NumberOfPdpEntries; Level2++, Pde++) { + if ((*Pde & IA32_PG_P) == 0) { + // + // If PDE entry does not exist, skip it + // + continue; + } + if ((*Pde & IA32_PG_PS) != 0) { + // + // This is 1G entry, skip it + // + continue; + } + Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + if (Pte == 0) { + continue; + } + for (Level3 = 0; Level3 < SIZE_4KB / sizeof (*Pte); Level3++, Pte++) { + if ((*Pte & IA32_PG_P) == 0) { + // + // If PTE entry does not exist, skip it + // + continue; + } + Address = (((Level2 << 9) + Level3) << 21); + + // + // If it is 2M page, check IsAddressSplit() + // + if (((*Pte & IA32_PG_PS) != 0) && IsAddressSplit (Address)) { + // + // Based on current page table, create 4KB page table for split area. + // + ASSERT (Address == (*Pte & PHYSICAL_ADDRESS_MASK)); + + Pt = AllocatePageTableMemory (1); + ASSERT (Pt != NULL); + + // Split it + for (Level4 = 0; Level4 < SIZE_4KB / sizeof(*Pt); Level4++) { + Pt[Level4] = Address + ((Level4 << 12) | mAddressEncMask | PAGE_ATTRIBUTE_BITS); + } // end for PT + *Pte = (UINT64)(UINTN)Pt | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + } // end if IsAddressSplit + } // end for PTE + } // end for PDE + } + + // + // Go through page table and set several page table entries to absent or execute-disable. + // + DEBUG ((EFI_D_INFO, "Patch page table start ...\n")); + for (Level1 = 0; Level1 < NumberOfPml4Entries; Level1++) { + if (sizeof (UINTN) == sizeof (UINT64)) { + if ((Pml4[Level1] & IA32_PG_P) == 0) { + // + // If Pml4 entry does not exist, skip it + // + continue; + } + Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + } else { + Pde = (UINT64*)(UINTN)mSmmProfileCr3; + } + for (Level2 = 0; Level2 < NumberOfPdpEntries; Level2++, Pde++) { + if ((*Pde & IA32_PG_P) == 0) { + // + // If PDE entry does not exist, skip it + // + continue; + } + if ((*Pde & IA32_PG_PS) != 0) { + // + // This is 1G entry, set NX bit and skip it + // + if (mXdSupported) { + *Pde = *Pde | IA32_PG_NX; + } + continue; + } + Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + if (Pte == 0) { + continue; + } + for (Level3 = 0; Level3 < SIZE_4KB / sizeof (*Pte); Level3++, Pte++) { + if ((*Pte & IA32_PG_P) == 0) { + // + // If PTE entry does not exist, skip it + // + continue; + } + Address = (((Level2 << 9) + Level3) << 21); + + if ((*Pte & IA32_PG_PS) != 0) { + // 2MB page + + if (!IsAddressValid (Address, &Nx)) { + // + // Patch to remove Present flag and RW flag + // + *Pte = *Pte & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); + } + if (Nx && mXdSupported) { + *Pte = *Pte | IA32_PG_NX; + } + } else { + // 4KB page + Pt = (UINT64 *)(UINTN)(*Pte & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + if (Pt == 0) { + continue; + } + for (Level4 = 0; Level4 < SIZE_4KB / sizeof(*Pt); Level4++, Pt++) { + if (!IsAddressValid (Address, &Nx)) { + *Pt = *Pt & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); + } + if (Nx && mXdSupported) { + *Pt = *Pt | IA32_PG_NX; + } + Address += SIZE_4KB; + } // end for PT + } // end if PS + } // end for PTE + } // end for PDE + } + + // + // Flush TLB + // + CpuFlushTlb (); + DEBUG ((EFI_D_INFO, "Patch page table done!\n")); + // + // Set execute-disable flag + // + mXdEnabled = TRUE; + + return ; +} + +/** + To find FADT in ACPI tables. + + @param AcpiTableGuid The GUID used to find ACPI table in UEFI ConfigurationTable. + + @return FADT table pointer. +**/ +EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE * +FindAcpiFadtTableByAcpiGuid ( + IN EFI_GUID *AcpiTableGuid + ) +{ + EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; + EFI_ACPI_DESCRIPTION_HEADER *Rsdt; + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; + UINTN Index; + UINT32 Data32; + Rsdp = NULL; + Rsdt = NULL; + Fadt = NULL; + // + // found ACPI table RSD_PTR from system table + // + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), AcpiTableGuid)) { + // + // A match was found. + // + Rsdp = gST->ConfigurationTable[Index].VendorTable; + break; + } + } + + if (Rsdp == NULL) { + return NULL; + } + + Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress; + if (Rsdt == NULL || Rsdt->Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { + return NULL; + } + + for (Index = sizeof (EFI_ACPI_DESCRIPTION_HEADER); Index < Rsdt->Length; Index = Index + sizeof (UINT32)) { + + Data32 = *(UINT32 *) ((UINT8 *) Rsdt + Index); + Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) (UINT32 *) (UINTN) Data32; + if (Fadt->Header.Signature == EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { + break; + } + } + + if (Fadt == NULL || Fadt->Header.Signature != EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { + return NULL; + } + + return Fadt; +} + +/** + To find FADT in ACPI tables. + + @return FADT table pointer. +**/ +EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE * +FindAcpiFadtTable ( + VOID + ) +{ + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; + + Fadt = FindAcpiFadtTableByAcpiGuid (&gEfiAcpi20TableGuid); + if (Fadt != NULL) { + return Fadt; + } + + return FindAcpiFadtTableByAcpiGuid (&gEfiAcpi10TableGuid); +} + +/** + To get system port address of the SMI Command Port in FADT table. + +**/ +VOID +GetSmiCommandPort ( + VOID + ) +{ + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; + + Fadt = FindAcpiFadtTable (); + ASSERT (Fadt != NULL); + + mSmiCommandPort = Fadt->SmiCmd; + DEBUG ((EFI_D_INFO, "mSmiCommandPort = %x\n", mSmiCommandPort)); +} + +/** + Updates page table to make some memory ranges (like system memory) absent + and make some memory ranges (like MMIO) present and execute disable. It also + update 2MB-page to 4KB-page for some memory ranges. + +**/ +VOID +SmmProfileStart ( + VOID + ) +{ + // + // The flag indicates SMM profile starts to work. + // + mSmmProfileStart = TRUE; +} + +/** + Initialize SMM profile in SmmReadyToLock protocol callback function. + + @param Protocol Points to the protocol's unique identifier. + @param Interface Points to the interface instance. + @param Handle The handle on which the interface was installed. + + @retval EFI_SUCCESS SmmReadyToLock protocol callback runs successfully. +**/ +EFI_STATUS +EFIAPI +InitSmmProfileCallBack ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + // + // Save to variable so that SMM profile data can be found. + // + gRT->SetVariable ( + SMM_PROFILE_NAME, + &gEfiCallerIdGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(mSmmProfileBase), + &mSmmProfileBase + ); + + // + // Get Software SMI from FADT + // + GetSmiCommandPort (); + + // + // Initialize protected memory range for patching page table later. + // + InitProtectedMemRange (); + + return EFI_SUCCESS; +} + +/** + Initialize SMM profile data structures. + +**/ +VOID +InitSmmProfileInternal ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Base; + VOID *Registration; + UINTN Index; + UINTN MsrDsAreaSizePerCpu; + UINTN TotalSize; + + mPFEntryCount = (UINTN *)AllocateZeroPool (sizeof (UINTN) * mMaxNumberOfCpus); + ASSERT (mPFEntryCount != NULL); + mLastPFEntryValue = (UINT64 (*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool ( + sizeof (mLastPFEntryValue[0]) * mMaxNumberOfCpus); + ASSERT (mLastPFEntryValue != NULL); + mLastPFEntryPointer = (UINT64 *(*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool ( + sizeof (mLastPFEntryPointer[0]) * mMaxNumberOfCpus); + ASSERT (mLastPFEntryPointer != NULL); + + // + // Allocate memory for SmmProfile below 4GB. + // The base address + // + mSmmProfileSize = PcdGet32 (PcdCpuSmmProfileSize); + ASSERT ((mSmmProfileSize & 0xFFF) == 0); + + if (mBtsSupported) { + TotalSize = mSmmProfileSize + mMsrDsAreaSize; + } else { + TotalSize = mSmmProfileSize; + } + + Base = 0xFFFFFFFF; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (TotalSize), + &Base + ); + ASSERT_EFI_ERROR (Status); + ZeroMem ((VOID *)(UINTN)Base, TotalSize); + mSmmProfileBase = (SMM_PROFILE_HEADER *)(UINTN)Base; + + // + // Initialize SMM profile data header. + // + mSmmProfileBase->HeaderSize = sizeof (SMM_PROFILE_HEADER); + mSmmProfileBase->MaxDataEntries = (UINT64)((mSmmProfileSize - sizeof(SMM_PROFILE_HEADER)) / sizeof (SMM_PROFILE_ENTRY)); + mSmmProfileBase->MaxDataSize = MultU64x64 (mSmmProfileBase->MaxDataEntries, sizeof(SMM_PROFILE_ENTRY)); + mSmmProfileBase->CurDataEntries = 0; + mSmmProfileBase->CurDataSize = 0; + mSmmProfileBase->TsegStart = mCpuHotPlugData.SmrrBase; + mSmmProfileBase->TsegSize = mCpuHotPlugData.SmrrSize; + mSmmProfileBase->NumSmis = 0; + mSmmProfileBase->NumCpus = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + + if (mBtsSupported) { + mMsrDsArea = (MSR_DS_AREA_STRUCT **)AllocateZeroPool (sizeof (MSR_DS_AREA_STRUCT *) * mMaxNumberOfCpus); + ASSERT (mMsrDsArea != NULL); + mMsrBTSRecord = (BRANCH_TRACE_RECORD **)AllocateZeroPool (sizeof (BRANCH_TRACE_RECORD *) * mMaxNumberOfCpus); + ASSERT (mMsrBTSRecord != NULL); + mMsrPEBSRecord = (PEBS_RECORD **)AllocateZeroPool (sizeof (PEBS_RECORD *) * mMaxNumberOfCpus); + ASSERT (mMsrPEBSRecord != NULL); + + mMsrDsAreaBase = (MSR_DS_AREA_STRUCT *)((UINTN)Base + mSmmProfileSize); + MsrDsAreaSizePerCpu = mMsrDsAreaSize / mMaxNumberOfCpus; + mBTSRecordNumber = (MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER - sizeof(MSR_DS_AREA_STRUCT)) / sizeof(BRANCH_TRACE_RECORD); + for (Index = 0; Index < mMaxNumberOfCpus; Index++) { + mMsrDsArea[Index] = (MSR_DS_AREA_STRUCT *)((UINTN)mMsrDsAreaBase + MsrDsAreaSizePerCpu * Index); + mMsrBTSRecord[Index] = (BRANCH_TRACE_RECORD *)((UINTN)mMsrDsArea[Index] + sizeof(MSR_DS_AREA_STRUCT)); + mMsrPEBSRecord[Index] = (PEBS_RECORD *)((UINTN)mMsrDsArea[Index] + MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER); + + mMsrDsArea[Index]->BTSBufferBase = (UINTN)mMsrBTSRecord[Index]; + mMsrDsArea[Index]->BTSIndex = mMsrDsArea[Index]->BTSBufferBase; + mMsrDsArea[Index]->BTSAbsoluteMaximum = mMsrDsArea[Index]->BTSBufferBase + mBTSRecordNumber * sizeof(BRANCH_TRACE_RECORD) + 1; + mMsrDsArea[Index]->BTSInterruptThreshold = mMsrDsArea[Index]->BTSAbsoluteMaximum + 1; + + mMsrDsArea[Index]->PEBSBufferBase = (UINTN)mMsrPEBSRecord[Index]; + mMsrDsArea[Index]->PEBSIndex = mMsrDsArea[Index]->PEBSBufferBase; + mMsrDsArea[Index]->PEBSAbsoluteMaximum = mMsrDsArea[Index]->PEBSBufferBase + PEBS_RECORD_NUMBER * sizeof(PEBS_RECORD) + 1; + mMsrDsArea[Index]->PEBSInterruptThreshold = mMsrDsArea[Index]->PEBSAbsoluteMaximum + 1; + } + } + + mProtectionMemRange = mProtectionMemRangeTemplate; + mProtectionMemRangeCount = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE); + + // + // Update TSeg entry. + // + mProtectionMemRange[0].Range.Base = mCpuHotPlugData.SmrrBase; + mProtectionMemRange[0].Range.Top = mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize; + + // + // Update SMM profile entry. + // + mProtectionMemRange[1].Range.Base = (EFI_PHYSICAL_ADDRESS)(UINTN)mSmmProfileBase; + mProtectionMemRange[1].Range.Top = (EFI_PHYSICAL_ADDRESS)(UINTN)mSmmProfileBase + TotalSize; + + // + // Allocate memory reserved for creating 4KB pages. + // + InitPagesForPFHandler (); + + // + // Start SMM profile when SmmReadyToLock protocol is installed. + // + Status = gSmst->SmmRegisterProtocolNotify ( + &gEfiSmmReadyToLockProtocolGuid, + InitSmmProfileCallBack, + &Registration + ); + ASSERT_EFI_ERROR (Status); + + return ; +} + +/** + Check if XD feature is supported by a processor. + +**/ +VOID +CheckFeatureSupported ( + VOID + ) +{ + UINT32 RegEax; + UINT32 RegEdx; + MSR_IA32_MISC_ENABLE_REGISTER MiscEnableMsr; + + if (mXdSupported) { + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax <= CPUID_EXTENDED_FUNCTION) { + // + // Extended CPUID functions are not supported on this processor. + // + mXdSupported = FALSE; + } + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & CPUID1_EDX_XD_SUPPORT) == 0) { + // + // Execute Disable Bit feature is not supported on this processor. + // + mXdSupported = FALSE; + } + } + + if (mBtsSupported) { + AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & CPUID1_EDX_BTS_AVAILABLE) != 0) { + // + // Per IA32 manuals: + // When CPUID.1:EDX[21] is set, the following BTS facilities are available: + // 1. The BTS_UNAVAILABLE flag in the IA32_MISC_ENABLE MSR indicates the + // availability of the BTS facilities, including the ability to set the BTS and + // BTINT bits in the MSR_DEBUGCTLA MSR. + // 2. The IA32_DS_AREA MSR can be programmed to point to the DS save area. + // + MiscEnableMsr.Uint64 = AsmReadMsr64 (MSR_IA32_MISC_ENABLE); + if (MiscEnableMsr.Bits.BTS == 1) { + // + // BTS facilities is not supported if MSR_IA32_MISC_ENABLE.BTS bit is set. + // + mBtsSupported = FALSE; + } + } + } +} + +/** + Enable single step. + +**/ +VOID +ActivateSingleStepDB ( + VOID + ) +{ + UINTN Dr6; + + Dr6 = AsmReadDr6 (); + if ((Dr6 & DR6_SINGLE_STEP) != 0) { + return; + } + Dr6 |= DR6_SINGLE_STEP; + AsmWriteDr6 (Dr6); +} + +/** + Enable last branch. + +**/ +VOID +ActivateLBR ( + VOID + ) +{ + UINT64 DebugCtl; + + DebugCtl = AsmReadMsr64 (MSR_DEBUG_CTL); + if ((DebugCtl & MSR_DEBUG_CTL_LBR) != 0) { + return ; + } + DebugCtl |= MSR_DEBUG_CTL_LBR; + AsmWriteMsr64 (MSR_DEBUG_CTL, DebugCtl); +} + +/** + Enable branch trace store. + + @param CpuIndex The index of the processor. + +**/ +VOID +ActivateBTS ( + IN UINTN CpuIndex + ) +{ + UINT64 DebugCtl; + + DebugCtl = AsmReadMsr64 (MSR_DEBUG_CTL); + if ((DebugCtl & MSR_DEBUG_CTL_BTS) != 0) { + return ; + } + + AsmWriteMsr64 (MSR_DS_AREA, (UINT64)(UINTN)mMsrDsArea[CpuIndex]); + DebugCtl |= (UINT64)(MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR); + DebugCtl &= ~((UINT64)MSR_DEBUG_CTL_BTINT); + AsmWriteMsr64 (MSR_DEBUG_CTL, DebugCtl); +} + +/** + Increase SMI number in each SMI entry. + +**/ +VOID +SmmProfileRecordSmiNum ( + VOID + ) +{ + if (mSmmProfileStart) { + mSmmProfileBase->NumSmis++; + } +} + +/** + Initialize processor environment for SMM profile. + + @param CpuIndex The index of the processor. + +**/ +VOID +ActivateSmmProfile ( + IN UINTN CpuIndex + ) +{ + // + // Enable Single Step DB# + // + ActivateSingleStepDB (); + + if (mBtsSupported) { + // + // We can not get useful information from LER, so we have to use BTS. + // + ActivateLBR (); + + // + // Enable BTS + // + ActivateBTS (CpuIndex); + } +} + +/** + Initialize SMM profile in SMM CPU entry point. + + @param[in] Cr3 The base address of the page tables to use in SMM. + +**/ +VOID +InitSmmProfile ( + UINT32 Cr3 + ) +{ + // + // Save Cr3 + // + mSmmProfileCr3 = Cr3; + + // + // Skip SMM profile initialization if feature is disabled + // + if (!FeaturePcdGet (PcdCpuSmmProfileEnable)) { + return; + } + + // + // Initialize SmmProfile here + // + InitSmmProfileInternal (); + + // + // Initialize profile IDT. + // + InitIdtr (); +} + +/** + Update page table to map the memory correctly in order to make the instruction + which caused page fault execute successfully. And it also save the original page + table to be restored in single-step exception. + + @param PageTable PageTable Address. + @param PFAddress The memory address which caused page fault exception. + @param CpuIndex The index of the processor. + @param ErrorCode The Error code of exception. + +**/ +VOID +RestorePageTableBelow4G ( + UINT64 *PageTable, + UINT64 PFAddress, + UINTN CpuIndex, + UINTN ErrorCode + ) +{ + UINTN PTIndex; + UINTN PFIndex; + + // + // PML4 + // + if (sizeof(UINT64) == sizeof(UINTN)) { + PTIndex = (UINTN)BitFieldRead64 (PFAddress, 39, 47); + ASSERT (PageTable[PTIndex] != 0); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); + } + + // + // PDPTE + // + PTIndex = (UINTN)BitFieldRead64 (PFAddress, 30, 38); + ASSERT (PageTable[PTIndex] != 0); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); + + // + // PD + // + PTIndex = (UINTN)BitFieldRead64 (PFAddress, 21, 29); + if ((PageTable[PTIndex] & IA32_PG_PS) != 0) { + // + // Large page + // + + // + // Record old entries with non-present status + // Old entries include the memory which instruction is at and the memory which instruction access. + // + // + ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); + if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { + PFIndex = mPFEntryCount[CpuIndex]; + mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; + mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; + mPFEntryCount[CpuIndex]++; + } + + // + // Set new entry + // + PageTable[PTIndex] = (PFAddress & ~((1ull << 21) - 1)); + PageTable[PTIndex] |= (UINT64)IA32_PG_PS; + PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS; + if ((ErrorCode & IA32_PF_EC_ID) != 0) { + PageTable[PTIndex] &= ~IA32_PG_NX; + } + } else { + // + // Small page + // + ASSERT (PageTable[PTIndex] != 0); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); + + // + // 4K PTE + // + PTIndex = (UINTN)BitFieldRead64 (PFAddress, 12, 20); + + // + // Record old entries with non-present status + // Old entries include the memory which instruction is at and the memory which instruction access. + // + // + ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); + if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { + PFIndex = mPFEntryCount[CpuIndex]; + mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; + mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; + mPFEntryCount[CpuIndex]++; + } + + // + // Set new entry + // + PageTable[PTIndex] = (PFAddress & ~((1ull << 12) - 1)); + PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS; + if ((ErrorCode & IA32_PF_EC_ID) != 0) { + PageTable[PTIndex] &= ~IA32_PG_NX; + } + } +} + +/** + The Page fault handler to save SMM profile data. + + @param Rip The RIP when exception happens. + @param ErrorCode The Error code of exception. + +**/ +VOID +SmmProfilePFHandler ( + UINTN Rip, + UINTN ErrorCode + ) +{ + UINT64 *PageTable; + UINT64 PFAddress; + UINTN CpuIndex; + UINTN Index; + UINT64 InstructionAddress; + UINTN MaxEntryNumber; + UINTN CurrentEntryNumber; + BOOLEAN IsValidPFAddress; + SMM_PROFILE_ENTRY *SmmProfileEntry; + UINT64 SmiCommand; + EFI_STATUS Status; + UINT8 SoftSmiValue; + EFI_SMM_SAVE_STATE_IO_INFO IoInfo; + + if (!mSmmProfileStart) { + // + // If SMM profile does not start, call original page fault handler. + // + SmiDefaultPFHandler (); + return; + } + + if (mBtsSupported) { + DisableBTS (); + } + + IsValidPFAddress = FALSE; + PageTable = (UINT64 *)AsmReadCr3 (); + PFAddress = AsmReadCr2 (); + CpuIndex = GetCpuIndex (); + + if (PFAddress <= 0xFFFFFFFF) { + RestorePageTableBelow4G (PageTable, PFAddress, CpuIndex, ErrorCode); + } else { + RestorePageTableAbove4G (PageTable, PFAddress, CpuIndex, ErrorCode, &IsValidPFAddress); + } + + if (!IsValidPFAddress) { + InstructionAddress = Rip; + if ((ErrorCode & IA32_PF_EC_ID) != 0 && (mBtsSupported)) { + // + // If it is instruction fetch failure, get the correct IP from BTS. + // + InstructionAddress = GetSourceFromDestinationOnBts (CpuIndex, Rip); + if (InstructionAddress == 0) { + // + // It indicates the instruction which caused page fault is not a jump instruction, + // set instruction address same as the page fault address. + // + InstructionAddress = PFAddress; + } + } + + // + // Indicate it is not software SMI + // + SmiCommand = 0xFFFFFFFFFFFFFFFFULL; + for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { + Status = SmmReadSaveState(&mSmmCpu, sizeof(IoInfo), EFI_SMM_SAVE_STATE_REGISTER_IO, Index, &IoInfo); + if (EFI_ERROR (Status)) { + continue; + } + if (IoInfo.IoPort == mSmiCommandPort) { + // + // A software SMI triggered by SMI command port has been found, get SmiCommand from SMI command port. + // + SoftSmiValue = IoRead8 (mSmiCommandPort); + SmiCommand = (UINT64)SoftSmiValue; + break; + } + } + + SmmProfileEntry = (SMM_PROFILE_ENTRY *)(UINTN)(mSmmProfileBase + 1); + // + // Check if there is already a same entry in profile data. + // + for (Index = 0; Index < (UINTN) mSmmProfileBase->CurDataEntries; Index++) { + if ((SmmProfileEntry[Index].ErrorCode == (UINT64)ErrorCode) && + (SmmProfileEntry[Index].Address == PFAddress) && + (SmmProfileEntry[Index].CpuNum == (UINT64)CpuIndex) && + (SmmProfileEntry[Index].Instruction == InstructionAddress) && + (SmmProfileEntry[Index].SmiCmd == SmiCommand)) { + // + // Same record exist, need not save again. + // + break; + } + } + if (Index == mSmmProfileBase->CurDataEntries) { + CurrentEntryNumber = (UINTN) mSmmProfileBase->CurDataEntries; + MaxEntryNumber = (UINTN) mSmmProfileBase->MaxDataEntries; + if (FeaturePcdGet (PcdCpuSmmProfileRingBuffer)) { + CurrentEntryNumber = CurrentEntryNumber % MaxEntryNumber; + } + if (CurrentEntryNumber < MaxEntryNumber) { + // + // Log the new entry + // + SmmProfileEntry[CurrentEntryNumber].SmiNum = mSmmProfileBase->NumSmis; + SmmProfileEntry[CurrentEntryNumber].ErrorCode = (UINT64)ErrorCode; + SmmProfileEntry[CurrentEntryNumber].ApicId = (UINT64)GetApicId (); + SmmProfileEntry[CurrentEntryNumber].CpuNum = (UINT64)CpuIndex; + SmmProfileEntry[CurrentEntryNumber].Address = PFAddress; + SmmProfileEntry[CurrentEntryNumber].Instruction = InstructionAddress; + SmmProfileEntry[CurrentEntryNumber].SmiCmd = SmiCommand; + // + // Update current entry index and data size in the header. + // + mSmmProfileBase->CurDataEntries++; + mSmmProfileBase->CurDataSize = MultU64x64 (mSmmProfileBase->CurDataEntries, sizeof (SMM_PROFILE_ENTRY)); + } + } + } + // + // Flush TLB + // + CpuFlushTlb (); + + if (mBtsSupported) { + EnableBTS (); + } +} + +/** + Replace INT1 exception handler to restore page table to absent/execute-disable state + in order to trigger page fault again to save SMM profile data.. + +**/ +VOID +InitIdtr ( + VOID + ) +{ + EFI_STATUS Status; + + Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_DEBUG, DebugExceptionHandler); + ASSERT_EFI_ERROR (Status); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h new file mode 100644 index 0000000000..04a3dfb2e8 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h @@ -0,0 +1,126 @@ +/** @file +SMM profile header file. + +Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_PROFILE_H_ +#define _SMM_PROFILE_H_ + +#include "SmmProfileInternal.h" + +// +// External functions +// + +/** + Initialize processor environment for SMM profile. + + @param CpuIndex The index of the processor. + +**/ +VOID +ActivateSmmProfile ( + IN UINTN CpuIndex + ); + +/** + Initialize SMM profile in SMM CPU entry point. + + @param[in] Cr3 The base address of the page tables to use in SMM. + +**/ +VOID +InitSmmProfile ( + UINT32 Cr3 + ); + +/** + Increase SMI number in each SMI entry. + +**/ +VOID +SmmProfileRecordSmiNum ( + VOID + ); + +/** + The Page fault handler to save SMM profile data. + + @param Rip The RIP when exception happens. + @param ErrorCode The Error code of exception. + +**/ +VOID +SmmProfilePFHandler ( + UINTN Rip, + UINTN ErrorCode + ); + +/** + Updates page table to make some memory ranges (like system memory) absent + and make some memory ranges (like MMIO) present and execute disable. It also + update 2MB-page to 4KB-page for some memory ranges. + +**/ +VOID +SmmProfileStart ( + VOID + ); + +/** + Page fault IDT handler for SMM Profile. + +**/ +VOID +EFIAPI +PageFaultIdtHandlerSmmProfile ( + VOID + ); + + +/** + Check if XD feature is supported by a processor. + +**/ +VOID +CheckFeatureSupported ( + VOID + ); + +/** + Update page table according to protected memory ranges and the 4KB-page mapped memory ranges. + +**/ +VOID +InitPaging ( + VOID + ); + +/** + Get CPU Index from APIC ID. + +**/ +UINTN +GetCpuIndex ( + VOID + ); + +// +// The flag indicates if execute-disable is supported by processor. +// +extern BOOLEAN mXdSupported; +// +// The flag indicates if execute-disable is enabled on processor. +// +extern BOOLEAN mXdEnabled; + +#endif // _SMM_PROFILE_H_ diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h new file mode 100644 index 0000000000..a21689145b --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h @@ -0,0 +1,165 @@ +/** @file +SMM profile internal header file. + +Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_PROFILE_INTERNAL_H_ +#define _SMM_PROFILE_INTERNAL_H_ + +#include +#include +#include +#include +#include +#include +#include + +#include "SmmProfileArch.h" + +// +// Configure the SMM_PROFILE DTS region size +// +#define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M + +#define MAX_PF_PAGE_COUNT 0x2 + +#define PEBS_RECORD_NUMBER 0x2 + +#define MAX_PF_ENTRY_COUNT 10 + +// +// This MACRO just enable unit test for the profile +// Please disable it. +// + +#define IA32_PF_EC_ID (1u << 4) + +#define SMM_PROFILE_NAME L"SmmProfileData" + +// +// CPU generic definition +// +#define CPUID1_EDX_XD_SUPPORT 0x100000 +#define MSR_EFER 0xc0000080 +#define MSR_EFER_XD 0x800 + +#define CPUID1_EDX_BTS_AVAILABLE 0x200000 + +#define DR6_SINGLE_STEP 0x4000 +#define RFLAG_TF 0x100 + +#define MSR_DEBUG_CTL 0x1D9 +#define MSR_DEBUG_CTL_LBR 0x1 +#define MSR_DEBUG_CTL_TR 0x40 +#define MSR_DEBUG_CTL_BTS 0x80 +#define MSR_DEBUG_CTL_BTINT 0x100 +#define MSR_DS_AREA 0x600 + +typedef struct { + EFI_PHYSICAL_ADDRESS Base; + EFI_PHYSICAL_ADDRESS Top; +} MEMORY_RANGE; + +typedef struct { + MEMORY_RANGE Range; + BOOLEAN Present; + BOOLEAN Nx; +} MEMORY_PROTECTION_RANGE; + +typedef struct { + UINT64 HeaderSize; + UINT64 MaxDataEntries; + UINT64 MaxDataSize; + UINT64 CurDataEntries; + UINT64 CurDataSize; + UINT64 TsegStart; + UINT64 TsegSize; + UINT64 NumSmis; + UINT64 NumCpus; +} SMM_PROFILE_HEADER; + +typedef struct { + UINT64 SmiNum; + UINT64 CpuNum; + UINT64 ApicId; + UINT64 ErrorCode; + UINT64 Instruction; + UINT64 Address; + UINT64 SmiCmd; +} SMM_PROFILE_ENTRY; + +extern SMM_S3_RESUME_STATE *mSmmS3ResumeState; +extern UINTN gSmiExceptionHandlers[]; +extern BOOLEAN mXdSupported; +extern UINTN *mPFEntryCount; +extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; +extern UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT]; + +// +// Internal functions +// + +/** + Update IDT table to replace page fault handler and INT 1 handler. + +**/ +VOID +InitIdtr ( + VOID + ); + +/** + Check if the memory address will be mapped by 4KB-page. + + @param Address The address of Memory. + +**/ +BOOLEAN +IsAddressSplit ( + IN EFI_PHYSICAL_ADDRESS Address + ); + +/** + Check if the memory address will be mapped by 4KB-page. + + @param Address The address of Memory. + @param Nx The flag indicates if the memory is execute-disable. + +**/ +BOOLEAN +IsAddressValid ( + IN EFI_PHYSICAL_ADDRESS Address, + IN BOOLEAN *Nx + ); + +/** + Page Fault handler for SMM use. + +**/ +VOID +SmiDefaultPFHandler ( + VOID + ); + +/** + Clear TF in FLAGS. + + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. + +**/ +VOID +ClearTrapFlag ( + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ); + +#endif // _SMM_PROFILE_H_ diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c new file mode 100644 index 0000000000..3188d43818 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c @@ -0,0 +1,738 @@ +/** @file +Provides services to access SMRAM Save State Map + +Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "PiSmmCpuDxeSmm.h" + +typedef struct { + UINT64 Signature; // Offset 0x00 + UINT16 Reserved1; // Offset 0x08 + UINT16 Reserved2; // Offset 0x0A + UINT16 Reserved3; // Offset 0x0C + UINT16 SmmCs; // Offset 0x0E + UINT16 SmmDs; // Offset 0x10 + UINT16 SmmSs; // Offset 0x12 + UINT16 SmmOtherSegment; // Offset 0x14 + UINT16 Reserved4; // Offset 0x16 + UINT64 Reserved5; // Offset 0x18 + UINT64 Reserved6; // Offset 0x20 + UINT64 Reserved7; // Offset 0x28 + UINT64 SmmGdtPtr; // Offset 0x30 + UINT32 SmmGdtSize; // Offset 0x38 + UINT32 Reserved8; // Offset 0x3C + UINT64 Reserved9; // Offset 0x40 + UINT64 Reserved10; // Offset 0x48 + UINT16 Reserved11; // Offset 0x50 + UINT16 Reserved12; // Offset 0x52 + UINT32 Reserved13; // Offset 0x54 + UINT64 Reserved14; // Offset 0x58 +} PROCESSOR_SMM_DESCRIPTOR; + +extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd; + +// +// EFER register LMA bit +// +#define LMA BIT10 + +/// +/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY +/// +#define SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field) + +/// +/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_REGISTER_RANGE +/// +#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 } + +/// +/// Structure used to describe a range of registers +/// +typedef struct { + EFI_SMM_SAVE_STATE_REGISTER Start; + EFI_SMM_SAVE_STATE_REGISTER End; + UINTN Length; +} CPU_SMM_SAVE_STATE_REGISTER_RANGE; + +/// +/// Structure used to build a lookup table to retrieve the widths and offsets +/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value +/// + +#define SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1 +#define SMM_SAVE_STATE_REGISTER_IOMISC_INDEX 2 +#define SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX 3 +#define SMM_SAVE_STATE_REGISTER_MAX_INDEX 4 + +typedef struct { + UINT8 Width32; + UINT8 Width64; + UINT16 Offset32; + UINT16 Offset64Lo; + UINT16 Offset64Hi; + BOOLEAN Writeable; +} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY; + +/// +/// Structure used to build a lookup table for the IOMisc width information +/// +typedef struct { + UINT8 Width; + EFI_SMM_SAVE_STATE_IO_WIDTH IoWidth; +} CPU_SMM_SAVE_STATE_IO_WIDTH; + +/// +/// Variables from SMI Handler +/// +extern UINT32 gSmbase; +extern volatile UINT32 gSmiStack; +extern UINT32 gSmiCr3; +extern volatile UINT8 gcSmiHandlerTemplate[]; +extern CONST UINT16 gcSmiHandlerSize; + +// +// Variables used by SMI Handler +// +IA32_DESCRIPTOR gSmiHandlerIdtr; + +/// +/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER +/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY +/// +CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = { + SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, EFI_SMM_SAVE_STATE_REGISTER_LDTINFO), + SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES, EFI_SMM_SAVE_STATE_REGISTER_RIP), + SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS, EFI_SMM_SAVE_STATE_REGISTER_CR4), + { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0 } +}; + +/// +/// Lookup table used to retrieve the widths and offsets associated with each +/// supported EFI_SMM_SAVE_STATE_REGISTER value +/// +CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = { + {0, 0, 0, 0, 0, FALSE}, // Reserved + + // + // Internally defined CPU Save State Registers. Not defined in PI SMM CPU Protocol. + // + {4, 4, SMM_CPU_OFFSET (x86.SMMRevId) , SMM_CPU_OFFSET (x64.SMMRevId) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX = 1 + {4, 4, SMM_CPU_OFFSET (x86.IOMisc) , SMM_CPU_OFFSET (x64.IOMisc) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_IOMISC_INDEX = 2 + {4, 8, SMM_CPU_OFFSET (x86.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) + 4, FALSE}, // SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX = 3 + + // + // CPU Save State registers defined in PI SMM CPU Protocol. + // + {0, 8, 0 , SMM_CPU_OFFSET (x64.GdtBaseLoDword) , SMM_CPU_OFFSET (x64.GdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTBASE = 4 + {0, 8, 0 , SMM_CPU_OFFSET (x64.IdtBaseLoDword) , SMM_CPU_OFFSET (x64.IdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTBASE = 5 + {0, 8, 0 , SMM_CPU_OFFSET (x64.LdtBaseLoDword) , SMM_CPU_OFFSET (x64.LdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTBASE = 6 + {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT = 7 + {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT = 8 + {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT = 9 + {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTINFO = 10 + + {4, 4, SMM_CPU_OFFSET (x86._ES) , SMM_CPU_OFFSET (x64._ES) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_ES = 20 + {4, 4, SMM_CPU_OFFSET (x86._CS) , SMM_CPU_OFFSET (x64._CS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CS = 21 + {4, 4, SMM_CPU_OFFSET (x86._SS) , SMM_CPU_OFFSET (x64._SS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_SS = 22 + {4, 4, SMM_CPU_OFFSET (x86._DS) , SMM_CPU_OFFSET (x64._DS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DS = 23 + {4, 4, SMM_CPU_OFFSET (x86._FS) , SMM_CPU_OFFSET (x64._FS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_FS = 24 + {4, 4, SMM_CPU_OFFSET (x86._GS) , SMM_CPU_OFFSET (x64._GS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GS = 25 + {0, 4, 0 , SMM_CPU_OFFSET (x64._LDTR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL = 26 + {4, 4, SMM_CPU_OFFSET (x86._TR) , SMM_CPU_OFFSET (x64._TR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_TR_SEL = 27 + {4, 8, SMM_CPU_OFFSET (x86._DR7) , SMM_CPU_OFFSET (x64._DR7) , SMM_CPU_OFFSET (x64._DR7) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR7 = 28 + {4, 8, SMM_CPU_OFFSET (x86._DR6) , SMM_CPU_OFFSET (x64._DR6) , SMM_CPU_OFFSET (x64._DR6) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR6 = 29 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R8) , SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R8 = 30 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R9) , SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R9 = 31 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R10) , SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R10 = 32 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R11) , SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R11 = 33 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R12) , SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R12 = 34 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R13) , SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R13 = 35 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R14) , SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R14 = 36 + {0, 8, 0 , SMM_CPU_OFFSET (x64._R15) , SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R15 = 37 + {4, 8, SMM_CPU_OFFSET (x86._EAX) , SMM_CPU_OFFSET (x64._RAX) , SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RAX = 38 + {4, 8, SMM_CPU_OFFSET (x86._EBX) , SMM_CPU_OFFSET (x64._RBX) , SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBX = 39 + {4, 8, SMM_CPU_OFFSET (x86._ECX) , SMM_CPU_OFFSET (x64._RCX) , SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RCX = 40 + {4, 8, SMM_CPU_OFFSET (x86._EDX) , SMM_CPU_OFFSET (x64._RDX) , SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDX = 41 + {4, 8, SMM_CPU_OFFSET (x86._ESP) , SMM_CPU_OFFSET (x64._RSP) , SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSP = 42 + {4, 8, SMM_CPU_OFFSET (x86._EBP) , SMM_CPU_OFFSET (x64._RBP) , SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBP = 43 + {4, 8, SMM_CPU_OFFSET (x86._ESI) , SMM_CPU_OFFSET (x64._RSI) , SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSI = 44 + {4, 8, SMM_CPU_OFFSET (x86._EDI) , SMM_CPU_OFFSET (x64._RDI) , SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDI = 45 + {4, 8, SMM_CPU_OFFSET (x86._EIP) , SMM_CPU_OFFSET (x64._RIP) , SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RIP = 46 + + {4, 8, SMM_CPU_OFFSET (x86._EFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RFLAGS = 51 + {4, 8, SMM_CPU_OFFSET (x86._CR0) , SMM_CPU_OFFSET (x64._CR0) , SMM_CPU_OFFSET (x64._CR0) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR0 = 52 + {4, 8, SMM_CPU_OFFSET (x86._CR3) , SMM_CPU_OFFSET (x64._CR3) , SMM_CPU_OFFSET (x64._CR3) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR3 = 53 + {0, 4, 0 , SMM_CPU_OFFSET (x64._CR4) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR4 = 54 +}; + +/// +/// Lookup table for the IOMisc width information +/// +CONST CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] = { + { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 0 + { 1, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // SMM_IO_LENGTH_BYTE = 1 + { 2, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT16 }, // SMM_IO_LENGTH_WORD = 2 + { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 3 + { 4, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT32 }, // SMM_IO_LENGTH_DWORD = 4 + { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 5 + { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 6 + { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 } // Undefined = 7 +}; + +/// +/// Lookup table for the IOMisc type information +/// +CONST EFI_SMM_SAVE_STATE_IO_TYPE mSmmCpuIoType[] = { + EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_DX = 0 + EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_IN_DX = 1 + EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_OUTS = 2 + EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_INS = 3 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 4 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 5 + EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // SMM_IO_TYPE_REP_OUTS = 6 + EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // SMM_IO_TYPE_REP_INS = 7 + EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_IMMEDIATE = 8 + EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_OUT_IMMEDIATE = 9 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 10 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 11 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 12 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 13 + (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 14 + (EFI_SMM_SAVE_STATE_IO_TYPE)0 // Undefined = 15 +}; + +/// +/// The mode of the CPU at the time an SMI occurs +/// +UINT8 mSmmSaveStateRegisterLma; + +/** + Read information from the CPU save state. + + @param Register Specifies the CPU register to read form the save state. + + @retval 0 Register is not valid + @retval >0 Index into mSmmCpuWidthOffset[] associated with Register + +**/ +UINTN +GetRegisterIndex ( + IN EFI_SMM_SAVE_STATE_REGISTER Register + ) +{ + UINTN Index; + UINTN Offset; + + for (Index = 0, Offset = SMM_SAVE_STATE_REGISTER_MAX_INDEX; mSmmCpuRegisterRanges[Index].Length != 0; Index++) { + if (Register >= mSmmCpuRegisterRanges[Index].Start && Register <= mSmmCpuRegisterRanges[Index].End) { + return Register - mSmmCpuRegisterRanges[Index].Start + Offset; + } + Offset += mSmmCpuRegisterRanges[Index].Length; + } + return 0; +} + +/** + Read a CPU Save State register on the target processor. + + This function abstracts the differences that whether the CPU Save State register is in the + IA32 CPU Save State Map or X64 CPU Save State Map. + + This function supports reading a CPU Save State register in SMBase relocation handler. + + @param[in] CpuIndex Specifies the zero-based index of the CPU save state. + @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. + @param[in] Width The number of bytes to read from the CPU save state. + @param[out] Buffer Upon return, this holds the CPU register value read from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. + @retval EFI_INVALID_PARAMTER This or Buffer is NULL. + +**/ +EFI_STATUS +ReadSaveStateRegisterByIndex ( + IN UINTN CpuIndex, + IN UINTN RegisterIndex, + IN UINTN Width, + OUT VOID *Buffer + ) +{ + SMRAM_SAVE_STATE_MAP *CpuSaveState; + + if (RegisterIndex == 0) { + return EFI_NOT_FOUND; + } + + CpuSaveState = gSmst->CpuSaveState[CpuIndex]; + + if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { + // + // If 32-bit mode width is zero, then the specified register can not be accessed + // + if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { + return EFI_NOT_FOUND; + } + + // + // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed + // + if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { + return EFI_INVALID_PARAMETER; + } + + // + // Write return buffer + // + ASSERT(CpuSaveState != NULL); + CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width); + } else { + // + // If 64-bit mode width is zero, then the specified register can not be accessed + // + if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { + return EFI_NOT_FOUND; + } + + // + // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed + // + if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { + return EFI_INVALID_PARAMETER; + } + + // + // Write lower 32-bits of return buffer + // + CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width)); + if (Width >= 4) { + // + // Write upper 32-bits of return buffer + // + CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4); + } + } + return EFI_SUCCESS; +} + +/** + Read a CPU Save State register on the target processor. + + This function abstracts the differences that whether the CPU Save State register is in the + IA32 CPU Save State Map or X64 CPU Save State Map. + + This function supports reading a CPU Save State register in SMBase relocation handler. + + @param[in] CpuIndex Specifies the zero-based index of the CPU save state. + @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. + @param[in] Width The number of bytes to read from the CPU save state. + @param[out] Buffer Upon return, this holds the CPU register value read from the save state. + + @retval EFI_SUCCESS The register was read from Save State. + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. + @retval EFI_INVALID_PARAMTER This or Buffer is NULL. + +**/ +EFI_STATUS +EFIAPI +ReadSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + OUT VOID *Buffer + ) +{ + UINT32 SmmRevId; + SMRAM_SAVE_STATE_IOMISC IoMisc; + EFI_SMM_SAVE_STATE_IO_INFO *IoInfo; + VOID *IoMemAddr; + + // + // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { + // + // Only byte access is supported for this register + // + if (Width != 1) { + return EFI_INVALID_PARAMETER; + } + + *(UINT8 *)Buffer = mSmmSaveStateRegisterLma; + + return EFI_SUCCESS; + } + + // + // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { + // + // Get SMM Revision ID + // + ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX, sizeof(SmmRevId), &SmmRevId); + + // + // See if the CPU supports the IOMisc register in the save state + // + if (SmmRevId < SMRAM_SAVE_STATE_MIN_REV_ID_IOMISC) { + return EFI_NOT_FOUND; + } + + // + // Get the IOMisc register value + // + ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_IOMISC_INDEX, sizeof(IoMisc.Uint32), &IoMisc.Uint32); + + // + // Check for the SMI_FLAG in IOMisc + // + if (IoMisc.Bits.SmiFlag == 0) { + return EFI_NOT_FOUND; + } + + // + // Compute index for the I/O Length and I/O Type lookup tables + // + if (mSmmCpuIoWidth[IoMisc.Bits.Length].Width == 0 || mSmmCpuIoType[IoMisc.Bits.Type] == 0) { + return EFI_NOT_FOUND; + } + + // + // Zero the IoInfo structure that will be returned in Buffer + // + IoInfo = (EFI_SMM_SAVE_STATE_IO_INFO *)Buffer; + ZeroMem (IoInfo, sizeof(EFI_SMM_SAVE_STATE_IO_INFO)); + + // + // Use lookup tables to help fill in all the fields of the IoInfo structure + // + IoInfo->IoPort = (UINT16)IoMisc.Bits.Port; + IoInfo->IoWidth = mSmmCpuIoWidth[IoMisc.Bits.Length].IoWidth; + IoInfo->IoType = mSmmCpuIoType[IoMisc.Bits.Type]; + if (IoInfo->IoType == EFI_SMM_SAVE_STATE_IO_TYPE_INPUT || IoInfo->IoType == EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT) { + ReadSaveStateRegister (CpuIndex, EFI_SMM_SAVE_STATE_REGISTER_RAX, mSmmCpuIoWidth[IoMisc.Bits.Length].Width, &IoInfo->IoData); + } + else { + ReadSaveStateRegisterByIndex(CpuIndex, SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX, sizeof(IoMemAddr), &IoMemAddr); + CopyMem(&IoInfo->IoData, IoMemAddr, mSmmCpuIoWidth[IoMisc.Bits.Length].Width); + } + return EFI_SUCCESS; + } + + // + // Convert Register to a register lookup table index + // + return ReadSaveStateRegisterByIndex (CpuIndex, GetRegisterIndex (Register), Width, Buffer); +} + +/** + Write value to a CPU Save State register on the target processor. + + This function abstracts the differences that whether the CPU Save State register is in the + IA32 CPU Save State Map or X64 CPU Save State Map. + + This function supports writing a CPU Save State register in SMBase relocation handler. + + @param[in] CpuIndex Specifies the zero-based index of the CPU save state. + @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. + @param[in] Width The number of bytes to read from the CPU save state. + @param[in] Buffer Upon entry, this holds the new CPU register value. + + @retval EFI_SUCCESS The register was written to Save State. + @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. + @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct. + +**/ +EFI_STATUS +EFIAPI +WriteSaveStateRegister ( + IN UINTN CpuIndex, + IN EFI_SMM_SAVE_STATE_REGISTER Register, + IN UINTN Width, + IN CONST VOID *Buffer + ) +{ + UINTN RegisterIndex; + SMRAM_SAVE_STATE_MAP *CpuSaveState; + + // + // Writes to EFI_SMM_SAVE_STATE_REGISTER_LMA are ignored + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { + return EFI_SUCCESS; + } + + // + // Writes to EFI_SMM_SAVE_STATE_REGISTER_IO are not supported + // + if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { + return EFI_NOT_FOUND; + } + + // + // Convert Register to a register lookup table index + // + RegisterIndex = GetRegisterIndex (Register); + if (RegisterIndex == 0) { + return EFI_NOT_FOUND; + } + + CpuSaveState = gSmst->CpuSaveState[CpuIndex]; + + // + // Do not write non-writable SaveState, because it will cause exception. + // + if (!mSmmCpuWidthOffset[RegisterIndex].Writeable) { + return EFI_UNSUPPORTED; + } + + // + // Check CPU mode + // + if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { + // + // If 32-bit mode width is zero, then the specified register can not be accessed + // + if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { + return EFI_NOT_FOUND; + } + + // + // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed + // + if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { + return EFI_INVALID_PARAMETER; + } + // + // Write SMM State register + // + ASSERT (CpuSaveState != NULL); + CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width); + } else { + // + // If 64-bit mode width is zero, then the specified register can not be accessed + // + if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { + return EFI_NOT_FOUND; + } + + // + // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed + // + if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { + return EFI_INVALID_PARAMETER; + } + + // + // Write lower 32-bits of SMM State register + // + CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width)); + if (Width >= 4) { + // + // Write upper 32-bits of SMM State register + // + CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4); + } + } + return EFI_SUCCESS; +} + +/** + Hook the code executed immediately after an RSM instruction on the currently + executing CPU. The mode of code executed immediately after RSM must be + detected, and the appropriate hook must be selected. Always clear the auto + HALT restart flag if it is set. + + @param[in] CpuIndex The processor index for the currently + executing CPU. + @param[in] CpuState Pointer to SMRAM Save State Map for the + currently executing CPU. + @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to + 32-bit mode from 64-bit SMM. + @param[in] NewInstructionPointer Instruction pointer to use if resuming to + same mode as SMM. + + @retval The value of the original instruction pointer before it was hooked. + +**/ +UINT64 +EFIAPI +HookReturnFromSmm ( + IN UINTN CpuIndex, + SMRAM_SAVE_STATE_MAP *CpuState, + UINT64 NewInstructionPointer32, + UINT64 NewInstructionPointer + ) +{ + UINT64 OriginalInstructionPointer; + + OriginalInstructionPointer = SmmCpuFeaturesHookReturnFromSmm ( + CpuIndex, + CpuState, + NewInstructionPointer32, + NewInstructionPointer + ); + if (OriginalInstructionPointer != 0) { + return OriginalInstructionPointer; + } + + if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { + OriginalInstructionPointer = (UINT64)CpuState->x86._EIP; + CpuState->x86._EIP = (UINT32)NewInstructionPointer; + // + // Clear the auto HALT restart flag so the RSM instruction returns + // program control to the instruction following the HLT instruction. + // + if ((CpuState->x86.AutoHALTRestart & BIT0) != 0) { + CpuState->x86.AutoHALTRestart &= ~BIT0; + } + } else { + OriginalInstructionPointer = CpuState->x64._RIP; + if ((CpuState->x64.IA32_EFER & LMA) == 0) { + CpuState->x64._RIP = (UINT32)NewInstructionPointer32; + } else { + CpuState->x64._RIP = (UINT32)NewInstructionPointer; + } + // + // Clear the auto HALT restart flag so the RSM instruction returns + // program control to the instruction following the HLT instruction. + // + if ((CpuState->x64.AutoHALTRestart & BIT0) != 0) { + CpuState->x64.AutoHALTRestart &= ~BIT0; + } + } + return OriginalInstructionPointer; +} + +/** + Get the size of the SMI Handler in bytes. + + @retval The size, in bytes, of the SMI Handler. + +**/ +UINTN +EFIAPI +GetSmiHandlerSize ( + VOID + ) +{ + UINTN Size; + + Size = SmmCpuFeaturesGetSmiHandlerSize (); + if (Size != 0) { + return Size; + } + return gcSmiHandlerSize; +} + +/** + Install the SMI handler for the CPU specified by CpuIndex. This function + is called by the CPU that was elected as monarch during System Management + Mode initialization. + + @param[in] CpuIndex The index of the CPU to install the custom SMI handler. + The value must be between 0 and the NumberOfCpus field + in the System Management System Table (SMST). + @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. + @param[in] SmiStack The stack to use when an SMI is processed by the + the CPU specified by CpuIndex. + @param[in] StackSize The size, in bytes, if the stack used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtBase The base address of the GDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtBase The base address of the IDT to use when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is + processed by the CPU specified by CpuIndex. + @param[in] Cr3 The base address of the page tables to use when an SMI + is processed by the CPU specified by CpuIndex. +**/ +VOID +EFIAPI +InstallSmiHandler ( + IN UINTN CpuIndex, + IN UINT32 SmBase, + IN VOID *SmiStack, + IN UINTN StackSize, + IN UINTN GdtBase, + IN UINTN GdtSize, + IN UINTN IdtBase, + IN UINTN IdtSize, + IN UINT32 Cr3 + ) +{ + PROCESSOR_SMM_DESCRIPTOR *Psd; + + // + // Initialize PROCESSOR_SMM_DESCRIPTOR + // + Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + SMM_PSD_OFFSET); + CopyMem (Psd, &gcPsd, sizeof (gcPsd)); + Psd->SmmGdtPtr = (UINT64)GdtBase; + Psd->SmmGdtSize = (UINT32)GdtSize; + + if (SmmCpuFeaturesGetSmiHandlerSize () != 0) { + // + // Install SMI handler provided by library + // + SmmCpuFeaturesInstallSmiHandler ( + CpuIndex, + SmBase, + SmiStack, + StackSize, + GdtBase, + GdtSize, + IdtBase, + IdtSize, + Cr3 + ); + return; + } + + // + // Initialize values in template before copy + // + gSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); + gSmiCr3 = Cr3; + gSmbase = SmBase; + gSmiHandlerIdtr.Base = IdtBase; + gSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1); + + // + // Set the value at the top of the CPU stack to the CPU Index + // + *(UINTN*)(UINTN)gSmiStack = CpuIndex; + + // + // Copy template to CPU specific SMI handler location + // + CopyMem ( + (VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET), + (VOID*)gcSmiHandlerTemplate, + gcSmiHandlerSize + ); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c new file mode 100644 index 0000000000..5a632eaa24 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c @@ -0,0 +1,116 @@ +/** @file +SMM Timer feature support + +Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +UINT64 mTimeoutTicker = 0; +// +// Number of counts in a roll-over cycle of the performance counter. +// +UINT64 mCycle = 0; +// +// Flag to indicate the performance counter is count-up or count-down. +// +BOOLEAN mCountDown; + +/** + Initialize Timer for SMM AP Sync. + +**/ +VOID +InitializeSmmTimer ( + VOID + ) +{ + UINT64 TimerFrequency; + UINT64 Start; + UINT64 End; + + TimerFrequency = GetPerformanceCounterProperties (&Start, &End); + mTimeoutTicker = DivU64x32 ( + MultU64x64(TimerFrequency, PcdGet64 (PcdCpuSmmApSyncTimeout)), + 1000 * 1000 + ); + if (End < Start) { + mCountDown = TRUE; + mCycle = Start - End; + } else { + mCountDown = FALSE; + mCycle = End - Start; + } +} + +/** + Start Timer for SMM AP Sync. + +**/ +UINT64 +EFIAPI +StartSyncTimer ( + VOID + ) +{ + return GetPerformanceCounter (); +} + + +/** + Check if the SMM AP Sync timer is timeout. + + @param Timer The start timer from the begin. + +**/ +BOOLEAN +EFIAPI +IsSyncTimerTimeout ( + IN UINT64 Timer + ) +{ + UINT64 CurrentTimer; + UINT64 Delta; + + CurrentTimer = GetPerformanceCounter (); + // + // We need to consider the case that CurrentTimer is equal to Timer + // when some timer runs too slow and CPU runs fast. We think roll over + // condition does not happen on this case. + // + if (mCountDown) { + // + // The performance counter counts down. Check for roll over condition. + // + if (CurrentTimer <= Timer) { + Delta = Timer - CurrentTimer; + } else { + // + // Handle one roll-over. + // + Delta = mCycle - (CurrentTimer - Timer) + 1; + } + } else { + // + // The performance counter counts up. Check for roll over condition. + // + if (CurrentTimer >= Timer) { + Delta = CurrentTimer - Timer; + } else { + // + // Handle one roll-over. + // + Delta = mCycle - (Timer - CurrentTimer) + 1; + } + } + + return (BOOLEAN) (Delta >= mTimeoutTicker); +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S new file mode 100644 index 0000000000..d7cbc8cdc5 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S @@ -0,0 +1,204 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MpFuncs.S +# +# Abstract: +# +# This is the assembly code for Multi-processor S3 support +# +#------------------------------------------------------------------------------ + +.equ VacantFlag, 0x0 +.equ NotVacantFlag, 0xff + +.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart +.equ StackStartAddressLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08 +.equ StackSizeLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10 +.equ CProcedureLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x18 +.equ GdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20 +.equ IdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x2A +.equ BufferStartLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x34 +.equ Cr3OffsetLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38 + +#------------------------------------------------------------------------------------- +#RendezvousFunnelProc procedure follows. All APs execute their procedure. This +#procedure serializes all the AP processors through an Init sequence. It must be +#noted that APs arrive here very raw...ie: real mode, no stack. +#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +#IS IN MACHINE CODE. +#------------------------------------------------------------------------------------- +#RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +.code: + +ASM_GLOBAL ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: + +# At this point CS = 0x(vv00) and ip= 0x0. + + .byte 0x8c,0xc8 # mov ax, cs + .byte 0x8e,0xd8 # mov ds, ax + .byte 0x8e,0xc0 # mov es, ax + .byte 0x8e,0xd0 # mov ss, ax + .byte 0x33,0xc0 # xor ax, ax + .byte 0x8e,0xe0 # mov fs, ax + .byte 0x8e,0xe8 # mov gs, ax + +flat32Start: + + .byte 0xBE + .word BufferStartLocation + .byte 0x66,0x8B,0x14 # mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer + + .byte 0xBE + .word Cr3OffsetLocation + .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the value of CR3 + + .byte 0xBE + .word GdtrLocation + .byte 0x66 # db 66h + .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si] + + .byte 0xBE + .word IdtrLocation + .byte 0x66 # db 66h + .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si] + + .byte 0x33,0xC0 # xor ax, ax + .byte 0x8E,0xD8 # mov ds, ax + + .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0 + .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0) + .byte 0xF,0x22,0xC0 # mov cr0, eax + +FLAT32_JUMP: + + .byte 0x66,0x67,0xEA # far jump + .long 0x0 # 32-bit offset + .word 0x20 # 16-bit selector + +PMODE_ENTRY: # protected mode entry point + + .byte 0x66,0xB8,0x18,0x0 # mov ax, 18h + .byte 0x66,0x8E,0xD8 # mov ds, ax + .byte 0x66,0x8E,0xC0 # mov es, ax + .byte 0x66,0x8E,0xE0 # mov fs, ax + .byte 0x66,0x8E,0xE8 # mov gs, ax + .byte 0x66,0x8E,0xD0 # mov ss, ax ; Flat mode setup. + + .byte 0xF,0x20,0xE0 # mov eax, cr4 + .byte 0xF,0xBA,0xE8,0x5 # bts eax, 5 + .byte 0xF,0x22,0xE0 # mov cr4, eax + + .byte 0xF,0x22,0xD9 # mov cr3, ecx + + .byte 0x8B,0xF2 # mov esi, edx ; Save wakeup buffer address + + .byte 0xB9 + .long 0xC0000080 # mov ecx, 0c0000080h ; EFER MSR number. + .byte 0xF,0x32 # rdmsr ; Read EFER. + .byte 0xF,0xBA,0xE8,0x8 # bts eax, 8 ; Set LME=1. + .byte 0xF,0x30 # wrmsr ; Write EFER. + + .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Read CR0. + .byte 0xF,0xBA,0xE8,0x1F # bts eax, 31 ; Set PG=1. + .byte 0xF,0x22,0xC0 # mov cr0, eax ; Write CR0. + +LONG_JUMP: + + .byte 0x67,0xEA # far jump + .long 0x0 # 32-bit offset + .word 0x38 # 16-bit selector + +LongModeStart: + + movw $0x30,%ax + .byte 0x66 + movw %ax,%ds + .byte 0x66 + movw %ax,%es + .byte 0x66 + movw %ax,%ss + + movl %esi,%edi + addl $LockLocation, %edi + movb $NotVacantFlag, %al +TestLock: + xchgb (%edi), %al + cmpb $NotVacantFlag, %al + jz TestLock + +ProgramStack: + + movl %esi,%edi + addl $StackSizeLocation, %edi + movq (%edi), %rax + movl %esi,%edi + addl $StackStartAddressLocation, %edi + addq (%edi), %rax + movq %rax, %rsp + movq %rax, (%edi) + +Releaselock: + + movb $VacantFlag, %al + movl %esi,%edi + addl $LockLocation, %edi + xchgb (%edi), %al + + # + # Call assembly function to initialize FPU. + # + movabsq $ASM_PFX(InitializeFloatingPointUnits), %rax + subq $0x20, %rsp + call *%rax + addq $0x20, %rsp + # + # Call C Function + # + movl %esi,%edi + addl $CProcedureLocation, %edi + movq (%edi), %rax + + testq %rax, %rax + jz GoToSleep + + subq $0x20, %rsp + call *%rax + addq $0x20, %rsp + +GoToSleep: + cli + hlt + jmp .-2 + +RendezvousFunnelProcEnd: + + +#------------------------------------------------------------------------------------- +# AsmGetAddressMap (&AddressMap); +#------------------------------------------------------------------------------------- +# comments here for definition of address map +ASM_GLOBAL ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + movabsq $RendezvousFunnelProcStart, %rax + movq %rax, (%rcx) + movq $(PMODE_ENTRY - RendezvousFunnelProcStart), 0x08(%rcx) + movq $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x10(%rcx) + movq $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x18(%rcx) + movq $(LongModeStart - RendezvousFunnelProcStart), 0x20(%rcx) + movq $(LONG_JUMP - RendezvousFunnelProcStart), 0x28(%rcx) + ret + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm new file mode 100644 index 0000000000..2c5a7c9bc2 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm @@ -0,0 +1,206 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.asm +; +; Abstract: +; +; This is the assembly code for Multi-processor S3 support +; +;------------------------------------------------------------------------------- + +EXTERN InitializeFloatingPointUnits:PROC + +VacantFlag Equ 00h +NotVacantFlag Equ 0ffh + +LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart +StackStartAddressLocation equ LockLocation + 08h +StackSizeLocation equ LockLocation + 10h +CProcedureLocation equ LockLocation + 18h +GdtrLocation equ LockLocation + 20h +IdtrLocation equ LockLocation + 2Ah +BufferStartLocation equ LockLocation + 34h +Cr3OffsetLocation equ LockLocation + 38h + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +;text SEGMENT +.code + +RendezvousFunnelProc PROC +RendezvousFunnelProcStart:: + +; At this point CS = 0x(vv00) and ip= 0x0. + + db 8ch, 0c8h ; mov ax, cs + db 8eh, 0d8h ; mov ds, ax + db 8eh, 0c0h ; mov es, ax + db 8eh, 0d0h ; mov ss, ax + db 33h, 0c0h ; xor ax, ax + db 8eh, 0e0h ; mov fs, ax + db 8eh, 0e8h ; mov gs, ax + +flat32Start:: + + db 0BEh + dw BufferStartLocation ; mov si, BufferStartLocation + db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer + + db 0BEh + dw Cr3OffsetLocation ; mov si, Cr3Location + db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the value of CR3 + + db 0BEh + dw GdtrLocation ; mov si, GdtrProfile + db 66h ; db 66h + db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si] + + db 0BEh + dw IdtrLocation ; mov si, IdtrProfile + db 66h ; db 66h + db 2Eh, 0Fh, 01h, 1Ch ; lidt fword ptr cs:[si] + + db 33h, 0C0h ; xor ax, ax + db 8Eh, 0D8h ; mov ds, ax + + db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0 + db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0) + db 0Fh, 22h, 0C0h ; mov cr0, eax + +FLAT32_JUMP:: + + db 66h, 67h, 0EAh ; far jump + dd 0h ; 32-bit offset + dw 20h ; 16-bit selector + +PMODE_ENTRY:: ; protected mode entry point + + db 66h, 0B8h, 18h, 00h ; mov ax, 18h + db 66h, 8Eh, 0D8h ; mov ds, ax + db 66h, 8Eh, 0C0h ; mov es, ax + db 66h, 8Eh, 0E0h ; mov fs, ax + db 66h, 8Eh, 0E8h ; mov gs, ax + db 66h, 8Eh, 0D0h ; mov ss, ax ; Flat mode setup. + + db 0Fh, 20h, 0E0h ; mov eax, cr4 + db 0Fh, 0BAh, 0E8h, 05h ; bts eax, 5 + db 0Fh, 22h, 0E0h ; mov cr4, eax + + db 0Fh, 22h, 0D9h ; mov cr3, ecx + + db 8Bh, 0F2h ; mov esi, edx ; Save wakeup buffer address + + db 0B9h + dd 0C0000080h ; mov ecx, 0c0000080h ; EFER MSR number. + db 0Fh, 32h ; rdmsr ; Read EFER. + db 0Fh, 0BAh, 0E8h, 08h ; bts eax, 8 ; Set LME=1. + db 0Fh, 30h ; wrmsr ; Write EFER. + + db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Read CR0. + db 0Fh, 0BAh, 0E8h, 1Fh ; bts eax, 31 ; Set PG=1. + db 0Fh, 22h, 0C0h ; mov cr0, eax ; Write CR0. + +LONG_JUMP:: + + db 67h, 0EAh ; far jump + dd 0h ; 32-bit offset + dw 38h ; 16-bit selector + +LongModeStart:: + + mov ax, 30h + mov ds, ax + mov es, ax + mov ss, ax + + mov edi, esi + add edi, LockLocation + mov al, NotVacantFlag +TestLock:: + xchg byte ptr [edi], al + cmp al, NotVacantFlag + jz TestLock + +ProgramStack:: + + mov edi, esi + add edi, StackSizeLocation + mov rax, qword ptr [edi] + mov edi, esi + add edi, StackStartAddressLocation + add rax, qword ptr [edi] + mov rsp, rax + mov qword ptr [edi], rax + +Releaselock:: + + mov al, VacantFlag + mov edi, esi + add edi, LockLocation + xchg byte ptr [edi], al + + ; + ; Call assembly function to initialize FPU. + ; + mov rax, InitializeFloatingPointUnits + sub rsp, 20h + call rax + add rsp, 20h + + ; + ; Call C Function + ; + mov edi, esi + add edi, CProcedureLocation + mov rax, qword ptr [edi] + + test rax, rax + jz GoToSleep + + sub rsp, 20h + call rax + add rsp, 20h + +GoToSleep:: + cli + hlt + jmp $-2 + +RendezvousFunnelProcEnd:: +RendezvousFunnelProc ENDP + + +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +; comments here for definition of address map +AsmGetAddressMap PROC + mov rax, offset RendezvousFunnelProcStart + mov qword ptr [rcx], rax + mov qword ptr [rcx+8h], PMODE_ENTRY - RendezvousFunnelProcStart + mov qword ptr [rcx+10h], FLAT32_JUMP - RendezvousFunnelProcStart + mov qword ptr [rcx+18h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + mov qword ptr [rcx+20h], LongModeStart - RendezvousFunnelProcStart + mov qword ptr [rcx+28h], LONG_JUMP - RendezvousFunnelProcStart + ret + +AsmGetAddressMap ENDP + +END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm new file mode 100644 index 0000000000..702233d6e4 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm @@ -0,0 +1,196 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MpFuncs.nasm +; +; Abstract: +; +; This is the assembly code for Multi-processor S3 support +; +;------------------------------------------------------------------------------- + +extern ASM_PFX(InitializeFloatingPointUnits) + +%define VacantFlag 0x0 +%define NotVacantFlag 0xff + +%define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart +%define StackStartAddressLocation LockLocation + 0x8 +%define StackSizeLocation LockLocation + 0x10 +%define CProcedureLocation LockLocation + 0x18 +%define GdtrLocation LockLocation + 0x20 +%define IdtrLocation LockLocation + 0x2A +%define BufferStartLocation LockLocation + 0x34 +%define Cr3OffsetLocation LockLocation + 0x38 + +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc procedure follows. All APs execute their procedure. This +;procedure serializes all the AP processors through an Init sequence. It must be +;noted that APs arrive here very raw...ie: real mode, no stack. +;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC +;IS IN MACHINE CODE. +;------------------------------------------------------------------------------------- +;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); + +;text SEGMENT +DEFAULT REL +SECTION .text + +BITS 16 +global ASM_PFX(RendezvousFunnelProc) +ASM_PFX(RendezvousFunnelProc): +RendezvousFunnelProcStart: + +; At this point CS = 0x(vv00) and ip= 0x0. + + mov ax, cs + mov ds, ax + mov es, ax + mov ss, ax + xor ax, ax + mov fs, ax + mov gs, ax + +flat32Start: + + mov si, BufferStartLocation + mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer + + mov si, Cr3OffsetLocation + mov ecx,dword [si] ; ECX is keeping the value of CR3 + + mov si, GdtrLocation +o32 lgdt [cs:si] + + mov si, IdtrLocation +o32 lidt [cs:si] + + xor ax, ax + mov ds, ax + + mov eax, cr0 ; Get control register 0 + or eax, 0x000000001 ; Set PE bit (bit #0) + mov cr0, eax + +FLAT32_JUMP: + +a32 jmp dword 0x20:0x0 + +BITS 32 +PMODE_ENTRY: ; protected mode entry point + + mov ax, 0x18 +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax ; Flat mode setup. + + mov eax, cr4 + bts eax, 5 + mov cr4, eax + + mov cr3, ecx + + mov esi, edx ; Save wakeup buffer address + + mov ecx, 0xc0000080 ; EFER MSR number. + rdmsr ; Read EFER. + bts eax, 8 ; Set LME=1. + wrmsr ; Write EFER. + + mov eax, cr0 ; Read CR0. + bts eax, 31 ; Set PG=1. + mov cr0, eax ; Write CR0. + +LONG_JUMP: + +a16 jmp dword 0x38:0x0 + +BITS 64 +LongModeStart: + + mov ax, 0x30 +o16 mov ds, ax +o16 mov es, ax +o16 mov ss, ax + + mov edi, esi + add edi, LockLocation + mov al, NotVacantFlag +TestLock: + xchg byte [edi], al + cmp al, NotVacantFlag + jz TestLock + +ProgramStack: + + mov edi, esi + add edi, StackSizeLocation + mov rax, qword [edi] + mov edi, esi + add edi, StackStartAddressLocation + add rax, qword [edi] + mov rsp, rax + mov qword [edi], rax + +Releaselock: + + mov al, VacantFlag + mov edi, esi + add edi, LockLocation + xchg byte [edi], al + + ; + ; Call assembly function to initialize FPU. + ; + mov rax, ASM_PFX(InitializeFloatingPointUnits) + sub rsp, 0x20 + call rax + add rsp, 0x20 + + ; + ; Call C Function + ; + mov edi, esi + add edi, CProcedureLocation + mov rax, qword [edi] + + test rax, rax + jz GoToSleep + + sub rsp, 0x20 + call rax + add rsp, 0x20 + +GoToSleep: + cli + hlt + jmp $-2 + +RendezvousFunnelProcEnd: + +;------------------------------------------------------------------------------------- +; AsmGetAddressMap (&AddressMap); +;------------------------------------------------------------------------------------- +; comments here for definition of address map +global ASM_PFX(AsmGetAddressMap) +ASM_PFX(AsmGetAddressMap): + mov rax, RendezvousFunnelProcStart + mov qword [rcx], rax + mov qword [rcx+0x8], PMODE_ENTRY - RendezvousFunnelProcStart + mov qword [rcx+0x10], FLAT32_JUMP - RendezvousFunnelProcStart + mov qword [rcx+0x18], RendezvousFunnelProcEnd - RendezvousFunnelProcStart + mov qword [rcx+0x20], LongModeStart - RendezvousFunnelProcStart + mov qword [rcx+0x28], LONG_JUMP - RendezvousFunnelProcStart + ret + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c new file mode 100644 index 0000000000..32385faae4 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c @@ -0,0 +1,970 @@ +/** @file +Page Fault (#PF) handler for X64 processors + +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +#define PAGE_TABLE_PAGES 8 +#define ACC_MAX_BIT BIT3 + +LIST_ENTRY mPagePool = INITIALIZE_LIST_HEAD_VARIABLE (mPagePool); +BOOLEAN m1GPageTableSupport = FALSE; +UINT8 mPhysicalAddressBits; +BOOLEAN mCpuSmmStaticPageTable; + +/** + Check if 1-GByte pages is supported by processor or not. + + @retval TRUE 1-GByte pages is supported. + @retval FALSE 1-GByte pages is not supported. + +**/ +BOOLEAN +Is1GPageSupport ( + VOID + ) +{ + UINT32 RegEax; + UINT32 RegEdx; + + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000001) { + AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & BIT26) != 0) { + return TRUE; + } + } + return FALSE; +} + +/** + Set sub-entries number in entry. + + @param[in, out] Entry Pointer to entry + @param[in] SubEntryNum Sub-entries number based on 0: + 0 means there is 1 sub-entry under this entry + 0x1ff means there is 512 sub-entries under this entry + +**/ +VOID +SetSubEntriesNum ( + IN OUT UINT64 *Entry, + IN UINT64 SubEntryNum + ) +{ + // + // Sub-entries number is saved in BIT52 to BIT60 (reserved field) in Entry + // + *Entry = BitFieldWrite64 (*Entry, 52, 60, SubEntryNum); +} + +/** + Return sub-entries number in entry. + + @param[in] Entry Pointer to entry + + @return Sub-entries number based on 0: + 0 means there is 1 sub-entry under this entry + 0x1ff means there is 512 sub-entries under this entry +**/ +UINT64 +GetSubEntriesNum ( + IN UINT64 *Entry + ) +{ + // + // Sub-entries number is saved in BIT52 to BIT60 (reserved field) in Entry + // + return BitFieldRead64 (*Entry, 52, 60); +} + +/** + Calculate the maximum support address. + + @return the maximum support address. +**/ +UINT8 +CalculateMaximumSupportAddress ( + VOID + ) +{ + UINT32 RegEax; + UINT8 PhysicalAddressBits; + VOID *Hob; + + // + // Get physical address bits supported. + // + Hob = GetFirstHob (EFI_HOB_TYPE_CPU); + if (Hob != NULL) { + PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; + } else { + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + PhysicalAddressBits = (UINT8) RegEax; + } else { + PhysicalAddressBits = 36; + } + } + + // + // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses. + // + ASSERT (PhysicalAddressBits <= 52); + if (PhysicalAddressBits > 48) { + PhysicalAddressBits = 48; + } + return PhysicalAddressBits; +} + +/** + Set static page table. + + @param[in] PageTable Address of page table. +**/ +VOID +SetStaticPageTable ( + IN UINTN PageTable + ) +{ + UINT64 PageAddress; + UINTN NumberOfPml4EntriesNeeded; + UINTN NumberOfPdpEntriesNeeded; + UINTN IndexOfPml4Entries; + UINTN IndexOfPdpEntries; + UINTN IndexOfPageDirectoryEntries; + UINT64 *PageMapLevel4Entry; + UINT64 *PageMap; + UINT64 *PageDirectoryPointerEntry; + UINT64 *PageDirectory1GEntry; + UINT64 *PageDirectoryEntry; + + if (mPhysicalAddressBits <= 39 ) { + NumberOfPml4EntriesNeeded = 1; + NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (mPhysicalAddressBits - 30)); + } else { + NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (mPhysicalAddressBits - 39)); + NumberOfPdpEntriesNeeded = 512; + } + + // + // By architecture only one PageMapLevel4 exists - so lets allocate storage for it. + // + PageMap = (VOID *) PageTable; + + PageMapLevel4Entry = PageMap; + PageAddress = 0; + for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) { + // + // Each PML4 entry points to a page of Page Directory Pointer entries. + // + PageDirectoryPointerEntry = (UINT64 *) ((*PageMapLevel4Entry) & ~mAddressEncMask & gPhyMask); + if (PageDirectoryPointerEntry == NULL) { + PageDirectoryPointerEntry = AllocatePageTableMemory (1); + ASSERT(PageDirectoryPointerEntry != NULL); + ZeroMem (PageDirectoryPointerEntry, EFI_PAGES_TO_SIZE(1)); + + *PageMapLevel4Entry = (UINT64)(UINTN)PageDirectoryPointerEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + } + + if (m1GPageTableSupport) { + PageDirectory1GEntry = PageDirectoryPointerEntry; + for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) { + if (IndexOfPml4Entries == 0 && IndexOfPageDirectoryEntries < 4) { + // + // Skip the < 4G entries + // + continue; + } + // + // Fill in the Page Directory entries + // + *PageDirectory1GEntry = PageAddress | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; + } + } else { + PageAddress = BASE_4GB; + for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) { + if (IndexOfPml4Entries == 0 && IndexOfPdpEntries < 4) { + // + // Skip the < 4G entries + // + continue; + } + // + // Each Directory Pointer entries points to a page of Page Directory entires. + // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop. + // + PageDirectoryEntry = (UINT64 *) ((*PageDirectoryPointerEntry) & ~mAddressEncMask & gPhyMask); + if (PageDirectoryEntry == NULL) { + PageDirectoryEntry = AllocatePageTableMemory (1); + ASSERT(PageDirectoryEntry != NULL); + ZeroMem (PageDirectoryEntry, EFI_PAGES_TO_SIZE(1)); + + // + // Fill in a Page Directory Pointer Entries + // + *PageDirectoryPointerEntry = (UINT64)(UINTN)PageDirectoryEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + } + + for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) { + // + // Fill in the Page Directory entries + // + *PageDirectoryEntry = PageAddress | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; + } + } + } + } +} + +/** + Create PageTable for SMM use. + + @return The address of PML4 (to set CR3). + +**/ +UINT32 +SmmInitPageTable ( + VOID + ) +{ + EFI_PHYSICAL_ADDRESS Pages; + UINT64 *PTEntry; + LIST_ENTRY *FreePage; + UINTN Index; + UINTN PageFaultHandlerHookAddress; + IA32_IDT_GATE_DESCRIPTOR *IdtEntry; + EFI_STATUS Status; + + // + // Initialize spin lock + // + InitializeSpinLock (mPFLock); + + mCpuSmmStaticPageTable = PcdGetBool (PcdCpuSmmStaticPageTable); + m1GPageTableSupport = Is1GPageSupport (); + DEBUG ((DEBUG_INFO, "1GPageTableSupport - 0x%x\n", m1GPageTableSupport)); + DEBUG ((DEBUG_INFO, "PcdCpuSmmStaticPageTable - 0x%x\n", mCpuSmmStaticPageTable)); + + mPhysicalAddressBits = CalculateMaximumSupportAddress (); + DEBUG ((DEBUG_INFO, "PhysicalAddressBits - 0x%x\n", mPhysicalAddressBits)); + // + // Generate PAE page table for the first 4GB memory space + // + Pages = Gen4GPageTable (FALSE); + + // + // Set IA32_PG_PMNT bit to mask this entry + // + PTEntry = (UINT64*)(UINTN)Pages; + for (Index = 0; Index < 4; Index++) { + PTEntry[Index] |= IA32_PG_PMNT; + } + + // + // Fill Page-Table-Level4 (PML4) entry + // + PTEntry = (UINT64*)AllocatePageTableMemory (1); + ASSERT (PTEntry != NULL); + *PTEntry = Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + ZeroMem (PTEntry + 1, EFI_PAGE_SIZE - sizeof (*PTEntry)); + + // + // Set sub-entries number + // + SetSubEntriesNum (PTEntry, 3); + + if (mCpuSmmStaticPageTable) { + SetStaticPageTable ((UINTN)PTEntry); + } else { + // + // Add pages to page pool + // + FreePage = (LIST_ENTRY*)AllocatePageTableMemory (PAGE_TABLE_PAGES); + ASSERT (FreePage != NULL); + for (Index = 0; Index < PAGE_TABLE_PAGES; Index++) { + InsertTailList (&mPagePool, FreePage); + FreePage += EFI_PAGE_SIZE / sizeof (*FreePage); + } + } + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + // + // Set own Page Fault entry instead of the default one, because SMM Profile + // feature depends on IRET instruction to do Single Step + // + PageFaultHandlerHookAddress = (UINTN)PageFaultIdtHandlerSmmProfile; + IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) gcSmiIdtr.Base; + IdtEntry += EXCEPT_IA32_PAGE_FAULT; + IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress; + IdtEntry->Bits.Reserved_0 = 0; + IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; + IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16); + IdtEntry->Bits.OffsetUpper = (UINT32)(PageFaultHandlerHookAddress >> 32); + IdtEntry->Bits.Reserved_1 = 0; + } else { + // + // Register Smm Page Fault Handler + // + Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT, SmiPFHandler); + ASSERT_EFI_ERROR (Status); + } + + // + // Additional SMM IDT initialization for SMM stack guard + // + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + InitializeIDTSmmStackGuard (); + } + + // + // Return the address of PML4 (to set CR3) + // + return (UINT32)(UINTN)PTEntry; +} + +/** + Set access record in entry. + + @param[in, out] Entry Pointer to entry + @param[in] Acc Access record value + +**/ +VOID +SetAccNum ( + IN OUT UINT64 *Entry, + IN UINT64 Acc + ) +{ + // + // Access record is saved in BIT9 to BIT11 (reserved field) in Entry + // + *Entry = BitFieldWrite64 (*Entry, 9, 11, Acc); +} + +/** + Return access record in entry. + + @param[in] Entry Pointer to entry + + @return Access record value. + +**/ +UINT64 +GetAccNum ( + IN UINT64 *Entry + ) +{ + // + // Access record is saved in BIT9 to BIT11 (reserved field) in Entry + // + return BitFieldRead64 (*Entry, 9, 11); +} + +/** + Return and update the access record in entry. + + @param[in, out] Entry Pointer to entry + + @return Access record value. + +**/ +UINT64 +GetAndUpdateAccNum ( + IN OUT UINT64 *Entry + ) +{ + UINT64 Acc; + + Acc = GetAccNum (Entry); + if ((*Entry & IA32_PG_A) != 0) { + // + // If this entry has been accessed, clear access flag in Entry and update access record + // to the initial value 7, adding ACC_MAX_BIT is to make it larger than others + // + *Entry &= ~(UINT64)(UINTN)IA32_PG_A; + SetAccNum (Entry, 0x7); + return (0x7 + ACC_MAX_BIT); + } else { + if (Acc != 0) { + // + // If the access record is not the smallest value 0, minus 1 and update the access record field + // + SetAccNum (Entry, Acc - 1); + } + } + return Acc; +} + +/** + Reclaim free pages for PageFault handler. + + Search the whole entries tree to find the leaf entry that has the smallest + access record value. Insert the page pointed by this leaf entry into the + page pool. And check its upper entries if need to be inserted into the page + pool or not. + +**/ +VOID +ReclaimPages ( + VOID + ) +{ + UINT64 *Pml4; + UINT64 *Pdpt; + UINT64 *Pdt; + UINTN Pml4Index; + UINTN PdptIndex; + UINTN PdtIndex; + UINTN MinPml4; + UINTN MinPdpt; + UINTN MinPdt; + UINT64 MinAcc; + UINT64 Acc; + UINT64 SubEntriesNum; + BOOLEAN PML4EIgnore; + BOOLEAN PDPTEIgnore; + UINT64 *ReleasePageAddress; + + Pml4 = NULL; + Pdpt = NULL; + Pdt = NULL; + MinAcc = (UINT64)-1; + MinPml4 = (UINTN)-1; + MinPdpt = (UINTN)-1; + MinPdt = (UINTN)-1; + Acc = 0; + ReleasePageAddress = 0; + + // + // First, find the leaf entry has the smallest access record value + // + Pml4 = (UINT64*)(UINTN)(AsmReadCr3 () & gPhyMask); + for (Pml4Index = 0; Pml4Index < EFI_PAGE_SIZE / sizeof (*Pml4); Pml4Index++) { + if ((Pml4[Pml4Index] & IA32_PG_P) == 0 || (Pml4[Pml4Index] & IA32_PG_PMNT) != 0) { + // + // If the PML4 entry is not present or is masked, skip it + // + continue; + } + Pdpt = (UINT64*)(UINTN)(Pml4[Pml4Index] & ~mAddressEncMask & gPhyMask); + PML4EIgnore = FALSE; + for (PdptIndex = 0; PdptIndex < EFI_PAGE_SIZE / sizeof (*Pdpt); PdptIndex++) { + if ((Pdpt[PdptIndex] & IA32_PG_P) == 0 || (Pdpt[PdptIndex] & IA32_PG_PMNT) != 0) { + // + // If the PDPT entry is not present or is masked, skip it + // + if ((Pdpt[PdptIndex] & IA32_PG_PMNT) != 0) { + // + // If the PDPT entry is masked, we will ignore checking the PML4 entry + // + PML4EIgnore = TRUE; + } + continue; + } + if ((Pdpt[PdptIndex] & IA32_PG_PS) == 0) { + // + // It's not 1-GByte pages entry, it should be a PDPT entry, + // we will not check PML4 entry more + // + PML4EIgnore = TRUE; + Pdt = (UINT64*)(UINTN)(Pdpt[PdptIndex] & ~mAddressEncMask & gPhyMask); + PDPTEIgnore = FALSE; + for (PdtIndex = 0; PdtIndex < EFI_PAGE_SIZE / sizeof(*Pdt); PdtIndex++) { + if ((Pdt[PdtIndex] & IA32_PG_P) == 0 || (Pdt[PdtIndex] & IA32_PG_PMNT) != 0) { + // + // If the PD entry is not present or is masked, skip it + // + if ((Pdt[PdtIndex] & IA32_PG_PMNT) != 0) { + // + // If the PD entry is masked, we will not PDPT entry more + // + PDPTEIgnore = TRUE; + } + continue; + } + if ((Pdt[PdtIndex] & IA32_PG_PS) == 0) { + // + // It's not 2 MByte page table entry, it should be PD entry + // we will find the entry has the smallest access record value + // + PDPTEIgnore = TRUE; + Acc = GetAndUpdateAccNum (Pdt + PdtIndex); + if (Acc < MinAcc) { + // + // If the PD entry has the smallest access record value, + // save the Page address to be released + // + MinAcc = Acc; + MinPml4 = Pml4Index; + MinPdpt = PdptIndex; + MinPdt = PdtIndex; + ReleasePageAddress = Pdt + PdtIndex; + } + } + } + if (!PDPTEIgnore) { + // + // If this PDPT entry has no PDT entries pointer to 4 KByte pages, + // it should only has the entries point to 2 MByte Pages + // + Acc = GetAndUpdateAccNum (Pdpt + PdptIndex); + if (Acc < MinAcc) { + // + // If the PDPT entry has the smallest access record value, + // save the Page address to be released + // + MinAcc = Acc; + MinPml4 = Pml4Index; + MinPdpt = PdptIndex; + MinPdt = (UINTN)-1; + ReleasePageAddress = Pdpt + PdptIndex; + } + } + } + } + if (!PML4EIgnore) { + // + // If PML4 entry has no the PDPT entry pointer to 2 MByte pages, + // it should only has the entries point to 1 GByte Pages + // + Acc = GetAndUpdateAccNum (Pml4 + Pml4Index); + if (Acc < MinAcc) { + // + // If the PML4 entry has the smallest access record value, + // save the Page address to be released + // + MinAcc = Acc; + MinPml4 = Pml4Index; + MinPdpt = (UINTN)-1; + MinPdt = (UINTN)-1; + ReleasePageAddress = Pml4 + Pml4Index; + } + } + } + // + // Make sure one PML4/PDPT/PD entry is selected + // + ASSERT (MinAcc != (UINT64)-1); + + // + // Secondly, insert the page pointed by this entry into page pool and clear this entry + // + InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(*ReleasePageAddress & ~mAddressEncMask & gPhyMask)); + *ReleasePageAddress = 0; + + // + // Lastly, check this entry's upper entries if need to be inserted into page pool + // or not + // + while (TRUE) { + if (MinPdt != (UINTN)-1) { + // + // If 4 KByte Page Table is released, check the PDPT entry + // + Pdpt = (UINT64*)(UINTN)(Pml4[MinPml4] & ~mAddressEncMask & gPhyMask); + SubEntriesNum = GetSubEntriesNum(Pdpt + MinPdpt); + if (SubEntriesNum == 0) { + // + // Release the empty Page Directory table if there was no more 4 KByte Page Table entry + // clear the Page directory entry + // + InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(Pdpt[MinPdpt] & ~mAddressEncMask & gPhyMask)); + Pdpt[MinPdpt] = 0; + // + // Go on checking the PML4 table + // + MinPdt = (UINTN)-1; + continue; + } + // + // Update the sub-entries filed in PDPT entry and exit + // + SetSubEntriesNum (Pdpt + MinPdpt, SubEntriesNum - 1); + break; + } + if (MinPdpt != (UINTN)-1) { + // + // One 2MB Page Table is released or Page Directory table is released, check the PML4 entry + // + SubEntriesNum = GetSubEntriesNum (Pml4 + MinPml4); + if (SubEntriesNum == 0) { + // + // Release the empty PML4 table if there was no more 1G KByte Page Table entry + // clear the Page directory entry + // + InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(Pml4[MinPml4] & ~mAddressEncMask & gPhyMask)); + Pml4[MinPml4] = 0; + MinPdpt = (UINTN)-1; + continue; + } + // + // Update the sub-entries filed in PML4 entry and exit + // + SetSubEntriesNum (Pml4 + MinPml4, SubEntriesNum - 1); + break; + } + // + // PLM4 table has been released before, exit it + // + break; + } +} + +/** + Allocate free Page for PageFault handler use. + + @return Page address. + +**/ +UINT64 +AllocPage ( + VOID + ) +{ + UINT64 RetVal; + + if (IsListEmpty (&mPagePool)) { + // + // If page pool is empty, reclaim the used pages and insert one into page pool + // + ReclaimPages (); + } + + // + // Get one free page and remove it from page pool + // + RetVal = (UINT64)(UINTN)mPagePool.ForwardLink; + RemoveEntryList (mPagePool.ForwardLink); + // + // Clean this page and return + // + ZeroMem ((VOID*)(UINTN)RetVal, EFI_PAGE_SIZE); + return RetVal; +} + +/** + Page Fault handler for SMM use. + +**/ +VOID +SmiDefaultPFHandler ( + VOID + ) +{ + UINT64 *PageTable; + UINT64 *Pml4; + UINT64 PFAddress; + UINTN StartBit; + UINTN EndBit; + UINT64 PTIndex; + UINTN Index; + SMM_PAGE_SIZE_TYPE PageSize; + UINTN NumOfPages; + UINTN PageAttribute; + EFI_STATUS Status; + UINT64 *UpperEntry; + + // + // Set default SMM page attribute + // + PageSize = SmmPageSize2M; + NumOfPages = 1; + PageAttribute = 0; + + EndBit = 0; + Pml4 = (UINT64*)(AsmReadCr3 () & gPhyMask); + PFAddress = AsmReadCr2 (); + + Status = GetPlatformPageTableAttribute (PFAddress, &PageSize, &NumOfPages, &PageAttribute); + // + // If platform not support page table attribute, set default SMM page attribute + // + if (Status != EFI_SUCCESS) { + PageSize = SmmPageSize2M; + NumOfPages = 1; + PageAttribute = 0; + } + if (PageSize >= MaxSmmPageSizeType) { + PageSize = SmmPageSize2M; + } + if (NumOfPages > 512) { + NumOfPages = 512; + } + + switch (PageSize) { + case SmmPageSize4K: + // + // BIT12 to BIT20 is Page Table index + // + EndBit = 12; + break; + case SmmPageSize2M: + // + // BIT21 to BIT29 is Page Directory index + // + EndBit = 21; + PageAttribute |= (UINTN)IA32_PG_PS; + break; + case SmmPageSize1G: + if (!m1GPageTableSupport) { + DEBUG ((DEBUG_ERROR, "1-GByte pages is not supported!")); + ASSERT (FALSE); + } + // + // BIT30 to BIT38 is Page Directory Pointer Table index + // + EndBit = 30; + PageAttribute |= (UINTN)IA32_PG_PS; + break; + default: + ASSERT (FALSE); + } + + // + // If execute-disable is enabled, set NX bit + // + if (mXdEnabled) { + PageAttribute |= IA32_PG_NX; + } + + for (Index = 0; Index < NumOfPages; Index++) { + PageTable = Pml4; + UpperEntry = NULL; + for (StartBit = 39; StartBit > EndBit; StartBit -= 9) { + PTIndex = BitFieldRead64 (PFAddress, StartBit, StartBit + 8); + if ((PageTable[PTIndex] & IA32_PG_P) == 0) { + // + // If the entry is not present, allocate one page from page pool for it + // + PageTable[PTIndex] = AllocPage () | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + } else { + // + // Save the upper entry address + // + UpperEntry = PageTable + PTIndex; + } + // + // BIT9 to BIT11 of entry is used to save access record, + // initialize value is 7 + // + PageTable[PTIndex] |= (UINT64)IA32_PG_A; + SetAccNum (PageTable + PTIndex, 7); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & gPhyMask); + } + + PTIndex = BitFieldRead64 (PFAddress, StartBit, StartBit + 8); + if ((PageTable[PTIndex] & IA32_PG_P) != 0) { + // + // Check if the entry has already existed, this issue may occur when the different + // size page entries created under the same entry + // + DEBUG ((DEBUG_ERROR, "PageTable = %lx, PTIndex = %x, PageTable[PTIndex] = %lx\n", PageTable, PTIndex, PageTable[PTIndex])); + DEBUG ((DEBUG_ERROR, "New page table overlapped with old page table!\n")); + ASSERT (FALSE); + } + // + // Fill the new entry + // + PageTable[PTIndex] = ((PFAddress | mAddressEncMask) & gPhyMask & ~((1ull << EndBit) - 1)) | + PageAttribute | IA32_PG_A | PAGE_ATTRIBUTE_BITS; + if (UpperEntry != NULL) { + SetSubEntriesNum (UpperEntry, GetSubEntriesNum (UpperEntry) + 1); + } + // + // Get the next page address if we need to create more page tables + // + PFAddress += (1ull << EndBit); + } +} + +/** + ThePage Fault handler wrapper for SMM use. + + @param InterruptType Defines the type of interrupt or exception that + occurred on the processor.This parameter is processor architecture specific. + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. +**/ +VOID +EFIAPI +SmiPFHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + UINTN PFAddress; + UINTN GuardPageAddress; + UINTN CpuIndex; + + ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT); + + AcquireSpinLock (mPFLock); + + PFAddress = AsmReadCr2 (); + + if (mCpuSmmStaticPageTable && (PFAddress >= LShiftU64 (1, (mPhysicalAddressBits - 1)))) { + DumpCpuContext (InterruptType, SystemContext); + DEBUG ((DEBUG_ERROR, "Do not support address 0x%lx by processor!\n", PFAddress)); + CpuDeadLoop (); + } + + // + // If a page fault occurs in SMRAM range, it might be in a SMM stack guard page, + // or SMM page protection violation. + // + if ((PFAddress >= mCpuHotPlugData.SmrrBase) && + (PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))) { + DumpCpuContext (InterruptType, SystemContext); + CpuIndex = GetCpuIndex (); + GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize); + if ((FeaturePcdGet (PcdCpuSmmStackGuard)) && + (PFAddress >= GuardPageAddress) && + (PFAddress < (GuardPageAddress + EFI_PAGE_SIZE))) { + DEBUG ((DEBUG_ERROR, "SMM stack overflow!\n")); + } else { + if ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0) { + DEBUG ((DEBUG_ERROR, "SMM exception at execution (0x%lx)\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp); + ); + } else { + DEBUG ((DEBUG_ERROR, "SMM exception at access (0x%lx)\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); + ); + } + } + CpuDeadLoop (); + } + + // + // If a page fault occurs in SMM range + // + if ((PFAddress < mCpuHotPlugData.SmrrBase) || + (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { + DumpCpuContext (InterruptType, SystemContext); + if ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0) { + DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%lx) out of SMM range after SMM is locked!\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp); + ); + CpuDeadLoop (); + } + if (IsSmmCommBufferForbiddenAddress (PFAddress)) { + DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress)); + DEBUG_CODE ( + DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); + ); + CpuDeadLoop (); + } + } + + if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { + SmmProfilePFHandler ( + SystemContext.SystemContextX64->Rip, + SystemContext.SystemContextX64->ExceptionData + ); + } else { + SmiDefaultPFHandler (); + } + + ReleaseSpinLock (mPFLock); +} + +/** + This function sets memory attribute for page table. +**/ +VOID +SetPageTableAttributes ( + VOID + ) +{ + UINTN Index2; + UINTN Index3; + UINTN Index4; + UINT64 *L1PageTable; + UINT64 *L2PageTable; + UINT64 *L3PageTable; + UINT64 *L4PageTable; + BOOLEAN IsSplitted; + BOOLEAN PageTableSplitted; + + if (!mCpuSmmStaticPageTable) { + return ; + } + + DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n")); + + // + // Disable write protection, because we need mark page table to be write protected. + // We need *write* page table memory, to mark itself to be *read only*. + // + AsmWriteCr0 (AsmReadCr0() & ~CR0_WP); + + do { + DEBUG ((DEBUG_INFO, "Start...\n")); + PageTableSplitted = FALSE; + + L4PageTable = (UINT64 *)GetPageTableBase (); + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L4PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + + for (Index4 = 0; Index4 < SIZE_4KB/sizeof(UINT64); Index4++) { + L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L3PageTable == NULL) { + continue; + } + + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L3PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + + for (Index3 = 0; Index3 < SIZE_4KB/sizeof(UINT64); Index3++) { + if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { + // 1G + continue; + } + L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L2PageTable == NULL) { + continue; + } + + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + + for (Index2 = 0; Index2 < SIZE_4KB/sizeof(UINT64); Index2++) { + if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { + // 2M + continue; + } + L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); + if (L1PageTable == NULL) { + continue; + } + SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); + PageTableSplitted = (PageTableSplitted || IsSplitted); + } + } + } + } while (PageTableSplitted); + + // + // Enable write protection, after page table updated. + // + AsmWriteCr0 (AsmReadCr0() | CR0_WP); + + return ; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c new file mode 100644 index 0000000000..6dbcb086aa --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c @@ -0,0 +1,67 @@ +/** @file +Semaphore mechanism to indicate to the BSP that an AP has exited SMM +after SMBASE relocation. + +Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +extern UINT32 mSmmRelocationOriginalAddressPtr32; +extern UINT32 mRebasedFlagAddr32; + +UINTN mSmmRelocationOriginalAddress; +volatile BOOLEAN *mRebasedFlag; + +/** +AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode. +**/ +VOID +SmmRelocationSemaphoreComplete32 ( + VOID + ); + +/** + Hook return address of SMM Save State so that semaphore code + can be executed immediately after AP exits SMM to indicate to + the BSP that an AP has exited SMM after SMBASE relocation. + + @param[in] CpuIndex The processor index. + @param[in] RebasedFlag A pointer to a flag that is set to TRUE + immediately after AP exits SMM. + +**/ +VOID +SemaphoreHook ( + IN UINTN CpuIndex, + IN volatile BOOLEAN *RebasedFlag + ) +{ + SMRAM_SAVE_STATE_MAP *CpuState; + UINTN TempValue; + + mRebasedFlag = RebasedFlag; + mRebasedFlagAddr32 = (UINT32)(UINTN)mRebasedFlag; + + CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); + mSmmRelocationOriginalAddress = HookReturnFromSmm ( + CpuIndex, + CpuState, + (UINT64)(UINTN)&SmmRelocationSemaphoreComplete32, + (UINT64)(UINTN)&SmmRelocationSemaphoreComplete + ); + + // + // Use temp value to fix ICC complier warning + // + TempValue = (UINTN)&mSmmRelocationOriginalAddress; + mSmmRelocationOriginalAddressPtr32 = (UINT32)TempValue; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S new file mode 100644 index 0000000000..600d8623cd --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S @@ -0,0 +1,243 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiEntry.S +# +# Abstract: +# +# Code template of the SMI handler for a particular processor +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gcSmiHandlerTemplate) +ASM_GLOBAL ASM_PFX(gcSmiHandlerSize) +ASM_GLOBAL ASM_PFX(gSmiCr3) +ASM_GLOBAL ASM_PFX(gSmiStack) +ASM_GLOBAL ASM_PFX(gSmbase) +ASM_GLOBAL ASM_PFX(mXdSupported) +ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr) + +.equ MSR_IA32_MISC_ENABLE, 0x1A0 +.equ MSR_EFER, 0xc0000080 +.equ MSR_EFER_XD, 0x800 + +# +# Constants relating to PROCESSOR_SMM_DESCRIPTOR +# +.equ DSC_OFFSET, 0xfb00 +.equ DSC_GDTPTR, 0x30 +.equ DSC_GDTSIZ, 0x38 +.equ DSC_CS, 14 +.equ DSC_DS, 16 +.equ DSC_SS, 18 +.equ DSC_OTHERSEG, 20 +# +# Constants relating to CPU State Save Area +# +.equ SSM_DR6, 0xffd0 +.equ SSM_DR7, 0xffc8 + +.equ PROTECT_MODE_CS, 0x08 +.equ PROTECT_MODE_DS, 0x20 +.equ LONG_MODE_CS, 0x38 +.equ TSS_SEGMENT, 0x40 +.equ GDT_SIZE, 0x50 + + .text + +ASM_PFX(gcSmiHandlerTemplate): + +_SmiEntryPoint: + # + # The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- + # bit addressing mode. And that coincidence has been used in the following + # "64-bit like" 16-bit code. Be aware that once RDI is referenced as a + # base address register, it is actually BX that is referenced. + # + .byte 0xbb # mov bx, imm16 + .word _GdtDesc - _SmiEntryPoint + 0x8000 + # + # fix GDT descriptor + # + .byte 0x2e,0xa1 # mov ax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTSIZ + .byte 0x48 # dec ax + .byte 0x2e + movl %eax, (%rdi) # mov cs:[bx], ax + .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] + .word DSC_OFFSET + DSC_GDTPTR + .byte 0x2e + movw %ax, 2(%rdi) + .byte 0x66,0x2e + lgdt (%rdi) + # + # Patch ProtectedMode Segment + # + .byte 0xb8 + .word PROTECT_MODE_CS + .byte 0x2e + movl %eax, -2(%rdi) + # + # Patch ProtectedMode entry + # + .byte 0x66, 0xbf # mov edi, SMBASE +ASM_PFX(gSmbase): .space 4 + lea ((ProtectedMode - _SmiEntryPoint) + 0x8000)(%edi), %ax + .byte 0x2e + movw %ax, -6(%rdi) + # + # Switch into ProtectedMode + # + movq %cr0, %rbx + .byte 0x66 + andl $0x9ffafff3, %ebx + .byte 0x66 + orl $0x00000023, %ebx + + movq %rbx, %cr0 + .byte 0x66, 0xea + .space 6 + +_GdtDesc: .space 6 + +ProtectedMode: + movw $PROTECT_MODE_DS, %ax + movl %eax, %ds + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + movl %eax, %ss + .byte 0xbc # mov esp, imm32 +ASM_PFX(gSmiStack): .space 4 + jmp ProtFlatMode + +ProtFlatMode: + .byte 0xb8 +ASM_PFX(gSmiCr3): .space 4 + movq %rax, %cr3 + movl $0x668,%eax # as cr4.PGE is not set here, refresh cr3 + movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. +# Load TSS + subl $8, %esp # reserve room in stack + sgdt (%rsp) + movl 2(%rsp), %eax # eax = GDT base + addl $8, %esp + movb $0x89, %dl + movb %dl, (TSS_SEGMENT + 5)(%rax) # clear busy flag + movl $TSS_SEGMENT, %eax + ltr %ax + +# enable NXE if supported + .byte 0xb0 # mov al, imm8 +ASM_PFX(mXdSupported): .byte 1 + cmpb $0, %al + jz SkipNxe +# +# Check XD disable bit +# + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + subl $4, %esp + pushq %rdx # save MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] + jz L13 + andw $0x0FFFB, %dx # clear XD Disable bit if it is set + wrmsr +L13: + movl $MSR_EFER, %ecx + rdmsr + orw $MSR_EFER_XD,%ax # enable NXE + wrmsr + jmp NxeDone +SkipNxe: + subl $8, %esp +NxeDone: + + # + # Switch to LongMode + # + pushq $LONG_MODE_CS # push cs hardcore here + call Base # push return address for retf later +Base: + addl $(LongMode - Base), (%rsp) # offset for far retf, seg is the 1st arg + + movl $MSR_EFER, %ecx + rdmsr + orb $1,%ah # enable LME + wrmsr + movq %cr0, %rbx + orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE + movq %rbx, %cr0 + retf +LongMode: # long mode (64-bit code) starts here + movabsq $ASM_PFX(gSmiHandlerIdtr), %rax + lidt (%rax) + lea (DSC_OFFSET)(%rdi), %ebx + movw DSC_DS(%rbx), %ax + movl %eax,%ds + movw DSC_OTHERSEG(%rbx), %ax + movl %eax,%es + movl %eax,%fs + movl %eax,%gs + movw DSC_SS(%rbx), %ax + movl %eax,%ss +# jmp _SmiHandler ; instruction is not needed + +_SmiHandler: + movq 8(%rsp), %rbx + # Save FP registers + + subq $0x200, %rsp + .byte 0x48 # FXSAVE64 + fxsave (%rsp) + + addq $-0x20, %rsp + + movq %rbx, %rcx + movabsq $ASM_PFX(CpuSmmDebugEntry), %rax + call *%rax + + movq %rbx, %rcx + movabsq $ASM_PFX(SmiRendezvous), %rax + call *%rax + + movq %rbx, %rcx + movabsq $ASM_PFX(CpuSmmDebugExit), %rax + call *%rax + + addq $0x20, %rsp + + # + # Restore FP registers + # + .byte 0x48 # FXRSTOR64 + fxrstor (%rsp) + + addq $0x200, %rsp + + movabsq $ASM_PFX(mXdSupported), %rax + movb (%rax), %al + cmpb $0, %al + jz L16 + popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] + testl $BIT2, %edx + jz L16 + movl $MSR_IA32_MISC_ENABLE, %ecx + rdmsr + orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM + wrmsr + +L16: + rsm + +ASM_PFX(gcSmiHandlerSize): .word . - _SmiEntryPoint diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm new file mode 100644 index 0000000000..c74f82aac8 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm @@ -0,0 +1,242 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.asm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +; +; Variables referenced by C code +; +EXTERNDEF SmiRendezvous:PROC +EXTERNDEF CpuSmmDebugEntry:PROC +EXTERNDEF CpuSmmDebugExit:PROC +EXTERNDEF gcSmiHandlerTemplate:BYTE +EXTERNDEF gcSmiHandlerSize:WORD +EXTERNDEF gSmiCr3:DWORD +EXTERNDEF gSmiStack:DWORD +EXTERNDEF gSmbase:DWORD +EXTERNDEF mXdSupported:BYTE +EXTERNDEF gSmiHandlerIdtr:FWORD + +MSR_IA32_MISC_ENABLE EQU 1A0h +MSR_EFER EQU 0c0000080h +MSR_EFER_XD EQU 0800h + +; +; Constants relating to PROCESSOR_SMM_DESCRIPTOR +; +DSC_OFFSET EQU 0fb00h +DSC_GDTPTR EQU 30h +DSC_GDTSIZ EQU 38h +DSC_CS EQU 14 +DSC_DS EQU 16 +DSC_SS EQU 18 +DSC_OTHERSEG EQU 20 +; +; Constants relating to CPU State Save Area +; +SSM_DR6 EQU 0ffd0h +SSM_DR7 EQU 0ffc8h + +PROTECT_MODE_CS EQU 08h +PROTECT_MODE_DS EQU 20h +LONG_MODE_CS EQU 38h +TSS_SEGMENT EQU 40h +GDT_SIZE EQU 50h + + .code + +gcSmiHandlerTemplate LABEL BYTE + +_SmiEntryPoint: + ; + ; The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- + ; bit addressing mode. And that coincidence has been used in the following + ; "64-bit like" 16-bit code. Be aware that once RDI is referenced as a + ; base address register, it is actually BX that is referenced. + ; + DB 0bbh ; mov bx, imm16 + DW offset _GdtDesc - _SmiEntryPoint + 8000h ; bx = GdtDesc offset +; fix GDT descriptor + DB 2eh, 0a1h ; mov ax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTSIZ + DB 48h ; dec ax + DB 2eh + mov [rdi], eax ; mov cs:[bx], ax + DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] + DW DSC_OFFSET + DSC_GDTPTR + DB 2eh + mov [rdi + 2], ax ; mov cs:[bx + 2], eax + DB 66h, 2eh + lgdt fword ptr [rdi] ; lgdt fword ptr cs:[bx] +; Patch ProtectedMode Segment + DB 0b8h ; mov ax, imm16 + DW PROTECT_MODE_CS ; set AX for segment directly + DB 2eh + mov [rdi - 2], eax ; mov cs:[bx - 2], ax +; Patch ProtectedMode entry + DB 66h, 0bfh ; mov edi, SMBASE +gSmbase DD ? + lea ax, [edi + (@ProtectedMode - _SmiEntryPoint) + 8000h] + DB 2eh + mov [rdi - 6], ax ; mov cs:[bx - 6], eax +; Switch into @ProtectedMode + mov rbx, cr0 + DB 66h + and ebx, 9ffafff3h + DB 66h + or ebx, 00000023h + + mov cr0, rbx + DB 66h, 0eah + DD ? + DW ? + +_GdtDesc FWORD ? +@ProtectedMode: + mov ax, PROTECT_MODE_DS + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + DB 0bch ; mov esp, imm32 +gSmiStack DD ? + jmp ProtFlatMode + +ProtFlatMode: + DB 0b8h ; mov eax, offset gSmiCr3 +gSmiCr3 DD ? + mov cr3, rax + mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. +; Load TSS + sub esp, 8 ; reserve room in stack + sgdt fword ptr [rsp] + mov eax, [rsp + 2] ; eax = GDT base + add esp, 8 + mov dl, 89h + mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax + +; enable NXE if supported + DB 0b0h ; mov al, imm8 +mXdSupported DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + sub esp, 4 + push rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz @f + and dx, 0FFFBh ; clear XD Disable bit if it is set + wrmsr +@@: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 8 +@XdDone: + +; Switch into @LongMode + push LONG_MODE_CS ; push cs hardcore here + call Base ; push return address for retf later +Base: + add dword ptr [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg + + mov ecx, MSR_EFER + rdmsr + or ah, 1 ; enable LME + wrmsr + mov rbx, cr0 + or ebx, 080010023h ; enable paging + WP + NE + MP + PE + mov cr0, rbx + retf +@LongMode: ; long mode (64-bit code) starts here + mov rax, offset gSmiHandlerIdtr + lidt fword ptr [rax] + lea ebx, [rdi + DSC_OFFSET] + mov ax, [rbx + DSC_DS] + mov ds, eax + mov ax, [rbx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [rbx + DSC_SS] + mov ss, eax +; jmp _SmiHandler ; instruction is not needed + +_SmiHandler: + mov rbx, [rsp] ; rbx <- CpuIndex + + ; + ; Save FP registers + ; + sub rsp, 200h + DB 48h ; FXSAVE64 + fxsave [rsp] + + add rsp, -20h + + mov rcx, rbx + mov rax, CpuSmmDebugEntry + call rax + + mov rcx, rbx + mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous + call rax + + mov rcx, rbx + mov rax, CpuSmmDebugExit + call rax + + add rsp, 20h + + ; + ; Restore FP registers + ; + DB 48h ; FXRSTOR64 + fxrstor [rsp] + + add rsp, 200h + + mov rax, offset ASM_PFX(mXdSupported) + mov al, [rax] + cmp al, 0 + jz @f + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz @f + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +@@: + rsm + +gcSmiHandlerSize DW $ - _SmiEntryPoint + + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm new file mode 100644 index 0000000000..c3c094ff9f --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm @@ -0,0 +1,224 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiEntry.nasm +; +; Abstract: +; +; Code template of the SMI handler for a particular processor +; +;------------------------------------------------------------------------------- + +; +; Variables referrenced by C code +; + +%define MSR_IA32_MISC_ENABLE 0x1A0 +%define MSR_EFER 0xc0000080 +%define MSR_EFER_XD 0x800 + +; +; Constants relating to PROCESSOR_SMM_DESCRIPTOR +; +%define DSC_OFFSET 0xfb00 +%define DSC_GDTPTR 0x30 +%define DSC_GDTSIZ 0x38 +%define DSC_CS 14 +%define DSC_DS 16 +%define DSC_SS 18 +%define DSC_OTHERSEG 20 +; +; Constants relating to CPU State Save Area +; +%define SSM_DR6 0xffd0 +%define SSM_DR7 0xffc8 + +%define PROTECT_MODE_CS 0x8 +%define PROTECT_MODE_DS 0x20 +%define LONG_MODE_CS 0x38 +%define TSS_SEGMENT 0x40 +%define GDT_SIZE 0x50 + +extern ASM_PFX(SmiRendezvous) +extern ASM_PFX(gSmiHandlerIdtr) +extern ASM_PFX(CpuSmmDebugEntry) +extern ASM_PFX(CpuSmmDebugExit) + +global ASM_PFX(gSmbase) +global ASM_PFX(mXdSupported) +global ASM_PFX(gSmiStack) +global ASM_PFX(gSmiCr3) +global ASM_PFX(gcSmiHandlerTemplate) +global ASM_PFX(gcSmiHandlerSize) + + DEFAULT REL + SECTION .text + +BITS 16 +ASM_PFX(gcSmiHandlerTemplate): +_SmiEntryPoint: + mov bx, _GdtDesc - _SmiEntryPoint + 0x8000 + mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] + dec ax + mov [cs:bx], ax + mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] + mov [cs:bx + 2], eax +o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] + mov ax, PROTECT_MODE_CS + mov [cs:bx-0x2],ax + DB 0x66, 0xbf ; mov edi, SMBASE +ASM_PFX(gSmbase): DD 0 + lea eax, [edi + (@ProtectedMode - _SmiEntryPoint) + 0x8000] + mov [cs:bx-0x6],eax + mov ebx, cr0 + and ebx, 0x9ffafff3 + or ebx, 0x23 + mov cr0, ebx + jmp dword 0x0:0x0 +_GdtDesc: + DW 0 + DD 0 + +BITS 32 +@ProtectedMode: + mov ax, PROTECT_MODE_DS +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax + DB 0xbc ; mov esp, imm32 +ASM_PFX(gSmiStack): DD 0 + jmp ProtFlatMode + +BITS 64 +ProtFlatMode: + DB 0xb8 ; mov eax, offset gSmiCr3 +ASM_PFX(gSmiCr3): DD 0 + mov cr3, rax + mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 + mov cr4, rax ; in PreModifyMtrrs() to flush TLB. +; Load TSS + sub esp, 8 ; reserve room in stack + sgdt [rsp] + mov eax, [rsp + 2] ; eax = GDT base + add esp, 8 + mov dl, 0x89 + mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag + mov eax, TSS_SEGMENT + ltr ax + +; enable NXE if supported + DB 0xb0 ; mov al, imm8 +ASM_PFX(mXdSupported): DB 1 + cmp al, 0 + jz @SkipXd +; +; Check XD disable bit +; + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + sub esp, 4 + push rdx ; save MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] + jz .0 + and dx, 0xFFFB ; clear XD Disable bit if it is set + wrmsr +.0: + mov ecx, MSR_EFER + rdmsr + or ax, MSR_EFER_XD ; enable NXE + wrmsr + jmp @XdDone +@SkipXd: + sub esp, 8 +@XdDone: + +; Switch into @LongMode + push LONG_MODE_CS ; push cs hardcore here + call Base ; push return address for retf later +Base: + add dword [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg + + mov ecx, MSR_EFER + rdmsr + or ah, 1 ; enable LME + wrmsr + mov rbx, cr0 + or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE + mov cr0, rbx + retf +@LongMode: ; long mode (64-bit code) starts here + mov rax, ASM_PFX(gSmiHandlerIdtr) + lidt [rax] + lea ebx, [rdi + DSC_OFFSET] + mov ax, [rbx + DSC_DS] + mov ds, eax + mov ax, [rbx + DSC_OTHERSEG] + mov es, eax + mov fs, eax + mov gs, eax + mov ax, [rbx + DSC_SS] + mov ss, eax +; jmp _SmiHandler ; instruction is not needed + +_SmiHandler: + mov rbx, [rsp + 0x8] ; rcx <- CpuIndex + + ; + ; Save FP registers + ; + sub rsp, 0x200 + DB 0x48 ; FXSAVE64 + fxsave [rsp] + + add rsp, -0x20 + + mov rcx, rbx + mov rax, CpuSmmDebugEntry + call rax + + mov rcx, rbx + mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous + call rax + + mov rcx, rbx + mov rax, CpuSmmDebugExit + call rax + + add rsp, 0x20 + + ; + ; Restore FP registers + ; + DB 0x48 ; FXRSTOR64 + fxrstor [rsp] + + add rsp, 0x200 + + mov rax, ASM_PFX(mXdSupported) + mov al, [rax] + cmp al, 0 + jz .1 + pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] + test edx, BIT2 + jz .1 + mov ecx, MSR_IA32_MISC_ENABLE + rdmsr + or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM + wrmsr + +.1: + rsm + +gcSmiHandlerSize DW $ - _SmiEntryPoint + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S new file mode 100644 index 0000000000..338bb70dd8 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S @@ -0,0 +1,365 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmiException.S +# +# Abstract: +# +# Exception handlers used in SM mode +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(SmiPFHandler) +ASM_GLOBAL ASM_PFX(gcSmiIdtr) +ASM_GLOBAL ASM_PFX(gcSmiGdtr) +ASM_GLOBAL ASM_PFX(gcPsd) + + .data + +NullSeg: .quad 0 # reserved by architecture +CodeSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +ProtModeCodeSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +ProtModeSsSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x93 + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +DataSeg32: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x93 + .byte 0xcf # LimitHigh + .byte 0 # BaseHigh +CodeSeg16: + .word -1 + .word 0 + .byte 0 + .byte 0x9b + .byte 0x8f + .byte 0 +DataSeg16: + .word -1 + .word 0 + .byte 0 + .byte 0x93 + .byte 0x8f + .byte 0 +CodeSeg64: + .word -1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x9b + .byte 0xaf # LimitHigh + .byte 0 # BaseHigh +# TSS Segment for X64 specially +TssSeg: + .word TSS_DESC_SIZE - 1 # LimitLow + .word 0 # BaseLow + .byte 0 # BaseMid + .byte 0x89 + .byte 0x00 # LimitHigh + .byte 0 # BaseHigh + .long 0 # BaseUpper + .long 0 # Reserved +.equ GDT_SIZE, .- NullSeg + +TssDescriptor: + .space 104, 0 +.equ TSS_DESC_SIZE, .- TssDescriptor + +# +# This structure serves as a template for all processors. +# +ASM_PFX(gcPsd): + .ascii "PSDSIG " + .word PSD_SIZE + .word 2 + .word 1 << 2 + .word CODE_SEL + .word DATA_SEL + .word DATA_SEL + .word DATA_SEL + .word 0 + .quad 0 + .quad 0 + .quad 0 # fixed in InitializeMpServiceData() + .quad NullSeg + .long GDT_SIZE + .long 0 + .space 24, 0 + .quad 0 +.equ PSD_SIZE, . - ASM_PFX(gcPsd) + +# +# CODE & DATA segments for SMM runtime +# +.equ CODE_SEL, CodeSeg64 - NullSeg +.equ DATA_SEL, DataSeg32 - NullSeg +.equ CODE32_SEL, CodeSeg32 - NullSeg + +ASM_PFX(gcSmiGdtr): + .word GDT_SIZE - 1 + .quad NullSeg + +ASM_PFX(gcSmiIdtr): + .word 0 + .quad 0 + + .text + +#------------------------------------------------------------------------------ +# _SmiExceptionEntryPoints is the collection of exception entry points followed +# by a common exception handler. +# +# Stack frame would be as follows as specified in IA32 manuals: +# +---------------------+ <-- 16-byte aligned ensured by processor +# + Old SS + +# +---------------------+ +# + Old RSP + +# +---------------------+ +# + RFlags + +# +---------------------+ +# + CS + +# +---------------------+ +# + RIP + +# +---------------------+ +# + Error Code + +# +---------------------+ +# + Vector Number + +# +---------------------+ +# + RBP + +# +---------------------+ <-- RBP, 16-byte aligned +# +# RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(PageFaultIdtHandlerSmmProfile) +ASM_PFX(PageFaultIdtHandlerSmmProfile): + pushq $0x0e # Page Fault + .byte 0x40, 0xf6, 0xc4, 0x08 #test spl, 8 + jnz L1 + pushq (%rsp) + movq $0, 8(%rsp) +L1: + pushq %rbp + movq %rsp, %rbp + + # + # Since here the stack pointer is 16-byte aligned, so + # EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + # is 16-byte aligned + # + +## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +## UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pushq %r15 + pushq %r14 + pushq %r13 + pushq %r12 + pushq %r11 + pushq %r10 + pushq %r9 + pushq %r8 + pushq %rax + pushq %rcx + pushq %rdx + pushq %rbx + pushq 48(%rbp) # RSP + pushq (%rbp) # RBP + pushq %rsi + pushq %rdi + +## UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzwq 56(%rbp), %rax + pushq %rax # for ss + movzwq 32(%rbp), %rax + pushq %rax # for cs + movq %ds, %rax + pushq %rax + movq %es, %rax + pushq %rax + movq %fs, %rax + pushq %rax + movq %gs, %rax + pushq %rax + +## UINT64 Rip; + pushq 24(%rbp) + +## UINT64 Gdtr[2], Idtr[2]; + subq $16, %rsp + sidt (%rsp) + subq $16, %rsp + sgdt (%rsp) + +## UINT64 Ldtr, Tr; + xorq %rax, %rax + strw %ax + pushq %rax + sldtw %ax + pushq %rax + +## UINT64 RFlags; + pushq 40(%rbp) + +## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + movq %cr8, %rax + pushq %rax + movq %cr4, %rax + orq $0x208, %rax + movq %rax, %cr4 + pushq %rax + movq %cr3, %rax + pushq %rax + movq %cr2, %rax + pushq %rax + xorq %rax, %rax + pushq %rax + movq %cr0, %rax + pushq %rax + +## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + movq %dr7, %rax + pushq %rax + movq %dr6, %rax + pushq %rax + movq %dr3, %rax + pushq %rax + movq %dr2, %rax + pushq %rax + movq %dr1, %rax + pushq %rax + movq %dr0, %rax + pushq %rax + +## FX_SAVE_STATE_X64 FxSaveState; + + subq $512, %rsp + movq %rsp, %rdi + .byte 0xf, 0xae, 0x7 # fxsave [rdi] + +# UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +## UINT32 ExceptionData; + pushq 16(%rbp) + +## call into exception handler + movq 8(%rbp), %rcx + movabsq $ASM_PFX(SmiPFHandler), %rax + +## Prepare parameter and call + movq %rsp, %rdx + # + # Per X64 calling convention, allocate maximum parameter stack space + # and make sure RSP is 16-byte aligned + # + subq $4 * 8 + 8, %rsp + call *%rax + addq $4 * 8 + 8, %rsp + jmp L5 + +L5: +## UINT64 ExceptionData; + addq $8, %rsp + +## FX_SAVE_STATE_X64 FxSaveState; + + movq %rsp, %rsi + .byte 0xf, 0xae, 0xe # fxrstor [rsi] + addq $512, %rsp + +## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +## Skip restoration of DRx registers to support debuggers +## that set breakpoints in interrupt/exception context + addq $8 * 6, %rsp + +## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + popq %rax + movq %rax, %cr0 + addq $8, %rsp # not for Cr1 + popq %rax + movq %rax, %cr2 + popq %rax + movq %rax, %cr3 + popq %rax + movq %rax, %cr4 + popq %rax + movq %rax, %cr8 + +## UINT64 RFlags; + popq 40(%rbp) + +## UINT64 Ldtr, Tr; +## UINT64 Gdtr[2], Idtr[2]; +## Best not let anyone mess with these particular registers... + addq $48, %rsp + +## UINT64 Rip; + popq 24(%rbp) + +## UINT64 Gs, Fs, Es, Ds, Cs, Ss; + popq %rax + # mov gs, rax ; not for gs + popq %rax + # mov fs, rax ; not for fs + # (X64 will not use fs and gs, so we do not restore it) + popq %rax + movq %rax, %es + popq %rax + movq %rax, %ds + popq 32(%rbp) # for cs + popq 56(%rbp) # for ss + +## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +## UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + popq %rdi + popq %rsi + addq $8, %rsp # not for rbp + popq 48(%rbp) # for rsp + popq %rbx + popq %rdx + popq %rcx + popq %rax + popq %r8 + popq %r9 + popq %r10 + popq %r11 + popq %r12 + popq %r13 + popq %r14 + popq %r15 + + movq %rbp, %rsp + +# Enable TF bit after page fault handler runs + btsl $8, 40(%rsp) #RFLAGS + + popq %rbp + addq $16, %rsp # skip INT# & ErrCode + iretq + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm new file mode 100644 index 0000000000..80bd739ff4 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm @@ -0,0 +1,383 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.asm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +EXTERNDEF SmiPFHandler:PROC +EXTERNDEF gcSmiIdtr:FWORD +EXTERNDEF gcSmiGdtr:FWORD +EXTERNDEF gcPsd:BYTE + + .const + +NullSeg DQ 0 ; reserved by architecture +CodeSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +ProtModeCodeSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +ProtModeSsSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 93h + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +DataSeg32 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 93h + DB 0cfh ; LimitHigh + DB 0 ; BaseHigh +CodeSeg16 LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh + DB 0 +DataSeg16 LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh + DB 0 +CodeSeg64 LABEL QWORD + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 9bh + DB 0afh ; LimitHigh + DB 0 ; BaseHigh +; TSS Segment for X64 specially +TssSeg LABEL QWORD + DW TSS_DESC_SIZE - 1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 89h + DB 00h ; LimitHigh + DB 0 ; BaseHigh + DD 0 ; BaseUpper + DD 0 ; Reserved +GDT_SIZE = $ - offset NullSeg + +; Create TSS Descriptor just after GDT +TssDescriptor LABEL BYTE + DD 0 ; Reserved + DQ 0 ; RSP0 + DQ 0 ; RSP1 + DQ 0 ; RSP2 + DD 0 ; Reserved + DD 0 ; Reserved + DQ 0 ; IST1 + DQ 0 ; IST2 + DQ 0 ; IST3 + DQ 0 ; IST4 + DQ 0 ; IST5 + DQ 0 ; IST6 + DQ 0 ; IST7 + DD 0 ; Reserved + DD 0 ; Reserved + DW 0 ; Reserved + DW 0 ; I/O Map Base Address +TSS_DESC_SIZE = $ - offset TssDescriptor + +; +; This structure serves as a template for all processors. +; +gcPsd LABEL BYTE + DB 'PSDSIG ' + DW PSD_SIZE + DW 2 + DW 1 SHL 2 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW 0 + DQ 0 + DQ 0 + DQ 0 ; fixed in InitializeMpServiceData() + DQ offset NullSeg + DD GDT_SIZE + DD 0 + DB 24 dup (0) + DQ 0 +PSD_SIZE = $ - offset gcPsd + +; +; CODE & DATA segments for SMM runtime +; +CODE_SEL = offset CodeSeg64 - offset NullSeg +DATA_SEL = offset DataSeg32 - offset NullSeg +CODE32_SEL = offset CodeSeg32 - offset NullSeg + +gcSmiGdtr LABEL FWORD + DW GDT_SIZE - 1 + DQ offset NullSeg + +gcSmiIdtr LABEL FWORD + DW 0 + DQ 0 + + .code + +;------------------------------------------------------------------------------ +; _SmiExceptionEntryPoints is the collection of exception entry points followed +; by a common exception handler. +; +; Stack frame would be as follows as specified in IA32 manuals: +; +; +---------------------+ <-- 16-byte aligned ensured by processor +; + Old SS + +; +---------------------+ +; + Old RSP + +; +---------------------+ +; + RFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + RIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + RBP + +; +---------------------+ <-- RBP, 16-byte aligned +; +; RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT +;------------------------------------------------------------------------------ +PageFaultIdtHandlerSmmProfile PROC + push 0eh ; Page Fault + test spl, 8 ; odd multiple of 8 => ErrCode present + jnz @F + push [rsp] ; duplicate INT# if no ErrCode + mov qword ptr [rsp + 8], 0 +@@: + push rbp + mov rbp, rsp + + ; + ; Since here the stack pointer is 16-byte aligned, so + ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + ; is 16-byte aligned + ; + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + push r15 + push r14 + push r13 + push r12 + push r11 + push r10 + push r9 + push r8 + push rax + push rcx + push rdx + push rbx + push qword ptr [rbp + 48] ; RSP + push qword ptr [rbp] ; RBP + push rsi + push rdi + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzx rax, word ptr [rbp + 56] + push rax ; for ss + movzx rax, word ptr [rbp + 32] + push rax ; for cs + mov rax, ds + push rax + mov rax, es + push rax + mov rax, fs + push rax + mov rax, gs + push rax + +;; UINT64 Rip; + push qword ptr [rbp + 24] + +;; UINT64 Gdtr[2], Idtr[2]; + sub rsp, 16 + sidt fword ptr [rsp] + sub rsp, 16 + sgdt fword ptr [rsp] + +;; UINT64 Ldtr, Tr; + xor rax, rax + str ax + push rax + sldt ax + push rax + +;; UINT64 RFlags; + push qword ptr [rbp + 40] + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + mov rax, cr8 + push rax + mov rax, cr4 + or rax, 208h + mov cr4, rax + push rax + mov rax, cr3 + push rax + mov rax, cr2 + push rax + xor rax, rax + push rax + mov rax, cr0 + push rax + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov rax, dr7 + push rax + mov rax, dr6 + push rax + mov rax, dr3 + push rax + mov rax, dr2 + push rax + mov rax, dr1 + push rax + mov rax, dr0 + push rax + +;; FX_SAVE_STATE_X64 FxSaveState; + + sub rsp, 512 + mov rdi, rsp + db 0fh, 0aeh, 00000111y ;fxsave [rdi] + +; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push qword ptr [rbp + 16] + +;; call into exception handler + mov rcx, [rbp + 8] + mov rax, SmiPFHandler + +;; Prepare parameter and call + mov rdx, rsp + ; + ; Per X64 calling convention, allocate maximum parameter stack space + ; and make sure RSP is 16-byte aligned + ; + sub rsp, 4 * 8 + 8 + call rax + add rsp, 4 * 8 + 8 + jmp @F + +@@: +;; UINT64 ExceptionData; + add rsp, 8 + +;; FX_SAVE_STATE_X64 FxSaveState; + + mov rsi, rsp + db 0fh, 0aeh, 00001110y ; fxrstor [rsi] + add rsp, 512 + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoints in interrupt/exception context + add rsp, 8 * 6 + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + pop rax + mov cr0, rax + add rsp, 8 ; not for Cr1 + pop rax + mov cr2, rax + pop rax + mov cr3, rax + pop rax + mov cr4, rax + pop rax + mov cr8, rax + +;; UINT64 RFlags; + pop qword ptr [rbp + 40] + +;; UINT64 Ldtr, Tr; +;; UINT64 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add rsp, 48 + +;; UINT64 Rip; + pop qword ptr [rbp + 24] + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; + pop rax + ; mov gs, rax ; not for gs + pop rax + ; mov fs, rax ; not for fs + ; (X64 will not use fs and gs, so we do not restore it) + pop rax + mov es, rax + pop rax + mov ds, rax + pop qword ptr [rbp + 32] ; for cs + pop qword ptr [rbp + 56] ; for ss + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pop rdi + pop rsi + add rsp, 8 ; not for rbp + pop qword ptr [rbp + 48] ; for rsp + pop rbx + pop rdx + pop rcx + pop rax + pop r8 + pop r9 + pop r10 + pop r11 + pop r12 + pop r13 + pop r14 + pop r15 + + mov rsp, rbp + +; Enable TF bit after page fault handler runs + bts dword ptr [rsp + 40], 8 ;RFLAGS + + pop rbp + add rsp, 16 ; skip INT# & ErrCode + iretq +PageFaultIdtHandlerSmmProfile ENDP + + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm new file mode 100644 index 0000000000..b2e2e6dee6 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm @@ -0,0 +1,384 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmiException.nasm +; +; Abstract: +; +; Exception handlers used in SM mode +; +;------------------------------------------------------------------------------- + +extern ASM_PFX(SmiPFHandler) + +global ASM_PFX(gcSmiIdtr) +global ASM_PFX(gcSmiGdtr) +global ASM_PFX(gcPsd) + + SECTION .data + +NullSeg: DQ 0 ; reserved by architecture +CodeSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +ProtModeCodeSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +ProtModeSsSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x93 + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +DataSeg32: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x93 + DB 0xcf ; LimitHigh + DB 0 ; BaseHigh +CodeSeg16: + DW -1 + DW 0 + DB 0 + DB 0x9b + DB 0x8f + DB 0 +DataSeg16: + DW -1 + DW 0 + DB 0 + DB 0x93 + DB 0x8f + DB 0 +CodeSeg64: + DW -1 ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x9b + DB 0xaf ; LimitHigh + DB 0 ; BaseHigh +; TSS Segment for X64 specially +TssSeg: + DW TSS_DESC_SIZE ; LimitLow + DW 0 ; BaseLow + DB 0 ; BaseMid + DB 0x89 + DB 0x80 ; LimitHigh + DB 0 ; BaseHigh + DD 0 ; BaseUpper + DD 0 ; Reserved +GDT_SIZE equ $ - NullSeg + +; Create TSS Descriptor just after GDT +TssDescriptor: + DD 0 ; Reserved + DQ 0 ; RSP0 + DQ 0 ; RSP1 + DQ 0 ; RSP2 + DD 0 ; Reserved + DD 0 ; Reserved + DQ 0 ; IST1 + DQ 0 ; IST2 + DQ 0 ; IST3 + DQ 0 ; IST4 + DQ 0 ; IST5 + DQ 0 ; IST6 + DQ 0 ; IST7 + DD 0 ; Reserved + DD 0 ; Reserved + DW 0 ; Reserved + DW 0 ; I/O Map Base Address +TSS_DESC_SIZE equ $ - TssDescriptor + +; +; This structure serves as a template for all processors. +; +ASM_PFX(gcPsd): + DB 'PSDSIG ' + DW PSD_SIZE + DW 2 + DW 1 << 2 + DW CODE_SEL + DW DATA_SEL + DW DATA_SEL + DW DATA_SEL + DW 0 + DQ 0 + DQ 0 + DQ 0 ; fixed in InitializeMpServiceData() + DQ NullSeg + DD GDT_SIZE + DD 0 + times 24 DB 0 + DQ 0 +PSD_SIZE equ $ - ASM_PFX(gcPsd) + +; +; CODE & DATA segments for SMM runtime +; +CODE_SEL equ CodeSeg64 - NullSeg +DATA_SEL equ DataSeg32 - NullSeg +CODE32_SEL equ CodeSeg32 - NullSeg + +ASM_PFX(gcSmiGdtr): + DW GDT_SIZE - 1 + DQ NullSeg + +ASM_PFX(gcSmiIdtr): + DW 0 + DQ 0 + + DEFAULT REL + SECTION .text + +;------------------------------------------------------------------------------ +; _SmiExceptionEntryPoints is the collection of exception entrypoints followed +; by a common exception handler. +; +; Stack frame would be as follows as specified in IA32 manuals: +; +; +---------------------+ <-- 16-byte aligned ensured by processor +; + Old SS + +; +---------------------+ +; + Old RSP + +; +---------------------+ +; + RFlags + +; +---------------------+ +; + CS + +; +---------------------+ +; + RIP + +; +---------------------+ +; + Error Code + +; +---------------------+ +; + Vector Number + +; +---------------------+ +; + RBP + +; +---------------------+ <-- RBP, 16-byte aligned +; +; RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT +;------------------------------------------------------------------------------ +global ASM_PFX(PageFaultIdtHandlerSmmProfile) +ASM_PFX(PageFaultIdtHandlerSmmProfile): + push 0xe ; Page Fault + test spl, 8 ; odd multiple of 8 => ErrCode present + jnz .0 + push qword [rsp] ; duplicate INT# if no ErrCode + mov qword [rsp + 8], 0 +.0: + push rbp + mov rbp, rsp + + ; + ; Since here the stack pointer is 16-byte aligned, so + ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 + ; is 16-byte aligned + ; + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + push r15 + push r14 + push r13 + push r12 + push r11 + push r10 + push r9 + push r8 + push rax + push rcx + push rdx + push rbx + push qword [rbp + 48] ; RSP + push qword [rbp] ; RBP + push rsi + push rdi + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero + movzx rax, word [rbp + 56] + push rax ; for ss + movzx rax, word [rbp + 32] + push rax ; for cs + mov rax, ds + push rax + mov rax, es + push rax + mov rax, fs + push rax + mov rax, gs + push rax + +;; UINT64 Rip; + push qword [rbp + 24] + +;; UINT64 Gdtr[2], Idtr[2]; + sub rsp, 16 + sidt [rsp] + sub rsp, 16 + sgdt [rsp] + +;; UINT64 Ldtr, Tr; + xor rax, rax + str ax + push rax + sldt ax + push rax + +;; UINT64 RFlags; + push qword [rbp + 40] + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + mov rax, cr8 + push rax + mov rax, cr4 + or rax, 0x208 + mov cr4, rax + push rax + mov rax, cr3 + push rax + mov rax, cr2 + push rax + xor rax, rax + push rax + mov rax, cr0 + push rax + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; + mov rax, dr7 + push rax + mov rax, dr6 + push rax + mov rax, dr3 + push rax + mov rax, dr2 + push rax + mov rax, dr1 + push rax + mov rax, dr0 + push rax + +;; FX_SAVE_STATE_X64 FxSaveState; + + sub rsp, 512 + mov rdi, rsp + db 0xf, 0xae, 00000111y ;fxsave [rdi] + +; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear + cld + +;; UINT32 ExceptionData; + push qword [rbp + 16] + +;; call into exception handler + mov rcx, [rbp + 8] + mov rax, ASM_PFX(SmiPFHandler) + +;; Prepare parameter and call + mov rdx, rsp + ; + ; Per X64 calling convention, allocate maximum parameter stack space + ; and make sure RSP is 16-byte aligned + ; + sub rsp, 4 * 8 + 8 + call rax + add rsp, 4 * 8 + 8 + jmp .1 + +.1: +;; UINT64 ExceptionData; + add rsp, 8 + +;; FX_SAVE_STATE_X64 FxSaveState; + + mov rsi, rsp + db 0xf, 0xae, 00001110y ; fxrstor [rsi] + add rsp, 512 + +;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; +;; Skip restoration of DRx registers to support debuggers +;; that set breakpoints in interrupt/exception context + add rsp, 8 * 6 + +;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; + pop rax + mov cr0, rax + add rsp, 8 ; not for Cr1 + pop rax + mov cr2, rax + pop rax + mov cr3, rax + pop rax + mov cr4, rax + pop rax + mov cr8, rax + +;; UINT64 RFlags; + pop qword [rbp + 40] + +;; UINT64 Ldtr, Tr; +;; UINT64 Gdtr[2], Idtr[2]; +;; Best not let anyone mess with these particular registers... + add rsp, 48 + +;; UINT64 Rip; + pop qword [rbp + 24] + +;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; + pop rax + ; mov gs, rax ; not for gs + pop rax + ; mov fs, rax ; not for fs + ; (X64 will not use fs and gs, so we do not restore it) + pop rax + mov es, rax + pop rax + mov ds, rax + pop qword [rbp + 32] ; for cs + pop qword [rbp + 56] ; for ss + +;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; +;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; + pop rdi + pop rsi + add rsp, 8 ; not for rbp + pop qword [rbp + 48] ; for rsp + pop rbx + pop rdx + pop rcx + pop rax + pop r8 + pop r9 + pop r10 + pop r11 + pop r12 + pop r13 + pop r14 + pop r15 + + mov rsp, rbp + +; Enable TF bit after page fault handler runs + bts dword [rsp + 40], 8 ;RFLAGS + + pop rbp + add rsp, 16 ; skip INT# & ErrCode + iretq + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c new file mode 100644 index 0000000000..9d26e44a9a --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c @@ -0,0 +1,204 @@ +/** @file + SMM CPU misc functions for x64 arch specific. + +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" + +EFI_PHYSICAL_ADDRESS mGdtBuffer; +UINTN mGdtBufferSize; + +/** + Initialize IDT for SMM Stack Guard. + +**/ +VOID +EFIAPI +InitializeIDTSmmStackGuard ( + VOID + ) +{ + IA32_IDT_GATE_DESCRIPTOR *IdtGate; + + // + // If SMM Stack Guard feature is enabled, set the IST field of + // the interrupt gate for Page Fault Exception to be 1 + // + IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base; + IdtGate += EXCEPT_IA32_PAGE_FAULT; + IdtGate->Bits.Reserved_0 = 1; +} + +/** + Initialize Gdt for all processors. + + @param[in] Cr3 CR3 value. + @param[out] GdtStepSize The step size for GDT table. + + @return GdtBase for processor 0. + GdtBase for processor X is: GdtBase + (GdtStepSize * X) +**/ +VOID * +InitGdt ( + IN UINTN Cr3, + OUT UINTN *GdtStepSize + ) +{ + UINTN Index; + IA32_SEGMENT_DESCRIPTOR *GdtDescriptor; + UINTN TssBase; + UINTN GdtTssTableSize; + UINT8 *GdtTssTables; + UINTN GdtTableStepSize; + + // + // For X64 SMM, we allocate separate GDT/TSS for each CPUs to avoid TSS load contention + // on each SMI entry. + // + GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE + 7) & ~7; // 8 bytes aligned + mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; + GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); + ASSERT (GdtTssTables != NULL); + mGdtBuffer = (UINTN)GdtTssTables; + GdtTableStepSize = GdtTssTableSize; + + for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { + CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE); + + // + // Fixup TSS descriptors + // + TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1); + GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2; + GdtDescriptor->Bits.BaseLow = (UINT16)(UINTN)TssBase; + GdtDescriptor->Bits.BaseMid = (UINT8)((UINTN)TssBase >> 16); + GdtDescriptor->Bits.BaseHigh = (UINT8)((UINTN)TssBase >> 24); + + if (FeaturePcdGet (PcdCpuSmmStackGuard)) { + // + // Setup top of known good stack as IST1 for each processor. + // + *(UINTN *)(TssBase + TSS_X64_IST1_OFFSET) = (mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize); + } + } + + *GdtStepSize = GdtTableStepSize; + return GdtTssTables; +} + +/** + This function sets GDT/IDT buffer to be RO and XP. +**/ +VOID +PatchGdtIdtMap ( + VOID + ) +{ + EFI_PHYSICAL_ADDRESS BaseAddress; + UINTN Size; + + // + // GDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n")); + + BaseAddress = mGdtBuffer; + Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_RO + ); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); + + // + // IDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n")); + + BaseAddress = gcSmiIdtr.Base; + Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_RO + ); + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); +} + +/** + Get Protected mode code segment from current GDT table. + + @return Protected mode code segment value. +**/ +UINT16 +GetProtectedModeCS ( + VOID + ) +{ + IA32_DESCRIPTOR GdtrDesc; + IA32_SEGMENT_DESCRIPTOR *GdtEntry; + UINTN GdtEntryCount; + UINT16 Index; + + Index = (UINT16) -1; + AsmReadGdtr (&GdtrDesc); + GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR); + GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base; + for (Index = 0; Index < GdtEntryCount; Index++) { + if (GdtEntry->Bits.L == 0) { + if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.L == 0) { + break; + } + } + GdtEntry++; + } + ASSERT (Index != -1); + return Index * 8; +} + +/** + Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. + + @param[in] ApHltLoopCode The address of the safe hlt-loop function. + @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. + @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. + +**/ +VOID +TransferApToSafeState ( + IN UINTN ApHltLoopCode, + IN UINTN TopOfStack, + IN UINTN NumberToFinishAddress + ) +{ + AsmDisablePaging64 ( + GetProtectedModeCS (), + (UINT32)ApHltLoopCode, + (UINT32)NumberToFinishAddress, + 0, + (UINT32)TopOfStack + ); + // + // It should never reach here + // + ASSERT (FALSE); +} + diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S new file mode 100644 index 0000000000..5e352f57c3 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S @@ -0,0 +1,141 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# SmmInit.S +# +# Abstract: +# +# Functions for relocating SMBASE's for all processors +# +#------------------------------------------------------------------------------ + +ASM_GLOBAL ASM_PFX(gSmmCr0) +ASM_GLOBAL ASM_PFX(gSmmCr3) +ASM_GLOBAL ASM_PFX(gSmmCr4) +ASM_GLOBAL ASM_PFX(gSmmJmpAddr) +ASM_GLOBAL ASM_PFX(gcSmmInitTemplate) +ASM_GLOBAL ASM_PFX(gcSmmInitSize) +ASM_GLOBAL ASM_PFX(mRebasedFlagAddr32) +ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete) +ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete32) +ASM_GLOBAL ASM_PFX(mSmmRelocationOriginalAddressPtr32) +ASM_GLOBAL ASM_PFX(gSmmInitStack) +ASM_GLOBAL ASM_PFX(gcSmiInitGdtr) + + + .text + +ASM_PFX(gcSmiInitGdtr): + .word 0 + .quad 0 + +SmmStartup: + .byte 0x66,0xb8 # mov eax, imm32 +ASM_PFX(gSmmCr3): .space 4 + movq %rax, %cr3 + .byte 0x66,0x2e + lgdt (ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp) + .byte 0x66,0xb8 # mov eax, imm32 +ASM_PFX(gSmmCr4): .space 4 + orb $2, %ah # enable XMM registers access + movq %rax, %cr4 + .byte 0x66 + movl $0xc0000080,%ecx # IA32_EFER MSR + rdmsr + orb $1,%ah # set LME bit + wrmsr + .byte 0x66,0xb8 # mov eax, imm32 +ASM_PFX(gSmmCr0): .space 4 + movq %rax, %cr0 + .byte 0x66,0xea # far jmp to long mode +ASM_PFX(gSmmJmpAddr): .quad LongMode +LongMode: # long-mode starts here + .byte 0x48,0xbc # mov rsp, imm64 +ASM_PFX(gSmmInitStack): .space 8 + andw $0xfff0, %sp # make sure RSP is 16-byte aligned + # + # Accoring to X64 calling convention, XMM0~5 are volatile, we need to save + # them before calling C-function. + # + subq $0x60, %rsp + movdqa %xmm0, 0x0(%rsp) + movdqa %xmm1, 0x10(%rsp) + movdqa %xmm2, 0x20(%rsp) + movdqa %xmm3, 0x30(%rsp) + movdqa %xmm4, 0x40(%rsp) + movdqa %xmm5, 0x50(%rsp) + + + addq $-0x20, %rsp + call ASM_PFX(SmmInitHandler) + addq $0x20, %rsp + # + # Restore XMM0~5 after calling C-function. + # + movdqa 0x0(%rsp), %xmm0 + movdqa 0x10(%rsp), %xmm1 + movdqa 0x20(%rsp), %xmm2 + movdqa 0x30(%rsp), %xmm3 + movdqa 0x40(%rsp), %xmm4 + movdqa 0x50(%rsp), %xmm5 + + rsm + +ASM_PFX(gcSmmInitTemplate): + +_SmmInitTemplate: + .byte 0x66,0x2e,0x8b,0x2e # mov ebp, cs:[@F] + .word L1 - _SmmInitTemplate + 0x8000 + .byte 0x66, 0x81, 0xed, 0, 0, 3, 0 # sub ebp, 0x30000 + jmp *%bp # jmp ebp actually +L1: + .quad SmmStartup + +ASM_PFX(gcSmmInitSize): .word . - ASM_PFX(gcSmmInitTemplate) + +ASM_PFX(SmmRelocationSemaphoreComplete): + # Create a simple stack frame to store RAX and the original RSM location + pushq %rax # Used to store return address + pushq %rax + + # Load the original RSM location onto stack + movabsq $ASM_PFX(mSmmRelocationOriginalAddress), %rax + movq (%rax), %rax + movq %rax, 0x08(%rsp) + + # Update rebase flag + movabsq $ASM_PFX(mRebasedFlag), %rax + movq (%rax), %rax + movb $1, (%rax) + + #restore RAX and return to original RSM location + popq %rax + retq + +# +# Semaphore code running in 32-bit mode +# +ASM_PFX(SmmRelocationSemaphoreComplete32): + # + # movb $1, () + # + .byte 0xc6, 0x05 +ASM_PFX(mRebasedFlagAddr32): + .long 0 + .byte 1 + # + # jmpd () + # + .byte 0xff, 0x25 +ASM_PFX(mSmmRelocationOriginalAddressPtr32): + .long 0 diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm new file mode 100644 index 0000000000..9182f0293a --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm @@ -0,0 +1,132 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmmInit.Asm +; +; Abstract: +; +; Functions for relocating SMBASE's for all processors +; +;------------------------------------------------------------------------------- + +EXTERNDEF SmmInitHandler:PROC +EXTERNDEF gSmmCr0:DWORD +EXTERNDEF gSmmCr3:DWORD +EXTERNDEF gSmmCr4:DWORD +EXTERNDEF gSmmJmpAddr:QWORD +EXTERNDEF gcSmmInitTemplate:BYTE +EXTERNDEF gcSmmInitSize:WORD +EXTERNDEF mRebasedFlag:PTR BYTE +EXTERNDEF mSmmRelocationOriginalAddress:QWORD +EXTERNDEF mRebasedFlagAddr32:DWORD +EXTERNDEF mSmmRelocationOriginalAddressPtr32:DWORD +EXTERNDEF gSmmInitStack:QWORD +EXTERNDEF gcSmiInitGdtr:FWORD + + .code + +gcSmiInitGdtr LABEL FWORD + DW 0 + DQ 0 + +SmmStartup PROC + DB 66h, 0b8h ; mov eax, imm32 +gSmmCr3 DD ? + mov cr3, rax + DB 66h, 2eh + lgdt fword ptr [ebp + (offset gcSmiInitGdtr - SmmStartup)] + DB 66h, 0b8h ; mov eax, imm32 +gSmmCr4 DD ? + or ah, 2 ; enable XMM registers access + mov cr4, rax + DB 66h + mov ecx, 0c0000080h ; IA32_EFER MSR + rdmsr + or ah, 1 ; set LME bit + wrmsr + DB 66h, 0b8h ; mov eax, imm32 +gSmmCr0 DD ? + mov cr0, rax ; enable protected mode & paging + DB 66h, 0eah ; far jmp to long mode +gSmmJmpAddr DQ @LongMode +@LongMode: ; long-mode starts here + DB 48h, 0bch ; mov rsp, imm64 +gSmmInitStack DQ ? + and sp, 0fff0h ; make sure RSP is 16-byte aligned + ; + ; Accoring to X64 calling convention, XMM0~5 are volatile, we need to save + ; them before calling C-function. + ; + sub rsp, 60h + movdqa [rsp], xmm0 + movdqa [rsp + 10h], xmm1 + movdqa [rsp + 20h], xmm2 + movdqa [rsp + 30h], xmm3 + movdqa [rsp + 40h], xmm4 + movdqa [rsp + 50h], xmm5 + + add rsp, -20h + call SmmInitHandler + add rsp, 20h + + ; + ; Restore XMM0~5 after calling C-function. + ; + movdqa xmm0, [rsp] + movdqa xmm1, [rsp + 10h] + movdqa xmm2, [rsp + 20h] + movdqa xmm3, [rsp + 30h] + movdqa xmm4, [rsp + 40h] + movdqa xmm5, [rsp + 50h] + + rsm +SmmStartup ENDP + +gcSmmInitTemplate LABEL BYTE + +_SmmInitTemplate PROC + DB 66h, 2eh, 8bh, 2eh ; mov ebp, cs:[@F] + DW @L1 - _SmmInitTemplate + 8000h + DB 66h, 81h, 0edh, 00h, 00h, 03h, 00 ; sub ebp, 30000h + jmp bp ; jmp ebp actually +@L1: + DQ SmmStartup +_SmmInitTemplate ENDP + +gcSmmInitSize DW $ - gcSmmInitTemplate + +SmmRelocationSemaphoreComplete PROC + push rax + mov rax, mRebasedFlag + mov byte ptr [rax], 1 + pop rax + jmp [mSmmRelocationOriginalAddress] +SmmRelocationSemaphoreComplete ENDP + +; +; Semaphore code running in 32-bit mode +; +SmmRelocationSemaphoreComplete32 PROC + ; + ; mov byte ptr [], 1 + ; + db 0c6h, 05h +mRebasedFlagAddr32 dd 0 + db 1 + ; + ; jmp dword ptr [] + ; + db 0ffh, 25h +mSmmRelocationOriginalAddressPtr32 dd 0 +SmmRelocationSemaphoreComplete32 ENDP + + END diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm new file mode 100644 index 0000000000..9d05e2cb05 --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm @@ -0,0 +1,130 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SmmInit.nasm +; +; Abstract: +; +; Functions for relocating SMBASE's for all processors +; +;------------------------------------------------------------------------------- + +extern ASM_PFX(SmmInitHandler) +extern ASM_PFX(mRebasedFlag) +extern ASM_PFX(mSmmRelocationOriginalAddress) + +global ASM_PFX(gSmmCr3) +global ASM_PFX(gSmmCr4) +global ASM_PFX(gSmmCr0) +global ASM_PFX(gSmmJmpAddr) +global ASM_PFX(gSmmInitStack) +global ASM_PFX(gcSmiInitGdtr) +global ASM_PFX(gcSmmInitSize) +global ASM_PFX(gcSmmInitTemplate) +global ASM_PFX(mRebasedFlagAddr32) +global ASM_PFX(mSmmRelocationOriginalAddressPtr32) + + DEFAULT REL + SECTION .text + +ASM_PFX(gcSmiInitGdtr): + DW 0 + DQ 0 + +global ASM_PFX(SmmStartup) +ASM_PFX(SmmStartup): + DB 0x66, 0xb8 ; mov eax, imm32 +ASM_PFX(gSmmCr3): DD 0 + mov cr3, rax + DB 0x66, 0x2e + lgdt [ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] + DB 0x66, 0xb8 ; mov eax, imm32 +ASM_PFX(gSmmCr4): DD 0 + or ah, 2 ; enable XMM registers access + mov cr4, rax + DB 0x66 + mov ecx, 0xc0000080 ; IA32_EFER MSR + rdmsr + or ah, 1 ; set LME bit + wrmsr + DB 0x66, 0xb8 ; mov eax, imm32 +ASM_PFX(gSmmCr0): DD 0 + mov cr0, rax ; enable protected mode & paging + DB 0x66, 0xea ; far jmp to long mode +ASM_PFX(gSmmJmpAddr): DQ @LongMode +@LongMode: ; long-mode starts here + DB 0x48, 0xbc ; mov rsp, imm64 +ASM_PFX(gSmmInitStack): DQ 0 + and sp, 0xfff0 ; make sure RSP is 16-byte aligned + ; + ; Accoring to X64 calling convention, XMM0~5 are volatile, we need to save + ; them before calling C-function. + ; + sub rsp, 0x60 + movdqa [rsp], xmm0 + movdqa [rsp + 0x10], xmm1 + movdqa [rsp + 0x20], xmm2 + movdqa [rsp + 0x30], xmm3 + movdqa [rsp + 0x40], xmm4 + movdqa [rsp + 0x50], xmm5 + + add rsp, -0x20 + call ASM_PFX(SmmInitHandler) + add rsp, 0x20 + + ; + ; Restore XMM0~5 after calling C-function. + ; + movdqa xmm0, [rsp] + movdqa xmm1, [rsp + 0x10] + movdqa xmm2, [rsp + 0x20] + movdqa xmm3, [rsp + 0x30] + movdqa xmm4, [rsp + 0x40] + movdqa xmm5, [rsp + 0x50] + + rsm + +BITS 16 +ASM_PFX(gcSmmInitTemplate): + mov ebp, [cs:@L1 - ASM_PFX(gcSmmInitTemplate) + 0x8000] + sub ebp, 0x30000 + jmp ebp +@L1: + DQ ASM_PFX(SmmStartup) + +ASM_PFX(gcSmmInitSize): DW $ - ASM_PFX(gcSmmInitTemplate) + +BITS 64 +global ASM_PFX(SmmRelocationSemaphoreComplete) +ASM_PFX(SmmRelocationSemaphoreComplete): + push rax + mov rax, [ASM_PFX(mRebasedFlag)] + mov byte [rax], 1 + pop rax + jmp [ASM_PFX(mSmmRelocationOriginalAddress)] + +; +; Semaphore code running in 32-bit mode +; +global ASM_PFX(SmmRelocationSemaphoreComplete32) +ASM_PFX(SmmRelocationSemaphoreComplete32): + ; + ; mov byte ptr [], 1 + ; + db 0xc6, 0x5 +ASM_PFX(mRebasedFlagAddr32): dd 0 + db 1 + ; + ; jmp dword ptr [] + ; + db 0xff, 0x25 +ASM_PFX(mSmmRelocationOriginalAddressPtr32): dd 0 diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c new file mode 100644 index 0000000000..37da5fb78d --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c @@ -0,0 +1,319 @@ +/** @file +X64 processor specific functions to enable SMM profile. + +Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "PiSmmCpuDxeSmm.h" +#include "SmmProfileInternal.h" + +// +// Current page index. +// +UINTN mPFPageIndex; + +// +// Pool for dynamically creating page table in page fault handler. +// +UINT64 mPFPageBuffer; + +// +// Store the uplink information for each page being used. +// +UINT64 *mPFPageUplink[MAX_PF_PAGE_COUNT]; + +/** + Create SMM page table for S3 path. + +**/ +VOID +InitSmmS3Cr3 ( + VOID + ) +{ + EFI_PHYSICAL_ADDRESS Pages; + UINT64 *PTEntry; + + // + // Generate PAE page table for the first 4GB memory space + // + Pages = Gen4GPageTable (FALSE); + + // + // Fill Page-Table-Level4 (PML4) entry + // + PTEntry = (UINT64*)AllocatePageTableMemory (1); + ASSERT (PTEntry != NULL); + *PTEntry = Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + ZeroMem (PTEntry + 1, EFI_PAGE_SIZE - sizeof (*PTEntry)); + + // + // Return the address of PML4 (to set CR3) + // + mSmmS3ResumeState->SmmS3Cr3 = (UINT32)(UINTN)PTEntry; + + return ; +} + +/** + Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. + +**/ +VOID +InitPagesForPFHandler ( + VOID + ) +{ + VOID *Address; + + // + // Pre-Allocate memory for page fault handler + // + Address = NULL; + Address = AllocatePages (MAX_PF_PAGE_COUNT); + ASSERT (Address != NULL); + + mPFPageBuffer = (UINT64)(UINTN) Address; + mPFPageIndex = 0; + ZeroMem ((VOID *) (UINTN) mPFPageBuffer, EFI_PAGE_SIZE * MAX_PF_PAGE_COUNT); + ZeroMem (mPFPageUplink, sizeof (mPFPageUplink)); + + return; +} + +/** + Allocate one page for creating 4KB-page based on 2MB-page. + + @param Uplink The address of Page-Directory entry. + +**/ +VOID +AcquirePage ( + UINT64 *Uplink + ) +{ + UINT64 Address; + + // + // Get the buffer + // + Address = mPFPageBuffer + EFI_PAGES_TO_SIZE (mPFPageIndex); + ZeroMem ((VOID *) (UINTN) Address, EFI_PAGE_SIZE); + + // + // Cut the previous uplink if it exists and wasn't overwritten + // + if ((mPFPageUplink[mPFPageIndex] != NULL) && ((*mPFPageUplink[mPFPageIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK) == Address)) { + *mPFPageUplink[mPFPageIndex] = 0; + } + + // + // Link & Record the current uplink + // + *Uplink = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + mPFPageUplink[mPFPageIndex] = Uplink; + + mPFPageIndex = (mPFPageIndex + 1) % MAX_PF_PAGE_COUNT; +} + +/** + Update page table to map the memory correctly in order to make the instruction + which caused page fault execute successfully. And it also save the original page + table to be restored in single-step exception. + + @param PageTable PageTable Address. + @param PFAddress The memory address which caused page fault exception. + @param CpuIndex The index of the processor. + @param ErrorCode The Error code of exception. + @param IsValidPFAddress The flag indicates if SMM profile data need be added. + +**/ +VOID +RestorePageTableAbove4G ( + UINT64 *PageTable, + UINT64 PFAddress, + UINTN CpuIndex, + UINTN ErrorCode, + BOOLEAN *IsValidPFAddress + ) +{ + UINTN PTIndex; + UINT64 Address; + BOOLEAN Nx; + BOOLEAN Existed; + UINTN Index; + UINTN PFIndex; + + ASSERT ((PageTable != NULL) && (IsValidPFAddress != NULL)); + + // + // If page fault address is 4GB above. + // + + // + // Check if page fault address has existed in page table. + // If it exists in page table but page fault is generated, + // there are 2 possible reasons: 1. present flag is set to 0; 2. instruction fetch in protected memory range. + // + Existed = FALSE; + PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK); + PTIndex = BitFieldRead64 (PFAddress, 39, 47); + if ((PageTable[PTIndex] & IA32_PG_P) != 0) { + // PML4E + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + PTIndex = BitFieldRead64 (PFAddress, 30, 38); + if ((PageTable[PTIndex] & IA32_PG_P) != 0) { + // PDPTE + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + PTIndex = BitFieldRead64 (PFAddress, 21, 29); + // PD + if ((PageTable[PTIndex] & IA32_PG_PS) != 0) { + // + // 2MB page + // + Address = (UINT64)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + if ((Address & ~((1ull << 21) - 1)) == ((PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 21) - 1)))) { + Existed = TRUE; + } + } else { + // + // 4KB page + // + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask& PHYSICAL_ADDRESS_MASK); + if (PageTable != 0) { + // + // When there is a valid entry to map to 4KB page, need not create a new entry to map 2MB. + // + PTIndex = BitFieldRead64 (PFAddress, 12, 20); + Address = (UINT64)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + if ((Address & ~((1ull << 12) - 1)) == (PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 12) - 1))) { + Existed = TRUE; + } + } + } + } + } + + // + // If page entry does not existed in page table at all, create a new entry. + // + if (!Existed) { + + if (IsAddressValid (PFAddress, &Nx)) { + // + // If page fault address above 4GB is in protected range but it causes a page fault exception, + // Will create a page entry for this page fault address, make page table entry as present/rw and execution-disable. + // this access is not saved into SMM profile data. + // + *IsValidPFAddress = TRUE; + } + + // + // Create one entry in page table for page fault address. + // + SmiDefaultPFHandler (); + // + // Find the page table entry created just now. + // + PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK); + PFAddress = AsmReadCr2 (); + // PML4E + PTIndex = BitFieldRead64 (PFAddress, 39, 47); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + // PDPTE + PTIndex = BitFieldRead64 (PFAddress, 30, 38); + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + // PD + PTIndex = BitFieldRead64 (PFAddress, 21, 29); + Address = PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK; + // + // Check if 2MB-page entry need be changed to 4KB-page entry. + // + if (IsAddressSplit (Address)) { + AcquirePage (&PageTable[PTIndex]); + + // PTE + PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); + for (Index = 0; Index < 512; Index++) { + PageTable[Index] = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS; + if (!IsAddressValid (Address, &Nx)) { + PageTable[Index] = PageTable[Index] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); + } + if (Nx && mXdSupported) { + PageTable[Index] = PageTable[Index] | IA32_PG_NX; + } + if (Address == (PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 12) - 1))) { + PTIndex = Index; + } + Address += SIZE_4KB; + } // end for PT + } else { + // + // Update 2MB page entry. + // + if (!IsAddressValid (Address, &Nx)) { + // + // Patch to remove present flag and rw flag. + // + PageTable[PTIndex] = PageTable[PTIndex] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); + } + // + // Set XD bit to 1 + // + if (Nx && mXdSupported) { + PageTable[PTIndex] = PageTable[PTIndex] | IA32_PG_NX; + } + } + } + + // + // Record old entries with non-present status + // Old entries include the memory which instruction is at and the memory which instruction access. + // + // + ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); + if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { + PFIndex = mPFEntryCount[CpuIndex]; + mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; + mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; + mPFEntryCount[CpuIndex]++; + } + + // + // Add present flag or clear XD flag to make page fault handler succeed. + // + PageTable[PTIndex] |= (UINT64)(PAGE_ATTRIBUTE_BITS); + if ((ErrorCode & IA32_PF_EC_ID) != 0) { + // + // If page fault is caused by instruction fetch, clear XD bit in the entry. + // + PageTable[PTIndex] &= ~IA32_PG_NX; + } + + return; +} + +/** + Clear TF in FLAGS. + + @param SystemContext A pointer to the processor context when + the interrupt occurred on the processor. + +**/ +VOID +ClearTrapFlag ( + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ) +{ + SystemContext.SystemContextX64->Rflags &= (UINTN) ~BIT8; +} diff --git a/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h new file mode 100644 index 0000000000..32f33139bf --- /dev/null +++ b/Core/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h @@ -0,0 +1,105 @@ +/** @file +X64 processor specific header file to enable SMM profile. + +Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SMM_PROFILE_ARCH_H_ +#define _SMM_PROFILE_ARCH_H_ + +#pragma pack (1) + +typedef struct _MSR_DS_AREA_STRUCT { + UINT64 BTSBufferBase; + UINT64 BTSIndex; + UINT64 BTSAbsoluteMaximum; + UINT64 BTSInterruptThreshold; + UINT64 PEBSBufferBase; + UINT64 PEBSIndex; + UINT64 PEBSAbsoluteMaximum; + UINT64 PEBSInterruptThreshold; + UINT64 PEBSCounterReset[2]; + UINT64 Reserved; +} MSR_DS_AREA_STRUCT; + +typedef struct _BRANCH_TRACE_RECORD { + UINT64 LastBranchFrom; + UINT64 LastBranchTo; + UINT64 Rsvd0 : 4; + UINT64 BranchPredicted : 1; + UINT64 Rsvd1 : 59; +} BRANCH_TRACE_RECORD; + +typedef struct _PEBS_RECORD { + UINT64 Rflags; + UINT64 LinearIP; + UINT64 Rax; + UINT64 Rbx; + UINT64 Rcx; + UINT64 Rdx; + UINT64 Rsi; + UINT64 Rdi; + UINT64 Rbp; + UINT64 Rsp; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; +} PEBS_RECORD; + +#pragma pack () + +#define PHYSICAL_ADDRESS_MASK ((1ull << 52) - SIZE_4KB) + +/** + Update page table to map the memory correctly in order to make the instruction + which caused page fault execute successfully. And it also save the original page + table to be restored in single-step exception. + + @param PageTable PageTable Address. + @param PFAddress The memory address which caused page fault exception. + @param CpuIndex The index of the processor. + @param ErrorCode The Error code of exception. + @param IsValidPFAddress The flag indicates if SMM profile data need be added. + +**/ +VOID +RestorePageTableAbove4G ( + UINT64 *PageTable, + UINT64 PFAddress, + UINTN CpuIndex, + UINTN ErrorCode, + BOOLEAN *IsValidPFAddress + ); + +/** + Create SMM page table for S3 path. + +**/ +VOID +InitSmmS3Cr3 ( + VOID + ); + +/** + Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. + +**/ +VOID +InitPagesForPFHandler ( + VOID + ); + +#endif // _SMM_PROFILE_ARCH_H_ diff --git a/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni b/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni new file mode 100644 index 0000000000..06af9d2ff0 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni @@ -0,0 +1,21 @@ +// /** @file +// Reset Vector +// +// This VTF requires build time fixups in order to find the SEC entry point. +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Reset Vector" + +#string STR_MODULE_DESCRIPTION #language en-US "This VTF requires build time fixups in order to find the SEC entry point" + diff --git a/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni b/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni new file mode 100644 index 0000000000..f18a4f0443 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni @@ -0,0 +1,17 @@ +// /** @file +// ResetVector Localized Strings and Content +// +// Copyright (c) 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" + + diff --git a/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf b/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf new file mode 100644 index 0000000000..ed41c3807d --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf @@ -0,0 +1,38 @@ +## @file +# Reset Vector +# +# This VTF requires build time fixups in order to find the SEC entry point. +# +# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ResetVector + FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 + MODULE_TYPE = SEC + VERSION_STRING = 1.1 + MODULE_UNI_FILE = ResetVector.uni + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + Vtf.nasmb + +[Packages] + MdePkg/MdePkg.dec + +[UserExtensions.TianoCore."ExtraFiles"] + ResetVectorExtra.uni diff --git a/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb b/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb new file mode 100644 index 0000000000..5aa733ea59 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb @@ -0,0 +1,60 @@ +;------------------------------------------------------------------------------ +; @file +; First code exectuted by processor after resetting. +; +; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 16 + +ALIGN 16 ; 0xffffffd0 + +applicationProcessorEntryPoint: +; +; Application Processors entry point +; +; GenFv generates code aligned on a 4k boundary which will jump to this +; location. (0xffffffd0) This allows the Local APIC Startup IPI to be +; used to wake up the application processors. +; + jmp short resetVector + +ALIGN 16 ; 0xffffffe0 + +peiCoreEntryPoint: +; +; PEI Core entry point +; +; GenFv fills the address of the PEI Core into this location +; + DD 0x12345678 + +ALIGN 16 ; 0xfffffff0 + +resetVector: +; +; Reset Vector +; +; This is where the processor will begin execution +; + nop + nop + jmp near $ + +ALIGN 8 + +ApStartupSegment: + DD 0x12345678 + +BootFvBaseAddress: + DD 0x12345678 + +ALIGN 16 ; 0x100000000 diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw new file mode 100644 index 0000000000..2c6ff655de Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw new file mode 100644 index 0000000000..e34780a3a2 Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw new file mode 100644 index 0000000000..6dfa68eabb Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf new file mode 100644 index 0000000000..72abd6e91c --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf @@ -0,0 +1,36 @@ +## @file +# Reset Vector binary +# +# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ResetVector + MODULE_UNI_FILE = ResetVector.uni + FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 + MODULE_TYPE = SEC + VERSION_STRING = 1.1 + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Binaries.Ia32] + RAW|ResetVector.ia32.raw|* + +[Binaries.X64] + RAW|ResetVector.x64.raw|* + +[UserExtensions.TianoCore."ExtraFiles"] + ResetVectorExtra.uni diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni new file mode 100644 index 0000000000..43eba267b6 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni @@ -0,0 +1,21 @@ +// /** @file +// Reset Vector binary +// +// Reset Vector binary +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Reset Vector binary" + +#string STR_MODULE_DESCRIPTION #language en-US "Reset Vector binary" + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw new file mode 100644 index 0000000000..6c0bcc47eb Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw new file mode 100644 index 0000000000..a78d5b407c Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw new file mode 100644 index 0000000000..61c71349a8 Binary files /dev/null and b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw differ diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni new file mode 100644 index 0000000000..f18a4f0443 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni @@ -0,0 +1,17 @@ +// /** @file +// ResetVector Localized Strings and Content +// +// Copyright (c) 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" + + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Build.py b/Core/UefiCpuPkg/ResetVector/Vtf0/Build.py new file mode 100644 index 0000000000..a645c371b9 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Build.py @@ -0,0 +1,53 @@ +## @file +# Automate the process of building the various reset vector types +# +# Copyright (c) 2009, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +import glob +import os +import subprocess +import sys + +def RunCommand(commandLine): + #print ' '.join(commandLine) + return subprocess.call(commandLine) + +for filename in glob.glob(os.path.join('Bin', '*.raw')): + os.remove(filename) + +for arch in ('ia32', 'x64'): + for debugType in (None, 'port80', 'serial'): + output = os.path.join('Bin', 'ResetVector') + output += '.' + arch + if debugType is not None: + output += '.' + debugType + output += '.raw' + commandLine = ( + 'nasm', + '-D', 'ARCH_%s' % arch.upper(), + '-D', 'DEBUG_%s' % str(debugType).upper(), + '-o', output, + 'Vtf0.nasmb', + ) + ret = RunCommand(commandLine) + print '\tASM\t' + output + if ret != 0: sys.exit(ret) + + commandLine = ( + 'python', + 'Tools/FixupForRawSection.py', + output, + ) + print '\tFIXUP\t' + output + ret = RunCommand(commandLine) + if ret != 0: sys.exit(ret) + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc b/Core/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc new file mode 100644 index 0000000000..b46da27686 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc @@ -0,0 +1,31 @@ +;------------------------------------------------------------------------------ +; @file +; Common macros used in the ResetVector VTF module. +; +; Copyright (c) 2008, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +%define ADDR16_OF(x) (0x10000 - fourGigabytes + x) +%define ADDR_OF(x) (0x100000000 - fourGigabytes + x) + +%macro OneTimeCall 1 + jmp %1 +%1 %+ OneTimerCallReturn: +%endmacro + +%macro OneTimeCallRet 1 + jmp %1 %+ OneTimerCallReturn +%endmacro + +StartOfResetVectorCode: + +%define ADDR_OF_START_OF_RESET_CODE ADDR_OF(StartOfResetVectorCode) + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm new file mode 100644 index 0000000000..883cef03e0 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm @@ -0,0 +1,26 @@ +;------------------------------------------------------------------------------ +; @file +; Debug disabled +; +; Copyright (c) 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 16 + +%macro debugInitialize 0 + ; + ; No initialization is required + ; +%endmacro + +%macro debugShowPostCode 1 +%endmacro + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm new file mode 100644 index 0000000000..226c49f220 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm @@ -0,0 +1,48 @@ +;------------------------------------------------------------------------------ +; @file +; 16-bit initialization code +; +; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + + +BITS 16 + +; +; @param[out] DI 'BP' to indicate boot-strap processor +; +EarlyBspInitReal16: + mov di, 'BP' + jmp short Main16 + +; +; @param[out] DI 'AP' to indicate application processor +; +EarlyApInitReal16: + mov di, 'AP' + jmp short Main16 + +; +; Modified: EAX +; +; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test) +; @param[out] ESP Initial value of the EAX register (BIST: Built-in Self Test) +; +EarlyInit16: + ; + ; ESP - Initial value of the EAX register (BIST: Built-in Self Test) + ; + mov esp, eax + + debugInitialize + + OneTimeCallRet EarlyInit16 + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm new file mode 100644 index 0000000000..146df600a6 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm @@ -0,0 +1,133 @@ +;------------------------------------------------------------------------------ +; @file +; Transition from 16 bit real mode into 32 bit flat protected mode +; +; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +%define SEC_DEFAULT_CR0 0x40000023 +%define SEC_DEFAULT_CR4 0x640 + +BITS 16 + +; +; Modified: EAX, EBX +; +TransitionFromReal16To32BitFlat: + + debugShowPostCode POSTCODE_16BIT_MODE + + cli + + mov bx, 0xf000 + mov ds, bx + + mov bx, ADDR16_OF(gdtr) + +o32 lgdt [cs:bx] + + mov eax, SEC_DEFAULT_CR0 + mov cr0, eax + + jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere) +BITS 32 +jumpTo32BitAndLandHere: + + mov eax, SEC_DEFAULT_CR4 + mov cr4, eax + + debugShowPostCode POSTCODE_32BIT_MODE + + mov ax, LINEAR_SEL + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + OneTimeCallRet TransitionFromReal16To32BitFlat + +ALIGN 2 + +gdtr: + dw GDT_END - GDT_BASE - 1 ; GDT limit + dd ADDR_OF(GDT_BASE) + +ALIGN 16 + +; +; Macros for GDT entries +; + +%define PRESENT_FLAG(p) (p << 7) +%define DPL(dpl) (dpl << 5) +%define SYSTEM_FLAG(s) (s << 4) +%define DESC_TYPE(t) (t) + +; Type: data, expand-up, writable, accessed +%define DATA32_TYPE 3 + +; Type: execute, readable, expand-up, accessed +%define CODE32_TYPE 0xb + +; Type: execute, readable, expand-up, accessed +%define CODE64_TYPE 0xb + +%define GRANULARITY_FLAG(g) (g << 7) +%define DEFAULT_SIZE32(d) (d << 6) +%define CODE64_FLAG(l) (l << 5) +%define UPPER_LIMIT(l) (l) + +; +; The Global Descriptor Table (GDT) +; + +GDT_BASE: +; null descriptor +NULL_SEL equ $-GDT_BASE + DW 0 ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB 0 ; sys flag, dpl, type + DB 0 ; limit 19:16, flags + DB 0 ; base 31:24 + +; linear data segment descriptor +LINEAR_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(DATA32_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf) + DB 0 ; base 31:24 + +; linear code segment descriptor +LINEAR_CODE_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf) + DB 0 ; base 31:24 + +%ifdef ARCH_X64 +; linear code (64-bit) segment descriptor +LINEAR_CODE64_SEL equ $-GDT_BASE + DW 0xffff ; limit 15:0 + DW 0 ; base 15:0 + DB 0 ; base 23:16 + DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE64_TYPE) + DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(1)|UPPER_LIMIT(0xf) + DB 0 ; base 31:24 +%endif + +GDT_END: + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm new file mode 100644 index 0000000000..142d9f3212 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm @@ -0,0 +1,71 @@ +;------------------------------------------------------------------------------ +; @file +; First code executed by processor after resetting. +; +; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 16 + +ALIGN 16 + +; +; Pad the image size to 4k when page tables are in VTF0 +; +; If the VTF0 image has page tables built in, then we need to make +; sure the end of VTF0 is 4k above where the page tables end. +; +; This is required so the page tables will be 4k aligned when VTF0 is +; located just below 0x100000000 (4GB) in the firmware device. +; +%ifdef ALIGN_TOP_TO_4K_FOR_PAGING + TIMES (0x1000 - ($ - EndOfPageTables) - 0x20) DB 0 +%endif + +applicationProcessorEntryPoint: +; +; Application Processors entry point +; +; GenFv generates code aligned on a 4k boundary which will jump to this +; location. (0xffffffe0) This allows the Local APIC Startup IPI to be +; used to wake up the application processors. +; + jmp EarlyApInitReal16 + +ALIGN 8 + + DD 0 + +; +; The VTF signature +; +; VTF-0 means that the VTF (Volume Top File) code does not require +; any fixups. +; +vtfSignature: + DB 'V', 'T', 'F', 0 + +ALIGN 16 + +resetVector: +; +; Reset Vector +; +; This is where the processor will begin execution +; + nop + nop + jmp EarlyBspInitReal16 + +ALIGN 16 + +fourGigabytes: + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm new file mode 100644 index 0000000000..62e71da3d5 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; @file +; Transition from 32 bit flat protected mode into 64 bit flat protected mode +; +; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 32 + +; +; Modified: EAX +; +Transition32FlatTo64Flat: + + OneTimeCall SetCr3ForPageTables64 + + mov eax, cr4 + bts eax, 5 ; enable PAE + mov cr4, eax + + mov ecx, 0xc0000080 + rdmsr + bts eax, 8 ; set LME + wrmsr + + mov eax, cr0 + bts eax, 31 ; set PG + mov cr0, eax ; enable paging + + jmp LINEAR_CODE64_SEL:ADDR_OF(jumpTo64BitAndLandHere) +BITS 64 +jumpTo64BitAndLandHere: + + debugShowPostCode POSTCODE_64BIT_MODE + + OneTimeCallRet Transition32FlatTo64Flat + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm new file mode 100644 index 0000000000..2e16e71f6a --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm @@ -0,0 +1,30 @@ +;------------------------------------------------------------------------------ +; @file +; Sets the CR3 register for 64-bit paging +; +; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 32 + +; +; Modified: EAX +; +SetCr3ForPageTables64: + + ; + ; These pages are built into the ROM image in X64/PageTables.asm + ; + mov eax, ADDR_OF(TopLevelPageDirectory) + mov cr3, eax + + OneTimeCallRet SetCr3ForPageTables64 + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm new file mode 100644 index 0000000000..d0c2d8c39c --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm @@ -0,0 +1,86 @@ +;------------------------------------------------------------------------------ +; @file +; Search for the Boot Firmware Volume (BFV) base address +; +; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \ +; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } } +%define FFS_GUID_DWORD0 0x8c8ce578 +%define FFS_GUID_DWORD1 0x4f1c8a3d +%define FFS_GUID_DWORD2 0x61893599 +%define FFS_GUID_DWORD3 0xd32dc385 + +BITS 32 + +; +; Modified: EAX, EBX +; Preserved: EDI, ESP +; +; @param[out] EBP Address of Boot Firmware Volume (BFV) +; +Flat32SearchForBfvBase: + + xor eax, eax +searchingForBfvHeaderLoop: + ; + ; We check for a firmware volume at every 4KB address in the top 16MB + ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.) + ; + sub eax, 0x1000 + cmp eax, 0xff000000 + jb searchedForBfvHeaderButNotFound + + ; + ; Check FFS GUID + ; + cmp dword [eax + 0x10], FFS_GUID_DWORD0 + jne searchingForBfvHeaderLoop + cmp dword [eax + 0x14], FFS_GUID_DWORD1 + jne searchingForBfvHeaderLoop + cmp dword [eax + 0x18], FFS_GUID_DWORD2 + jne searchingForBfvHeaderLoop + cmp dword [eax + 0x1c], FFS_GUID_DWORD3 + jne searchingForBfvHeaderLoop + + ; + ; Check FV Length + ; + cmp dword [eax + 0x24], 0 + jne searchingForBfvHeaderLoop + mov ebx, eax + add ebx, dword [eax + 0x20] + jnz searchingForBfvHeaderLoop + + jmp searchedForBfvHeaderAndItWasFound + +searchedForBfvHeaderButNotFound: + ; + ; Hang if the SEC entry point was not found + ; + debugShowPostCode POSTCODE_BFV_NOT_FOUND + + ; + ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed + ; for debugging purposes. + ; + mov eax, 0xBFBFBFBF + mov ebp, eax + jmp $ + +searchedForBfvHeaderAndItWasFound: + mov ebp, eax + + debugShowPostCode POSTCODE_BFV_FOUND + + OneTimeCallRet Flat32SearchForBfvBase + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm new file mode 100644 index 0000000000..6206b44485 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm @@ -0,0 +1,200 @@ +;------------------------------------------------------------------------------ +; @file +; Search for the SEC Core entry point +; +; Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 32 + +%define EFI_FV_FILETYPE_SECURITY_CORE 0x03 + +; +; Modified: EAX, EBX, ECX, EDX +; Preserved: EDI, EBP, ESP +; +; @param[in] EBP Address of Boot Firmware Volume (BFV) +; @param[out] ESI SEC Core Entry Point Address +; +Flat32SearchForSecEntryPoint: + + ; + ; Initialize EBP and ESI to 0 + ; + xor ebx, ebx + mov esi, ebx + + ; + ; Pass over the BFV header + ; + mov eax, ebp + mov bx, [ebp + 0x30] + add eax, ebx + jc secEntryPointWasNotFound + + jmp searchingForFfsFileHeaderLoop + +moveForwardWhileSearchingForFfsFileHeaderLoop: + ; + ; Make forward progress in the search + ; + inc eax + jc secEntryPointWasNotFound + +searchingForFfsFileHeaderLoop: + test eax, eax + jz secEntryPointWasNotFound + + ; + ; Ensure 8 byte alignment + ; + add eax, 7 + jc secEntryPointWasNotFound + and al, 0xf8 + + ; + ; Look to see if there is an FFS file at eax + ; + mov bl, [eax + 0x17] + test bl, 0x20 + jz moveForwardWhileSearchingForFfsFileHeaderLoop + mov ecx, [eax + 0x14] + and ecx, 0x00ffffff + or ecx, ecx + jz moveForwardWhileSearchingForFfsFileHeaderLoop + add ecx, eax + jz jumpSinceWeFoundTheLastFfsFile + jc moveForwardWhileSearchingForFfsFileHeaderLoop +jumpSinceWeFoundTheLastFfsFile: + + ; + ; There seems to be a valid file at eax + ; + cmp byte [eax + 0x12], EFI_FV_FILETYPE_SECURITY_CORE ; Check File Type + jne readyToTryFfsFileAtEcx + +fileTypeIsSecCore: + OneTimeCall GetEntryPointOfFfsFile + test eax, eax + jnz doneSeachingForSecEntryPoint + +readyToTryFfsFileAtEcx: + ; + ; Try the next FFS file at ECX + ; + mov eax, ecx + jmp searchingForFfsFileHeaderLoop + +secEntryPointWasNotFound: + xor eax, eax + +doneSeachingForSecEntryPoint: + mov esi, eax + + test esi, esi + jnz secCoreEntryPointWasFound + +secCoreEntryPointWasNotFound: + ; + ; Hang if the SEC entry point was not found + ; + debugShowPostCode POSTCODE_SEC_NOT_FOUND + jz $ + +secCoreEntryPointWasFound: + debugShowPostCode POSTCODE_SEC_FOUND + + OneTimeCallRet Flat32SearchForSecEntryPoint + +%define EFI_SECTION_PE32 0x10 +%define EFI_SECTION_TE 0x12 + +; +; Input: +; EAX - Start of FFS file +; ECX - End of FFS file +; +; Output: +; EAX - Entry point of PE32 (or 0 if not found) +; +; Modified: +; EBX +; +GetEntryPointOfFfsFile: + test eax, eax + jz getEntryPointOfFfsFileErrorReturn + add eax, 0x18 ; EAX = Start of section + +getEntryPointOfFfsFileLoopForSections: + cmp eax, ecx + jae getEntryPointOfFfsFileErrorReturn + + cmp byte [eax + 3], EFI_SECTION_PE32 + je getEntryPointOfFfsFileFoundPe32Section + + cmp byte [eax + 3], EFI_SECTION_TE + je getEntryPointOfFfsFileFoundTeSection + + ; + ; The section type was not PE32 or TE, so move to next section + ; + mov ebx, dword [eax] + and ebx, 0x00ffffff + add eax, ebx + jc getEntryPointOfFfsFileErrorReturn + + ; + ; Ensure that FFS section is 32-bit aligned + ; + add eax, 3 + jc getEntryPointOfFfsFileErrorReturn + and al, 0xfc + jmp getEntryPointOfFfsFileLoopForSections + +getEntryPointOfFfsFileFoundPe32Section: + add eax, 4 ; EAX = Start of PE32 image + + cmp word [eax], 'MZ' + jne getEntryPointOfFfsFileErrorReturn + movzx ebx, word [eax + 0x3c] + add ebx, eax + + ; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) + cmp dword [ebx], `PE\x00\x00` + jne getEntryPointOfFfsFileErrorReturn + + ; *EntryPoint = (VOID *)((UINTN)Pe32Data + + ; (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff)); + add eax, [ebx + 0x4 + 0x14 + 0x10] + jmp getEntryPointOfFfsFileReturn + +getEntryPointOfFfsFileFoundTeSection: + add eax, 4 ; EAX = Start of TE image + mov ebx, eax + + ; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) + cmp word [ebx], 'VZ' + jne getEntryPointOfFfsFileErrorReturn + ; *EntryPoint = (VOID *)((UINTN)Pe32Data + + ; (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) + + ; sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize); + add eax, [ebx + 0x8] + add eax, 0x28 + movzx ebx, word [ebx + 0x6] + sub eax, ebx + jmp getEntryPointOfFfsFileReturn + +getEntryPointOfFfsFileErrorReturn: + mov eax, 0 + +getEntryPointOfFfsFileReturn: + OneTimeCallRet GetEntryPointOfFfsFile + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Main.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Main.asm new file mode 100644 index 0000000000..ebfb9015d4 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Main.asm @@ -0,0 +1,106 @@ +;------------------------------------------------------------------------------ +; @file +; Main routine of the pre-SEC code up through the jump into SEC +; +; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + + +BITS 16 + +; +; Modified: EBX, ECX, EDX, EBP +; +; @param[in,out] RAX/EAX Initial value of the EAX register +; (BIST: Built-in Self Test) +; @param[in,out] DI 'BP': boot-strap processor, or +; 'AP': application processor +; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV) +; +; @return None This routine jumps to SEC and does not return +; +Main16: + OneTimeCall EarlyInit16 + + ; + ; Transition the processor from 16-bit real mode to 32-bit flat mode + ; + OneTimeCall TransitionFromReal16To32BitFlat + +BITS 32 + + ; + ; Search for the Boot Firmware Volume (BFV) + ; + OneTimeCall Flat32SearchForBfvBase + + ; + ; EBP - Start of BFV + ; + + ; + ; Search for the SEC entry point + ; + OneTimeCall Flat32SearchForSecEntryPoint + + ; + ; ESI - SEC Core entry point + ; EBP - Start of BFV + ; + +%ifdef ARCH_IA32 + + ; + ; Restore initial EAX value into the EAX register + ; + mov eax, esp + + ; + ; Jump to the 32-bit SEC entry point + ; + jmp esi + +%else + + ; + ; Transition the processor from 32-bit flat mode to 64-bit flat mode + ; + OneTimeCall Transition32FlatTo64Flat + +BITS 64 + + ; + ; Some values were calculated in 32-bit mode. Make sure the upper + ; 32-bits of 64-bit registers are zero for these values. + ; + mov rax, 0x00000000ffffffff + and rsi, rax + and rbp, rax + and rsp, rax + + ; + ; RSI - SEC Core entry point + ; RBP - Start of BFV + ; + + ; + ; Restore initial EAX value into the RAX register + ; + mov rax, rsp + + ; + ; Jump to the 64-bit SEC entry point + ; + jmp rsi + +%endif + + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm new file mode 100644 index 0000000000..4b13c4860b --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm @@ -0,0 +1,28 @@ +;------------------------------------------------------------------------------ +; @file +; Port 0x80 debug support macros +; +; Copyright (c) 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 16 + +%macro debugInitialize 0 + ; + ; No initialization is required + ; +%endmacro + +%macro debugShowPostCode 1 + mov al, %1 + out 0x80, al +%endmacro + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc b/Core/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc new file mode 100644 index 0000000000..62eda5d992 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc @@ -0,0 +1,25 @@ +;------------------------------------------------------------------------------ +; @file +; Definitions of POST CODES for the reset vector module +; +; Copyright (c) 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +%define POSTCODE_16BIT_MODE 0x16 +%define POSTCODE_32BIT_MODE 0x32 +%define POSTCODE_64BIT_MODE 0x64 + +%define POSTCODE_BFV_NOT_FOUND 0xb0 +%define POSTCODE_BFV_FOUND 0xb1 + +%define POSTCODE_SEC_NOT_FOUND 0xf0 +%define POSTCODE_SEC_FOUND 0xf1 + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt b/Core/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt new file mode 100644 index 0000000000..e6e5b54243 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt @@ -0,0 +1,41 @@ + +=== HOW TO USE VTF0 === + +Add this line to your FDF FV section: +INF RuleOverride=RESET_VECTOR USE = IA32 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf +(For X64 SEC/PEI change IA32 to X64 => 'USE = X64') + +In your FDF FFS file rules sections add: +[Rule.Common.SEC.RESET_VECTOR] + FILE RAW = $(NAMED_GUID) { + RAW RAW |.raw + } + +=== VTF0 Boot Flow === + +1. Transition to IA32 flat mode +2. Locate BFV (Boot Firmware Volume) by checking every 4kb boundary +3. Locate SEC image +4. X64 VTF0 transitions to X64 mode +5. Call SEC image entry point + +== VTF0 SEC input parameters == + +All inputs to SEC image are register based: +EAX/RAX - Initial value of the EAX register (BIST: Built-in Self Test) +DI - 'BP': boot-strap processor, or 'AP': application processor +EBP/RBP - Pointer to the start of the Boot Firmware Volume + +=== HOW TO BUILD VTF0 === + +Dependencies: +* Python 2.5~2.7 +* Nasm 2.03 or newer + +To rebuild the VTF0 binaries: +1. Change to VTF0 source dir: UefiCpuPkg/ResetVector/Vtf0 +2. nasm and python should be in executable path +3. Run this command: + python Build.py +4. Binaries output will be in UefiCpuPkg/ResetVector/Vtf0/Bin + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni b/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni new file mode 100644 index 0000000000..3fcc3f084c --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni @@ -0,0 +1,21 @@ +// /** @file +// Reset Vector +// +// Reset Vector +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Reset Vector" + +#string STR_MODULE_DESCRIPTION #language en-US "Reset Vector" + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni b/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni new file mode 100644 index 0000000000..f18a4f0443 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni @@ -0,0 +1,17 @@ +// /** @file +// ResetVector Localized Strings and Content +// +// Copyright (c) 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" + + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm new file mode 100644 index 0000000000..ebd0910f4a --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm @@ -0,0 +1,132 @@ +;------------------------------------------------------------------------------ +; @file +; Serial port debug support macros +; +; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +;//--------------------------------------------- +;// UART Register Offsets +;//--------------------------------------------- +%define BAUD_LOW_OFFSET 0x00 +%define BAUD_HIGH_OFFSET 0x01 +%define IER_OFFSET 0x01 +%define LCR_SHADOW_OFFSET 0x01 +%define FCR_SHADOW_OFFSET 0x02 +%define IR_CONTROL_OFFSET 0x02 +%define FCR_OFFSET 0x02 +%define EIR_OFFSET 0x02 +%define BSR_OFFSET 0x03 +%define LCR_OFFSET 0x03 +%define MCR_OFFSET 0x04 +%define LSR_OFFSET 0x05 +%define MSR_OFFSET 0x06 + +;//--------------------------------------------- +;// UART Register Bit Defines +;//--------------------------------------------- +%define LSR_TXRDY 0x20 +%define LSR_RXDA 0x01 +%define DLAB 0x01 + +; UINT16 gComBase = 0x3f8; +; UINTN gBps = 115200; +; UINT8 gData = 8; +; UINT8 gStop = 1; +; UINT8 gParity = 0; +; UINT8 gBreakSet = 0; + +%define DEFAULT_COM_BASE 0x3f8 +%define DEFAULT_BPS 115200 +%define DEFAULT_DATA 8 +%define DEFAULT_STOP 1 +%define DEFAULT_PARITY 0 +%define DEFAULT_BREAK_SET 0 + +%define SERIAL_DEFAULT_LCR ( \ + (DEFAULT_BREAK_SET << 6) | \ + (DEFAULT_PARITY << 3) | \ + (DEFAULT_STOP << 2) | \ + (DEFAULT_DATA - 5) \ + ) + +%define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE + +%macro inFromSerialPort 1 + mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1) + in al, dx +%endmacro + +%macro waitForSerialTxReady 0 + +%%waitingForTx: + inFromSerialPort LSR_OFFSET + test al, LSR_TXRDY + jz %%waitingForTx + +%endmacro + +%macro outToSerialPort 2 + mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1) + mov al, %2 + out dx, al +%endmacro + +%macro debugShowCharacter 1 + waitForSerialTxReady + outToSerialPort 0, %1 +%endmacro + +%macro debugShowHexDigit 1 + %if (%1 < 0xa) + debugShowCharacter BYTE ('0' + (%1)) + %else + debugShowCharacter BYTE ('a' + ((%1) - 0xa)) + %endif +%endmacro + +%macro debugNewline 0 + debugShowCharacter `\r` + debugShowCharacter `\n` +%endmacro + +%macro debugShowPostCode 1 + debugShowHexDigit (((%1) >> 4) & 0xf) + debugShowHexDigit ((%1) & 0xf) + debugNewline +%endmacro + +BITS 16 + +%macro debugInitialize 0 + jmp real16InitDebug +real16InitDebugReturn: +%endmacro + +real16InitDebug: + ; + ; Set communications format + ; + outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR) + + ; + ; Configure baud rate + ; + outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8) + outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff) + + ; + ; Switch back to bank 0 + ; + outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR + + jmp real16InitDebugReturn + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py b/Core/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py new file mode 100644 index 0000000000..a70ce7501d --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py @@ -0,0 +1,26 @@ +## @file +# Apply fixup to VTF binary image for FFS Raw section +# +# Copyright (c) 2008, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +import sys + +filename = sys.argv[1] + +d = open(sys.argv[1], 'rb').read() +c = ((len(d) + 4 + 7) & ~7) - 4 +if c > len(d): + c -= len(d) + f = open(sys.argv[1], 'wb') + f.write('\x90' * c) + f.write(d) + f.close() diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf b/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf new file mode 100644 index 0000000000..41aba45a14 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf @@ -0,0 +1,36 @@ +## @file +# Reset Vector +# +# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ResetVector + FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 + MODULE_TYPE = SEC + VERSION_STRING = 1.1 + MODULE_UNI_FILE = ResetVector.uni + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + Vtf0.nasmb + +[Packages] + MdePkg/MdePkg.dec + +[UserExtensions.TianoCore."ExtraFiles"] + ResetVectorExtra.uni diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb b/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb new file mode 100644 index 0000000000..f4a29e8d89 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb @@ -0,0 +1,70 @@ +;------------------------------------------------------------------------------ +; @file +; This file includes all other code files to assemble the reset vector code +; +; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +; +; If neither ARCH_IA32 nor ARCH_X64 are defined, then try to include +; Base.h to use the C pre-processor to determine the architecture. +; +%ifndef ARCH_IA32 + %ifndef ARCH_X64 + #include + #if defined (MDE_CPU_IA32) + %define ARCH_IA32 + #elif defined (MDE_CPU_X64) + %define ARCH_X64 + #endif + %endif +%endif + +%ifdef ARCH_IA32 + %ifdef ARCH_X64 + %error "Only one of ARCH_IA32 or ARCH_X64 can be defined." + %endif +%elifdef ARCH_X64 +%else + %error "Either ARCH_IA32 or ARCH_X64 must be defined." +%endif + +%include "CommonMacros.inc" + +%include "PostCodes.inc" + +%ifdef ARCH_X64 +%include "X64/PageTables.asm" +%endif + +%ifdef DEBUG_PORT80 + %include "Port80Debug.asm" +%elifdef DEBUG_SERIAL + %include "SerialDebug.asm" +%else + %include "DebugDisabled.asm" +%endif + +%include "Ia32/SearchForBfvBase.asm" +%include "Ia32/SearchForSecEntry.asm" + +%ifdef ARCH_X64 +%include "Ia32/Flat32ToFlat64.asm" +%include "Ia32/PageTables64.asm" +%endif + +%include "Ia16/Real16ToFlat32.asm" +%include "Ia16/Init16.asm" + +%include "Main.asm" + +%include "Ia16/ResetVectorVtf0.asm" + diff --git a/Core/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm b/Core/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm new file mode 100644 index 0000000000..3d703c74f6 --- /dev/null +++ b/Core/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm @@ -0,0 +1,78 @@ +;------------------------------------------------------------------------------ +; @file +; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x100000000 (4GB) +; +; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + +BITS 64 + +%define ALIGN_TOP_TO_4K_FOR_PAGING + +%define PAGE_PRESENT 0x01 +%define PAGE_READ_WRITE 0x02 +%define PAGE_USER_SUPERVISOR 0x04 +%define PAGE_WRITE_THROUGH 0x08 +%define PAGE_CACHE_DISABLE 0x010 +%define PAGE_ACCESSED 0x020 +%define PAGE_DIRTY 0x040 +%define PAGE_PAT 0x080 +%define PAGE_GLOBAL 0x0100 +%define PAGE_2M_MBO 0x080 +%define PAGE_2M_PAT 0x01000 + +%define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \ + PAGE_ACCESSED + \ + PAGE_DIRTY + \ + PAGE_READ_WRITE + \ + PAGE_PRESENT) + +%define PAGE_PDP_ATTR (PAGE_ACCESSED + \ + PAGE_READ_WRITE + \ + PAGE_PRESENT) + +%define PGTBLS_OFFSET(x) ((x) - TopLevelPageDirectory) +%define PGTBLS_ADDR(x) (ADDR_OF(TopLevelPageDirectory) + (x)) + +%define PDP(offset) (ADDR_OF(TopLevelPageDirectory) + (offset) + \ + PAGE_PDP_ATTR) +%define PTE_2MB(x) ((x << 21) + PAGE_2M_PDE_ATTR) + +TopLevelPageDirectory: + + ; + ; Top level Page Directory Pointers (1 * 512GB entry) + ; + DQ PDP(0x1000) + + + ; + ; Next level Page Directory Pointers (4 * 1GB entries => 4GB) + ; + TIMES 0x1000-PGTBLS_OFFSET($) DB 0 + + DQ PDP(0x2000) + DQ PDP(0x3000) + DQ PDP(0x4000) + DQ PDP(0x5000) + + ; + ; Page Table Entries (2048 * 2MB entries => 4GB) + ; + TIMES 0x2000-PGTBLS_OFFSET($) DB 0 + +%assign i 0 +%rep 0x800 + DQ PTE_2MB(i) + %assign i i+1 +%endrep + +EndOfPageTables: diff --git a/Core/UefiCpuPkg/SecCore/FindPeiCore.c b/Core/UefiCpuPkg/SecCore/FindPeiCore.c new file mode 100644 index 0000000000..60ccaa9667 --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/FindPeiCore.c @@ -0,0 +1,198 @@ +/** @file + Locate the entry point for the PEI Core + + Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include + +#include "SecMain.h" + +/** + Find core image base. + + @param BootFirmwareVolumePtr Point to the boot firmware volume. + @param SecCoreImageBase The base address of the SEC core image. + @param PeiCoreImageBase The base address of the PEI core image. + +**/ +EFI_STATUS +EFIAPI +FindImageBase ( + IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, + OUT EFI_PHYSICAL_ADDRESS *SecCoreImageBase, + OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase + ) +{ + EFI_PHYSICAL_ADDRESS CurrentAddress; + EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume; + EFI_FFS_FILE_HEADER *File; + UINT32 Size; + EFI_PHYSICAL_ADDRESS EndOfFile; + EFI_COMMON_SECTION_HEADER *Section; + EFI_PHYSICAL_ADDRESS EndOfSection; + + *SecCoreImageBase = 0; + *PeiCoreImageBase = 0; + + CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) BootFirmwareVolumePtr; + EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr->FvLength; + + // + // Loop through the FFS files in the Boot Firmware Volume + // + for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr->HeaderLength; ; ) { + + CurrentAddress = (EndOfFile + 7) & 0xfffffffffffffff8ULL; + if (CurrentAddress > EndOfFirmwareVolume) { + return EFI_NOT_FOUND; + } + + File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress; + if (IS_FFS_FILE2 (File)) { + Size = FFS_FILE2_SIZE (File); + if (Size <= 0x00FFFFFF) { + return EFI_NOT_FOUND; + } + } else { + Size = FFS_FILE_SIZE (File); + if (Size < sizeof (EFI_FFS_FILE_HEADER)) { + return EFI_NOT_FOUND; + } + } + + EndOfFile = CurrentAddress + Size; + if (EndOfFile > EndOfFirmwareVolume) { + return EFI_NOT_FOUND; + } + + // + // Look for SEC Core / PEI Core files + // + if (File->Type != EFI_FV_FILETYPE_SECURITY_CORE && + File->Type != EFI_FV_FILETYPE_PEI_CORE) { + continue; + } + + // + // Loop through the FFS file sections within the FFS file + // + if (IS_FFS_FILE2 (File)) { + EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER2)); + } else { + EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER)); + } + for (;;) { + CurrentAddress = (EndOfSection + 3) & 0xfffffffffffffffcULL; + Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress; + + if (IS_SECTION2 (Section)) { + Size = SECTION2_SIZE (Section); + if (Size <= 0x00FFFFFF) { + return EFI_NOT_FOUND; + } + } else { + Size = SECTION_SIZE (Section); + if (Size < sizeof (EFI_COMMON_SECTION_HEADER)) { + return EFI_NOT_FOUND; + } + } + + EndOfSection = CurrentAddress + Size; + if (EndOfSection > EndOfFile) { + return EFI_NOT_FOUND; + } + + // + // Look for executable sections + // + if (Section->Type == EFI_SECTION_PE32 || Section->Type == EFI_SECTION_TE) { + if (File->Type == EFI_FV_FILETYPE_SECURITY_CORE) { + if (IS_SECTION2 (Section)) { + *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); + } else { + *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); + } + } else { + if (IS_SECTION2 (Section)) { + *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); + } else { + *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); + } + } + break; + } + } + + // + // Both SEC Core and PEI Core images found + // + if (*SecCoreImageBase != 0 && *PeiCoreImageBase != 0) { + return EFI_SUCCESS; + } + } +} + +/** + Find and return Pei Core entry point. + + It also find SEC and PEI Core file debug information. It will report them if + remote debug is enabled. + + @param BootFirmwareVolumePtr Point to the boot firmware volume. + @param PeiCoreEntryPoint The entry point of the PEI core. + +**/ +VOID +EFIAPI +FindAndReportEntryPoints ( + IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, + OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS SecCoreImageBase; + EFI_PHYSICAL_ADDRESS PeiCoreImageBase; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + + // + // Find SEC Core and PEI Core image base + // + Status = FindImageBase (BootFirmwareVolumePtr, &SecCoreImageBase, &PeiCoreImageBase); + ASSERT_EFI_ERROR (Status); + + ZeroMem ((VOID *) &ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); + // + // Report SEC Core debug information when remote debug is enabled + // + ImageContext.ImageAddress = SecCoreImageBase; + ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); + PeCoffLoaderRelocateImageExtraAction (&ImageContext); + + // + // Report PEI Core debug information when remote debug is enabled + // + ImageContext.ImageAddress = PeiCoreImageBase; + ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); + PeCoffLoaderRelocateImageExtraAction (&ImageContext); + + // + // Find PEI Core entry point + // + Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, (VOID**) PeiCoreEntryPoint); + if (EFI_ERROR (Status)) { + *PeiCoreEntryPoint = 0; + } + + return; +} diff --git a/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 b/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 new file mode 100644 index 0000000000..d90613c4d0 --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 @@ -0,0 +1,106 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ResetVec.asm +; +; Abstract: +; +; Reset Vector Data structure +; This structure is located at 0xFFFFFFC0 +; +;------------------------------------------------------------------------------ + + .model tiny + .686p + .stack 0h + .code + +; +; The layout of this file is fixed. The build tool makes assumption of the layout. +; + + ORG 0h +; +; Reserved +; +ReservedData DD 0eeeeeeeeh, 0eeeeeeeeh + + ORG 10h +; +; This is located at 0xFFFFFFD0h +; + mov di, "AP" + jmp ApStartup + + ORG 20h +; +; Pointer to the entry point of the PEI core +; It is located at 0xFFFFFFE0, and is fixed up by some build tool +; So if the value 8..1 appears in the final FD image, tool failure occurs. +; +PeiCoreEntryPoint DD 87654321h + +; +; This is the handler for all kinds of exceptions. Since it's for debugging +; purpose only, nothing except a dead loop would be done here. Developers could +; analyze the cause of the exception if a debugger had been attached. +; +InterruptHandler PROC + jmp $ + iret +InterruptHandler ENDP + + ORG 30h +; +; For IA32, the reset vector must be at 0xFFFFFFF0, i.e., 4G-16 byte +; Execution starts here upon power-on/platform-reset. +; +ResetHandler: + nop + nop +ApStartup: + ; + ; Jmp Rel16 instruction + ; Use machine code directly in case of the assembler optimization + ; SEC entry point relative address will be fixed up by some build tool. + ; + ; Typically, SEC entry point is the function _ModuleEntryPoint() defined in + ; SecEntry.asm + ; + DB 0e9h + DW -3 + + + ORG 38h +; +; Ap reset vector segment address is at 0xFFFFFFF8 +; This will be fixed up by some build tool, +; so if the value 1..8 appears in the final FD image, +; tool failure occurs +; +ApSegAddress dd 12345678h + + ORG 3ch +; +; BFV Base is at 0xFFFFFFFC +; This will be fixed up by some build tool, +; so if the value 1..8 appears in the final FD image, +; tool failure occurs. +; +BfvBase DD 12345678h + +; +; Nothing can go here, otherwise the layout of this file would change. +; + + END diff --git a/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb b/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb new file mode 100644 index 0000000000..2fcdc85e47 --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb @@ -0,0 +1,103 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2014, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ResetVec.nasmb +; +; Abstract: +; +; Reset Vector Data structure +; This structure is located at 0xFFFFFFC0 +; +;------------------------------------------------------------------------------ + +; .stack 0x0 +; SECTION .text +USE16 + +; +; The layout of this file is fixed. The build tool makes assumption of the layout. +; + + ORG 0h +; +; Reserved +; +ReservedData: DD 0eeeeeeeeh, 0eeeeeeeeh + + TIMES 0x10-($-$$) DB 0 +; +; This is located at 0xFFFFFFD0h +; + mov di, "PA" + jmp ApStartup + + TIMES 0x20-($-$$) DB 0 +; +; Pointer to the entry point of the PEI core +; It is located at 0xFFFFFFE0, and is fixed up by some build tool +; So if the value 8..1 appears in the final FD image, tool failure occurs. +; +PeiCoreEntryPoint: DD 87654321h + +; +; This is the handler for all kinds of exceptions. Since it's for debugging +; purpose only, nothing except a dead loop would be done here. Developers could +; analyze the cause of the exception if a debugger had been attached. +; +global ASM_PFX(InterruptHandler) +ASM_PFX(InterruptHandler): + jmp $ + iret + + TIMES 0x30-($-$$) DB 0 +; +; For IA32, the reset vector must be at 0xFFFFFFF0, i.e., 4G-16 byte +; Execution starts here upon power-on/platform-reset. +; +ResetHandler: + nop + nop +ApStartup: + ; + ; Jmp Rel16 instruction + ; Use machine code directly in case of the assembler optimization + ; SEC entry point relative address will be fixed up by some build tool. + ; + ; Typically, SEC entry point is the function _ModuleEntryPoint() defined in + ; SecEntry.asm + ; + DB 0e9h + DW -3 + + + TIMES 0x38-($-$$) DB 0 +; +; Ap reset vector segment address is at 0xFFFFFFF8 +; This will be fixed up by some build tool, +; so if the value 1..8 appears in the final FD image, +; tool failure occurs +; +ApSegAddress: dd 12345678h + + TIMES 0x3c-($-$$) DB 0 +; +; BFV Base is at 0xFFFFFFFC +; This will be fixed up by some build tool, +; so if the value 1..8 appears in the final FD image, +; tool failure occurs. +; +BfvBase: DD 12345678h + +; +; Nothing can go here, otherwise the layout of this file would change. +; diff --git a/Core/UefiCpuPkg/SecCore/SecBist.c b/Core/UefiCpuPkg/SecCore/SecBist.c new file mode 100644 index 0000000000..a9d36acadb --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecBist.c @@ -0,0 +1,270 @@ +/** @file + Get SEC platform information(2) PPI and reinstall it. + + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "SecMain.h" + +EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformation = { + SecPlatformInformationBist +}; + +EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiSecPlatformInformationPpiGuid, + &mSecPlatformInformation +}; + +EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2 = { + SecPlatformInformation2Bist +}; + +EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2 = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiSecPlatformInformation2PpiGuid, + &mSecPlatformInformation2 +}; + +/** + Worker function to parse CPU BIST information from Guided HOB. + + @param[in, out] StructureSize Pointer to the variable describing size of the input buffer. + @param[in, out] StructureBuffer Pointer to the buffer save CPU BIST information. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +GetBistFromHob ( + IN OUT UINT64 *StructureSize, + IN OUT VOID *StructureBuffer + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + VOID *DataInHob; + UINTN DataSize; + + GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid); + if (GuidHob == NULL) { + *StructureSize = 0; + return EFI_SUCCESS; + } + + DataInHob = GET_GUID_HOB_DATA (GuidHob); + DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); + + // + // return the information from BistHob + // + if ((*StructureSize) < (UINT64) DataSize) { + *StructureSize = (UINT64) DataSize; + return EFI_BUFFER_TOO_SMALL; + } + + *StructureSize = (UINT64) DataSize; + CopyMem (StructureBuffer, DataInHob, DataSize); + return EFI_SUCCESS; +} + +/** + Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI. + + @param[in] PeiServices Pointer to the PEI Services Table. + @param[in, out] StructureSize Pointer to the variable describing size of the input buffer. + @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformationBist ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ) +{ + return GetBistFromHob (StructureSize, PlatformInformationRecord); +} + +/** + Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. + + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in, out] StructureSize The pointer to the variable describing size of the input buffer. + @param[out] PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to + hold the record is returned in StructureSize. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation2Bist ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 + ) +{ + return GetBistFromHob (StructureSize, PlatformInformationRecord2); +} + +/** + Worker function to get CPUs' BIST by calling SecPlatformInformationPpi + or SecPlatformInformation2Ppi. + + @param[in] PeiServices Pointer to PEI Services Table + @param[in] Guid PPI Guid + @param[out] PpiDescriptor Return a pointer to instance of the + EFI_PEI_PPI_DESCRIPTOR + @param[out] BistInformationData Pointer to BIST information data + @param[out] BistInformationSize Return the size in bytes of BIST information + + @retval EFI_SUCCESS Retrieve of the BIST data successfully + @retval EFI_NOT_FOUND No sec platform information(2) ppi export + @retval EFI_DEVICE_ERROR Failed to get CPU Information + +**/ +EFI_STATUS +GetBistInfoFromPpi ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_GUID *Guid, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + OUT VOID **BistInformationData, + OUT UINT64 *BistInformationSize OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi; + EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; + UINT64 InformationSize; + + Status = PeiServicesLocatePpi ( + Guid, // GUID + 0, // INSTANCE + PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR + (VOID **)&SecPlatformInformation2Ppi // PPI + ); + if (Status == EFI_NOT_FOUND) { + return EFI_NOT_FOUND; + } + + if (Status == EFI_SUCCESS) { + // + // Get the size of the sec platform information2(BSP/APs' BIST data) + // + InformationSize = 0; + SecPlatformInformation2 = NULL; + Status = SecPlatformInformation2Ppi->PlatformInformation2 ( + PeiServices, + &InformationSize, + SecPlatformInformation2 + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = PeiServicesAllocatePool ( + (UINTN) InformationSize, + (VOID **) &SecPlatformInformation2 + ); + if (Status == EFI_SUCCESS) { + // + // Retrieve BIST data + // + Status = SecPlatformInformation2Ppi->PlatformInformation2 ( + PeiServices, + &InformationSize, + SecPlatformInformation2 + ); + if (Status == EFI_SUCCESS) { + *BistInformationData = SecPlatformInformation2; + if (BistInformationSize != NULL) { + *BistInformationSize = InformationSize; + } + return EFI_SUCCESS; + } + } + } + } + + return EFI_DEVICE_ERROR; +} + +/** + Get CPUs' BIST by calling SecPlatformInformationPpi/SecPlatformInformation2Ppi. + +**/ +VOID +RepublishSecPlatformInformationPpi ( + VOID + ) +{ + EFI_STATUS Status; + CONST EFI_PEI_SERVICES **PeiServices; + UINT64 BistInformationSize; + VOID *BistInformationData; + EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor; + + PeiServices = GetPeiServicesTablePointer (); + Status = GetBistInfoFromPpi ( + PeiServices, + &gEfiSecPlatformInformation2PpiGuid, + &SecInformationDescriptor, + &BistInformationData, + &BistInformationSize + ); + if (Status == EFI_SUCCESS) { + BuildGuidDataHob ( + &gEfiCallerIdGuid, + BistInformationData, + (UINTN) BistInformationSize + ); + // + // The old SecPlatformInformation2 data is on temporary memory. + // After memory discovered, we should never get it from temporary memory, + // or the data will be crashed. So, we reinstall SecPlatformInformation2 PPI here. + // + Status = PeiServicesReInstallPpi ( + SecInformationDescriptor, + &mPeiSecPlatformInformation2 + ); + } if (Status == EFI_NOT_FOUND) { + Status = GetBistInfoFromPpi ( + PeiServices, + &gEfiSecPlatformInformationPpiGuid, + &SecInformationDescriptor, + &BistInformationData, + &BistInformationSize + ); + if (Status == EFI_SUCCESS) { + BuildGuidDataHob ( + &gEfiCallerIdGuid, + BistInformationData, + (UINTN) BistInformationSize + ); + // + // The old SecPlatformInformation data is on temporary memory. + // After memory discovered, we should never get it from temporary memory, + // or the data will be crashed. So, we reinstall SecPlatformInformation PPI here. + // + Status = PeiServicesReInstallPpi ( + SecInformationDescriptor, + &mPeiSecPlatformInformation + ); + } else if (Status == EFI_NOT_FOUND) { + return; + } + } + + ASSERT_EFI_ERROR(Status); +} diff --git a/Core/UefiCpuPkg/SecCore/SecCore.inf b/Core/UefiCpuPkg/SecCore/SecCore.inf new file mode 100644 index 0000000000..0d135e62ec --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecCore.inf @@ -0,0 +1,79 @@ +## @file +# SecCore module that implements the SEC phase. +# +# This is the first module taking control of the platform upon power-on/reset. +# It implements the first phase of the security phase. The entry point function is +# _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to +# protected mode, setup flat memory model, enable temporary memory and +# call into SecStartup(). +# +# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SecCore + MODULE_UNI_FILE = SecCore.uni + FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 + MODULE_TYPE = SEC + VERSION_STRING = 1.0 + + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + SecMain.c + SecMain.h + FindPeiCore.c + SecBist.c + +[Sources.IA32] + Ia32/ResetVec.nasmb + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + BaseLib + PlatformSecLib + PcdLib + DebugAgentLib + UefiCpuLib + PeCoffGetEntryPointLib + PeCoffExtraActionLib + CpuExceptionHandlerLib + ReportStatusCodeLib + PeiServicesLib + PeiServicesTablePointerLib + HobLib + +[Ppis] + ## SOMETIMES_CONSUMES + ## PRODUCES + gEfiSecPlatformInformationPpiGuid + ## SOMETIMES_CONSUMES + ## SOMETIMES_PRODUCES + gEfiSecPlatformInformation2PpiGuid + gEfiTemporaryRamDonePpiGuid ## PRODUCES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## CONSUMES + +[UserExtensions.TianoCore."ExtraFiles"] + SecCoreExtra.uni diff --git a/Core/UefiCpuPkg/SecCore/SecCore.uni b/Core/UefiCpuPkg/SecCore/SecCore.uni new file mode 100644 index 0000000000..bd43c8b753 --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecCore.uni @@ -0,0 +1,24 @@ +// /** @file +// SecCore module that implements the SEC phase. +// +// This is the first module taking control of the platform upon power-on/reset. +// It implements the first phase of the security phase. The entry point function is +// _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to +// protected mode, setup flat memory model, enable temporary memory and +// call into SecStartup(). +// +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "SecCore module that implements the SEC phase" + +#string STR_MODULE_DESCRIPTION #language en-US "This is the first module taking control of the platform upon power-on/reset. It implements the first phase of the security phase. The entry point function is _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to protected mode, will setup flat memory model, will enable temporary memory and will call into SecStartup()." diff --git a/Core/UefiCpuPkg/SecCore/SecCoreExtra.uni b/Core/UefiCpuPkg/SecCore/SecCoreExtra.uni new file mode 100644 index 0000000000..c4bd4da20e --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecCoreExtra.uni @@ -0,0 +1,18 @@ +// /** @file +// SecCore Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"SEC Core Module" diff --git a/Core/UefiCpuPkg/SecCore/SecMain.c b/Core/UefiCpuPkg/SecCore/SecMain.c new file mode 100644 index 0000000000..077d0db49f --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecMain.c @@ -0,0 +1,310 @@ +/** @file + C functions in SEC + + Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "SecMain.h" + +EFI_PEI_TEMPORARY_RAM_DONE_PPI gSecTemporaryRamDonePpi = { + SecTemporaryRamDone +}; + +EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformationPpi = { SecPlatformInformation }; + +EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformationPpi[] = { + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gEfiTemporaryRamDonePpiGuid, + &gSecTemporaryRamDonePpi + }, + { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiSecPlatformInformationPpiGuid, + &mSecPlatformInformationPpi + } +}; + +// +// These are IDT entries pointing to 10:FFFFFFE4h. +// +UINT64 mIdtEntryTemplate = 0xffff8e000010ffe4ULL; + +/** + Caller provided function to be invoked at the end of InitializeDebugAgent(). + + Entry point to the C language phase of SEC. After the SEC assembly + code has initialized some temporary memory and set up the stack, + the control is transferred to this function. + + @param[in] Context The first input parameter of InitializeDebugAgent(). + +**/ +VOID +NORETURN +EFIAPI +SecStartupPhase2( + IN VOID *Context + ); + +/** + + Entry point to the C language phase of SEC. After the SEC assembly + code has initialized some temporary memory and set up the stack, + the control is transferred to this function. + + + @param SizeOfRam Size of the temporary memory available for use. + @param TempRamBase Base address of temporary ram + @param BootFirmwareVolume Base address of the Boot Firmware Volume. +**/ +VOID +EFIAPI +SecStartup ( + IN UINT32 SizeOfRam, + IN UINT32 TempRamBase, + IN VOID *BootFirmwareVolume + ) +{ + EFI_SEC_PEI_HAND_OFF SecCoreData; + IA32_DESCRIPTOR IdtDescriptor; + SEC_IDT_TABLE IdtTableInStack; + UINT32 Index; + UINT32 PeiStackSize; + EFI_STATUS Status; + + // + // Report Status Code to indicate entering SEC core + // + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + EFI_SOFTWARE_SEC | EFI_SW_SEC_PC_ENTRY_POINT + ); + + PeiStackSize = PcdGet32 (PcdPeiTemporaryRamStackSize); + if (PeiStackSize == 0) { + PeiStackSize = (SizeOfRam >> 1); + } + + ASSERT (PeiStackSize < SizeOfRam); + + // + // Process all libraries constructor function linked to SecCore. + // + ProcessLibraryConstructorList (); + + // + // Initialize floating point operating environment + // to be compliant with UEFI spec. + // + InitializeFloatingPointUnits (); + + // |-------------------|----> + // |IDT Table | + // |-------------------| + // |PeiService Pointer | PeiStackSize + // |-------------------| + // | | + // | Stack | + // |-------------------|----> + // | | + // | | + // | Heap | PeiTemporayRamSize + // | | + // | | + // |-------------------|----> TempRamBase + + IdtTableInStack.PeiService = 0; + for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) { + CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&mIdtEntryTemplate, sizeof (UINT64)); + } + + IdtDescriptor.Base = (UINTN) &IdtTableInStack.IdtTable; + IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1); + + AsmWriteIdtr (&IdtDescriptor); + + // + // Setup the default exception handlers + // + Status = InitializeCpuExceptionHandlers (NULL); + ASSERT_EFI_ERROR (Status); + + // + // Update the base address and length of Pei temporary memory + // + SecCoreData.DataSize = (UINT16) sizeof (EFI_SEC_PEI_HAND_OFF); + SecCoreData.BootFirmwareVolumeBase = BootFirmwareVolume; + SecCoreData.BootFirmwareVolumeSize = (UINTN)(0x100000000ULL - (UINTN) BootFirmwareVolume); + SecCoreData.TemporaryRamBase = (VOID*)(UINTN) TempRamBase; + SecCoreData.TemporaryRamSize = SizeOfRam; + SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase; + SecCoreData.PeiTemporaryRamSize = SizeOfRam - PeiStackSize; + SecCoreData.StackBase = (VOID*)(UINTN)(TempRamBase + SecCoreData.PeiTemporaryRamSize); + SecCoreData.StackSize = PeiStackSize; + + // + // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready. + // + InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, &SecCoreData, SecStartupPhase2); +} + +/** + Caller provided function to be invoked at the end of InitializeDebugAgent(). + + Entry point to the C language phase of SEC. After the SEC assembly + code has initialized some temporary memory and set up the stack, + the control is transferred to this function. + + @param[in] Context The first input parameter of InitializeDebugAgent(). + +**/ +VOID +NORETURN +EFIAPI +SecStartupPhase2( + IN VOID *Context + ) +{ + EFI_SEC_PEI_HAND_OFF *SecCoreData; + EFI_PEI_PPI_DESCRIPTOR *PpiList; + UINT32 Index; + EFI_PEI_PPI_DESCRIPTOR *AllSecPpiList; + EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint; + + SecCoreData = (EFI_SEC_PEI_HAND_OFF *) Context; + AllSecPpiList = (EFI_PEI_PPI_DESCRIPTOR *) SecCoreData->PeiTemporaryRamBase; + // + // Find Pei Core entry point. It will report SEC and Pei Core debug information if remote debug + // is enabled. + // + FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint); + if (PeiCoreEntryPoint == NULL) + { + CpuDeadLoop (); + } + + // + // Perform platform specific initialization before entering PeiCore. + // + PpiList = SecPlatformMain (SecCoreData); + if (PpiList != NULL) { + // + // Remove the terminal flag from the terminal PPI + // + CopyMem (AllSecPpiList, mPeiSecPlatformInformationPpi, sizeof (mPeiSecPlatformInformationPpi)); + Index = sizeof (mPeiSecPlatformInformationPpi) / sizeof (EFI_PEI_PPI_DESCRIPTOR) - 1; + AllSecPpiList[Index].Flags = AllSecPpiList[Index].Flags & (~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); + + // + // Append the platform additional PPI list + // + Index += 1; + while (((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) != EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)) { + CopyMem (&AllSecPpiList[Index], PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR)); + Index++; + PpiList++; + } + + // + // Add the terminal PPI + // + CopyMem (&AllSecPpiList[Index ++], PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR)); + + // + // Set PpiList to the total PPI + // + PpiList = AllSecPpiList; + + // + // Adjust PEI TEMP RAM Range. + // + ASSERT (SecCoreData->PeiTemporaryRamSize > Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); + SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN) SecCoreData->PeiTemporaryRamBase + Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); + SecCoreData->PeiTemporaryRamSize = SecCoreData->PeiTemporaryRamSize - Index * sizeof (EFI_PEI_PPI_DESCRIPTOR); + } else { + // + // No addition PPI, PpiList directly point to the common PPI list. + // + PpiList = &mPeiSecPlatformInformationPpi[0]; + } + + DEBUG (( + DEBUG_INFO, + "%a() Stack Base: 0x%p, Stack Size: 0x%x\n", + __FUNCTION__, + SecCoreData->StackBase, + (UINT32) SecCoreData->StackSize + )); + + // + // Report Status Code to indicate transferring to PEI core + // + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + EFI_SOFTWARE_SEC | EFI_SW_SEC_PC_HANDOFF_TO_NEXT + ); + + // + // Transfer the control to the PEI core + // + ASSERT (PeiCoreEntryPoint != NULL); + (*PeiCoreEntryPoint) (SecCoreData, PpiList); + + // + // Should not come here. + // + UNREACHABLE (); +} + +/** + TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked + by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. + + @retval EFI_SUCCESS Use of Temporary RAM was disabled. + @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamDone ( + VOID + ) +{ + BOOLEAN State; + + // + // Republish Sec Platform Information(2) PPI + // + RepublishSecPlatformInformationPpi (); + + // + // Migrate DebugAgentContext. + // + InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL); + + // + // Disable interrupts and save current interrupt state + // + State = SaveAndDisableInterrupts(); + + // + // Disable Temporary RAM after Stack and Heap have been migrated at this point. + // + SecPlatformDisableTemporaryMemory (); + + // + // Restore original interrupt state + // + SetInterruptState (State); + + return EFI_SUCCESS; +} diff --git a/Core/UefiCpuPkg/SecCore/SecMain.h b/Core/UefiCpuPkg/SecCore/SecMain.h new file mode 100644 index 0000000000..6e31a953f7 --- /dev/null +++ b/Core/UefiCpuPkg/SecCore/SecMain.h @@ -0,0 +1,160 @@ +/** @file + Master header file for SecCore. + + Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _SEC_CORE_H_ +#define _SEC_CORE_H_ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SEC_IDT_ENTRY_COUNT 34 + +typedef struct _SEC_IDT_TABLE { + // + // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base + // address should be 8-byte alignment. + // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store + // EFI_PEI_SERVICES** + // + UINT64 PeiService; + UINT64 IdtTable[SEC_IDT_ENTRY_COUNT]; +} SEC_IDT_TABLE; + +/** + TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked + by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. + + @retval EFI_SUCCESS Use of Temporary RAM was disabled. + @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamDone ( + VOID + ); + +/** + Entry point to the C language phase of SEC. After the SEC assembly + code has initialized some temporary memory and set up the stack, + the control is transferred to this function. + + @param SizeOfRam Size of the temporary memory available for use. + @param TempRamBase Base address of temporary ram + @param BootFirmwareVolume Base address of the Boot Firmware Volume. +**/ +VOID +EFIAPI +SecStartup ( + IN UINT32 SizeOfRam, + IN UINT32 TempRamBase, + IN VOID *BootFirmwareVolume + ); + +/** + Find and return Pei Core entry point. + + It also find SEC and PEI Core file debug information. It will report them if + remote debug is enabled. + + @param BootFirmwareVolumePtr Point to the boot firmware volume. + @param PeiCoreEntryPoint Point to the PEI core entry point. + +**/ +VOID +EFIAPI +FindAndReportEntryPoints ( + IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, + OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint + ); + +/** + Auto-generated function that calls the library constructors for all of the module's + dependent libraries. This function must be called by the SEC Core once a stack has + been established. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + VOID + ); + +/** + Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI. + + @param PeiServices Pointer to the PEI Services Table. + @param StructureSize Pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformationBist ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ); + +/** + Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. + + @param PeiServices The pointer to the PEI Services Table. + @param StructureSize The pointer to the variable describing size of the input buffer. + @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to + hold the record is returned in StructureSize. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformation2Bist ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 + ); + +/** + Republish SecPlatformInformationPpi/SecPlatformInformation2Ppi. + +**/ +VOID +RepublishSecPlatformInformationPpi ( + VOID + ); + +#endif diff --git a/Core/UefiCpuPkg/UefiCpuPkg.dec b/Core/UefiCpuPkg/UefiCpuPkg.dec new file mode 100644 index 0000000000..6f30ad032d --- /dev/null +++ b/Core/UefiCpuPkg/UefiCpuPkg.dec @@ -0,0 +1,289 @@ +## @file UefiCpuPkg.dec +# This Package provides UEFI compatible CPU modules and libraries. +# +# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials are licensed and made available under +# the terms and conditions of the BSD License which accompanies this distribution. +# The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + DEC_SPECIFICATION = 0x00010005 + PACKAGE_NAME = UefiCpuPkg + PACKAGE_UNI_FILE = UefiCpuPkg.uni + PACKAGE_GUID = 2171df9b-0d39-45aa-ac37-2de190010d23 + PACKAGE_VERSION = 0.3 + +[Includes] + Include + +[LibraryClasses] + ## @libraryclass Defines some routines that are generic for IA32 family CPU + ## to be UEFI specification compliant. + ## + UefiCpuLib|Include/Library/UefiCpuLib.h + + ## @libraryclass Defines some routines that are used to register/manage/program + ## CPU features. + ## + RegisterCpuFeaturesLib|Include/Library/RegisterCpuFeaturesLib.h + +[LibraryClasses.IA32, LibraryClasses.X64] + ## @libraryclass Provides functions to manage MTRR settings on IA32 and X64 CPUs. + ## + MtrrLib|Include/Library/MtrrLib.h + + ## @libraryclass Provides functions to manage the Local APIC on IA32 and X64 CPUs. + ## + LocalApicLib|Include/Library/LocalApicLib.h + + ## @libraryclass Provides platform specific initialization functions in the SEC phase. + ## + PlatformSecLib|Include/Library/PlatformSecLib.h + + ## @libraryclass Public include file for the SMM CPU Platform Hook Library. + ## + SmmCpuPlatformHookLib|Include/Library/SmmCpuPlatformHookLib.h + + ## @libraryclass Provides the CPU specific programming for PiSmmCpuDxeSmm module. + ## + SmmCpuFeaturesLib|Include/Library/SmmCpuFeaturesLib.h + + ## @libraryclass Provides functions to support MP services on CpuMpPei and CpuDxe module. + ## + MpInitLib|Include/Library/MpInitLib.h + + ## @libraryclass Provides services to access Microcode region on flash device. + # + MicrocodeFlashAccessLib|Include/Library/MicrocodeFlashAccessLib.h + +[Guids] + gUefiCpuPkgTokenSpaceGuid = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} + gMsegSmramGuid = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} + + ## Include/Guid/MicrocodeFmp.h + gMicrocodeFmpImageTypeIdGuid = { 0x96d4fdcd, 0x1502, 0x424d, { 0x9d, 0x4c, 0x9b, 0x12, 0xd2, 0xdc, 0xae, 0x5c } } + + ## Include/Guid/CpuFeaturesSetDone.h + gEdkiiCpuFeaturesSetDoneGuid = { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 }} + + ## Include/Guid/CpuFeaturesInitDone.h + gEdkiiCpuFeaturesInitDoneGuid = { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 }} + +[Protocols] + ## Include/Protocol/SmmCpuService.h + gEfiSmmCpuServiceProtocolGuid = { 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 }} + + ## Include/Protocol/SmMonitorInit.h + gEfiSmMonitorInitProtocolGuid = { 0x228f344d, 0xb3de, 0x43bb, { 0xa4, 0xd7, 0xea, 0x20, 0xb, 0x1b, 0x14, 0x82 }} + +# +# [Error.gUefiCpuPkgTokenSpaceGuid] +# 0x80000001 | Invalid value provided. +# + +[PcdsFeatureFlag] + ## Indicates if SMM Profile will be enabled. + # If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged. + # This PCD is only for validation purpose. It should be set to false in production.

+ # TRUE - SMM Profile will be enabled.
+ # FALSE - SMM Profile will be disabled.
+ # @Prompt Enable SMM Profile. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileEnable|FALSE|BOOLEAN|0x32132109 + + ## Indicates if the SMM profile log buffer is a ring buffer. + # If disabled, no additional log can be done when the buffer is full.

+ # TRUE - the SMM profile log buffer is a ring buffer.
+ # FALSE - the SMM profile log buffer is a normal buffer.
+ # @Prompt The SMM profile log buffer is a ring buffer. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer|FALSE|BOOLEAN|0x3213210a + + ## Indicates if SMM Startup AP in a blocking fashion. + # TRUE - SMM Startup AP in a blocking fashion.
+ # FALSE - SMM Startup AP in a non-blocking fashion.
+ # @Prompt SMM Startup AP in a blocking fashion. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp|FALSE|BOOLEAN|0x32132108 + + ## Indicates if SMM Stack Guard will be enabled. + # If enabled, stack overflow in SMM can be caught, preventing chaotic consequences.

+ # TRUE - SMM Stack Guard will be enabled.
+ # FALSE - SMM Stack Guard will be disabled.
+ # @Prompt Enable SMM Stack Guard. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard|TRUE|BOOLEAN|0x1000001C + + ## Indicates if BSP election in SMM will be enabled. + # If enabled, a BSP will be dynamically elected among all processors in each SMI. + # Otherwise, processor 0 is always as BSP in each SMI.

+ # TRUE - BSP election in SMM will be enabled.
+ # FALSE - BSP election in SMM will be disabled.
+ # @Prompt Enable BSP election in SMM. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|TRUE|BOOLEAN|0x32132106 + + ## Indicates if CPU SMM hot-plug will be enabled.

+ # TRUE - SMM CPU hot-plug will be enabled.
+ # FALSE - SMM CPU hot-plug will be disabled.
+ # @Prompt SMM CPU hot-plug. + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport|FALSE|BOOLEAN|0x3213210C + + ## Indicates if SMM Debug will be enabled. + # If enabled, hardware breakpoints in SMRAM can be set outside of SMM mode and take effect in SMM.

+ # TRUE - SMM Debug will be enabled.
+ # FALSE - SMM Debug will be disabled.
+ # @Prompt Enable SMM Debug. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug|FALSE|BOOLEAN|0x1000001B + + ## Indicates if lock SMM Feature Control MSR.

+ # TRUE - SMM Feature Control MSR will be locked.
+ # FALSE - SMM Feature Control MSR will not be locked.
+ # @Prompt Lock SMM Feature Control MSR. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock|TRUE|BOOLEAN|0x3213210B + +[PcdsFixedAtBuild, PcdsPatchableInModule] + ## This value is the CPU Local APIC base address, which aligns the address on a 4-KByte boundary. + # @Prompt Configure base address of CPU Local APIC + # @Expression 0x80000001 | (gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress & 0xfff) == 0 + gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress|0xfee00000|UINT32|0x00000001 + + ## Specifies delay value in microseconds after sending out an INIT IPI. + # @Prompt Configure delay value after send an INIT IPI + gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds|10000|UINT32|0x30000002 + + ## This value specifies the Application Processor (AP) stack size, used for Mp Service, which must + ## aligns the address on a 4-KByte boundary. + # @Prompt Configure stack size for Application Processor (AP) + gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize|0x8000|UINT32|0x00000003 + + ## Specifies stack size in the temporary RAM. 0 means half of TemporaryRamSize. + # @Prompt Stack size in the temporary RAM. + gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize|0|UINT32|0x10001003 + + ## Specifies buffer size in bytes to save SMM profile data. The value should be a multiple of 4KB. + # @Prompt SMM profile data buffer size. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize|0x200000|UINT32|0x32132107 + + ## Specifies stack size in bytes for each processor in SMM. + # @Prompt Processor stack size in SMM. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x2000|UINT32|0x32132105 + + ## Indicates if SMM Code Access Check is enabled. + # If enabled, the SMM handler cannot execute the code outside SMM regions. + # This PCD is suggested to TRUE in production image.

+ # TRUE - SMM Code Access Check will be enabled.
+ # FALSE - SMM Code Access Check will be disabled.
+ # @Prompt SMM Code Access Check. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable|TRUE|BOOLEAN|0x60000013 + + ## Specifies the number of variable MTRRs reserved for OS use. The default number of + # MTRRs reserved for OS use is 2. + # @Prompt Number of reserved variable MTRRs. + gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0x2|UINT32|0x00000015 + + ## Specifies buffer size in bytes for STM exception stack. The value should be a multiple of 4KB. + # @Prompt STM exception stack size. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStmExceptionStackSize|0x1000|UINT32|0x32132111 + + ## Specifies buffer size in bytes of MSEG. The value should be a multiple of 4KB. + # @Prompt MSEG size. + gUefiCpuPkgTokenSpaceGuid.PcdCpuMsegSize|0x200000|UINT32|0x32132112 + + ## Specifies the supported CPU features bit in array. + # @Prompt Supported CPU features. + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport|{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}|VOID*|0x00000016 + + ## Specifies if CPU features will be initialized after SMM relocation. + # @Prompt If CPU features will be initialized after SMM relocation. + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation|FALSE|BOOLEAN|0x0000001C + + ## Specifies if CPU features will be initialized during S3 resume. + # @Prompt If CPU features will be initialized during S3 resume. + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|FALSE|BOOLEAN|0x0000001D + +[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] + ## Specifies max supported number of Logical Processors. + # @Prompt Configure max supported number of Logical Processors + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64|UINT32|0x00000002 + ## Specifies timeout value in microseconds for the BSP to detect all APs for the first time. + # @Prompt Timeout for the BSP to detect all APs for the first time. + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000|UINT32|0x00000004 + ## Specifies the base address of the first microcode Patch in the microcode Region. + # @Prompt Microcode Region base address. + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress|0x0|UINT64|0x00000005 + ## Specifies the size of the microcode Region. + # @Prompt Microcode Region size. + gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize|0x0|UINT64|0x00000006 + ## Specifies the AP wait loop state during POST phase. + # The value is defined as below.

+ # 1: Place AP in the Hlt-Loop state.
+ # 2: Place AP in the Mwait-Loop state.
+ # 3: Place AP in the Run-Loop state.
+ # @Prompt The AP wait loop state. + # @ValidRange 0x80000001 | 1 - 3 + gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode|1|UINT8|0x60008006 + ## Specifies the AP target C-state for Mwait during POST phase. + # The default value 0 means C1 state. + # The value is defined as below.

+ # @Prompt The specified AP target C-state for Mwait. + gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate|0|UINT8|0x00000007 + + ## Indicates if SMM uses static page table. + # If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.

+ # This flag only impacts X64 build, because SMM alway builds static page table for IA32. + # TRUE - SMM uses static page table for all memory.
+ # FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.
+ # @Prompt Use static page table for all memory in SMM. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStaticPageTable|TRUE|BOOLEAN|0x3213210D + + ## Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM. + # @Prompt AP synchronization timeout value in SMM. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000000|UINT64|0x32132104 + + ## Indicates the CPU synchronization method used when processing an SMI. + # 0x00 - Traditional CPU synchronization method.
+ # 0x01 - Relaxed CPU synchronization method.
+ # @Prompt SMM CPU Synchronization Method. + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014 + + ## Specifies user's desired settings for enabling/disabling processor features. + # @Prompt User settings for enabling/disabling processor features. + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000017 + + ## Specifies the On-demand clock modulation duty cycle when ACPI feature is enabled. + # @Prompt The encoded values for target duty cycle modulation. + # @ValidRange 0x80000001 | 0 - 15 + gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle|0x0|UINT8|0x0000001A + + ## Indicates if the current boot is a power-on reset.

+ # TRUE - Current boot is a power-on reset.
+ # FALSE - Current boot is not a power-on reset.
+ # @Prompt Current boot is a power-on reset. + gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset|FALSE|BOOLEAN|0x0000001B + +[PcdsDynamic, PcdsDynamicEx] + ## Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA. + # @Prompt The pointer to a CPU S3 data buffer. + # @ValidList 0x80000001 | 0 + gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress|0x0|UINT64|0x60000010 + + ## Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported. + # @Prompt The pointer to CPU Hot Plug Data. + # @ValidList 0x80000001 | 0 + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress|0x0|UINT64|0x60000011 + + ## Indicates processor feature capabilities, each bit corresponding to a specific feature. + # @Prompt Processor feature capabilities. + # @ValidList 0x80000001 | 0 + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000018 + + ## Specifies actual settings for processor features, each bit corresponding to a specific feature. + # @Prompt Actual processor feature settings. + # @ValidList 0x80000001 | 0 + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000019 + +[UserExtensions.TianoCore."ExtraFiles"] + UefiCpuPkgExtra.uni diff --git a/Core/UefiCpuPkg/UefiCpuPkg.dsc b/Core/UefiCpuPkg/UefiCpuPkg.dsc new file mode 100644 index 0000000000..1336b0cfc0 --- /dev/null +++ b/Core/UefiCpuPkg/UefiCpuPkg.dsc @@ -0,0 +1,158 @@ +## @file +# UefiCpuPkg Package +# +# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + PLATFORM_NAME = UefiCpu + PLATFORM_GUID = a1b7be22-78b3-4260-9569-8649e8c17d49 + PLATFORM_VERSION = 0.3 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/UefiCpu + SUPPORTED_ARCHITECTURES = IA32|IPF|X64 + BUILD_TARGETS = DEBUG|RELEASE|NOOPT + SKUID_IDENTIFIER = DEFAULT + +# +# External libraries to build package +# + +[LibraryClasses] + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf + PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf + PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf + DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf + LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf + SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf + CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf + PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf + PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf + SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf + SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf + MicrocodeFlashAccessLib|UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf + TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf + +[LibraryClasses.common.SEC] + PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf + +[LibraryClasses.common.PEIM] + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf + LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf + MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf + RegisterCpuFeaturesLib|UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf + +[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM] + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf + +[LibraryClasses.IPF.PEIM] + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointerLibKr7.inf + +[LibraryClasses.common.DXE_DRIVER] + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf + MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf + RegisterCpuFeaturesLib|UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf + +[LibraryClasses.common.DXE_SMM_DRIVER] + SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf + MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf + +[LibraryClasses.common.UEFI_APPLICATION] + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + +# +# Drivers/Libraries within this package +# + +[Components] + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + UefiCpuPkg/CpuIoPei/CpuIoPei.inf + UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf + UefiCpuPkg/Application/Cpuid/Cpuid.inf + +[Components.IA32, Components.X64] + UefiCpuPkg/CpuDxe/CpuDxe.inf + UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf { + + NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf + } + UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf { + + NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf + } + UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf + UefiCpuPkg/CpuMpPei/CpuMpPei.inf + UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf + UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf + UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf + UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf + UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf + UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf + UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf + UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf + UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf + UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf + UefiCpuPkg/Library/MtrrLib/MtrrLib.inf + UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf + UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf + UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf + UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf + UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf + UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf + UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf + UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf + UefiCpuPkg/SecCore/SecCore.inf + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { + + FILE_GUID = D1D74FE9-7A4E-41D3-A0B3-67F13AD34D94 + + SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf + } + UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf + UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf + +[BuildOptions] + *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/Core/UefiCpuPkg/UefiCpuPkg.uni b/Core/UefiCpuPkg/UefiCpuPkg.uni new file mode 100644 index 0000000000..cd0ecab611 --- /dev/null +++ b/Core/UefiCpuPkg/UefiCpuPkg.uni @@ -0,0 +1,196 @@ +// /** @file +// This Package provides UEFI compatible CPU modules and libraries. +// +// This Package provides UEFI compatible CPU modules and libraries. +// +// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are licensed and made available under +// the terms and conditions of the BSD License which accompanies this distribution. +// The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PACKAGE_ABSTRACT #language en-US "Provides UEFI compatible CPU modules and libraries" + +#string STR_PACKAGE_DESCRIPTION #language en-US "This Package provides UEFI compatible CPU modules and libraries." + + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuLocalApicBaseAddress_PROMPT #language en-US "Configure base address of CPU Local APIC" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuLocalApicBaseAddress_HELP #language en-US "This value is the CPU Local APIC base address, which aligns the address on a 4-KByte boundary." + +#string STR_gUefiCpuPkgTokenSpaceGuid_ERR_80000001 #language en-US "Invalid value provided." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuInitIpiDelayInMicroSeconds_PROMPT #language en-US "Configure delay value after send an INIT IPI" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuInitIpiDelayInMicroSeconds_HELP #language en-US "Specifies delay value in microseconds after sending out an INIT IPI." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMaxLogicalProcessorNumber_PROMPT #language en-US "Configure max supported number of Logical Processors" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMaxLogicalProcessorNumber_HELP #language en-US "Specifies max supported number of Logical Processors." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStackSize_PROMPT #language en-US "Configure stack size for Application Processor (AP)" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStackSize_HELP #language en-US "This value specifies the Application Processor (AP) stack size, used for Mp Service, which must\n" + "aligns the address on a 4-KByte boundary." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_PROMPT #language en-US "Timeout for the BSP to detect all APs for the first time." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_HELP #language en-US "Specifies timeout value in microseconds for the BSP to detect all APs for the first time." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_PROMPT #language en-US "Microcode Region base address." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_HELP #language en-US "Specifies the base address of the first microcode Patch in the microcode Region." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchRegionSize_PROMPT #language en-US "Microcode Region size." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchRegionSize_HELP #language en-US "Specifies the size of the microcode Region." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_PROMPT #language en-US "Enable SMM Profile" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_HELP #language en-US "Indicates if SMM Profile will be enabled. If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged. This PCD is only for validation purpose. It should be set to false in production.

\n" + "TRUE - SMM Profile will be enabled.
\n" + "FALSE - SMM Profile will be disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileRingBuffer_PROMPT #language en-US "The SMM profile log buffer is a ring buffer" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileRingBuffer_HELP #language en-US "Indicates if the SMM profile log buffer is a ring buffer. If disabled, no additional log can be done when the buffer is full.

\n" + "TRUE - the SMM profile log buffer is a ring buffer.
\n" + "FALSE - the SMM profile log buffer is a normal buffer.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmBlockStartupThisAp_PROMPT #language en-US "SMM Startup AP in a blocking fashion" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmBlockStartupThisAp_HELP #language en-US "Indicates if SMM Startup AP in a blocking fashion.\n" + "TRUE - SMM Startup AP in a blocking fashion.
\n" + "FALSE - SMM Startup AP in a non-blocking fashion.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackGuard_PROMPT #language en-US "Enable SMM Stack Guard" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackGuard_HELP #language en-US "Indicates if SMM Stack Guard will be enabled. If enabled, stack overflow in SMM can be caught, which eases debugging.

\n" + "TRUE - SMM Stack Guard will be enabled.
\n" + "FALSE - SMM Stack Guard will be disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmEnableBspElection_PROMPT #language en-US "Enable BSP election in SMM" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmEnableBspElection_HELP #language en-US "Indicates if BSP election in SMM will be enabled. If enabled, a BSP will be dynamically elected among all processors in each SMI. Otherwise, processor 0 is always as BSP in each SMI.

\n" + "TRUE - BSP election in SMM will be enabled.
\n" + "FALSE - BSP election in SMM will be disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugSupport_PROMPT #language en-US "SMM CPU hot-plug" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugSupport_HELP #language en-US "Enable CPU SMM hot-plug?

\n" + "TRUE - enabled.
\n" + "FALSE - disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmDebug_PROMPT #language en-US "Enable SMM Debug" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmDebug_HELP #language en-US "Indicates if SMM Debug will be enabled. If enabled, hardware breakpoints in SMRAM can be set outside of SMM mode and take effect in SMM.

\n" + "TRUE - SMM Debug will be enabled.
\n" + "FALSE - SMM Debug will be disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmFeatureControlMsrLock_PROMPT #language en-US "Lock SMM Feature Control MSR" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmFeatureControlMsrLock_HELP #language en-US "Lock SMM Feature Control MSR?

\n" + "TRUE - locked.
\n" + "FALSE - unlocked.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdPeiTemporaryRamStackSize_PROMPT #language en-US "Stack size in the temporary RAM" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdPeiTemporaryRamStackSize_HELP #language en-US "Specifies stack size in the temporary RAM. 0 means half of TemporaryRamSize." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileSize_PROMPT #language en-US "SMM profile data buffer size" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileSize_HELP #language en-US "Specifies buffer size in bytes to save SMM profile data. The value should be a multiple of 4KB." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_PROMPT #language en-US "Processor stack size in SMM" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_HELP #language en-US "Specifies stack size in bytes for each processor in SMM." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_PROMPT #language en-US "AP synchronization timeout value in SMM" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_HELP #language en-US "Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmCodeAccessCheckEnable_PROMPT #language en-US "SMM Code Access Check" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmCodeAccessCheckEnable_HELP #language en-US "Enable SMM Code Access Check? If enabled, the SMM handler cannot execute the code outside SMM regions. This PCD is suggested to TRUE in production image.

\n" + "TRUE - SMM Code Access Check will be enabled.
\n" + "FALSE - SMM Code Access Check will be disabled.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmSyncMode_PROMPT #language en-US "SMM CPU Synchronization Method" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmSyncMode_HELP #language en-US "Indicates the CPU synchronization method used when processing an SMI.

\n" + "0x00 - Traditional CPU synchronization method.
\n" + "0x01 - Relaxed CPU synchronization method.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuS3DataAddress_PROMPT #language en-US "The pointer to a CPU S3 data buffer" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuS3DataAddress_HELP #language en-US "Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_PROMPT #language en-US "The pointer to CPU Hot Plug Data" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_HELP #language en-US "Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT #language en-US "Number of reserved variable MTRRs" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP #language en-US "Specifies the number of variable MTRRs reserved for OS use." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_PROMPT #language en-US "The AP wait loop state" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_HELP #language en-US "Specifies the AP wait loop state during POST phase." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApTargetCstate_PROMPT #language en-US "The specified AP target C-state for Mwait" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApTargetCstate_HELP #language en-US "Specifies the AP target C-state for Mwait during POST phase." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_PROMPT #language en-US "Use static page table for all memory in SMM." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_HELP #language en-US "Indicates if SMM uses static page table.\n" + "If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.

\n" + "This flag only impacts X64 build, because SMM alway builds static page table for IA32.\n" + "TRUE - SMM uses static page table for all memory.
\n" + "FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.
" + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStmExceptionStackSize_PROMPT #language en-US "STM exception stack size." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStmExceptionStackSize_HELP #language en-US "Specifies buffer size in bytes for STM exception stack. The value should be a multiple of 4KB." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMsegSize_PROMPT #language en-US "MSEG size." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMsegSize_HELP #language en-US "Specifies buffer size in bytes of MSEG. The value should be a multiple of 4KB." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSupport_PROMPT #language en-US "Supported CPU features." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSupport_HELP #language en-US "Specifies the supported CPU features bit in array." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitAfterSmmRelocation_PROMPT #language en-US "If CPU features will be initialized after SMM relocation." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitAfterSmmRelocation_HELP #language en-US "Specifies if CPU features will be initialized after SMM relocation." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitOnS3Resume_PROMPT #language en-US "If CPU features will be initialized during S3 resume." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitOnS3Resume_HELP #language en-US "Specifies if CPU features will be initialized during S3 resume." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesUserConfiguration_PROMPT #language en-US "User settings for enabling/disabling processor features." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesUserConfiguration_HELP #language en-US "Specifies user's desired settings for enabling/disabling processor features." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuClockModulationDutyCycle_PROMPT #language en-US "The encoded values for target duty cycle modulation." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuClockModulationDutyCycle_HELP #language en-US "Specifies the On-demand clock modulation duty cycle when ACPI feature is enabled." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdIsPowerOnReset_PROMPT #language en-US "Current boot is a power-on reset." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdIsPowerOnReset_HELP #language en-US "Indicates if the current boot is a power-on reset." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesCapability_PROMPT #language en-US "Processor feature capabilities." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesCapability_HELP #language en-US "Indicates processor feature capabilities, each bit corresponding to a specific feature." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSetting_PROMPT #language en-US "Actual processor feature settings." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSetting_HELP #language en-US "Specifies actual settings for processor features, each bit corresponding to a specific feature." diff --git a/Core/UefiCpuPkg/UefiCpuPkgExtra.uni b/Core/UefiCpuPkg/UefiCpuPkgExtra.uni new file mode 100644 index 0000000000..858761af24 --- /dev/null +++ b/Core/UefiCpuPkg/UefiCpuPkgExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// UefiCpu Package Localized Strings and Content. +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are licensed and made available under +// the terms and conditions of the BSD License which accompanies this distribution. +// The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_PACKAGE_NAME +#language en-US +"UefiCpu package" + + diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S new file mode 100644 index 0000000000..ede19f21c3 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S @@ -0,0 +1,38 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2012, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* AsmFuncs.S +#* +#* Abstract: +#* +#* Assembly function to set segment selectors. +# +#------------------------------------------------------------------------------ + +.text + +#------------------------------------------------------------------------------ +# +# VOID +# EFIAPI +# AsmSetDataSelectors ( +# IN UINT16 SelectorValue +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(AsmSetDataSelectors) +ASM_PFX(AsmSetDataSelectors): + movl 4(%esp), %eax + movw %ax, %ss + movw %ax, %ds + movw %ax, %es + movw %ax, %fs + movw %ax, %gs + ret diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm new file mode 100644 index 0000000000..79496c48d7 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2012, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; AsmFuncs.Asm +; +; Abstract: +; +; Assembly function to set segment selectors. +; +; Notes: +; +;------------------------------------------------------------------------------ + +.686 +.model flat,C + +.code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmSetDataSelectors ( +; IN UINT16 SelectorValue +; ); +;------------------------------------------------------------------------------ +AsmSetDataSelectors PROC near public + mov eax, [esp + 4] + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + ret +AsmSetDataSelectors ENDP + +END diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm new file mode 100644 index 0000000000..fa5dda1466 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm @@ -0,0 +1,41 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; AsmFuncs.Asm +; +; Abstract: +; +; Assembly function to set segment selectors. +; +; Notes: +; +;------------------------------------------------------------------------------ + +SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmSetDataSelectors ( +; IN UINT16 SelectorValue +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(AsmSetDataSelectors) +ASM_PFX(AsmSetDataSelectors): + mov eax, [esp + 4] +o16 mov ds, ax +o16 mov es, ax +o16 mov fs, ax +o16 mov gs, ax +o16 mov ss, ax + ret + diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c new file mode 100644 index 0000000000..e53ed21bdc --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -0,0 +1,1176 @@ +/** @file + This module produces the EFI_PEI_S3_RESUME2_PPI. + This module works with StandAloneBootScriptExecutor to S3 resume to OS. + This module will execute the boot script saved during last boot and after that, + control is passed to OS waking up handler. + + Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions + of the BSD License which accompanies this distribution. The + full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + This macro aligns the address of a variable with auto storage + duration down to CPU_STACK_ALIGNMENT. + + Since the stack grows downward, the result preserves more of the + stack than the original address (or the same amount), not less. +**/ +#define STACK_ALIGN_DOWN(Ptr) \ + ((UINTN)(Ptr) & ~(UINTN)(CPU_STACK_ALIGNMENT - 1)) + +#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull + +#pragma pack(1) +typedef union { + struct { + UINT32 LimitLow : 16; + UINT32 BaseLow : 16; + UINT32 BaseMid : 8; + UINT32 Type : 4; + UINT32 System : 1; + UINT32 Dpl : 2; + UINT32 Present : 1; + UINT32 LimitHigh : 4; + UINT32 Software : 1; + UINT32 Reserved : 1; + UINT32 DefaultSize : 1; + UINT32 Granularity : 1; + UINT32 BaseHigh : 8; + } Bits; + UINT64 Uint64; +} IA32_GDT; + +// +// Page-Map Level-4 Offset (PML4) and +// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Reserved:1; // Reserved + UINT64 MustBeZero:2; // Must Be Zero + UINT64 Available:3; // Available for use by system software + UINT64 PageTableBaseAddress:40; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // No Execute bit + } Bits; + UINT64 Uint64; +} PAGE_MAP_AND_DIRECTORY_POINTER; + +// +// Page Table Entry 2MB +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 MustBe1:1; // Must be 1 + UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available:3; // Available for use by system software + UINT64 PAT:1; // + UINT64 MustBeZero:8; // Must be zero; + UINT64 PageTableBaseAddress:31; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution + } Bits; + UINT64 Uint64; +} PAGE_TABLE_ENTRY; + +// +// Page Table Entry 1GB +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 MustBe1:1; // Must be 1 + UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available:3; // Available for use by system software + UINT64 PAT:1; // + UINT64 MustBeZero:17; // Must be zero; + UINT64 PageTableBaseAddress:22; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution + } Bits; + UINT64 Uint64; +} PAGE_TABLE_1G_ENTRY; + +#pragma pack() + +// +// Function prototypes +// +/** + a ASM function to transfer control to OS. + + @param S3WakingVector The S3 waking up vector saved in ACPI Facs table + @param AcpiLowMemoryBase a buffer under 1M which could be used during the transfer +**/ +typedef +VOID +(EFIAPI *ASM_TRANSFER_CONTROL) ( + IN UINT32 S3WakingVector, + IN UINT32 AcpiLowMemoryBase + ); + +/** + Restores the platform to its preboot configuration for an S3 resume and + jumps to the OS waking vector. + + This function will restore the platform to its pre-boot configuration that was + pre-stored in the boot script table and transfer control to OS waking vector. + Upon invocation, this function is responsible for locating the following + information before jumping to OS waking vector: + - ACPI tables + - boot script table + - any other information that it needs + + The S3RestoreConfig() function then executes the pre-stored boot script table + and transitions the platform to the pre-boot state. The boot script is recorded + during regular boot using the EFI_S3_SAVE_STATE_PROTOCOL.Write() and + EFI_S3_SMM_SAVE_STATE_PROTOCOL.Write() functions. Finally, this function + transfers control to the OS waking vector. If the OS supports only a real-mode + waking vector, this function will switch from flat mode to real mode before + jumping to the waking vector. If all platform pre-boot configurations are + successfully restored and all other necessary information is ready, this + function will never return and instead will directly jump to the OS waking + vector. If this function returns, it indicates that the attempt to resume + from the ACPI S3 sleep state failed. + + @param[in] This Pointer to this instance of the PEI_S3_RESUME_PPI + + @retval EFI_ABORTED Execution of the S3 resume boot script table failed. + @retval EFI_NOT_FOUND Some necessary information that is used for the S3 + resume boot path could not be located. + +**/ +EFI_STATUS +EFIAPI +S3RestoreConfig2 ( + IN EFI_PEI_S3_RESUME2_PPI *This + ); + +/** + Set data segment selectors value including DS/ES/FS/GS/SS. + + @param[in] SelectorValue Segment selector value to be set. + +**/ +VOID +EFIAPI +AsmSetDataSelectors ( + IN UINT16 SelectorValue + ); + +// +// Globals +// +EFI_PEI_S3_RESUME2_PPI mS3ResumePpi = { S3RestoreConfig2 }; + +EFI_PEI_PPI_DESCRIPTOR mPpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiS3Resume2PpiGuid, + &mS3ResumePpi +}; + +EFI_PEI_PPI_DESCRIPTOR mPpiListPostScriptTable = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gPeiPostScriptTablePpiGuid, + 0 +}; + +EFI_PEI_PPI_DESCRIPTOR mPpiListEndOfPeiTable = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiEndOfPeiSignalPpiGuid, + 0 +}; + +// +// Global Descriptor Table (GDT) +// +GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = { +/* selector { Global Segment Descriptor } */ +/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* 0x08 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* 0x10 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, +/* 0x18 */ {{0xFFFF, 0, 0, 0x3, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, +/* 0x20 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +/* 0x28 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 0, 0, 1, 0}}, +/* 0x30 */ {{0xFFFF, 0, 0, 0x3, 1, 0, 1, 0xF, 0, 0, 0, 1, 0}}, +/* 0x38 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 1, 0, 1, 0}}, +/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, +}; + +#define DATA_SEGEMENT_SELECTOR 0x18 + +// +// IA32 Gdt register +// +GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = { + sizeof (mGdtEntries) - 1, + (UINTN) mGdtEntries + }; + +/** + Performance measure function to get S3 detailed performance data. + + This function will getS3 detailed performance data and saved in pre-reserved ACPI memory. +**/ +VOID +WriteToOsS3PerformanceData ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase; + PERF_HEADER *PerfHeader; + PERF_DATA *PerfData; + UINT64 Ticker; + UINTN Index; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINTN VarSize; + UINTN LogEntryKey; + CONST VOID *Handle; + CONST CHAR8 *Token; + CONST CHAR8 *Module; + UINT64 StartTicker; + UINT64 EndTicker; + UINT64 StartValue; + UINT64 EndValue; + BOOLEAN CountUp; + UINT64 Freq; + + // + // Retrieve time stamp count as early as possible + // + Ticker = GetPerformanceCounter (); + + Freq = GetPerformanceCounterProperties (&StartValue, &EndValue); + + Freq = DivU64x32 (Freq, 1000); + + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + if (EFI_ERROR (Status)) { + return; + } + + VarSize = sizeof (EFI_PHYSICAL_ADDRESS); + Status = VariableServices->GetVariable ( + VariableServices, + L"PerfDataMemAddr", + &gPerformanceProtocolGuid, + NULL, + &VarSize, + &mAcpiLowMemoryBase + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "Fail to retrieve variable to log S3 performance data \n")); + return; + } + + PerfHeader = (PERF_HEADER *) (UINTN) mAcpiLowMemoryBase; + + if (PerfHeader->Signiture != PERFORMANCE_SIGNATURE) { + DEBUG ((EFI_D_ERROR, "Performance data in ACPI memory get corrupted! \n")); + return; + } + + // + // Record total S3 resume time. + // + if (EndValue >= StartValue) { + PerfHeader->S3Resume = Ticker - StartValue; + CountUp = TRUE; + } else { + PerfHeader->S3Resume = StartValue - Ticker; + CountUp = FALSE; + } + + // + // Get S3 detailed performance data + // + Index = 0; + LogEntryKey = 0; + while ((LogEntryKey = GetPerformanceMeasurement ( + LogEntryKey, + &Handle, + &Token, + &Module, + &StartTicker, + &EndTicker)) != 0) { + if (EndTicker != 0) { + PerfData = &PerfHeader->S3Entry[Index]; + + // + // Use File Handle to specify the different performance log for PEIM. + // File Handle is the base address of PEIM FFS file. + // + if ((AsciiStrnCmp (Token, "PEIM", PEI_PERFORMANCE_STRING_SIZE) == 0) && (Handle != NULL)) { + AsciiSPrint (PerfData->Token, PERF_TOKEN_LENGTH, "0x%11p", Handle); + } else { + AsciiStrnCpyS (PerfData->Token, PERF_TOKEN_SIZE, Token, PERF_TOKEN_LENGTH); + } + if (StartTicker == 1) { + StartTicker = StartValue; + } + if (EndTicker == 1) { + EndTicker = StartValue; + } + Ticker = CountUp? (EndTicker - StartTicker) : (StartTicker - EndTicker); + PerfData->Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq); + + // + // Only Record > 1ms performance data so that more big performance can be recorded. + // + if ((Ticker > Freq) && (++Index >= PERF_PEI_ENTRY_MAX_NUM)) { + // + // Reach the maximum number of PEI performance log entries. + // + break; + } + } + } + PerfHeader->S3EntryNum = (UINT32) Index; +} + +/** + The function will check if current waking vector is long mode. + + @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT + + @retval TRUE Current context need long mode waking vector. + @retval FALSE Current context need not long mode waking vector. +**/ +BOOLEAN +IsLongModeWakingVector ( + IN ACPI_S3_CONTEXT *AcpiS3Context + ) +{ + EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; + + Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); + if ((Facs == NULL) || + (Facs->Signature != EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) || + ((Facs->FirmwareWakingVector == 0) && (Facs->XFirmwareWakingVector == 0)) ) { + // Something wrong with FACS + return FALSE; + } + if (Facs->XFirmwareWakingVector != 0) { + if ((Facs->Version == EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && + ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0) && + ((Facs->Flags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) != 0)) { + // Both BIOS and OS wants 64bit vector + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + return TRUE; + } + } + } + return FALSE; +} + +/** + Jump to OS waking vector. + The function will install boot script done PPI, report S3 resume status code, and then jump to OS waking vector. + + @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT + @param PeiS3ResumeState a pointer to a structure of PEI_S3_RESUME_STATE +**/ +VOID +EFIAPI +S3ResumeBootOs ( + IN ACPI_S3_CONTEXT *AcpiS3Context, + IN PEI_S3_RESUME_STATE *PeiS3ResumeState + ) +{ + EFI_STATUS Status; + EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; + ASM_TRANSFER_CONTROL AsmTransferControl; + UINTN TempStackTop; + UINTN TempStack[0x10]; + + // + // Restore IDT + // + AsmWriteIdtr (&PeiS3ResumeState->Idtr); + + if (PeiS3ResumeState->ReturnStatus != EFI_SUCCESS) { + // + // Report Status code that boot script execution is failed + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MINOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_BOOT_SCRIPT_ERROR) + ); + } + + // + // NOTE: Because Debug Timer interrupt and system interrupts will be disabled + // in BootScriptExecuteDxe, the rest code in S3ResumeBootOs() cannot be halted + // by soft debugger. + // + + PERF_END (NULL, "ScriptExec", NULL, 0); + + // + // Install BootScriptDonePpi + // + Status = PeiServicesInstallPpi (&mPpiListPostScriptTable); + ASSERT_EFI_ERROR (Status); + + // + // Get ACPI Table Address + // + Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); + + if ((Facs == NULL) || + (Facs->Signature != EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) || + ((Facs->FirmwareWakingVector == 0) && (Facs->XFirmwareWakingVector == 0)) ) { + // + // Report Status code that no valid vector is found + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) + ); + CpuDeadLoop (); + return ; + } + + // + // Install EndOfPeiPpi + // + Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable); + ASSERT_EFI_ERROR (Status); + + // + // report status code on S3 resume + // + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); + + PERF_CODE ( + WriteToOsS3PerformanceData (); + ); + + AsmTransferControl = (ASM_TRANSFER_CONTROL)(UINTN)PeiS3ResumeState->AsmTransferControl; + if (Facs->XFirmwareWakingVector != 0) { + // + // Switch to native waking vector + // + TempStackTop = (UINTN)&TempStack + sizeof(TempStack); + DEBUG (( + DEBUG_INFO, + "%a() Stack Base: 0x%x, Stack Size: 0x%x\n", + __FUNCTION__, + TempStackTop, + sizeof (TempStack) + )); + if ((Facs->Version == EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && + ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0) && + ((Facs->Flags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) != 0)) { + // + // X64 long mode waking vector + // + DEBUG ((DEBUG_INFO, "Transfer to 64bit OS waking vector - %x\r\n", (UINTN)Facs->XFirmwareWakingVector)); + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + AsmEnablePaging64 ( + 0x38, + Facs->XFirmwareWakingVector, + 0, + 0, + (UINT64)(UINTN)TempStackTop + ); + } else { + // + // Report Status code that no valid waking vector is found + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) + ); + DEBUG (( EFI_D_ERROR, "Unsupported for 32bit DXE transfer to 64bit OS waking vector!\r\n")); + ASSERT (FALSE); + CpuDeadLoop (); + return ; + } + } else { + // + // IA32 protected mode waking vector (Page disabled) + // + DEBUG ((DEBUG_INFO, "Transfer to 32bit OS waking vector - %x\r\n", (UINTN)Facs->XFirmwareWakingVector)); + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT) (UINTN) Facs->XFirmwareWakingVector, + NULL, + NULL, + (VOID *)(UINTN)TempStackTop + ); + } + } else { + // + // 16bit Realmode waking vector + // + DEBUG ((DEBUG_INFO, "Transfer to 16bit OS waking vector - %x\r\n", (UINTN)Facs->FirmwareWakingVector)); + AsmTransferControl (Facs->FirmwareWakingVector, 0x0); + } + + // + // Report Status code the failure of S3Resume + // + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) + ); + + // + // Never run to here + // + CpuDeadLoop(); +} + +/** + Restore S3 page table because we do not trust ACPINvs content. + If BootScriptExector driver will not run in 64-bit mode, this function will do nothing. + + @param S3NvsPageTableAddress PageTableAddress in ACPINvs + @param Build4GPageTableOnly If BIOS just build 4G page table only +**/ +VOID +RestoreS3PageTables ( + IN UINTN S3NvsPageTableAddress, + IN BOOLEAN Build4GPageTableOnly + ) +{ + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + UINT32 RegEax; + UINT32 RegEdx; + UINT8 PhysicalAddressBits; + EFI_PHYSICAL_ADDRESS PageAddress; + UINTN IndexOfPml4Entries; + UINTN IndexOfPdpEntries; + UINTN IndexOfPageDirectoryEntries; + UINT32 NumberOfPml4EntriesNeeded; + UINT32 NumberOfPdpEntriesNeeded; + PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry; + PAGE_MAP_AND_DIRECTORY_POINTER *PageMap; + PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry; + PAGE_TABLE_ENTRY *PageDirectoryEntry; + VOID *Hob; + BOOLEAN Page1GSupport; + PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry; + UINT64 AddressEncMask; + + // + // Make sure AddressEncMask is contained to smallest supported address field + // + AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; + + // + // NOTE: We have to ASSUME the page table generation format, because we do not know whole page table information. + // The whole page table is too large to be saved in SMRAM. + // + // The assumption is : whole page table is allocated in CONTINUOUS memory and CR3 points to TOP page. + // + DEBUG ((DEBUG_INFO, "S3NvsPageTableAddress - %x (%x)\n", (UINTN)S3NvsPageTableAddress, (UINTN)Build4GPageTableOnly)); + + // + // By architecture only one PageMapLevel4 exists - so lets allocate storage for it. + // + PageMap = (PAGE_MAP_AND_DIRECTORY_POINTER *)S3NvsPageTableAddress; + S3NvsPageTableAddress += SIZE_4KB; + + Page1GSupport = FALSE; + if (PcdGetBool(PcdUse1GPageTable)) { + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000001) { + AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & BIT26) != 0) { + Page1GSupport = TRUE; + } + } + } + + // + // Get physical address bits supported. + // + Hob = GetFirstHob (EFI_HOB_TYPE_CPU); + if (Hob != NULL) { + PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; + } else { + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + PhysicalAddressBits = (UINT8) RegEax; + } else { + PhysicalAddressBits = 36; + } + } + + // + // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses. + // + ASSERT (PhysicalAddressBits <= 52); + if (PhysicalAddressBits > 48) { + PhysicalAddressBits = 48; + } + + // + // NOTE: In order to save time to create full page table, we just create 4G page table by default. + // And let PF handler in BootScript driver to create more on request. + // + if (Build4GPageTableOnly) { + PhysicalAddressBits = 32; + ZeroMem (PageMap, EFI_PAGES_TO_SIZE(2)); + } + // + // Calculate the table entries needed. + // + if (PhysicalAddressBits <= 39) { + NumberOfPml4EntriesNeeded = 1; + NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30)); + } else { + NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39)); + NumberOfPdpEntriesNeeded = 512; + } + + PageMapLevel4Entry = PageMap; + PageAddress = 0; + for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) { + // + // Each PML4 entry points to a page of Page Directory Pointer entires. + // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop. + // + PageDirectoryPointerEntry = (PAGE_MAP_AND_DIRECTORY_POINTER *)S3NvsPageTableAddress; + S3NvsPageTableAddress += SIZE_4KB; + + // + // Make a PML4 Entry + // + PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry | AddressEncMask; + PageMapLevel4Entry->Bits.ReadWrite = 1; + PageMapLevel4Entry->Bits.Present = 1; + + if (Page1GSupport) { + PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry; + + for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) { + // + // Fill in the Page Directory entries + // + PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; + PageDirectory1GEntry->Bits.ReadWrite = 1; + PageDirectory1GEntry->Bits.Present = 1; + PageDirectory1GEntry->Bits.MustBe1 = 1; + } + } else { + for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) { + // + // Each Directory Pointer entries points to a page of Page Directory entires. + // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop. + // + PageDirectoryEntry = (PAGE_TABLE_ENTRY *)S3NvsPageTableAddress; + S3NvsPageTableAddress += SIZE_4KB; + + // + // Fill in a Page Directory Pointer Entries + // + PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask; + PageDirectoryPointerEntry->Bits.ReadWrite = 1; + PageDirectoryPointerEntry->Bits.Present = 1; + + for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) { + // + // Fill in the Page Directory entries + // + PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; + PageDirectoryEntry->Bits.ReadWrite = 1; + PageDirectoryEntry->Bits.Present = 1; + PageDirectoryEntry->Bits.MustBe1 = 1; + } + } + } + } + return ; + } else { + // + // If DXE is running 32-bit mode, no need to establish page table. + // + return ; + } +} + +/** + Jump to boot script executor driver. + + The function will close and lock SMRAM and then jump to boot script execute driver to executing S3 boot script table. + + @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT + @param EfiBootScriptExecutorVariable The function entry to executing S3 boot Script table. This function is build in + boot script execute driver +**/ +VOID +EFIAPI +S3ResumeExecuteBootScript ( + IN ACPI_S3_CONTEXT *AcpiS3Context, + IN BOOT_SCRIPT_EXECUTOR_VARIABLE *EfiBootScriptExecutorVariable + ) +{ + EFI_STATUS Status; + PEI_SMM_ACCESS_PPI *SmmAccess; + UINTN Index; + VOID *GuidHob; + IA32_DESCRIPTOR *IdtDescriptor; + VOID *IdtBuffer; + PEI_S3_RESUME_STATE *PeiS3ResumeState; + BOOLEAN InterruptStatus; + + DEBUG ((DEBUG_INFO, "S3ResumeExecuteBootScript()\n")); + + // + // Attempt to use content from SMRAM first + // + GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); + if (GuidHob != NULL) { + // + // Last step for SMM - send SMI for initialization + // + + // + // Send SMI to APs + // + SendSmiIpiAllExcludingSelf (); + // + // Send SMI to BSP + // + SendSmiIpi (GetApicId ()); + + Status = PeiServicesLocatePpi ( + &gPeiSmmAccessPpiGuid, + 0, + NULL, + (VOID **) &SmmAccess + ); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Close all SMRAM regions before executing boot script\n")); + + for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) { + Status = SmmAccess->Close ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); + } + + DEBUG ((DEBUG_INFO, "Lock all SMRAM regions before executing boot script\n")); + + for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) { + Status = SmmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); + } + } + } + + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + AsmWriteCr3 ((UINTN)AcpiS3Context->S3NvsPageTableAddress); + } + + if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) { + // + // On some platform, such as ECP, a dispatch node in boot script table may execute a 32-bit PEIM which may need PeiServices + // pointer. So PeiServices need preserve in (IDTBase- sizeof (UINTN)). + // + IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile); + // + // Make sure the newly allocated IDT align with 16-bytes + // + IdtBuffer = AllocatePages (EFI_SIZE_TO_PAGES((IdtDescriptor->Limit + 1) + 16)); + if (IdtBuffer == NULL) { + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_RESUME_FAILED) + ); + ASSERT (FALSE); + } + // + // Additional 16 bytes allocated to save IA32 IDT descriptor and Pei Service Table Pointer + // IA32 IDT descriptor will be used to setup IA32 IDT table for 32-bit Framework Boot Script code + // + ZeroMem (IdtBuffer, 16); + AsmReadIdtr ((IA32_DESCRIPTOR *)IdtBuffer); + CopyMem ((VOID*)((UINT8*)IdtBuffer + 16),(VOID*)(IdtDescriptor->Base), (IdtDescriptor->Limit + 1)); + IdtDescriptor->Base = (UINTN)((UINT8*)IdtBuffer + 16); + *(UINTN*)(IdtDescriptor->Base - sizeof(UINTN)) = (UINTN)GetPeiServicesTablePointer (); + } + + InterruptStatus = SaveAndDisableInterrupts (); + // + // Need to make sure the GDT is loaded with values that support long mode and real mode. + // + AsmWriteGdtr (&mGdt); + // + // update segment selectors per the new GDT. + // + AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR); + // + // Restore interrupt state. + // + SetInterruptState (InterruptStatus); + + // + // Prepare data for return back + // + PeiS3ResumeState = AllocatePool (sizeof(*PeiS3ResumeState)); + if (PeiS3ResumeState == NULL) { + REPORT_STATUS_CODE ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_RESUME_FAILED) + ); + ASSERT (FALSE); + } + DEBUG ((DEBUG_INFO, "PeiS3ResumeState - %x\r\n", PeiS3ResumeState)); + PeiS3ResumeState->ReturnCs = 0x10; + PeiS3ResumeState->ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)S3ResumeBootOs; + PeiS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status); + // + // Save IDT + // + AsmReadIdtr (&PeiS3ResumeState->Idtr); + + // + // Report Status Code to indicate S3 boot script execution + // + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_S3_BOOT_SCRIPT); + + PERF_START (NULL, "ScriptExec", NULL, 0); + + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + // + // X64 S3 Resume + // + DEBUG ((DEBUG_INFO, "Enable X64 and transfer control to Standalone Boot Script Executor\r\n")); + + // + // Switch to long mode to complete resume. + // + AsmEnablePaging64 ( + 0x38, + EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint, + (UINT64)(UINTN)AcpiS3Context, + (UINT64)(UINTN)PeiS3ResumeState, + (UINT64)(UINTN)(AcpiS3Context->BootScriptStackBase + AcpiS3Context->BootScriptStackSize) + ); + } else { + // + // IA32 S3 Resume + // + DEBUG ((DEBUG_INFO, "transfer control to Standalone Boot Script Executor\r\n")); + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT) (UINTN) EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint, + (VOID *)AcpiS3Context, + (VOID *)PeiS3ResumeState, + (VOID *)(UINTN)(AcpiS3Context->BootScriptStackBase + AcpiS3Context->BootScriptStackSize) + ); + } + + // + // Never run to here + // + CpuDeadLoop(); +} +/** + Restores the platform to its preboot configuration for an S3 resume and + jumps to the OS waking vector. + + This function will restore the platform to its pre-boot configuration that was + pre-stored in the boot script table and transfer control to OS waking vector. + Upon invocation, this function is responsible for locating the following + information before jumping to OS waking vector: + - ACPI tables + - boot script table + - any other information that it needs + + The S3RestoreConfig() function then executes the pre-stored boot script table + and transitions the platform to the pre-boot state. The boot script is recorded + during regular boot using the EFI_S3_SAVE_STATE_PROTOCOL.Write() and + EFI_S3_SMM_SAVE_STATE_PROTOCOL.Write() functions. Finally, this function + transfers control to the OS waking vector. If the OS supports only a real-mode + waking vector, this function will switch from flat mode to real mode before + jumping to the waking vector. If all platform pre-boot configurations are + successfully restored and all other necessary information is ready, this + function will never return and instead will directly jump to the OS waking + vector. If this function returns, it indicates that the attempt to resume + from the ACPI S3 sleep state failed. + + @param[in] This Pointer to this instance of the PEI_S3_RESUME_PPI + + @retval EFI_ABORTED Execution of the S3 resume boot script table failed. + @retval EFI_NOT_FOUND Some necessary information that is used for the S3 + resume boot path could not be located. + +**/ +EFI_STATUS +EFIAPI +S3RestoreConfig2 ( + IN EFI_PEI_S3_RESUME2_PPI *This + ) +{ + EFI_STATUS Status; + PEI_SMM_ACCESS_PPI *SmmAccess; + UINTN Index; + ACPI_S3_CONTEXT *AcpiS3Context; + EFI_PHYSICAL_ADDRESS TempEfiBootScriptExecutorVariable; + EFI_PHYSICAL_ADDRESS TempAcpiS3Context; + BOOT_SCRIPT_EXECUTOR_VARIABLE *EfiBootScriptExecutorVariable; + UINTN VarSize; + EFI_SMRAM_DESCRIPTOR *SmramDescriptor; + SMM_S3_RESUME_STATE *SmmS3ResumeState; + VOID *GuidHob; + BOOLEAN Build4GPageTableOnly; + BOOLEAN InterruptStatus; + + TempAcpiS3Context = 0; + TempEfiBootScriptExecutorVariable = 0; + + DEBUG ((DEBUG_INFO, "Enter S3 PEIM\r\n")); + + VarSize = sizeof (EFI_PHYSICAL_ADDRESS); + Status = RestoreLockBox ( + &gEfiAcpiVariableGuid, + &TempAcpiS3Context, + &VarSize + ); + ASSERT_EFI_ERROR (Status); + + Status = RestoreLockBox ( + &gEfiAcpiS3ContextGuid, + NULL, + NULL + ); + ASSERT_EFI_ERROR (Status); + + AcpiS3Context = (ACPI_S3_CONTEXT *)(UINTN)TempAcpiS3Context; + ASSERT (AcpiS3Context != NULL); + + VarSize = sizeof (EFI_PHYSICAL_ADDRESS); + Status = RestoreLockBox ( + &gEfiBootScriptExecutorVariableGuid, + &TempEfiBootScriptExecutorVariable, + &VarSize + ); + ASSERT_EFI_ERROR (Status); + + Status = RestoreLockBox ( + &gEfiBootScriptExecutorContextGuid, + NULL, + NULL + ); + ASSERT_EFI_ERROR (Status); + + EfiBootScriptExecutorVariable = (BOOT_SCRIPT_EXECUTOR_VARIABLE *) (UINTN) TempEfiBootScriptExecutorVariable; + ASSERT (EfiBootScriptExecutorVariable != NULL); + + DEBUG (( DEBUG_INFO, "AcpiS3Context = %x\n", AcpiS3Context)); + DEBUG (( DEBUG_INFO, "Waking Vector = %x\n", ((EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)))->FirmwareWakingVector)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->AcpiFacsTable = %x\n", AcpiS3Context->AcpiFacsTable)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->IdtrProfile = %x\n", AcpiS3Context->IdtrProfile)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->S3NvsPageTableAddress = %x\n", AcpiS3Context->S3NvsPageTableAddress)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->S3DebugBufferAddress = %x\n", AcpiS3Context->S3DebugBufferAddress)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->BootScriptStackBase = %x\n", AcpiS3Context->BootScriptStackBase)); + DEBUG (( DEBUG_INFO, "AcpiS3Context->BootScriptStackSize = %x\n", AcpiS3Context->BootScriptStackSize)); + DEBUG (( DEBUG_INFO, "EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint = %x\n", EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint)); + + // + // Additional step for BootScript integrity - we only handle BootScript and BootScriptExecutor. + // Script dispatch image and context (parameter) are handled by platform. + // We just use restore all lock box in place, no need restore one by one. + // + Status = RestoreAllLockBoxInPlace (); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + // Something wrong + CpuDeadLoop (); + } + + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { + // + // Need reconstruct page table here, since we do not trust ACPINvs. + // + if (IsLongModeWakingVector (AcpiS3Context)) { + Build4GPageTableOnly = FALSE; + } else { + Build4GPageTableOnly = TRUE; + } + RestoreS3PageTables ((UINTN)AcpiS3Context->S3NvsPageTableAddress, Build4GPageTableOnly); + } + + // + // Attempt to use content from SMRAM first + // + GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); + if (GuidHob != NULL) { + Status = PeiServicesLocatePpi ( + &gPeiSmmAccessPpiGuid, + 0, + NULL, + (VOID **) &SmmAccess + ); + for (Index = 0; !EFI_ERROR (Status); Index++) { + Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); + } + + SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); + SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; + + SmmS3ResumeState->ReturnCs = AsmReadCs (); + SmmS3ResumeState->ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)S3ResumeExecuteBootScript; + SmmS3ResumeState->ReturnContext1 = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context; + SmmS3ResumeState->ReturnContext2 = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable; + SmmS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status); + + DEBUG (( DEBUG_INFO, "SMM S3 Signature = %x\n", SmmS3ResumeState->Signature)); + DEBUG (( DEBUG_INFO, "SMM S3 Stack Base = %x\n", SmmS3ResumeState->SmmS3StackBase)); + DEBUG (( DEBUG_INFO, "SMM S3 Stack Size = %x\n", SmmS3ResumeState->SmmS3StackSize)); + DEBUG (( DEBUG_INFO, "SMM S3 Resume Entry Point = %x\n", SmmS3ResumeState->SmmS3ResumeEntryPoint)); + DEBUG (( DEBUG_INFO, "SMM S3 CR0 = %x\n", SmmS3ResumeState->SmmS3Cr0)); + DEBUG (( DEBUG_INFO, "SMM S3 CR3 = %x\n", SmmS3ResumeState->SmmS3Cr3)); + DEBUG (( DEBUG_INFO, "SMM S3 CR4 = %x\n", SmmS3ResumeState->SmmS3Cr4)); + DEBUG (( DEBUG_INFO, "SMM S3 Return CS = %x\n", SmmS3ResumeState->ReturnCs)); + DEBUG (( DEBUG_INFO, "SMM S3 Return Entry Point = %x\n", SmmS3ResumeState->ReturnEntryPoint)); + DEBUG (( DEBUG_INFO, "SMM S3 Return Context1 = %x\n", SmmS3ResumeState->ReturnContext1)); + DEBUG (( DEBUG_INFO, "SMM S3 Return Context2 = %x\n", SmmS3ResumeState->ReturnContext2)); + DEBUG (( DEBUG_INFO, "SMM S3 Return Stack Pointer = %x\n", SmmS3ResumeState->ReturnStackPointer)); + DEBUG (( DEBUG_INFO, "SMM S3 Smst = %x\n", SmmS3ResumeState->Smst)); + + if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) { + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint, + (VOID *)AcpiS3Context, + 0, + (VOID *)(UINTN)(SmmS3ResumeState->SmmS3StackBase + SmmS3ResumeState->SmmS3StackSize) + ); + } + if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { + // + // Switch to long mode to complete resume. + // + + InterruptStatus = SaveAndDisableInterrupts (); + // + // Need to make sure the GDT is loaded with values that support long mode and real mode. + // + AsmWriteGdtr (&mGdt); + // + // update segment selectors per the new GDT. + // + AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR); + // + // Restore interrupt state. + // + SetInterruptState (InterruptStatus); + + AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3); + + // + // Disable interrupt of Debug timer, since IDT table cannot work in long mode. + // NOTE: On x64 platforms, because DisablePaging64() will disable interrupts, + // the code in S3ResumeExecuteBootScript() cannot be halted by soft debugger. + // + SaveAndSetDebugTimerInterrupt (FALSE); + + AsmEnablePaging64 ( + 0x38, + SmmS3ResumeState->SmmS3ResumeEntryPoint, + (UINT64)(UINTN)AcpiS3Context, + 0, + SmmS3ResumeState->SmmS3StackBase + SmmS3ResumeState->SmmS3StackSize + ); + } + + } + + S3ResumeExecuteBootScript (AcpiS3Context, EfiBootScriptExecutorVariable ); + return EFI_SUCCESS; +} +/** + Main entry for S3 Resume PEIM. + + This routine is to install EFI_PEI_S3_RESUME2_PPI. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Pointer to PEI Services table. + + @retval EFI_SUCCESS S3Resume Ppi is installed successfully. + +**/ +EFI_STATUS +EFIAPI +PeimS3ResumeEntryPoint ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + + // + // Install S3 Resume Ppi + // + Status = (**PeiServices).InstallPpi (PeiServices, &mPpiList); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf new file mode 100644 index 0000000000..d514523089 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf @@ -0,0 +1,101 @@ +## @file +# S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI. +# +# This module works with StandAloneBootScriptExecutor to S3 resume to OS. +# This module will excute the boot script saved during last boot and after that, +# control is passed to OS waking up handler. +# +# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# +# This program and the accompanying materials are +# licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = S3Resume2Pei + MODULE_UNI_FILE = S3Resume2Pei.uni + FILE_GUID = 89E549B0-7CFE-449d-9BA3-10D8B2312D71 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = PeimS3ResumeEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + S3Resume.c + +[Sources.IA32] + Ia32/AsmFuncs.asm + Ia32/AsmFuncs.nasm + Ia32/AsmFuncs.S + +[Sources.X64] + X64/AsmFuncs.asm + X64/AsmFuncs.nasm + X64/AsmFuncs.S + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + PeiServicesTablePointerLib + PerformanceLib + HobLib + PeiServicesLib + PeimEntryPoint + TimerLib + BaseLib + DebugLib + PcdLib + IoLib + BaseMemoryLib + MemoryAllocationLib + DebugAgentLib + LocalApicLib + ReportStatusCodeLib + LockBoxLib + PrintLib + +[Guids] + gEfiBootScriptExecutorVariableGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox + gEfiBootScriptExecutorContextGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox + gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## Variable:L"PerfDataMemAddr" + ## SOMETIMES_CONSUMES ## HOB + ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox + gEfiAcpiVariableGuid + gEfiAcpiS3ContextGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox + +[Ppis] + gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES + gEfiPeiS3Resume2PpiGuid ## PRODUCES + gPeiSmmAccessPpiGuid ## SOMETIMES_CONSUMES + gPeiPostScriptTablePpiGuid ## SOMETIMES_PRODUCES + gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES + +[FeaturePcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + S3Resume2PeiExtra.uni diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni new file mode 100644 index 0000000000..0f78a15173 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni @@ -0,0 +1,26 @@ +// /** @file +// S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI. +// +// This module works with StandAloneBootScriptExecutor to S3 resume to OS. +// This module will excute the boot script saved during last boot and after that, +// control is passed to OS waking up handler. +// +// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI" + +#string STR_MODULE_DESCRIPTION #language en-US "This module works with StandAloneBootScriptExecutor to S3 resume to OS.\n" + "This module will execute the boot script saved during last boot and after that,\n" + "control is passed to the OS waking up handler." + diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni new file mode 100644 index 0000000000..4d88423149 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// S3Resume2Pei Localized Strings and Content +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"S3 Resume v2 PEI Module" + + diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S new file mode 100644 index 0000000000..2ced09f35c --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S @@ -0,0 +1,37 @@ +#------------------------------------------------------------------------------ +#* +#* Copyright (c) 2012, Intel Corporation. All rights reserved.
+#* This program and the accompanying materials +#* are licensed and made available under the terms and conditions of the BSD License +#* which accompanies this distribution. The full text of the license may be found at +#* http://opensource.org/licenses/bsd-license.php +#* +#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#* +#* AsmFuncs.S +#* +#* Abstract: +#* +#* Assembly function to set segment selectors. +# +#------------------------------------------------------------------------------ + +.text + +#------------------------------------------------------------------------------ +# +# VOID +# EFIAPI +# AsmSetDataSelectors ( +# IN UINT16 SelectorValue +# ); +#------------------------------------------------------------------------------ +ASM_GLOBAL ASM_PFX(AsmSetDataSelectors) +ASM_PFX(AsmSetDataSelectors): + movw %cx, %ss + movw %cx, %ds + movw %cx, %es + movw %cx, %fs + movw %cx, %gs + ret diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm new file mode 100644 index 0000000000..eb014a5862 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm @@ -0,0 +1,41 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2012, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; AsmFuncs.Asm +; +; Abstract: +; +; Assembly function to set segment selectors. +; +; Notes: +; +;------------------------------------------------------------------------------ + +.code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmSetDataSelectors ( +; IN UINT16 SelectorValue +; ); +;------------------------------------------------------------------------------ +AsmSetDataSelectors PROC + mov ds, cx + mov es, cx + mov fs, cx + mov gs, cx + mov ss, cx + ret +AsmSetDataSelectors ENDP + +END diff --git a/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm new file mode 100644 index 0000000000..add73cacc0 --- /dev/null +++ b/Core/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm @@ -0,0 +1,41 @@ +;------------------------------------------------------------------------------ ; +; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; AsmFuncs.Asm +; +; Abstract: +; +; Assembly function to set segment selectors. +; +; Notes: +; +;------------------------------------------------------------------------------ + +DEFAULT REL +SECTION .text + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmSetDataSelectors ( +; IN UINT16 SelectorValue +; ); +;------------------------------------------------------------------------------ +global ASM_PFX(AsmSetDataSelectors) +ASM_PFX(AsmSetDataSelectors): +o16 mov ds, cx +o16 mov es, cx +o16 mov fs, cx +o16 mov gs, cx +o16 mov ss, cx + ret + diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c b/UefiCpuPkg/Application/Cpuid/Cpuid.c deleted file mode 100644 index 2efad68405..0000000000 --- a/UefiCpuPkg/Application/Cpuid/Cpuid.c +++ /dev/null @@ -1,1506 +0,0 @@ -/** @file - UEFI Application to display CPUID leaf information. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include - -/// -/// Macro used to display the value of a bit field in a register returned by CPUID. -/// -#define PRINT_BIT_FIELD(Variable, FieldName) \ - Print (L"%5a%42a: %x\n", #Variable, #FieldName, Variable.Bits.FieldName); - -/// -/// Macro used to display the value of a register returned by CPUID. -/// -#define PRINT_VALUE(Variable, Description) \ - Print (L"%5a%42a: %x\n", #Variable, #Description, Variable); - -/// -/// Structure for cache description lookup table -/// -typedef struct { - UINT8 CacheDescriptor; - CHAR8 *Type; - CHAR8 *Description; -} CPUID_CACHE_INFO_DESCRIPTION; - -/// -/// Cache description lookup table -/// -CPUID_CACHE_INFO_DESCRIPTION mCpuidCacheInfoDescription[] = { - { 0x00 , "General" , "Null descriptor, this byte contains no information" }, - { 0x01 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries" }, - { 0x02 , "TLB" , "Instruction TLB: 4 MByte pages, fully associative, 2 entries" }, - { 0x03 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 64 entries" }, - { 0x04 , "TLB" , "Data TLB: 4 MByte pages, 4-way set associative, 8 entries" }, - { 0x05 , "TLB" , "Data TLB1: 4 MByte pages, 4-way set associative, 32 entries" }, - { 0x06 , "Cache" , "1st-level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size" }, - { 0x08 , "Cache" , "1st-level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size" }, - { 0x09 , "Cache" , "1st-level instruction cache: 32KBytes, 4-way set associative, 64 byte line size" }, - { 0x0A , "Cache" , "1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size" }, - { 0x0B , "TLB" , "Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries" }, - { 0x0C , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size" }, - { 0x0D , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size" }, - { 0x0E , "Cache" , "1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size" }, - { 0x1D , "Cache" , "2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size" }, - { 0x21 , "Cache" , "2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size" }, - { 0x22 , "Cache" , "3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x23 , "Cache" , "3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x24 , "Cache" , "2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size" }, - { 0x25 , "Cache" , "3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x29 , "Cache" , "3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x2C , "Cache" , "1st-level data cache: 32 KBytes, 8-way set associative, 64 byte line size" }, - { 0x30 , "Cache" , "1st-level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size" }, - { 0x40 , "Cache" , "No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache" }, - { 0x41 , "Cache" , "2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size" }, - { 0x42 , "Cache" , "2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size" }, - { 0x43 , "Cache" , "2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size" }, - { 0x44 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size" }, - { 0x45 , "Cache" , "2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size" }, - { 0x46 , "Cache" , "3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size" }, - { 0x47 , "Cache" , "3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size" }, - { 0x48 , "Cache" , "2nd-level cache: 3MByte, 12-way set associative, 64 byte line size" }, - { 0x49 , "Cache" , "3rd-level cache: 4MB, 16-way set associative, 64-byte line size (Intel Xeon processor MP, Family 0FH, Model 06H). 2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size" }, - { 0x4A , "Cache" , "3rd-level cache: 6MByte, 12-way set associative, 64 byte line size" }, - { 0x4B , "Cache" , "3rd-level cache: 8MByte, 16-way set associative, 64 byte line size" }, - { 0x4C , "Cache" , "3rd-level cache: 12MByte, 12-way set associative, 64 byte line size" }, - { 0x4D , "Cache" , "3rd-level cache: 16MByte, 16-way set associative, 64 byte line size" }, - { 0x4E , "Cache" , "2nd-level cache: 6MByte, 24-way set associative, 64 byte line size" }, - { 0x4F , "TLB" , "Instruction TLB: 4 KByte pages, 32 entries" }, - { 0x50 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries" }, - { 0x51 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries" }, - { 0x52 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries" }, - { 0x55 , "TLB" , "Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries" }, - { 0x56 , "TLB" , "Data TLB0: 4 MByte pages, 4-way set associative, 16 entries" }, - { 0x57 , "TLB" , "Data TLB0: 4 KByte pages, 4-way associative, 16 entries" }, - { 0x59 , "TLB" , "Data TLB0: 4 KByte pages, fully associative, 16 entries" }, - { 0x5A , "TLB" , "Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries" }, - { 0x5B , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 64 entries" }, - { 0x5C , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,128 entries" }, - { 0x5D , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,256 entries" }, - { 0x60 , "Cache" , "1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size" }, - { 0x61 , "TLB" , "Instruction TLB: 4 KByte pages, fully associative, 48 entries" }, - { 0x63 , "TLB" , "Data TLB: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries and a separate array with 1 GByte pages, 4-way set associative, 4 entries" }, - { 0x64 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 512 entries" }, - { 0x66 , "Cache" , "1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size" }, - { 0x67 , "Cache" , "1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size" }, - { 0x68 , "Cache" , "1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size" }, - { 0x6A , "Cache" , "uTLB: 4 KByte pages, 8-way set associative, 64 entries" }, - { 0x6B , "Cache" , "DTLB: 4 KByte pages, 8-way set associative, 256 entries" }, - { 0x6C , "Cache" , "DTLB: 2M/4M pages, 8-way set associative, 128 entries" }, - { 0x6D , "Cache" , "DTLB: 1 GByte pages, fully associative, 16 entries" }, - { 0x70 , "Cache" , "Trace cache: 12 K-uop, 8-way set associative" }, - { 0x71 , "Cache" , "Trace cache: 16 K-uop, 8-way set associative" }, - { 0x72 , "Cache" , "Trace cache: 32 K-uop, 8-way set associative" }, - { 0x76 , "TLB" , "Instruction TLB: 2M/4M pages, fully associative, 8 entries" }, - { 0x78 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 64byte line size" }, - { 0x79 , "Cache" , "2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x7A , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x7B , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x7C , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, 2 lines per sector" }, - { 0x7D , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 64byte line size" }, - { 0x7F , "Cache" , "2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size" }, - { 0x80 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size" }, - { 0x82 , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size" }, - { 0x83 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size" }, - { 0x84 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size" }, - { 0x85 , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size" }, - { 0x86 , "Cache" , "2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size" }, - { 0x87 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size" }, - { 0xA0 , "DTLB" , "DTLB: 4k pages, fully associative, 32 entries" }, - { 0xB0 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries" }, - { 0xB1 , "TLB" , "Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries" }, - { 0xB2 , "TLB" , "Instruction TLB: 4KByte pages, 4-way set associative, 64 entries" }, - { 0xB3 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 128 entries" }, - { 0xB4 , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 256 entries" }, - { 0xB5 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 64 entries" }, - { 0xB6 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 128 entries" }, - { 0xBA , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 64 entries" }, - { 0xC0 , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries" }, - { 0xC1 , "STLB" , "Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries" }, - { 0xC2 , "DTLB" , "DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries" }, - { 0xC3 , "STLB" , "Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, 1536 entries. Also 1GBbyte pages, 4-way, 16 entries." }, - { 0xC4 , "DTLB" , "DTLB: 2M/4M Byte pages, 4-way associative, 32 entries" }, - { 0xCA , "STLB" , "Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries" }, - { 0xD0 , "Cache" , "3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size" }, - { 0xD1 , "Cache" , "3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size" }, - { 0xD2 , "Cache" , "3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size" }, - { 0xD6 , "Cache" , "3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size" }, - { 0xD7 , "Cache" , "3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size" }, - { 0xD8 , "Cache" , "3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size" }, - { 0xDC , "Cache" , "3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size" }, - { 0xDD , "Cache" , "3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size" }, - { 0xDE , "Cache" , "3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size" }, - { 0xE2 , "Cache" , "3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size" }, - { 0xE3 , "Cache" , "3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size" }, - { 0xE4 , "Cache" , "3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size" }, - { 0xEA , "Cache" , "3rd-level cache: 12MByte, 24-way set associative, 64 byte line size" }, - { 0xEB , "Cache" , "3rd-level cache: 18MByte, 24-way set associative, 64 byte line size" }, - { 0xEC , "Cache" , "3rd-level cache: 24MByte, 24-way set associative, 64 byte line size" }, - { 0xF0 , "Prefetch" , "64-Byte prefetching" }, - { 0xF1 , "Prefetch" , "128-Byte prefetching" }, - { 0xFF , "General" , "CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters" } -}; - -/// -/// The maximum supported CPUID leaf index starting from leaf 0x00000000. -/// -UINT32 gMaximumBasicFunction = CPUID_SIGNATURE; - -/// -/// The maximum supported CPUID leaf index starting from leaf 0x80000000. -/// -UINT32 gMaximumExtendedFunction = CPUID_EXTENDED_FUNCTION; - -/** - Display CPUID_SIGNATURE leaf. - -**/ -VOID -CpuidSignature ( - VOID - ) -{ - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - CHAR8 Signature[13]; - - AsmCpuid (CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx); - - Print (L"CPUID_SIGNATURE (Leaf %08x)\n", CPUID_SIGNATURE); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx); - PRINT_VALUE (Eax, MaximumLeaf); - *(UINT32 *)(Signature + 0) = Ebx; - *(UINT32 *)(Signature + 4) = Edx; - *(UINT32 *)(Signature + 8) = Ecx; - Signature [12] = 0; - Print (L" Signature = %a\n", Signature); - - gMaximumBasicFunction = Eax; -} - -/** - Display CPUID_VERSION_INFO leaf. - -**/ -VOID -CpuidVersionInfo ( - VOID - ) -{ - CPUID_VERSION_INFO_EAX Eax; - CPUID_VERSION_INFO_EBX Ebx; - CPUID_VERSION_INFO_ECX Ecx; - CPUID_VERSION_INFO_EDX Edx; - UINT32 DisplayFamily; - UINT32 DisplayModel; - - if (CPUID_VERSION_INFO > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - - Print (L"CPUID_VERSION_INFO (Leaf %08x)\n", CPUID_VERSION_INFO); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - - DisplayFamily = Eax.Bits.FamilyId; - if (Eax.Bits.FamilyId == 0x0F) { - DisplayFamily |= (Eax.Bits.ExtendedFamilyId << 4); - } - - DisplayModel = Eax.Bits.Model; - if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) { - DisplayModel |= (Eax.Bits.ExtendedModelId << 4); - } - - Print (L" Family = %x Model = %x Stepping = %x\n", DisplayFamily, DisplayModel, Eax.Bits.SteppingId); - - PRINT_BIT_FIELD (Eax, SteppingId); - PRINT_BIT_FIELD (Eax, Model); - PRINT_BIT_FIELD (Eax, FamilyId); - PRINT_BIT_FIELD (Eax, ProcessorType); - PRINT_BIT_FIELD (Eax, ExtendedModelId); - PRINT_BIT_FIELD (Eax, ExtendedFamilyId); - PRINT_BIT_FIELD (Ebx, BrandIndex); - PRINT_BIT_FIELD (Ebx, CacheLineSize); - PRINT_BIT_FIELD (Ebx, MaximumAddressableIdsForLogicalProcessors); - PRINT_BIT_FIELD (Ebx, InitialLocalApicId); - PRINT_BIT_FIELD (Ecx, SSE3); - PRINT_BIT_FIELD (Ecx, PCLMULQDQ); - PRINT_BIT_FIELD (Ecx, DTES64); - PRINT_BIT_FIELD (Ecx, MONITOR); - PRINT_BIT_FIELD (Ecx, DS_CPL); - PRINT_BIT_FIELD (Ecx, VMX); - PRINT_BIT_FIELD (Ecx, SMX); - PRINT_BIT_FIELD (Ecx, TM2); - PRINT_BIT_FIELD (Ecx, SSSE3); - PRINT_BIT_FIELD (Ecx, CNXT_ID); - PRINT_BIT_FIELD (Ecx, SDBG); - PRINT_BIT_FIELD (Ecx, FMA); - PRINT_BIT_FIELD (Ecx, CMPXCHG16B); - PRINT_BIT_FIELD (Ecx, xTPR_Update_Control); - PRINT_BIT_FIELD (Ecx, PDCM); - PRINT_BIT_FIELD (Ecx, PCID); - PRINT_BIT_FIELD (Ecx, DCA); - PRINT_BIT_FIELD (Ecx, SSE4_1); - PRINT_BIT_FIELD (Ecx, SSE4_2); - PRINT_BIT_FIELD (Ecx, x2APIC); - PRINT_BIT_FIELD (Ecx, MOVBE); - PRINT_BIT_FIELD (Ecx, POPCNT); - PRINT_BIT_FIELD (Ecx, TSC_Deadline); - PRINT_BIT_FIELD (Ecx, AESNI); - PRINT_BIT_FIELD (Ecx, XSAVE); - PRINT_BIT_FIELD (Ecx, OSXSAVE); - PRINT_BIT_FIELD (Ecx, AVX); - PRINT_BIT_FIELD (Ecx, F16C); - PRINT_BIT_FIELD (Ecx, RDRAND); - PRINT_BIT_FIELD (Edx, FPU); - PRINT_BIT_FIELD (Edx, VME); - PRINT_BIT_FIELD (Edx, DE); - PRINT_BIT_FIELD (Edx, PSE); - PRINT_BIT_FIELD (Edx, TSC); - PRINT_BIT_FIELD (Edx, MSR); - PRINT_BIT_FIELD (Edx, PAE); - PRINT_BIT_FIELD (Edx, MCE); - PRINT_BIT_FIELD (Edx, CX8); - PRINT_BIT_FIELD (Edx, APIC); - PRINT_BIT_FIELD (Edx, SEP); - PRINT_BIT_FIELD (Edx, MTRR); - PRINT_BIT_FIELD (Edx, PGE); - PRINT_BIT_FIELD (Edx, MCA); - PRINT_BIT_FIELD (Edx, CMOV); - PRINT_BIT_FIELD (Edx, PAT); - PRINT_BIT_FIELD (Edx, PSE_36); - PRINT_BIT_FIELD (Edx, PSN); - PRINT_BIT_FIELD (Edx, CLFSH); - PRINT_BIT_FIELD (Edx, DS); - PRINT_BIT_FIELD (Edx, ACPI); - PRINT_BIT_FIELD (Edx, MMX); - PRINT_BIT_FIELD (Edx, FXSR); - PRINT_BIT_FIELD (Edx, SSE); - PRINT_BIT_FIELD (Edx, SSE2); - PRINT_BIT_FIELD (Edx, SS); - PRINT_BIT_FIELD (Edx, HTT); - PRINT_BIT_FIELD (Edx, TM); - PRINT_BIT_FIELD (Edx, PBE); -} - -/** - Lookup a cache description string from the mCpuidCacheInfoDescription table. - - @param[in] CacheDescriptor Cache descriptor value from CPUID_CACHE_INFO. - -**/ -CPUID_CACHE_INFO_DESCRIPTION * -LookupCacheDescription ( - UINT8 CacheDescriptor - ) -{ - UINTN NumDescriptors; - UINTN Descriptor; - - if (CacheDescriptor == 0x00) { - return NULL; - } - NumDescriptors = sizeof (mCpuidCacheInfoDescription)/sizeof (mCpuidCacheInfoDescription[0]); - for (Descriptor = 0; Descriptor < NumDescriptors; Descriptor++) { - if (CacheDescriptor == mCpuidCacheInfoDescription[Descriptor].CacheDescriptor) { - return &mCpuidCacheInfoDescription[Descriptor]; - } - } - return NULL; -} - -/** - Display CPUID_CACHE_INFO leaf for each supported cache descriptor. - -**/ -VOID -CpuidCacheInfo ( - VOID - ) -{ - CPUID_CACHE_INFO_CACHE_TLB Eax; - CPUID_CACHE_INFO_CACHE_TLB Ebx; - CPUID_CACHE_INFO_CACHE_TLB Ecx; - CPUID_CACHE_INFO_CACHE_TLB Edx; - UINTN Index; - CPUID_CACHE_INFO_DESCRIPTION *CacheDescription; - - if (CPUID_CACHE_INFO > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_CACHE_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - - Print (L"CPUID_CACHE_INFO (Leaf %08x)\n", CPUID_CACHE_INFO); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - if (Eax.Bits.NotValid == 0) { - // - // Process Eax.CacheDescriptor[1..3]. Ignore Eax.CacheDescriptor[0] - // - for (Index = 1; Index < 4; Index++) { - CacheDescription = LookupCacheDescription (Eax.CacheDescriptor[Index]); - if (CacheDescription != NULL) { - Print (L" %-8a %a\n", - CacheDescription->Type, - CacheDescription->Description - ); - } - } - } - if (Ebx.Bits.NotValid == 0) { - // - // Process Ebx.CacheDescriptor[0..3] - // - for (Index = 0; Index < 4; Index++) { - CacheDescription = LookupCacheDescription (Ebx.CacheDescriptor[Index]); - if (CacheDescription != NULL) { - Print (L" %-8a %a\n", - CacheDescription->Type, - CacheDescription->Description - ); - } - } - } - if (Ecx.Bits.NotValid == 0) { - // - // Process Ecx.CacheDescriptor[0..3] - // - for (Index = 0; Index < 4; Index++) { - CacheDescription = LookupCacheDescription (Ecx.CacheDescriptor[Index]); - if (CacheDescription != NULL) { - Print (L" %-8a %a\n", - CacheDescription->Type, - CacheDescription->Description - ); - } - } - } - if (Edx.Bits.NotValid == 0) { - // - // Process Edx.CacheDescriptor[0..3] - // - for (Index = 0; Index < 4; Index++) { - CacheDescription = LookupCacheDescription (Edx.CacheDescriptor[Index]); - if (CacheDescription != NULL) { - Print (L" %-8a %a\n", - CacheDescription->Type, - CacheDescription->Description - ); - } - } - } -} - -/** - Display CPUID_SERIAL_NUMBER leaf if it is supported. - -**/ -VOID -CpuidSerialNumber ( - VOID - ) -{ - CPUID_VERSION_INFO_EDX VersionInfoEdx; - UINT32 Ecx; - UINT32 Edx; - - Print (L"CPUID_SERIAL_NUMBER (Leaf %08x)\n", CPUID_SERIAL_NUMBER); - - if (CPUID_SERIAL_NUMBER > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); - if (VersionInfoEdx.Bits.PSN == 0) { - Print (L" Not Supported\n"); - return; - } - - AsmCpuid (CPUID_SERIAL_NUMBER, NULL, NULL, &Ecx, &Edx); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx, Edx); - Print (L" Processor Serial Number = %08x%08x%08x\n", 0, Edx, Ecx); -} - -/** - Display CPUID_CACHE_PARAMS for all supported sub-leafs. - -**/ -VOID -CpuidCacheParams ( - VOID - ) -{ - UINT32 CacheLevel; - CPUID_CACHE_PARAMS_EAX Eax; - CPUID_CACHE_PARAMS_EBX Ebx; - UINT32 Ecx; - CPUID_CACHE_PARAMS_EDX Edx; - - if (CPUID_CACHE_PARAMS > gMaximumBasicFunction) { - return; - } - - CacheLevel = 0; - do { - AsmCpuidEx ( - CPUID_CACHE_PARAMS, CacheLevel, - &Eax.Uint32, &Ebx.Uint32, &Ecx, &Edx.Uint32 - ); - if (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL) { - Print (L"CPUID_CACHE_PARAMS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_CACHE_PARAMS, CacheLevel); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx, Edx.Uint32); - PRINT_BIT_FIELD (Eax, CacheType); - PRINT_BIT_FIELD (Eax, CacheLevel); - PRINT_BIT_FIELD (Eax, SelfInitializingCache); - PRINT_BIT_FIELD (Eax, FullyAssociativeCache); - PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForLogicalProcessors); - PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForProcessorCores); - PRINT_BIT_FIELD (Ebx, LineSize); - PRINT_BIT_FIELD (Ebx, LinePartitions); - PRINT_BIT_FIELD (Ebx, Ways); - PRINT_VALUE (Ecx, NumberOfSets); - PRINT_BIT_FIELD (Edx, Invalidate); - PRINT_BIT_FIELD (Edx, CacheInclusiveness); - PRINT_BIT_FIELD (Edx, ComplexCacheIndexing); - } - CacheLevel++; - } while (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL); -} - -/** - Display CPUID_MONITOR_MWAIT leaf. - -**/ -VOID -CpuidMonitorMwait ( - VOID - ) -{ - CPUID_MONITOR_MWAIT_EAX Eax; - CPUID_MONITOR_MWAIT_EBX Ebx; - CPUID_MONITOR_MWAIT_ECX Ecx; - CPUID_MONITOR_MWAIT_EDX Edx; - - if (CPUID_MONITOR_MWAIT > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_MONITOR_MWAIT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - - Print (L"CPUID_MONITOR_MWAIT (Leaf %08x)\n", CPUID_MONITOR_MWAIT); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - - PRINT_BIT_FIELD (Eax, SmallestMonitorLineSize); - PRINT_BIT_FIELD (Ebx, LargestMonitorLineSize); - PRINT_BIT_FIELD (Ecx, ExtensionsSupported); - PRINT_BIT_FIELD (Ecx, InterruptAsBreak); - PRINT_BIT_FIELD (Edx, C0States); - PRINT_BIT_FIELD (Edx, C1States); - PRINT_BIT_FIELD (Edx, C2States); - PRINT_BIT_FIELD (Edx, C3States); - PRINT_BIT_FIELD (Edx, C4States); - PRINT_BIT_FIELD (Edx, C5States); - PRINT_BIT_FIELD (Edx, C6States); - PRINT_BIT_FIELD (Edx, C7States); -} - -/** - Display CPUID_THERMAL_POWER_MANAGEMENT leaf. - -**/ -VOID -CpuidThermalPowerManagement ( - VOID - ) -{ - CPUID_THERMAL_POWER_MANAGEMENT_EAX Eax; - CPUID_THERMAL_POWER_MANAGEMENT_EBX Ebx; - CPUID_THERMAL_POWER_MANAGEMENT_ECX Ecx; - - if (CPUID_THERMAL_POWER_MANAGEMENT > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); - - Print (L"CPUID_THERMAL_POWER_MANAGEMENT (Leaf %08x)\n", CPUID_THERMAL_POWER_MANAGEMENT); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0); - - PRINT_BIT_FIELD (Eax, DigitalTemperatureSensor); - PRINT_BIT_FIELD (Eax, TurboBoostTechnology); - PRINT_BIT_FIELD (Eax, ARAT); - PRINT_BIT_FIELD (Eax, PLN); - PRINT_BIT_FIELD (Eax, ECMD); - PRINT_BIT_FIELD (Eax, PTM); - PRINT_BIT_FIELD (Eax, HWP); - PRINT_BIT_FIELD (Eax, HWP_Notification); - PRINT_BIT_FIELD (Eax, HWP_Activity_Window); - PRINT_BIT_FIELD (Eax, HWP_Energy_Performance_Preference); - PRINT_BIT_FIELD (Eax, HWP_Package_Level_Request); - PRINT_BIT_FIELD (Eax, HDC); - PRINT_BIT_FIELD (Ebx, InterruptThresholds); - PRINT_BIT_FIELD (Ecx, HardwareCoordinationFeedback); - PRINT_BIT_FIELD (Ecx, PerformanceEnergyBias); -} - -/** - Display CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS for all supported sub-leafs. - -**/ -VOID -CpuidStructuredExtendedFeatureFlags ( - VOID - ) -{ - UINT32 Eax; - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX Ecx; - UINT32 SubLeaf; - - if (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, - &Eax, NULL, NULL, NULL - ); - for (SubLeaf = 0; SubLeaf <= Eax; SubLeaf++) { - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - SubLeaf, - NULL, &Ebx.Uint32, &Ecx.Uint32, NULL - ); - if (Ebx.Uint32 != 0 || Ecx.Uint32 != 0) { - Print (L"CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, SubLeaf); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0); - PRINT_BIT_FIELD (Ebx, FSGSBASE); - PRINT_BIT_FIELD (Ebx, IA32_TSC_ADJUST); - PRINT_BIT_FIELD (Ebx, SGX); - PRINT_BIT_FIELD (Ebx, BMI1); - PRINT_BIT_FIELD (Ebx, HLE); - PRINT_BIT_FIELD (Ebx, AVX2); - PRINT_BIT_FIELD (Ebx, FDP_EXCPTN_ONLY); - PRINT_BIT_FIELD (Ebx, SMEP); - PRINT_BIT_FIELD (Ebx, BMI2); - PRINT_BIT_FIELD (Ebx, EnhancedRepMovsbStosb); - PRINT_BIT_FIELD (Ebx, INVPCID); - PRINT_BIT_FIELD (Ebx, RTM); - PRINT_BIT_FIELD (Ebx, RDT_M); - PRINT_BIT_FIELD (Ebx, DeprecateFpuCsDs); - PRINT_BIT_FIELD (Ebx, MPX); - PRINT_BIT_FIELD (Ebx, RDT_A); - PRINT_BIT_FIELD (Ebx, RDSEED); - PRINT_BIT_FIELD (Ebx, ADX); - PRINT_BIT_FIELD (Ebx, SMAP); - PRINT_BIT_FIELD (Ebx, CLFLUSHOPT); - PRINT_BIT_FIELD (Ebx, CLWB); - PRINT_BIT_FIELD (Ebx, IntelProcessorTrace); - PRINT_BIT_FIELD (Ebx, SHA); - PRINT_BIT_FIELD (Ecx, PREFETCHWT1); - PRINT_BIT_FIELD (Ecx, UMIP); - PRINT_BIT_FIELD (Ecx, PKU); - PRINT_BIT_FIELD (Ecx, OSPKE); - PRINT_BIT_FIELD (Ecx, MAWAU); - PRINT_BIT_FIELD (Ecx, RDPID); - PRINT_BIT_FIELD (Ecx, SGX_LC); - } - } -} - -/** - Display CPUID_DIRECT_CACHE_ACCESS_INFO leaf. - -**/ -VOID -CpuidDirectCacheAccessInfo ( - VOID - ) -{ - UINT32 Eax; - - if (CPUID_DIRECT_CACHE_ACCESS_INFO > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_DIRECT_CACHE_ACCESS_INFO, &Eax, NULL, NULL, NULL); - Print (L"CPUID_DIRECT_CACHE_ACCESS_INFO (Leaf %08x)\n", CPUID_DIRECT_CACHE_ACCESS_INFO); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0); -} - -/** - Display CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING leaf. - -**/ -VOID -CpuidArchitecturalPerformanceMonitoring ( - VOID - ) -{ - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX Eax; - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX Ebx; - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX Edx; - - if (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING, &Eax.Uint32, &Ebx.Uint32, NULL, &Edx.Uint32); - Print (L"CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING (Leaf %08x)\n", CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, Edx.Uint32); - PRINT_BIT_FIELD (Eax, ArchPerfMonVerID); - PRINT_BIT_FIELD (Eax, PerformanceMonitorCounters); - PRINT_BIT_FIELD (Eax, PerformanceMonitorCounterWidth); - PRINT_BIT_FIELD (Eax, EbxBitVectorLength); - PRINT_BIT_FIELD (Ebx, UnhaltedCoreCycles); - PRINT_BIT_FIELD (Ebx, InstructionsRetired); - PRINT_BIT_FIELD (Ebx, UnhaltedReferenceCycles); - PRINT_BIT_FIELD (Ebx, LastLevelCacheReferences); - PRINT_BIT_FIELD (Ebx, LastLevelCacheMisses); - PRINT_BIT_FIELD (Ebx, BranchInstructionsRetired); - PRINT_BIT_FIELD (Ebx, AllBranchMispredictRetired); - PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounters); - PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounterWidth); -} - -/** - Display CPUID_EXTENDED_TOPOLOGY leafs for all supported levels. - -**/ -VOID -CpuidExtendedTopology ( - VOID - ) -{ - CPUID_EXTENDED_TOPOLOGY_EAX Eax; - CPUID_EXTENDED_TOPOLOGY_EBX Ebx; - CPUID_EXTENDED_TOPOLOGY_ECX Ecx; - UINT32 Edx; - UINT32 LevelNumber; - - if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) { - return; - } - - LevelNumber = 0; - do { - AsmCpuidEx ( - CPUID_EXTENDED_TOPOLOGY, LevelNumber, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx - ); - if (Eax.Bits.ApicIdShift != 0) { - Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_TOPOLOGY, LevelNumber); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx); - PRINT_BIT_FIELD (Eax, ApicIdShift); - PRINT_BIT_FIELD (Ebx, LogicalProcessors); - PRINT_BIT_FIELD (Ecx, LevelNumber); - PRINT_BIT_FIELD (Ecx, LevelType); - PRINT_VALUE (Edx, x2APIC_ID); - } - LevelNumber++; - } while (Eax.Bits.ApicIdShift != 0); -} - -/** - Display CPUID_EXTENDED_STATE sub-leaf. - -**/ -VOID -CpuidExtendedStateSubLeaf ( - VOID - ) -{ - CPUID_EXTENDED_STATE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_EXTENDED_STATE_SUB_LEAF_ECX Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF, - &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx - ); - Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx); - PRINT_BIT_FIELD (Eax, XSAVEOPT); - PRINT_BIT_FIELD (Eax, XSAVEC); - PRINT_BIT_FIELD (Eax, XGETBV); - PRINT_BIT_FIELD (Eax, XSAVES); - PRINT_VALUE (Ebx, EnabledSaveStateSize_XCR0_IA32_XSS); - PRINT_BIT_FIELD (Ecx, XCR0); - PRINT_BIT_FIELD (Ecx, PT); - PRINT_BIT_FIELD (Ecx, XCR0_1); - PRINT_VALUE (Edx, IA32_XSS_Supported_32_63); -} - -/** - Display CPUID_EXTENDED_STATE size and offset information sub-leaf. - -**/ -VOID -CpuidExtendedStateSizeOffset ( - VOID - ) -{ - UINT32 Eax; - UINT32 Ebx; - CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX Ecx; - UINT32 Edx; - UINT32 SubLeaf; - - for (SubLeaf = CPUID_EXTENDED_STATE_SIZE_OFFSET; SubLeaf < 32; SubLeaf++) { - AsmCpuidEx ( - CPUID_EXTENDED_STATE, SubLeaf, - &Eax, &Ebx, &Ecx.Uint32, &Edx - ); - if (Edx != 0) { - Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, SubLeaf); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx.Uint32, Edx); - PRINT_VALUE (Eax, FeatureSaveStateSize); - PRINT_VALUE (Ebx, FeatureSaveStateOffset); - PRINT_BIT_FIELD (Ecx, XSS); - PRINT_BIT_FIELD (Ecx, Compacted); - } - } -} - -/** - Display CPUID_EXTENDED_STATE main leaf and sub-leafs. - -**/ -VOID -CpuidExtendedStateMainLeaf ( - VOID - ) -{ - CPUID_EXTENDED_STATE_MAIN_LEAF_EAX Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - - if (CPUID_EXTENDED_STATE > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF, - &Eax.Uint32, &Ebx, &Ecx, &Edx - ); - Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx, Edx); - PRINT_BIT_FIELD (Eax, x87); - PRINT_BIT_FIELD (Eax, SSE); - PRINT_BIT_FIELD (Eax, AVX); - PRINT_BIT_FIELD (Eax, MPX); - PRINT_BIT_FIELD (Eax, AVX_512); - PRINT_BIT_FIELD (Eax, IA32_XSS); - PRINT_BIT_FIELD (Eax, PKRU); - PRINT_VALUE (Ebx, EnabledSaveStateSize); - PRINT_VALUE (Ecx, SupportedSaveStateSize); - PRINT_VALUE (Edx, XCR0_Supported_32_63); - - CpuidExtendedStateSubLeaf (); - CpuidExtendedStateSizeOffset (); -} - -/** - Display CPUID_INTEL_RDT_MONITORING enumeration sub-leaf. - -**/ -VOID -CpuidIntelRdtMonitoringEnumerationSubLeaf ( - VOID - ) -{ - UINT32 Ebx; - CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX Edx; - - if (CPUID_INTEL_RDT_MONITORING > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF, - NULL, &Ebx, NULL, &Edx.Uint32 - ); - Print (L"CPUID_INTEL_RDT_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, 0, Edx.Uint32); - PRINT_VALUE (Ebx, Maximum_RMID_Range); - PRINT_BIT_FIELD (Edx, L3CacheRDT_M); -} - -/** - Display CPUID_INTEL_RDT_MONITORING L3 cache capability sub-leaf. - -**/ -VOID -CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf ( - VOID - ) -{ - UINT32 Ebx; - UINT32 Ecx; - CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX Edx; - - if (CPUID_INTEL_RDT_MONITORING > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF, - NULL, &Ebx, &Ecx, &Edx.Uint32 - ); - Print (L"CPUID_INTEL_RDT_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, Ecx, Edx.Uint32); - PRINT_VALUE (Ebx, OccupancyConversionFactor); - PRINT_VALUE (Ecx, Maximum_RMID_Range); - PRINT_BIT_FIELD (Edx, L3CacheOccupancyMonitoring); - PRINT_BIT_FIELD (Edx, L3CacheTotalBandwidthMonitoring); - PRINT_BIT_FIELD (Edx, L3CacheLocalBandwidthMonitoring); -} - -/** - Display CPUID_INTEL_RDT_ALLOCATION L3 cache allocation technology enumeration - sub-leaf. - -**/ -VOID -CpuidIntelRdtAllocationL3CacheSubLeaf ( - VOID - ) -{ - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX Ecx; - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF, - &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx.Uint32 - ); - Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx.Uint32); - PRINT_BIT_FIELD (Eax, CapacityLength); - PRINT_VALUE (Ebx, AllocationUnitBitMap); - PRINT_BIT_FIELD (Ecx, CosUpdatesInfrequent); - PRINT_BIT_FIELD (Ecx, CodeDataPrioritization); - PRINT_BIT_FIELD (Edx, HighestCosNumber); -} - -/** - Display CPUID_INTEL_RDT_ALLOCATION L2 cache allocation technology enumeration - sub-leaf. - -**/ -VOID -CpuidIntelRdtAllocationL2CacheSubLeaf ( - VOID - ) -{ - CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF, - &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 - ); - Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, 0, Edx.Uint32); - PRINT_BIT_FIELD (Eax, CapacityLength); - PRINT_VALUE (Ebx, AllocationUnitBitMap); - PRINT_BIT_FIELD (Edx, HighestCosNumber); -} - -/** - Display CPUID_INTEL_RDT_ALLOCATION main leaf and sub-leaves. - -**/ -VOID -CpuidIntelRdtAllocationMainLeaf ( - VOID - ) -{ - CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX Ebx; - - if (CPUID_INTEL_RDT_ALLOCATION > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF, - NULL, &Ebx.Uint32, NULL, NULL - ); - Print (L"CPUID_INTEL_RDT_ALLOCATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx.Uint32, 0, 0); - PRINT_BIT_FIELD (Ebx, L3CacheAllocation); - PRINT_BIT_FIELD (Ebx, L2CacheAllocation); - - CpuidIntelRdtAllocationL3CacheSubLeaf (); - CpuidIntelRdtAllocationL2CacheSubLeaf (); -} - -/** - Display Sub-Leaf 0 Enumeration of Intel SGX Capabilities. - -**/ -VOID -CpuidEnumerationOfIntelSgxCapabilities0SubLeaf ( - VOID - ) -{ - CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF, - &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 - ); - Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, 0, Edx.Uint32); - PRINT_BIT_FIELD (Eax, SGX1); - PRINT_BIT_FIELD (Eax, SGX2); - PRINT_BIT_FIELD (Edx, MaxEnclaveSize_Not64); - PRINT_BIT_FIELD (Edx, MaxEnclaveSize_64); -} - -/** - Display Sub-Leaf 1 Enumeration of Intel SGX Capabilities. - -**/ -VOID -CpuidEnumerationOfIntelSgxCapabilities1SubLeaf ( - VOID - ) -{ - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF, - &Eax, &Ebx, &Ecx, &Edx - ); - Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx); -} - -/** - Display Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources. - -**/ -VOID -CpuidEnumerationOfIntelSgxResourcesSubLeaf ( - VOID - ) -{ - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX Eax; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX Ebx; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX Ecx; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX Edx; - UINT32 SubLeaf; - - SubLeaf = CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF; - do { - AsmCpuidEx ( - CPUID_INTEL_SGX, SubLeaf, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - if (Eax.Bits.SubLeafType == 0x1) { - Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, SubLeaf); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - PRINT_BIT_FIELD (Eax, SubLeafType); - PRINT_BIT_FIELD (Eax, LowAddressOfEpcSection); - PRINT_BIT_FIELD (Ebx, HighAddressOfEpcSection); - PRINT_BIT_FIELD (Ecx, EpcSection); - PRINT_BIT_FIELD (Ecx, LowSizeOfEpcSection); - PRINT_BIT_FIELD (Edx, HighSizeOfEpcSection); - } - SubLeaf++; - } while (Eax.Bits.SubLeafType == 0x1); -} - -/** - Display Intel SGX Resource Enumeration. - -**/ -VOID -CpuidEnumerationOfIntelSgx ( - VOID - ) -{ - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; - - if (CPUID_INTEL_SGX > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, - NULL, &Ebx.Uint32, NULL, NULL - ); - if (Ebx.Bits.SGX != 1) { - // - // Only if CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1, the processor has support - // for Intel SGX. - // - return; - } - - CpuidEnumerationOfIntelSgxCapabilities0SubLeaf (); - CpuidEnumerationOfIntelSgxCapabilities1SubLeaf (); - CpuidEnumerationOfIntelSgxResourcesSubLeaf (); -} - -/** - Display CPUID_INTEL_PROCESSOR_TRACE sub-leafs. - - @param[in] MaximumSubLeaf Maximum sub-leaf index for CPUID_INTEL_PROCESSOR_TRACE. - -**/ -VOID -CpuidIntelProcessorTraceSubLeaf ( - UINT32 MaximumSubLeaf - ) -{ - UINT32 SubLeaf; - CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX Eax; - CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX Ebx; - - for (SubLeaf = CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF; SubLeaf <= MaximumSubLeaf; SubLeaf++) { - AsmCpuidEx ( - CPUID_INTEL_PROCESSOR_TRACE, SubLeaf, - &Eax.Uint32, &Ebx.Uint32, NULL, NULL - ); - Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, SubLeaf); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, 0); - PRINT_BIT_FIELD (Eax, ConfigurableAddressRanges); - PRINT_BIT_FIELD (Eax, MtcPeriodEncodings); - PRINT_BIT_FIELD (Ebx, CycleThresholdEncodings); - PRINT_BIT_FIELD (Ebx, PsbFrequencyEncodings); - } -} - -/** - Display CPUID_INTEL_PROCESSOR_TRACE main leaf and sub-leafs. - -**/ -VOID -CpuidIntelProcessorTraceMainLeaf ( - VOID - ) -{ - UINT32 Eax; - CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX Ebx; - CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX Ecx; - - if (CPUID_INTEL_PROCESSOR_TRACE > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, - &Eax, &Ebx.Uint32, &Ecx.Uint32, NULL - ); - Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0); - PRINT_VALUE (Eax, MaximumSubLeaf); - PRINT_BIT_FIELD (Ebx, Cr3Filter); - PRINT_BIT_FIELD (Ebx, ConfigurablePsb); - PRINT_BIT_FIELD (Ebx, IpTraceStopFiltering); - PRINT_BIT_FIELD (Ebx, Mtc); - PRINT_BIT_FIELD (Ebx, PTWrite); - PRINT_BIT_FIELD (Ebx, PowerEventTrace); - PRINT_BIT_FIELD (Ecx, RTIT); - PRINT_BIT_FIELD (Ecx, ToPA); - PRINT_BIT_FIELD (Ecx, SingleRangeOutput); - PRINT_BIT_FIELD (Ecx, TraceTransportSubsystem); - PRINT_BIT_FIELD (Ecx, LIP); - - CpuidIntelProcessorTraceSubLeaf (Eax); -} - -/** - Display CPUID_TIME_STAMP_COUNTER leaf. - -**/ -VOID -CpuidTimeStampCounter ( - VOID - ) -{ - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - - if (CPUID_TIME_STAMP_COUNTER > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_TIME_STAMP_COUNTER, &Eax, &Ebx, &Ecx, NULL); - Print (L"CPUID_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_TIME_STAMP_COUNTER); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, 0); -} - -/** - Display CPUID_PROCESSOR_FREQUENCY leaf. - -**/ -VOID -CpuidProcessorFrequency ( - VOID - ) -{ - CPUID_PROCESSOR_FREQUENCY_EAX Eax; - CPUID_PROCESSOR_FREQUENCY_EBX Ebx; - CPUID_PROCESSOR_FREQUENCY_ECX Ecx; - - if (CPUID_PROCESSOR_FREQUENCY > gMaximumBasicFunction) { - return; - } - - AsmCpuid (CPUID_PROCESSOR_FREQUENCY, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); - Print (L"CPUID_PROCESSOR_FREQUENCY (Leaf %08x)\n", CPUID_PROCESSOR_FREQUENCY); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0); - PRINT_BIT_FIELD (Eax, ProcessorBaseFrequency); - PRINT_BIT_FIELD (Ebx, MaximumFrequency); - PRINT_BIT_FIELD (Ecx, BusFrequency); -} - -/** - Display CPUID_SOC_VENDOR sub-leafs that contain the SoC Vendor Brand String. - Also display these sub-leafs as a single SoC Vendor Brand String. - -**/ -VOID -CpuidSocVendorBrandString ( - VOID - ) -{ - CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; - // - // Array to store brand string from 3 brand string leafs with - // 4 32-bit brand string values per leaf and an extra value to - // null terminate the string. - // - UINT32 BrandString[3 * 4 + 1]; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[0] = Eax.Uint32; - BrandString[1] = Ebx.Uint32; - BrandString[2] = Ecx.Uint32; - BrandString[3] = Edx.Uint32; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[4] = Eax.Uint32; - BrandString[5] = Ebx.Uint32; - BrandString[6] = Ecx.Uint32; - BrandString[7] = Edx.Uint32; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[8] = Eax.Uint32; - BrandString[9] = Ebx.Uint32; - BrandString[10] = Ecx.Uint32; - BrandString[11] = Edx.Uint32; - - BrandString[12] = 0; - - Print (L"Vendor Brand String = %a\n", (CHAR8 *)BrandString); -} - -/** - Display CPUID_SOC_VENDOR main leaf and sub-leafs. - -**/ -VOID -CpuidSocVendor ( - VOID - ) -{ - UINT32 Eax; - CPUID_SOC_VENDOR_MAIN_LEAF_EBX Ebx; - UINT32 Ecx; - UINT32 Edx; - - if (CPUID_SOC_VENDOR > gMaximumBasicFunction) { - return; - } - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF, - &Eax, &Ebx.Uint32, &Ecx, &Edx - ); - Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx, Edx); - if (Eax < 3) { - Print (L" Not Supported\n"); - return; - } - PRINT_VALUE (Eax, MaxSOCID_Index); - PRINT_BIT_FIELD (Ebx, SocVendorId); - PRINT_BIT_FIELD (Ebx, IsVendorScheme); - PRINT_VALUE (Ecx, ProjectID); - PRINT_VALUE (Edx, SteppingID); - CpuidSocVendorBrandString (); -} - -/** - Display CPUID_EXTENDED_FUNCTION leaf. - -**/ -VOID -CpuidExtendedFunction ( - VOID - ) -{ - UINT32 Eax; - - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); - Print (L"CPUID_EXTENDED_FUNCTION (Leaf %08x)\n", CPUID_EXTENDED_FUNCTION); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0); - PRINT_VALUE (Eax, MaximumExtendedFunction); - - gMaximumExtendedFunction = Eax; -} - -/** - Display CPUID_EXTENDED_CPU_SIG leaf. - -**/ -VOID -CpuidExtendedCpuSig ( - VOID - ) -{ - UINT32 Eax; - CPUID_EXTENDED_CPU_SIG_ECX Ecx; - CPUID_EXTENDED_CPU_SIG_EDX Edx; - - if (CPUID_EXTENDED_CPU_SIG > gMaximumExtendedFunction) { - return; - } - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, &Eax, NULL, &Ecx.Uint32, &Edx.Uint32); - Print (L"CPUID_EXTENDED_CPU_SIG (Leaf %08x)\n", CPUID_EXTENDED_CPU_SIG); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, Ecx.Uint32, Edx.Uint32); - PRINT_BIT_FIELD (Ecx, LAHF_SAHF); - PRINT_BIT_FIELD (Ecx, LZCNT); - PRINT_BIT_FIELD (Ecx, PREFETCHW); - PRINT_BIT_FIELD (Edx, SYSCALL_SYSRET); - PRINT_BIT_FIELD (Edx, NX); - PRINT_BIT_FIELD (Edx, Page1GB); - PRINT_BIT_FIELD (Edx, RDTSCP); - PRINT_BIT_FIELD (Edx, LM); -} - -/** - Display CPUID_BRAND_STRING1, CPUID_BRAND_STRING2 and CPUID_BRAND_STRING3 - leafs. Also display these three leafs as a single brand string. - -**/ -VOID -CpuidProcessorBrandString ( - VOID - ) -{ - CPUID_BRAND_STRING_DATA Eax; - CPUID_BRAND_STRING_DATA Ebx; - CPUID_BRAND_STRING_DATA Ecx; - CPUID_BRAND_STRING_DATA Edx; - // - // Array to store brand string from 3 brand string leafs with - // 4 32-bit brand string values per leaf and an extra value to - // null terminate the string. - // - UINT32 BrandString[3 * 4 + 1]; - - if (CPUID_BRAND_STRING1 <= gMaximumExtendedFunction) { - AsmCpuid (CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - Print (L"CPUID_BRAND_STRING1 (Leaf %08x)\n", CPUID_BRAND_STRING1); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[0] = Eax.Uint32; - BrandString[1] = Ebx.Uint32; - BrandString[2] = Ecx.Uint32; - BrandString[3] = Edx.Uint32; - } - - if (CPUID_BRAND_STRING2 <= gMaximumExtendedFunction) { - AsmCpuid (CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - Print (L"CPUID_BRAND_STRING2 (Leaf %08x)\n", CPUID_BRAND_STRING2); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[4] = Eax.Uint32; - BrandString[5] = Ebx.Uint32; - BrandString[6] = Ecx.Uint32; - BrandString[7] = Edx.Uint32; - } - - if (CPUID_BRAND_STRING3 <= gMaximumExtendedFunction) { - AsmCpuid (CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - Print (L"CPUID_BRAND_STRING3 (Leaf %08x)\n", CPUID_BRAND_STRING3); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); - BrandString[8] = Eax.Uint32; - BrandString[9] = Ebx.Uint32; - BrandString[10] = Ecx.Uint32; - BrandString[11] = Edx.Uint32; - } - - BrandString[12] = 0; - - Print (L"Brand String = %a\n", (CHAR8 *)BrandString); -} - -/** - Display CPUID_EXTENDED_CACHE_INFO leaf. - -**/ -VOID -CpuidExtendedCacheInfo ( - VOID - ) -{ - CPUID_EXTENDED_CACHE_INFO_ECX Ecx; - - if (CPUID_EXTENDED_CACHE_INFO > gMaximumExtendedFunction) { - return; - } - - AsmCpuid (CPUID_EXTENDED_CACHE_INFO, NULL, NULL, &Ecx.Uint32, NULL); - Print (L"CPUID_EXTENDED_CACHE_INFO (Leaf %08x)\n", CPUID_EXTENDED_CACHE_INFO); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx.Uint32, 0); - PRINT_BIT_FIELD (Ecx, CacheLineSize); - PRINT_BIT_FIELD (Ecx, L2Associativity); - PRINT_BIT_FIELD (Ecx, CacheSize); -} - -/** - Display CPUID_EXTENDED_TIME_STAMP_COUNTER leaf. - -**/ -VOID -CpuidExtendedTimeStampCounter ( - VOID - ) -{ - CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX Edx; - - if (CPUID_EXTENDED_TIME_STAMP_COUNTER > gMaximumExtendedFunction) { - return; - } - - AsmCpuid (CPUID_EXTENDED_TIME_STAMP_COUNTER, NULL, NULL, NULL, &Edx.Uint32); - Print (L"CPUID_EXTENDED_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_EXTENDED_TIME_STAMP_COUNTER); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, 0, Edx.Uint32); - PRINT_BIT_FIELD (Edx, InvariantTsc); -} - -/** - Display CPUID_VIR_PHY_ADDRESS_SIZE leaf. - -**/ -VOID -CpuidVirPhyAddressSize ( - VOID - ) -{ - CPUID_VIR_PHY_ADDRESS_SIZE_EAX Eax; - - if (CPUID_VIR_PHY_ADDRESS_SIZE > gMaximumExtendedFunction) { - return; - } - - AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Eax.Uint32, NULL, NULL, NULL); - Print (L"CPUID_VIR_PHY_ADDRESS_SIZE (Leaf %08x)\n", CPUID_VIR_PHY_ADDRESS_SIZE); - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, 0, 0, 0); - PRINT_BIT_FIELD (Eax, PhysicalAddressBits); - PRINT_BIT_FIELD (Eax, LinearAddressBits); -} - -/** - The user Entry Point for Application. The user code starts with this function - as the real entry point for the application. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -UefiMain ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - Print (L"UEFI CPUID Version 0.5\n"); - - CpuidSignature (); - CpuidVersionInfo (); - CpuidCacheInfo (); - CpuidSerialNumber (); - CpuidCacheParams(); - CpuidMonitorMwait (); - CpuidThermalPowerManagement (); - CpuidStructuredExtendedFeatureFlags (); - CpuidDirectCacheAccessInfo(); - CpuidArchitecturalPerformanceMonitoring (); - CpuidExtendedTopology (); - CpuidExtendedStateMainLeaf (); - CpuidIntelRdtMonitoringEnumerationSubLeaf (); - CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf (); - CpuidIntelRdtAllocationMainLeaf (); - CpuidEnumerationOfIntelSgx (); - CpuidIntelProcessorTraceMainLeaf (); - CpuidTimeStampCounter (); - CpuidProcessorFrequency (); - CpuidSocVendor (); - CpuidExtendedFunction (); - CpuidExtendedCpuSig (); - CpuidProcessorBrandString (); - CpuidExtendedCacheInfo (); - CpuidExtendedTimeStampCounter (); - CpuidVirPhyAddressSize (); - - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.inf b/UefiCpuPkg/Application/Cpuid/Cpuid.inf deleted file mode 100644 index 0d71b115d9..0000000000 --- a/UefiCpuPkg/Application/Cpuid/Cpuid.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# UEFI Application to display CPUID leaf information. -# -# This UEFI application displays the registers values returned by CPUID for -# all the CPUID leafs and sub-leafs that a CPU supports. It also displays -# the values of all the bit fields in the registers returned by each CPUID -# leaf and sub-leaf. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Cpuid - MODULE_UNI_FILE = Cpuid.uni - FILE_GUID = 4AE7E1E8-9DFE-4e3e-85B4-A5F6ABD470FB - MODULE_TYPE = UEFI_APPLICATION - VERSION_STRING = 0.5 - ENTRY_POINT = UefiMain - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - Cpuid.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - UefiApplicationEntryPoint - BaseLib - UefiLib - -[UserExtensions.TianoCore."ExtraFiles"] - CpuidExtra.uni diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.uni b/UefiCpuPkg/Application/Cpuid/Cpuid.uni deleted file mode 100644 index 32dee43414..0000000000 --- a/UefiCpuPkg/Application/Cpuid/Cpuid.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// UEFI Application to display CPUID leaf information. -// -// This UEFI application displays the registers values returned by CPUID for -// all the CPUID leafs and sub-leafs that a CPU supports. It also displays -// the values of all the bit fields in the registers returned by each CPUID -// leaf and sub-leaf. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "UEFI Application to display CPUID leaf information" - -#string STR_MODULE_DESCRIPTION #language en-US "This UEFI application displays the registers values returned by CPUID for all the CPUID leafs and sub-leafs that a CPU supports. It also displays the values of all the bit fields in the registers returned by each CPUID leaf and sub-leaf." diff --git a/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni b/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni deleted file mode 100644 index b4251e23cc..0000000000 --- a/UefiCpuPkg/Application/Cpuid/CpuidExtra.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// UEFI Application to display CPUID leaf information. -// -// This UEFI application displays the registers values returned by CPUID for -// all the CPUID leafs and sub-leafs that a CPU supports. It also displays -// the values of all the bit fields in the registers returned by each CPUID -// leaf and sub-leaf. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPUID Application" diff --git a/UefiCpuPkg/Contributions.txt b/UefiCpuPkg/Contributions.txt deleted file mode 100644 index f87cbd73c6..0000000000 --- a/UefiCpuPkg/Contributions.txt +++ /dev/null @@ -1,218 +0,0 @@ - -====================== -= Code Contributions = -====================== - -To make a contribution to a TianoCore project, follow these steps. -1. Create a change description in the format specified below to - use in the source control commit log. -2. Your commit message must include your "Signed-off-by" signature, - and "Contributed-under" message. -3. Your "Contributed-under" message explicitly states that the - contribution is made under the terms of the specified - contribution agreement. Your "Contributed-under" message - must include the name of contribution agreement and version. - For example: Contributed-under: TianoCore Contribution Agreement 1.0 - The "TianoCore Contribution Agreement" is included below in - this document. -4. Submit your code to the TianoCore project using the process - that the project documents on its web page. If the process is - not documented, then submit the code on development email list - for the project. -5. It is preferred that contributions are submitted using the same - copyright license as the base project. When that is not possible, - then contributions using the following licenses can be accepted: - * BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause - * BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause - * MIT: http://opensource.org/licenses/MIT - * Python-2.0: http://opensource.org/licenses/Python-2.0 - * Zlib: http://opensource.org/licenses/Zlib - - Contributions of code put into the public domain can also be - accepted. - - Contributions using other licenses might be accepted, but further - review will be required. - -===================================================== -= Change Description / Commit Message / Patch Email = -===================================================== - -Your change description should use the standard format for a -commit message, and must include your "Signed-off-by" signature -and the "Contributed-under" message. - -== Sample Change Description / Commit Message = - -=== Start of sample patch email message === - -From: Contributor Name -Subject: [PATCH] CodeModule: Brief-single-line-summary - -Full-commit-message - -Contributed-under: TianoCore Contribution Agreement 1.0 -Signed-off-by: Contributor Name ---- - -An extra message for the patch email which will not be considered part -of the commit message can be added here. - -Patch content inline or attached - -=== End of sample patch email message === - -=== Notes for sample patch email === - -* The first line of commit message is taken from the email's subject - line following [PATCH]. The remaining portion of the commit message - is the email's content until the '---' line. -* git format-patch is one way to create this format - -=== Definitions for sample patch email === - -* "CodeModule" is a short idenfier for the affected code. For - example MdePkg, or MdeModulePkg UsbBusDxe. -* "Brief-single-line-summary" is a short summary of the change. -* The entire first line should be less than ~70 characters. -* "Full-commit-message" a verbose multiple line comment describing - the change. Each line should be less than ~70 characters. -* "Contributed-under" explicitely states that the contribution is - made under the terms of the contribtion agreement. This - agreement is included below in this document. -* "Signed-off-by" is the contributor's signature identifying them - by their real/legal name and their email address. - -======================================== -= TianoCore Contribution Agreement 1.0 = -======================================== - -INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION, -INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE -PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE -TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE -TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR -REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE -CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED -BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS -AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE -AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT -USE THE CONTENT. - -Unless otherwise indicated, all Content made available on the TianoCore -site is provided to you under the terms and conditions of the BSD -License ("BSD"). A copy of the BSD License is available at -http://opensource.org/licenses/bsd-license.php -or when applicable, in the associated License.txt file. - -Certain other content may be made available under other licenses as -indicated in or with such Content. (For example, in a License.txt file.) - -You accept and agree to the following terms and conditions for Your -present and future Contributions submitted to TianoCore site. Except -for the license granted to Intel hereunder, You reserve all right, -title, and interest in and to Your Contributions. - -== SECTION 1: Definitions == -* "You" or "Contributor" shall mean the copyright owner or legal - entity authorized by the copyright owner that is making a - Contribution hereunder. All other entities that control, are - controlled by, or are under common control with that entity are - considered to be a single Contributor. For the purposes of this - definition, "control" means (i) the power, direct or indirect, to - cause the direction or management of such entity, whether by - contract or otherwise, or (ii) ownership of fifty percent (50%) - or more of the outstanding shares, or (iii) beneficial ownership - of such entity. -* "Contribution" shall mean any original work of authorship, - including any modifications or additions to an existing work, - that is intentionally submitted by You to the TinaoCore site for - inclusion in, or documentation of, any of the Content. For the - purposes of this definition, "submitted" means any form of - electronic, verbal, or written communication sent to the - TianoCore site or its representatives, including but not limited - to communication on electronic mailing lists, source code - control systems, and issue tracking systems that are managed by, - or on behalf of, the TianoCore site for the purpose of - discussing and improving the Content, but excluding - communication that is conspicuously marked or otherwise - designated in writing by You as "Not a Contribution." - -== SECTION 2: License for Contributions == -* Contributor hereby agrees that redistribution and use of the - Contribution in source and binary forms, with or without - modification, are permitted provided that the following - conditions are met: -** Redistributions of source code must retain the Contributor's - copyright notice, this list of conditions and the following - disclaimer. -** Redistributions in binary form must reproduce the Contributor's - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. -* Disclaimer. None of the names of Contributor, Intel, or the names - of their respective contributors may be used to endorse or - promote products derived from this software without specific - prior written permission. -* Contributor grants a license (with the right to sublicense) under - claims of Contributor's patents that Contributor can license that - are infringed by the Contribution (as delivered by Contributor) to - make, use, distribute, sell, offer for sale, and import the - Contribution and derivative works thereof solely to the minimum - extent necessary for licensee to exercise the granted copyright - license; this patent license applies solely to those portions of - the Contribution that are unmodified. No hardware per se is - licensed. -* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE - CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE - CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - -== SECTION 3: Representations == -* You represent that You are legally entitled to grant the above - license. If your employer(s) has rights to intellectual property - that You create that includes Your Contributions, You represent - that You have received permission to make Contributions on behalf - of that employer, that Your employer has waived such rights for - Your Contributions. -* You represent that each of Your Contributions is Your original - creation (see Section 4 for submissions on behalf of others). - You represent that Your Contribution submissions include complete - details of any third-party license or other restriction - (including, but not limited to, related patents and trademarks) - of which You are personally aware and which are associated with - any part of Your Contributions. - -== SECTION 4: Third Party Contributions == -* Should You wish to submit work that is not Your original creation, - You may submit it to TianoCore site separately from any - Contribution, identifying the complete details of its source - and of any license or other restriction (including, but not - limited to, related patents, trademarks, and license agreements) - of which You are personally aware, and conspicuously marking the - work as "Submitted on behalf of a third-party: [named here]". - -== SECTION 5: Miscellaneous == -* Applicable Laws. Any claims arising under or relating to this - Agreement shall be governed by the internal substantive laws of - the State of Delaware or federal courts located in Delaware, - without regard to principles of conflict of laws. -* Language. This Agreement is in the English language only, which - language shall be controlling in all respects, and all versions - of this Agreement in any other language shall be for accommodation - only and shall not be binding. All communications and notices made - or given pursuant to this Agreement, and all documentation and - support to be provided, unless otherwise noted, shall be in the - English language. - diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c deleted file mode 100644 index 4a5e282741..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ /dev/null @@ -1,1180 +0,0 @@ -/** @file - CPU DXE Module to produce CPU ARCH Protocol. - - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuDxe.h" -#include "CpuMp.h" -#include "CpuPageTable.h" - -#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) -#define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY_RO) - -// -// Global Variables -// -BOOLEAN InterruptState = FALSE; -EFI_HANDLE mCpuHandle = NULL; -BOOLEAN mIsFlushingGCD; -UINT64 mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; -UINT64 mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; -UINT64 mTimerPeriod = 0; - -FIXED_MTRR mFixedMtrrTable[] = { - { - MTRR_LIB_IA32_MTRR_FIX64K_00000, - 0, - 0x10000 - }, - { - MTRR_LIB_IA32_MTRR_FIX16K_80000, - 0x80000, - 0x4000 - }, - { - MTRR_LIB_IA32_MTRR_FIX16K_A0000, - 0xA0000, - 0x4000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_C0000, - 0xC0000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_C8000, - 0xC8000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_D0000, - 0xD0000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_D8000, - 0xD8000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_E0000, - 0xE0000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_E8000, - 0xE8000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_F0000, - 0xF0000, - 0x1000 - }, - { - MTRR_LIB_IA32_MTRR_FIX4K_F8000, - 0xF8000, - 0x1000 - }, -}; - - -EFI_CPU_ARCH_PROTOCOL gCpu = { - CpuFlushCpuDataCache, - CpuEnableInterrupt, - CpuDisableInterrupt, - CpuGetInterruptState, - CpuInit, - CpuRegisterInterruptHandler, - CpuGetTimerValue, - CpuSetMemoryAttributes, - 1, // NumberOfTimers - 4 // DmaBufferAlignment -}; - -// -// CPU Arch Protocol Functions -// - -/** - Flush CPU data cache. If the instruction cache is fully coherent - with all DMA operations then function can just return EFI_SUCCESS. - - @param This Protocol instance structure - @param Start Physical address to start flushing from. - @param Length Number of bytes to flush. Round up to chipset - granularity. - @param FlushType Specifies the type of flush operation to perform. - - @retval EFI_SUCCESS If cache was flushed - @retval EFI_UNSUPPORTED If flush type is not supported. - @retval EFI_DEVICE_ERROR If requested range could not be flushed. - -**/ -EFI_STATUS -EFIAPI -CpuFlushCpuDataCache ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length, - IN EFI_CPU_FLUSH_TYPE FlushType - ) -{ - if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) { - AsmWbinvd (); - return EFI_SUCCESS; - } else if (FlushType == EfiCpuFlushTypeInvalidate) { - AsmInvd (); - return EFI_SUCCESS; - } else { - return EFI_UNSUPPORTED; - } -} - - -/** - Enables CPU interrupts. - - @param This Protocol instance structure - - @retval EFI_SUCCESS If interrupts were enabled in the CPU - @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU. - -**/ -EFI_STATUS -EFIAPI -CpuEnableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ) -{ - EnableInterrupts (); - - InterruptState = TRUE; - return EFI_SUCCESS; -} - - -/** - Disables CPU interrupts. - - @param This Protocol instance structure - - @retval EFI_SUCCESS If interrupts were disabled in the CPU. - @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU. - -**/ -EFI_STATUS -EFIAPI -CpuDisableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ) -{ - DisableInterrupts (); - - InterruptState = FALSE; - return EFI_SUCCESS; -} - - -/** - Return the state of interrupts. - - @param This Protocol instance structure - @param State Pointer to the CPU's current interrupt state - - @retval EFI_SUCCESS If interrupts were disabled in the CPU. - @retval EFI_INVALID_PARAMETER State is NULL. - -**/ -EFI_STATUS -EFIAPI -CpuGetInterruptState ( - IN EFI_CPU_ARCH_PROTOCOL *This, - OUT BOOLEAN *State - ) -{ - if (State == NULL) { - return EFI_INVALID_PARAMETER; - } - - *State = InterruptState; - return EFI_SUCCESS; -} - - -/** - Generates an INIT to the CPU. - - @param This Protocol instance structure - @param InitType Type of CPU INIT to perform - - @retval EFI_SUCCESS If CPU INIT occurred. This value should never be - seen. - @retval EFI_DEVICE_ERROR If CPU INIT failed. - @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported. - -**/ -EFI_STATUS -EFIAPI -CpuInit ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_CPU_INIT_TYPE InitType - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Registers a function to be called from the CPU interrupt handler. - - @param This Protocol instance structure - @param InterruptType Defines which interrupt to hook. IA-32 - valid range is 0x00 through 0xFF - @param InterruptHandler A pointer to a function of type - EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. A null - pointer is an error condition. - - @retval EFI_SUCCESS If handler installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler - for InterruptType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for - InterruptType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType - is not supported. - -**/ -EFI_STATUS -EFIAPI -CpuRegisterInterruptHandler ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return RegisterCpuInterruptHandler (InterruptType, InterruptHandler); -} - - -/** - Returns a timer value from one of the CPU's internal timers. There is no - inherent time interval between ticks but is a function of the CPU frequency. - - @param This - Protocol instance structure. - @param TimerIndex - Specifies which CPU timer is requested. - @param TimerValue - Pointer to the returned timer value. - @param TimerPeriod - A pointer to the amount of time that passes - in femtoseconds (10-15) for each increment - of TimerValue. If TimerValue does not - increment at a predictable rate, then 0 is - returned. The amount of time that has - passed between two calls to GetTimerValue() - can be calculated with the formula - (TimerValue2 - TimerValue1) * TimerPeriod. - This parameter is optional and may be NULL. - - @retval EFI_SUCCESS - If the CPU timer count was returned. - @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers. - @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer. - @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL. - -**/ -EFI_STATUS -EFIAPI -CpuGetTimerValue ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN UINT32 TimerIndex, - OUT UINT64 *TimerValue, - OUT UINT64 *TimerPeriod OPTIONAL - ) -{ - UINT64 BeginValue; - UINT64 EndValue; - - if (TimerValue == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (TimerIndex != 0) { - return EFI_INVALID_PARAMETER; - } - - *TimerValue = AsmReadTsc (); - - if (TimerPeriod != NULL) { - if (mTimerPeriod == 0) { - // - // Read time stamp counter before and after delay of 100 microseconds - // - BeginValue = AsmReadTsc (); - MicroSecondDelay (100); - EndValue = AsmReadTsc (); - // - // Calculate the actual frequency - // - mTimerPeriod = DivU64x64Remainder ( - MultU64x32 ( - 1000 * 1000 * 1000, - 100 - ), - EndValue - BeginValue, - NULL - ); - } - *TimerPeriod = mTimerPeriod; - } - - return EFI_SUCCESS; -} - -/** - A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to - EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure. - - @param[in] Buffer Pointer to an MTRR_SETTINGS object, to be passed to - MtrrSetAllMtrrs(). -**/ -VOID -EFIAPI -SetMtrrsFromBuffer ( - IN VOID *Buffer - ) -{ - MtrrSetAllMtrrs (Buffer); -} - -/** - Implementation of SetMemoryAttributes() service of CPU Architecture Protocol. - - This function modifies the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param This The EFI_CPU_ARCH_PROTOCOL instance. - @param BaseAddress The physical address that is the start address of a memory region. - @param Length The size in bytes of the memory region. - @param Attributes The bit mask of attributes to set for the memory region. - - @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -CpuSetMemoryAttributes ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ) -{ - RETURN_STATUS Status; - MTRR_MEMORY_CACHE_TYPE CacheType; - EFI_STATUS MpStatus; - EFI_MP_SERVICES_PROTOCOL *MpService; - MTRR_SETTINGS MtrrSettings; - UINT64 CacheAttributes; - UINT64 MemoryAttributes; - MTRR_MEMORY_CACHE_TYPE CurrentCacheType; - - // - // If this function is called because GCD SetMemorySpaceAttributes () is called - // by RefreshGcdMemoryAttributes (), then we are just synchronzing GCD memory - // map with MTRR values. So there is no need to modify MTRRs, just return immediately - // to avoid unnecessary computing. - // - if (mIsFlushingGCD) { - DEBUG((DEBUG_INFO, " Flushing GCD\n")); - return EFI_SUCCESS; - } - - - CacheAttributes = Attributes & CACHE_ATTRIBUTE_MASK; - MemoryAttributes = Attributes & MEMORY_ATTRIBUTE_MASK; - - if (Attributes != (CacheAttributes | MemoryAttributes)) { - return EFI_INVALID_PARAMETER; - } - - if (CacheAttributes != 0) { - if (!IsMtrrSupported ()) { - return EFI_UNSUPPORTED; - } - - switch (CacheAttributes) { - case EFI_MEMORY_UC: - CacheType = CacheUncacheable; - break; - - case EFI_MEMORY_WC: - CacheType = CacheWriteCombining; - break; - - case EFI_MEMORY_WT: - CacheType = CacheWriteThrough; - break; - - case EFI_MEMORY_WP: - CacheType = CacheWriteProtected; - break; - - case EFI_MEMORY_WB: - CacheType = CacheWriteBack; - break; - - default: - return EFI_INVALID_PARAMETER; - } - CurrentCacheType = MtrrGetMemoryAttribute(BaseAddress); - if (CurrentCacheType != CacheType) { - // - // call MTRR libary function - // - Status = MtrrSetMemoryAttribute ( - BaseAddress, - Length, - CacheType - ); - - if (!RETURN_ERROR (Status)) { - MpStatus = gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&MpService - ); - // - // Synchronize the update with all APs - // - if (!EFI_ERROR (MpStatus)) { - MtrrGetAllMtrrs (&MtrrSettings); - MpStatus = MpService->StartupAllAPs ( - MpService, // This - SetMtrrsFromBuffer, // Procedure - FALSE, // SingleThread - NULL, // WaitEvent - 0, // TimeoutInMicrosecsond - &MtrrSettings, // ProcedureArgument - NULL // FailedCpuList - ); - ASSERT (MpStatus == EFI_SUCCESS || MpStatus == EFI_NOT_STARTED); - } - } - if (EFI_ERROR(Status)) { - return Status; - } - } - } - - // - // Set memory attribute by page table - // - return AssignMemoryPageAttributes (NULL, BaseAddress, Length, MemoryAttributes, AllocatePages); -} - -/** - Initializes the valid bits mask and valid address mask for MTRRs. - - This function initializes the valid bits mask and valid address mask for MTRRs. - -**/ -VOID -InitializeMtrrMask ( - VOID - ) -{ - UINT32 RegEax; - UINT8 PhysicalAddressBits; - - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - - if (RegEax >= 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - - PhysicalAddressBits = (UINT8) RegEax; - - mValidMtrrBitsMask = LShiftU64 (1, PhysicalAddressBits) - 1; - mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL; - } else { - mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK; - mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS; - } -} - -/** - Gets GCD Mem Space type from MTRR Type. - - This function gets GCD Mem Space type from MTRR Type. - - @param MtrrAttributes MTRR memory type - - @return GCD Mem Space type - -**/ -UINT64 -GetMemorySpaceAttributeFromMtrrType ( - IN UINT8 MtrrAttributes - ) -{ - switch (MtrrAttributes) { - case MTRR_CACHE_UNCACHEABLE: - return EFI_MEMORY_UC; - case MTRR_CACHE_WRITE_COMBINING: - return EFI_MEMORY_WC; - case MTRR_CACHE_WRITE_THROUGH: - return EFI_MEMORY_WT; - case MTRR_CACHE_WRITE_PROTECTED: - return EFI_MEMORY_WP; - case MTRR_CACHE_WRITE_BACK: - return EFI_MEMORY_WB; - default: - return 0; - } -} - -/** - Searches memory descriptors covered by given memory range. - - This function searches into the Gcd Memory Space for descriptors - (from StartIndex to EndIndex) that contains the memory range - specified by BaseAddress and Length. - - @param MemorySpaceMap Gcd Memory Space Map as array. - @param NumberOfDescriptors Number of descriptors in map. - @param BaseAddress BaseAddress for the requested range. - @param Length Length for the requested range. - @param StartIndex Start index into the Gcd Memory Space Map. - @param EndIndex End index into the Gcd Memory Space Map. - - @retval EFI_SUCCESS Search successfully. - @retval EFI_NOT_FOUND The requested descriptors does not exist. - -**/ -EFI_STATUS -SearchGcdMemorySpaces ( - IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, - IN UINTN NumberOfDescriptors, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - OUT UINTN *StartIndex, - OUT UINTN *EndIndex - ) -{ - UINTN Index; - - *StartIndex = 0; - *EndIndex = 0; - for (Index = 0; Index < NumberOfDescriptors; Index++) { - if (BaseAddress >= MemorySpaceMap[Index].BaseAddress && - BaseAddress < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { - *StartIndex = Index; - } - if (BaseAddress + Length - 1 >= MemorySpaceMap[Index].BaseAddress && - BaseAddress + Length - 1 < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { - *EndIndex = Index; - return EFI_SUCCESS; - } - } - return EFI_NOT_FOUND; -} - -/** - Sets the attributes for a specified range in Gcd Memory Space Map. - - This function sets the attributes for a specified range in - Gcd Memory Space Map. - - @param MemorySpaceMap Gcd Memory Space Map as array - @param NumberOfDescriptors Number of descriptors in map - @param BaseAddress BaseAddress for the range - @param Length Length for the range - @param Attributes Attributes to set - - @retval EFI_SUCCESS Memory attributes set successfully - @retval EFI_NOT_FOUND The specified range does not exist in Gcd Memory Space - -**/ -EFI_STATUS -SetGcdMemorySpaceAttributes ( - IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, - IN UINTN NumberOfDescriptors, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ) -{ - EFI_STATUS Status; - UINTN Index; - UINTN StartIndex; - UINTN EndIndex; - EFI_PHYSICAL_ADDRESS RegionStart; - UINT64 RegionLength; - - // - // Get all memory descriptors covered by the memory range - // - Status = SearchGcdMemorySpaces ( - MemorySpaceMap, - NumberOfDescriptors, - BaseAddress, - Length, - &StartIndex, - &EndIndex - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Go through all related descriptors and set attributes accordingly - // - for (Index = StartIndex; Index <= EndIndex; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) { - continue; - } - // - // Calculate the start and end address of the overlapping range - // - if (BaseAddress >= MemorySpaceMap[Index].BaseAddress) { - RegionStart = BaseAddress; - } else { - RegionStart = MemorySpaceMap[Index].BaseAddress; - } - if (BaseAddress + Length - 1 < MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length) { - RegionLength = BaseAddress + Length - RegionStart; - } else { - RegionLength = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - RegionStart; - } - // - // Set memory attributes according to MTRR attribute and the original attribute of descriptor - // - gDS->SetMemorySpaceAttributes ( - RegionStart, - RegionLength, - (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK) | (MemorySpaceMap[Index].Capabilities & Attributes) - ); - } - - return EFI_SUCCESS; -} - - -/** - Refreshes the GCD Memory Space attributes according to MTRRs. - - This function refreshes the GCD Memory Space attributes according to MTRRs. - -**/ -VOID -RefreshGcdMemoryAttributes ( - VOID - ) -{ - EFI_STATUS Status; - UINTN Index; - UINTN SubIndex; - UINT64 RegValue; - EFI_PHYSICAL_ADDRESS BaseAddress; - UINT64 Length; - UINT64 Attributes; - UINT64 CurrentAttributes; - UINT8 MtrrType; - UINTN NumberOfDescriptors; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; - UINT64 DefaultAttributes; - VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; - MTRR_FIXED_SETTINGS MtrrFixedSettings; - UINT32 FirmwareVariableMtrrCount; - UINT8 DefaultMemoryType; - - if (!IsMtrrSupported ()) { - return; - } - - FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount (); - ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); - - mIsFlushingGCD = TRUE; - MemorySpaceMap = NULL; - - // - // Initialize the valid bits mask and valid address mask for MTRRs - // - InitializeMtrrMask (); - - // - // Get the memory attribute of variable MTRRs - // - MtrrGetMemoryAttributeInVariableMtrr ( - mValidMtrrBitsMask, - mValidMtrrAddressMask, - VariableMtrr - ); - - // - // Get the memory space map from GCD - // - Status = gDS->GetMemorySpaceMap ( - &NumberOfDescriptors, - &MemorySpaceMap - ); - ASSERT_EFI_ERROR (Status); - - DefaultMemoryType = (UINT8) MtrrGetDefaultMemoryType (); - DefaultAttributes = GetMemorySpaceAttributeFromMtrrType (DefaultMemoryType); - - // - // Set default attributes to all spaces. - // - for (Index = 0; Index < NumberOfDescriptors; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) { - continue; - } - gDS->SetMemorySpaceAttributes ( - MemorySpaceMap[Index].BaseAddress, - MemorySpaceMap[Index].Length, - (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK) | - (MemorySpaceMap[Index].Capabilities & DefaultAttributes) - ); - } - - // - // Go for variable MTRRs with WB attribute - // - for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && - VariableMtrr[Index].Type == MTRR_CACHE_WRITE_BACK) { - SetGcdMemorySpaceAttributes ( - MemorySpaceMap, - NumberOfDescriptors, - VariableMtrr[Index].BaseAddress, - VariableMtrr[Index].Length, - EFI_MEMORY_WB - ); - } - } - - // - // Go for variable MTRRs with the attribute except for WB and UC attributes - // - for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && - VariableMtrr[Index].Type != MTRR_CACHE_WRITE_BACK && - VariableMtrr[Index].Type != MTRR_CACHE_UNCACHEABLE) { - Attributes = GetMemorySpaceAttributeFromMtrrType ((UINT8) VariableMtrr[Index].Type); - SetGcdMemorySpaceAttributes ( - MemorySpaceMap, - NumberOfDescriptors, - VariableMtrr[Index].BaseAddress, - VariableMtrr[Index].Length, - Attributes - ); - } - } - - // - // Go for variable MTRRs with UC attribute - // - for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && - VariableMtrr[Index].Type == MTRR_CACHE_UNCACHEABLE) { - SetGcdMemorySpaceAttributes ( - MemorySpaceMap, - NumberOfDescriptors, - VariableMtrr[Index].BaseAddress, - VariableMtrr[Index].Length, - EFI_MEMORY_UC - ); - } - } - - // - // Go for fixed MTRRs - // - Attributes = 0; - BaseAddress = 0; - Length = 0; - MtrrGetFixedMtrr (&MtrrFixedSettings); - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - RegValue = MtrrFixedSettings.Mtrr[Index]; - // - // Check for continuous fixed MTRR sections - // - for (SubIndex = 0; SubIndex < 8; SubIndex++) { - MtrrType = (UINT8) RShiftU64 (RegValue, SubIndex * 8); - CurrentAttributes = GetMemorySpaceAttributeFromMtrrType (MtrrType); - if (Length == 0) { - // - // A new MTRR attribute begins - // - Attributes = CurrentAttributes; - } else { - // - // If fixed MTRR attribute changed, then set memory attribute for previous atrribute - // - if (CurrentAttributes != Attributes) { - SetGcdMemorySpaceAttributes ( - MemorySpaceMap, - NumberOfDescriptors, - BaseAddress, - Length, - Attributes - ); - BaseAddress = mFixedMtrrTable[Index].BaseAddress + mFixedMtrrTable[Index].Length * SubIndex; - Length = 0; - Attributes = CurrentAttributes; - } - } - Length += mFixedMtrrTable[Index].Length; - } - } - // - // Handle the last fixed MTRR region - // - SetGcdMemorySpaceAttributes ( - MemorySpaceMap, - NumberOfDescriptors, - BaseAddress, - Length, - Attributes - ); - - // - // Free memory space map allocated by GCD service GetMemorySpaceMap () - // - if (MemorySpaceMap != NULL) { - FreePool (MemorySpaceMap); - } - - mIsFlushingGCD = FALSE; -} - -/** - Initialize Interrupt Descriptor Table for interrupt handling. - -**/ -VOID -InitInterruptDescriptorTable ( - VOID - ) -{ - EFI_STATUS Status; - EFI_VECTOR_HANDOFF_INFO *VectorInfoList; - EFI_VECTOR_HANDOFF_INFO *VectorInfo; - - VectorInfo = NULL; - Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **) &VectorInfoList); - if (Status == EFI_SUCCESS && VectorInfoList != NULL) { - VectorInfo = VectorInfoList; - } - Status = InitializeCpuInterruptHandlers (VectorInfo); - ASSERT_EFI_ERROR (Status); -} - - -/** - Callback function for idle events. - - @param Event Event whose notification function is being invoked. - @param Context The pointer to the notification function's context, - which is implementation-dependent. - -**/ -VOID -EFIAPI -IdleLoopEventCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - CpuSleep (); -} - -/** - Ensure the compatibility of a memory space descriptor with the MMIO aperture. - - The memory space descriptor can come from the GCD memory space map, or it can - represent a gap between two neighboring memory space descriptors. In the - latter case, the GcdMemoryType field is expected to be - EfiGcdMemoryTypeNonExistent. - - If the memory space descriptor already has type - EfiGcdMemoryTypeMemoryMappedIo, and its capabilities are a superset of the - required capabilities, then no action is taken -- it is by definition - compatible with the aperture. - - Otherwise, the intersection of the memory space descriptor is calculated with - the aperture. If the intersection is the empty set (no overlap), no action is - taken; the memory space descriptor is compatible with the aperture. - - Otherwise, the type of the descriptor is investigated again. If the type is - EfiGcdMemoryTypeNonExistent (representing a gap, or a genuine descriptor with - such a type), then an attempt is made to add the intersection as MMIO space - to the GCD memory space map, with the specified capabilities. This ensures - continuity for the aperture, and the descriptor is deemed compatible with the - aperture. - - Otherwise, the memory space descriptor is incompatible with the MMIO - aperture. - - @param[in] Base Base address of the aperture. - @param[in] Length Length of the aperture. - @param[in] Capabilities Capabilities required by the aperture. - @param[in] Descriptor The descriptor to ensure compatibility with the - aperture for. - - @retval EFI_SUCCESS The descriptor is compatible. The GCD memory - space map may have been updated, for - continuity within the aperture. - @retval EFI_INVALID_PARAMETER The descriptor is incompatible. - @return Error codes from gDS->AddMemorySpace(). -**/ -EFI_STATUS -IntersectMemoryDescriptor ( - IN UINT64 Base, - IN UINT64 Length, - IN UINT64 Capabilities, - IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor - ) -{ - UINT64 IntersectionBase; - UINT64 IntersectionEnd; - EFI_STATUS Status; - - if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo && - (Descriptor->Capabilities & Capabilities) == Capabilities) { - return EFI_SUCCESS; - } - - IntersectionBase = MAX (Base, Descriptor->BaseAddress); - IntersectionEnd = MIN (Base + Length, - Descriptor->BaseAddress + Descriptor->Length); - if (IntersectionBase >= IntersectionEnd) { - // - // The descriptor and the aperture don't overlap. - // - return EFI_SUCCESS; - } - - if (Descriptor->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { - Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, - IntersectionBase, IntersectionEnd - IntersectionBase, - Capabilities); - - DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, - "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__, - IntersectionBase, IntersectionEnd, Status)); - return Status; - } - - DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts " - "with aperture [%Lx, %Lx) cap %Lx\n", gEfiCallerBaseName, __FUNCTION__, - Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length, - (UINT32)Descriptor->GcdMemoryType, Descriptor->Capabilities, - Base, Base + Length, Capabilities)); - return EFI_INVALID_PARAMETER; -} - -/** - Add MMIO space to GCD. - The routine checks the GCD database and only adds those which are - not added in the specified range to GCD. - - @param Base Base address of the MMIO space. - @param Length Length of the MMIO space. - @param Capabilities Capabilities of the MMIO space. - - @retval EFI_SUCCES The MMIO space was added successfully. -**/ -EFI_STATUS -AddMemoryMappedIoSpace ( - IN UINT64 Base, - IN UINT64 Length, - IN UINT64 Capabilities - ) -{ - EFI_STATUS Status; - UINTN Index; - UINTN NumberOfDescriptors; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; - - Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return Status; - } - - for (Index = 0; Index < NumberOfDescriptors; Index++) { - Status = IntersectMemoryDescriptor (Base, Length, Capabilities, - &MemorySpaceMap[Index]); - if (EFI_ERROR (Status)) { - goto FreeMemorySpaceMap; - } - } - - DEBUG_CODE ( - // - // Make sure there are adjacent descriptors covering [Base, Base + Length). - // It is possible that they have not been merged; merging can be prevented - // by allocation and different capabilities. - // - UINT64 CheckBase; - EFI_STATUS CheckStatus; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; - - for (CheckBase = Base; - CheckBase < Base + Length; - CheckBase = Descriptor.BaseAddress + Descriptor.Length) { - CheckStatus = gDS->GetMemorySpaceDescriptor (CheckBase, &Descriptor); - ASSERT_EFI_ERROR (CheckStatus); - ASSERT (Descriptor.GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo); - ASSERT ((Descriptor.Capabilities & Capabilities) == Capabilities); - } - ); - -FreeMemorySpaceMap: - FreePool (MemorySpaceMap); - - return Status; -} - -/** - Add and allocate CPU local APIC memory mapped space. - - @param[in]ImageHandle Image handle this driver. - -**/ -VOID -AddLocalApicMemorySpace ( - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS BaseAddress; - - BaseAddress = (EFI_PHYSICAL_ADDRESS) GetLocalApicBaseAddress(); - Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC); - ASSERT_EFI_ERROR (Status); - - // - // Try to allocate APIC memory mapped space, does not check return - // status because it may be allocated by other driver, or DXE Core if - // this range is built into Memory Allocation HOB. - // - Status = gDS->AllocateMemorySpace ( - EfiGcdAllocateAddress, - EfiGcdMemoryTypeMemoryMappedIo, - 0, - SIZE_4KB, - &BaseAddress, - ImageHandle, - NULL - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: %a: AllocateMemorySpace() Status - %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - } -} - -/** - Initialize the state information for the CPU Architectural Protocol. - - @param ImageHandle Image handle this driver. - @param SystemTable Pointer to the System Table. - - @retval EFI_SUCCESS Thread can be successfully created - @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure - @retval EFI_DEVICE_ERROR Cannot create the thread - -**/ -EFI_STATUS -EFIAPI -InitializeCpu ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_EVENT IdleLoopEvent; - - InitializePageTableLib(); - - InitializeFloatingPointUnits (); - - // - // Make sure interrupts are disabled - // - DisableInterrupts (); - - // - // Init GDT for DXE - // - InitGlobalDescriptorTable (); - - // - // Setup IDT pointer, IDT and interrupt entry points - // - InitInterruptDescriptorTable (); - - // - // Enable the local APIC for Virtual Wire Mode. - // - ProgramVirtualWireMode (); - - // - // Install CPU Architectural Protocol - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mCpuHandle, - &gEfiCpuArchProtocolGuid, &gCpu, - NULL - ); - ASSERT_EFI_ERROR (Status); - - // - // Refresh GCD memory space map according to MTRR value. - // - RefreshGcdMemoryAttributes (); - - // - // Add and allocate local APIC memory mapped space - // - AddLocalApicMemorySpace (ImageHandle); - - // - // Setup a callback for idle events - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - IdleLoopEventCallback, - NULL, - &gIdleLoopEventGuid, - &IdleLoopEvent - ); - ASSERT_EFI_ERROR (Status); - - InitializeMpSupport (); - - return Status; -} - diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h deleted file mode 100644 index 27ad45bf9b..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuDxe.h +++ /dev/null @@ -1,264 +0,0 @@ -/** @file - CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol. - - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_DXE_H_ -#define _CPU_DXE_H_ - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \ - EFI_MEMORY_WC | \ - EFI_MEMORY_WT | \ - EFI_MEMORY_WB | \ - EFI_MEMORY_UCE \ - ) - - -/** - Flush CPU data cache. If the instruction cache is fully coherent - with all DMA operations then function can just return EFI_SUCCESS. - - @param This Protocol instance structure - @param Start Physical address to start flushing from. - @param Length Number of bytes to flush. Round up to chipset - granularity. - @param FlushType Specifies the type of flush operation to perform. - - @retval EFI_SUCCESS If cache was flushed - @retval EFI_UNSUPPORTED If flush type is not supported. - @retval EFI_DEVICE_ERROR If requested range could not be flushed. - -**/ -EFI_STATUS -EFIAPI -CpuFlushCpuDataCache ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length, - IN EFI_CPU_FLUSH_TYPE FlushType - ); - -/** - Enables CPU interrupts. - - @param This Protocol instance structure - - @retval EFI_SUCCESS If interrupts were enabled in the CPU - @retval EFI_DEVICE_ERROR If interrupts could not be enabled on the CPU. - -**/ -EFI_STATUS -EFIAPI -CpuEnableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ); - -/** - Disables CPU interrupts. - - @param This Protocol instance structure - - @retval EFI_SUCCESS If interrupts were disabled in the CPU. - @retval EFI_DEVICE_ERROR If interrupts could not be disabled on the CPU. - -**/ -EFI_STATUS -EFIAPI -CpuDisableInterrupt ( - IN EFI_CPU_ARCH_PROTOCOL *This - ); - -/** - Return the state of interrupts. - - @param This Protocol instance structure - @param State Pointer to the CPU's current interrupt state - - @retval EFI_SUCCESS If interrupts were disabled in the CPU. - @retval EFI_INVALID_PARAMETER State is NULL. - -**/ -EFI_STATUS -EFIAPI -CpuGetInterruptState ( - IN EFI_CPU_ARCH_PROTOCOL *This, - OUT BOOLEAN *State - ); - -/** - Generates an INIT to the CPU. - - @param This Protocol instance structure - @param InitType Type of CPU INIT to perform - - @retval EFI_SUCCESS If CPU INIT occurred. This value should never be - seen. - @retval EFI_DEVICE_ERROR If CPU INIT failed. - @retval EFI_UNSUPPORTED Requested type of CPU INIT not supported. - -**/ -EFI_STATUS -EFIAPI -CpuInit ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_CPU_INIT_TYPE InitType - ); - -/** - Registers a function to be called from the CPU interrupt handler. - - @param This Protocol instance structure - @param InterruptType Defines which interrupt to hook. IA-32 - valid range is 0x00 through 0xFF - @param InterruptHandler A pointer to a function of type - EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. A null - pointer is an error condition. - - @retval EFI_SUCCESS If handler installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler - for InterruptType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for - InterruptType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType - is not supported. - -**/ -EFI_STATUS -EFIAPI -CpuRegisterInterruptHandler ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ); - -/** - Returns a timer value from one of the CPU's internal timers. There is no - inherent time interval between ticks but is a function of the CPU frequency. - - @param This - Protocol instance structure. - @param TimerIndex - Specifies which CPU timer is requested. - @param TimerValue - Pointer to the returned timer value. - @param TimerPeriod - A pointer to the amount of time that passes - in femtoseconds (10-15) for each increment - of TimerValue. If TimerValue does not - increment at a predictable rate, then 0 is - returned. The amount of time that has - passed between two calls to GetTimerValue() - can be calculated with the formula - (TimerValue2 - TimerValue1) * TimerPeriod. - This parameter is optional and may be NULL. - - @retval EFI_SUCCESS - If the CPU timer count was returned. - @retval EFI_UNSUPPORTED - If the CPU does not have any readable timers. - @retval EFI_DEVICE_ERROR - If an error occurred while reading the timer. - @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL. - -**/ -EFI_STATUS -EFIAPI -CpuGetTimerValue ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN UINT32 TimerIndex, - OUT UINT64 *TimerValue, - OUT UINT64 *TimerPeriod OPTIONAL - ); - -/** - Set memory cacheability attributes for given range of memeory. - - @param This Protocol instance structure - @param BaseAddress Specifies the start address of the - memory range - @param Length Specifies the length of the memory range - @param Attributes The memory cacheability for the memory range - - @retval EFI_SUCCESS If the cacheability of that memory range is - set successfully - @retval EFI_UNSUPPORTED If the desired operation cannot be done - @retval EFI_INVALID_PARAMETER The input parameter is not correct, - such as Length = 0 - -**/ -EFI_STATUS -EFIAPI -CpuSetMemoryAttributes ( - IN EFI_CPU_ARCH_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ); - -/** - Initialize Global Descriptor Table. - -**/ -VOID -InitGlobalDescriptorTable ( - VOID - ); - -/** - Sets the code selector (CS). - - @param Selector Value of code selector. - -**/ -VOID -EFIAPI -SetCodeSelector ( - UINT16 Selector - ); - -/** - Sets the data selector (DS). - - @param Selector Value of data selector. - -**/ -VOID -EFIAPI -SetDataSelectors ( - UINT16 Selector - ); - -#endif - diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf deleted file mode 100644 index 3e8d196739..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuDxe.inf +++ /dev/null @@ -1,89 +0,0 @@ -## @file -# CPU driver installs CPU Architecture Protocol and CPU MP protocol. -# -# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuDxe - MODULE_UNI_FILE = CpuDxe.uni - FILE_GUID = 1A1E4886-9517-440e-9FDE-3BE44CEE2136 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = InitializeCpu - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - CpuLib - DebugLib - DxeServicesTableLib - MemoryAllocationLib - MtrrLib - UefiBootServicesTableLib - UefiDriverEntryPoint - LocalApicLib - UefiCpuLib - UefiLib - CpuExceptionHandlerLib - HobLib - ReportStatusCodeLib - MpInitLib - TimerLib - -[Sources] - CpuDxe.c - CpuDxe.h - CpuGdt.c - CpuGdt.h - CpuMp.c - CpuMp.h - CpuPageTable.h - CpuPageTable.c - -[Sources.IA32] - Ia32/CpuAsm.asm - Ia32/CpuAsm.nasm - Ia32/CpuAsm.S - -[Sources.X64] - X64/CpuAsm.asm - X64/CpuAsm.nasm - X64/CpuAsm.S - -[Protocols] - gEfiCpuArchProtocolGuid ## PRODUCES - gEfiMpServiceProtocolGuid ## PRODUCES - -[Guids] - gIdleLoopEventGuid ## CONSUMES ## Event - gEfiVectorHandoffTableGuid ## SOMETIMES_CONSUMES ## SystemTable - -[Ppis] - gEfiSecPlatformInformation2PpiGuid ## UNDEFINED # HOB - gEfiSecPlatformInformationPpiGuid ## UNDEFINED # HOB - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuDxeExtra.uni diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.uni b/UefiCpuPkg/CpuDxe/CpuDxe.uni deleted file mode 100644 index caf01dcbf5..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuDxe.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU driver installs CPU Architecture Protocol and CPU MP Protocol. -// -// CPU driver installs CPU Architecture Protocol and CPU MP Protocol. -// -// Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU Architecture Protocol and CPU MP Protocol." - diff --git a/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni b/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni deleted file mode 100644 index c1d201911c..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuDxe Localized Strings and Content -// -// Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU Architectural and CPU Multi-processor DXE Driver" - - diff --git a/UefiCpuPkg/CpuDxe/CpuGdt.c b/UefiCpuPkg/CpuDxe/CpuGdt.c deleted file mode 100644 index 9ef2fdfefb..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuGdt.c +++ /dev/null @@ -1,161 +0,0 @@ -/** @file - C based implemention of IA32 interrupt handling only - requiring a minimal assembly interrupt entry point. - - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuDxe.h" -#include "CpuGdt.h" - -// -// Global descriptor table (GDT) Template -// -STATIC GDT_ENTRIES GdtTemplate = { - // - // NULL_SEL - // - { - 0x0, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x0, // type - 0x0, // limit 19:16, flags - 0x0, // base 31:24 - }, - // - // LINEAR_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x092, // present, ring 0, data, read/write - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // LINEAR_CODE_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x09F, // present, ring 0, code, execute/read, conforming, accessed - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // SYS_DATA_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x093, // present, ring 0, data, read/write, accessed - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // SYS_CODE_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x09A, // present, ring 0, code, execute/read - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // SPARE4_SEL - // - { - 0x0, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x0, // type - 0x0, // limit 19:16, flags - 0x0, // base 31:24 - }, - // - // LINEAR_DATA64_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x092, // present, ring 0, data, read/write - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // LINEAR_CODE64_SEL - // - { - 0x0FFFF, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x09A, // present, ring 0, code, execute/read - 0x0AF, // page-granular, 64-bit code - 0x0, // base (high) - }, - // - // SPARE5_SEL - // - { - 0x0, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x0, // type - 0x0, // limit 19:16, flags - 0x0, // base 31:24 - }, -}; - -/** - Initialize Global Descriptor Table. - -**/ -VOID -InitGlobalDescriptorTable ( - VOID - ) -{ - GDT_ENTRIES *gdt; - IA32_DESCRIPTOR gdtPtr; - - // - // Allocate Runtime Data for the GDT - // - gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); - ASSERT (gdt != NULL); - gdt = ALIGN_POINTER (gdt, 8); - - // - // Initialize all GDT entries - // - CopyMem (gdt, &GdtTemplate, sizeof (GdtTemplate)); - - // - // Write GDT register - // - gdtPtr.Base = (UINT32)(UINTN)(VOID*) gdt; - gdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1); - AsmWriteGdtr (&gdtPtr); - - // - // Update selector (segment) registers base on new GDT - // - SetCodeSelector ((UINT16)CPU_CODE_SEL); - SetDataSelectors ((UINT16)CPU_DATA_SEL); -} - diff --git a/UefiCpuPkg/CpuDxe/CpuGdt.h b/UefiCpuPkg/CpuDxe/CpuGdt.h deleted file mode 100644 index 2a00751602..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuGdt.h +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - C based implemention of IA32 interrupt handling only - requiring a minimal assembly interrupt entry point. - - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_GDT_H_ -#define _CPU_GDT_H_ - -// -// Local structure definitions -// - -#pragma pack (1) - -// -// Global Descriptor Entry structures -// - -typedef struct _GDT_ENTRY { - UINT16 Limit15_0; - UINT16 Base15_0; - UINT8 Base23_16; - UINT8 Type; - UINT8 Limit19_16_and_flags; - UINT8 Base31_24; -} GDT_ENTRY; - -typedef -struct _GDT_ENTRIES { - GDT_ENTRY Null; - GDT_ENTRY Linear; - GDT_ENTRY LinearCode; - GDT_ENTRY SysData; - GDT_ENTRY SysCode; - GDT_ENTRY Spare4; - GDT_ENTRY LinearData64; - GDT_ENTRY LinearCode64; - GDT_ENTRY Spare5; -} GDT_ENTRIES; - -#pragma pack () - -#define NULL_SEL OFFSET_OF (GDT_ENTRIES, Null) -#define LINEAR_SEL OFFSET_OF (GDT_ENTRIES, Linear) -#define LINEAR_CODE_SEL OFFSET_OF (GDT_ENTRIES, LinearCode) -#define SYS_DATA_SEL OFFSET_OF (GDT_ENTRIES, SysData) -#define SYS_CODE_SEL OFFSET_OF (GDT_ENTRIES, SysCode) -#define SPARE4_SEL OFFSET_OF (GDT_ENTRIES, Spare4) -#define LINEAR_DATA64_SEL OFFSET_OF (GDT_ENTRIES, LinearData64) -#define LINEAR_CODE64_SEL OFFSET_OF (GDT_ENTRIES, LinearCode64) -#define SPARE5_SEL OFFSET_OF (GDT_ENTRIES, Spare5) - -#if defined (MDE_CPU_IA32) -#define CPU_CODE_SEL LINEAR_CODE_SEL -#define CPU_DATA_SEL LINEAR_SEL -#elif defined (MDE_CPU_X64) -#define CPU_CODE_SEL LINEAR_CODE64_SEL -#define CPU_DATA_SEL LINEAR_DATA64_SEL -#else -#error CPU type not supported for CPU GDT initialization! -#endif - -#endif // _CPU_GDT_H_ - diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c deleted file mode 100644 index 44569466d3..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ /dev/null @@ -1,639 +0,0 @@ -/** @file - CPU DXE Module to produce CPU MP Protocol. - - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuDxe.h" -#include "CpuMp.h" - -EFI_HANDLE mMpServiceHandle = NULL; -UINTN mNumberOfProcessors = 1; - -EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { - GetNumberOfProcessors, - GetProcessorInfo, - StartupAllAPs, - StartupThisAP, - SwitchBSP, - EnableDisableAP, - WhoAmI -}; - -/** - This service retrieves the number of logical processor in the platform - and the number of those logical processors that are enabled on this boot. - This service may only be called from the BSP. - - This function is used to retrieve the following information: - - The number of logical processors that are present in the system. - - The number of enabled logical processors in the system at the instant - this call is made. - - Because MP Service Protocol provides services to enable and disable processors - dynamically, the number of enabled logical processors may vary during the - course of a boot session. - - If this service is called from an AP, then EFI_DEVICE_ERROR is returned. - If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then - EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors - is returned in NumberOfProcessors, the number of currently enabled processor - is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. - @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL. - -**/ -EFI_STATUS -EFIAPI -GetNumberOfProcessors ( - IN EFI_MP_SERVICES_PROTOCOL *This, - OUT UINTN *NumberOfProcessors, - OUT UINTN *NumberOfEnabledProcessors - ) -{ - if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) { - return EFI_INVALID_PARAMETER; - } - - return MpInitLibGetNumberOfProcessors ( - NumberOfProcessors, - NumberOfEnabledProcessors - ); -} - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - This service retrieves detailed MP-related information about any processor - on the platform. Note the following: - - The processor information may change during the course of a boot session. - - The information presented here is entirely MP related. - - Information regarding the number of caches and their sizes, frequency of operation, - slot numbers is all considered platform-related information and is not provided - by this service. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - -**/ -EFI_STATUS -EFIAPI -GetProcessorInfo ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ) -{ - return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL); -} - -/** - This service executes a caller provided function on all enabled APs. APs can - run either simultaneously or one at a time in sequence. This service supports - both blocking and non-blocking requests. The non-blocking requests use EFI - events so the BSP can detect when the APs have finished. This service may only - be called from the BSP. - - This function is used to dispatch all the enabled APs to the function specified - by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned - immediately and Procedure is not started on any AP. - - If SingleThread is TRUE, all the enabled APs execute the function specified by - Procedure one by one, in ascending order of processor handle number. Otherwise, - all the enabled APs execute the function specified by Procedure simultaneously. - - If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all - APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking - mode, and the BSP returns from this service without waiting for APs. If a - non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT - is signaled, then EFI_UNSUPPORTED must be returned. - - If the timeout specified by TimeoutInMicroseconds expires before all APs return - from Procedure, then Procedure on the failed APs is terminated. All enabled APs - are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its - content points to the list of processor handle numbers in which Procedure was - terminated. - - Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - to make sure that the nature of the code that is executed on the BSP and the - dispatched APs is well controlled. The MP Services Protocol does not guarantee - that the Procedure function is MP-safe. Hence, the tasks that can be run in - parallel are limited to certain independent tasks and well-controlled exclusive - code. EFI services and protocols may not be called by APs unless otherwise - specified. - - In blocking execution mode, BSP waits until all APs finish or - TimeoutInMicroseconds expires. - - In non-blocking execution mode, BSP is freed to return to the caller and then - proceed to the next task without having to wait for APs. The following - sequence needs to occur in a non-blocking execution mode: - - -# The caller that intends to use this MP Services Protocol in non-blocking - mode creates WaitEvent by calling the EFI CreateEvent() service. The caller - invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent - is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests - the function specified by Procedure to be started on all the enabled APs, - and releases the BSP to continue with other tasks. - -# The caller can use the CheckEvent() and WaitForEvent() services to check - the state of the WaitEvent created in step 1. - -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP - Service signals WaitEvent by calling the EFI SignalEvent() function. If - FailedCpuList is not NULL, its content is available when WaitEvent is - signaled. If all APs returned from Procedure prior to the timeout, then - FailedCpuList is set to NULL. If not all APs return from Procedure before - the timeout, then FailedCpuList is filled in with the list of the failed - APs. The buffer is allocated by MP Service Protocol using AllocatePool(). - It is the caller's responsibility to free the buffer with FreePool() service. - -# This invocation of SignalEvent() function informs the caller that invoked - EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed - the specified task or a timeout occurred. The contents of FailedCpuList - can be examined to determine which APs did not complete the specified task - prior to the timeout. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroseconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure, or TimeoutInMicroseconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, - if all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - The buffer is allocated by MP Service Protocol, - and it's the caller's responsibility to - free the buffer with FreePool() service. - In blocking mode, it is ready for consumption - when the call returns. In non-blocking mode, - it is ready when WaitEvent is signaled. The - list of failed CPU is terminated by - END_OF_CPU_LIST. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - all enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -StartupAllAPs ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ) -{ - return MpInitLibStartupAllAPs ( - Procedure, - SingleThread, - WaitEvent, - TimeoutInMicroseconds, - ProcedureArgument, - FailedCpuList - ); -} - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. The caller can request the BSP to either wait for the completion - of the AP or just proceed with the next task by using the EFI event mechanism. - See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking - execution support. This service may only be called from the BSP. - - This function is used to dispatch one enabled AP to the function specified by - Procedure passing in the argument specified by ProcedureArgument. If WaitEvent - is NULL, execution is in blocking mode. The BSP waits until the AP finishes or - TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. - BSP proceeds to the next task without waiting for the AP. If a non-blocking mode - is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, - then EFI_UNSUPPORTED must be returned. - - If the timeout specified by TimeoutInMicroseconds expires before the AP returns - from Procedure, then execution of Procedure by the AP is terminated. The AP is - available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and - EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] Procedure A pointer to the function to be run on the - designated AP of the system. See type - EFI_AP_PROCEDURE. - @param[in] ProcessorNumber The handle number of the AP. The range is - from 0 to the total number of logical - processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until this AP finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on this AP, - and go on executing immediately. If this AP - return from Procedure or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - this AP to finish this Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - this AP returns from Procedure, then Procedure - on the AP is terminated. The - AP is available for next function assigned - by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure on the - specified AP. - @param[out] Finished If NULL, this parameter is ignored. In - blocking mode, this parameter is ignored. - In non-blocking mode, if AP returns from - Procedure before the timeout expires, its - content is set to TRUE. Otherwise, the - value is set to FALSE. The caller can - determine if the AP returned from Procedure - by evaluating this value. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval EFI_SUCCESS In non-blocking mode, the function has been - dispatched to specified AP. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - the specified AP has finished. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -StartupThisAP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ) -{ - return MpInitLibStartupThisAP ( - Procedure, - ProcessorNumber, - WaitEvent, - TimeoutInMicroseconds, - ProcedureArgument, - Finished - ); -} - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. The new BSP can take over the - execution of the old BSP and continue seamlessly from where the old one left - off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT - is signaled. - - If the BSP cannot be switched prior to the return from this service, then - EFI_UNSUPPORTED must be returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_SUCCESS The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - -**/ -EFI_STATUS -EFIAPI -SwitchBSP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ) -{ - return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); -} - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - This service allows the caller enable or disable an AP from this point onward. - The caller can optionally specify the health status of the AP by Health. If - an AP is being disabled, then the state of the disabled AP is implementation - dependent. If an AP is enabled, then the implementation must guarantee that a - complete initialization sequence is performed on the AP, so the AP is in a state - that is compatible with an MP operating system. This service may not be supported - after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. - - If the enable or disable AP operation cannot be completed prior to the return - from this service, then EFI_UNSUPPORTED must be returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. This flag - corresponds to StatusFlag defined in - EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only - the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter - is ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed - prior to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. - -**/ -EFI_STATUS -EFIAPI -EnableDisableAP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ) -{ - return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); -} - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - This service returns the processor handle number for the calling processor. - The returned value is in the range from 0 to the total number of logical - processors minus 1. The total number of logical processors can be retrieved - with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be - called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER - is returned. Otherwise, the current processors handle number is returned in - ProcessorNumber, and EFI_SUCCESS is returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[out] ProcessorNumber Pointer to the handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - -**/ -EFI_STATUS -EFIAPI -WhoAmI ( - IN EFI_MP_SERVICES_PROTOCOL *This, - OUT UINTN *ProcessorNumber - ) -{ - return MpInitLibWhoAmI (ProcessorNumber);; -} - -/** - Collects BIST data from HOB. - - This function collects BIST data from HOB built from Sec Platform Information - PPI or SEC Platform Information2 PPI. - -**/ -VOID -CollectBistDataFromHob ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; - EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation; - UINTN NumberOfData; - EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; - EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance; - UINTN ProcessorNumber; - EFI_PROCESSOR_INFORMATION ProcessorInfo; - EFI_HEALTH_FLAGS BistData; - UINTN CpuInstanceNumber; - - SecPlatformInformation2 = NULL; - SecPlatformInformation = NULL; - - // - // Get gEfiSecPlatformInformation2PpiGuid Guided HOB firstly - // - GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); - if (GuidHob != NULL) { - // - // Sec Platform Information2 PPI includes BSP/APs' BIST information - // - SecPlatformInformation2 = GET_GUID_HOB_DATA (GuidHob); - NumberOfData = SecPlatformInformation2->NumberOfCpus; - CpuInstance = SecPlatformInformation2->CpuInstance; - } else { - // - // Otherwise, get gEfiSecPlatformInformationPpiGuid Guided HOB - // - GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid); - if (GuidHob != NULL) { - SecPlatformInformation = GET_GUID_HOB_DATA (GuidHob); - NumberOfData = 1; - // - // SEC Platform Information only includes BSP's BIST information - // does not have BSP's APIC ID - // - BspCpuInstance.CpuLocation = GetApicId (); - BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32; - CpuInstance = &BspCpuInstance; - } else { - DEBUG ((DEBUG_INFO, "Does not find any HOB stored CPU BIST information!\n")); - // - // Does not find any HOB stored BIST information - // - return; - } - } - - for (ProcessorNumber = 0; ProcessorNumber < mNumberOfProcessors; ProcessorNumber++) { - MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData); - for (CpuInstanceNumber = 0; CpuInstanceNumber < NumberOfData; CpuInstanceNumber++) { - if (ProcessorInfo.ProcessorId == CpuInstance[CpuInstanceNumber].CpuLocation) { - // - // Update CPU health status for MP Services Protocol according to BIST data. - // - BistData = CpuInstance[CpuInstanceNumber].InfoRecord.IA32HealthFlags; - } - } - if (BistData.Uint32 != 0) { - // - // Report Status Code that self test is failed - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST) - ); - } - } -} - -/** - Initialize Multi-processor support. - -**/ -VOID -InitializeMpSupport ( - VOID - ) -{ - EFI_STATUS Status; - UINTN NumberOfProcessors; - UINTN NumberOfEnabledProcessors; - - // - // Wakeup APs to do initialization - // - Status = MpInitLibInitialize (); - ASSERT_EFI_ERROR (Status); - - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); - mNumberOfProcessors = NumberOfProcessors; - DEBUG ((DEBUG_ERROR, "Detect CPU count: %d\n", mNumberOfProcessors)); - - // - // Update CPU healthy information from Guided HOB - // - CollectBistDataFromHob (); - - Status = gBS->InstallMultipleProtocolInterfaces ( - &mMpServiceHandle, - &gEfiMpServiceProtocolGuid, &mMpServicesTemplate, - NULL - ); - ASSERT_EFI_ERROR (Status); -} - diff --git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h deleted file mode 100644 index 43ec3bdd0b..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuMp.h +++ /dev/null @@ -1,476 +0,0 @@ -/** @file - CPU DXE MP support - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_MP_H_ -#define _CPU_MP_H_ - -/** - Initialize Multi-processor support. - -**/ -VOID -InitializeMpSupport ( - VOID - ); - -/** - This service retrieves the number of logical processor in the platform - and the number of those logical processors that are enabled on this boot. - This service may only be called from the BSP. - - This function is used to retrieve the following information: - - The number of logical processors that are present in the system. - - The number of enabled logical processors in the system at the instant - this call is made. - - Because MP Service Protocol provides services to enable and disable processors - dynamically, the number of enabled logical processors may vary during the - course of a boot session. - - If this service is called from an AP, then EFI_DEVICE_ERROR is returned. - If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then - EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors - is returned in NumberOfProcessors, the number of currently enabled processor - is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. - @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL. - -**/ -EFI_STATUS -EFIAPI -GetNumberOfProcessors ( - IN EFI_MP_SERVICES_PROTOCOL *This, - OUT UINTN *NumberOfProcessors, - OUT UINTN *NumberOfEnabledProcessors - ); - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - This service retrieves detailed MP-related information about any processor - on the platform. Note the following: - - The processor information may change during the course of a boot session. - - The information presented here is entirely MP related. - - Information regarding the number of caches and their sizes, frequency of operation, - slot numbers is all considered platform-related information and is not provided - by this service. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - -**/ -EFI_STATUS -EFIAPI -GetProcessorInfo ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ); - -/** - This service executes a caller provided function on all enabled APs. APs can - run either simultaneously or one at a time in sequence. This service supports - both blocking and non-blocking requests. The non-blocking requests use EFI - events so the BSP can detect when the APs have finished. This service may only - be called from the BSP. - - This function is used to dispatch all the enabled APs to the function specified - by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned - immediately and Procedure is not started on any AP. - - If SingleThread is TRUE, all the enabled APs execute the function specified by - Procedure one by one, in ascending order of processor handle number. Otherwise, - all the enabled APs execute the function specified by Procedure simultaneously. - - If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all - APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking - mode, and the BSP returns from this service without waiting for APs. If a - non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT - is signaled, then EFI_UNSUPPORTED must be returned. - - If the timeout specified by TimeoutInMicroseconds expires before all APs return - from Procedure, then Procedure on the failed APs is terminated. All enabled APs - are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its - content points to the list of processor handle numbers in which Procedure was - terminated. - - Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - to make sure that the nature of the code that is executed on the BSP and the - dispatched APs is well controlled. The MP Services Protocol does not guarantee - that the Procedure function is MP-safe. Hence, the tasks that can be run in - parallel are limited to certain independent tasks and well-controlled exclusive - code. EFI services and protocols may not be called by APs unless otherwise - specified. - - In blocking execution mode, BSP waits until all APs finish or - TimeoutInMicroseconds expires. - - In non-blocking execution mode, BSP is freed to return to the caller and then - proceed to the next task without having to wait for APs. The following - sequence needs to occur in a non-blocking execution mode: - - -# The caller that intends to use this MP Services Protocol in non-blocking - mode creates WaitEvent by calling the EFI CreateEvent() service. The caller - invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent - is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests - the function specified by Procedure to be started on all the enabled APs, - and releases the BSP to continue with other tasks. - -# The caller can use the CheckEvent() and WaitForEvent() services to check - the state of the WaitEvent created in step 1. - -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP - Service signals WaitEvent by calling the EFI SignalEvent() function. If - FailedCpuList is not NULL, its content is available when WaitEvent is - signaled. If all APs returned from Procedure prior to the timeout, then - FailedCpuList is set to NULL. If not all APs return from Procedure before - the timeout, then FailedCpuList is filled in with the list of the failed - APs. The buffer is allocated by MP Service Protocol using AllocatePool(). - It is the caller's responsibility to free the buffer with FreePool() service. - -# This invocation of SignalEvent() function informs the caller that invoked - EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed - the specified task or a timeout occurred. The contents of FailedCpuList - can be examined to determine which APs did not complete the specified task - prior to the timeout. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroseconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure, or TimeoutInMicroseconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, - if all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - The buffer is allocated by MP Service Protocol, - and it's the caller's responsibility to - free the buffer with FreePool() service. - In blocking mode, it is ready for consumption - when the call returns. In non-blocking mode, - it is ready when WaitEvent is signaled. The - list of failed CPU is terminated by - END_OF_CPU_LIST. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - all enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -StartupAllAPs ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ); - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. The caller can request the BSP to either wait for the completion - of the AP or just proceed with the next task by using the EFI event mechanism. - See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking - execution support. This service may only be called from the BSP. - - This function is used to dispatch one enabled AP to the function specified by - Procedure passing in the argument specified by ProcedureArgument. If WaitEvent - is NULL, execution is in blocking mode. The BSP waits until the AP finishes or - TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. - BSP proceeds to the next task without waiting for the AP. If a non-blocking mode - is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, - then EFI_UNSUPPORTED must be returned. - - If the timeout specified by TimeoutInMicroseconds expires before the AP returns - from Procedure, then execution of Procedure by the AP is terminated. The AP is - available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and - EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL - instance. - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] ProcessorNumber The handle number of the AP. The range is - from 0 to the total number of logical - processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroseconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure or TimeoutInMicroseconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() - or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] Finished If NULL, this parameter is ignored. In - blocking mode, this parameter is ignored. - In non-blocking mode, if AP returns from - Procedure before the timeout expires, its - content is set to TRUE. Otherwise, the - value is set to FALSE. The caller can - determine if the AP returned from Procedure - by evaluating this value. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval EFI_SUCCESS In non-blocking mode, the function has been - dispatched to specified AP. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - the specified AP has finished. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -StartupThisAP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ); - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. The new BSP can take over the - execution of the old BSP and continue seamlessly from where the old one left - off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT - is signaled. - - If the BSP cannot be switched prior to the return from this service, then - EFI_UNSUPPORTED must be returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_SUCCESS The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - -**/ -EFI_STATUS -EFIAPI -SwitchBSP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ); - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - This service allows the caller enable or disable an AP from this point onward. - The caller can optionally specify the health status of the AP by Health. If - an AP is being disabled, then the state of the disabled AP is implementation - dependent. If an AP is enabled, then the implementation must guarantee that a - complete initialization sequence is performed on the AP, so the AP is in a state - that is compatible with an MP operating system. This service may not be supported - after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. - - If the enable or disable AP operation cannot be completed prior to the return - from this service, then EFI_UNSUPPORTED must be returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. This flag - corresponds to StatusFlag defined in - EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only - the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter - is ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed - prior to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. - -**/ -EFI_STATUS -EFIAPI -EnableDisableAP ( - IN EFI_MP_SERVICES_PROTOCOL *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ); - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - This service returns the processor handle number for the calling processor. - The returned value is in the range from 0 to the total number of logical - processors minus 1. The total number of logical processors can be retrieved - with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be - called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER - is returned. Otherwise, the current processors handle number is returned in - ProcessorNumber, and EFI_SUCCESS is returned. - - @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. - @param[out] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - -**/ -EFI_STATUS -EFIAPI -WhoAmI ( - IN EFI_MP_SERVICES_PROTOCOL *This, - OUT UINTN *ProcessorNumber - ); - -#endif // _CPU_MP_H_ - diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c deleted file mode 100644 index 2c61e7503e..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ /dev/null @@ -1,788 +0,0 @@ -/** @file - Page table management support. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- Copyright (c) 2017, AMD Incorporated. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "CpuPageTable.h" - -/// -/// Page Table Entry -/// -#define IA32_PG_P BIT0 -#define IA32_PG_RW BIT1 -#define IA32_PG_U BIT2 -#define IA32_PG_WT BIT3 -#define IA32_PG_CD BIT4 -#define IA32_PG_A BIT5 -#define IA32_PG_D BIT6 -#define IA32_PG_PS BIT7 -#define IA32_PG_PAT_2M BIT12 -#define IA32_PG_PAT_4K IA32_PG_PS -#define IA32_PG_PMNT BIT62 -#define IA32_PG_NX BIT63 - -#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P) -// -// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE -// X64 PAE PDPTE does not have such restriction -// -#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) - -#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS) - -#define PAGING_4K_MASK 0xFFF -#define PAGING_2M_MASK 0x1FFFFF -#define PAGING_1G_MASK 0x3FFFFFFF - -#define PAGING_PAE_INDEX_MASK 0x1FF - -#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull -#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull -#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull - -typedef enum { - PageNone, - Page4K, - Page2M, - Page1G, -} PAGE_ATTRIBUTE; - -typedef struct { - PAGE_ATTRIBUTE Attribute; - UINT64 Length; - UINT64 AddressMask; -} PAGE_ATTRIBUTE_TABLE; - -typedef enum { - PageActionAssign, - PageActionSet, - PageActionClear, -} PAGE_ACTION; - -PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = { - {Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64}, - {Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64}, - {Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64}, -}; - -/** - Enable write protection function for AP. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -SyncCpuEnableWriteProtection ( - IN OUT VOID *Buffer - ) -{ - AsmWriteCr0 (AsmReadCr0 () | BIT16); -} - -/** - CpuFlushTlb function for AP. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -SyncCpuFlushTlb ( - IN OUT VOID *Buffer - ) -{ - CpuFlushTlb(); -} - -/** - Sync memory page attributes for AP. - - @param[in] Procedure A pointer to the function to be run on enabled APs of - the system. -**/ -VOID -SyncMemoryPageAttributesAp ( - IN EFI_AP_PROCEDURE Procedure - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpService; - - Status = gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&MpService - ); - // - // Synchronize the update with all APs - // - if (!EFI_ERROR (Status)) { - Status = MpService->StartupAllAPs ( - MpService, // This - Procedure, // Procedure - FALSE, // SingleThread - NULL, // WaitEvent - 0, // TimeoutInMicrosecsond - NULL, // ProcedureArgument - NULL // FailedCpuList - ); - ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_STARTED || Status == EFI_NOT_READY); - } -} - -/** - Return current paging context. - - @param[in,out] PagingContext The paging context. -**/ -VOID -GetCurrentPagingContext ( - IN OUT PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext - ) -{ - UINT32 RegEax; - UINT32 RegEdx; - - ZeroMem(PagingContext, sizeof(*PagingContext)); - if (sizeof(UINTN) == sizeof(UINT64)) { - PagingContext->MachineType = IMAGE_FILE_MACHINE_X64; - } else { - PagingContext->MachineType = IMAGE_FILE_MACHINE_I386; - } - if ((AsmReadCr0 () & BIT31) != 0) { - PagingContext->ContextData.X64.PageTableBase = (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64); - if ((AsmReadCr0 () & BIT16) == 0) { - AsmWriteCr0 (AsmReadCr0 () | BIT16); - SyncMemoryPageAttributesAp (SyncCpuEnableWriteProtection); - } - } else { - PagingContext->ContextData.X64.PageTableBase = 0; - } - - if ((AsmReadCr4 () & BIT4) != 0) { - PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE; - } - if ((AsmReadCr4 () & BIT5) != 0) { - PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE; - } - if ((AsmReadCr0 () & BIT16) != 0) { - PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE; - } - - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax > 0x80000000) { - AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT20) != 0) { - // XD supported - if ((AsmReadMsr64 (0xC0000080) & BIT11) != 0) { - // XD activated - PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED; - } - } - if ((RegEdx & BIT26) != 0) { - PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT; - } - } -} - -/** - Return length according to page attributes. - - @param[in] PageAttributes The page attribute of the page entry. - - @return The length of page entry. -**/ -UINTN -PageAttributeToLength ( - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINTN Index; - for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { - if (PageAttribute == mPageAttributeTable[Index].Attribute) { - return (UINTN)mPageAttributeTable[Index].Length; - } - } - return 0; -} - -/** - Return address mask according to page attributes. - - @param[in] PageAttributes The page attribute of the page entry. - - @return The address mask of page entry. -**/ -UINTN -PageAttributeToMask ( - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINTN Index; - for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { - if (PageAttribute == mPageAttributeTable[Index].Attribute) { - return (UINTN)mPageAttributeTable[Index].AddressMask; - } - } - return 0; -} - -/** - Return page table entry to match the address. - - @param[in] PagingContext The paging context. - @param[in] Address The address to be checked. - @param[out] PageAttributes The page attribute of the page entry. - - @return The page entry. -**/ -VOID * -GetPageTableEntry ( - IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, - IN PHYSICAL_ADDRESS Address, - OUT PAGE_ATTRIBUTE *PageAttribute - ) -{ - UINTN Index1; - UINTN Index2; - UINTN Index3; - UINTN Index4; - UINT64 *L1PageTable; - UINT64 *L2PageTable; - UINT64 *L3PageTable; - UINT64 *L4PageTable; - UINT64 AddressEncMask; - - ASSERT (PagingContext != NULL); - - Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK; - Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK; - Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK; - Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK; - - // Make sure AddressEncMask is contained to smallest supported address field. - // - AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; - - if (PagingContext->MachineType == IMAGE_FILE_MACHINE_X64) { - L4PageTable = (UINT64 *)(UINTN)PagingContext->ContextData.X64.PageTableBase; - if (L4PageTable[Index4] == 0) { - *PageAttribute = PageNone; - return NULL; - } - - L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); - } else { - ASSERT((PagingContext->ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) != 0); - L3PageTable = (UINT64 *)(UINTN)PagingContext->ContextData.Ia32.PageTableBase; - } - if (L3PageTable[Index3] == 0) { - *PageAttribute = PageNone; - return NULL; - } - if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { - // 1G - *PageAttribute = Page1G; - return &L3PageTable[Index3]; - } - - L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L2PageTable[Index2] == 0) { - *PageAttribute = PageNone; - return NULL; - } - if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { - // 2M - *PageAttribute = Page2M; - return &L2PageTable[Index2]; - } - - // 4k - L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~AddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if ((L1PageTable[Index1] == 0) && (Address != 0)) { - *PageAttribute = PageNone; - return NULL; - } - *PageAttribute = Page4K; - return &L1PageTable[Index1]; -} - -/** - Return memory attributes of page entry. - - @param[in] PageEntry The page entry. - - @return Memory attributes of page entry. -**/ -UINT64 -GetAttributesFromPageEntry ( - IN UINT64 *PageEntry - ) -{ - UINT64 Attributes; - Attributes = 0; - if ((*PageEntry & IA32_PG_P) == 0) { - Attributes |= EFI_MEMORY_RP; - } - if ((*PageEntry & IA32_PG_RW) == 0) { - Attributes |= EFI_MEMORY_RO; - } - if ((*PageEntry & IA32_PG_NX) != 0) { - Attributes |= EFI_MEMORY_XP; - } - return Attributes; -} - -/** - Modify memory attributes of page entry. - - @param[in] PagingContext The paging context. - @param[in] PageEntry The page entry. - @param[in] Attributes The bit mask of attributes to modify for the memory region. - @param[in] PageAction The page action. - @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. -**/ -VOID -ConvertPageEntryAttribute ( - IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext, - IN UINT64 *PageEntry, - IN UINT64 Attributes, - IN PAGE_ACTION PageAction, - OUT BOOLEAN *IsModified - ) -{ - UINT64 CurrentPageEntry; - UINT64 NewPageEntry; - - CurrentPageEntry = *PageEntry; - NewPageEntry = CurrentPageEntry; - if ((Attributes & EFI_MEMORY_RP) != 0) { - switch (PageAction) { - case PageActionAssign: - case PageActionSet: - NewPageEntry &= ~(UINT64)IA32_PG_P; - break; - case PageActionClear: - NewPageEntry |= IA32_PG_P; - break; - } - } else { - switch (PageAction) { - case PageActionAssign: - NewPageEntry |= IA32_PG_P; - break; - case PageActionSet: - case PageActionClear: - break; - } - } - if ((Attributes & EFI_MEMORY_RO) != 0) { - switch (PageAction) { - case PageActionAssign: - case PageActionSet: - NewPageEntry &= ~(UINT64)IA32_PG_RW; - break; - case PageActionClear: - NewPageEntry |= IA32_PG_RW; - break; - } - } else { - switch (PageAction) { - case PageActionAssign: - NewPageEntry |= IA32_PG_RW; - break; - case PageActionSet: - case PageActionClear: - break; - } - } - if ((PagingContext->ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED) != 0) { - if ((Attributes & EFI_MEMORY_XP) != 0) { - switch (PageAction) { - case PageActionAssign: - case PageActionSet: - NewPageEntry |= IA32_PG_NX; - break; - case PageActionClear: - NewPageEntry &= ~IA32_PG_NX; - break; - } - } else { - switch (PageAction) { - case PageActionAssign: - NewPageEntry &= ~IA32_PG_NX; - break; - case PageActionSet: - case PageActionClear: - break; - } - } - } - *PageEntry = NewPageEntry; - if (CurrentPageEntry != NewPageEntry) { - *IsModified = TRUE; - DEBUG ((DEBUG_INFO, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry)); - DEBUG ((DEBUG_INFO, "->0x%lx\n", NewPageEntry)); - } else { - *IsModified = FALSE; - } -} - -/** - This function returns if there is need to split page entry. - - @param[in] BaseAddress The base address to be checked. - @param[in] Length The length to be checked. - @param[in] PageEntry The page entry to be checked. - @param[in] PageAttribute The page attribute of the page entry. - - @retval SplitAttributes on if there is need to split page entry. -**/ -PAGE_ATTRIBUTE -NeedSplitPage ( - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 *PageEntry, - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINT64 PageEntryLength; - - PageEntryLength = PageAttributeToLength (PageAttribute); - - if (((BaseAddress & (PageEntryLength - 1)) == 0) && (Length >= PageEntryLength)) { - return PageNone; - } - - if (((BaseAddress & PAGING_2M_MASK) != 0) || (Length < SIZE_2MB)) { - return Page4K; - } - - return Page2M; -} - -/** - This function splits one page entry to small page entries. - - @param[in] PageEntry The page entry to be splitted. - @param[in] PageAttribute The page attribute of the page entry. - @param[in] SplitAttribute How to split the page entry. - @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. - - @retval RETURN_SUCCESS The page entry is splitted. - @retval RETURN_UNSUPPORTED The page entry does not support to be splitted. - @retval RETURN_OUT_OF_RESOURCES No resource to split page entry. -**/ -RETURN_STATUS -SplitPage ( - IN UINT64 *PageEntry, - IN PAGE_ATTRIBUTE PageAttribute, - IN PAGE_ATTRIBUTE SplitAttribute, - IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc - ) -{ - UINT64 BaseAddress; - UINT64 *NewPageEntry; - UINTN Index; - UINT64 AddressEncMask; - - ASSERT (PageAttribute == Page2M || PageAttribute == Page1G); - - ASSERT (AllocatePagesFunc != NULL); - - // Make sure AddressEncMask is contained to smallest supported address field. - // - AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; - - if (PageAttribute == Page2M) { - // - // Split 2M to 4K - // - ASSERT (SplitAttribute == Page4K); - if (SplitAttribute == Page4K) { - NewPageEntry = AllocatePagesFunc (1); - DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry)); - if (NewPageEntry == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - BaseAddress = *PageEntry & ~AddressEncMask & PAGING_2M_ADDRESS_MASK_64; - for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { - NewPageEntry[Index] = (BaseAddress + SIZE_4KB * Index) | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); - } - (*PageEntry) = (UINT64)(UINTN)NewPageEntry | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); - return RETURN_SUCCESS; - } else { - return RETURN_UNSUPPORTED; - } - } else if (PageAttribute == Page1G) { - // - // Split 1G to 2M - // No need support 1G->4K directly, we should use 1G->2M, then 2M->4K to get more compact page table. - // - ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K); - if ((SplitAttribute == Page2M || SplitAttribute == Page4K)) { - NewPageEntry = AllocatePagesFunc (1); - DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry)); - if (NewPageEntry == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - BaseAddress = *PageEntry & ~AddressEncMask & PAGING_1G_ADDRESS_MASK_64; - for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { - NewPageEntry[Index] = (BaseAddress + SIZE_2MB * Index) | AddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS); - } - (*PageEntry) = (UINT64)(UINTN)NewPageEntry | AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); - return RETURN_SUCCESS; - } else { - return RETURN_UNSUPPORTED; - } - } else { - return RETURN_UNSUPPORTED; - } -} - -/** - This function modifies the page attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - Caller should make sure BaseAddress and Length is at page boundary. - - @param[in] PagingContext The paging context. NULL means get page table from current CPU context. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to modify for the memory region. - @param[in] PageAction The page action. - @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. - NULL mean page split is unsupported. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. - - @retval RETURN_SUCCESS The attributes were modified for the memory region. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. -**/ -RETURN_STATUS -ConvertMemoryPageAttributes ( - IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - IN PAGE_ACTION PageAction, - IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL, - OUT BOOLEAN *IsSplitted, OPTIONAL - OUT BOOLEAN *IsModified OPTIONAL - ) -{ - PAGE_TABLE_LIB_PAGING_CONTEXT CurrentPagingContext; - UINT64 *PageEntry; - PAGE_ATTRIBUTE PageAttribute; - UINTN PageEntryLength; - PAGE_ATTRIBUTE SplitAttribute; - RETURN_STATUS Status; - BOOLEAN IsEntryModified; - - if ((BaseAddress & (SIZE_4KB - 1)) != 0) { - DEBUG ((DEBUG_ERROR, "BaseAddress(0x%lx) is not aligned!\n", BaseAddress)); - return EFI_UNSUPPORTED; - } - if ((Length & (SIZE_4KB - 1)) != 0) { - DEBUG ((DEBUG_ERROR, "Length(0x%lx) is not aligned!\n", Length)); - return EFI_UNSUPPORTED; - } - if (Length == 0) { - DEBUG ((DEBUG_ERROR, "Length is 0!\n")); - return RETURN_INVALID_PARAMETER; - } - - if ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) != 0) { - DEBUG ((DEBUG_ERROR, "Attributes(0x%lx) has unsupported bit\n", Attributes)); - return EFI_UNSUPPORTED; - } - - if (PagingContext == NULL) { - GetCurrentPagingContext (&CurrentPagingContext); - } else { - CopyMem (&CurrentPagingContext, PagingContext, sizeof(CurrentPagingContext)); - } - switch(CurrentPagingContext.MachineType) { - case IMAGE_FILE_MACHINE_I386: - if (CurrentPagingContext.ContextData.Ia32.PageTableBase == 0) { - if (Attributes == 0) { - return EFI_SUCCESS; - } else { - DEBUG ((DEBUG_ERROR, "PageTable is 0!\n")); - return EFI_UNSUPPORTED; - } - } - if ((CurrentPagingContext.ContextData.Ia32.Attributes & PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE) == 0) { - DEBUG ((DEBUG_ERROR, "Non-PAE Paging!\n")); - return EFI_UNSUPPORTED; - } - break; - case IMAGE_FILE_MACHINE_X64: - ASSERT (CurrentPagingContext.ContextData.X64.PageTableBase != 0); - break; - default: - ASSERT(FALSE); - return EFI_UNSUPPORTED; - break; - } - -// DEBUG ((DEBUG_ERROR, "ConvertMemoryPageAttributes(%x) - %016lx, %016lx, %02lx\n", IsSet, BaseAddress, Length, Attributes)); - - if (IsSplitted != NULL) { - *IsSplitted = FALSE; - } - if (IsModified != NULL) { - *IsModified = FALSE; - } - - // - // Below logic is to check 2M/4K page to make sure we donot waist memory. - // - while (Length != 0) { - PageEntry = GetPageTableEntry (&CurrentPagingContext, BaseAddress, &PageAttribute); - if (PageEntry == NULL) { - return RETURN_UNSUPPORTED; - } - PageEntryLength = PageAttributeToLength (PageAttribute); - SplitAttribute = NeedSplitPage (BaseAddress, Length, PageEntry, PageAttribute); - if (SplitAttribute == PageNone) { - ConvertPageEntryAttribute (&CurrentPagingContext, PageEntry, Attributes, PageAction, &IsEntryModified); - if (IsEntryModified) { - if (IsModified != NULL) { - *IsModified = TRUE; - } - } - // - // Convert success, move to next - // - BaseAddress += PageEntryLength; - Length -= PageEntryLength; - } else { - if (AllocatePagesFunc == NULL) { - return RETURN_UNSUPPORTED; - } - Status = SplitPage (PageEntry, PageAttribute, SplitAttribute, AllocatePagesFunc); - if (RETURN_ERROR (Status)) { - return RETURN_UNSUPPORTED; - } - if (IsSplitted != NULL) { - *IsSplitted = TRUE; - } - if (IsModified != NULL) { - *IsModified = TRUE; - } - // - // Just split current page - // Convert success in next around - // - } - } - - return RETURN_SUCCESS; -} - -/** - This function assigns the page attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - Caller should make sure BaseAddress and Length is at page boundary. - - Caller need guarentee the TPL <= TPL_NOTIFY, if there is split page request. - - @param[in] PagingContext The paging context. NULL means get page table from current CPU context. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to set for the memory region. - @param[in] AllocatePagesFunc If page split is needed, this function is used to allocate more pages. - NULL mean page split is unsupported. - - @retval RETURN_SUCCESS The attributes were cleared for the memory region. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. -**/ -RETURN_STATUS -EFIAPI -AssignMemoryPageAttributes ( - IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL - ) -{ - RETURN_STATUS Status; - BOOLEAN IsModified; - BOOLEAN IsSplitted; - -// DEBUG((DEBUG_INFO, "AssignMemoryPageAttributes: 0x%lx - 0x%lx (0x%lx)\n", BaseAddress, Length, Attributes)); - Status = ConvertMemoryPageAttributes (PagingContext, BaseAddress, Length, Attributes, PageActionAssign, AllocatePagesFunc, &IsSplitted, &IsModified); - if (!EFI_ERROR(Status)) { - if ((PagingContext == NULL) && IsModified) { - // - // Flush TLB as last step - // - CpuFlushTlb(); - SyncMemoryPageAttributesAp (SyncCpuFlushTlb); - } - } - - return Status; -} - -/** - Initialize the Page Table lib. -**/ -VOID -InitializePageTableLib ( - VOID - ) -{ - PAGE_TABLE_LIB_PAGING_CONTEXT CurrentPagingContext; - - GetCurrentPagingContext (&CurrentPagingContext); - DEBUG ((DEBUG_INFO, "CurrentPagingContext:\n", CurrentPagingContext.MachineType)); - DEBUG ((DEBUG_INFO, " MachineType - 0x%x\n", CurrentPagingContext.MachineType)); - DEBUG ((DEBUG_INFO, " PageTableBase - 0x%x\n", CurrentPagingContext.ContextData.X64.PageTableBase)); - DEBUG ((DEBUG_INFO, " Attributes - 0x%x\n", CurrentPagingContext.ContextData.X64.Attributes)); - - return ; -} - diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.h b/UefiCpuPkg/CpuDxe/CpuPageTable.h deleted file mode 100644 index eaff595b4c..0000000000 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.h +++ /dev/null @@ -1,113 +0,0 @@ -/** @file - Page table management header file. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _PAGE_TABLE_LIB_H_ -#define _PAGE_TABLE_LIB_H_ - -#include - -#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE BIT0 -#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE BIT1 -#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT BIT2 -#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE BIT30 -#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED BIT31 -// Other bits are reserved for future use -typedef struct { - UINT32 PageTableBase; - UINT32 Reserved; - UINT32 Attributes; -} PAGE_TABLE_LIB_PAGING_CONTEXT_IA32; - -typedef struct { - UINT64 PageTableBase; - UINT32 Attributes; -} PAGE_TABLE_LIB_PAGING_CONTEXT_X64; - -typedef union { - PAGE_TABLE_LIB_PAGING_CONTEXT_IA32 Ia32; - PAGE_TABLE_LIB_PAGING_CONTEXT_X64 X64; -} PAGE_TABLE_LIB_PAGING_CONTEXT_DATA; - -typedef struct { - // - // PE32+ Machine type for EFI images - // - // #define IMAGE_FILE_MACHINE_I386 0x014c - // #define IMAGE_FILE_MACHINE_X64 0x8664 - // - UINT16 MachineType; - PAGE_TABLE_LIB_PAGING_CONTEXT_DATA ContextData; -} PAGE_TABLE_LIB_PAGING_CONTEXT; - -/** - Allocates one or more 4KB pages for page table. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -typedef -VOID * -(EFIAPI *PAGE_TABLE_LIB_ALLOCATE_PAGES) ( - IN UINTN Pages - ); - -/** - This function assigns the page attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - Caller should make sure BaseAddress and Length is at page boundary. - - Caller need guarentee the TPL <= TPL_NOTIFY, if there is split page request. - - @param PagingContext The paging context. NULL means get page table from current CPU context. - @param BaseAddress The physical address that is the start address of a memory region. - @param Length The size in bytes of the memory region. - @param Attributes The bit mask of attributes to set for the memory region. - @param AllocatePagesFunc If page split is needed, this function is used to allocate more pages. - NULL mean page split is unsupported. - - @retval RETURN_SUCCESS The attributes were cleared for the memory region. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. -**/ -RETURN_STATUS -EFIAPI -AssignMemoryPageAttributes ( - IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL - ); - -/** - Initialize the Page Table lib. -**/ -VOID -InitializePageTableLib ( - VOID - ); - -#endif diff --git a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S b/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S deleted file mode 100644 index e034bc2e2e..0000000000 --- a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.S +++ /dev/null @@ -1,57 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* CpuAsm.S -#* -#* Abstract: -#* -#------------------------------------------------------------------------------ - - -#.MMX -#.XMM - -#------------------------------------------------------------------------------ -# VOID -# SetCodeSelector ( -# UINT16 Selector -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(SetCodeSelector) -ASM_PFX(SetCodeSelector): - movl 4(%esp), %ecx - subl $0x10, %esp - leal setCodeSelectorLongJump, %eax - movl %eax, (%esp) - movw %cx, 4(%esp) - .byte 0xFF, 0x2C, 0x24 # jmp *(%esp) note:(FWORD jmp) -setCodeSelectorLongJump: - addl $0x10, %esp - ret - -#------------------------------------------------------------------------------ -# VOID -# SetDataSelectors ( -# UINT16 Selector -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(SetDataSelectors) -ASM_PFX(SetDataSelectors): - movl 4(%esp), %ecx - movw %cx, %ss - movw %cx, %ds - movw %cx, %es - movw %cx, %fs - movw %cx, %gs - ret - -#END - diff --git a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm b/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm deleted file mode 100644 index 7f8f0d6f3a..0000000000 --- a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.asm +++ /dev/null @@ -1,58 +0,0 @@ - TITLE CpuAsm.asm: -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.asm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - - .686 - .model flat,C - .code - -;------------------------------------------------------------------------------ -; VOID -; SetCodeSelector ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -SetCodeSelector PROC PUBLIC - mov ecx, [esp+4] - sub esp, 0x10 - lea eax, setCodeSelectorLongJump - mov [esp], eax - mov [esp+4], cx - jmp fword ptr [esp] -setCodeSelectorLongJump: - add esp, 0x10 - ret -SetCodeSelector ENDP - -;------------------------------------------------------------------------------ -; VOID -; SetDataSelectors ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -SetDataSelectors PROC PUBLIC - mov ecx, [esp+4] - mov ss, cx - mov ds, cx - mov es, cx - mov fs, cx - mov gs, cx - ret -SetDataSelectors ENDP - - -END diff --git a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm b/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm deleted file mode 100644 index c67ddfb010..0000000000 --- a/UefiCpuPkg/CpuDxe/Ia32/CpuAsm.nasm +++ /dev/null @@ -1,53 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2016, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.nasm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; SetCodeSelector ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetCodeSelector) -ASM_PFX(SetCodeSelector): - mov ecx, [esp+4] - sub esp, 0x10 - lea eax, [setCodeSelectorLongJump] - mov [esp], eax - mov [esp+4], cx - jmp dword far [esp] -setCodeSelectorLongJump: - add esp, 0x10 - ret - -;------------------------------------------------------------------------------ -; VOID -; SetDataSelectors ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetDataSelectors) -ASM_PFX(SetDataSelectors): - mov ecx, [esp+4] -o16 mov ss, cx -o16 mov ds, cx -o16 mov es, cx -o16 mov fs, cx -o16 mov gs, cx - ret - diff --git a/UefiCpuPkg/CpuDxe/X64/CpuAsm.S b/UefiCpuPkg/CpuDxe/X64/CpuAsm.S deleted file mode 100644 index e82cadf369..0000000000 --- a/UefiCpuPkg/CpuDxe/X64/CpuAsm.S +++ /dev/null @@ -1,60 +0,0 @@ -# TITLE CpuAsm.S: - -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* CpuAsm.S -#* -#* Abstract: -#* -#------------------------------------------------------------------------------ - - -#text SEGMENT - - -#------------------------------------------------------------------------------ -# VOID -# SetCodeSelector ( -# UINT16 Selector -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(SetCodeSelector) -ASM_PFX(SetCodeSelector): - subq $0x10, %rsp - leaq L_setCodeSelectorLongJump(%rip), %rax - movq %rax, (%rsp) - movw %cx, 4(%rsp) - .byte 0xFF, 0x2C, 0x24 # jmp (%rsp) note:fword jmp -L_setCodeSelectorLongJump: - addq $0x10, %rsp - ret - -#------------------------------------------------------------------------------ -# VOID -# SetDataSelectors ( -# UINT16 Selector -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(SetDataSelectors) -ASM_PFX(SetDataSelectors): - movw %cx, %ss - movw %cx, %ds - movw %cx, %es - movw %cx, %fs - movw %cx, %gs - ret - -#text ENDS - -#END - - diff --git a/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm b/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm deleted file mode 100644 index c71b06a81e..0000000000 --- a/UefiCpuPkg/CpuDxe/X64/CpuAsm.asm +++ /dev/null @@ -1,54 +0,0 @@ - TITLE CpuAsm.asm: -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.asm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; VOID -; SetCodeSelector ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -SetCodeSelector PROC PUBLIC - sub rsp, 0x10 - lea rax, setCodeSelectorLongJump - mov [rsp], rax - mov [rsp+4], cx - jmp fword ptr [rsp] -setCodeSelectorLongJump: - add rsp, 0x10 - ret -SetCodeSelector ENDP - -;------------------------------------------------------------------------------ -; VOID -; SetDataSelectors ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -SetDataSelectors PROC PUBLIC - mov ss, cx - mov ds, cx - mov es, cx - mov fs, cx - mov gs, cx - ret -SetDataSelectors ENDP - -END - diff --git a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm b/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm deleted file mode 100644 index 77ecfb3404..0000000000 --- a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm +++ /dev/null @@ -1,52 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2016, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.nasm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - - DEFAULT REL - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; SetCodeSelector ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetCodeSelector) -ASM_PFX(SetCodeSelector): - sub rsp, 0x10 - lea rax, [setCodeSelectorLongJump] - mov [rsp], rax - mov [rsp+4], cx - jmp dword far [rsp] -setCodeSelectorLongJump: - add rsp, 0x10 - ret - -;------------------------------------------------------------------------------ -; VOID -; SetDataSelectors ( -; UINT16 Selector -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(SetDataSelectors) -ASM_PFX(SetDataSelectors): -o16 mov ss, cx -o16 mov ds, cx -o16 mov es, cx -o16 mov fs, cx -o16 mov gs, cx - ret - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c deleted file mode 100644 index b0b186d36d..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c +++ /dev/null @@ -1,122 +0,0 @@ -/** @file - CPU Features DXE driver to initialize CPU features. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include - -#include -#include - - -/** - Worker function to perform CPU feature initialization. - -**/ -VOID -CpuFeaturesInitializeWorker ( - VOID - ) -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - CpuFeaturesDetect (); - - CpuFeaturesInitialize (); - - // - // Install CPU Features Init Done Protocol - // - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - &gEdkiiCpuFeaturesInitDoneGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs. - - @param[in] Event The Event that is being processed, not used. - @param[in] Context Event Context, not used. -**/ -VOID -EFIAPI -SmmConfigurationEventNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration; - - // - // Make sure this notification is for this handler - // - Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration); - if (EFI_ERROR (Status)) { - return; - } - - CpuFeaturesInitializeWorker (); -} - -/** - CPU Features driver entry point function. - - If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one - SMM Configuration Protocol notify function to perform CPU features - initialization. Otherwise, it will perform CPU features initialization - directly. - - @param ImageHandle Image handle this driver. - @param SystemTable Pointer to the System Table. - - @retval EFI_SUCCESS CPU Features is initialized successfully. -**/ -EFI_STATUS -EFIAPI -CpuFeaturesDxeInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - VOID *Registration; - - if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { - // - // Install notification callback on SMM Configuration Protocol - // - EfiCreateProtocolNotifyEvent ( - &gEfiSmmConfigurationProtocolGuid, - TPL_CALLBACK, - SmmConfigurationEventNotify, - NULL, - &Registration - ); - } else { - CpuFeaturesInitializeWorker (); - } - - return EFI_SUCCESS; -} - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf deleted file mode 100644 index 175e8a9797..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf +++ /dev/null @@ -1,53 +0,0 @@ -## @file -# CPU Features DXE driver. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuFeaturesDxe - MODULE_UNI_FILE = CpuFeaturesDxe.uni - FILE_GUID = 63EB1B62-10C9-4693-88AC-AE0999EA87F8 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = CpuFeaturesDxeInitialize - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - UefiLib - UefiDriverEntryPoint - UefiBootServicesTableLib - RegisterCpuFeaturesLib - -[Sources] - CpuFeaturesDxe.c - -[Guids] - gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # protocol GUID installed - -[Protocols] - gEfiSmmConfigurationProtocolGuid ## NOTIFY - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSUMES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuFeaturesDxeExtra.uni diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni deleted file mode 100644 index c42e4daf43..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Features DXE driver. -// -// CPU Features DXE driver. -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Features DXE driver to initialize CPU features." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Features DXE driver to initialize CPU features." - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni deleted file mode 100644 index 39a943e5a9..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuFeaturesDxe Localized Strings and Content -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU Features DXE Driver" - - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c deleted file mode 100644 index b052d554a9..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c +++ /dev/null @@ -1,75 +0,0 @@ -/** @file - CPU Features PEIM driver to initialize CPU features. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include - -#include - -EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEdkiiCpuFeaturesInitDoneGuid, - NULL -}; - -/** - CPU Features driver entry point function. - - It will perform CPU features initialization, except for - PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Describes the list of possible PEI Services. - - @retval EFI_SUCCESS CPU Features is initialized successfully. -**/ -EFI_STATUS -EFIAPI -CpuFeaturesPeimInitialize ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - EFI_BOOT_MODE BootMode; - - Status = PeiServicesGetBootMode (&BootMode); - ASSERT_EFI_ERROR (Status); - - if (BootMode == BOOT_ON_S3_RESUME && - !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) { - // - // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE - // on S3 boot mode - // - return EFI_SUCCESS; - } - - CpuFeaturesDetect (); - - CpuFeaturesInitialize (); - - // - // Install CPU Features Init Done PPI - // - Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf deleted file mode 100644 index dd4b388c9a..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# CPU Features PEIM driver. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuFeaturesPei - MODULE_UNI_FILE = CpuFeaturesPei.uni - FILE_GUID = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - - ENTRY_POINT = CpuFeaturesPeimInitialize - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - PeimEntryPoint - PeiServicesLib - RegisterCpuFeaturesLib - -[Sources] - CpuFeaturesPei.c - -[Guids] - gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # PPI GUID installed - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSUMES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuFeaturesPeiExtra.uni diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni deleted file mode 100644 index b03754aee6..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Features PEIM driver. -// -// CPU Features PEIM driver. -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Features PEIM driver to initialize CPU features." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Features PEIM driver to initialize CPU features." - diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni b/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni deleted file mode 100644 index 43dbe96197..0000000000 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuFeaturesPei Localized Strings and Content -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU Features PEIM Driver" - - diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c b/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c deleted file mode 100644 index d19349d4b0..0000000000 --- a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c +++ /dev/null @@ -1,588 +0,0 @@ -/** @file - Produces the CPU I/O 2 Protocol. - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuIo2Dxe.h" - -// -// Handle for the CPU I/O 2 Protocol -// -EFI_HANDLE mHandle = NULL; - -// -// CPU I/O 2 Protocol instance -// -EFI_CPU_IO2_PROTOCOL mCpuIo2 = { - { - CpuMemoryServiceRead, - CpuMemoryServiceWrite - }, - { - CpuIoServiceRead, - CpuIoServiceWrite - } -}; - -// -// Lookup table for increment values based on transfer widths -// -UINT8 mInStride[] = { - 1, // EfiCpuIoWidthUint8 - 2, // EfiCpuIoWidthUint16 - 4, // EfiCpuIoWidthUint32 - 8, // EfiCpuIoWidthUint64 - 0, // EfiCpuIoWidthFifoUint8 - 0, // EfiCpuIoWidthFifoUint16 - 0, // EfiCpuIoWidthFifoUint32 - 0, // EfiCpuIoWidthFifoUint64 - 1, // EfiCpuIoWidthFillUint8 - 2, // EfiCpuIoWidthFillUint16 - 4, // EfiCpuIoWidthFillUint32 - 8 // EfiCpuIoWidthFillUint64 -}; - -// -// Lookup table for increment values based on transfer widths -// -UINT8 mOutStride[] = { - 1, // EfiCpuIoWidthUint8 - 2, // EfiCpuIoWidthUint16 - 4, // EfiCpuIoWidthUint32 - 8, // EfiCpuIoWidthUint64 - 1, // EfiCpuIoWidthFifoUint8 - 2, // EfiCpuIoWidthFifoUint16 - 4, // EfiCpuIoWidthFifoUint32 - 8, // EfiCpuIoWidthFifoUint64 - 0, // EfiCpuIoWidthFillUint8 - 0, // EfiCpuIoWidthFillUint16 - 0, // EfiCpuIoWidthFillUint32 - 0 // EfiCpuIoWidthFillUint64 -}; - -/** - Check parameters to a CPU I/O 2 Protocol service request. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[in] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The parameters for this request pass the checks. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -CpuIoCheckParameter ( - IN BOOLEAN MmioOperation, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - UINT64 MaxCount; - UINT64 Limit; - - // - // Check to see if Buffer is NULL - // - if (Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if Width is in the valid range - // - if ((UINT32)Width >= EfiCpuIoWidthMaximum) { - return EFI_INVALID_PARAMETER; - } - - // - // For FIFO type, the target address won't increase during the access, - // so treat Count as 1 - // - if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) { - Count = 1; - } - - // - // Check to see if Width is in the valid range for I/O Port operations - // - Width = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); - if (!MmioOperation && (Width == EfiCpuIoWidthUint64)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if Address is aligned - // - if ((Address & ((UINT64)mInStride[Width] - 1)) != 0) { - return EFI_UNSUPPORTED; - } - - // - // Check to see if any address associated with this transfer exceeds the maximum - // allowed address. The maximum address implied by the parameters passed in is - // Address + Size * Count. If the following condition is met, then the transfer - // is not supported. - // - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 - // - // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count - // can also be the maximum integer value supported by the CPU, this range - // check must be adjusted to avoid all oveflow conditions. - // - // The following form of the range check is equivalent but assumes that - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). - // - Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); - if (Count == 0) { - if (Address > Limit) { - return EFI_UNSUPPORTED; - } - } else { - MaxCount = RShiftU64 (Limit, Width); - if (MaxCount < (Count - 1)) { - return EFI_UNSUPPORTED; - } - if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { - return EFI_UNSUPPORTED; - } - } - - // - // Check to see if Buffer is aligned - // (IA-32 allows UINT64 and INT64 data types to be 32-bit aligned.) - // - if (((UINTN)Buffer & ((MIN (sizeof (UINTN), mInStride[Width]) - 1))) != 0) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -/** - Reads memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[out] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiCpuIoWidthUint8) { - *Uint8Buffer = MmioRead8 ((UINTN)Address); - } else if (OperationWidth == EfiCpuIoWidthUint16) { - *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); - } else if (OperationWidth == EfiCpuIoWidthUint32) { - *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); - } else if (OperationWidth == EfiCpuIoWidthUint64) { - *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); - } - } - return EFI_SUCCESS; -} - -/** - Writes memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[in] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiCpuIoWidthUint8) { - MmioWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (OperationWidth == EfiCpuIoWidthUint16) { - MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else if (OperationWidth == EfiCpuIoWidthUint32) { - MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } else if (OperationWidth == EfiCpuIoWidthUint64) { - MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); - } - } - return EFI_SUCCESS; -} - -/** - Reads I/O registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[out] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); - - // - // Fifo operations supported for (mInStride[Width] == 0) - // - if (InStride == 0) { - switch (OperationWidth) { - case EfiCpuIoWidthUint8: - IoReadFifo8 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiCpuIoWidthUint16: - IoReadFifo16 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiCpuIoWidthUint32: - IoReadFifo32 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - default: - // - // The CpuIoCheckParameter call above will ensure that this - // path is not taken. - // - ASSERT (FALSE); - break; - } - } - - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiCpuIoWidthUint8) { - *Uint8Buffer = IoRead8 ((UINTN)Address); - } else if (OperationWidth == EfiCpuIoWidthUint16) { - *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); - } else if (OperationWidth == EfiCpuIoWidthUint32) { - *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); - } - } - - return EFI_SUCCESS; -} - -/** - Write I/O registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[in] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_CPU_IO_PROTOCOL_WIDTH OperationWidth; - UINT8 *Uint8Buffer; - - // - // Make sure the parameters are valid - // - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03); - - // - // Fifo operations supported for (mInStride[Width] == 0) - // - if (InStride == 0) { - switch (OperationWidth) { - case EfiCpuIoWidthUint8: - IoWriteFifo8 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiCpuIoWidthUint16: - IoWriteFifo16 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiCpuIoWidthUint32: - IoWriteFifo32 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - default: - // - // The CpuIoCheckParameter call above will ensure that this - // path is not taken. - // - ASSERT (FALSE); - break; - } - } - - for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiCpuIoWidthUint8) { - IoWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (OperationWidth == EfiCpuIoWidthUint16) { - IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else if (OperationWidth == EfiCpuIoWidthUint32) { - IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } - } - - return EFI_SUCCESS; -} - -/** - The user Entry Point for module CpuIo2Dxe. The user code starts with this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -CpuIo2Initialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiCpuIo2ProtocolGuid); - Status = gBS->InstallMultipleProtocolInterfaces ( - &mHandle, - &gEfiCpuIo2ProtocolGuid, &mCpuIo2, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h b/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h deleted file mode 100644 index 7d00da16f4..0000000000 --- a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h +++ /dev/null @@ -1,225 +0,0 @@ -/** @file - Internal include file for the CPU I/O 2 Protocol. - -Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_IO2_DXE_H_ -#define _CPU_IO2_DXE_H_ - -#include - -#include - -#include -#include -#include -#include - -#define MAX_IO_PORT_ADDRESS 0xFFFF - -/** - Reads memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[out] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Writes memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[in] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -/** - Reads I/O registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[out] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Write I/O registers. - - The I/O operations are carried out exactly as requested. The caller is responsible - for satisfying any alignment and I/O width restrictions that a PI System on a - platform might require. For example on some platforms, width requests of - EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will - be handled by the driver. - - If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, - or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for - each of the Count operations that is performed. - - If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, - EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times on the same Address. - - If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, - EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is - incremented for each of the Count operations that is performed. The read or - write operation is performed Count times from the first element of Buffer. - - @param[in] This A pointer to the EFI_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O or Memory operation. - @param[in] Address The base address of the I/O operation. - @param[in] Count The number of I/O operations to perform. The number of - bytes moved is Width size * Count, starting at Address. - @param[in] Buffer For read operations, the destination buffer to store the results. - For write operations, the source buffer from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the PI system. - @retval EFI_INVALID_PARAMETER Width is invalid for this PI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this PI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN EFI_CPU_IO2_PROTOCOL *This, - IN EFI_CPU_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -#endif diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf b/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf deleted file mode 100644 index 55036622ca..0000000000 --- a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf +++ /dev/null @@ -1,53 +0,0 @@ -## @file -# Produces the CPU I/O 2 Protocol by using the services of the I/O Library. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuIo2Dxe - MODULE_UNI_FILE = CpuIo2Dxe.uni - FILE_GUID = A19B1FE7-C1BC-49F8-875F-54A5D542443F - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = CpuIo2Initialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - CpuIo2Dxe.c - CpuIo2Dxe.h - -[Packages] - MdePkg/MdePkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - BaseLib - DebugLib - IoLib - UefiBootServicesTableLib - -[Protocols] - gEfiCpuIo2ProtocolGuid ## PRODUCES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuIo2DxeExtra.uni diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni b/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni deleted file mode 100644 index 59456fb3e5..0000000000 --- a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// Produces the CPU I/O 2 Protocol by using the services of the I/O Library. -// -// Produces the CPU I/O 2 Protocol by using the services of the I/O Library. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Produces the CPU I/O 2 Protocol by using the services of the I/O Library" - -#string STR_MODULE_DESCRIPTION #language en-US "Produces the CPU I/O 2 Protocol by using the services of the I/O Library." - diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni b/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni deleted file mode 100644 index 655da485df..0000000000 --- a/UefiCpuPkg/CpuIo2Dxe/CpuIo2DxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuIo2Dxe Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU I/O v2 DXE Driver" - - diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c deleted file mode 100644 index 20b8350fe4..0000000000 --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c +++ /dev/null @@ -1,413 +0,0 @@ -/** @file - Produces the SMM CPU I/O Protocol. - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuIo2Smm.h" - -// -// Handle for the SMM CPU I/O Protocol -// -EFI_HANDLE mHandle = NULL; - -// -// SMM CPU I/O Protocol instance -// -EFI_SMM_CPU_IO2_PROTOCOL mSmmCpuIo2 = { - { - CpuMemoryServiceRead, - CpuMemoryServiceWrite - }, - { - CpuIoServiceRead, - CpuIoServiceWrite - } -}; - -// -// Lookup table for increment values based on transfer widths -// -UINT8 mStride[] = { - 1, // SMM_IO_UINT8 - 2, // SMM_IO_UINT16 - 4, // SMM_IO_UINT32 - 8 // SMM_IO_UINT64 -}; - -/** - Check parameters to a SMM CPU I/O Protocol service request. - - @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - -**/ -EFI_STATUS -CpuIoCheckParameter ( - IN BOOLEAN MmioOperation, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - UINT64 MaxCount; - UINT64 Limit; - - // - // Check to see if Buffer is NULL - // - if (Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if Width is in the valid range - // - if ((UINT32)Width > SMM_IO_UINT64) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if Width is in the valid range for I/O Port operations - // - if (!MmioOperation && (Width == SMM_IO_UINT64)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if any address associated with this transfer exceeds the maximum - // allowed address. The maximum address implied by the parameters passed in is - // Address + Size * Count. If the following condition is met, then the transfer - // is not supported. - // - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 - // - // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count - // can also be the maximum integer value supported by the CPU, this range - // check must be adjusted to avoid all overflow conditions. - // - // The following form of the range check is equivalent but assumes that - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). - // - Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); - if (Count == 0) { - if (Address > Limit) { - return EFI_UNSUPPORTED; - } - } else { - MaxCount = RShiftU64 (Limit, Width); - if (MaxCount < (Count - 1)) { - return EFI_UNSUPPORTED; - } - if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { - return EFI_UNSUPPORTED; - } - } - - // - // Check to see if Address is aligned - // - if ((Address & ((UINT64)mStride[Width] - 1)) != 0) { - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -/** - Reads memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[out] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 Stride; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - Stride = mStride[Width]; - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { - if (Width == SMM_IO_UINT8) { - *Uint8Buffer = MmioRead8 ((UINTN)Address); - } else if (Width == SMM_IO_UINT16) { - *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); - } else if (Width == SMM_IO_UINT32) { - *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); - } else if (Width == SMM_IO_UINT64) { - *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); - } - } - return EFI_SUCCESS; -} - -/** - Writes memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 Stride; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - Stride = mStride[Width]; - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { - if (Width == SMM_IO_UINT8) { - MmioWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (Width == SMM_IO_UINT16) { - MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else if (Width == SMM_IO_UINT32) { - MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } else if (Width == SMM_IO_UINT64) { - MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); - } - } - return EFI_SUCCESS; -} - -/** - Reads I/O registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[out] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 Stride; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - Stride = mStride[Width]; - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { - if (Width == SMM_IO_UINT8) { - *Uint8Buffer = IoRead8 ((UINTN)Address); - } else if (Width == SMM_IO_UINT16) { - *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); - } else if (Width == SMM_IO_UINT32) { - *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); - } - } - - return EFI_SUCCESS; -} - -/** - Write I/O registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 Stride; - UINT8 *Uint8Buffer; - - // - // Make sure the parameters are valid - // - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - Stride = mStride[Width]; - for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { - if (Width == SMM_IO_UINT8) { - IoWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (Width == SMM_IO_UINT16) { - IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else if (Width == SMM_IO_UINT32) { - IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } - } - - return EFI_SUCCESS; -} - -/** - The module Entry Point SmmCpuIoProtocol driver - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval Other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -SmmCpuIo2Initialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Copy the SMM CPU I/O Protocol instance into the System Management System Table - // - CopyMem (&gSmst->SmmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); - - // - // Install the SMM CPU I/O Protocol into the SMM protocol database - // - Status = gSmst->SmmInstallProtocolInterface ( - &mHandle, - &gEfiSmmCpuIo2ProtocolGuid, - EFI_NATIVE_INTERFACE, - &mSmmCpuIo2 - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h deleted file mode 100644 index 5a092594d7..0000000000 --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h +++ /dev/null @@ -1,162 +0,0 @@ -/** @file - Internal include file for the SMM CPU I/O Protocol. - -Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_IO2_SMM_H_ -#define _CPU_IO2_SMM_H_ - -#include - -#include - -#include -#include -#include -#include -#include - -#define MAX_IO_PORT_ADDRESS 0xFFFF - -/** - Reads memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[out] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Writes memory-mapped registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -/** - Reads I/O registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[out] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Write I/O registers. - - The I/O operations are carried out exactly as requested. The caller is - responsible for any alignment and I/O width issues that the bus, device, - platform, or type of I/O might require. - - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. - @param[in] Width Signifies the width of the I/O operations. - @param[in] Address The base address of the I/O operations. The caller is - responsible for aligning the Address if required. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer to store - the results. For write operations, the source buffer - from which to write data. - - @retval EFI_SUCCESS The data was read from or written to the device. - @retval EFI_UNSUPPORTED The Address is not valid for this system. - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, - IN EFI_SMM_IO_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -#endif diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf deleted file mode 100644 index d7c98f67c0..0000000000 --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf +++ /dev/null @@ -1,52 +0,0 @@ -## @file -# Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. -# -# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuIo2Smm - MODULE_UNI_FILE = CpuIo2Smm.uni - FILE_GUID = A47EE2D8-F60E-42fd-8E58-7BD65EE4C29B - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x0001000A - ENTRY_POINT = SmmCpuIo2Initialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - CpuIo2Smm.c - CpuIo2Smm.h - -[Packages] - MdePkg/MdePkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - BaseLib - DebugLib - IoLib - SmmServicesTableLib - BaseMemoryLib - -[Protocols] - gEfiSmmCpuIo2ProtocolGuid ## PRODUCES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuIo2SmmExtra.uni diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni deleted file mode 100644 index c3a212b1e7..0000000000 --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. -// -// Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library" - -#string STR_MODULE_DESCRIPTION #language en-US "Produces the SMM CPU I/O 2 Protocol by using the services of the I/O Library." - diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni b/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni deleted file mode 100644 index b1b82b03b7..0000000000 --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2SmmExtra.uni +++ /dev/null @@ -1,19 +0,0 @@ -// /** @file -// CpuIo2Smm Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU I/O v2 SMM Driver" - - diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPei.c b/UefiCpuPkg/CpuIoPei/CpuIoPei.c deleted file mode 100644 index b6d538b166..0000000000 --- a/UefiCpuPkg/CpuIoPei/CpuIoPei.c +++ /dev/null @@ -1,916 +0,0 @@ -/** @file - Produces the CPU I/O PPI. - -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuIoPei.h" - -// -// Instance of CPU I/O PPI -// -EFI_PEI_CPU_IO_PPI gCpuIoPpi = { - { - CpuMemoryServiceRead, - CpuMemoryServiceWrite - }, - { - CpuIoServiceRead, - CpuIoServiceWrite - }, - CpuIoRead8, - CpuIoRead16, - CpuIoRead32, - CpuIoRead64, - CpuIoWrite8, - CpuIoWrite16, - CpuIoWrite32, - CpuIoWrite64, - CpuMemRead8, - CpuMemRead16, - CpuMemRead32, - CpuMemRead64, - CpuMemWrite8, - CpuMemWrite16, - CpuMemWrite32, - CpuMemWrite64 -}; - -// -// PPI Descriptor used to install the CPU I/O PPI -// -EFI_PEI_PPI_DESCRIPTOR gPpiList = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiCpuIoPpiInstalledGuid, - NULL -}; - -// -// Lookup table for increment values based on transfer widths -// -UINT8 mInStride[] = { - 1, // EfiPeiCpuIoWidthUint8 - 2, // EfiPeiCpuIoWidthUint16 - 4, // EfiPeiCpuIoWidthUint32 - 8, // EfiPeiCpuIoWidthUint64 - 0, // EfiPeiCpuIoWidthFifoUint8 - 0, // EfiPeiCpuIoWidthFifoUint16 - 0, // EfiPeiCpuIoWidthFifoUint32 - 0, // EfiPeiCpuIoWidthFifoUint64 - 1, // EfiPeiCpuIoWidthFillUint8 - 2, // EfiPeiCpuIoWidthFillUint16 - 4, // EfiPeiCpuIoWidthFillUint32 - 8 // EfiPeiCpuIoWidthFillUint64 -}; - -// -// Lookup table for increment values based on transfer widths -// -UINT8 mOutStride[] = { - 1, // EfiPeiCpuIoWidthUint8 - 2, // EfiPeiCpuIoWidthUint16 - 4, // EfiPeiCpuIoWidthUint32 - 8, // EfiPeiCpuIoWidthUint64 - 1, // EfiPeiCpuIoWidthFifoUint8 - 2, // EfiPeiCpuIoWidthFifoUint16 - 4, // EfiPeiCpuIoWidthFifoUint32 - 8, // EfiPeiCpuIoWidthFifoUint64 - 0, // EfiPeiCpuIoWidthFillUint8 - 0, // EfiPeiCpuIoWidthFillUint16 - 0, // EfiPeiCpuIoWidthFillUint32 - 0 // EfiPeiCpuIoWidthFillUint64 -}; - -/** - Check parameters to a CPU I/O PPI service request. - - @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[in] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The parameters for this request pass the checks. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -CpuIoCheckParameter ( - IN BOOLEAN MmioOperation, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - UINT64 MaxCount; - UINT64 Limit; - - // - // Check to see if Buffer is NULL - // - if (Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if Width is in the valid range - // - if ((UINT32)Width >= EfiPeiCpuIoWidthMaximum) { - return EFI_INVALID_PARAMETER; - } - - // - // For FIFO type, the target address won't increase during the access, - // so treat Count as 1 - // - if (Width >= EfiPeiCpuIoWidthFifoUint8 && Width <= EfiPeiCpuIoWidthFifoUint64) { - Count = 1; - } - - // - // Check to see if Width is in the valid range for I/O Port operations - // - Width = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); - if (!MmioOperation && (Width == EfiPeiCpuIoWidthUint64)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to see if any address associated with this transfer exceeds the maximum - // allowed address. The maximum address implied by the parameters passed in is - // Address + Size * Count. If the following condition is met, then the transfer - // is not supported. - // - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 - // - // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count - // can also be the maximum integer value supported by the CPU, this range - // check must be adjusted to avoid all overflow conditions. - // - // The following form of the range check is equivalent but assumes that - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). - // - Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); - if (Count == 0) { - if (Address > Limit) { - return EFI_UNSUPPORTED; - } - } else { - MaxCount = RShiftU64 (Limit, Width); - if (MaxCount < (Count - 1)) { - return EFI_UNSUPPORTED; - } - if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { - return EFI_UNSUPPORTED; - } - } - - return EFI_SUCCESS; -} - -/** - Reads memory-mapped registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[out] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; - BOOLEAN Aligned; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); - Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiPeiCpuIoWidthUint8) { - *Uint8Buffer = MmioRead8 ((UINTN)Address); - } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { - if (Aligned) { - *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); - } else { - WriteUnaligned16 ((UINT16 *)Uint8Buffer, MmioRead16 ((UINTN)Address)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { - if (Aligned) { - *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); - } else { - WriteUnaligned32 ((UINT32 *)Uint8Buffer, MmioRead32 ((UINTN)Address)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint64) { - if (Aligned) { - *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); - } else { - WriteUnaligned64 ((UINT64 *)Uint8Buffer, MmioRead64 ((UINTN)Address)); - } - } - } - return EFI_SUCCESS; -} - -/** - Writes memory-mapped registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[in] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; - BOOLEAN Aligned; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); - Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiPeiCpuIoWidthUint8) { - MmioWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { - if (Aligned) { - MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else { - MmioWrite16 ((UINTN)Address, ReadUnaligned16 ((UINT16 *)Uint8Buffer)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { - if (Aligned) { - MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } else { - MmioWrite32 ((UINTN)Address, ReadUnaligned32 ((UINT32 *)Uint8Buffer)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint64) { - if (Aligned) { - MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); - } else { - MmioWrite64 ((UINTN)Address, ReadUnaligned64 ((UINT64 *)Uint8Buffer)); - } - } - } - return EFI_SUCCESS; -} - -/** - Reads I/O registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[out] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; - BOOLEAN Aligned; - UINT8 *Uint8Buffer; - - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); - - // - // Fifo operations supported for (mInStride[Width] == 0) - // - if (InStride == 0) { - switch (OperationWidth) { - case EfiPeiCpuIoWidthUint8: - IoReadFifo8 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiPeiCpuIoWidthUint16: - IoReadFifo16 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiPeiCpuIoWidthUint32: - IoReadFifo32 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - default: - // - // The CpuIoCheckParameter call above will ensure that this - // path is not taken. - // - ASSERT (FALSE); - break; - } - } - - Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); - for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiPeiCpuIoWidthUint8) { - *Uint8Buffer = IoRead8 ((UINTN)Address); - } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { - if (Aligned) { - *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); - } else { - WriteUnaligned16 ((UINT16 *)Uint8Buffer, IoRead16 ((UINTN)Address)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { - if (Aligned) { - *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); - } else { - WriteUnaligned32 ((UINT32 *)Uint8Buffer, IoRead32 ((UINTN)Address)); - } - } - } - - return EFI_SUCCESS; -} - -/** - Write I/O registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[in] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ) -{ - EFI_STATUS Status; - UINT8 InStride; - UINT8 OutStride; - EFI_PEI_CPU_IO_PPI_WIDTH OperationWidth; - BOOLEAN Aligned; - UINT8 *Uint8Buffer; - - // - // Make sure the parameters are valid - // - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select loop based on the width of the transfer - // - InStride = mInStride[Width]; - OutStride = mOutStride[Width]; - OperationWidth = (EFI_PEI_CPU_IO_PPI_WIDTH) (Width & 0x03); - - // - // Fifo operations supported for (mInStride[Width] == 0) - // - if (InStride == 0) { - switch (OperationWidth) { - case EfiPeiCpuIoWidthUint8: - IoWriteFifo8 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiPeiCpuIoWidthUint16: - IoWriteFifo16 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - case EfiPeiCpuIoWidthUint32: - IoWriteFifo32 ((UINTN)Address, Count, Buffer); - return EFI_SUCCESS; - default: - // - // The CpuIoCheckParameter call above will ensure that this - // path is not taken. - // - ASSERT (FALSE); - break; - } - } - - Aligned = (BOOLEAN)(((UINTN)Buffer & (mInStride[OperationWidth] - 1)) == 0x00); - for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) { - if (OperationWidth == EfiPeiCpuIoWidthUint8) { - IoWrite8 ((UINTN)Address, *Uint8Buffer); - } else if (OperationWidth == EfiPeiCpuIoWidthUint16) { - if (Aligned) { - IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); - } else { - IoWrite16 ((UINTN)Address, ReadUnaligned16 ((UINT16 *)Uint8Buffer)); - } - } else if (OperationWidth == EfiPeiCpuIoWidthUint32) { - if (Aligned) { - IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); - } else { - IoWrite32 ((UINTN)Address, ReadUnaligned32 ((UINT32 *)Uint8Buffer)); - } - } - } - - return EFI_SUCCESS; -} - -/** - 8-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return An 8-bit value returned from the I/O space. -**/ -UINT8 -EFIAPI -CpuIoRead8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return IoRead8 ((UINTN)Address); -} - -/** - 16-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 16-bit value returned from the I/O space. - -**/ -UINT16 -EFIAPI -CpuIoRead16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return IoRead16 ((UINTN)Address); -} - -/** - 32-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 32-bit value returned from the I/O space. - -**/ -UINT32 -EFIAPI -CpuIoRead32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return IoRead32 ((UINTN)Address); -} - -/** - 64-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 64-bit value returned from the I/O space. - -**/ -UINT64 -EFIAPI -CpuIoRead64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return IoRead64 ((UINTN)Address); -} - -/** - 8-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT8 Data - ) -{ - IoWrite8 ((UINTN)Address, Data); -} - -/** - 16-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT16 Data - ) -{ - IoWrite16 ((UINTN)Address, Data); -} - -/** - 32-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT32 Data - ) -{ - IoWrite32 ((UINTN)Address, Data); -} - -/** - 64-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT64 Data - ) -{ - IoWrite64 ((UINTN)Address, Data); -} - -/** - 8-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return An 8-bit value returned from the memory space. - -**/ -UINT8 -EFIAPI -CpuMemRead8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return MmioRead8 ((UINTN)Address); -} - -/** - 16-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 16-bit value returned from the memory space. - -**/ -UINT16 -EFIAPI -CpuMemRead16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return MmioRead16 ((UINTN)Address); -} - -/** - 32-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 32-bit value returned from the memory space. - -**/ -UINT32 -EFIAPI -CpuMemRead32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return MmioRead32 ((UINTN)Address); -} - -/** - 64-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 64-bit value returned from the memory space. - -**/ -UINT64 -EFIAPI -CpuMemRead64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ) -{ - return MmioRead64 ((UINTN)Address); -} - -/** - 8-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT8 Data - ) -{ - MmioWrite8 ((UINTN)Address, Data); -} - -/** - 16-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT16 Data - ) -{ - MmioWrite16 ((UINTN)Address, Data); -} - -/** - 32-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT32 Data - ) -{ - MmioWrite32 ((UINTN)Address, Data); -} - -/** - 64-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT64 Data - ) -{ - MmioWrite64 ((UINTN)Address, Data); -} - -/** - The Entry point of the CPU I/O PEIM - - This function is the Entry point of the CPU I/O PEIM which installs CpuIoPpi. - - @param[in] FileHandle Pointer to image file handle. - @param[in] PeiServices Pointer to PEI Services Table - - @retval EFI_SUCCESS CPU I/O PPI successfully installed - -**/ -EFI_STATUS -EFIAPI -CpuIoInitialize ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - - // - // Register so it will be automatically shadowed to memory - // - Status = PeiServicesRegisterForShadow (FileHandle); - - // - // Make CpuIo pointer in PeiService table point to gCpuIoPpi - // - (*((EFI_PEI_SERVICES **)PeiServices))->CpuIo = &gCpuIoPpi; - - if (Status == EFI_ALREADY_STARTED) { - // - // Shadow completed and running from memory - // - DEBUG ((EFI_D_INFO, "CpuIO PPI has been loaded into memory. Reinstalled PPI=0x%x\n", &gCpuIoPpi)); - } else { - Status = PeiServicesInstallPpi (&gPpiList); - ASSERT_EFI_ERROR (Status); - } - - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPei.h b/UefiCpuPkg/CpuIoPei/CpuIoPei.h deleted file mode 100644 index 052f0e3d0e..0000000000 --- a/UefiCpuPkg/CpuIoPei/CpuIoPei.h +++ /dev/null @@ -1,448 +0,0 @@ -/** @file - Internal include file for the CPU I/O PPI. - -Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_IO2_PEI_H_ -#define _CPU_IO2_PEI_H_ - -#include - -#include - -#include -#include -#include -#include - -#define MAX_IO_PORT_ADDRESS 0xFFFF - -/** - Reads memory-mapped registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[out] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceRead ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Writes memory-mapped registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[in] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuMemoryServiceWrite ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -/** - Reads I/O registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[out] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceRead ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - OUT VOID *Buffer - ); - -/** - Write I/O registers. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Width The width of the access. Enumerated in bytes. - @param[in] Address The physical address of the access. - @param[in] Count The number of accesses to perform. - @param[in] Buffer A pointer to the buffer of data. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Width is invalid for this EFI system. - @retval EFI_INVALID_PARAMETER Buffer is NULL. - @retval EFI_UNSUPPORTED The address range specified by Address, Width, - and Count is not valid for this EFI system. - -**/ -EFI_STATUS -EFIAPI -CpuIoServiceWrite ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN EFI_PEI_CPU_IO_PPI_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN VOID *Buffer - ); - -/** - 8-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return An 8-bit value returned from the I/O space. -**/ -UINT8 -EFIAPI -CpuIoRead8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 16-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 16-bit value returned from the I/O space. - -**/ -UINT16 -EFIAPI -CpuIoRead16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 32-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 32-bit value returned from the I/O space. - -**/ -UINT32 -EFIAPI -CpuIoRead32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 64-bit I/O read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 64-bit value returned from the I/O space. - -**/ -UINT64 -EFIAPI -CpuIoRead64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 8-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT8 Data - ); - -/** - 16-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT16 Data - ); - -/** - 32-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT32 Data - ); - -/** - 64-bit I/O write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuIoWrite64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT64 Data - ); - -/** - 8-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return An 8-bit value returned from the memory space. - -**/ -UINT8 -EFIAPI -CpuMemRead8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 16-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 16-bit value returned from the memory space. - -**/ -UINT16 -EFIAPI -CpuMemRead16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 32-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 32-bit value returned from the memory space. - -**/ -UINT32 -EFIAPI -CpuMemRead32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 64-bit memory read operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - - @return A 64-bit value returned from the memory space. - -**/ -UINT64 -EFIAPI -CpuMemRead64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address - ); - -/** - 8-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite8 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT8 Data - ); - -/** - 16-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite16 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT16 Data - ); - -/** - 32-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite32 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT32 Data - ); - -/** - 64-bit memory write operations. - - @param[in] PeiServices An indirect pointer to the PEI Services Table published - by the PEI Foundation. - @param[in] This Pointer to local data for the interface. - @param[in] Address The physical address of the access. - @param[in] Data The data to write. - -**/ -VOID -EFIAPI -CpuMemWrite64 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_PEI_CPU_IO_PPI *This, - IN UINT64 Address, - IN UINT64 Data - ); - -#endif diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPei.inf b/UefiCpuPkg/CpuIoPei/CpuIoPei.inf deleted file mode 100644 index b72ad6bfaf..0000000000 --- a/UefiCpuPkg/CpuIoPei/CpuIoPei.inf +++ /dev/null @@ -1,51 +0,0 @@ -## @file -# Produces the CPU I/O PPI by using the services of the I/O Library. -# -# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuIoPei - MODULE_UNI_FILE = CpuIoPei.uni - FILE_GUID = AE265864-CF5D-41a8-913D-71C155E76442 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = CpuIoInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - CpuIoPei.c - CpuIoPei.h - -[Packages] - MdePkg/MdePkg.dec - -[LibraryClasses] - PeimEntryPoint - BaseLib - DebugLib - IoLib - PeiServicesLib - -[Ppis] - gEfiPeiCpuIoPpiInstalledGuid ## PRODUCES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - CpuIoPeiExtra.uni diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPei.uni b/UefiCpuPkg/CpuIoPei/CpuIoPei.uni deleted file mode 100644 index 0d8a14ef12..0000000000 --- a/UefiCpuPkg/CpuIoPei/CpuIoPei.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// Produces the CPU I/O PPI by using the services of the I/O Library. -// -// Produces the CPU I/O PPI by using the services of the I/O Library. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Produces the CPU I/O PPI by using the services of the I/O Library" - -#string STR_MODULE_DESCRIPTION #language en-US "Produces the CPU I/O PPI by using the services of the I/O Library." - diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni b/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni deleted file mode 100644 index cd1f53a0cc..0000000000 --- a/UefiCpuPkg/CpuIoPei/CpuIoPeiExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuIoPei Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU I/O PEI Module" - - diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c deleted file mode 100644 index bf18ca4556..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuBist.c +++ /dev/null @@ -1,295 +0,0 @@ -/** @file - Update and publish processors' BIST information. - - Copyright (c) 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuMpPei.h" - -EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2Ppi = { - SecPlatformInformation2 -}; - -EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2Ppi = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiSecPlatformInformation2PpiGuid, - &mSecPlatformInformation2Ppi -}; - -/** - Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. - - @param PeiServices The pointer to the PEI Services Table. - @param StructureSize The pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to - hold the record is returned in StructureSize. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation2 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - VOID *DataInHob; - UINTN DataSize; - - GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); - if (GuidHob == NULL) { - *StructureSize = 0; - return EFI_SUCCESS; - } - - DataInHob = GET_GUID_HOB_DATA (GuidHob); - DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); - - // - // return the information from BistHob - // - if ((*StructureSize) < (UINT64) DataSize) { - *StructureSize = (UINT64) DataSize; - return EFI_BUFFER_TOO_SMALL; - } - - *StructureSize = (UINT64) DataSize; - CopyMem (PlatformInformationRecord2, DataInHob, DataSize); - return EFI_SUCCESS; -} - -/** - Worker function to get CPUs' BIST by calling SecPlatformInformationPpi - or SecPlatformInformation2Ppi. - - @param PeiServices Pointer to PEI Services Table - @param Guid PPI Guid - @param PpiDescriptor Return a pointer to instance of the - EFI_PEI_PPI_DESCRIPTOR - @param BistInformationData Pointer to BIST information data - @param BistInformationSize Return the size in bytes of BIST information - - @retval EFI_SUCCESS Retrieve of the BIST data successfully - @retval EFI_NOT_FOUND No sec platform information(2) ppi export - @retval EFI_DEVICE_ERROR Failed to get CPU Information - -**/ -EFI_STATUS -GetBistInfoFromPpi ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_GUID *Guid, - OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, - OUT VOID **BistInformationData, - OUT UINT64 *BistInformationSize OPTIONAL - ) -{ - EFI_STATUS Status; - EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi; - EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; - UINT64 InformationSize; - - Status = PeiServicesLocatePpi ( - Guid, // GUID - 0, // INSTANCE - PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID **)&SecPlatformInformation2Ppi // PPI - ); - if (Status == EFI_NOT_FOUND) { - return EFI_NOT_FOUND; - } - - if (Status == EFI_SUCCESS) { - // - // Get the size of the sec platform information2(BSP/APs' BIST data) - // - InformationSize = 0; - SecPlatformInformation2 = NULL; - Status = SecPlatformInformation2Ppi->PlatformInformation2 ( - PeiServices, - &InformationSize, - SecPlatformInformation2 - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - Status = PeiServicesAllocatePool ( - (UINTN) InformationSize, - (VOID **) &SecPlatformInformation2 - ); - if (Status == EFI_SUCCESS) { - // - // Retrieve BIST data - // - Status = SecPlatformInformation2Ppi->PlatformInformation2 ( - PeiServices, - &InformationSize, - SecPlatformInformation2 - ); - if (Status == EFI_SUCCESS) { - *BistInformationData = SecPlatformInformation2; - if (BistInformationSize != NULL) { - *BistInformationSize = InformationSize; - } - return EFI_SUCCESS; - } - } - } - } - - return EFI_DEVICE_ERROR; -} - -/** - Collects BIST data from PPI. - - This function collects BIST data from Sec Platform Information2 PPI - or SEC Platform Information PPI. - - @param PeiServices Pointer to PEI Services Table - -**/ -VOID -CollectBistDataFromPpi ( - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor; - EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; - EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation; - UINTN NumberOfData; - EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; - EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance; - UINTN ProcessorNumber; - UINTN CpuIndex; - EFI_PROCESSOR_INFORMATION ProcessorInfo; - EFI_HEALTH_FLAGS BistData; - UINTN NumberOfProcessors; - UINTN NumberOfEnabledProcessors; - UINTN BistInformationSize; - EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2; - EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob; - - - MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors); - - BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + - sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors; - Status = PeiServicesAllocatePool ( - (UINTN) BistInformationSize, - (VOID **) &PlatformInformationRecord2 - ); - ASSERT_EFI_ERROR (Status); - PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors; - - SecPlatformInformation2 = NULL; - SecPlatformInformation = NULL; - NumberOfData = 0; - CpuInstance = NULL; - // - // Get BIST information from Sec Platform Information2 Ppi firstly - // - Status = GetBistInfoFromPpi ( - PeiServices, - &gEfiSecPlatformInformation2PpiGuid, - &SecInformationDescriptor, - (VOID *) &SecPlatformInformation2, - NULL - ); - if (Status == EFI_SUCCESS) { - // - // Sec Platform Information2 PPI includes BSP/APs' BIST information - // - NumberOfData = SecPlatformInformation2->NumberOfCpus; - CpuInstance = SecPlatformInformation2->CpuInstance; - } else { - // - // Otherwise, get BIST information from Sec Platform Information Ppi - // - Status = GetBistInfoFromPpi ( - PeiServices, - &gEfiSecPlatformInformationPpiGuid, - &SecInformationDescriptor, - (VOID *) &SecPlatformInformation, - NULL - ); - if (Status == EFI_SUCCESS) { - NumberOfData = 1; - // - // SEC Platform Information only includes BSP's BIST information - // and does not have BSP's APIC ID - // - BspCpuInstance.CpuLocation = GetInitialApicId (); - BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32; - CpuInstance = &BspCpuInstance; - } else { - DEBUG ((EFI_D_INFO, "Does not find any stored CPU BIST information from PPI!\n")); - } - } - for (ProcessorNumber = 0; ProcessorNumber < NumberOfProcessors; ProcessorNumber ++) { - MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData); - for (CpuIndex = 0; CpuIndex < NumberOfData; CpuIndex ++) { - ASSERT (CpuInstance != NULL); - if (ProcessorInfo.ProcessorId == CpuInstance[CpuIndex].CpuLocation) { - // - // Update processor's BIST data if it is already stored before - // - BistData = CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags; - } - } - if (BistData.Uint32 != 0) { - // - // Report Status Code that self test is failed - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST) - ); - } - DEBUG ((EFI_D_INFO, " APICID - 0x%08x, BIST - 0x%08x\n", - (UINT32) ProcessorInfo.ProcessorId, - BistData - )); - CpuInstanceInHob = PlatformInformationRecord2->CpuInstance; - CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId; - CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData; - } - - // - // Build SecPlatformInformation2 PPI GUIDed HOB that also could be consumed - // by CPU MP driver to get CPU BIST data - // - BuildGuidDataHob ( - &gEfiSecPlatformInformation2PpiGuid, - PlatformInformationRecord2, - (UINTN) BistInformationSize - ); - - if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) { - // - // Reinstall SecPlatformInformation2 PPI to include new BIST information - // - Status = PeiServicesReInstallPpi ( - SecInformationDescriptor, - &mPeiSecPlatformInformation2Ppi - ); - ASSERT_EFI_ERROR (Status); - } else { - // - // Install SecPlatformInformation2 PPI to include new BIST information - // - Status = PeiServicesInstallPpi (&mPeiSecPlatformInformation2Ppi); - ASSERT_EFI_ERROR(Status); - } -} - diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c deleted file mode 100644 index eaf99c73cd..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ /dev/null @@ -1,468 +0,0 @@ -/** @file - CPU PEI Module installs CPU Multiple Processor PPI. - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuMpPei.h" - -// -// CPU MP PPI to be installed -// -EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = { - PeiGetNumberOfProcessors, - PeiGetProcessorInfo, - PeiStartupAllAPs, - PeiStartupThisAP, - PeiSwitchBSP, - PeiEnableDisableAP, - PeiWhoAmI, -}; - -EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiMpServicesPpiGuid, - &mMpServicesPpi -}; - -/** - This service retrieves the number of logical processor in the platform - and the number of those logical processors that are enabled on this boot. - This service may only be called from the BSP. - - This function is used to retrieve the following information: - - The number of logical processors that are present in the system. - - The number of enabled logical processors in the system at the instant - this call is made. - - Because MP Service Ppi provides services to enable and disable processors - dynamically, the number of enabled logical processors may vary during the - course of a boot session. - - If this service is called from an AP, then EFI_DEVICE_ERROR is returned. - If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then - EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors - is returned in NumberOfProcessors, the number of currently enabled processor - is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to this instance of the PPI. - @param[out] NumberOfProcessors Pointer to the total number of logical processors in - the system, including the BSP and disabled APs. - @param[out] NumberOfEnabledProcessors - Number of processors in the system that are enabled. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. - NumberOfEnabledProcessors is NULL. -**/ -EFI_STATUS -EFIAPI -PeiGetNumberOfProcessors ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - OUT UINTN *NumberOfProcessors, - OUT UINTN *NumberOfEnabledProcessors - ) -{ - if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) { - return EFI_INVALID_PARAMETER; - } - - return MpInitLibGetNumberOfProcessors ( - NumberOfProcessors, - NumberOfEnabledProcessors - ); -} - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - This service retrieves detailed MP-related information about any processor - on the platform. Note the following: - - The processor information may change during the course of a boot session. - - The information presented here is entirely MP related. - - Information regarding the number of caches and their sizes, frequency of operation, - slot numbers is all considered platform-related information and is not provided - by this service. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to this instance of the PPI. - @param[in] ProcessorNumber Pointer to the total number of logical processors in - the system, including the BSP and disabled APs. - @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. -**/ -EFI_STATUS -EFIAPI -PeiGetProcessorInfo ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ) -{ - return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL); -} - -/** - This service executes a caller provided function on all enabled APs. APs can - run either simultaneously or one at a time in sequence. This service supports - both blocking requests only. This service may only - be called from the BSP. - - This function is used to dispatch all the enabled APs to the function specified - by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned - immediately and Procedure is not started on any AP. - - If SingleThread is TRUE, all the enabled APs execute the function specified by - Procedure one by one, in ascending order of processor handle number. Otherwise, - all the enabled APs execute the function specified by Procedure simultaneously. - - If the timeout specified by TimeoutInMicroSeconds expires before all APs return - from Procedure, then Procedure on the failed APs is terminated. All enabled APs - are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its - content points to the list of processor handle numbers in which Procedure was - terminated. - - Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - to make sure that the nature of the code that is executed on the BSP and the - dispatched APs is well controlled. The MP Services Ppi does not guarantee - that the Procedure function is MP-safe. Hence, the tasks that can be run in - parallel are limited to certain independent tasks and well-controlled exclusive - code. PEI services and Ppis may not be called by APs unless otherwise - specified. - - In blocking execution mode, BSP waits until all APs finish or - TimeoutInMicroSeconds expires. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] Procedure A pointer to the function to be run on enabled APs of - the system. - @param[in] SingleThread If TRUE, then all the enabled APs execute the function - specified by Procedure one by one, in ascending order - of processor handle number. If FALSE, then all the - enabled APs execute the function specified by Procedure - simultaneously. - @param[in] TimeoutInMicroSeconds - Indicates the time limit in microseconds for APs to - return from Procedure, for blocking mode only. Zero - means infinity. If the timeout expires before all APs - return from Procedure, then Procedure on the failed APs - is terminated. All enabled APs are available for next - function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the - timeout expires in blocking mode, BSP returns - EFI_TIMEOUT. - @param[in] ProcedureArgument The parameter passed into Procedure for all APs. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before the - timeout expired. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before all - enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. -**/ -EFI_STATUS -EFIAPI -PeiStartupAllAPs ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN UINTN TimeoutInMicroSeconds, - IN VOID *ProcedureArgument OPTIONAL - ) -{ - return MpInitLibStartupAllAPs ( - Procedure, - SingleThread, - NULL, - TimeoutInMicroSeconds, - ProcedureArgument, - NULL - ); -} - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. The caller can request the BSP to wait for the completion - of the AP. This service may only be called from the BSP. - - This function is used to dispatch one enabled AP to the function specified by - Procedure passing in the argument specified by ProcedureArgument. - The execution is in blocking mode. The BSP waits until the AP finishes or - TimeoutInMicroSecondss expires. - - If the timeout specified by TimeoutInMicroseconds expires before the AP returns - from Procedure, then execution of Procedure by the AP is terminated. The AP is - available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and - EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] Procedure A pointer to the function to be run on enabled APs of - the system. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] TimeoutInMicroseconds - Indicates the time limit in microseconds for APs to - return from Procedure, for blocking mode only. Zero - means infinity. If the timeout expires before all APs - return from Procedure, then Procedure on the failed APs - is terminated. All enabled APs are available for next - function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the - timeout expires in blocking mode, BSP returns - EFI_TIMEOUT. - @param[in] ProcedureArgument The parameter passed into Procedure for all APs. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before the - timeout expires. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before the - specified AP has finished. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. -**/ -EFI_STATUS -EFIAPI -PeiStartupThisAP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL - ) -{ - return MpInitLibStartupThisAP ( - Procedure, - ProcessorNumber, - NULL, - TimeoutInMicroseconds, - ProcedureArgument, - NULL - ); -} - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. The new BSP can take over the - execution of the old BSP and continue seamlessly from where the old one left - off. - - If the BSP cannot be switched prior to the return from this service, then - EFI_UNSUPPORTED must be returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled - AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this - service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_SUCCESS The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled - AP. - @retval EFI_NOT_READY The specified AP is busy. -**/ -EFI_STATUS -EFIAPI -PeiSwitchBSP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ) -{ - return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); -} - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - This service allows the caller enable or disable an AP from this point onward. - The caller can optionally specify the health status of the AP by Health. If - an AP is being disabled, then the state of the disabled AP is implementation - dependent. If an AP is enabled, then the implementation must guarantee that a - complete initialization sequence is performed on the AP, so the AP is in a state - that is compatible with an MP operating system. - - If the enable or disable AP operation cannot be completed prior to the return - from this service, then EFI_UNSUPPORTED must be returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for enabled, - FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies the - new health status of the AP. This flag corresponds to - StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo(). - Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter is - ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior - to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. -**/ -EFI_STATUS -EFIAPI -PeiEnableDisableAP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ) -{ - return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); -} - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - This service returns the processor handle number for the calling processor. - The returned value is in the range from 0 to the total number of logical - processors minus 1. The total number of logical processors can be retrieved - with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be - called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER - is returned. Otherwise, the current processors handle number is returned in - ProcessorNumber, and EFI_SUCCESS is returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned in - ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. -**/ -EFI_STATUS -EFIAPI -PeiWhoAmI ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - OUT UINTN *ProcessorNumber - ) -{ - return MpInitLibWhoAmI (ProcessorNumber); -} - -/** - The Entry point of the MP CPU PEIM. - - This function will wakeup APs and collect CPU AP count and install the - Mp Service Ppi. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Describes the list of possible PEI Services. - - @retval EFI_SUCCESS MpServicePpi is installed successfully. - -**/ -EFI_STATUS -EFIAPI -CpuMpPeimInit ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - EFI_VECTOR_HANDOFF_INFO *VectorInfo; - EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi; - - // - // Get Vector Hand-off Info PPI - // - VectorInfo = NULL; - Status = PeiServicesLocatePpi ( - &gEfiVectorHandoffInfoPpiGuid, - 0, - NULL, - (VOID **)&VectorHandoffInfoPpi - ); - if (Status == EFI_SUCCESS) { - VectorInfo = VectorHandoffInfoPpi->Info; - } - Status = InitializeCpuExceptionHandlers (VectorInfo); - ASSERT_EFI_ERROR (Status); - - // - // Wakeup APs to do initialization - // - Status = MpInitLibInitialize (); - ASSERT_EFI_ERROR (Status); - - // - // Update and publish CPU BIST information - // - CollectBistDataFromPpi (PeiServices); - - // - // Install CPU MP PPI - // - Status = PeiServicesInstallPpi(&mPeiCpuMpPpiDesc); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h deleted file mode 100644 index 0836593efc..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ /dev/null @@ -1,405 +0,0 @@ -/** @file - Definitions to install Multiple Processor PPI. - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_MP_PEI_H_ -#define _CPU_MP_PEI_H_ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; - -/** - This service retrieves the number of logical processor in the platform - and the number of those logical processors that are enabled on this boot. - This service may only be called from the BSP. - - This function is used to retrieve the following information: - - The number of logical processors that are present in the system. - - The number of enabled logical processors in the system at the instant - this call is made. - - Because MP Service Ppi provides services to enable and disable processors - dynamically, the number of enabled logical processors may vary during the - course of a boot session. - - If this service is called from an AP, then EFI_DEVICE_ERROR is returned. - If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then - EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors - is returned in NumberOfProcessors, the number of currently enabled processor - is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to this instance of the PPI. - @param[out] NumberOfProcessors Pointer to the total number of logical processors in - the system, including the BSP and disabled APs. - @param[out] NumberOfEnabledProcessors - Number of processors in the system that are enabled. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. - NumberOfEnabledProcessors is NULL. -**/ -EFI_STATUS -EFIAPI -PeiGetNumberOfProcessors ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - OUT UINTN *NumberOfProcessors, - OUT UINTN *NumberOfEnabledProcessors - ); - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - This service retrieves detailed MP-related information about any processor - on the platform. Note the following: - - The processor information may change during the course of a boot session. - - The information presented here is entirely MP related. - - Information regarding the number of caches and their sizes, frequency of operation, - slot numbers is all considered platform-related information and is not provided - by this service. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This Pointer to this instance of the PPI. - @param[in] ProcessorNumber Pointer to the total number of logical processors in - the system, including the BSP and disabled APs. - @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. -**/ -EFI_STATUS -EFIAPI -PeiGetProcessorInfo ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ); - -/** - This service executes a caller provided function on all enabled APs. APs can - run either simultaneously or one at a time in sequence. This service supports - both blocking requests only. This service may only - be called from the BSP. - - This function is used to dispatch all the enabled APs to the function specified - by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned - immediately and Procedure is not started on any AP. - - If SingleThread is TRUE, all the enabled APs execute the function specified by - Procedure one by one, in ascending order of processor handle number. Otherwise, - all the enabled APs execute the function specified by Procedure simultaneously. - - If the timeout specified by TimeoutInMicroSeconds expires before all APs return - from Procedure, then Procedure on the failed APs is terminated. All enabled APs - are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its - content points to the list of processor handle numbers in which Procedure was - terminated. - - Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - to make sure that the nature of the code that is executed on the BSP and the - dispatched APs is well controlled. The MP Services Ppi does not guarantee - that the Procedure function is MP-safe. Hence, the tasks that can be run in - parallel are limited to certain independent tasks and well-controlled exclusive - code. PEI services and Ppis may not be called by APs unless otherwise - specified. - - In blocking execution mode, BSP waits until all APs finish or - TimeoutInMicroSeconds expires. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] Procedure A pointer to the function to be run on enabled APs of - the system. - @param[in] SingleThread If TRUE, then all the enabled APs execute the function - specified by Procedure one by one, in ascending order - of processor handle number. If FALSE, then all the - enabled APs execute the function specified by Procedure - simultaneously. - @param[in] TimeoutInMicroSeconds - Indicates the time limit in microseconds for APs to - return from Procedure, for blocking mode only. Zero - means infinity. If the timeout expires before all APs - return from Procedure, then Procedure on the failed APs - is terminated. All enabled APs are available for next - function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the - timeout expires in blocking mode, BSP returns - EFI_TIMEOUT. - @param[in] ProcedureArgument The parameter passed into Procedure for all APs. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before the - timeout expired. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before all - enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. -**/ -EFI_STATUS -EFIAPI -PeiStartupAllAPs ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN UINTN TimeoutInMicroSeconds, - IN VOID *ProcedureArgument OPTIONAL - ); - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. The caller can request the BSP to wait for the completion - of the AP. This service may only be called from the BSP. - - This function is used to dispatch one enabled AP to the function specified by - Procedure passing in the argument specified by ProcedureArgument. - The execution is in blocking mode. The BSP waits until the AP finishes or - TimeoutInMicroSecondss expires. - - If the timeout specified by TimeoutInMicroseconds expires before the AP returns - from Procedure, then execution of Procedure by the AP is terminated. The AP is - available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and - EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] Procedure A pointer to the function to be run on enabled APs of - the system. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] TimeoutInMicroseconds - Indicates the time limit in microseconds for APs to - return from Procedure, for blocking mode only. Zero - means infinity. If the timeout expires before all APs - return from Procedure, then Procedure on the failed APs - is terminated. All enabled APs are available for next - function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() - or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the - timeout expires in blocking mode, BSP returns - EFI_TIMEOUT. - @param[in] ProcedureArgument The parameter passed into Procedure for all APs. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before the - timeout expires. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before the - specified AP has finished. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. -**/ -EFI_STATUS -EFIAPI -PeiStartupThisAP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL - ); - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. The new BSP can take over the - execution of the old BSP and continue seamlessly from where the old one left - off. - - If the BSP cannot be switched prior to the return from this service, then - EFI_UNSUPPORTED must be returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled - AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this - service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_SUCCESS The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled - AP. - @retval EFI_NOT_READY The specified AP is busy. -**/ -EFI_STATUS -EFIAPI -PeiSwitchBSP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ); - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - This service allows the caller enable or disable an AP from this point onward. - The caller can optionally specify the health status of the AP by Health. If - an AP is being disabled, then the state of the disabled AP is implementation - dependent. If an AP is enabled, then the implementation must guarantee that a - complete initialization sequence is performed on the AP, so the AP is in a state - that is compatible with an MP operating system. - - If the enable or disable AP operation cannot be completed prior to the return - from this service, then EFI_UNSUPPORTED must be returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for enabled, - FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies the - new health status of the AP. This flag corresponds to - StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo(). - Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter is - ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior - to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. -**/ -EFI_STATUS -EFIAPI -PeiEnableDisableAP ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ); - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - This service returns the processor handle number for the calling processor. - The returned value is in the range from 0 to the total number of logical - processors minus 1. The total number of logical processors can be retrieved - with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be - called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER - is returned. Otherwise, the current processors handle number is returned in - ProcessorNumber, and EFI_SUCCESS is returned. - - @param[in] PeiServices An indirect pointer to the PEI Services Table - published by the PEI Foundation. - @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance. - @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the - total number of logical processors minus 1. The total - number of logical processors can be retrieved by - EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned in - ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. -**/ -EFI_STATUS -EFIAPI -PeiWhoAmI ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_MP_SERVICES_PPI *This, - OUT UINTN *ProcessorNumber - ); - -/** - Collects BIST data from PPI. - - This function collects BIST data from Sec Platform Information2 PPI - or SEC Platform Information PPI. - - @param PeiServices Pointer to PEI Services Table - -**/ -VOID -CollectBistDataFromPpi ( - IN CONST EFI_PEI_SERVICES **PeiServices - ); - -/** - Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. - - @param PeiServices The pointer to the PEI Services Table. - @param StructureSize The pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to - hold the record is returned in StructureSize. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation2 ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 - ); - -#endif diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf deleted file mode 100644 index 3b40d88201..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ /dev/null @@ -1,66 +0,0 @@ -## @file -# CPU driver installs CPU PI Multi-processor PPI. -# -# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuMpPei - MODULE_UNI_FILE = CpuMpPei.uni - FILE_GUID = EDADEB9D-DDBA-48BD-9D22-C1C169C8C5C6 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = CpuMpPeimInit - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - CpuMpPei.h - CpuMpPei.c - CpuBist.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - HobLib - LocalApicLib - PeimEntryPoint - PeiServicesLib - ReportStatusCodeLib - CpuExceptionHandlerLib - MpInitLib - BaseMemoryLib - -[Ppis] - gEfiPeiMpServicesPpiGuid ## PRODUCES - gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES - ## SOMETIMES_CONSUMES - ## PRODUCES - ## UNDEFINED # HOB - gEfiSecPlatformInformation2PpiGuid - gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES - -[Depex] - gEfiPeiMemoryDiscoveredPpiGuid - -[UserExtensions.TianoCore."ExtraFiles"] - CpuMpPeiExtra.uni - diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.uni b/UefiCpuPkg/CpuMpPei/CpuMpPei.uni deleted file mode 100644 index d458d0d624..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU driver installs CPU PI Multi-processor PPI. -// -// CPU driver installs CPU PI Multi-processor PPI. -// -// Copyright (c) 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Installs CPU PI Multi-processor PPI" - -#string STR_MODULE_DESCRIPTION #language en-US "CPU driver installs CPU PI Multi-processor PPI." - diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni b/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni deleted file mode 100644 index cf832fb80b..0000000000 --- a/UefiCpuPkg/CpuMpPei/CpuMpPeiExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuMpPei Localized Strings and Content -// -// Copyright (c) 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"CPU Multi-processor PEIM Driver" - - diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c deleted file mode 100644 index dccb406b8d..0000000000 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c +++ /dev/null @@ -1,292 +0,0 @@ -/** @file -ACPI CPU Data initialization module - -This module initializes the ACPI_CPU_DATA structure and registers the address -of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple -version of this module. It does not provide a machine check handler or CPU -register initialization tables for ACPI S3 resume. It also only supports the -number of CPUs reported by the MP Services Protocol, so this module does not -support hot plug CPUs. This module can be copied into a CPU specific package -and customized if these additional features are required. - -Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2015, Red Hat, Inc. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -// -// Data structure used to allocate ACPI_CPU_DATA and its supporting structures -// -typedef struct { - ACPI_CPU_DATA AcpiCpuData; - MTRR_SETTINGS MtrrTable; - IA32_DESCRIPTOR GdtrProfile; - IA32_DESCRIPTOR IdtrProfile; -} ACPI_CPU_DATA_EX; - -/** - Allocate EfiACPIMemoryNVS below 4G memory address. - - This function allocates EfiACPIMemoryNVS below 4G memory address. - - @param[in] Size Size of memory to allocate. - - @return Allocated address for output. - -**/ -VOID * -AllocateAcpiNvsMemoryBelow4G ( - IN UINTN Size - ) -{ - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - VOID *Buffer; - - Address = BASE_4GB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (Size), - &Address - ); - if (EFI_ERROR (Status)) { - return NULL; - } - - Buffer = (VOID *)(UINTN)Address; - ZeroMem (Buffer, Size); - - return Buffer; -} - -/** - Callback function executed when the EndOfDxe event group is signaled. - - We delay allocating StartupVector and saving the MTRR settings until BDS signals EndOfDxe. - - @param[in] Event Event whose notification function is being invoked. - @param[out] Context Pointer to the MTRR_SETTINGS buffer to fill in. -**/ -VOID -EFIAPI -CpuS3DataOnEndOfDxe ( - IN EFI_EVENT Event, - OUT VOID *Context - ) -{ - EFI_STATUS Status; - ACPI_CPU_DATA_EX *AcpiCpuDataEx; - - AcpiCpuDataEx = (ACPI_CPU_DATA_EX *) Context; - // - // Allocate a 4KB reserved page below 1MB - // - AcpiCpuDataEx->AcpiCpuData.StartupVector = BASE_1MB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - 1, - &AcpiCpuDataEx->AcpiCpuData.StartupVector - ); - ASSERT_EFI_ERROR (Status); - - DEBUG ((EFI_D_VERBOSE, "%a\n", __FUNCTION__)); - MtrrGetAllMtrrs (&AcpiCpuDataEx->MtrrTable); - - // - // Close event, so it will not be invoked again. - // - gBS->CloseEvent (Event); -} - -/** - The entry function of the CpuS3Data driver. - - Allocate and initialize all fields of the ACPI_CPU_DATA structure except the - MTRR settings. Register an event notification on gEfiEndOfDxeEventGroupGuid - to capture the ACPI_CPU_DATA MTRR settings. The PcdCpuS3DataAddress is set - to the address that ACPI_CPU_DATA is allocated at. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval EFI_UNSUPPORTED Do not support ACPI S3. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -CpuS3DataInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - ACPI_CPU_DATA_EX *AcpiCpuDataEx; - ACPI_CPU_DATA *AcpiCpuData; - EFI_MP_SERVICES_PROTOCOL *MpServices; - UINTN NumberOfCpus; - UINTN NumberOfEnabledProcessors; - VOID *Stack; - UINTN TableSize; - CPU_REGISTER_TABLE *RegisterTable; - UINTN Index; - EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; - UINTN GdtSize; - UINTN IdtSize; - VOID *Gdt; - VOID *Idt; - EFI_EVENT Event; - ACPI_CPU_DATA *OldAcpiCpuData; - - if (!PcdGetBool (PcdAcpiS3Enable)) { - return EFI_UNSUPPORTED; - } - - // - // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure - // - OldAcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress); - - // - // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume. - // - AcpiCpuDataEx = AllocateAcpiNvsMemoryBelow4G (sizeof (ACPI_CPU_DATA_EX)); - ASSERT (AcpiCpuDataEx != NULL); - AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData; - - // - // Get MP Services Protocol - // - Status = gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&MpServices - ); - ASSERT_EFI_ERROR (Status); - - // - // Get the number of CPUs - // - Status = MpServices->GetNumberOfProcessors ( - MpServices, - &NumberOfCpus, - &NumberOfEnabledProcessors - ); - ASSERT_EFI_ERROR (Status); - AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; - - // - // Initialize ACPI_CPU_DATA fields - // - AcpiCpuData->StackSize = PcdGet32 (PcdCpuApStackSize); - AcpiCpuData->ApMachineCheckHandlerBase = 0; - AcpiCpuData->ApMachineCheckHandlerSize = 0; - AcpiCpuData->GdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->GdtrProfile; - AcpiCpuData->IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->IdtrProfile; - AcpiCpuData->MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable; - - // - // Allocate stack space for all CPUs - // - Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize); - ASSERT (Stack != NULL); - AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; - - // - // Get the boot processor's GDT and IDT - // - AsmReadGdtr (&AcpiCpuDataEx->GdtrProfile); - AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile); - - // - // Allocate GDT and IDT in ACPI NVS and copy current GDT and IDT contents - // - GdtSize = AcpiCpuDataEx->GdtrProfile.Limit + 1; - IdtSize = AcpiCpuDataEx->IdtrProfile.Limit + 1; - Gdt = AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize); - ASSERT (Gdt != NULL); - Idt = (VOID *)((UINTN)Gdt + GdtSize); - CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize); - CopyMem (Idt, (VOID *)AcpiCpuDataEx->IdtrProfile.Base, IdtSize); - AcpiCpuDataEx->GdtrProfile.Base = (UINTN)Gdt; - AcpiCpuDataEx->IdtrProfile.Base = (UINTN)Idt; - - if (OldAcpiCpuData != NULL) { - AcpiCpuData->RegisterTable = OldAcpiCpuData->RegisterTable; - AcpiCpuData->PreSmmInitRegisterTable = OldAcpiCpuData->PreSmmInitRegisterTable; - } else { - // - // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs - // - TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); - RegisterTable = (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G (TableSize); - ASSERT (RegisterTable != NULL); - - for (Index = 0; Index < NumberOfCpus; Index++) { - Status = MpServices->GetProcessorInfo ( - MpServices, - Index, - &ProcessorInfoBuffer - ); - ASSERT_EFI_ERROR (Status); - - RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; - RegisterTable[Index].TableLength = 0; - RegisterTable[Index].AllocatedSize = 0; - RegisterTable[Index].RegisterTableEntry = 0; - - RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; - RegisterTable[NumberOfCpus + Index].TableLength = 0; - RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; - RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; - } - AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; - AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); - } - - // - // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure - // - Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData); - ASSERT_EFI_ERROR (Status); - - // - // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. - // The notification function allocates StartupVector and saves MTRRs for ACPI_CPU_DATA - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - CpuS3DataOnEndOfDxe, - AcpiCpuData, - &gEfiEndOfDxeEventGroupGuid, - &Event - ); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf deleted file mode 100644 index 480c98ebcd..0000000000 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf +++ /dev/null @@ -1,70 +0,0 @@ -## @file -# ACPI CPU Data initialization module -# -# This module initializes the ACPI_CPU_DATA structure and registers the address -# of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple -# version of this module. It does not provide a machine check handler or CPU -# register initialization tables for ACPI S3 resume. It also only supports the -# number of CPUs reported by the MP Services Protocol, so this module does not -# support hot plug CPUs. This module can be copied into a CPU specific package -# and customized if these additional features are required. -# -# Copyright (c) 2013-2016, Intel Corporation. All rights reserved.
-# Copyright (c) 2015, Red Hat, Inc. -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuS3DataDxe - MODULE_UNI_FILE = CpuS3DataDxe.uni - FILE_GUID = 4D2E57EE-0E3F-44DD-93C4-D3B57E96945D - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = CpuS3DataInitialize - -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 - -[Sources] - CpuS3Data.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - UefiBootServicesTableLib - BaseMemoryLib - DebugLib - BaseLib - MtrrLib - -[Guids] - gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event - -[Protocols] - gEfiMpServiceProtocolGuid ## CONSUMES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES - -[Depex] - gEfiMpServiceProtocolGuid - -[UserExtensions.TianoCore."ExtraFiles"] - CpuS3DataDxeExtra.uni diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni deleted file mode 100644 index 4a0218f180..0000000000 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.uni +++ /dev/null @@ -1,40 +0,0 @@ -// /** @file -// ACPI CPU Data initialization module -// -// This module initializes the ACPI_CPU_DATA structure and registers the address -// of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple -// version of this module. It does not provide a machine check handler or CPU -// register initialization tables for ACPI S3 resume. It also only supports the -// number of CPUs reported by the MP Services Protocol, so this module does not -// support hot plug CPUs. This module can be copied into a CPU specific package -// and customized if these additional features are required. -// -// Copyright (c) 2015, Intel Corporation. All rights reserved.
-// -// Copyright (c) 2015, Red Hat, Inc. -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT -#language en-US -"ACPI CPU Data initialization module" - -#string STR_MODULE_DESCRIPTION -#language en-US -"This module initializes the ACPI_CPU_DATA structure and registers the address " -"of this structure in the PcdCpuS3DataAddress PCD. This is a generic/simple " -"version of this module. It does not provide a machine check handler or CPU " -"register initialization tables for ACPI S3 resume. It also only supports the " -"number of CPUs reported by the MP Services Protocol, so this module does not " -"support hot plug CPUs. This module can be copied into a CPU specific package " -"and customized if these additional features are required." - - diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni deleted file mode 100644 index 050f25f843..0000000000 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// CpuS3DataDxe Localized Strings and Content -// -// Copyright (c) 2015, Intel Corporation. All rights reserved.
-// -// Copyright (c) 2015, Red Hat, Inc. -// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME #language en-US "CpuS3DataDxe module" - - diff --git a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c b/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c deleted file mode 100644 index 7a5ec152d7..0000000000 --- a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.c +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - Microcode flash device access library NULL instance. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include - -/** - Perform microcode write opreation. - - @param[in] FlashAddress The address of flash device to be accessed. - @param[in] Buffer The pointer to the data buffer. - @param[in] Length The length of data buffer in bytes. - - @retval EFI_SUCCESS The operation returns successfully. - @retval EFI_WRITE_PROTECTED The flash device is read only. - @retval EFI_UNSUPPORTED The flash device access is unsupported. - @retval EFI_INVALID_PARAMETER The input parameter is not valid. -**/ -EFI_STATUS -EFIAPI -MicrocodeFlashWrite ( - IN EFI_PHYSICAL_ADDRESS FlashAddress, - IN VOID *Buffer, - IN UINTN Length - ) -{ - CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length); - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf b/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf deleted file mode 100644 index a4a47e0737..0000000000 --- a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# Microcode flash device access library. -# -# Microcode flash device access library NULL instance. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = MicrocodeFlashAccessLibNull - MODULE_UNI_FILE = MicrocodeFlashAccessLibNull.uni - FILE_GUID = 6F871ADD-9D86-4676-8BAD-68E2E451FC5B - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = MicrocodeFlashAccessLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - MicrocodeFlashAccessLibNull.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseMemoryLib diff --git a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni b/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni deleted file mode 100644 index cc4195c412..0000000000 --- a/UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Microcode flash device access library. -// -// Microcode flash device access library NULL instance. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Microcode flash device access library." - -#string STR_MODULE_DESCRIPTION #language en-US "Microcode flash device access library NULL instance." - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc deleted file mode 100644 index 1b22c55117..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc +++ /dev/null @@ -1,33 +0,0 @@ -## @file -# MicrocodeCapsulePdb -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] -# -# Uncomment the following line and update with your platform pkg name -# -# PLATFORM_NAME = - PLATFORM_GUID = 6875FD33-602E-4EF9-9DF2-8BA7D8B7A7AF - PLATFORM_VERSION = 0.1 -# -# Uncomment the following line and update with your platform pkg name -# -# FLASH_DEFINITION = /MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf -# -# Uncomment the following line and update with your platform pkg name -# -# OUTPUT_DIRECTORY = Build/ - SUPPORTED_ARCHITECTURES = IA32|X64 - BUILD_TARGETS = DEBUG|RELEASE - SKUID_IDENTIFIER = DEFAULT diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf deleted file mode 100644 index f171604d4f..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf +++ /dev/null @@ -1,32 +0,0 @@ -## @file -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[FmpPayload.FmpPayloadMicrocode1] -IMAGE_HEADER_INIT_VERSION = 0x02 -IMAGE_TYPE_ID = 96d4fdcd-1502-424d-9d4c-9b12d2dcae5c # Microcode GUID (do not change it) -IMAGE_INDEX = 0x1 -HARDWARE_INSTANCE = 0x0 - -# -# Uncomment the following line and update with path to Microcode PDB file -# -#FILE DATA = $(WORKSPACE)//Microcode/Microcode.pdb - -[Capsule.MicrocodeCapsule] -CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # FMP special Guid (do not change it) -CAPSULE_FLAGS = PersistAcrossReset,InitiateReset -CAPSULE_HEADER_SIZE = 0x20 -CAPSULE_HEADER_INIT_VERSION = 0x1 - -FMP_PAYLOAD = FmpPayloadMicrocode1 diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md deleted file mode 100644 index 9f81373fda..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsulePdb/Readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# How to generate Microcode FMP from Microcode PDB file - -1) Copy directory `UefiCpuPkg/Feature/Capsule/MicrocodeUpdatePdb` to `/MicrocodeUpdatePdb`. - -2) Uncomment and update `FILE DATA` statement in `/MicrocodeUpdatePdb/MicrocodeCapsulePdb.fdf` with path to a Microcode PDB file. The PDB file can placed in `/MicrocodeUpdatePdb` or any other path. - -`FILE DATA = ` - -Uncomment and update `PLATFORM_NAME`, `FLASH_DEFINITION`, `OUTPUT_DIRECTORY` section in `/MicrocodeUpdatePdb/MicrocodeCapsulePdb.dsc` with . - - PLATFORM_NAME = - FLASH_DEFINITION = /MicrocodeCapsulePdb/MicrocodeCapsulePdb.fdf - OUTPUT_DIRECTORY = Build/ - -3) Use EDK II build tools to generate the Microcode FMP Capsule - -`build -p /MicrocodeCapsulePdb/MicrocodeCapsulePdb.dsc` - -4) The Microcode FMP Capsule is generated at `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/MicrocodeCapsule.Cap` - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf deleted file mode 100644 index 81af841f2c..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Microcode/Microcode.inf +++ /dev/null @@ -1,27 +0,0 @@ -## @file -# Microcode text file to binary -# -# Convert text format microcode to binary format. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] -BASE_NAME = Microcode -FILE_GUID = ABC36AAC-2031-4422-896E-0A3B899AD0B4 -COMPONENT_TYPE = Microcode -FFS_EXT = .ffs - -[Sources] -# -# Uncomment the following line and update with name of Microcode TXT file -# -#Microcode.txt diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc deleted file mode 100644 index a66f89b4e2..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc +++ /dev/null @@ -1,39 +0,0 @@ -## @file -# MicrocodeCapsuleTxt -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] -# -# Uncomment the following line and update with your platform pkg name -# -# PLATFORM_NAME = - PLATFORM_GUID = 6875FD33-602E-4EF9-9DF2-8BA7D8B7A7AF - PLATFORM_VERSION = 0.1 -# -# Uncomment the following line and update with your platform pkg name -# -# FLASH_DEFINITION = /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf -# -# Uncomment the following line and update with your platform pkg name -# -# OUTPUT_DIRECTORY = Build/ - SUPPORTED_ARCHITECTURES = IA32|X64 - BUILD_TARGETS = DEBUG|RELEASE - SKUID_IDENTIFIER = DEFAULT - -[Components] -# -# Uncomment the following line and update with path to Microcode INF file -# -# /MicrocodeCapsuleTxt/Microcode/Microcode.inf diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf deleted file mode 100644 index 113693b1df..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf +++ /dev/null @@ -1,32 +0,0 @@ -## @file -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[FmpPayload.FmpPayloadMicrocode1] -IMAGE_HEADER_INIT_VERSION = 0x02 -IMAGE_TYPE_ID = 96d4fdcd-1502-424d-9d4c-9b12d2dcae5c # Microcode GUID (do not change it) -IMAGE_INDEX = 0x1 -HARDWARE_INSTANCE = 0x0 - -# -# Uncomment the following line and update with path to Microcode MCB file -# -#FILE DATA = $(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/IA32/PlatformPkg/MicrocodeCapsuleTxt/Microcode/Microcode/OUTPUT/Microcode.mcb - -[Capsule.MicrocodeCapsule] -CAPSULE_GUID = 6dcbd5ed-e82d-4c44-bda1-7194199ad92a # FMP special Guid (do not change it) -CAPSULE_FLAGS = PersistAcrossReset,InitiateReset -CAPSULE_HEADER_SIZE = 0x20 -CAPSULE_HEADER_INIT_VERSION = 0x1 - -FMP_PAYLOAD = FmpPayloadMicrocode1 diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md b/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md deleted file mode 100644 index f7d7040fcb..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeCapsuleTxt/Readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# How to generate Microcode FMP from Microcode TXT file - -1) Copy directory `UefiCpuPkg/Feature/Capsule/MicrocodeUpdateTxt` to `/MicrocodeUpdateTxt` - -2) Copy microcode TXT file to`/MicrocodeUpdateTxt/Microcode` - -3) Uncomment and update statement in `[Sources]` section of `/MicrocodeUpdateTxt/Microcode/Microcode.inf` with name of Microcode TXT file copied in previous step. - - [Sources] - - -Uncomment and update `FILE DATA` statement in `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.fdf` with path to a Microcode MCB file. The MCB file is placed in `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/IA32//MicrocodeUpdateTxt/Microcode/Microcode/OUTPUT/`. - -`FILE DATA = ` - -Uncomment and update `PLATFORM_NAME`, `FLASH_DEFINITION`, `OUTPUT_DIRECTORY` section in `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.dsc` with . - - PLATFORM_NAME = - FLASH_DEFINITION = /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.fdf - OUTPUT_DIRECTORY = Build/ - -Uncomment and update statement in `Components` section of `/MicrocodeUpdateTxt/MicrocodeCapsuleTxt.dsc` with path to a Microcode INF file. - - [Components] - - -4) Use EDK II build tools to generate the Microcode FMP Capsule - -`build -p /MicrocodeCapsuleTxt/MicrocodeCapsuleTxt.dsc` - -5) The generated Microcode FMP Capsule is found at `$(WORKSPACE)/$(OUTPUT_DIRECTORY)/$(TARGET)_$(TOOL_CHAIN_TAG)/FV/MicrocodeCapsule.Cap` - - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c deleted file mode 100644 index ebde93a91e..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c +++ /dev/null @@ -1,748 +0,0 @@ -/** @file - Produce FMP instance for Microcode. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MicrocodeUpdate.h" - -// -// MicrocodeFmp driver private data -// -MICROCODE_FMP_PRIVATE_DATA *mMicrocodeFmpPrivate = NULL; - -EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = { - FmpGetImageInfo, - FmpGetImage, - FmpSetImage, - FmpCheckImage, - FmpGetPackageInfo, - FmpSetPackageInfo -}; - -/** - Initialize Microcode Descriptor. - - @param[in] MicrocodeFmpPrivate private data structure to be initialized. - - @return EFI_SUCCESS Microcode Descriptor is initialized. -**/ -EFI_STATUS -InitializeMicrocodeDescriptor ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ); - -/** - Returns information about the current firmware image(s) of the device. - - This function allows a copy of the current firmware image to be created and saved. - The saved copy could later been used, for example, in firmware image recovery or rollback. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer. - On input, this is the size of the buffer allocated by the caller. - On output, it is the size of the buffer returned by the firmware - if the buffer was large enough, or the size of the buffer needed - to contain the image(s) information if the buffer was too small. - @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s) - information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs. - @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number - associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] DescriptorCount A pointer to the location in which firmware returns the number of - descriptors or firmware images within this device. - @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes, - of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] PackageVersion A version number that represents all the firmware images in the device. - The format is vendor specific and new version must have a greater value - than the old version. If PackageVersion is not supported, the value is - 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison - is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates - that package version update is in progress. - @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the - package version name. The buffer is allocated by this function with - AllocatePool(), and it is the caller's responsibility to free it with a call - to FreePool(). - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size - needed to hold the image(s) information is returned in ImageInfoSize. - @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL. - @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image. - -**/ -EFI_STATUS -EFIAPI -FmpGetImageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN OUT UINTN *ImageInfoSize, - IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, - OUT UINT32 *DescriptorVersion, - OUT UINT8 *DescriptorCount, - OUT UINTN *DescriptorSize, - OUT UINT32 *PackageVersion, - OUT CHAR16 **PackageVersionName - ) -{ - MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; - UINTN Index; - - MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); - - if(ImageInfoSize == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (*ImageInfoSize < sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount) { - *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount; - return EFI_BUFFER_TOO_SMALL; - } - - if (ImageInfo == NULL || - DescriptorVersion == NULL || - DescriptorCount == NULL || - DescriptorSize == NULL || - PackageVersion == NULL || - PackageVersionName == NULL) { - return EFI_INVALID_PARAMETER; - } - - *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount; - *DescriptorSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR); - *DescriptorCount = MicrocodeFmpPrivate->DescriptorCount; - *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; - - // - // supports 1 ImageInfo descriptor - // - CopyMem(&ImageInfo[0], MicrocodeFmpPrivate->ImageDescriptor, sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount); - for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { - if ((ImageInfo[Index].AttributesSetting & IMAGE_ATTRIBUTE_IN_USE) != 0) { - ImageInfo[Index].LastAttemptVersion = MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion; - ImageInfo[Index].LastAttemptStatus = MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus; - } - } - - // - // package version - // - *PackageVersion = MicrocodeFmpPrivate->PackageVersion; - if (MicrocodeFmpPrivate->PackageVersionName != NULL) { - *PackageVersionName = AllocateCopyPool(StrSize(MicrocodeFmpPrivate->PackageVersionName), MicrocodeFmpPrivate->PackageVersionName); - } - - return EFI_SUCCESS; -} - -/** - Retrieves a copy of the current firmware image of the device. - - This function allows a copy of the current firmware image to be created and saved. - The saved copy could later been used, for example, in firmware image recovery or rollback. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in,out] Image Points to the buffer where the current image is copied to. - @param[in,out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes. - On return, points to the length of the image, in bytes. - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the - image. The current buffer size needed to hold the image is returned - in ImageSize. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_NOT_FOUND The current image is not copied to the buffer. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpGetImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN OUT VOID *Image, - IN OUT UINTN *ImageSize - ) -{ - MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; - MICROCODE_INFO *MicrocodeInfo; - - if (Image == NULL || ImageSize == NULL) { - return EFI_INVALID_PARAMETER; - } - - MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); - - if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || ImageSize == NULL || Image == NULL) { - return EFI_INVALID_PARAMETER; - } - - MicrocodeInfo = &MicrocodeFmpPrivate->MicrocodeInfo[ImageIndex - 1]; - - if (*ImageSize < MicrocodeInfo->TotalSize) { - *ImageSize = MicrocodeInfo->TotalSize; - return EFI_BUFFER_TOO_SMALL; - } - - *ImageSize = MicrocodeInfo->TotalSize; - CopyMem (Image, MicrocodeInfo->MicrocodeEntryPoint, MicrocodeInfo->TotalSize); - return EFI_SUCCESS; -} - -/** - Updates the firmware image of the device. - - This function updates the hardware with the new firmware image. - This function returns EFI_UNSUPPORTED if the firmware image is not updatable. - If the firmware image is updatable, the function should perform the following minimal validations - before proceeding to do the firmware image update. - - Validate the image authentication if image has attribute - IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns - EFI_SECURITY_VIOLATION if the validation fails. - - Validate the image is a supported image for this device. The function returns EFI_ABORTED if - the image is unsupported. The function can optionally provide more detailed information on - why the image is not a supported image. - - Validate the data from VendorCode if not null. Image validation must be performed before - VendorCode data validation. VendorCode data is ignored or considered invalid if image - validation failed. The function returns EFI_ABORTED if the data is invalid. - - VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if - the caller did not specify the policy or use the default policy. As an example, vendor can implement - a policy to allow an option to force a firmware image update when the abort reason is due to the new - firmware image version is older than the current firmware image version or bad image checksum. - Sensitive operations such as those wiping the entire firmware image and render the device to be - non-functional should be encoded in the image itself rather than passed with the VendorCode. - AbortReason enables vendor to have the option to provide a more detailed description of the abort - reason to the caller. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in] Image Points to the new image. - @param[in] ImageSize Size of the new image in bytes. - @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy. - Null indicates the caller did not specify the policy or use the default policy. - @param[in] Progress A function used by the driver to report the progress of the firmware update. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_ABORTED The operation is aborted. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpSetImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN CONST VOID *Image, - IN UINTN ImageSize, - IN CONST VOID *VendorCode, - IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, - OUT CHAR16 **AbortReason - ) -{ - EFI_STATUS Status; - EFI_STATUS VarStatus; - MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate; - - if (Image == NULL || AbortReason == NULL) { - return EFI_INVALID_PARAMETER; - } - - MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This); - *AbortReason = NULL; - - if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || Image == NULL) { - return EFI_INVALID_PARAMETER; - } - - Status = MicrocodeWrite(MicrocodeFmpPrivate, (VOID *)Image, ImageSize, &MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, &MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus, AbortReason); - DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus)); - VarStatus = gRT->SetVariable( - MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME, - &gEfiCallerIdGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, - sizeof(MicrocodeFmpPrivate->LastAttempt), - &MicrocodeFmpPrivate->LastAttempt - ); - DEBUG((DEBUG_INFO, "SetLastAttemp - %r\n", VarStatus)); - - if (!EFI_ERROR(Status)) { - InitializeMicrocodeDescriptor(MicrocodeFmpPrivate); - DumpPrivateInfo (MicrocodeFmpPrivate); - } - - return Status; -} - -/** - Checks if the firmware image is valid for the device. - - This function allows firmware update application to validate the firmware image without - invoking the SetImage() first. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in] Image Points to the new image. - @param[in] ImageSize Size of the new image in bytes. - @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides, - if available, additional information if the image is invalid. - - @retval EFI_SUCCESS The image was successfully checked. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpCheckImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN CONST VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Returns information about the firmware package. - - This function returns package information. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[out] PackageVersion A version number that represents all the firmware images in the device. - The format is vendor specific and new version must have a greater value - than the old version. If PackageVersion is not supported, the value is - 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version - comparison is to be performed using PackageVersionName. A value of - 0xFFFFFFFD indicates that package version update is in progress. - @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing - the package version name. The buffer is allocated by this function with - AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of - package version name. A value of 0 indicates the device does not support - update of package version name. Length is the number of Unicode characters, - including the terminating null character. - @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute - Definitions' for possible returned values of this parameter. A value of 1 - indicates the attribute is supported and the current setting value is - indicated in AttributesSetting. A value of 0 indicates the attribute is not - supported and the current setting value in AttributesSetting is meaningless. - @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned - values of this parameter - - @retval EFI_SUCCESS The package information was successfully returned. - @retval EFI_UNSUPPORTED The operation is not supported. - -**/ -EFI_STATUS -EFIAPI -FmpGetPackageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - OUT UINT32 *PackageVersion, - OUT CHAR16 **PackageVersionName, - OUT UINT32 *PackageVersionNameMaxLen, - OUT UINT64 *AttributesSupported, - OUT UINT64 *AttributesSetting - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Updates information about the firmware package. - - This function updates package information. - This function returns EFI_UNSUPPORTED if the package information is not updatable. - VendorCode enables vendor to implement vendor-specific package information update policy. - Null if the caller did not specify this policy or use the default policy. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] Image Points to the authentication image. - Null if authentication is not required. - @param[in] ImageSize Size of the authentication image in bytes. - 0 if authentication is not required. - @param[in] VendorCode This enables vendor to implement vendor-specific firmware - image update policy. - Null indicates the caller did not specify this policy or use - the default policy. - @param[in] PackageVersion The new package version. - @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing - the package version name. - The string length is equal to or less than the value returned in - PackageVersionNameMaxLen. - - @retval EFI_SUCCESS The device was successfully updated with the new package - information. - @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value - returned in PackageVersionNameMaxLen. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpSetPackageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN CONST VOID *Image, - IN UINTN ImageSize, - IN CONST VOID *VendorCode, - IN UINT32 PackageVersion, - IN CONST CHAR16 *PackageVersionName - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Initialize Processor Microcode Index. - - @param[in] MicrocodeFmpPrivate private data structure to be initialized. -**/ -VOID -InitializedProcessorMicrocodeIndex ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - UINTN CpuIndex; - UINTN MicrocodeIndex; - UINTN TargetCpuIndex; - UINT32 AttemptStatus; - EFI_STATUS Status; - - for (CpuIndex = 0; CpuIndex < MicrocodeFmpPrivate->ProcessorCount; CpuIndex++) { - if (MicrocodeFmpPrivate->ProcessorInfo[CpuIndex].MicrocodeIndex != (UINTN)-1) { - continue; - } - for (MicrocodeIndex = 0; MicrocodeIndex < MicrocodeFmpPrivate->DescriptorCount; MicrocodeIndex++) { - if (!MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].InUse) { - continue; - } - TargetCpuIndex = CpuIndex; - Status = VerifyMicrocode( - MicrocodeFmpPrivate, - MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].MicrocodeEntryPoint, - MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeIndex].TotalSize, - FALSE, - &AttemptStatus, - NULL, - &TargetCpuIndex - ); - if (!EFI_ERROR(Status)) { - MicrocodeFmpPrivate->ProcessorInfo[CpuIndex].MicrocodeIndex = MicrocodeIndex; - } - } - } -} - -/** - Initialize Microcode Descriptor. - - @param[in] MicrocodeFmpPrivate private data structure to be initialized. - - @return EFI_SUCCESS Microcode Descriptor is initialized. -**/ -EFI_STATUS -InitializeMicrocodeDescriptor ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - UINT8 CurrentMicrocodeCount; - - CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo (MicrocodeFmpPrivate, 0, NULL, NULL); - - if (CurrentMicrocodeCount > MicrocodeFmpPrivate->DescriptorCount) { - if (MicrocodeFmpPrivate->ImageDescriptor != NULL) { - FreePool(MicrocodeFmpPrivate->ImageDescriptor); - MicrocodeFmpPrivate->ImageDescriptor = NULL; - } - if (MicrocodeFmpPrivate->MicrocodeInfo != NULL) { - FreePool(MicrocodeFmpPrivate->MicrocodeInfo); - MicrocodeFmpPrivate->MicrocodeInfo = NULL; - } - } else { - ZeroMem(MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR)); - ZeroMem(MicrocodeFmpPrivate->MicrocodeInfo, MicrocodeFmpPrivate->DescriptorCount * sizeof(MICROCODE_INFO)); - } - - MicrocodeFmpPrivate->DescriptorCount = CurrentMicrocodeCount; - - if (MicrocodeFmpPrivate->ImageDescriptor == NULL) { - MicrocodeFmpPrivate->ImageDescriptor = AllocateZeroPool(MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR)); - if (MicrocodeFmpPrivate->ImageDescriptor == NULL) { - return EFI_OUT_OF_RESOURCES; - } - } - if (MicrocodeFmpPrivate->MicrocodeInfo == NULL) { - MicrocodeFmpPrivate->MicrocodeInfo = AllocateZeroPool(MicrocodeFmpPrivate->DescriptorCount * sizeof(MICROCODE_INFO)); - if (MicrocodeFmpPrivate->MicrocodeInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - } - - CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo (MicrocodeFmpPrivate, MicrocodeFmpPrivate->DescriptorCount, MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->MicrocodeInfo); - ASSERT(CurrentMicrocodeCount == MicrocodeFmpPrivate->DescriptorCount); - - InitializedProcessorMicrocodeIndex (MicrocodeFmpPrivate); - - return EFI_SUCCESS; -} - -/** - Initialize MicrocodeFmpDriver multiprocessor information. - - @param[in] MicrocodeFmpPrivate private data structure to be initialized. - - @return EFI_SUCCESS private data is initialized. -**/ -EFI_STATUS -InitializeProcessorInfo ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpService; - UINTN NumberOfProcessors; - UINTN NumberOfEnabledProcessors; - UINTN Index; - UINTN BspIndex; - - Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService); - ASSERT_EFI_ERROR(Status); - - MicrocodeFmpPrivate->MpService = MpService; - MicrocodeFmpPrivate->ProcessorCount = 0; - MicrocodeFmpPrivate->ProcessorInfo = NULL; - - Status = MpService->GetNumberOfProcessors (MpService, &NumberOfProcessors, &NumberOfEnabledProcessors); - ASSERT_EFI_ERROR(Status); - MicrocodeFmpPrivate->ProcessorCount = NumberOfProcessors; - - Status = MpService->WhoAmI (MpService, &BspIndex); - ASSERT_EFI_ERROR(Status); - MicrocodeFmpPrivate->BspIndex = BspIndex; - - MicrocodeFmpPrivate->ProcessorInfo = AllocateZeroPool (sizeof(PROCESSOR_INFO) * MicrocodeFmpPrivate->ProcessorCount); - if (MicrocodeFmpPrivate->ProcessorInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - for (Index = 0; Index < NumberOfProcessors; Index++) { - MicrocodeFmpPrivate->ProcessorInfo[Index].CpuIndex = Index; - MicrocodeFmpPrivate->ProcessorInfo[Index].MicrocodeIndex = (UINTN)-1; - if (Index == BspIndex) { - CollectProcessorInfo (&MicrocodeFmpPrivate->ProcessorInfo[Index]); - } else { - Status = MpService->StartupThisAP ( - MpService, - CollectProcessorInfo, - Index, - NULL, - 0, - &MicrocodeFmpPrivate->ProcessorInfo[Index], - NULL - ); - ASSERT_EFI_ERROR(Status); - } - } - - return EFI_SUCCESS; -} - -/** - Dump private information. - - @param[in] MicrocodeFmpPrivate private data structure. -**/ -VOID -DumpPrivateInfo ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - UINTN Index; - PROCESSOR_INFO *ProcessorInfo; - MICROCODE_INFO *MicrocodeInfo; - EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor; - - DEBUG ((DEBUG_INFO, "ProcessorInfo:\n")); - DEBUG ((DEBUG_INFO, " ProcessorCount - 0x%x\n", MicrocodeFmpPrivate->ProcessorCount)); - DEBUG ((DEBUG_INFO, " BspIndex - 0x%x\n", MicrocodeFmpPrivate->BspIndex)); - - ProcessorInfo = MicrocodeFmpPrivate->ProcessorInfo; - for (Index = 0; Index < MicrocodeFmpPrivate->ProcessorCount; Index++) { - DEBUG (( - DEBUG_INFO, - " ProcessorInfo[0x%x] - 0x%08x, 0x%02x, 0x%08x, (0x%x)\n", - ProcessorInfo[Index].CpuIndex, - ProcessorInfo[Index].ProcessorSignature, - ProcessorInfo[Index].PlatformId, - ProcessorInfo[Index].MicrocodeRevision, - ProcessorInfo[Index].MicrocodeIndex - )); - } - - DEBUG ((DEBUG_INFO, "MicrocodeInfo:\n")); - MicrocodeInfo = MicrocodeFmpPrivate->MicrocodeInfo; - DEBUG ((DEBUG_INFO, " MicrocodeRegion - 0x%x - 0x%x\n", MicrocodeFmpPrivate->MicrocodePatchAddress, MicrocodeFmpPrivate->MicrocodePatchRegionSize)); - DEBUG ((DEBUG_INFO, " MicrocodeCount - 0x%x\n", MicrocodeFmpPrivate->DescriptorCount)); - for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { - DEBUG (( - DEBUG_INFO, - " MicrocodeInfo[0x%x] - 0x%08x, 0x%08x, (0x%x)\n", - Index, - MicrocodeInfo[Index].MicrocodeEntryPoint, - MicrocodeInfo[Index].TotalSize, - MicrocodeInfo[Index].InUse - )); - } - - ImageDescriptor = MicrocodeFmpPrivate->ImageDescriptor; - DEBUG ((DEBUG_VERBOSE, "ImageDescriptor:\n")); - for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { - DEBUG((DEBUG_VERBOSE, " ImageDescriptor (%d)\n", Index)); - DEBUG((DEBUG_VERBOSE, " ImageIndex - 0x%x\n", ImageDescriptor[Index].ImageIndex)); - DEBUG((DEBUG_VERBOSE, " ImageTypeId - %g\n", &ImageDescriptor[Index].ImageTypeId)); - DEBUG((DEBUG_VERBOSE, " ImageId - 0x%lx\n", ImageDescriptor[Index].ImageId)); - DEBUG((DEBUG_VERBOSE, " ImageIdName - %s\n", ImageDescriptor[Index].ImageIdName)); - DEBUG((DEBUG_VERBOSE, " Version - 0x%x\n", ImageDescriptor[Index].Version)); - DEBUG((DEBUG_VERBOSE, " VersionName - %s\n", ImageDescriptor[Index].VersionName)); - DEBUG((DEBUG_VERBOSE, " Size - 0x%x\n", ImageDescriptor[Index].Size)); - DEBUG((DEBUG_VERBOSE, " AttributesSupported - 0x%lx\n", ImageDescriptor[Index].AttributesSupported)); - DEBUG((DEBUG_VERBOSE, " AttributesSetting - 0x%lx\n", ImageDescriptor[Index].AttributesSetting)); - DEBUG((DEBUG_VERBOSE, " Compatibilities - 0x%lx\n", ImageDescriptor[Index].Compatibilities)); - DEBUG((DEBUG_VERBOSE, " LowestSupportedImageVersion - 0x%x\n", ImageDescriptor[Index].LowestSupportedImageVersion)); - DEBUG((DEBUG_VERBOSE, " LastAttemptVersion - 0x%x\n", ImageDescriptor[Index].LastAttemptVersion)); - DEBUG((DEBUG_VERBOSE, " LastAttemptStatus - 0x%x\n", ImageDescriptor[Index].LastAttemptStatus)); - DEBUG((DEBUG_VERBOSE, " HardwareInstance - 0x%lx\n", ImageDescriptor[Index].HardwareInstance)); - } -} - -/** - Initialize MicrocodeFmpDriver private data structure. - - @param[in] MicrocodeFmpPrivate private data structure to be initialized. - - @return EFI_SUCCESS private data is initialized. -**/ -EFI_STATUS -InitializePrivateData ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - EFI_STATUS Status; - EFI_STATUS VarStatus; - UINTN VarSize; - BOOLEAN Result; - - MicrocodeFmpPrivate->Signature = MICROCODE_FMP_PRIVATE_DATA_SIGNATURE; - MicrocodeFmpPrivate->Handle = NULL; - CopyMem(&MicrocodeFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof(EFI_FIRMWARE_MANAGEMENT_PROTOCOL)); - - MicrocodeFmpPrivate->PackageVersion = 0x1; - MicrocodeFmpPrivate->PackageVersionName = L"Microcode"; - - MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion = 0x0; - MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus = 0x0; - VarSize = sizeof(MicrocodeFmpPrivate->LastAttempt); - VarStatus = gRT->GetVariable( - MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME, - &gEfiCallerIdGuid, - NULL, - &VarSize, - &MicrocodeFmpPrivate->LastAttempt - ); - DEBUG((DEBUG_INFO, "GetLastAttemp - %r\n", VarStatus)); - DEBUG((DEBUG_INFO, "GetLastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus)); - - Result = GetMicrocodeRegion(&MicrocodeFmpPrivate->MicrocodePatchAddress, &MicrocodeFmpPrivate->MicrocodePatchRegionSize); - if (!Result) { - DEBUG((DEBUG_ERROR, "Fail to get Microcode Region\n")); - return EFI_NOT_FOUND; - } - - Status = InitializeProcessorInfo (MicrocodeFmpPrivate); - if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, "InitializeProcessorInfo - %r\n", Status)); - return Status; - } - - Status = InitializeMicrocodeDescriptor(MicrocodeFmpPrivate); - if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, "InitializeMicrocodeDescriptor - %r\n", Status)); - return Status; - } - - DumpPrivateInfo (MicrocodeFmpPrivate); - - return Status; -} - -/** - Microcode FMP module entrypoint - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @return EFI_SUCCESS Microcode FMP module is initialized. -**/ -EFI_STATUS -EFIAPI -MicrocodeFmpMain ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Initialize MicrocodeFmpPrivateData - // - mMicrocodeFmpPrivate = AllocateZeroPool (sizeof(MICROCODE_FMP_PRIVATE_DATA)); - if (mMicrocodeFmpPrivate == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = InitializePrivateData(mMicrocodeFmpPrivate); - if (EFI_ERROR(Status)) { - FreePool(mMicrocodeFmpPrivate); - mMicrocodeFmpPrivate = NULL; - return Status; - } - - // - // Install FMP protocol. - // - Status = gBS->InstallProtocolInterface ( - &mMicrocodeFmpPrivate->Handle, - &gEfiFirmwareManagementProtocolGuid, - EFI_NATIVE_INTERFACE, - &mMicrocodeFmpPrivate->Fmp - ); - if (EFI_ERROR (Status)) { - FreePool(mMicrocodeFmpPrivate); - mMicrocodeFmpPrivate = NULL; - return Status; - } - - return Status; -} diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c deleted file mode 100644 index 4e8f1d5fd8..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c +++ /dev/null @@ -1,981 +0,0 @@ -/** @file - SetImage instance to update Microcode. - - Caution: This module requires additional review when modified. - This module will have external input - capsule image. - This external input must be validated carefully to avoid security issue like - buffer overflow, integer overflow. - - MicrocodeWrite() and VerifyMicrocode() will receive untrusted input and do basic validation. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MicrocodeUpdate.h" - -/** - Get Microcode Region. - - @param[out] MicrocodePatchAddress The address of Microcode - @param[out] MicrocodePatchRegionSize The region size of Microcode - - @retval TRUE The Microcode region is returned. - @retval FALSE No Microcode region. -**/ -BOOLEAN -GetMicrocodeRegion ( - OUT VOID **MicrocodePatchAddress, - OUT UINTN *MicrocodePatchRegionSize - ) -{ - *MicrocodePatchAddress = (VOID *)(UINTN)PcdGet64(PcdCpuMicrocodePatchAddress); - *MicrocodePatchRegionSize = (UINTN)PcdGet64(PcdCpuMicrocodePatchRegionSize); - - if ((*MicrocodePatchAddress == NULL) || (*MicrocodePatchRegionSize == 0)) { - return FALSE; - } - - return TRUE; -} - -/** - Get Microcode update signature of currently loaded Microcode update. - - @return Microcode signature. - -**/ -UINT32 -GetCurrentMicrocodeSignature ( - VOID - ) -{ - UINT64 Signature; - - AsmWriteMsr64(MSR_IA32_BIOS_SIGN_ID, 0); - AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, NULL); - Signature = AsmReadMsr64(MSR_IA32_BIOS_SIGN_ID); - return (UINT32)RShiftU64(Signature, 32); -} - -/** - Get current processor signature. - - @return current processor signature. -**/ -UINT32 -GetCurrentProcessorSignature ( - VOID - ) -{ - UINT32 RegEax; - AsmCpuid(CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL); - return RegEax; -} - -/** - Get current platform ID. - - @return current platform ID. -**/ -UINT8 -GetCurrentPlatformId ( - VOID - ) -{ - UINT8 PlatformId; - - PlatformId = (UINT8)AsmMsrBitFieldRead64(MSR_IA32_PLATFORM_ID, 50, 52); - return PlatformId; -} - -/** - Load new Microcode. - - @param[in] Address The address of new Microcode. - - @return Loaded Microcode signature. - -**/ -UINT32 -LoadMicrocode ( - IN UINT64 Address - ) -{ - AsmWriteMsr64(MSR_IA32_BIOS_UPDT_TRIG, Address); - return GetCurrentMicrocodeSignature(); -} - -/** - Load Microcode on an Application Processor. - The function prototype for invoking a function on an Application Processor. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -MicrocodeLoadAp ( - IN OUT VOID *Buffer - ) -{ - MICROCODE_LOAD_BUFFER *MicrocodeLoadBuffer; - - MicrocodeLoadBuffer = Buffer; - MicrocodeLoadBuffer->Revision = LoadMicrocode (MicrocodeLoadBuffer->Address); -} - -/** - Load new Microcode on this processor - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] CpuIndex The index of the processor. - @param[in] Address The address of new Microcode. - - @return Loaded Microcode signature. - -**/ -UINT32 -LoadMicrocodeOnThis ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN UINTN CpuIndex, - IN UINT64 Address - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpService; - MICROCODE_LOAD_BUFFER MicrocodeLoadBuffer; - - if (CpuIndex == MicrocodeFmpPrivate->BspIndex) { - return LoadMicrocode (Address); - } else { - MpService = MicrocodeFmpPrivate->MpService; - MicrocodeLoadBuffer.Address = Address; - MicrocodeLoadBuffer.Revision = 0; - Status = MpService->StartupThisAP ( - MpService, - MicrocodeLoadAp, - CpuIndex, - NULL, - 0, - &MicrocodeLoadBuffer, - NULL - ); - ASSERT_EFI_ERROR(Status); - return MicrocodeLoadBuffer.Revision; - } -} - -/** - Collect processor information. - The function prototype for invoking a function on an Application Processor. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -CollectProcessorInfo ( - IN OUT VOID *Buffer - ) -{ - PROCESSOR_INFO *ProcessorInfo; - - ProcessorInfo = Buffer; - ProcessorInfo->ProcessorSignature = GetCurrentProcessorSignature(); - ProcessorInfo->PlatformId = GetCurrentPlatformId(); - ProcessorInfo->MicrocodeRevision = GetCurrentMicrocodeSignature(); -} - -/** - Get current Microcode information. - - The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo) - in MicrocodeFmpPrivate must be initialized. - - The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo) - in MicrocodeFmpPrivate may not be avaiable in this function. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] DescriptorCount The count of Microcode ImageDescriptor allocated. - @param[out] ImageDescriptor Microcode ImageDescriptor - @param[out] MicrocodeInfo Microcode information - - @return Microcode count -**/ -UINTN -GetMicrocodeInfo ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN UINTN DescriptorCount, OPTIONAL - OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor, OPTIONAL - OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL - ) -{ - VOID *MicrocodePatchAddress; - UINTN MicrocodePatchRegionSize; - CPU_MICROCODE_HEADER *MicrocodeEntryPoint; - UINTN MicrocodeEnd; - UINTN TotalSize; - UINTN Count; - UINT64 ImageAttributes; - BOOLEAN IsInUse; - EFI_STATUS Status; - UINT32 AttemptStatus; - UINTN TargetCpuIndex; - - MicrocodePatchAddress = MicrocodeFmpPrivate->MicrocodePatchAddress; - MicrocodePatchRegionSize = MicrocodeFmpPrivate->MicrocodePatchRegionSize; - - DEBUG((DEBUG_INFO, "Microcode Region - 0x%x - 0x%x\n", MicrocodePatchAddress, MicrocodePatchRegionSize)); - - Count = 0; - - MicrocodeEnd = (UINTN)MicrocodePatchAddress + MicrocodePatchRegionSize; - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) MicrocodePatchAddress; - do { - if (MicrocodeEntryPoint->HeaderVersion == 0x1 && MicrocodeEntryPoint->LoaderRevision == 0x1) { - // - // It is the microcode header. It is not the padding data between microcode patches - // becasue the padding data should not include 0x00000001 and it should be the repeated - // byte format (like 0xXYXYXYXY....). - // - if (MicrocodeEntryPoint->DataSize == 0) { - TotalSize = 2048; - } else { - TotalSize = MicrocodeEntryPoint->TotalSize; - } - - TargetCpuIndex = (UINTN)-1; - Status = VerifyMicrocode(MicrocodeFmpPrivate, MicrocodeEntryPoint, TotalSize, FALSE, &AttemptStatus, NULL, &TargetCpuIndex); - if (!EFI_ERROR(Status)) { - IsInUse = TRUE; - ASSERT (TargetCpuIndex < MicrocodeFmpPrivate->ProcessorCount); - MicrocodeFmpPrivate->ProcessorInfo[TargetCpuIndex].MicrocodeIndex = Count; - } else { - IsInUse = FALSE; - } - - if (ImageDescriptor != NULL && DescriptorCount > Count) { - ImageDescriptor[Count].ImageIndex = (UINT8)(Count + 1); - CopyGuid (&ImageDescriptor[Count].ImageTypeId, &gMicrocodeFmpImageTypeIdGuid); - ImageDescriptor[Count].ImageId = LShiftU64(MicrocodeEntryPoint->ProcessorFlags, 32) + MicrocodeEntryPoint->ProcessorSignature.Uint32; - ImageDescriptor[Count].ImageIdName = NULL; - ImageDescriptor[Count].Version = MicrocodeEntryPoint->UpdateRevision; - ImageDescriptor[Count].VersionName = NULL; - ImageDescriptor[Count].Size = TotalSize; - ImageAttributes = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | IMAGE_ATTRIBUTE_RESET_REQUIRED; - if (IsInUse) { - ImageAttributes |= IMAGE_ATTRIBUTE_IN_USE; - } - ImageDescriptor[Count].AttributesSupported = ImageAttributes | IMAGE_ATTRIBUTE_IN_USE; - ImageDescriptor[Count].AttributesSetting = ImageAttributes; - ImageDescriptor[Count].Compatibilities = 0; - ImageDescriptor[Count].LowestSupportedImageVersion = MicrocodeEntryPoint->UpdateRevision; // do not support rollback - ImageDescriptor[Count].LastAttemptVersion = 0; - ImageDescriptor[Count].LastAttemptStatus = 0; - ImageDescriptor[Count].HardwareInstance = 0; - } - if (MicrocodeInfo != NULL && DescriptorCount > Count) { - MicrocodeInfo[Count].MicrocodeEntryPoint = MicrocodeEntryPoint; - MicrocodeInfo[Count].TotalSize = TotalSize; - MicrocodeInfo[Count].InUse = IsInUse; - } - } else { - // - // It is the padding data between the microcode patches for microcode patches alignment. - // Because the microcode patch is the multiple of 1-KByte, the padding data should not - // exist if the microcode patch alignment value is not larger than 1-KByte. So, the microcode - // alignment value should be larger than 1-KByte. We could skip SIZE_1KB padding data to - // find the next possible microcode patch header. - // - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + SIZE_1KB); - continue; - } - - Count++; - ASSERT(Count < 0xFF); - - // - // Get the next patch. - // - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + TotalSize); - } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd)); - - return Count; -} - -/** - Return matched processor information. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] ProcessorSignature The processor signature to be matched - @param[in] ProcessorFlags The processor flags to be matched - @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. - On output, the index of target CPU which matches the Microcode. - - @return matched processor information. -**/ -PROCESSOR_INFO * -GetMatchedProcessor ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN UINT32 ProcessorSignature, - IN UINT32 ProcessorFlags, - IN OUT UINTN *TargetCpuIndex - ) -{ - UINTN Index; - - if (*TargetCpuIndex != (UINTN)-1) { - Index = *TargetCpuIndex; - if ((ProcessorSignature == MicrocodeFmpPrivate->ProcessorInfo[Index].ProcessorSignature) && - ((ProcessorFlags & (1 << MicrocodeFmpPrivate->ProcessorInfo[Index].PlatformId)) != 0)) { - return &MicrocodeFmpPrivate->ProcessorInfo[Index]; - } else { - return NULL; - } - } - - for (Index = 0; Index < MicrocodeFmpPrivate->ProcessorCount; Index++) { - if ((ProcessorSignature == MicrocodeFmpPrivate->ProcessorInfo[Index].ProcessorSignature) && - ((ProcessorFlags & (1 << MicrocodeFmpPrivate->ProcessorInfo[Index].PlatformId)) != 0)) { - *TargetCpuIndex = Index; - return &MicrocodeFmpPrivate->ProcessorInfo[Index]; - } - } - return NULL; -} - -/** - Verify Microcode. - - Caution: This function may receive untrusted input. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[in] TryLoad Try to load Microcode or not. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. - On output, the index of target CPU which matches the Microcode. - - @retval EFI_SUCCESS The Microcode image passes verification. - @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. - @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. - @retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect. - @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. -**/ -EFI_STATUS -VerifyMicrocode ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN VOID *Image, - IN UINTN ImageSize, - IN BOOLEAN TryLoad, - OUT UINT32 *LastAttemptStatus, - OUT CHAR16 **AbortReason, OPTIONAL - IN OUT UINTN *TargetCpuIndex - ) -{ - UINTN Index; - CPU_MICROCODE_HEADER *MicrocodeEntryPoint; - UINTN TotalSize; - UINTN DataSize; - UINT32 CurrentRevision; - PROCESSOR_INFO *ProcessorInfo; - UINT32 CheckSum32; - UINTN ExtendedTableLength; - UINT32 ExtendedTableCount; - CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; - CPU_MICROCODE_EXTENDED_TABLE_HEADER *ExtendedTableHeader; - BOOLEAN CorrectMicrocode; - - // - // Check HeaderVersion - // - MicrocodeEntryPoint = Image; - if (MicrocodeEntryPoint->HeaderVersion != 0x1) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on HeaderVersion\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidHeaderVersion"), L"InvalidHeaderVersion"); - } - return EFI_INCOMPATIBLE_VERSION; - } - // - // Check LoaderRevision - // - if (MicrocodeEntryPoint->LoaderRevision != 0x1) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on LoaderRevision\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidLoaderVersion"), L"InvalidLoaderVersion"); - } - return EFI_INCOMPATIBLE_VERSION; - } - // - // Check Size - // - if (MicrocodeEntryPoint->DataSize == 0) { - TotalSize = 2048; - } else { - TotalSize = MicrocodeEntryPoint->TotalSize; - } - if (TotalSize <= sizeof(CPU_MICROCODE_HEADER)) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize too small\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize"); - } - return EFI_VOLUME_CORRUPTED; - } - if (TotalSize != ImageSize) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize"); - } - return EFI_VOLUME_CORRUPTED; - } - // - // Check CheckSum32 - // - if (MicrocodeEntryPoint->DataSize == 0) { - DataSize = 2048 - sizeof(CPU_MICROCODE_HEADER); - } else { - DataSize = MicrocodeEntryPoint->DataSize; - } - if (DataSize > TotalSize - sizeof(CPU_MICROCODE_HEADER)) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize too big\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidDataSize"), L"InvalidDataSize"); - } - return EFI_VOLUME_CORRUPTED; - } - if ((DataSize & 0x3) != 0) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize not aligned\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidDataSize"), L"InvalidDataSize"); - } - return EFI_VOLUME_CORRUPTED; - } - CheckSum32 = CalculateSum32((UINT32 *)MicrocodeEntryPoint, DataSize + sizeof(CPU_MICROCODE_HEADER)); - if (CheckSum32 != 0) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CheckSum32\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidChecksum"), L"InvalidChecksum"); - } - return EFI_VOLUME_CORRUPTED; - } - - // - // Check ProcessorSignature/ProcessorFlags - // - - ProcessorInfo = GetMatchedProcessor (MicrocodeFmpPrivate, MicrocodeEntryPoint->ProcessorSignature.Uint32, MicrocodeEntryPoint->ProcessorFlags, TargetCpuIndex); - if (ProcessorInfo == NULL) { - CorrectMicrocode = FALSE; - ExtendedTableLength = TotalSize - (DataSize + sizeof(CPU_MICROCODE_HEADER)); - if (ExtendedTableLength != 0) { - // - // Extended Table exist, check if the CPU in support list - // - ExtendedTableHeader = (CPU_MICROCODE_EXTENDED_TABLE_HEADER *)((UINT8 *)(MicrocodeEntryPoint) + DataSize + sizeof(CPU_MICROCODE_HEADER)); - // - // Calculate Extended Checksum - // - if ((ExtendedTableLength > sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) && ((ExtendedTableLength & 0x3) != 0)) { - CheckSum32 = CalculateSum32((UINT32 *)ExtendedTableHeader, ExtendedTableLength); - if (CheckSum32 == 0) { - // - // Checksum correct - // - ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; - if (ExtendedTableCount <= (ExtendedTableLength - sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) / sizeof(CPU_MICROCODE_EXTENDED_TABLE)) { - ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *)(ExtendedTableHeader + 1); - for (Index = 0; Index < ExtendedTableCount; Index++) { - CheckSum32 = CalculateSum32((UINT32 *)ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); - if (CheckSum32 == 0) { - // - // Verify Header - // - ProcessorInfo = GetMatchedProcessor (MicrocodeFmpPrivate, ExtendedTable->ProcessorSignature.Uint32, ExtendedTable->ProcessorFlag, TargetCpuIndex); - if (ProcessorInfo != NULL) { - // - // Find one - // - CorrectMicrocode = TRUE; - break; - } - } - ExtendedTable++; - } - } - } - } - } - if (!CorrectMicrocode) { - if (TryLoad) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CurrentProcessorSignature/ProcessorFlags\n")); - } - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"UnsupportedProcessSignature/ProcessorFlags"), L"UnsupportedProcessSignature/ProcessorFlags"); - } - return EFI_UNSUPPORTED; - } - } - - // - // Check UpdateRevision - // - CurrentRevision = ProcessorInfo->MicrocodeRevision; - if ((MicrocodeEntryPoint->UpdateRevision < CurrentRevision) || - (TryLoad && (MicrocodeEntryPoint->UpdateRevision == CurrentRevision))) { - if (TryLoad) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on UpdateRevision\n")); - } - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"IncorrectRevision"), L"IncorrectRevision"); - } - return EFI_INCOMPATIBLE_VERSION; - } - - // - // try load MCU - // - if (TryLoad) { - CurrentRevision = LoadMicrocodeOnThis(MicrocodeFmpPrivate, ProcessorInfo->CpuIndex, (UINTN)MicrocodeEntryPoint + sizeof(CPU_MICROCODE_HEADER)); - if (MicrocodeEntryPoint->UpdateRevision != CurrentRevision) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on LoadMicrocode\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR; - if (AbortReason != NULL) { - *AbortReason = AllocateCopyPool(sizeof(L"InvalidData"), L"InvalidData"); - } - return EFI_SECURITY_VIOLATION; - } - } - - return EFI_SUCCESS; -} - -/** - Get next Microcode entrypoint. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] MicrocodeEntryPoint Current Microcode entrypoint - - @return next Microcode entrypoint. -**/ -CPU_MICROCODE_HEADER * -GetNextMicrocode ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN CPU_MICROCODE_HEADER *MicrocodeEntryPoint - ) -{ - UINTN Index; - - for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) { - if (MicrocodeEntryPoint == MicrocodeFmpPrivate->MicrocodeInfo[Index].MicrocodeEntryPoint) { - if (Index == (UINTN)MicrocodeFmpPrivate->DescriptorCount - 1) { - // it is last one - return NULL; - } else { - // return next one - return MicrocodeFmpPrivate->MicrocodeInfo[Index + 1].MicrocodeEntryPoint; - } - } - } - - ASSERT(FALSE); - return NULL; -} - -/** - Get current Microcode used region size. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - - @return current Microcode used region size. -**/ -UINTN -GetCurrentMicrocodeUsedRegionSize ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ) -{ - if (MicrocodeFmpPrivate->DescriptorCount == 0) { - return 0; - } - - return (UINTN)MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeFmpPrivate->DescriptorCount - 1].MicrocodeEntryPoint - + (UINTN)MicrocodeFmpPrivate->MicrocodeInfo[MicrocodeFmpPrivate->DescriptorCount - 1].TotalSize - - (UINTN)MicrocodeFmpPrivate->MicrocodePatchAddress; -} - -/** - Update Microcode. - - @param[in] Address The flash address of Microcode. - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - - @retval EFI_SUCCESS The Microcode image is updated. - @retval EFI_WRITE_PROTECTED The flash device is read only. -**/ -EFI_STATUS -UpdateMicrocode ( - IN UINT64 Address, - IN VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *LastAttemptStatus - ) -{ - EFI_STATUS Status; - - DEBUG((DEBUG_INFO, "PlatformUpdate:")); - DEBUG((DEBUG_INFO, " Address - 0x%lx,", Address)); - DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ImageSize)); - - Status = MicrocodeFlashWrite ( - Address, - Image, - ImageSize - ); - if (!EFI_ERROR(Status)) { - *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS; - } else { - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; - } - return Status; -} - -/** - Update Microcode flash region. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] TargetMicrocodeEntryPoint Target Microcode entrypoint to be updated - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - - @retval EFI_SUCCESS The Microcode image is written. - @retval EFI_WRITE_PROTECTED The flash device is read only. -**/ -EFI_STATUS -UpdateMicrocodeFlashRegion ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN CPU_MICROCODE_HEADER *TargetMicrocodeEntryPoint, - IN VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *LastAttemptStatus - ) -{ - VOID *MicrocodePatchAddress; - UINTN MicrocodePatchRegionSize; - UINTN TargetTotalSize; - UINTN UsedRegionSize; - EFI_STATUS Status; - VOID *MicrocodePatchScratchBuffer; - UINT8 *ScratchBufferPtr; - UINTN ScratchBufferSize; - UINTN RestSize; - UINTN AvailableSize; - VOID *NextMicrocodeEntryPoint; - MICROCODE_INFO *MicrocodeInfo; - UINTN MicrocodeCount; - UINTN Index; - - DEBUG((DEBUG_INFO, "UpdateMicrocodeFlashRegion: Image - 0x%x, size - 0x%x\n", Image, ImageSize)); - - MicrocodePatchAddress = MicrocodeFmpPrivate->MicrocodePatchAddress; - MicrocodePatchRegionSize = MicrocodeFmpPrivate->MicrocodePatchRegionSize; - - MicrocodePatchScratchBuffer = AllocateZeroPool (MicrocodePatchRegionSize); - if (MicrocodePatchScratchBuffer == NULL) { - DEBUG((DEBUG_ERROR, "Fail to allocate Microcode Scratch buffer\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; - return EFI_OUT_OF_RESOURCES; - } - ScratchBufferPtr = MicrocodePatchScratchBuffer; - ScratchBufferSize = 0; - - // - // Target data collection - // - TargetTotalSize = 0; - AvailableSize = 0; - NextMicrocodeEntryPoint = NULL; - if (TargetMicrocodeEntryPoint != NULL) { - if (TargetMicrocodeEntryPoint->DataSize == 0) { - TargetTotalSize = 2048; - } else { - TargetTotalSize = TargetMicrocodeEntryPoint->TotalSize; - } - DEBUG((DEBUG_INFO, " TargetTotalSize - 0x%x\n", TargetTotalSize)); - NextMicrocodeEntryPoint = GetNextMicrocode(MicrocodeFmpPrivate, TargetMicrocodeEntryPoint); - DEBUG((DEBUG_INFO, " NextMicrocodeEntryPoint - 0x%x\n", NextMicrocodeEntryPoint)); - if (NextMicrocodeEntryPoint != NULL) { - ASSERT ((UINTN)NextMicrocodeEntryPoint >= ((UINTN)TargetMicrocodeEntryPoint + TargetTotalSize)); - AvailableSize = (UINTN)NextMicrocodeEntryPoint - (UINTN)TargetMicrocodeEntryPoint; - } else { - AvailableSize = (UINTN)MicrocodePatchAddress + MicrocodePatchRegionSize - (UINTN)TargetMicrocodeEntryPoint; - } - DEBUG((DEBUG_INFO, " AvailableSize - 0x%x\n", AvailableSize)); - } - ASSERT (AvailableSize >= TargetTotalSize); - UsedRegionSize = GetCurrentMicrocodeUsedRegionSize(MicrocodeFmpPrivate); - DEBUG((DEBUG_INFO, " UsedRegionSize - 0x%x\n", UsedRegionSize)); - ASSERT (UsedRegionSize >= TargetTotalSize); - if (TargetMicrocodeEntryPoint != NULL) { - ASSERT ((UINTN)MicrocodePatchAddress + UsedRegionSize >= ((UINTN)TargetMicrocodeEntryPoint + TargetTotalSize)); - } - // - // Total Size means the Microcode data size. - // Available Size means the Microcode data size plus the pad till (1) next Microcode or (2) the end. - // - // (1) - // +------+-----------+-----+------+===================+ - // | MCU1 | Microcode | PAD | MCU2 | Empty | - // +------+-----------+-----+------+===================+ - // | TotalSize | - // |<-AvailableSize->| - // |<- UsedRegionSize ->| - // - // (2) - // +------+-----------+===================+ - // | MCU | Microcode | Empty | - // +------+-----------+===================+ - // | TotalSize | - // |<- AvailableSize ->| - // |<-UsedRegionSize->| - // - - // - // Update based on policy - // - - // - // 1. If there is enough space to update old one in situ, replace old microcode in situ. - // - if (AvailableSize >= ImageSize) { - DEBUG((DEBUG_INFO, "Replace old microcode in situ\n")); - // - // +------+------------+------+===================+ - // |Other1| Old Image |Other2| Empty | - // +------+------------+------+===================+ - // - // +------+---------+--+------+===================+ - // |Other1|New Image|FF|Other2| Empty | - // +------+---------+--+------+===================+ - // - // 1.1. Copy new image - CopyMem (ScratchBufferPtr, Image, ImageSize); - ScratchBufferSize += ImageSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - // 1.2. Pad 0xFF - RestSize = AvailableSize - ImageSize; - if (RestSize > 0) { - SetMem (ScratchBufferPtr, RestSize, 0xFF); - ScratchBufferSize += RestSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - } - Status = UpdateMicrocode((UINTN)TargetMicrocodeEntryPoint, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); - return Status; - } - - // - // 2. If there is enough space to remove old one and add new one, reorg and replace old microcode. - // - if (MicrocodePatchRegionSize - (UsedRegionSize - TargetTotalSize) >= ImageSize) { - if (TargetMicrocodeEntryPoint == NULL) { - DEBUG((DEBUG_INFO, "Append new microcode\n")); - // - // +------+------------+------+===================+ - // |Other1| Other |Other2| Empty | - // +------+------------+------+===================+ - // - // +------+------------+------+-----------+=======+ - // |Other1| Other |Other2| New Image | Empty | - // +------+------------+------+-----------+=======+ - // - Status = UpdateMicrocode((UINTN)MicrocodePatchAddress + UsedRegionSize, Image, ImageSize, LastAttemptStatus); - } else { - DEBUG((DEBUG_INFO, "Reorg and replace old microcode\n")); - // - // +------+------------+------+===================+ - // |Other1| Old Image |Other2| Empty | - // +------+------------+------+===================+ - // - // +------+---------------+------+================+ - // |Other1| New Image |Other2| Empty | - // +------+---------------+------+================+ - // - // 2.1. Copy new image - CopyMem (ScratchBufferPtr, Image, ImageSize); - ScratchBufferSize += ImageSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - // 2.2. Copy rest images after the old image. - if (NextMicrocodeEntryPoint != 0) { - RestSize = (UINTN)MicrocodePatchAddress + UsedRegionSize - ((UINTN)NextMicrocodeEntryPoint); - CopyMem (ScratchBufferPtr, (UINT8 *)TargetMicrocodeEntryPoint + TargetTotalSize, RestSize); - ScratchBufferSize += RestSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - } - Status = UpdateMicrocode((UINTN)TargetMicrocodeEntryPoint, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); - } - return Status; - } - - // - // 3. The new image can be put in MCU region, but not all others can be put. - // So all the unused MCU is removed. - // - if (MicrocodePatchRegionSize >= ImageSize) { - // - // +------+------------+------+===================+ - // |Other1| Old Image |Other2| Empty | - // +------+------------+------+===================+ - // - // +-------------------------------------+--------+ - // | New Image | Other | - // +-------------------------------------+--------+ - // - DEBUG((DEBUG_INFO, "Add new microcode from beginning\n")); - - MicrocodeCount = MicrocodeFmpPrivate->DescriptorCount; - MicrocodeInfo = MicrocodeFmpPrivate->MicrocodeInfo; - - // 3.1. Copy new image - CopyMem (ScratchBufferPtr, Image, ImageSize); - ScratchBufferSize += ImageSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - // 3.2. Copy some others to rest buffer - for (Index = 0; Index < MicrocodeCount; Index++) { - if (!MicrocodeInfo[Index].InUse) { - continue; - } - if (MicrocodeInfo[Index].MicrocodeEntryPoint == TargetMicrocodeEntryPoint) { - continue; - } - if (MicrocodeInfo[Index].TotalSize <= MicrocodePatchRegionSize - ScratchBufferSize) { - CopyMem (ScratchBufferPtr, MicrocodeInfo[Index].MicrocodeEntryPoint, MicrocodeInfo[Index].TotalSize); - ScratchBufferSize += MicrocodeInfo[Index].TotalSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - } - } - // 3.3. Pad 0xFF - RestSize = MicrocodePatchRegionSize - ScratchBufferSize; - if (RestSize > 0) { - SetMem (ScratchBufferPtr, RestSize, 0xFF); - ScratchBufferSize += RestSize; - ScratchBufferPtr = (UINT8 *)MicrocodePatchScratchBuffer + ScratchBufferSize; - } - Status = UpdateMicrocode((UINTN)MicrocodePatchAddress, MicrocodePatchScratchBuffer, ScratchBufferSize, LastAttemptStatus); - return Status; - } - - // - // 4. The new image size is bigger than the whole MCU region. - // - DEBUG((DEBUG_ERROR, "Microcode too big\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; - Status = EFI_OUT_OF_RESOURCES; - - return Status; -} - -/** - Write Microcode. - - Caution: This function may receive untrusted input. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - - @retval EFI_SUCCESS The Microcode image is written. - @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. - @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. - @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. - @retval EFI_WRITE_PROTECTED The flash device is read only. -**/ -EFI_STATUS -MicrocodeWrite ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *LastAttemptVersion, - OUT UINT32 *LastAttemptStatus, - OUT CHAR16 **AbortReason - ) -{ - EFI_STATUS Status; - VOID *AlignedImage; - CPU_MICROCODE_HEADER *TargetMicrocodeEntryPoint; - UINTN TargetCpuIndex; - UINTN TargetMicrcodeIndex; - - // - // MCU must be 16 bytes aligned - // - AlignedImage = AllocateCopyPool(ImageSize, Image); - if (AlignedImage == NULL) { - DEBUG((DEBUG_ERROR, "Fail to allocate aligned image\n")); - *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES; - return EFI_OUT_OF_RESOURCES; - } - - *LastAttemptVersion = ((CPU_MICROCODE_HEADER *)Image)->UpdateRevision; - TargetCpuIndex = (UINTN)-1; - Status = VerifyMicrocode(MicrocodeFmpPrivate, AlignedImage, ImageSize, TRUE, LastAttemptStatus, AbortReason, &TargetCpuIndex); - if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, "Fail to verify Microcode Region\n")); - FreePool(AlignedImage); - return Status; - } - DEBUG((DEBUG_INFO, "Pass VerifyMicrocode\n")); - - DEBUG((DEBUG_INFO, " TargetCpuIndex - 0x%x\n", TargetCpuIndex)); - ASSERT (TargetCpuIndex < MicrocodeFmpPrivate->ProcessorCount); - TargetMicrcodeIndex = MicrocodeFmpPrivate->ProcessorInfo[TargetCpuIndex].MicrocodeIndex; - DEBUG((DEBUG_INFO, " TargetMicrcodeIndex - 0x%x\n", TargetMicrcodeIndex)); - if (TargetMicrcodeIndex != (UINTN)-1) { - ASSERT (TargetMicrcodeIndex < MicrocodeFmpPrivate->DescriptorCount); - TargetMicrocodeEntryPoint = MicrocodeFmpPrivate->MicrocodeInfo[TargetMicrcodeIndex].MicrocodeEntryPoint; - } else { - TargetMicrocodeEntryPoint = NULL; - } - DEBUG((DEBUG_INFO, " TargetMicrocodeEntryPoint - 0x%x\n", TargetMicrocodeEntryPoint)); - - Status = UpdateMicrocodeFlashRegion( - MicrocodeFmpPrivate, - TargetMicrocodeEntryPoint, - AlignedImage, - ImageSize, - LastAttemptStatus - ); - - FreePool(AlignedImage); - - return Status; -} - - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h deleted file mode 100644 index 9dc306324e..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h +++ /dev/null @@ -1,494 +0,0 @@ -/** @file - Microcode update header file. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _MICROCODE_FMP_H_ -#define _MICROCODE_FMP_H_ - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define MICROCODE_FMP_PRIVATE_DATA_SIGNATURE SIGNATURE_32('M', 'C', 'U', 'F') - -// -// Microcode FMP private data structure. -// - -typedef struct { - UINT32 LastAttemptVersion; - UINT32 LastAttemptStatus; -} MICROCODE_FMP_LAST_ATTEMPT_VARIABLE; - -typedef struct { - CPU_MICROCODE_HEADER *MicrocodeEntryPoint; - UINTN TotalSize; - BOOLEAN InUse; -} MICROCODE_INFO; - -typedef struct { - UINTN CpuIndex; - UINT32 ProcessorSignature; - UINT8 PlatformId; - UINT32 MicrocodeRevision; - UINTN MicrocodeIndex; -} PROCESSOR_INFO; - -typedef struct { - UINT64 Address; - UINT32 Revision; -} MICROCODE_LOAD_BUFFER; - -struct _MICROCODE_FMP_PRIVATE_DATA { - UINT32 Signature; - EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp; - EFI_HANDLE Handle; - VOID *MicrocodePatchAddress; - UINTN MicrocodePatchRegionSize; - UINT8 DescriptorCount; - EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor; - MICROCODE_INFO *MicrocodeInfo; - UINT32 PackageVersion; - CHAR16 *PackageVersionName; - MICROCODE_FMP_LAST_ATTEMPT_VARIABLE LastAttempt; - EFI_MP_SERVICES_PROTOCOL *MpService; - UINTN BspIndex; - UINTN ProcessorCount; - PROCESSOR_INFO *ProcessorInfo; -}; - -typedef struct _MICROCODE_FMP_PRIVATE_DATA MICROCODE_FMP_PRIVATE_DATA; - -#define MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME L"MicrocodeLastAttempVar" - -/** - Returns a pointer to the MICROCODE_FMP_PRIVATE_DATA structure from the input a as Fmp. - - If the signatures matches, then a pointer to the data structure that contains - a specified field of that data structure is returned. - - @param a Pointer to the field specified by ServiceBinding within - a data structure of type MICROCODE_FMP_PRIVATE_DATA. - -**/ -#define MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(a) \ - CR ( \ - (a), \ - MICROCODE_FMP_PRIVATE_DATA, \ - Fmp, \ - MICROCODE_FMP_PRIVATE_DATA_SIGNATURE \ - ) - -/** - Get Microcode Region. - - @param[out] MicrocodePatchAddress The address of Microcode - @param[out] MicrocodePatchRegionSize The region size of Microcode - - @retval TRUE The Microcode region is returned. - @retval FALSE No Microcode region. -**/ -BOOLEAN -GetMicrocodeRegion ( - OUT VOID **MicrocodePatchAddress, - OUT UINTN *MicrocodePatchRegionSize - ); - -/** - Collect processor information. - The function prototype for invoking a function on an Application Processor. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -CollectProcessorInfo ( - IN OUT VOID *Buffer - ); - -/** - Get current Microcode information. - - The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo) - in MicrocodeFmpPrivate must be initialized. - - The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo) - in MicrocodeFmpPrivate may not be avaiable in this function. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] DescriptorCount The count of Microcode ImageDescriptor allocated. - @param[out] ImageDescriptor Microcode ImageDescriptor - @param[out] MicrocodeInfo Microcode information - - @return Microcode count -**/ -UINTN -GetMicrocodeInfo ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN UINTN DescriptorCount, OPTIONAL - OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor, OPTIONAL - OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL - ); - -/** - Verify Microcode. - - Caution: This function may receive untrusted input. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[in] TryLoad Try to load Microcode or not. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all. - On output, the index of target CPU which matches the Microcode. - - @retval EFI_SUCCESS The Microcode image passes verification. - @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. - @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. - @retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect. - @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. -**/ -EFI_STATUS -VerifyMicrocode ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN VOID *Image, - IN UINTN ImageSize, - IN BOOLEAN TryLoad, - OUT UINT32 *LastAttemptStatus, - OUT CHAR16 **AbortReason, OPTIONAL - IN OUT UINTN *TargetCpuIndex OPTIONAL - ); - -/** - Write Microcode. - - @param[in] MicrocodeFmpPrivate The Microcode driver private data - @param[in] Image The Microcode image buffer. - @param[in] ImageSize The size of Microcode image buffer in bytes. - @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - - @retval EFI_SUCCESS The Microcode image is written. - @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt. - @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect. - @retval EFI_SECURITY_VIOLATION The Microcode image fails to load. - @retval EFI_WRITE_PROTECTED The flash device is read only. -**/ -EFI_STATUS -MicrocodeWrite ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate, - IN VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *LastAttemptVersion, - OUT UINT32 *LastAttemptStatus, - OUT CHAR16 **AbortReason - ); - -/** - Dump private information. - - @param[in] MicrocodeFmpPrivate private data structure. -**/ -VOID -DumpPrivateInfo ( - IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate - ); - -/** - Returns information about the current firmware image(s) of the device. - - This function allows a copy of the current firmware image to be created and saved. - The saved copy could later been used, for example, in firmware image recovery or rollback. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer. - On input, this is the size of the buffer allocated by the caller. - On output, it is the size of the buffer returned by the firmware - if the buffer was large enough, or the size of the buffer needed - to contain the image(s) information if the buffer was too small. - @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s) - information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs. - @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number - associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] DescriptorCount A pointer to the location in which firmware returns the number of - descriptors or firmware images within this device. - @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes, - of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR. - @param[out] PackageVersion A version number that represents all the firmware images in the device. - The format is vendor specific and new version must have a greater value - than the old version. If PackageVersion is not supported, the value is - 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison - is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates - that package version update is in progress. - @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the - package version name. The buffer is allocated by this function with - AllocatePool(), and it is the caller's responsibility to free it with a call - to FreePool(). - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size - needed to hold the image(s) information is returned in ImageInfoSize. - @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL. - @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image. - -**/ -EFI_STATUS -EFIAPI -FmpGetImageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN OUT UINTN *ImageInfoSize, - IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, - OUT UINT32 *DescriptorVersion, - OUT UINT8 *DescriptorCount, - OUT UINTN *DescriptorSize, - OUT UINT32 *PackageVersion, - OUT CHAR16 **PackageVersionName - ); - -/** - Retrieves a copy of the current firmware image of the device. - - This function allows a copy of the current firmware image to be created and saved. - The saved copy could later been used, for example, in firmware image recovery or rollback. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in,out] Image Points to the buffer where the current image is copied to. - @param[in,out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes. - On return, points to the length of the image, in bytes. - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the - image. The current buffer size needed to hold the image is returned - in ImageSize. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_NOT_FOUND The current image is not copied to the buffer. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpGetImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN OUT VOID *Image, - IN OUT UINTN *ImageSize - ); - -/** - Updates the firmware image of the device. - - This function updates the hardware with the new firmware image. - This function returns EFI_UNSUPPORTED if the firmware image is not updatable. - If the firmware image is updatable, the function should perform the following minimal validations - before proceeding to do the firmware image update. - - Validate the image authentication if image has attribute - IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns - EFI_SECURITY_VIOLATION if the validation fails. - - Validate the image is a supported image for this device. The function returns EFI_ABORTED if - the image is unsupported. The function can optionally provide more detailed information on - why the image is not a supported image. - - Validate the data from VendorCode if not null. Image validation must be performed before - VendorCode data validation. VendorCode data is ignored or considered invalid if image - validation failed. The function returns EFI_ABORTED if the data is invalid. - - VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if - the caller did not specify the policy or use the default policy. As an example, vendor can implement - a policy to allow an option to force a firmware image update when the abort reason is due to the new - firmware image version is older than the current firmware image version or bad image checksum. - Sensitive operations such as those wiping the entire firmware image and render the device to be - non-functional should be encoded in the image itself rather than passed with the VendorCode. - AbortReason enables vendor to have the option to provide a more detailed description of the abort - reason to the caller. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in] Image Points to the new image. - @param[in] ImageSize Size of the new image in bytes. - @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy. - Null indicates the caller did not specify the policy or use the default policy. - @param[in] Progress A function used by the driver to report the progress of the firmware update. - @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more - details for the aborted operation. The buffer is allocated by this function - with AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - - @retval EFI_SUCCESS The device was successfully updated with the new image. - @retval EFI_ABORTED The operation is aborted. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpSetImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN CONST VOID *Image, - IN UINTN ImageSize, - IN CONST VOID *VendorCode, - IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, - OUT CHAR16 **AbortReason - ); - -/** - Checks if the firmware image is valid for the device. - - This function allows firmware update application to validate the firmware image without - invoking the SetImage() first. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] ImageIndex A unique number identifying the firmware image(s) within the device. - The number is between 1 and DescriptorCount. - @param[in] Image Points to the new image. - @param[in] ImageSize Size of the new image in bytes. - @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides, - if available, additional information if the image is invalid. - - @retval EFI_SUCCESS The image was successfully checked. - @retval EFI_INVALID_PARAMETER The Image was NULL. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpCheckImage ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN UINT8 ImageIndex, - IN CONST VOID *Image, - IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable - ); - -/** - Returns information about the firmware package. - - This function returns package information. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[out] PackageVersion A version number that represents all the firmware images in the device. - The format is vendor specific and new version must have a greater value - than the old version. If PackageVersion is not supported, the value is - 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version - comparison is to be performed using PackageVersionName. A value of - 0xFFFFFFFD indicates that package version update is in progress. - @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing - the package version name. The buffer is allocated by this function with - AllocatePool(), and it is the caller's responsibility to free it with a - call to FreePool(). - @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of - package version name. A value of 0 indicates the device does not support - update of package version name. Length is the number of Unicode characters, - including the terminating null character. - @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute - Definitions' for possible returned values of this parameter. A value of 1 - indicates the attribute is supported and the current setting value is - indicated in AttributesSetting. A value of 0 indicates the attribute is not - supported and the current setting value in AttributesSetting is meaningless. - @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned - values of this parameter - - @retval EFI_SUCCESS The package information was successfully returned. - @retval EFI_UNSUPPORTED The operation is not supported. - -**/ -EFI_STATUS -EFIAPI -FmpGetPackageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - OUT UINT32 *PackageVersion, - OUT CHAR16 **PackageVersionName, - OUT UINT32 *PackageVersionNameMaxLen, - OUT UINT64 *AttributesSupported, - OUT UINT64 *AttributesSetting - ); - -/** - Updates information about the firmware package. - - This function updates package information. - This function returns EFI_UNSUPPORTED if the package information is not updatable. - VendorCode enables vendor to implement vendor-specific package information update policy. - Null if the caller did not specify this policy or use the default policy. - - @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance. - @param[in] Image Points to the authentication image. - Null if authentication is not required. - @param[in] ImageSize Size of the authentication image in bytes. - 0 if authentication is not required. - @param[in] VendorCode This enables vendor to implement vendor-specific firmware - image update policy. - Null indicates the caller did not specify this policy or use - the default policy. - @param[in] PackageVersion The new package version. - @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing - the package version name. - The string length is equal to or less than the value returned in - PackageVersionNameMaxLen. - - @retval EFI_SUCCESS The device was successfully updated with the new package - information. - @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value - returned in PackageVersionNameMaxLen. - @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. - -**/ -EFI_STATUS -EFIAPI -FmpSetPackageInfo ( - IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, - IN CONST VOID *Image, - IN UINTN ImageSize, - IN CONST VOID *VendorCode, - IN UINT32 PackageVersion, - IN CONST CHAR16 *PackageVersionName - ); - -#endif - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf deleted file mode 100644 index 55797cf132..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf +++ /dev/null @@ -1,71 +0,0 @@ -## @file -# Microcode FMP update driver. -# -# Produce FMP instance to update Microcode. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = MicrocodeUpdateDxe - MODULE_UNI_FILE = MicrocodeUpdateDxe.uni - FILE_GUID = 0565365C-2FE1-4F88-B3BE-624C04623A20 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = MicrocodeFmpMain - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = X64 -# - -[Sources] - MicrocodeUpdate.h - MicrocodeFmp.c - MicrocodeUpdate.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - UefiLib - BaseMemoryLib - DebugLib - PcdLib - MemoryAllocationLib - UefiBootServicesTableLib - HobLib - UefiRuntimeServicesTableLib - UefiDriverEntryPoint - MicrocodeFlashAccessLib - -[Guids] - gMicrocodeFmpImageTypeIdGuid ## CONSUMES ## GUID - -[Protocols] - gEfiFirmwareManagementProtocolGuid ## PRODUCES - gEfiMpServiceProtocolGuid ## CONSUMES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES - -[Depex] - gEfiVariableArchProtocolGuid AND - gEfiMpServiceProtocolGuid - -[UserExtensions.TianoCore."ExtraFiles"] - MicrocodeUpdateDxeExtra.uni - diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni deleted file mode 100644 index 1b0d4941dc..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Microcode FMP update driver. -// -// Produce FMP instance to update Microcode. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Microcode FMP update driver." - -#string STR_MODULE_DESCRIPTION #language en-US "Produce FMP instance to update Microcode." diff --git a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni b/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni deleted file mode 100644 index b667f12f5c..0000000000 --- a/UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// MicrocodeUpdateDxe Localized Strings and Content -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"MicrocodeUpdate DXE Driver" - - diff --git a/UefiCpuPkg/Include/AcpiCpuData.h b/UefiCpuPkg/Include/AcpiCpuData.h deleted file mode 100644 index ec092074ce..0000000000 --- a/UefiCpuPkg/Include/AcpiCpuData.h +++ /dev/null @@ -1,162 +0,0 @@ -/** @file -Definitions for CPU S3 data. - -Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _ACPI_CPU_DATA_H_ -#define _ACPI_CPU_DATA_H_ - -// -// Register types in register table -// -typedef enum { - Msr, - ControlRegister, - MemoryMapped, - CacheControl -} REGISTER_TYPE; - -// -// Element of register table entry -// -typedef struct { - REGISTER_TYPE RegisterType; // offset 0 - 3 - UINT32 Index; // offset 4 - 7 - UINT8 ValidBitStart; // offset 8 - UINT8 ValidBitLength; // offset 9 - UINT16 Reserved; // offset 10 - 11 - UINT32 HighIndex; // offset 12-15, only valid for MemoryMapped - UINT64 Value; // offset 16-23 -} CPU_REGISTER_TABLE_ENTRY; - -// -// Register table definition, including current table length, -// allocated size of this table, and pointer to the list of table entries. -// -typedef struct { - // - // The number of valid entries in the RegisterTableEntry buffer - // - UINT32 TableLength; - UINT32 NumberBeforeReset; - // - // The size, in bytes, of the RegisterTableEntry buffer - // - UINT32 AllocatedSize; - // - // The initial APIC ID of the CPU this register table applies to - // - UINT32 InitialApicId; - // - // Physical address of CPU_REGISTER_TABLE_ENTRY structures. This buffer must be - // allocated below 4GB from memory of type EfiACPIMemoryNVS. - // - EFI_PHYSICAL_ADDRESS RegisterTableEntry; -} CPU_REGISTER_TABLE; - -// -// Data structure that is required for ACPI S3 resume. This structure must be -// allocated below 4GB from memory of type EfiACPIMemoryNVS. The PCD -// PcdCpuS3DataAddress must be set to the physical address where this structure -// is allocated -// -typedef struct { - // - // Physical address of 4KB buffer allocated below 1MB from memory of type - // EfiReservedMemoryType. The buffer is not required to be initialized, but - // it is recommended that the buffer be zero-filled. This buffer is used to - // wake APs during an ACPI S3 resume. - // - EFI_PHYSICAL_ADDRESS StartupVector; - // - // Physical address of structure of type IA32_DESCRIPTOR. This structure must - // be allocated below 4GB from memory of type EfiACPIMemoryNVS. The - // IA32_DESCRIPTOR structure provides the base address and length of a GDT - // The buffer for GDT must also be allocated below 4GB from memory of type - // EfiACPIMemoryNVS. The GDT must be filled in with the GDT contents that are - // used during an ACPI S3 resume. This is typically the contents of the GDT - // used by the boot processor when the platform is booted. - // - EFI_PHYSICAL_ADDRESS GdtrProfile; - // - // Physical address of structure of type IA32_DESCRIPTOR. This structure must - // be allocated below 4GB from memory of type EfiACPIMemoryNVS. The - // IA32_DESCRIPTOR structure provides the base address and length of an IDT. - // The buffer for IDT must also be allocated below 4GB from memory of type - // EfiACPIMemoryNVS. The IDT must be filled in with the IDT contents that are - // used during an ACPI S3 resume. This is typically the contents of the IDT - // used by the boot processor when the platform is booted. - // - EFI_PHYSICAL_ADDRESS IdtrProfile; - // - // Physical address of a buffer that is used as stacks during ACPI S3 resume. - // The total size of this buffer, in bytes, is NumberOfCpus * StackSize. This - // structure must be allocated below 4GB from memory of type EfiACPIMemoryNVS. - // - EFI_PHYSICAL_ADDRESS StackAddress; - // - // The size, in bytes, of the stack provided to each CPU during ACPI S3 resume. - // - UINT32 StackSize; - // - // The number of CPUs. If a platform does not support hot plug CPUs, then - // this is the number of CPUs detected when the platform is booted, regardless - // of being enabled or disabled. If a platform does support hot plug CPUs, - // then this is the maximum number of CPUs that the platform supports. - // - UINT32 NumberOfCpus; - // - // Physical address of structure of type MTRR_SETTINGS that contains a copy - // of the MTRR settings that are compatible with the MTRR settings used by - // the boot processor when the platform was booted. These MTRR settings are - // used during an ACPI S3 resume. This structure must be allocated below 4GB - // from memory of type EfiACPIMemoryNVS. - // - EFI_PHYSICAL_ADDRESS MtrrTable; - // - // Physical address of an array of CPU_REGISTER_TABLE structures, with - // NumberOfCpus entries. This array must be allocated below 4GB from memory - // of type EfiACPIMemoryNVS. If a register table is not required, then the - // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to 0. - // If TableLength is > 0, then elements of RegisterTableEntry are used to - // initialize the CPU that matches InitialApicId, during an ACPI S3 resume, - // before SMBASE relocation is performed. - // - EFI_PHYSICAL_ADDRESS PreSmmInitRegisterTable; - // - // Physical address of an array of CPU_REGISTER_TABLE structures, with - // NumberOfCpus entries. This array must be allocated below 4GB from memory - // of type EfiACPIMemoryNVS. If a register table is not required, then the - // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to 0. - // If TableLength is > 0, then elements of RegisterTableEntry are used to - // initialize the CPU that matches InitialApicId, during an ACPI S3 resume, - // after SMBASE relocation is performed. - // - EFI_PHYSICAL_ADDRESS RegisterTable; - // - // Physical address of a buffer that contains the machine check handler that - // is used during an ACPI S3 Resume. This buffer must be allocated below 4GB - // from memory of type EfiACPIMemoryNVS. In order for this machine check - // handler to be active on an AP during an ACPI S3 resume, the machine check - // vector in the IDT provided by IdtrProfile must be initialized to transfer - // control to this physical address. - // - EFI_PHYSICAL_ADDRESS ApMachineCheckHandlerBase; - // - // The size, in bytes, of the machine check handler that is used during an - // ACPI S3 Resume. If this field is 0, then a machine check handler is not - // provided. - // - UINT32 ApMachineCheckHandlerSize; -} ACPI_CPU_DATA; - -#endif diff --git a/UefiCpuPkg/Include/CpuHotPlugData.h b/UefiCpuPkg/Include/CpuHotPlugData.h deleted file mode 100644 index 2a0d9fabd5..0000000000 --- a/UefiCpuPkg/Include/CpuHotPlugData.h +++ /dev/null @@ -1,33 +0,0 @@ -/** @file -Definition for a structure sharing information for CPU hot plug. - -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_HOT_PLUG_DATA_H_ -#define _CPU_HOT_PLUG_DATA_H_ - -#define CPU_HOT_PLUG_DATA_REVISION_1 0x00000001 - -typedef struct { - UINT32 Revision; // Used for version identification for this structure - UINT32 ArrayLength; // The entries number of the following ApicId array and SmBase array - // - // Data required for SMBASE relocation - // - UINT64 *ApicId; // Pointer to ApicId array - UINTN *SmBase; // Pointer to SmBase array - UINT32 Reserved; - UINT32 SmrrBase; - UINT32 SmrrSize; -} CPU_HOT_PLUG_DATA; - -#endif diff --git a/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h b/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h deleted file mode 100644 index 70b5c704d5..0000000000 --- a/UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h +++ /dev/null @@ -1,26 +0,0 @@ -/** @file - CPU Features Init Done PPI/Protocol should be installed after CPU features - are initialized. - -Copyright (c) 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_FEATURES_INIT_DONE_H_ -#define _CPU_FEATURES_INIT_DONE_H_ - -#define EDKII_CPU_FEATURES_INIT_DONE_GUID \ - { \ - { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \ - } - -extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid; - -#endif diff --git a/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h b/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h deleted file mode 100644 index bf085c726c..0000000000 --- a/UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h +++ /dev/null @@ -1,26 +0,0 @@ -/** @file - CPU Features Set Done PPI/Protocol should be installed after CPU features - configuration are set. - -Copyright (c) 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_FEATURES_INIT_DONE_H_ -#define _CPU_FEATURES_INIT_DONE_H_ - -#define EDKII_CPU_FEATURES_SET_DONE_GUID \ - { \ - { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \ - } - -extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid; - -#endif diff --git a/UefiCpuPkg/Include/Guid/MicrocodeFmp.h b/UefiCpuPkg/Include/Guid/MicrocodeFmp.h deleted file mode 100644 index 88a19538c8..0000000000 --- a/UefiCpuPkg/Include/Guid/MicrocodeFmp.h +++ /dev/null @@ -1,21 +0,0 @@ -/** @file - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __MICROCODE_FMP_GUID_H__ -#define __MICROCODE_FMP_GUID_H__ - -#define MICROCODE_FMP_IMAGE_TYPE_ID_GUID { 0x96d4fdcd, 0x1502, 0x424d, { 0x9d, 0x4c, 0x9b, 0x12, 0xd2, 0xdc, 0xae, 0x5c } } - -extern EFI_GUID gMicrocodeFmpImageTypeIdGuid; - -#endif diff --git a/UefiCpuPkg/Include/Guid/MsegSmram.h b/UefiCpuPkg/Include/Guid/MsegSmram.h deleted file mode 100644 index ab337c4ccb..0000000000 --- a/UefiCpuPkg/Include/Guid/MsegSmram.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - - Defines the HOB GUID used to describe the MSEG memory region allocated in PEI. - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _MSEG_SMRAM_H_ -#define _MSEG_SMRAM_H_ - -#define MSEG_SMRAM_GUID \ - { \ - 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 } \ - } - -extern EFI_GUID gMsegSmramGuid; - -// -// The data portion of this HOB is type EFI_SMRAM_DESCRIPTOR -// - -#endif diff --git a/UefiCpuPkg/Include/Library/LocalApicLib.h b/UefiCpuPkg/Include/Library/LocalApicLib.h deleted file mode 100644 index fc980bc1f2..0000000000 --- a/UefiCpuPkg/Include/Library/LocalApicLib.h +++ /dev/null @@ -1,436 +0,0 @@ -/** @file - Public include file for Local APIC library. - - Local APIC library assumes local APIC is enabled. It does not - handles cases where local APIC is disabled. - - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __LOCAL_APIC_LIB_H__ -#define __LOCAL_APIC_LIB_H__ - -#define LOCAL_APIC_MODE_XAPIC 0x1 ///< xAPIC mode. -#define LOCAL_APIC_MODE_X2APIC 0x2 ///< x2APIC mode. - -/** - Retrieve the base address of local APIC. - - @return The base address of local APIC. - -**/ -UINTN -EFIAPI -GetLocalApicBaseAddress ( - VOID - ); - -/** - Set the base address of local APIC. - - If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). - - @param[in] BaseAddress Local APIC base address to be set. - -**/ -VOID -EFIAPI -SetLocalApicBaseAddress ( - IN UINTN BaseAddress - ); - -/** - Get the current local APIC mode. - - If local APIC is disabled, then ASSERT. - - @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. - @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. -**/ -UINTN -EFIAPI -GetApicMode ( - VOID - ); - -/** - Set the current local APIC mode. - - If the specified local APIC mode is not valid, then ASSERT. - If the specified local APIC mode can't be set as current, then ASSERT. - - @param ApicMode APIC mode to be set. - - @note This API must not be called from an interrupt handler or SMI handler. - It may result in unpredictable behavior. -**/ -VOID -EFIAPI -SetApicMode ( - IN UINTN ApicMode - ); - -/** - Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. - - In xAPIC mode, the initial local APIC ID may be different from current APIC ID. - In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, - the 32-bit local APIC ID is returned as initial APIC ID. - - @return 32-bit initial local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetInitialApicId ( - VOID - ); - -/** - Get the local APIC ID of the executing processor. - - @return 32-bit local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetApicId ( - VOID - ); - -/** - Get the value of the local APIC version register. - - @return the value of the local APIC version register. -**/ -UINT32 -EFIAPI -GetApicVersion ( - VOID - ); - -/** - Send a Fixed IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId The local APIC ID of the target processor. - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpi ( - IN UINT32 ApicId, - IN UINT8 Vector - ); - -/** - Send a Fixed IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpiAllExcludingSelf ( - IN UINT8 Vector - ); - -/** - Send a SMI IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendSmiIpi ( - IN UINT32 ApicId - ); - -/** - Send a SMI IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendSmiIpiAllExcludingSelf ( - VOID - ); - -/** - Send an INIT IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendInitIpi ( - IN UINT32 ApicId - ); - -/** - Send an INIT IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendInitIpiAllExcludingSelf ( - VOID - ); - -/** - Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param ApicId Specify the local APIC ID of the target processor. - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipi ( - IN UINT32 ApicId, - IN UINT32 StartupRoutine - ); - -/** - Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipiAllExcludingSelf ( - IN UINT32 StartupRoutine - ); - -/** - Initialize the state of the SoftwareEnable bit in the Local APIC - Spurious Interrupt Vector register. - - @param Enable If TRUE, then set SoftwareEnable to 1 - If FALSE, then set SoftwareEnable to 0. - -**/ -VOID -EFIAPI -InitializeLocalApicSoftwareEnable ( - IN BOOLEAN Enable - ); - -/** - Programming Virtual Wire Mode. - - This function programs the local APIC for virtual wire mode following - the example described in chapter A.3 of the MP 1.4 spec. - - IOxAPIC is not involved in this type of virtual wire mode. -**/ -VOID -EFIAPI -ProgramVirtualWireMode ( - VOID - ); - -/** - Disable LINT0 & LINT1 interrupts. - - This function sets the mask flag in the LVT LINT0 & LINT1 registers. -**/ -VOID -EFIAPI -DisableLvtInterrupts ( - VOID - ); - -/** - Read the initial count value from the init-count register. - - @return The initial count value read from the init-count register. -**/ -UINT32 -EFIAPI -GetApicTimerInitCount ( - VOID - ); - -/** - Read the current count value from the current-count register. - - @return The current count value read from the current-count register. -**/ -UINT32 -EFIAPI -GetApicTimerCurrentCount ( - VOID - ); - -/** - Initialize the local APIC timer. - - The local APIC timer is initialized and enabled. - - @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - If it is 0, then use the current divide value in the DCR. - @param InitCount The initial count value. - @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector The timer interrupt vector number. -**/ -VOID -EFIAPI -InitializeApicTimer ( - IN UINTN DivideValue, - IN UINT32 InitCount, - IN BOOLEAN PeriodicMode, - IN UINT8 Vector - ); - -/** - Get the state of the local APIC timer. - - @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector Return the timer interrupt vector number. -**/ -VOID -EFIAPI -GetApicTimerState ( - OUT UINTN *DivideValue OPTIONAL, - OUT BOOLEAN *PeriodicMode OPTIONAL, - OUT UINT8 *Vector OPTIONAL - ); - -/** - Enable the local APIC timer interrupt. -**/ -VOID -EFIAPI -EnableApicTimerInterrupt ( - VOID - ); - -/** - Disable the local APIC timer interrupt. -**/ -VOID -EFIAPI -DisableApicTimerInterrupt ( - VOID - ); - -/** - Get the local APIC timer interrupt state. - - @retval TRUE The local APIC timer interrupt is enabled. - @retval FALSE The local APIC timer interrupt is disabled. -**/ -BOOLEAN -EFIAPI -GetApicTimerInterruptState ( - VOID - ); - -/** - Send EOI to the local APIC. -**/ -VOID -EFIAPI -SendApicEoi ( - VOID - ); - -/** - Get the 32-bit address that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - @return 32-bit address used to send an MSI to the Local APIC. -**/ -UINT32 -EFIAPI -GetApicMsiAddress ( - VOID - ); - -/** - Get the 64-bit data value that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - If Vector is not in range 0x10..0xFE, then ASSERT(). - If DeliveryMode is not supported, then ASSERT(). - - @param Vector The 8-bit interrupt vector associated with the MSI. - Must be in the range 0x10..0xFE - @param DeliveryMode A 3-bit value that specifies how the recept of the MSI - is handled. The only supported values are: - 0: LOCAL_APIC_DELIVERY_MODE_FIXED - 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY - 2: LOCAL_APIC_DELIVERY_MODE_SMI - 4: LOCAL_APIC_DELIVERY_MODE_NMI - 5: LOCAL_APIC_DELIVERY_MODE_INIT - 7: LOCAL_APIC_DELIVERY_MODE_EXTINT - - @param LevelTriggered TRUE specifies a level triggered interrupt. - FALSE specifies an edge triggered interrupt. - @param AssertionLevel Ignored if LevelTriggered is FALSE. - TRUE specifies a level triggered interrupt that active - when the interrupt line is asserted. - FALSE specifies a level triggered interrupt that active - when the interrupt line is deasserted. - - @return 64-bit data value used to send an MSI to the Local APIC. -**/ -UINT64 -EFIAPI -GetApicMsiValue ( - IN UINT8 Vector, - IN UINTN DeliveryMode, - IN BOOLEAN LevelTriggered, - IN BOOLEAN AssertionLevel - ); - -/** - Get Package ID/Core ID/Thread ID of a processor. - - The algorithm assumes the target system has symmetry across physical - package boundaries with respect to the number of logical processors - per package, number of cores per package. - - @param[in] InitialApicId Initial APIC ID of the target logical processor. - @param[out] Package Returns the processor package ID. - @param[out] Core Returns the processor core ID. - @param[out] Thread Returns the processor thread ID. -**/ -VOID -EFIAPI -GetProcessorLocationByApicId ( - IN UINT32 InitialApicId, - OUT UINT32 *Package OPTIONAL, - OUT UINT32 *Core OPTIONAL, - OUT UINT32 *Thread OPTIONAL - ); - -#endif - diff --git a/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h b/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h deleted file mode 100644 index 0dfc3ef376..0000000000 --- a/UefiCpuPkg/Include/Library/MicrocodeFlashAccessLib.h +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - Microcode flash device access library. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#ifndef __MICROCODE_FLASH_ACCESS_LIB_H__ -#define __MICROCODE_FLASH_ACCESS_LIB_H__ - -/** - Perform microcode write opreation. - - @param[in] FlashAddress The address of flash device to be accessed. - @param[in] Buffer The pointer to the data buffer. - @param[in] Length The length of data buffer in bytes. - - @retval EFI_SUCCESS The operation returns successfully. - @retval EFI_WRITE_PROTECTED The flash device is read only. - @retval EFI_UNSUPPORTED The flash device access is unsupported. - @retval EFI_INVALID_PARAMETER The input parameter is not valid. -**/ -EFI_STATUS -EFIAPI -MicrocodeFlashWrite ( - IN EFI_PHYSICAL_ADDRESS FlashAddress, - IN VOID *Buffer, - IN UINTN Length - ); - -#endif diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/Library/MpInitLib.h deleted file mode 100644 index 05e9c6b3e6..0000000000 --- a/UefiCpuPkg/Include/Library/MpInitLib.h +++ /dev/null @@ -1,353 +0,0 @@ -/** @file - Multiple-Processor initialization Library. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __MP_INIT_LIB_H__ -#define __MP_INIT_LIB_H__ - -#include -#include - -/** - MP Initialize Library initialization. - - This service will allocate AP reset vector and wakeup all APs to do APs - initialization. - - This service must be invoked before all other MP Initialize Library - service are invoked. - - @retval EFI_SUCCESS MP initialization succeeds. - @retval Others MP initialization fails. - -**/ -EFI_STATUS -EFIAPI -MpInitLibInitialize ( - VOID - ); - -/** - Retrieves the number of logical processor in the platform and the number of - those logical processors that are enabled on this boot. This service may only - be called from the BSP. - - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors - is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibGetNumberOfProcessors ( - OUT UINTN *NumberOfProcessors, OPTIONAL - OUT UINTN *NumberOfEnabledProcessors OPTIONAL - ); - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - @param[out] HealthData Return processor health data. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibGetProcessorInfo ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, - OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL - ); - -/** - This service executes a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure, or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by MpInitLibStartupAllAPs() or - MPInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, - if all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - The buffer is allocated by MP Initialization - library, and it's the caller's responsibility to - free the buffer with FreePool() service. - In blocking mode, it is ready for consumption - when the call returns. In non-blocking mode, - it is ready when WaitEvent is signaled. The - list of failed CPU is terminated by - END_OF_CPU_LIST. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - all enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupAllAPs ( - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ); - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. - - @param[in] Procedure A pointer to the function to be run on the - designated AP of the system. See type - EFI_AP_PROCEDURE. - @param[in] ProcessorNumber The handle number of the AP. The range is - from 0 to the total number of logical - processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until this AP finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on this AP, - and go on executing immediately. If this AP - return from Procedure or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - this AP to finish this Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - this AP returns from Procedure, then Procedure - on the AP is terminated. The - AP is available for next function assigned - by MpInitLibStartupAllAPs() or - MpInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure on the - specified AP. - @param[out] Finished If NULL, this parameter is ignored. In - blocking mode, this parameter is ignored. - In non-blocking mode, if AP returns from - Procedure before the timeout expires, its - content is set to TRUE. Otherwise, the - value is set to FALSE. The caller can - determine if the AP returned from Procedure - by evaluating this value. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval EFI_SUCCESS In non-blocking mode, the function has been - dispatched to specified AP. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - the specified AP has finished. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupThisAP ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ); - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibSwitchBSP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ); - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. This flag - corresponds to StatusFlag defined in - EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only - the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter - is ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed - prior to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibEnableDisableAP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ); - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - @param[out] ProcessorNumber Pointer to the handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibWhoAmI ( - OUT UINTN *ProcessorNumber - ); - -#endif diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Library/MtrrLib.h deleted file mode 100644 index a63da4d1f5..0000000000 --- a/UefiCpuPkg/Include/Library/MtrrLib.h +++ /dev/null @@ -1,387 +0,0 @@ -/** @file - MTRR setting library - - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _MTRR_LIB_H_ -#define _MTRR_LIB_H_ - -// -// According to IA32 SDM, MTRRs number and MSR offset are always consistent -// for IA32 processor family -// - -// -// The semantics of below macro is MAX_MTRR_NUMBER_OF_VARIABLE_MTRR, the real number can be read out from MTRR_CAP register. -// -#define MTRR_NUMBER_OF_VARIABLE_MTRR 32 -// -// Firmware need reserve 2 MTRR for OS -// Note: It is replaced by PCD PcdCpuNumberOfReservedVariableMtrrs -// -#define RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER 2 - -#define MTRR_NUMBER_OF_FIXED_MTRR 11 -// -// Below macro is deprecated, and should not be used. -// -#define FIRMWARE_VARIABLE_MTRR_NUMBER 6 -#define MTRR_LIB_IA32_MTRR_CAP 0x0FE -#define MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK 0x0FF -#define MTRR_LIB_IA32_MTRR_FIX64K_00000 0x250 -#define MTRR_LIB_IA32_MTRR_FIX16K_80000 0x258 -#define MTRR_LIB_IA32_MTRR_FIX16K_A0000 0x259 -#define MTRR_LIB_IA32_MTRR_FIX4K_C0000 0x268 -#define MTRR_LIB_IA32_MTRR_FIX4K_C8000 0x269 -#define MTRR_LIB_IA32_MTRR_FIX4K_D0000 0x26A -#define MTRR_LIB_IA32_MTRR_FIX4K_D8000 0x26B -#define MTRR_LIB_IA32_MTRR_FIX4K_E0000 0x26C -#define MTRR_LIB_IA32_MTRR_FIX4K_E8000 0x26D -#define MTRR_LIB_IA32_MTRR_FIX4K_F0000 0x26E -#define MTRR_LIB_IA32_MTRR_FIX4K_F8000 0x26F -#define MTRR_LIB_IA32_VARIABLE_MTRR_BASE 0x200 -// -// Below macro is deprecated, and should not be used. -// -#define MTRR_LIB_IA32_VARIABLE_MTRR_END 0x20F -#define MTRR_LIB_IA32_MTRR_DEF_TYPE 0x2FF -#define MTRR_LIB_MSR_VALID_MASK 0xFFFFFFFFFULL -#define MTRR_LIB_CACHE_VALID_ADDRESS 0xFFFFFF000ULL -#define MTRR_LIB_CACHE_MTRR_ENABLED 0x800 -#define MTRR_LIB_CACHE_FIXED_MTRR_ENABLED 0x400 - -// -// Structure to describe a fixed MTRR -// -typedef struct { - UINT32 Msr; - UINT32 BaseAddress; - UINT32 Length; -} FIXED_MTRR; - -// -// Structure to describe a variable MTRR -// -typedef struct { - UINT64 BaseAddress; - UINT64 Length; - UINT64 Type; - UINT32 Msr; - BOOLEAN Valid; - BOOLEAN Used; -} VARIABLE_MTRR; - -// -// Structure to hold base and mask pair for variable MTRR register -// -typedef struct _MTRR_VARIABLE_SETTING_ { - UINT64 Base; - UINT64 Mask; -} MTRR_VARIABLE_SETTING; - -// -// Array for variable MTRRs -// -typedef struct _MTRR_VARIABLE_SETTINGS_ { - MTRR_VARIABLE_SETTING Mtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; -} MTRR_VARIABLE_SETTINGS; - -// -// Array for fixed MTRRs -// -typedef struct _MTRR_FIXED_SETTINGS_ { - UINT64 Mtrr[MTRR_NUMBER_OF_FIXED_MTRR]; -} MTRR_FIXED_SETTINGS; - -// -// Structure to hold all MTRRs -// -typedef struct _MTRR_SETTINGS_ { - MTRR_FIXED_SETTINGS Fixed; - MTRR_VARIABLE_SETTINGS Variables; - UINT64 MtrrDefType; -} MTRR_SETTINGS; - -// -// Memory cache types -// -typedef enum { - CacheUncacheable = 0, - CacheWriteCombining = 1, - CacheWriteThrough = 4, - CacheWriteProtected = 5, - CacheWriteBack = 6, - CacheInvalid = 7 -} MTRR_MEMORY_CACHE_TYPE; - -#define MTRR_CACHE_UNCACHEABLE 0 -#define MTRR_CACHE_WRITE_COMBINING 1 -#define MTRR_CACHE_WRITE_THROUGH 4 -#define MTRR_CACHE_WRITE_PROTECTED 5 -#define MTRR_CACHE_WRITE_BACK 6 -#define MTRR_CACHE_INVALID_TYPE 7 - -/** - Returns the variable MTRR count for the CPU. - - @return Variable MTRR count - -**/ -UINT32 -EFIAPI -GetVariableMtrrCount ( - VOID - ); - -/** - Returns the firmware usable variable MTRR count for the CPU. - - @return Firmware usable variable MTRR count - -**/ -UINT32 -EFIAPI -GetFirmwareVariableMtrrCount ( - VOID - ); - -/** - This function attempts to set the attributes for a memory range. - - @param[in] BaseAddress The physical address that is the start - address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attribute The bit mask of attributes to set for the - memory region. - - @retval RETURN_SUCCESS The attributes were set for the memory - region. - @retval RETURN_INVALID_PARAMETER Length is zero. - @retval RETURN_UNSUPPORTED The processor does not support one or - more bytes of the memory resource range - specified by BaseAddress and Length. - @retval RETURN_UNSUPPORTED The bit mask of attributes is not support - for the memory resource range specified - by BaseAddress and Length. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource - range specified by BaseAddress and Length - cannot be modified. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to - modify the attributes of the memory - resource range. - -**/ -RETURN_STATUS -EFIAPI -MtrrSetMemoryAttribute ( - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Attribute - ); - - -/** - This function will get the memory cache type of the specific address. - This function is mainly for debugging purposes. - - @param[in] Address The specific address - - @return The memory cache type of the specific address - -**/ -MTRR_MEMORY_CACHE_TYPE -EFIAPI -MtrrGetMemoryAttribute ( - IN PHYSICAL_ADDRESS Address - ); - - -/** - This function will get the raw value in variable MTRRs - - @param[out] VariableSettings A buffer to hold variable MTRRs content. - - @return The buffer point to MTRR_VARIABLE_SETTINGS in which holds the content of the variable MTRR - -**/ -MTRR_VARIABLE_SETTINGS* -EFIAPI -MtrrGetVariableMtrr ( - OUT MTRR_VARIABLE_SETTINGS *VariableSettings - ); - - -/** - This function sets variable MTRRs - - @param[in] VariableSettings A buffer to hold variable MTRRs content. - - @return The pointer of VariableSettings - -**/ -MTRR_VARIABLE_SETTINGS* -EFIAPI -MtrrSetVariableMtrr ( - IN MTRR_VARIABLE_SETTINGS *VariableSettings - ); - - -/** - This function gets the content in fixed MTRRs - - @param[out] FixedSettings A buffer to hold fixed MTRRs content. - - @return The pointer of FixedSettings - -**/ -MTRR_FIXED_SETTINGS* -EFIAPI -MtrrGetFixedMtrr ( - OUT MTRR_FIXED_SETTINGS *FixedSettings - ); - - -/** - This function sets fixed MTRRs - - @param[in] FixedSettings A buffer holding fixed MTRRs content. - - @return The pointer of FixedSettings - -**/ -MTRR_FIXED_SETTINGS* -EFIAPI -MtrrSetFixedMtrr ( - IN MTRR_FIXED_SETTINGS *FixedSettings - ); - - -/** - This function gets the content in all MTRRs (variable and fixed) - - @param[out] MtrrSetting A buffer to hold all MTRRs content. - - @return The pointer of MtrrSetting - -**/ -MTRR_SETTINGS * -EFIAPI -MtrrGetAllMtrrs ( - OUT MTRR_SETTINGS *MtrrSetting - ); - - -/** - This function sets all MTRRs (variable and fixed) - - @param[in] MtrrSetting A buffer to hold all MTRRs content. - - @return The pointer of MtrrSetting - -**/ -MTRR_SETTINGS * -EFIAPI -MtrrSetAllMtrrs ( - IN MTRR_SETTINGS *MtrrSetting - ); - - -/** - Get the attribute of variable MTRRs. - - This function shadows the content of variable MTRRs into - an internal array: VariableMtrr - - @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR - @param[in] MtrrValidAddressMask The valid address mask for MTRR since the base address in - MTRR must align to 4K, so valid address mask equal to - MtrrValidBitsMask & 0xfffffffffffff000ULL - @param[out] VariableMtrr The array to shadow variable MTRRs content - - @return The return value of this parameter indicates the number of - MTRRs which has been used. -**/ -UINT32 -EFIAPI -MtrrGetMemoryAttributeInVariableMtrr ( - IN UINT64 MtrrValidBitsMask, - IN UINT64 MtrrValidAddressMask, - OUT VARIABLE_MTRR *VariableMtrr - ); - - -/** - This function prints all MTRRs for debugging. -**/ -VOID -EFIAPI -MtrrDebugPrintAllMtrrs ( - VOID - ); - -/** - Checks if MTRR is supported. - - @retval TRUE MTRR is supported. - @retval FALSE MTRR is not supported. - -**/ -BOOLEAN -EFIAPI -IsMtrrSupported ( - VOID - ); - -/** - Returns the default MTRR cache type for the system. - - @return The default MTRR cache type. - -**/ -MTRR_MEMORY_CACHE_TYPE -EFIAPI -MtrrGetDefaultMemoryType ( - VOID - ); - -/** - This function attempts to set the attributes into MTRR setting buffer for a memory range. - - @param[in, out] MtrrSetting MTRR setting buffer to be set. - @param[in] BaseAddress The physical address that is the start address - of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attribute The bit mask of attributes to set for the - memory region. - - @retval RETURN_SUCCESS The attributes were set for the memory region. - @retval RETURN_INVALID_PARAMETER Length is zero. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the - memory resource range specified by BaseAddress and Length. - @retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - -**/ -RETURN_STATUS -EFIAPI -MtrrSetMemoryAttributeInMtrrSettings ( - IN OUT MTRR_SETTINGS *MtrrSetting, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Attribute - ); - -#endif // _MTRR_LIB_H_ diff --git a/UefiCpuPkg/Include/Library/PlatformSecLib.h b/UefiCpuPkg/Include/Library/PlatformSecLib.h deleted file mode 100644 index 0af7781771..0000000000 --- a/UefiCpuPkg/Include/Library/PlatformSecLib.h +++ /dev/null @@ -1,70 +0,0 @@ -/** @file -This library class defines interface for platform to perform platform -specific initialization in SEC phase. - -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __PLATFORM_SEC_LIB_H__ -#define __PLATFORM_SEC_LIB_H__ - -/** - A developer supplied function to perform platform specific operations. - - It's a developer supplied function to perform any operations appropriate to a - given platform. It's invoked just before passing control to PEI core by SEC - core. Platform developer may modify the SecCoreData passed to PEI Core. - It returns a platform specific PPI list that platform wishes to pass to PEI core. - The Generic SEC core module will merge this list to join the final list passed to - PEI core. - - @param SecCoreData The same parameter as passing to PEI core. It - could be overridden by this function. - - @return The platform specific PPI list to be passed to PEI core or - NULL if there is no need of such platform specific PPI list. - -**/ -EFI_PEI_PPI_DESCRIPTOR * -EFIAPI -SecPlatformMain ( - IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData - ); - -/** - This interface conveys state information out of the Security (SEC) phase into PEI. - - @param PeiServices Pointer to the PEI Services Table. - @param StructureSize Pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord - ); - -/** - This interface disables temporary memory in SEC Phase. -**/ -VOID -EFIAPI -SecPlatformDisableTemporaryMemory ( - VOID - ); - -#endif diff --git a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h b/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h deleted file mode 100644 index 4aa3529eb7..0000000000 --- a/UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h +++ /dev/null @@ -1,518 +0,0 @@ -/** @file - Register CPU Features Library to register and manage CPU features. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __REGISTER_CPU_FEATURES_LIB_H__ -#define __REGISTER_CPU_FEATURES_LIB_H__ - -#include -#include -#include - -/// -/// Defines used to identify a CPU feature. The lower 16-bits are used to -/// identify a unique CPU feature and the value represents a bit number in -/// a bit mask. The upper 16-bits are bit mask values that are used as -/// modifiers of a CPU feature. When used in a list, the define value -/// CPU_FEATURE_END is used to terminate a list of CPU feature values. -/// @{ -#define CPU_FEATURE_AESNI 0 -#define CPU_FEATURE_TURBO_MODE 1 -#define CPU_FEATURE_MWAIT 2 -#define CPU_FEATURE_ACPI 3 -#define CPU_FEATURE_EIST 4 -#define CPU_FEATURE_XD 5 -#define CPU_FEATURE_FASTSTRINGS 6 -#define CPU_FEATURE_VMX 7 -#define CPU_FEATURE_SMX 8 -#define CPU_FEATURE_SENTER 9 -#define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER 10 -#define CPU_FEATURE_LIMIT_CPUID_MAX_VAL 11 -#define CPU_FEATURE_MCE 12 -#define CPU_FEATURE_MCA 13 -#define CPU_FEATURE_MCG_CTL 14 -#define CPU_FEATURE_PENDING_BREAK 15 -#define CPU_FEATURE_C1E 16 -#define CPU_FEATURE_C1_AUTO_DEMOTION 17 -#define CPU_FEATURE_C3_AUTO_DEMOTION 18 -#define CPU_FEATURE_C1_UNDEMOTION 19 -#define CPU_FEATURE_C3_UNDEMOTION 20 -#define CPU_FEATURE_C_STATE 21 -#define CPU_FEATURE_TM 22 -#define CPU_FEATURE_TM2 23 -#define CPU_FEATURE_X2APIC 24 -#define CPU_FEATURE_RESERVED_25 25 -#define CPU_FEATURE_RESERVED_26 26 -#define CPU_FEATURE_RESERVED_27 27 -#define CPU_FEATURE_RESERVED_28 28 -#define CPU_FEATURE_RESERVED_29 29 -#define CPU_FEATURE_RESERVED_30 30 -#define CPU_FEATURE_RESERVED_31 31 - -#define CPU_FEATURE_L2_PREFETCHER (32+0) -#define CPU_FEATURE_L1_DATA_PREFETCHER (32+1) -#define CPU_FEATURE_HARDWARE_PREFETCHER (32+2) -#define CPU_FEATURE_ADJACENT_CACHE_LINE_PREFETCH (32+3) -#define CPU_FEATURE_DCU_PREFETCHER (32+4) -#define CPU_FEATURE_IP_PREFETCHER (32+5) -#define CPU_FEATURE_MLC_STREAMER_PREFETCHER (32+6) -#define CPU_FEATURE_MLC_SPATIAL_PREFETCHER (32+7) -#define CPU_FEATURE_THREE_STRICK_COUNTER (32+8) -#define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE (32+9) -#define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS (32+10) - -#define CPU_FEATURE_BEFORE_ALL BIT27 -#define CPU_FEATURE_AFTER_ALL BIT28 -#define CPU_FEATURE_BEFORE BIT29 -#define CPU_FEATURE_AFTER BIT30 -#define CPU_FEATURE_END MAX_UINT32 -/// @} - -/// -/// CPU Information passed into the SupportFunc and InitializeFunc of the -/// RegisterCpuFeature() library function. This structure contains information -/// that is commonly used during CPU feature detection and initialization. -/// -typedef struct { - /// - /// The package that the CPU resides - /// - EFI_PROCESSOR_INFORMATION ProcessorInfo; - /// - /// The Display Family of the CPU computed from CPUID leaf CPUID_VERSION_INFO - /// - UINT32 DisplayFamily; - /// - /// The Display Model of the CPU computed from CPUID leaf CPUID_VERSION_INFO - /// - UINT32 DisplayModel; - /// - /// The Stepping ID of the CPU computed from CPUID leaf CPUID_VERSION_INFO - /// - UINT32 SteppingId; - /// - /// The Processor Type of the CPU computed from CPUID leaf CPUID_VERSION_INFO - /// - UINT32 ProcessorType; - /// - /// Bit field structured returned in ECX from CPUID leaf CPUID_VERSION_INFO - /// - CPUID_VERSION_INFO_ECX CpuIdVersionInfoEcx; - /// - /// Bit field structured returned in EDX from CPUID leaf CPUID_VERSION_INFO - /// - CPUID_VERSION_INFO_EDX CpuIdVersionInfoEdx; -} REGISTER_CPU_FEATURE_INFORMATION; - -/** - Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask. - If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data - associated with that feature should be optimized away if compiler - optimizations are enabled. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesSupport. - - @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureSupported ( - IN UINT32 Feature - ); - -/** - Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesSetting. - - @retval TRUE The CPU feature is set in PcdCpuFeaturesSetting. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesSetting. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureInSetting ( - IN UINT32 Feature - ); - -/** - Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesCapability. - - @retval TRUE The CPU feature is set in PcdCpuFeaturesCapability. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesCapability. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureCapability ( - IN UINT32 Feature - ); - -/** - Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesUserConfiguration. - - @retval TRUE The CPU feature is set in PcdCpuFeaturesUserConfiguration. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesUserConfiguration. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureUserConfiguration ( - IN UINT32 Feature - ); - -/** - Prepares for the data used by CPU feature detection and initialization. - - @param[in] NumberOfProcessors The number of CPUs in the platform. - - @return Pointer to a buffer of CPU related configuration data. - - @note This service could be called by BSP only. -**/ -typedef -VOID * -(EFIAPI *CPU_FEATURE_GET_CONFIG_DATA)( - IN UINTN NumberOfProcessors - ); - -/** - Detects if CPU feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE CPU feature is supported. - @retval FALSE CPU feature is not supported. - - @note This service could be called by BSP/APs. -**/ -typedef -BOOLEAN -(EFIAPI *CPU_FEATURE_SUPPORT)( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes CPU feature to specific state. - - This service does not initialize hardware and only produces entries in the - Register Table for specified processor. Hardware initialization on BSP/APs - will be done in CpuFeaturesInitialize(). - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the CPU feature must be enabled. - If FALSE, then the CPU feature must be disabled. - - @retval RETURN_SUCCESS CPU feature is initialized. - - @note This service could be called by BSP only. -**/ -typedef -RETURN_STATUS -(EFIAPI *CPU_FEATURE_INITIALIZE)( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Registers a CPU Feature. - - @param[in] FeatureName A Null-terminated Ascii string indicates CPU feature - name. - @param[in] GetConfigDataFunc CPU feature get configuration data function. This - is an optional parameter that may be NULL. If NULL, - then the most recently registered function for the - CPU feature is used. If no functions are registered - for a CPU feature, then the CPU configuration data - for the registered feature is NULL. - @param[in] SupportFunc CPU feature support function. This is an optional - parameter that may be NULL. If NULL, then the most - recently registered function for the CPU feature is - used. If no functions are registered for a CPU - feature, then the CPU feature is assumed to be - supported by all CPUs. - @param[in] InitializeFunc CPU feature initialize function. This is an optional - parameter that may be NULL. If NULL, then the most - recently registered function for the CPU feature is - used. If no functions are registered for a CPU - feature, then the CPU feature initialization is - skipped. - @param[in] ... Variable argument list of UINT32 CPU feature value. - Values with no modifiers are the features provided - by the registered functions. - Values with CPU_FEATURE_BEFORE modifier are features - that must be initialized after the features provided - by the registered functions are used. - Values with CPU_FEATURE_AFTER modifier are features - that must be initialized before the features provided - by the registered functions are used. - The last argument in this variable argument list must - always be CPU_FEATURE_END. - - @retval RETURN_SUCCESS The CPU feature was successfully registered. - @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register - the CPU feature. - @retval RETURN_UNSUPPORTED Registration of the CPU feature is not - supported due to a circular dependency between - BEFORE and AFTER features. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -RegisterCpuFeature ( - IN CHAR8 *FeatureName, OPTIONAL - IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc, OPTIONAL - IN CPU_FEATURE_SUPPORT SupportFunc, OPTIONAL - IN CPU_FEATURE_INITIALIZE InitializeFunc, OPTIONAL - ... - ); - -/** - Performs CPU features detection. - - This service will invoke MP service to check CPU features' - capabilities on BSP/APs. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuFeaturesDetect ( - VOID - ); - -/** - Performs CPU features Initialization. - - This service will invoke MP service to perform CPU features - initialization on BSP/APs per user configuration. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuFeaturesInitialize ( - VOID - ); - -/** - Switches to assigned BSP after CPU features initialization. - - @param[in] ProcessorNumber The index of the CPU executing this function. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -SwitchBspAfterFeaturesInitialize ( - IN UINTN ProcessorNumber - ); - -/** - Adds an entry in specified register table. - - This function adds an entry in specified register table, with given register type, - register index, bit section and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] ValueMask Mask of bits in register to write - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuRegisterTableWrite ( - IN UINTN ProcessorNumber, - IN REGISTER_TYPE RegisterType, - IN UINT64 Index, - IN UINT64 ValueMask, - IN UINT64 Value - ); - -/** - Adds an entry in specified Pre-SMM register table. - - This function adds an entry in specified register table, with given register type, - register index, bit section and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] ValueMask Mask of bits in register to write - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -PreSmmCpuRegisterTableWrite ( - IN UINTN ProcessorNumber, - IN REGISTER_TYPE RegisterType, - IN UINT64 Index, - IN UINT64 ValueMask, - IN UINT64 Value - ); - -/** - Adds a 32-bit register write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -#define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \ - do { \ - CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \ - } while(FALSE); - -/** - Adds a 64-bit register write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \ - do { \ - CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \ - } while(FALSE); - -/** - Adds a bit field write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, bit field section, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program. - @param[in] Index Index of the register to program. - @param[in] Type The data type name of a register structure. - @param[in] Field The bit fiel name in register structure to write. - @param[in] Value Value to write to the bit field. - - @note This service could be called by BSP only. -**/ -#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \ - do { \ - UINT64 ValueMask; \ - ValueMask = MAX_UINT64; \ - ((Type *)(&ValueMask))->Field = 0; \ - CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \ - } while(FALSE); - -/** - Adds a 32-bit register write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -#define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value) \ - do { \ - PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \ - } while(FALSE); - -/** - Adds a 64-bit register write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -#define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value) \ - do { \ - PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \ - } while(FALSE); - -/** - Adds a bit field write entry in specified register table. - - This macro adds an entry in specified register table, with given register type, - register index, bit field section, and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program. - @param[in] Index Index of the register to program. - @param[in] Type The data type name of a register structure. - @param[in] Field The bit fiel name in register structure to write. - @param[in] Value Value to write to the bit field. - - @note This service could be called by BSP only. -**/ -#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \ - do { \ - UINT64 ValueMask; \ - ValueMask = MAX_UINT64; \ - ((Type *)(&ValueMask))->Field = 0; \ - PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value); \ - } while(FALSE); - -#endif diff --git a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h deleted file mode 100644 index 4478003467..0000000000 --- a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h +++ /dev/null @@ -1,401 +0,0 @@ -/** @file -Library that provides CPU specific functions to support the PiSmmCpuDxeSmm module. - -Copyright (c) 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __SMM_FEATURES_LIB_H__ -#define __SMM_FEATURES_LIB_H__ - -#include -#include -#include -#include - -/// -/// Enumeration of SMM registers that are accessed using the library functions -/// SmmCpuFeaturesIsSmmRegisterSupported (), SmmCpuFeaturesGetSmmRegister (), -/// and SmmCpuFeaturesSetSmmRegister (). -/// -typedef enum { - /// - /// Read-write register to provides access to MSR_SMM_FEATURE_CONTROL if the - /// CPU supports this MSR. - /// - SmmRegFeatureControl, - /// - /// Read-only register that returns a non-zero value if the CPU is able to - /// respond to SMIs. - /// - SmmRegSmmEnable, - /// - /// Read-only register that returns a non-zero value if the CPU is able to - /// respond to SMIs, but is busy with other actions that are causing a delay - /// in responding to an SMI. This register abstracts access to MSR_SMM_DELAYED - /// if the CPU supports this MSR. - /// - SmmRegSmmDelayed, - /// - /// Read-only register that returns a non-zero value if the CPU is able to - /// respond to SMIs, but is busy with other actions that are blocking its - /// ability to respond to an SMI. This register abstracts access to - /// MSR_SMM_BLOCKED if the CPU supports this MSR. - /// - SmmRegSmmBlocked -} SMM_REG_NAME; - -/** - Called during the very first SMI into System Management Mode to initialize - CPU features, including SMBASE, for the currently executing CPU. Since this - is the first SMI, the SMRAM Save State Map is at the default address of - SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executing - CPU is specified by CpuIndex and CpuIndex can be used to access information - about the currently executing CPU in the ProcessorInfo array and the - HotPlugCpuData data structure. - - @param[in] CpuIndex The index of the CPU to initialize. The value - must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU that - was elected as monarch during System Management - Mode initialization. - FALSE if the CpuIndex is not the index of the CPU - that was elected as monarch during System - Management Mode initialization. - @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMATION - structures. ProcessorInfo[CpuIndex] contains the - information for the currently executing CPU. - @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure that - contains the ApidId and SmBase arrays. -**/ -VOID -EFIAPI -SmmCpuFeaturesInitializeProcessor ( - IN UINTN CpuIndex, - IN BOOLEAN IsMonarch, - IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, - IN CPU_HOT_PLUG_DATA *CpuHotPlugData - ); - -/** - This function updates the SMRAM save state on the currently executing CPU - to resume execution at a specific address after an RSM instruction. This - function must evaluate the SMRAM save state to determine the execution mode - the RSM instruction resumes and update the resume execution address with - either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart - flag in the SMRAM save state must always be cleared. This function returns - the value of the instruction pointer from the SMRAM save state that was - replaced. If this function returns 0, then the SMRAM save state was not - modified. - - This function is called during the very first SMI on each CPU after - SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode - to signal that the SMBASE of each CPU has been updated before the default - SMBASE address is used for the first SMI to the next CPU. - - @param[in] CpuIndex The index of the CPU to hook. The value - must be between 0 and the NumberOfCpus - field in the System Management System Table - (SMST). - @param[in] CpuState Pointer to SMRAM Save State Map for the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to - 32-bit execution mode from 64-bit SMM. - @param[in] NewInstructionPointer Instruction pointer to use if resuming to - same execution mode as SMM. - - @retval 0 This function did modify the SMRAM save state. - @retval > 0 The original instruction pointer value from the SMRAM save state - before it was replaced. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesHookReturnFromSmm ( - IN UINTN CpuIndex, - IN SMRAM_SAVE_STATE_MAP *CpuState, - IN UINT64 NewInstructionPointer32, - IN UINT64 NewInstructionPointer - ); - -/** - Hook point in normal execution mode that allows the one CPU that was elected - as monarch during System Management Mode initialization to perform additional - initialization actions immediately after all of the CPUs have processed their - first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE - into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). -**/ -VOID -EFIAPI -SmmCpuFeaturesSmmRelocationComplete ( - VOID - ); - -/** - Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is - returned, then a custom SMI handler is not provided by this library, - and the default SMI handler must be used. - - @retval 0 Use the default SMI handler. - @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() - The caller is required to allocate enough SMRAM for each CPU to - support the size of the custom SMI handler. -**/ -UINTN -EFIAPI -SmmCpuFeaturesGetSmiHandlerSize ( - VOID - ); - -/** - Install a custom SMI handler for the CPU specified by CpuIndex. This function - is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater - than zero and is called by the CPU that was elected as monarch during System - Management Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -SmmCpuFeaturesInstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ); - -/** - Determines if MTRR registers must be configured to set SMRAM cache-ability - when executing in System Management Mode. - - @retval TRUE MTRR registers must be configured to set SMRAM cache-ability. - @retval FALSE MTRR registers do not need to be configured to set SMRAM - cache-ability. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesNeedConfigureMtrrs ( - VOID - ); - -/** - Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesDisableSmrr ( - VOID - ); - -/** - Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesReenableSmrr ( - VOID - ); - -/** - Processor specific hook point each time a CPU enters System Management Mode. - - @param[in] CpuIndex The index of the CPU that has entered SMM. The value - must be between 0 and the NumberOfCpus field in the - System Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousEntry ( - IN UINTN CpuIndex - ); - -/** - Processor specific hook point each time a CPU exits System Management Mode. - - @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must - be between 0 and the NumberOfCpus field in the System - Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousExit ( - IN UINTN CpuIndex - ); - -/** - Check to see if an SMM register is supported by a specified CPU. - - @param[in] CpuIndex The index of the CPU to check for SMM register support. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to check for support. - - @retval TRUE The SMM register specified by RegName is supported by the CPU - specified by CpuIndex. - @retval FALSE The SMM register specified by RegName is not supported by the - CPU specified by CpuIndex. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesIsSmmRegisterSupported ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ); - -/** - Returns the current value of the SMM register for the specified CPU. - If the SMM register is not supported, then 0 is returned. - - @param[in] CpuIndex The index of the CPU to read the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to read. - - @return The value of the SMM register specified by RegName from the CPU - specified by CpuIndex. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesGetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ); - -/** - Sets the value of an SMM register on a specified CPU. - If the SMM register is not supported, then no action is performed. - - @param[in] CpuIndex The index of the CPU to write the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to write. - registers are read-only. - @param[in] Value The value to write to the SMM register. -**/ -VOID -EFIAPI -SmmCpuFeaturesSetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName, - IN UINT64 Value - ); - -/** - Read an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for reading the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to read the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to read. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read - from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support reading Register. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ); - -/** - Writes an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for writing the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to write the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to write. - @param[in] Width The number of bytes to write to the CPU save state. - @param[in] Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written to Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support writing Register. -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesWriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ); - -/** - This function is hook point called after the gEfiSmmReadyToLockProtocolGuid - notification is completely processed. -**/ -VOID -EFIAPI -SmmCpuFeaturesCompleteSmmReadyToLock ( - VOID - ); - -/** - This API provides a method for a CPU to allocate a specific region for storing page tables. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the request, then NULL is - returned. - - This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer for page tables. - @retval NULL Fail to allocate a specific region for storing page tables, - Or there is no preference on where the page tables are allocated in SMRAM. - -**/ -VOID * -EFIAPI -SmmCpuFeaturesAllocatePageTableMemory ( - IN UINTN Pages - ); - -#endif diff --git a/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h b/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h deleted file mode 100644 index e40084edf9..0000000000 --- a/UefiCpuPkg/Include/Library/SmmCpuPlatformHookLib.h +++ /dev/null @@ -1,109 +0,0 @@ -/** @file - Public include file for the SMM CPU Platform Hook Library. - - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __SMM_CPU_PLATFORM_HOOK_LIB_H__ -#define __SMM_CPU_PLATFORM_HOOK_LIB_H__ - -/// -/// SMM Page Size Type -/// -typedef enum { - SmmPageSize4K, - SmmPageSize2M, - SmmPageSize1G, - MaxSmmPageSizeType -} SMM_PAGE_SIZE_TYPE; - -/** - Checks if platform produces a valid SMI. - - This function checks if platform produces a valid SMI. This function is - called at SMM entry to detect if this is a spurious SMI. This function - must be implemented in an MP safe way because it is called by multiple CPU - threads. - - @retval TRUE There is a valid SMI - @retval FALSE There is no valid SMI - -**/ -BOOLEAN -EFIAPI -PlatformValidSmi ( - VOID - ); - -/** - Clears platform top level SMI status bit. - - This function clears platform top level SMI status bit. - - @retval TRUE The platform top level SMI status is cleared. - @retval FALSE The platform top level SMI status cannot be cleared. - -**/ -BOOLEAN -EFIAPI -ClearTopLevelSmiStatus ( - VOID - ); - -/** - Performs platform specific way of SMM BSP election. - - This function performs platform specific way of SMM BSP election. - - @param IsBsp Output parameter. TRUE: the CPU this function executes - on is elected to be the SMM BSP. FALSE: the CPU this - function executes on is to be SMM AP. - - @retval EFI_SUCCESS The function executes successfully. - @retval EFI_NOT_READY The function does not determine whether this CPU should be - BSP or AP. This may occur if hardware init sequence to - enable the determination is yet to be done, or the function - chooses not to do BSP election and will let SMM CPU driver to - use its default BSP election process. - @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU should be - BSP or AP due to hardware error. - -**/ -EFI_STATUS -EFIAPI -PlatformSmmBspElection ( - OUT BOOLEAN *IsBsp - ); - -/** - Get platform page table attribute . - - This function gets page table attribute of platform. - - @param Address Input parameter. Obtain the page table entries attribute on this address. - @param PageSize Output parameter. The size of the page. - @param NumOfPages Output parameter. Number of page. - @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc). - - @retval EFI_SUCCESS The platform page table attribute from the address is determined. - @retval EFI_UNSUPPORTED The platform does not support getting page table attribute for the address. - -**/ -EFI_STATUS -EFIAPI -GetPlatformPageTableAttribute ( - IN UINT64 Address, - OUT SMM_PAGE_SIZE_TYPE *PageSize, - OUT UINTN *NumOfPages, - OUT UINTN *PageAttribute - ); - -#endif diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/UefiCpuLib.h deleted file mode 100644 index 561d579968..0000000000 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ /dev/null @@ -1,38 +0,0 @@ -/** @file - Public header file for UEFI CPU library class. - - This library class defines some routines that are generic for IA32 family CPU - to be UEFI specification compliant. - - Copyright (c) 2009, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __UEFI_CPU_LIB_H__ -#define __UEFI_CPU_LIB_H__ - - - -/** - Initializes floating point units for requirement of UEFI specification. - - This function initializes floating-point control word to 0x027F (all exceptions - masked,double-precision, round-to-nearest) and multimedia-extensions control word - (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero - for masked underflow). - -**/ -VOID -EFIAPI -InitializeFloatingPointUnits ( - VOID - ); - -#endif diff --git a/UefiCpuPkg/Include/Protocol/SmMonitorInit.h b/UefiCpuPkg/Include/Protocol/SmMonitorInit.h deleted file mode 100644 index 7b0aab0a6d..0000000000 --- a/UefiCpuPkg/Include/Protocol/SmMonitorInit.h +++ /dev/null @@ -1,141 +0,0 @@ -/** @file - STM service protocol definition - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SM_MONITOR_INIT_PROTOCOL_H_ -#define _SM_MONITOR_INIT_PROTOCOL_H_ - -#include -#include - -#define EFI_SM_MONITOR_INIT_PROTOCOL_GUID \ - { 0x228f344d, 0xb3de, 0x43bb, 0xa4, 0xd7, 0xea, 0x20, 0xb, 0x1b, 0x14, 0x82} - -// -// STM service -// - -/** - - Load STM image to MSEG. - - @param StmImage STM image - @param StmImageSize STM image size - - @retval EFI_SUCCESS Load STM to MSEG successfully - @retval EFI_ALREADY_STARTED STM image is already loaded to MSEG - @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image - @retval EFI_UNSUPPORTED MSEG is not enabled - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SM_MONITOR_LOAD_MONITOR) ( - IN EFI_PHYSICAL_ADDRESS StmImage, - IN UINTN StmImageSize - ); - -/** - - Add resources in list to database. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are added - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SM_MONITOR_ADD_PI_RESOURCE) ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ); - -/** - - Delete resources in list to database. - - @param ResourceList A pointer to resource list to be deleted - NULL means delete all resources. - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are deleted - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SM_MONITOR_DELETE_PI_RESOURCE) ( - IN STM_RSC *ResourceList OPTIONAL, - IN UINT32 NumEntries OPTIONAL - ); - -/** - - Get BIOS resources. - - @param ResourceList A pointer to resource list to be filled - @param ResourceSize On input it means size of resource list input. - On output it means size of resource list filled, - or the size of resource list to be filled if size of too small. - - @retval EFI_SUCCESS If resources are returned. - @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SM_MONITOR_GET_PI_RESOURCE) ( - OUT STM_RSC *ResourceList, - IN OUT UINT32 *ResourceSize - ); - -typedef UINT32 EFI_SM_MONITOR_STATE; -#define EFI_SM_MONITOR_STATE_ENABLED 0x1 -#define EFI_SM_MONITOR_STATE_ACTIVATED 0x2 - -/** - - Get STM state - - @return STM state - -**/ -typedef -EFI_SM_MONITOR_STATE -(EFIAPI *EFI_SM_MONITOR_GET_MONITOR_STATE) ( - VOID - ); - -typedef struct _EFI_SM_MONITOR_INIT_PROTOCOL { - // - // Valid at boot-time only - // - EFI_SM_MONITOR_LOAD_MONITOR LoadMonitor; - EFI_SM_MONITOR_ADD_PI_RESOURCE AddPiResource; - EFI_SM_MONITOR_DELETE_PI_RESOURCE DeletePiResource; - EFI_SM_MONITOR_GET_PI_RESOURCE GetPiResource; - // - // Valid at runtime - // - EFI_SM_MONITOR_GET_MONITOR_STATE GetMonitorState; -} EFI_SM_MONITOR_INIT_PROTOCOL; - -extern EFI_GUID gEfiSmMonitorInitProtocolGuid; - -#endif diff --git a/UefiCpuPkg/Include/Protocol/SmmCpuService.h b/UefiCpuPkg/Include/Protocol/SmmCpuService.h deleted file mode 100644 index 9aced54f4d..0000000000 --- a/UefiCpuPkg/Include/Protocol/SmmCpuService.h +++ /dev/null @@ -1,209 +0,0 @@ -/** @file -SMM CPU Service protocol definition. - -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_CPU_SERVICE_PROTOCOL_H_ -#define _SMM_CPU_SERVICE_PROTOCOL_H_ - -// -// Share some definitions with MP Services and CPU Arch Protocol -// -#include -#include - -#define EFI_SMM_CPU_SERVICE_PROTOCOL_GUID \ - { \ - 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 } \ - } - -typedef struct _EFI_SMM_CPU_SERVICE_PROTOCOL EFI_SMM_CPU_SERVICE_PROTOCOL; - -// -// Protocol functions -// - -/** - Gets processor information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL - instance. - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. -**/ -typedef -EFI_STATUS -(EFIAPI * EFI_SMM_GET_PROCESSOR_INFO) ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ); - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. The new BSP can take over the - execution of the old BSP and continue seamlessly from where the old one left - off. - - If the BSP cannot be switched prior to the return from this service, then - EFI_UNSUPPORTED must be returned. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_SUCCESS The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - -**/ -typedef -EFI_STATUS -(EFIAPI * EFI_SMM_SWITCH_BSP) ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ); - -/** - Notify that a new processor has been added to the system. - - The SMM CPU driver should add the processor to the SMM CPU list. - - If the processor is disabled it won't participate any SMI handler during subsequent SMIs. - - @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param ProcessorId The hardware ID of the processor. - @param ProcessorNumber The handle number of processor. - @param ProcessorResource A pointer to EFI_SMM_PROCESSOR_RESOURCE which holds the assigned resources. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_ALREADY_STARTED Processor already present. - @retval EFI_NOT_READY Space for a new handle could not be allocated. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SMM_ADD_PROCESSOR) ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINT64 ProcessorId, - OUT UINTN *ProcessorNumber - ); - -/** - Notify that a processor is hot-removed. - - Remove a processor from the CPU list of the SMM CPU driver. After this API is called, the removed processor - must not respond to SMIs in the coherence domain. - - @param This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param ProcessorId The hardware ID of the processor. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_NOT_FOUND Processor with the hardware ID specified by ProcessorId does not exist. - @retval EFI_NOT_READY Specified AP is busy. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SMM_REMOVE_PROCESSOR) ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ); - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - This service returns the processor handle number for the calling processor. - The returned value is in the range from 0 to the total number of logical - processors minus 1. This service may be called from the BSP and APs. - If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER - is returned. Otherwise, the current processors handle number is returned in - ProcessorNumber, and EFI_SUCCESS is returned. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - -**/ -typedef -EFI_STATUS -(EFIAPI * EFI_SMM_WHOAMI) ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - OUT UINTN *ProcessorNumber - ); - -/** - Register exception handler. - - @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. - @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and - the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL - of the UEFI 2.0 specification. - @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER - that is called when a processor interrupt occurs. - If this parameter is NULL, then the handler will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SMM_REGISTER_EXCEPTION_HANDLER) ( - IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ); - -// -// This protocol provides CPU services from SMM. -// -struct _EFI_SMM_CPU_SERVICE_PROTOCOL { - EFI_SMM_GET_PROCESSOR_INFO GetProcessorInfo; - EFI_SMM_SWITCH_BSP SwitchBsp; - EFI_SMM_ADD_PROCESSOR AddProcessor; - EFI_SMM_REMOVE_PROCESSOR RemoveProcessor; - EFI_SMM_WHOAMI WhoAmI; - EFI_SMM_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler; -}; - -extern EFI_GUID gEfiSmmCpuServiceProtocolGuid; - -#endif diff --git a/UefiCpuPkg/Include/Register/ArchitecturalMsr.h b/UefiCpuPkg/Include/Register/ArchitecturalMsr.h deleted file mode 100644 index 4f9c1033f3..0000000000 --- a/UefiCpuPkg/Include/Register/ArchitecturalMsr.h +++ /dev/null @@ -1,6441 +0,0 @@ -/** @file - Architectural MSR Definitions. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.1. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Appendix A VMX Capability Reporting Facility, Section A.1. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Appendix A VMX Capability Reporting Facility, Section A.6. - -**/ - -#ifndef __ARCHITECTURAL_MSR_H__ -#define __ARCHITECTURAL_MSR_H__ - -/** - See Section 35.22, "MSRs in Pentium Processors.". Pentium Processor (05_01H). - - @param ECX MSR_IA32_P5_MC_ADDR (0x00000000) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_P5_MC_ADDR); - AsmWriteMsr64 (MSR_IA32_P5_MC_ADDR, Msr); - @endcode - @note MSR_IA32_P5_MC_ADDR is defined as IA32_P5_MC_ADDR in SDM. -**/ -#define MSR_IA32_P5_MC_ADDR 0x00000000 - - -/** - See Section 35.22, "MSRs in Pentium Processors.". DF_DM = 05_01H. - - @param ECX MSR_IA32_P5_MC_TYPE (0x00000001) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_P5_MC_TYPE); - AsmWriteMsr64 (MSR_IA32_P5_MC_TYPE, Msr); - @endcode - @note MSR_IA32_P5_MC_TYPE is defined as IA32_P5_MC_TYPE in SDM. -**/ -#define MSR_IA32_P5_MC_TYPE 0x00000001 - - -/** - See Section 8.10.5, "Monitor/Mwait Address Range Determination.". Introduced - at Display Family / Display Model 0F_03H. - - @param ECX MSR_IA32_MONITOR_FILTER_SIZE (0x00000006) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MONITOR_FILTER_SIZE); - AsmWriteMsr64 (MSR_IA32_MONITOR_FILTER_SIZE, Msr); - @endcode - @note MSR_IA32_MONITOR_FILTER_SIZE is defined as IA32_MONITOR_FILTER_SIZE in SDM. -**/ -#define MSR_IA32_MONITOR_FILTER_SIZE 0x00000006 - - -/** - See Section 17.15, "Time-Stamp Counter.". Introduced at Display Family / - Display Model 05_01H. - - @param ECX MSR_IA32_TIME_STAMP_COUNTER (0x00000010) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_TIME_STAMP_COUNTER); - AsmWriteMsr64 (MSR_IA32_TIME_STAMP_COUNTER, Msr); - @endcode - @note MSR_IA32_TIME_STAMP_COUNTER is defined as IA32_TIME_STAMP_COUNTER in SDM. -**/ -#define MSR_IA32_TIME_STAMP_COUNTER 0x00000010 - - -/** - Platform ID (RO) The operating system can use this MSR to determine "slot" - information for the processor and the proper microcode update to load. - Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_IA32_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); - @endcode - @note MSR_IA32_PLATFORM_ID is defined as IA32_PLATFORM_ID in SDM. -**/ -#define MSR_IA32_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_IA32_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:18; - /// - /// [Bits 52:50] Platform Id (RO) Contains information concerning the - /// intended platform for the processor. - /// 52 51 50 - /// -- -- -- - /// 0 0 0 Processor Flag 0. - /// 0 0 1 Processor Flag 1 - /// 0 1 0 Processor Flag 2 - /// 0 1 1 Processor Flag 3 - /// 1 0 0 Processor Flag 4 - /// 1 0 1 Processor Flag 5 - /// 1 1 0 Processor Flag 6 - /// 1 1 1 Processor Flag 7 - /// - UINT32 PlatformId:3; - UINT32 Reserved3:11; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PLATFORM_ID_REGISTER; - - -/** - 06_01H. - - @param ECX MSR_IA32_APIC_BASE (0x0000001B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_APIC_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_APIC_BASE_REGISTER. - - Example usage - @code - MSR_IA32_APIC_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - AsmWriteMsr64 (MSR_IA32_APIC_BASE, Msr.Uint64); - @endcode - @note MSR_IA32_APIC_BASE is defined as IA32_APIC_BASE in SDM. -**/ -#define MSR_IA32_APIC_BASE 0x0000001B - -/** - MSR information returned for MSR index #MSR_IA32_APIC_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bit 8] BSP flag (R/W). - /// - UINT32 BSP:1; - UINT32 Reserved2:1; - /// - /// [Bit 10] Enable x2APIC mode. Introduced at Display Family / Display - /// Model 06_1AH. - /// - UINT32 EXTD:1; - /// - /// [Bit 11] APIC Global Enable (R/W). - /// - UINT32 EN:1; - /// - /// [Bits 31:12] APIC Base (R/W). - /// - UINT32 ApicBase:20; - /// - /// [Bits 63:32] APIC Base (R/W). - /// - UINT32 ApicBaseHi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_APIC_BASE_REGISTER; - - -/** - Control Features in Intel 64 Processor (R/W). If any one enumeration - condition for defined bit field holds. - - @param ECX MSR_IA32_FEATURE_CONTROL (0x0000003A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_IA32_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_IA32_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. -**/ -#define MSR_IA32_FEATURE_CONTROL 0x0000003A - -/** - MSR information returned for MSR index #MSR_IA32_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock bit (R/WO): (1 = locked). When set, locks this MSR from - /// being written, writes to this bit will result in GP(0). Note: Once the - /// Lock bit is set, the contents of this register cannot be modified. - /// Therefore the lock bit must be set after configuring support for Intel - /// Virtualization Technology and prior to transferring control to an - /// option ROM or the OS. Hence, once the Lock bit is set, the entire - /// IA32_FEATURE_CONTROL contents are preserved across RESET when PWRGOOD - /// is not deasserted. If any one enumeration condition for defined bit - /// field position greater than bit 0 holds. - /// - UINT32 Lock:1; - /// - /// [Bit 1] Enable VMX inside SMX operation (R/WL): This bit enables a - /// system executive to use VMX in conjunction with SMX to support - /// Intel(R) Trusted Execution Technology. BIOS must set this bit only - /// when the CPUID function 1 returns VMX feature flag and SMX feature - /// flag set (ECX bits 5 and 6 respectively). If CPUID.01H:ECX[5] = 1 && - /// CPUID.01H:ECX[6] = 1. - /// - UINT32 EnableVmxInsideSmx:1; - /// - /// [Bit 2] Enable VMX outside SMX operation (R/WL): This bit enables VMX - /// for system executive that do not require SMX. BIOS must set this bit - /// only when the CPUID function 1 returns VMX feature flag set (ECX bit - /// 5). If CPUID.01H:ECX[5] = 1. - /// - UINT32 EnableVmxOutsideSmx:1; - UINT32 Reserved1:5; - /// - /// [Bits 14:8] SENTER Local Function Enables (R/WL): When set, each bit - /// in the field represents an enable control for a corresponding SENTER - /// function. This bit is supported only if CPUID.1:ECX.[bit 6] is set. If - /// CPUID.01H:ECX[6] = 1. - /// - UINT32 SenterLocalFunctionEnables:7; - /// - /// [Bit 15] SENTER Global Enable (R/WL): This bit must be set to enable - /// SENTER leaf functions. This bit is supported only if CPUID.1:ECX.[bit - /// 6] is set. If CPUID.01H:ECX[6] = 1. - /// - UINT32 SenterGlobalEnable:1; - UINT32 Reserved2:1; - /// - /// [Bit 17] SGX Launch Control Enable (R/WL): This bit must be set to - /// enable runtime reconfiguration of SGX Launch Control via - /// IA32_SGXLEPUBKEYHASHn MSR. If CPUID.(EAX=07H, ECX=0H): ECX[30] = 1. - /// - UINT32 SgxLaunchControlEnable:1; - /// - /// [Bit 18] SGX Global Enable (R/WL): This bit must be set to enable SGX - /// leaf functions. If CPUID.(EAX=07H, ECX=0H): EBX[2] = 1. - /// - UINT32 SgxEnable:1; - UINT32 Reserved3:1; - /// - /// [Bit 20] LMCE On (R/WL): When set, system software can program the - /// MSRs associated with LMCE to configure delivery of some machine check - /// exceptions to a single logical processor. If IA32_MCG_CAP[27] = 1. - /// - UINT32 LmceOn:1; - UINT32 Reserved4:11; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_FEATURE_CONTROL_REGISTER; - - -/** - Per Logical Processor TSC Adjust (R/Write to clear). If CPUID.(EAX=07H, - ECX=0H): EBX[1] = 1. THREAD_ADJUST: Local offset value of the IA32_TSC for - a logical processor. Reset value is Zero. A write to IA32_TSC will modify - the local offset in IA32_TSC_ADJUST and the content of IA32_TSC, but does - not affect the internal invariant TSC hardware. - - @param ECX MSR_IA32_TSC_ADJUST (0x0000003B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_TSC_ADJUST); - AsmWriteMsr64 (MSR_IA32_TSC_ADJUST, Msr); - @endcode - @note MSR_IA32_TSC_ADJUST is defined as IA32_TSC_ADJUST in SDM. -**/ -#define MSR_IA32_TSC_ADJUST 0x0000003B - - -/** - BIOS Update Trigger (W) Executing a WRMSR instruction to this MSR causes a - microcode update to be loaded into the processor. See Section 9.11.6, - "Microcode Update Loader." A processor may prevent writing to this MSR when - loading guest states on VM entries or saving guest states on VM exits. - Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_BIOS_UPDT_TRIG (0x00000079) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = 0; - AsmWriteMsr64 (MSR_IA32_BIOS_UPDT_TRIG, Msr); - @endcode - @note MSR_IA32_BIOS_UPDT_TRIG is defined as IA32_BIOS_UPDT_TRIG in SDM. -**/ -#define MSR_IA32_BIOS_UPDT_TRIG 0x00000079 - - -/** - BIOS Update Signature (RO) Returns the microcode update signature following - the execution of CPUID.01H. A processor may prevent writing to this MSR when - loading guest states on VM entries or saving guest states on VM exits. - Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_BIOS_SIGN_ID (0x0000008B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_BIOS_SIGN_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_BIOS_SIGN_ID_REGISTER. - - Example usage - @code - MSR_IA32_BIOS_SIGN_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_BIOS_SIGN_ID); - @endcode - @note MSR_IA32_BIOS_SIGN_ID is defined as IA32_BIOS_SIGN_ID in SDM. -**/ -#define MSR_IA32_BIOS_SIGN_ID 0x0000008B - -/** - MSR information returned for MSR index #MSR_IA32_BIOS_SIGN_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:32; - /// - /// [Bits 63:32] Microcode update signature. This field contains the - /// signature of the currently loaded microcode update when read following - /// the execution of the CPUID instruction, function 1. It is required - /// that this register field be pre-loaded with zero prior to executing - /// the CPUID, function 1. If the field remains equal to zero, then there - /// is no microcode update loaded. Another nonzero value will be the - /// signature. - /// - UINT32 MicrocodeUpdateSignature:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_BIOS_SIGN_ID_REGISTER; - - -/** - IA32_SGXLEPUBKEYHASH[(64*n+63):(64*n)] (R/W) Bits (64*n+63):(64*n) of the - SHA256 digest of the SIGSTRUCT.MODULUS for SGX Launch Enclave. On reset, the - default value is the digest of Intel's signing key. Read permitted If - CPUID.(EAX=12H,ECX=0H):EAX[0]=1, Write permitted if CPUID.(EAX=12H,ECX=0H): - EAX[0]=1 && IA32_FEATURE_CONTROL[17] = 1 && IA32_FEATURE_CONTROL[0] = 1. - - @param ECX MSR_IA32_SGXLEPUBKEYHASHn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_SGXLEPUBKEYHASHn); - AsmWriteMsr64 (MSR_IA32_SGXLEPUBKEYHASHn, Msr); - @endcode - @note MSR_IA32_SGXLEPUBKEYHASH0 is defined as IA32_SGXLEPUBKEYHASH0 in SDM. - MSR_IA32_SGXLEPUBKEYHASH1 is defined as IA32_SGXLEPUBKEYHASH1 in SDM. - MSR_IA32_SGXLEPUBKEYHASH2 is defined as IA32_SGXLEPUBKEYHASH2 in SDM. - MSR_IA32_SGXLEPUBKEYHASH3 is defined as IA32_SGXLEPUBKEYHASH3 in SDM. - @{ -**/ -#define MSR_IA32_SGXLEPUBKEYHASH0 0x0000008C -#define MSR_IA32_SGXLEPUBKEYHASH1 0x0000008D -#define MSR_IA32_SGXLEPUBKEYHASH2 0x0000008E -#define MSR_IA32_SGXLEPUBKEYHASH3 0x0000008F -/// @} - - -/** - SMM Monitor Configuration (R/W). If CPUID.01H: ECX[5]=1 or CPUID.01H: ECX[6] = - 1. - - @param ECX MSR_IA32_SMM_MONITOR_CTL (0x0000009B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_SMM_MONITOR_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_SMM_MONITOR_CTL_REGISTER. - - Example usage - @code - MSR_IA32_SMM_MONITOR_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); - AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, Msr.Uint64); - @endcode - @note MSR_IA32_SMM_MONITOR_CTL is defined as IA32_SMM_MONITOR_CTL in SDM. -**/ -#define MSR_IA32_SMM_MONITOR_CTL 0x0000009B - -/** - MSR information returned for MSR index #MSR_IA32_SMM_MONITOR_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Valid (R/W). The STM may be invoked using VMCALL only if this - /// bit is 1. Because VMCALL is used to activate the dual-monitor treatment - /// (see Section 34.15.6), the dual-monitor treatment cannot be activated - /// if the bit is 0. This bit is cleared when the logical processor is - /// reset. - /// - UINT32 Valid:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Determines whether executions of VMXOFF unblock SMIs under the - /// default treatment of SMIs and SMM. Executions of VMXOFF unblock SMIs - /// unless bit 2 is 1 (the value of bit 0 is irrelevant). - /// - UINT32 BlockSmi:1; - UINT32 Reserved2:9; - /// - /// [Bits 31:12] MSEG Base (R/W). - /// - UINT32 MsegBase:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_SMM_MONITOR_CTL_REGISTER; - -/** - MSEG header that is located at the physical address specified by the MsegBase - field of #MSR_IA32_SMM_MONITOR_CTL_REGISTER. -**/ -typedef struct { - /// - /// Different processors may use different MSEG revision identifiers. These - /// identifiers enable software to avoid using an MSEG header formatted for - /// one processor on a processor that uses a different format. Software can - /// discover the MSEG revision identifier that a processor uses by reading - /// the VMX capability MSR IA32_VMX_MISC. - // - UINT32 MsegHeaderRevision; - /// - /// Bits 31:1 of this field are reserved and must be zero. Bit 0 of the field - /// is the IA-32e mode SMM feature bit. It indicates whether the logical - /// processor will be in IA-32e mode after the STM is activated. - /// - UINT32 MonitorFeatures; - UINT32 GdtrLimit; - UINT32 GdtrBaseOffset; - UINT32 CsSelector; - UINT32 EipOffset; - UINT32 EspOffset; - UINT32 Cr3Offset; - /// - /// Pad header so total size is 2KB - /// - UINT8 Reserved[SIZE_2KB - 8 * sizeof (UINT32)]; -} MSEG_HEADER; - -/// -/// @{ Define values for the MonitorFeatures field of #MSEG_HEADER -/// -#define STM_FEATURES_IA32E 0x1 -/// -/// @} -/// - -/** - Base address of the logical processor's SMRAM image (RO, SMM only). If - IA32_VMX_MISC[15]. - - @param ECX MSR_IA32_SMBASE (0x0000009E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_SMBASE); - @endcode - @note MSR_IA32_SMBASE is defined as IA32_SMBASE in SDM. -**/ -#define MSR_IA32_SMBASE 0x0000009E - - -/** - General Performance Counters (R/W). - MSR_IA32_PMCn is supported if CPUID.0AH: EAX[15:8] > n. - - @param ECX MSR_IA32_PMCn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_PMC0); - AsmWriteMsr64 (MSR_IA32_PMC0, Msr); - @endcode - @note MSR_IA32_PMC0 is defined as IA32_PMC0 in SDM. - MSR_IA32_PMC1 is defined as IA32_PMC1 in SDM. - MSR_IA32_PMC2 is defined as IA32_PMC2 in SDM. - MSR_IA32_PMC3 is defined as IA32_PMC3 in SDM. - MSR_IA32_PMC4 is defined as IA32_PMC4 in SDM. - MSR_IA32_PMC5 is defined as IA32_PMC5 in SDM. - MSR_IA32_PMC6 is defined as IA32_PMC6 in SDM. - MSR_IA32_PMC7 is defined as IA32_PMC7 in SDM. - @{ -**/ -#define MSR_IA32_PMC0 0x000000C1 -#define MSR_IA32_PMC1 0x000000C2 -#define MSR_IA32_PMC2 0x000000C3 -#define MSR_IA32_PMC3 0x000000C4 -#define MSR_IA32_PMC4 0x000000C5 -#define MSR_IA32_PMC5 0x000000C6 -#define MSR_IA32_PMC6 0x000000C7 -#define MSR_IA32_PMC7 0x000000C8 -/// @} - - -/** - TSC Frequency Clock Counter (R/Write to clear). If CPUID.06H: ECX[0] = 1. - C0_MCNT: C0 TSC Frequency Clock Count Increments at fixed interval (relative - to TSC freq.) when the logical processor is in C0. Cleared upon overflow / - wrap-around of IA32_APERF. - - @param ECX MSR_IA32_MPERF (0x000000E7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MPERF); - AsmWriteMsr64 (MSR_IA32_MPERF, Msr); - @endcode - @note MSR_IA32_MPERF is defined as IA32_MPERF in SDM. -**/ -#define MSR_IA32_MPERF 0x000000E7 - - -/** - Actual Performance Clock Counter (R/Write to clear). If CPUID.06H: ECX[0] = - 1. C0_ACNT: C0 Actual Frequency Clock Count Accumulates core clock counts at - the coordinated clock frequency, when the logical processor is in C0. - Cleared upon overflow / wrap-around of IA32_MPERF. - - @param ECX MSR_IA32_APERF (0x000000E8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_APERF); - AsmWriteMsr64 (MSR_IA32_APERF, Msr); - @endcode - @note MSR_IA32_APERF is defined as IA32_APERF in SDM. -**/ -#define MSR_IA32_APERF 0x000000E8 - - -/** - MTRR Capability (RO) Section 11.11.2.1, "IA32_MTRR_DEF_TYPE MSR.". - Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_MTRRCAP (0x000000FE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MTRRCAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MTRRCAP_REGISTER. - - Example usage - @code - MSR_IA32_MTRRCAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); - @endcode - @note MSR_IA32_MTRRCAP is defined as IA32_MTRRCAP in SDM. -**/ -#define MSR_IA32_MTRRCAP 0x000000FE - -/** - MSR information returned for MSR index #MSR_IA32_MTRRCAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] VCNT: The number of variable memory type ranges in the - /// processor. - /// - UINT32 VCNT:8; - /// - /// [Bit 8] Fixed range MTRRs are supported when set. - /// - UINT32 FIX:1; - UINT32 Reserved1:1; - /// - /// [Bit 10] WC Supported when set. - /// - UINT32 WC:1; - /// - /// [Bit 11] SMRR Supported when set. - /// - UINT32 SMRR:1; - UINT32 Reserved2:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MTRRCAP_REGISTER; - - -/** - SYSENTER_CS_MSR (R/W). Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_SYSENTER_CS (0x00000174) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_SYSENTER_CS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_SYSENTER_CS_REGISTER. - - Example usage - @code - MSR_IA32_SYSENTER_CS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SYSENTER_CS); - AsmWriteMsr64 (MSR_IA32_SYSENTER_CS, Msr.Uint64); - @endcode - @note MSR_IA32_SYSENTER_CS is defined as IA32_SYSENTER_CS in SDM. -**/ -#define MSR_IA32_SYSENTER_CS 0x00000174 - -/** - MSR information returned for MSR index #MSR_IA32_SYSENTER_CS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] CS Selector. - /// - UINT32 CS:16; - UINT32 Reserved1:16; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_SYSENTER_CS_REGISTER; - - -/** - SYSENTER_ESP_MSR (R/W). Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_SYSENTER_ESP (0x00000175) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_SYSENTER_ESP); - AsmWriteMsr64 (MSR_IA32_SYSENTER_ESP, Msr); - @endcode - @note MSR_IA32_SYSENTER_ESP is defined as IA32_SYSENTER_ESP in SDM. -**/ -#define MSR_IA32_SYSENTER_ESP 0x00000175 - - -/** - SYSENTER_EIP_MSR (R/W). Introduced at Display Family / Display Model 06_01H. - - @param ECX MSR_IA32_SYSENTER_EIP (0x00000176) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_SYSENTER_EIP); - AsmWriteMsr64 (MSR_IA32_SYSENTER_EIP, Msr); - @endcode - @note MSR_IA32_SYSENTER_EIP is defined as IA32_SYSENTER_EIP in SDM. -**/ -#define MSR_IA32_SYSENTER_EIP 0x00000176 - - -/** - Global Machine Check Capability (RO). Introduced at Display Family / Display - Model 06_01H. - - @param ECX MSR_IA32_MCG_CAP (0x00000179) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MCG_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MCG_CAP_REGISTER. - - Example usage - @code - MSR_IA32_MCG_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); - @endcode - @note MSR_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. -**/ -#define MSR_IA32_MCG_CAP 0x00000179 - -/** - MSR information returned for MSR index #MSR_IA32_MCG_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Count: Number of reporting banks. - /// - UINT32 Count:8; - /// - /// [Bit 8] MCG_CTL_P: IA32_MCG_CTL is present if this bit is set. - /// - UINT32 MCG_CTL_P:1; - /// - /// [Bit 9] MCG_EXT_P: Extended machine check state registers are present - /// if this bit is set. - /// - UINT32 MCG_EXT_P:1; - /// - /// [Bit 10] MCP_CMCI_P: Support for corrected MC error event is present. - /// Introduced at Display Family / Display Model 06_01H. - /// - UINT32 MCP_CMCI_P:1; - /// - /// [Bit 11] MCG_TES_P: Threshold-based error status register are present - /// if this bit is set. - /// - UINT32 MCG_TES_P:1; - UINT32 Reserved1:4; - /// - /// [Bits 23:16] MCG_EXT_CNT: Number of extended machine check state - /// registers present. - /// - UINT32 MCG_EXT_CNT:8; - /// - /// [Bit 24] MCG_SER_P: The processor supports software error recovery if - /// this bit is set. - /// - UINT32 MCG_SER_P:1; - UINT32 Reserved2:1; - /// - /// [Bit 26] MCG_ELOG_P: Indicates that the processor allows platform - /// firmware to be invoked when an error is detected so that it may - /// provide additional platform specific information in an ACPI format - /// "Generic Error Data Entry" that augments the data included in machine - /// check bank registers. Introduced at Display Family / Display Model - /// 06_3EH. - /// - UINT32 MCG_ELOG_P:1; - /// - /// [Bit 27] MCG_LMCE_P: Indicates that the processor support extended - /// state in IA32_MCG_STATUS and associated MSR necessary to configure - /// Local Machine Check Exception (LMCE). Introduced at Display Family / - /// Display Model 06_3EH. - /// - UINT32 MCG_LMCE_P:1; - UINT32 Reserved3:4; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MCG_CAP_REGISTER; - - -/** - Global Machine Check Status (R/W0). Introduced at Display Family / Display - Model 06_01H. - - @param ECX MSR_IA32_MCG_STATUS (0x0000017A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MCG_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MCG_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_MCG_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_STATUS); - AsmWriteMsr64 (MSR_IA32_MCG_STATUS, Msr.Uint64); - @endcode - @note MSR_IA32_MCG_STATUS is defined as IA32_MCG_STATUS in SDM. -**/ -#define MSR_IA32_MCG_STATUS 0x0000017A - -/** - MSR information returned for MSR index #MSR_IA32_MCG_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] RIPV. Restart IP valid. Introduced at Display Family / Display - /// Model 06_01H. - /// - UINT32 RIPV:1; - /// - /// [Bit 1] EIPV. Error IP valid. Introduced at Display Family / Display - /// Model 06_01H. - /// - UINT32 EIPV:1; - /// - /// [Bit 2] MCIP. Machine check in progress. Introduced at Display Family - /// / Display Model 06_01H. - /// - UINT32 MCIP:1; - /// - /// [Bit 3] LMCE_S. If IA32_MCG_CAP.LMCE_P[2 7] =1. - /// - UINT32 LMCE_S:1; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MCG_STATUS_REGISTER; - - -/** - Global Machine Check Control (R/W). If IA32_MCG_CAP.CTL_P[8] =1. - - @param ECX MSR_IA32_MCG_CTL (0x0000017B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MCG_CTL); - AsmWriteMsr64 (MSR_IA32_MCG_CTL, Msr); - @endcode - @note MSR_IA32_MCG_CTL is defined as IA32_MCG_CTL in SDM. -**/ -#define MSR_IA32_MCG_CTL 0x0000017B - - -/** - Performance Event Select Register n (R/W). If CPUID.0AH: EAX[15:8] > n. - - @param ECX MSR_IA32_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERFEVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERFEVTSEL_REGISTER. - - Example usage - @code - MSR_IA32_PERFEVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERFEVTSEL0); - AsmWriteMsr64 (MSR_IA32_PERFEVTSEL0, Msr.Uint64); - @endcode - @note MSR_IA32_PERFEVTSEL0 is defined as IA32_PERFEVTSEL0 in SDM. - MSR_IA32_PERFEVTSEL1 is defined as IA32_PERFEVTSEL1 in SDM. - MSR_IA32_PERFEVTSEL2 is defined as IA32_PERFEVTSEL2 in SDM. - MSR_IA32_PERFEVTSEL3 is defined as IA32_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_IA32_PERFEVTSEL0 0x00000186 -#define MSR_IA32_PERFEVTSEL1 0x00000187 -#define MSR_IA32_PERFEVTSEL2 0x00000188 -#define MSR_IA32_PERFEVTSEL3 0x00000189 -/// @} - -/** - MSR information returned for MSR indexes #MSR_IA32_PERFEVTSEL0 to - #MSR_IA32_PERFEVTSEL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Event Select: Selects a performance event logic unit. - /// - UINT32 EventSelect:8; - /// - /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to - /// detect on the selected event logic. - /// - UINT32 UMASK:8; - /// - /// [Bit 16] USR: Counts while in privilege level is not ring 0. - /// - UINT32 USR:1; - /// - /// [Bit 17] OS: Counts while in privilege level is ring 0. - /// - UINT32 OS:1; - /// - /// [Bit 18] Edge: Enables edge detection if set. - /// - UINT32 E:1; - /// - /// [Bit 19] PC: enables pin control. - /// - UINT32 PC:1; - /// - /// [Bit 20] INT: enables interrupt on counter overflow. - /// - UINT32 INT:1; - /// - /// [Bit 21] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. - /// - UINT32 ANY:1; - /// - /// [Bit 22] EN: enables the corresponding performance counter to commence - /// counting when this bit is set. - /// - UINT32 EN:1; - /// - /// [Bit 23] INV: invert the CMASK. - /// - UINT32 INV:1; - /// - /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding - /// performance counter increments each cycle if the event count is - /// greater than or equal to the CMASK. - /// - UINT32 CMASK:8; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERFEVTSEL_REGISTER; - - -/** - Current performance state(P-State) operating point (RO). Introduced at - Display Family / Display Model 0F_03H. - - @param ECX MSR_IA32_PERF_STATUS (0x00000198) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_PERF_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_STATUS); - @endcode - @note MSR_IA32_PERF_STATUS is defined as IA32_PERF_STATUS in SDM. -**/ -#define MSR_IA32_PERF_STATUS 0x00000198 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Current performance State Value. - /// - UINT32 State:16; - UINT32 Reserved1:16; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_STATUS_REGISTER; - - -/** - (R/W). Introduced at Display Family / Display Model 0F_03H. - - @param ECX MSR_IA32_PERF_CTL (0x00000199) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_CTL_REGISTER. - - Example usage - @code - MSR_IA32_PERF_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_CTL); - AsmWriteMsr64 (MSR_IA32_PERF_CTL, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_CTL is defined as IA32_PERF_CTL in SDM. -**/ -#define MSR_IA32_PERF_CTL 0x00000199 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Target performance State Value. - /// - UINT32 TargetState:16; - UINT32 Reserved1:16; - /// - /// [Bit 32] IDA Engage. (R/W) When set to 1: disengages IDA. 06_0FH - /// (Mobile only). - /// - UINT32 IDA:1; - UINT32 Reserved2:31; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_CTL_REGISTER; - - -/** - Clock Modulation Control (R/W) See Section 14.7.3, "Software Controlled - Clock Modulation.". If CPUID.01H:EDX[22] = 1. - - @param ECX MSR_IA32_CLOCK_MODULATION (0x0000019A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_CLOCK_MODULATION_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_CLOCK_MODULATION_REGISTER. - - Example usage - @code - MSR_IA32_CLOCK_MODULATION_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_CLOCK_MODULATION); - AsmWriteMsr64 (MSR_IA32_CLOCK_MODULATION, Msr.Uint64); - @endcode - @note MSR_IA32_CLOCK_MODULATION is defined as IA32_CLOCK_MODULATION in SDM. -**/ -#define MSR_IA32_CLOCK_MODULATION 0x0000019A - -/** - MSR information returned for MSR index #MSR_IA32_CLOCK_MODULATION -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Extended On-Demand Clock Modulation Duty Cycle:. If - /// CPUID.06H:EAX[5] = 1. - /// - UINT32 ExtendedOnDemandClockModulationDutyCycle:1; - /// - /// [Bits 3:1] On-Demand Clock Modulation Duty Cycle: Specific encoded - /// values for target duty cycle modulation. If CPUID.01H:EDX[22] = 1. - /// - UINT32 OnDemandClockModulationDutyCycle:3; - /// - /// [Bit 4] On-Demand Clock Modulation Enable: Set 1 to enable modulation. - /// If CPUID.01H:EDX[22] = 1. - /// - UINT32 OnDemandClockModulationEnable:1; - UINT32 Reserved1:27; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_CLOCK_MODULATION_REGISTER; - - -/** - Thermal Interrupt Control (R/W) Enables and disables the generation of an - interrupt on temperature transitions detected with the processor's thermal - sensors and thermal monitor. See Section 14.7.2, "Thermal Monitor.". - If CPUID.01H:EDX[22] = 1 - - @param ECX MSR_IA32_THERM_INTERRUPT (0x0000019B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_THERM_INTERRUPT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_THERM_INTERRUPT_REGISTER. - - Example usage - @code - MSR_IA32_THERM_INTERRUPT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_THERM_INTERRUPT); - AsmWriteMsr64 (MSR_IA32_THERM_INTERRUPT, Msr.Uint64); - @endcode - @note MSR_IA32_THERM_INTERRUPT is defined as IA32_THERM_INTERRUPT in SDM. -**/ -#define MSR_IA32_THERM_INTERRUPT 0x0000019B - -/** - MSR information returned for MSR index #MSR_IA32_THERM_INTERRUPT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] High-Temperature Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 HighTempEnable:1; - /// - /// [Bit 1] Low-Temperature Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 LowTempEnable:1; - /// - /// [Bit 2] PROCHOT# Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 PROCHOT_Enable:1; - /// - /// [Bit 3] FORCEPR# Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 FORCEPR_Enable:1; - /// - /// [Bit 4] Critical Temperature Interrupt Enable. - /// If CPUID.01H:EDX[22] = 1. - /// - UINT32 CriticalTempEnable:1; - UINT32 Reserved1:3; - /// - /// [Bits 14:8] Threshold #1 Value. If CPUID.01H:EDX[22] = 1. - /// - UINT32 Threshold1:7; - /// - /// [Bit 15] Threshold #1 Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 Threshold1Enable:1; - /// - /// [Bits 22:16] Threshold #2 Value. If CPUID.01H:EDX[22] = 1. - /// - UINT32 Threshold2:7; - /// - /// [Bit 23] Threshold #2 Interrupt Enable. If CPUID.01H:EDX[22] = 1. - /// - UINT32 Threshold2Enable:1; - /// - /// [Bit 24] Power Limit Notification Enable. If CPUID.06H:EAX[4] = 1. - /// - UINT32 PowerLimitNotificationEnable:1; - UINT32 Reserved2:7; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_THERM_INTERRUPT_REGISTER; - - -/** - Thermal Status Information (RO) Contains status information about the - processor's thermal sensor and automatic thermal monitoring facilities. See - Section 14.7.2, "Thermal Monitor". If CPUID.01H:EDX[22] = 1. - - @param ECX MSR_IA32_THERM_STATUS (0x0000019C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_THERM_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_THERM_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_THERM_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_THERM_STATUS); - @endcode - @note MSR_IA32_THERM_STATUS is defined as IA32_THERM_STATUS in SDM. -**/ -#define MSR_IA32_THERM_STATUS 0x0000019C - -/** - MSR information returned for MSR index #MSR_IA32_THERM_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thermal Status (RO):. If CPUID.01H:EDX[22] = 1. - /// - UINT32 ThermalStatus:1; - /// - /// [Bit 1] Thermal Status Log (R/W):. If CPUID.01H:EDX[22] = 1. - /// - UINT32 ThermalStatusLog:1; - /// - /// [Bit 2] PROCHOT # or FORCEPR# event (RO). If CPUID.01H:EDX[22] = 1. - /// - UINT32 PROCHOT_FORCEPR_Event:1; - /// - /// [Bit 3] PROCHOT # or FORCEPR# log (R/WC0). If CPUID.01H:EDX[22] = 1. - /// - UINT32 PROCHOT_FORCEPR_Log:1; - /// - /// [Bit 4] Critical Temperature Status (RO). If CPUID.01H:EDX[22] = 1. - /// - UINT32 CriticalTempStatus:1; - /// - /// [Bit 5] Critical Temperature Status log (R/WC0). - /// If CPUID.01H:EDX[22] = 1. - /// - UINT32 CriticalTempStatusLog:1; - /// - /// [Bit 6] Thermal Threshold #1 Status (RO). If CPUID.01H:ECX[8] = 1. - /// - UINT32 ThermalThreshold1Status:1; - /// - /// [Bit 7] Thermal Threshold #1 log (R/WC0). If CPUID.01H:ECX[8] = 1. - /// - UINT32 ThermalThreshold1Log:1; - /// - /// [Bit 8] Thermal Threshold #2 Status (RO). If CPUID.01H:ECX[8] = 1. - /// - UINT32 ThermalThreshold2Status:1; - /// - /// [Bit 9] Thermal Threshold #2 log (R/WC0). If CPUID.01H:ECX[8] = 1. - /// - UINT32 ThermalThreshold2Log:1; - /// - /// [Bit 10] Power Limitation Status (RO). If CPUID.06H:EAX[4] = 1. - /// - UINT32 PowerLimitStatus:1; - /// - /// [Bit 11] Power Limitation log (R/WC0). If CPUID.06H:EAX[4] = 1. - /// - UINT32 PowerLimitLog:1; - /// - /// [Bit 12] Current Limit Status (RO). If CPUID.06H:EAX[7] = 1. - /// - UINT32 CurrentLimitStatus:1; - /// - /// [Bit 13] Current Limit log (R/WC0). If CPUID.06H:EAX[7] = 1. - /// - UINT32 CurrentLimitLog:1; - /// - /// [Bit 14] Cross Domain Limit Status (RO). If CPUID.06H:EAX[7] = 1. - /// - UINT32 CrossDomainLimitStatus:1; - /// - /// [Bit 15] Cross Domain Limit log (R/WC0). If CPUID.06H:EAX[7] = 1. - /// - UINT32 CrossDomainLimitLog:1; - /// - /// [Bits 22:16] Digital Readout (RO). If CPUID.06H:EAX[0] = 1. - /// - UINT32 DigitalReadout:7; - UINT32 Reserved1:4; - /// - /// [Bits 30:27] Resolution in Degrees Celsius (RO). If CPUID.06H:EAX[0] = - /// 1. - /// - UINT32 ResolutionInDegreesCelsius:4; - /// - /// [Bit 31] Reading Valid (RO). If CPUID.06H:EAX[0] = 1. - /// - UINT32 ReadingValid:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_THERM_STATUS_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fast-Strings Enable When set, the fast-strings feature (for - /// REP MOVS and REP STORS) is enabled (default); when clear, fast-strings - /// are disabled. Introduced at Display Family / Display Model 0F_0H. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) 1 = Setting - /// this bit enables the thermal control circuit (TCC) portion of the - /// Intel Thermal Monitor feature. This allows the processor to - /// automatically reduce power consumption in response to TCC activation. - /// 0 = Disabled. Note: In some products clearing this bit might be - /// ignored in critical thermal conditions, and TM1, TM2 and adaptive - /// thermal throttling will still be activated. The default value of this - /// field varies with product. See respective tables where default value is - /// listed. Introduced at Display Family / Display Model 0F_0H. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Performance Monitoring Available (R) 1 = Performance - /// monitoring enabled 0 = Performance monitoring disabled. Introduced at - /// Display Family / Display Model 0F_0H. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:3; - /// - /// [Bit 11] Branch Trace Storage Unavailable (RO) 1 = Processor doesn't - /// support branch trace storage (BTS) 0 = BTS is supported. Introduced at - /// Display Family / Display Model 0F_0H. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Processor Event Based Sampling (PEBS) Unavailable (RO) 1 = - /// PEBS is not supported; 0 = PEBS is supported. Introduced at Display - /// Family / Display Model 06_0FH. - /// - UINT32 PEBS:1; - UINT32 Reserved4:3; - /// - /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W) 0= Enhanced - /// Intel SpeedStep Technology disabled 1 = Enhanced Intel SpeedStep - /// Technology enabled. If CPUID.01H: ECX[7] =1. - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] ENABLE MONITOR FSM (R/W) When this bit is set to 0, the - /// MONITOR feature flag is not set (CPUID.01H:ECX[bit 3] = 0). This - /// indicates that MONITOR/MWAIT are not supported. Software attempts to - /// execute MONITOR/MWAIT will cause #UD when this bit is 0. When this bit - /// is set to 1 (default), MONITOR/MWAIT are supported (CPUID.01H:ECX[bit - /// 3] = 1). If the SSE3 feature flag ECX[0] is not set (CPUID.01H:ECX[bit - /// 0] = 0), the OS must not attempt to alter this bit. BIOS must leave it - /// in the default state. Writing this bit when the SSE3 feature flag is - /// set to 0 may generate a #GP exception. Introduced at Display Family / - /// Display Model 0F_03H. - /// - UINT32 MONITOR:1; - UINT32 Reserved6:3; - /// - /// [Bit 22] Limit CPUID Maxval (R/W) When this bit is set to 1, CPUID.00H - /// returns a maximum value in EAX[7:0] of 2. BIOS should contain a setup - /// question that allows users to specify when the installed OS does not - /// support CPUID functions greater than 2. Before setting this bit, BIOS - /// must execute the CPUID.0H and examine the maximum value returned in - /// EAX[7:0]. If the maximum value is greater than 2, this bit is - /// supported. Otherwise, this bit is not supported. Setting this bit when - /// the maximum value is not greater than 2 may generate a #GP exception. - /// Setting this bit may cause unexpected behavior in software that - /// depends on the availability of CPUID leaves greater than 2. Introduced - /// at Display Family / Display Model 0F_03H. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] xTPR Message Disable (R/W) When set to 1, xTPR messages are - /// disabled. xTPR messages are optional messages that allow the processor - /// to inform the chipset of its priority. if CPUID.01H:ECX[14] = 1. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] XD Bit Disable (R/W) When set to 1, the Execute Disable Bit - /// feature (XD Bit) is disabled and the XD Bit extended feature flag will - /// be clear (CPUID.80000001H: EDX[20]=0). When set to a 0 (default), the - /// Execute Disable Bit feature (if available) allows the OS to enable PAE - /// paging and take advantage of data only pages. BIOS must not alter the - /// contents of this bit location, if XD bit is not supported. Writing - /// this bit to 1 when the XD Bit extended feature flag is set to 0 may - /// generate a #GP exception. if CPUID.80000001H:EDX[2 0] = 1. - /// - UINT32 XD:1; - UINT32 Reserved9:29; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MISC_ENABLE_REGISTER; - - -/** - Performance Energy Bias Hint (R/W). if CPUID.6H:ECX[3] = 1. - - @param ECX MSR_IA32_ENERGY_PERF_BIAS (0x000001B0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_ENERGY_PERF_BIAS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_ENERGY_PERF_BIAS_REGISTER. - - Example usage - @code - MSR_IA32_ENERGY_PERF_BIAS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_ENERGY_PERF_BIAS); - AsmWriteMsr64 (MSR_IA32_ENERGY_PERF_BIAS, Msr.Uint64); - @endcode - @note MSR_IA32_ENERGY_PERF_BIAS is defined as IA32_ENERGY_PERF_BIAS in SDM. -**/ -#define MSR_IA32_ENERGY_PERF_BIAS 0x000001B0 - -/** - MSR information returned for MSR index #MSR_IA32_ENERGY_PERF_BIAS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Power Policy Preference: 0 indicates preference to highest - /// performance. 15 indicates preference to maximize energy saving. - /// - UINT32 PowerPolicyPreference:4; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_ENERGY_PERF_BIAS_REGISTER; - - -/** - Package Thermal Status Information (RO) Contains status information about - the package's thermal sensor. See Section 14.8, "Package Level Thermal - Management.". If CPUID.06H: EAX[6] = 1. - - @param ECX MSR_IA32_PACKAGE_THERM_STATUS (0x000001B1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PACKAGE_THERM_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PACKAGE_THERM_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_PACKAGE_THERM_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PACKAGE_THERM_STATUS); - @endcode - @note MSR_IA32_PACKAGE_THERM_STATUS is defined as IA32_PACKAGE_THERM_STATUS in SDM. -**/ -#define MSR_IA32_PACKAGE_THERM_STATUS 0x000001B1 - -/** - MSR information returned for MSR index #MSR_IA32_PACKAGE_THERM_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Pkg Thermal Status (RO):. - /// - UINT32 ThermalStatus:1; - /// - /// [Bit 1] Pkg Thermal Status Log (R/W):. - /// - UINT32 ThermalStatusLog:1; - /// - /// [Bit 2] Pkg PROCHOT # event (RO). - /// - UINT32 PROCHOT_Event:1; - /// - /// [Bit 3] Pkg PROCHOT # log (R/WC0). - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 4] Pkg Critical Temperature Status (RO). - /// - UINT32 CriticalTempStatus:1; - /// - /// [Bit 5] Pkg Critical Temperature Status log (R/WC0). - /// - UINT32 CriticalTempStatusLog:1; - /// - /// [Bit 6] Pkg Thermal Threshold #1 Status (RO). - /// - UINT32 ThermalThreshold1Status:1; - /// - /// [Bit 7] Pkg Thermal Threshold #1 log (R/WC0). - /// - UINT32 ThermalThreshold1Log:1; - /// - /// [Bit 8] Pkg Thermal Threshold #2 Status (RO). - /// - UINT32 ThermalThreshold2Status:1; - /// - /// [Bit 9] Pkg Thermal Threshold #1 log (R/WC0). - /// - UINT32 ThermalThreshold2Log:1; - /// - /// [Bit 10] Pkg Power Limitation Status (RO). - /// - UINT32 PowerLimitStatus:1; - /// - /// [Bit 11] Pkg Power Limitation log (R/WC0). - /// - UINT32 PowerLimitLog:1; - UINT32 Reserved1:4; - /// - /// [Bits 22:16] Pkg Digital Readout (RO). - /// - UINT32 DigitalReadout:7; - UINT32 Reserved2:9; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PACKAGE_THERM_STATUS_REGISTER; - - -/** - Pkg Thermal Interrupt Control (R/W) Enables and disables the generation of - an interrupt on temperature transitions detected with the package's thermal - sensor. See Section 14.8, "Package Level Thermal Management.". If CPUID.06H: - EAX[6] = 1. - - @param ECX MSR_IA32_PACKAGE_THERM_INTERRUPT (0x000001B2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER. - - Example usage - @code - MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PACKAGE_THERM_INTERRUPT); - AsmWriteMsr64 (MSR_IA32_PACKAGE_THERM_INTERRUPT, Msr.Uint64); - @endcode - @note MSR_IA32_PACKAGE_THERM_INTERRUPT is defined as IA32_PACKAGE_THERM_INTERRUPT in SDM. -**/ -#define MSR_IA32_PACKAGE_THERM_INTERRUPT 0x000001B2 - -/** - MSR information returned for MSR index #MSR_IA32_PACKAGE_THERM_INTERRUPT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Pkg High-Temperature Interrupt Enable. - /// - UINT32 HighTempEnable:1; - /// - /// [Bit 1] Pkg Low-Temperature Interrupt Enable. - /// - UINT32 LowTempEnable:1; - /// - /// [Bit 2] Pkg PROCHOT# Interrupt Enable. - /// - UINT32 PROCHOT_Enable:1; - UINT32 Reserved1:1; - /// - /// [Bit 4] Pkg Overheat Interrupt Enable. - /// - UINT32 OverheatEnable:1; - UINT32 Reserved2:3; - /// - /// [Bits 14:8] Pkg Threshold #1 Value. - /// - UINT32 Threshold1:7; - /// - /// [Bit 15] Pkg Threshold #1 Interrupt Enable. - /// - UINT32 Threshold1Enable:1; - /// - /// [Bits 22:16] Pkg Threshold #2 Value. - /// - UINT32 Threshold2:7; - /// - /// [Bit 23] Pkg Threshold #2 Interrupt Enable. - /// - UINT32 Threshold2Enable:1; - /// - /// [Bit 24] Pkg Power Limit Notification Enable. - /// - UINT32 PowerLimitNotificationEnable:1; - UINT32 Reserved3:7; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PACKAGE_THERM_INTERRUPT_REGISTER; - - -/** - Trace/Profile Resource Control (R/W). Introduced at Display Family / Display - Model 06_0EH. - - @param ECX MSR_IA32_DEBUGCTL (0x000001D9) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_DEBUGCTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_DEBUGCTL_REGISTER. - - Example usage - @code - MSR_IA32_DEBUGCTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DEBUGCTL); - AsmWriteMsr64 (MSR_IA32_DEBUGCTL, Msr.Uint64); - @endcode - @note MSR_IA32_DEBUGCTL is defined as IA32_DEBUGCTL in SDM. -**/ -#define MSR_IA32_DEBUGCTL 0x000001D9 - -/** - MSR information returned for MSR index #MSR_IA32_DEBUGCTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] LBR: Setting this bit to 1 enables the processor to record a - /// running trace of the most recent branches taken by the processor in - /// the LBR stack. Introduced at Display Family / Display Model 06_01H. - /// - UINT32 LBR:1; - /// - /// [Bit 1] BTF: Setting this bit to 1 enables the processor to treat - /// EFLAGS.TF as single-step on branches instead of single-step on - /// instructions. Introduced at Display Family / Display Model 06_01H. - /// - UINT32 BTF:1; - UINT32 Reserved1:4; - /// - /// [Bit 6] TR: Setting this bit to 1 enables branch trace messages to be - /// sent. Introduced at Display Family / Display Model 06_0EH. - /// - UINT32 TR:1; - /// - /// [Bit 7] BTS: Setting this bit enables branch trace messages (BTMs) to - /// be logged in a BTS buffer. Introduced at Display Family / Display - /// Model 06_0EH. - /// - UINT32 BTS:1; - /// - /// [Bit 8] BTINT: When clear, BTMs are logged in a BTS buffer in circular - /// fashion. When this bit is set, an interrupt is generated by the BTS - /// facility when the BTS buffer is full. Introduced at Display Family / - /// Display Model 06_0EH. - /// - UINT32 BTINT:1; - /// - /// [Bit 9] BTS_OFF_OS: When set, BTS or BTM is skipped if CPL = 0. - /// Introduced at Display Family / Display Model 06_0FH. - /// - UINT32 BTS_OFF_OS:1; - /// - /// [Bit 10] BTS_OFF_USR: When set, BTS or BTM is skipped if CPL > 0. - /// Introduced at Display Family / Display Model 06_0FH. - /// - UINT32 BTS_OFF_USR:1; - /// - /// [Bit 11] FREEZE_LBRS_ON_PMI: When set, the LBR stack is frozen on a - /// PMI request. If CPUID.01H: ECX[15] = 1 && CPUID.0AH: EAX[7:0] > 1. - /// - UINT32 FREEZE_LBRS_ON_PMI:1; - /// - /// [Bit 12] FREEZE_PERFMON_ON_PMI: When set, each ENABLE bit of the - /// global counter control MSR are frozen (address 38FH) on a PMI request. - /// If CPUID.01H: ECX[15] = 1 && CPUID.0AH: EAX[7:0] > 1. - /// - UINT32 FREEZE_PERFMON_ON_PMI:1; - /// - /// [Bit 13] ENABLE_UNCORE_PMI: When set, enables the logical processor to - /// receive and generate PMI on behalf of the uncore. Introduced at - /// Display Family / Display Model 06_1AH. - /// - UINT32 ENABLE_UNCORE_PMI:1; - /// - /// [Bit 14] FREEZE_WHILE_SMM: When set, freezes perfmon and trace - /// messages while in SMM. If IA32_PERF_CAPABILITIES[ 12] = 1. - /// - UINT32 FREEZE_WHILE_SMM:1; - /// - /// [Bit 15] RTM_DEBUG: When set, enables DR7 debug bit on XBEGIN. If - /// (CPUID.(EAX=07H, ECX=0):EBX[11] = 1). - /// - UINT32 RTM_DEBUG:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_DEBUGCTL_REGISTER; - - -/** - SMRR Base Address (Writeable only in SMM) Base address of SMM memory range. - If IA32_MTRRCAP.SMRR[11] = 1. - - @param ECX MSR_IA32_SMRR_PHYSBASE (0x000001F2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_SMRR_PHYSBASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_SMRR_PHYSBASE_REGISTER. - - Example usage - @code - MSR_IA32_SMRR_PHYSBASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMRR_PHYSBASE); - AsmWriteMsr64 (MSR_IA32_SMRR_PHYSBASE, Msr.Uint64); - @endcode - @note MSR_IA32_SMRR_PHYSBASE is defined as IA32_SMRR_PHYSBASE in SDM. -**/ -#define MSR_IA32_SMRR_PHYSBASE 0x000001F2 - -/** - MSR information returned for MSR index #MSR_IA32_SMRR_PHYSBASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Type. Specifies memory type of the range. - /// - UINT32 Type:8; - UINT32 Reserved1:4; - /// - /// [Bits 31:12] PhysBase. SMRR physical Base Address. - /// - UINT32 PhysBase:20; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_SMRR_PHYSBASE_REGISTER; - - -/** - SMRR Range Mask. (Writeable only in SMM) Range Mask of SMM memory range. If - IA32_MTRRCAP[SMRR] = 1. - - @param ECX MSR_IA32_SMRR_PHYSMASK (0x000001F3) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_SMRR_PHYSMASK_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_SMRR_PHYSMASK_REGISTER. - - Example usage - @code - MSR_IA32_SMRR_PHYSMASK_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SMRR_PHYSMASK); - AsmWriteMsr64 (MSR_IA32_SMRR_PHYSMASK, Msr.Uint64); - @endcode - @note MSR_IA32_SMRR_PHYSMASK is defined as IA32_SMRR_PHYSMASK in SDM. -**/ -#define MSR_IA32_SMRR_PHYSMASK 0x000001F3 - -/** - MSR information returned for MSR index #MSR_IA32_SMRR_PHYSMASK -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:11; - /// - /// [Bit 11] Valid Enable range mask. - /// - UINT32 Valid:1; - /// - /// [Bits 31:12] PhysMask SMRR address range mask. - /// - UINT32 PhysMask:20; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_SMRR_PHYSMASK_REGISTER; - - -/** - DCA Capability (R). If CPUID.01H: ECX[18] = 1. - - @param ECX MSR_IA32_PLATFORM_DCA_CAP (0x000001F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_PLATFORM_DCA_CAP); - @endcode - @note MSR_IA32_PLATFORM_DCA_CAP is defined as IA32_PLATFORM_DCA_CAP in SDM. -**/ -#define MSR_IA32_PLATFORM_DCA_CAP 0x000001F8 - - -/** - If set, CPU supports Prefetch-Hint type. If CPUID.01H: ECX[18] = 1. - - @param ECX MSR_IA32_CPU_DCA_CAP (0x000001F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_CPU_DCA_CAP); - AsmWriteMsr64 (MSR_IA32_CPU_DCA_CAP, Msr); - @endcode - @note MSR_IA32_CPU_DCA_CAP is defined as IA32_CPU_DCA_CAP in SDM. -**/ -#define MSR_IA32_CPU_DCA_CAP 0x000001F9 - - -/** - DCA type 0 Status and Control register. If CPUID.01H: ECX[18] = 1. - - @param ECX MSR_IA32_DCA_0_CAP (0x000001FA) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_DCA_0_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_DCA_0_CAP_REGISTER. - - Example usage - @code - MSR_IA32_DCA_0_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DCA_0_CAP); - AsmWriteMsr64 (MSR_IA32_DCA_0_CAP, Msr.Uint64); - @endcode - @note MSR_IA32_DCA_0_CAP is defined as IA32_DCA_0_CAP in SDM. -**/ -#define MSR_IA32_DCA_0_CAP 0x000001FA - -/** - MSR information returned for MSR index #MSR_IA32_DCA_0_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] DCA_ACTIVE: Set by HW when DCA is fuseenabled and no - /// defeatures are set. - /// - UINT32 DCA_ACTIVE:1; - /// - /// [Bits 2:1] TRANSACTION. - /// - UINT32 TRANSACTION:2; - /// - /// [Bits 6:3] DCA_TYPE. - /// - UINT32 DCA_TYPE:4; - /// - /// [Bits 10:7] DCA_QUEUE_SIZE. - /// - UINT32 DCA_QUEUE_SIZE:4; - UINT32 Reserved1:2; - /// - /// [Bits 16:13] DCA_DELAY: Writes will update the register but have no HW - /// side-effect. - /// - UINT32 DCA_DELAY:4; - UINT32 Reserved2:7; - /// - /// [Bit 24] SW_BLOCK: SW can request DCA block by setting this bit. - /// - UINT32 SW_BLOCK:1; - UINT32 Reserved3:1; - /// - /// [Bit 26] HW_BLOCK: Set when DCA is blocked by HW (e.g. CR0.CD = 1). - /// - UINT32 HW_BLOCK:1; - UINT32 Reserved4:5; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_DCA_0_CAP_REGISTER; - - -/** - MTRRphysBasen. See Section 11.11.2.3, "Variable Range MTRRs". - If CPUID.01H: EDX.MTRR[12] = 1 and IA32_MTRRCAP[7:0] > n. - - @param ECX MSR_IA32_MTRR_PHYSBASEn - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_PHYSBASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_PHYSBASE_REGISTER. - - Example usage - @code - MSR_IA32_MTRR_PHYSBASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0); - AsmWriteMsr64 (MSR_IA32_MTRR_PHYSBASE0, Msr.Uint64); - @endcode - @note MSR_IA32_MTRR_PHYSBASE0 is defined as IA32_MTRR_PHYSBASE0 in SDM. - MSR_IA32_MTRR_PHYSBASE1 is defined as IA32_MTRR_PHYSBASE1 in SDM. - MSR_IA32_MTRR_PHYSBASE2 is defined as IA32_MTRR_PHYSBASE2 in SDM. - MSR_IA32_MTRR_PHYSBASE3 is defined as IA32_MTRR_PHYSBASE3 in SDM. - MSR_IA32_MTRR_PHYSBASE4 is defined as IA32_MTRR_PHYSBASE4 in SDM. - MSR_IA32_MTRR_PHYSBASE5 is defined as IA32_MTRR_PHYSBASE5 in SDM. - MSR_IA32_MTRR_PHYSBASE6 is defined as IA32_MTRR_PHYSBASE6 in SDM. - MSR_IA32_MTRR_PHYSBASE7 is defined as IA32_MTRR_PHYSBASE7 in SDM. - MSR_IA32_MTRR_PHYSBASE8 is defined as IA32_MTRR_PHYSBASE8 in SDM. - MSR_IA32_MTRR_PHYSBASE9 is defined as IA32_MTRR_PHYSBASE9 in SDM. - @{ -**/ -#define MSR_IA32_MTRR_PHYSBASE0 0x00000200 -#define MSR_IA32_MTRR_PHYSBASE1 0x00000202 -#define MSR_IA32_MTRR_PHYSBASE2 0x00000204 -#define MSR_IA32_MTRR_PHYSBASE3 0x00000206 -#define MSR_IA32_MTRR_PHYSBASE4 0x00000208 -#define MSR_IA32_MTRR_PHYSBASE5 0x0000020A -#define MSR_IA32_MTRR_PHYSBASE6 0x0000020C -#define MSR_IA32_MTRR_PHYSBASE7 0x0000020E -#define MSR_IA32_MTRR_PHYSBASE8 0x00000210 -#define MSR_IA32_MTRR_PHYSBASE9 0x00000212 -/// @} - -/** - MSR information returned for MSR indexes #MSR_IA32_MTRR_PHYSBASE0 to - #MSR_IA32_MTRR_PHYSBASE9 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Type. Specifies memory type of the range. - /// - UINT32 Type:8; - UINT32 Reserved1:4; - /// - /// [Bits 31:12] PhysBase. MTRR physical Base Address. - /// - UINT32 PhysBase:20; - /// - /// [Bits MAXPHYSADDR:32] PhysBase. Upper bits of MTRR physical Base Address. - /// MAXPHYADDR: The bit position indicated by MAXPHYADDR depends on the - /// maximum physical address range supported by the processor. It is - /// reported by CPUID leaf function 80000008H. If CPUID does not support - /// leaf 80000008H, the processor supports 36-bit physical address size, - /// then bit PhysMask consists of bits 35:12, and bits 63:36 are reserved. - /// - UINT32 PhysBaseHi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MTRR_PHYSBASE_REGISTER; - - -/** - MTRRphysMaskn. See Section 11.11.2.3, "Variable Range MTRRs". - If CPUID.01H: EDX.MTRR[12] = 1 and IA32_MTRRCAP[7:0] > n. - - @param ECX MSR_IA32_MTRR_PHYSMASKn - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_PHYSMASK_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_PHYSMASK_REGISTER. - - Example usage - @code - MSR_IA32_MTRR_PHYSMASK_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0); - AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0, Msr.Uint64); - @endcode - @note MSR_IA32_MTRR_PHYSMASK0 is defined as IA32_MTRR_PHYSMASK0 in SDM. - MSR_IA32_MTRR_PHYSMASK1 is defined as IA32_MTRR_PHYSMASK1 in SDM. - MSR_IA32_MTRR_PHYSMASK2 is defined as IA32_MTRR_PHYSMASK2 in SDM. - MSR_IA32_MTRR_PHYSMASK3 is defined as IA32_MTRR_PHYSMASK3 in SDM. - MSR_IA32_MTRR_PHYSMASK4 is defined as IA32_MTRR_PHYSMASK4 in SDM. - MSR_IA32_MTRR_PHYSMASK5 is defined as IA32_MTRR_PHYSMASK5 in SDM. - MSR_IA32_MTRR_PHYSMASK6 is defined as IA32_MTRR_PHYSMASK6 in SDM. - MSR_IA32_MTRR_PHYSMASK7 is defined as IA32_MTRR_PHYSMASK7 in SDM. - MSR_IA32_MTRR_PHYSMASK8 is defined as IA32_MTRR_PHYSMASK8 in SDM. - MSR_IA32_MTRR_PHYSMASK9 is defined as IA32_MTRR_PHYSMASK9 in SDM. - @{ -**/ -#define MSR_IA32_MTRR_PHYSMASK0 0x00000201 -#define MSR_IA32_MTRR_PHYSMASK1 0x00000203 -#define MSR_IA32_MTRR_PHYSMASK2 0x00000205 -#define MSR_IA32_MTRR_PHYSMASK3 0x00000207 -#define MSR_IA32_MTRR_PHYSMASK4 0x00000209 -#define MSR_IA32_MTRR_PHYSMASK5 0x0000020B -#define MSR_IA32_MTRR_PHYSMASK6 0x0000020D -#define MSR_IA32_MTRR_PHYSMASK7 0x0000020F -#define MSR_IA32_MTRR_PHYSMASK8 0x00000211 -#define MSR_IA32_MTRR_PHYSMASK9 0x00000213 -/// @} - -/** - MSR information returned for MSR indexes #MSR_IA32_MTRR_PHYSMASK0 to - #MSR_IA32_MTRR_PHYSMASK9 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:11; - /// - /// [Bit 11] Valid Enable range mask. - /// - UINT32 V:1; - /// - /// [Bits 31:12] PhysMask. MTRR address range mask. - /// - UINT32 PhysMask:20; - /// - /// [Bits MAXPHYSADDR:32] PhysMask. Upper bits of MTRR address range mask. - /// MAXPHYADDR: The bit position indicated by MAXPHYADDR depends on the - /// maximum physical address range supported by the processor. It is - /// reported by CPUID leaf function 80000008H. If CPUID does not support - /// leaf 80000008H, the processor supports 36-bit physical address size, - /// then bit PhysMask consists of bits 35:12, and bits 63:36 are reserved. - /// - UINT32 PhysMaskHi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MTRR_PHYSMASK_REGISTER; - - -/** - MTRRfix64K_00000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX64K_00000 (0x00000250) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX64K_00000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX64K_00000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX64K_00000 is defined as IA32_MTRR_FIX64K_00000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX64K_00000 0x00000250 - - -/** - MTRRfix16K_80000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX16K_80000 (0x00000258) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX16K_80000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX16K_80000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX16K_80000 is defined as IA32_MTRR_FIX16K_80000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX16K_80000 0x00000258 - - -/** - MTRRfix16K_A0000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX16K_A0000 (0x00000259) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX16K_A0000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX16K_A0000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX16K_A0000 is defined as IA32_MTRR_FIX16K_A0000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX16K_A0000 0x00000259 - - -/** - See Section 11.11.2.2, "Fixed Range MTRRs.". If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_C0000 (0x00000268) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_C0000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_C0000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_C0000 is defined as IA32_MTRR_FIX4K_C0000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_C0000 0x00000268 - - -/** - MTRRfix4K_C8000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_C8000 (0x00000269) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_C8000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_C8000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_C8000 is defined as IA32_MTRR_FIX4K_C8000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_C8000 0x00000269 - - -/** - MTRRfix4K_D0000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_D0000 (0x0000026A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_D0000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_D0000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_D0000 is defined as IA32_MTRR_FIX4K_D0000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_D0000 0x0000026A - - -/** - MTRRfix4K_D8000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_D8000 (0x0000026B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_D8000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_D8000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_D8000 is defined as IA32_MTRR_FIX4K_D8000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_D8000 0x0000026B - - -/** - MTRRfix4K_E0000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_E0000 (0x0000026C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_E0000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_E0000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_E0000 is defined as IA32_MTRR_FIX4K_E0000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_E0000 0x0000026C - - -/** - MTRRfix4K_E8000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_E8000 (0x0000026D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_E8000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_E8000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_E8000 is defined as IA32_MTRR_FIX4K_E8000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_E8000 0x0000026D - - -/** - MTRRfix4K_F0000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_F0000 (0x0000026E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_F0000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_F0000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_F0000 is defined as IA32_MTRR_FIX4K_F0000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_F0000 0x0000026E - - -/** - MTRRfix4K_F8000. If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_FIX4K_F8000 (0x0000026F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MTRR_FIX4K_F8000); - AsmWriteMsr64 (MSR_IA32_MTRR_FIX4K_F8000, Msr); - @endcode - @note MSR_IA32_MTRR_FIX4K_F8000 is defined as IA32_MTRR_FIX4K_F8000 in SDM. -**/ -#define MSR_IA32_MTRR_FIX4K_F8000 0x0000026F - - -/** - IA32_PAT (R/W). If CPUID.01H: EDX.MTRR[16] =1. - - @param ECX MSR_IA32_PAT (0x00000277) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PAT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PAT_REGISTER. - - Example usage - @code - MSR_IA32_PAT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PAT); - AsmWriteMsr64 (MSR_IA32_PAT, Msr.Uint64); - @endcode - @note MSR_IA32_PAT is defined as IA32_PAT in SDM. -**/ -#define MSR_IA32_PAT 0x00000277 - -/** - MSR information returned for MSR index #MSR_IA32_PAT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] PA0. - /// - UINT32 PA0:3; - UINT32 Reserved1:5; - /// - /// [Bits 10:8] PA1. - /// - UINT32 PA1:3; - UINT32 Reserved2:5; - /// - /// [Bits 18:16] PA2. - /// - UINT32 PA2:3; - UINT32 Reserved3:5; - /// - /// [Bits 26:24] PA3. - /// - UINT32 PA3:3; - UINT32 Reserved4:5; - /// - /// [Bits 34:32] PA4. - /// - UINT32 PA4:3; - UINT32 Reserved5:5; - /// - /// [Bits 42:40] PA5. - /// - UINT32 PA5:3; - UINT32 Reserved6:5; - /// - /// [Bits 50:48] PA6. - /// - UINT32 PA6:3; - UINT32 Reserved7:5; - /// - /// [Bits 58:56] PA7. - /// - UINT32 PA7:3; - UINT32 Reserved8:5; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PAT_REGISTER; - - -/** - Provides the programming interface to use corrected MC error signaling - capability (R/W). If IA32_MCG_CAP[10] = 1 && IA32_MCG_CAP[7:0] > n. - - @param ECX MSR_IA32_MCn_CTL2 - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MC_CTL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MC_CTL2_REGISTER. - - Example usage - @code - MSR_IA32_MC_CTL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MC0_CTL2); - AsmWriteMsr64 (MSR_IA32_MC0_CTL2, Msr.Uint64); - @endcode - @note MSR_IA32_MC0_CTL2 is defined as IA32_MC0_CTL2 in SDM. - MSR_IA32_MC1_CTL2 is defined as IA32_MC1_CTL2 in SDM. - MSR_IA32_MC2_CTL2 is defined as IA32_MC2_CTL2 in SDM. - MSR_IA32_MC3_CTL2 is defined as IA32_MC3_CTL2 in SDM. - MSR_IA32_MC4_CTL2 is defined as IA32_MC4_CTL2 in SDM. - MSR_IA32_MC5_CTL2 is defined as IA32_MC5_CTL2 in SDM. - MSR_IA32_MC6_CTL2 is defined as IA32_MC6_CTL2 in SDM. - MSR_IA32_MC7_CTL2 is defined as IA32_MC7_CTL2 in SDM. - MSR_IA32_MC8_CTL2 is defined as IA32_MC8_CTL2 in SDM. - MSR_IA32_MC9_CTL2 is defined as IA32_MC9_CTL2 in SDM. - MSR_IA32_MC10_CTL2 is defined as IA32_MC10_CTL2 in SDM. - MSR_IA32_MC11_CTL2 is defined as IA32_MC11_CTL2 in SDM. - MSR_IA32_MC12_CTL2 is defined as IA32_MC12_CTL2 in SDM. - MSR_IA32_MC13_CTL2 is defined as IA32_MC13_CTL2 in SDM. - MSR_IA32_MC14_CTL2 is defined as IA32_MC14_CTL2 in SDM. - MSR_IA32_MC15_CTL2 is defined as IA32_MC15_CTL2 in SDM. - MSR_IA32_MC16_CTL2 is defined as IA32_MC16_CTL2 in SDM. - MSR_IA32_MC17_CTL2 is defined as IA32_MC17_CTL2 in SDM. - MSR_IA32_MC18_CTL2 is defined as IA32_MC18_CTL2 in SDM. - MSR_IA32_MC19_CTL2 is defined as IA32_MC19_CTL2 in SDM. - MSR_IA32_MC20_CTL2 is defined as IA32_MC20_CTL2 in SDM. - MSR_IA32_MC21_CTL2 is defined as IA32_MC21_CTL2 in SDM. - MSR_IA32_MC22_CTL2 is defined as IA32_MC22_CTL2 in SDM. - MSR_IA32_MC23_CTL2 is defined as IA32_MC23_CTL2 in SDM. - MSR_IA32_MC24_CTL2 is defined as IA32_MC24_CTL2 in SDM. - MSR_IA32_MC25_CTL2 is defined as IA32_MC25_CTL2 in SDM. - MSR_IA32_MC26_CTL2 is defined as IA32_MC26_CTL2 in SDM. - MSR_IA32_MC27_CTL2 is defined as IA32_MC27_CTL2 in SDM. - MSR_IA32_MC28_CTL2 is defined as IA32_MC28_CTL2 in SDM. - MSR_IA32_MC29_CTL2 is defined as IA32_MC29_CTL2 in SDM. - MSR_IA32_MC30_CTL2 is defined as IA32_MC30_CTL2 in SDM. - MSR_IA32_MC31_CTL2 is defined as IA32_MC31_CTL2 in SDM. - @{ -**/ -#define MSR_IA32_MC0_CTL2 0x00000280 -#define MSR_IA32_MC1_CTL2 0x00000281 -#define MSR_IA32_MC2_CTL2 0x00000282 -#define MSR_IA32_MC3_CTL2 0x00000283 -#define MSR_IA32_MC4_CTL2 0x00000284 -#define MSR_IA32_MC5_CTL2 0x00000285 -#define MSR_IA32_MC6_CTL2 0x00000286 -#define MSR_IA32_MC7_CTL2 0x00000287 -#define MSR_IA32_MC8_CTL2 0x00000288 -#define MSR_IA32_MC9_CTL2 0x00000289 -#define MSR_IA32_MC10_CTL2 0x0000028A -#define MSR_IA32_MC11_CTL2 0x0000028B -#define MSR_IA32_MC12_CTL2 0x0000028C -#define MSR_IA32_MC13_CTL2 0x0000028D -#define MSR_IA32_MC14_CTL2 0x0000028E -#define MSR_IA32_MC15_CTL2 0x0000028F -#define MSR_IA32_MC16_CTL2 0x00000290 -#define MSR_IA32_MC17_CTL2 0x00000291 -#define MSR_IA32_MC18_CTL2 0x00000292 -#define MSR_IA32_MC19_CTL2 0x00000293 -#define MSR_IA32_MC20_CTL2 0x00000294 -#define MSR_IA32_MC21_CTL2 0x00000295 -#define MSR_IA32_MC22_CTL2 0x00000296 -#define MSR_IA32_MC23_CTL2 0x00000297 -#define MSR_IA32_MC24_CTL2 0x00000298 -#define MSR_IA32_MC25_CTL2 0x00000299 -#define MSR_IA32_MC26_CTL2 0x0000029A -#define MSR_IA32_MC27_CTL2 0x0000029B -#define MSR_IA32_MC28_CTL2 0x0000029C -#define MSR_IA32_MC29_CTL2 0x0000029D -#define MSR_IA32_MC30_CTL2 0x0000029E -#define MSR_IA32_MC31_CTL2 0x0000029F -/// @} - -/** - MSR information returned for MSR indexes #MSR_IA32_MC0_CTL2 - to #MSR_IA32_MC31_CTL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Corrected error count threshold. - /// - UINT32 CorrectedErrorCountThreshold:15; - UINT32 Reserved1:15; - /// - /// [Bit 30] CMCI_EN. - /// - UINT32 CMCI_EN:1; - UINT32 Reserved2:1; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MC_CTL2_REGISTER; - - -/** - MTRRdefType (R/W). If CPUID.01H: EDX.MTRR[12] =1. - - @param ECX MSR_IA32_MTRR_DEF_TYPE (0x000002FF) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_DEF_TYPE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MTRR_DEF_TYPE_REGISTER. - - Example usage - @code - MSR_IA32_MTRR_DEF_TYPE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, Msr.Uint64); - @endcode - @note MSR_IA32_MTRR_DEF_TYPE is defined as IA32_MTRR_DEF_TYPE in SDM. -**/ -#define MSR_IA32_MTRR_DEF_TYPE 0x000002FF - -/** - MSR information returned for MSR index #MSR_IA32_MTRR_DEF_TYPE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Default Memory Type. - /// - UINT32 Type:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] Fixed Range MTRR Enable. - /// - UINT32 FE:1; - /// - /// [Bit 11] MTRR Enable. - /// - UINT32 E:1; - UINT32 Reserved2:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MTRR_DEF_TYPE_REGISTER; - - -/** - Fixed-Function Performance Counter 0 (R/W): Counts Instr_Retired.Any. If - CPUID.0AH: EDX[4:0] > 0. - - @param ECX MSR_IA32_FIXED_CTR0 (0x00000309) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR0); - AsmWriteMsr64 (MSR_IA32_FIXED_CTR0, Msr); - @endcode - @note MSR_IA32_FIXED_CTR0 is defined as IA32_FIXED_CTR0 in SDM. -**/ -#define MSR_IA32_FIXED_CTR0 0x00000309 - - -/** - Fixed-Function Performance Counter 1 (R/W): Counts CPU_CLK_Unhalted.Core. If - CPUID.0AH: EDX[4:0] > 1. - - @param ECX MSR_IA32_FIXED_CTR1 (0x0000030A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR1); - AsmWriteMsr64 (MSR_IA32_FIXED_CTR1, Msr); - @endcode - @note MSR_IA32_FIXED_CTR1 is defined as IA32_FIXED_CTR1 in SDM. -**/ -#define MSR_IA32_FIXED_CTR1 0x0000030A - - -/** - Fixed-Function Performance Counter 2 (R/W): Counts CPU_CLK_Unhalted.Ref. If - CPUID.0AH: EDX[4:0] > 2. - - @param ECX MSR_IA32_FIXED_CTR2 (0x0000030B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_FIXED_CTR2); - AsmWriteMsr64 (MSR_IA32_FIXED_CTR2, Msr); - @endcode - @note MSR_IA32_FIXED_CTR2 is defined as IA32_FIXED_CTR2 in SDM. -**/ -#define MSR_IA32_FIXED_CTR2 0x0000030B - - -/** - RO. If CPUID.01H: ECX[15] = 1. - - @param ECX MSR_IA32_PERF_CAPABILITIES (0x00000345) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_CAPABILITIES_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_CAPABILITIES_REGISTER. - - Example usage - @code - MSR_IA32_PERF_CAPABILITIES_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_CAPABILITIES); - AsmWriteMsr64 (MSR_IA32_PERF_CAPABILITIES, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_CAPABILITIES is defined as IA32_PERF_CAPABILITIES in SDM. -**/ -#define MSR_IA32_PERF_CAPABILITIES 0x00000345 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_CAPABILITIES -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 5:0] LBR format. - /// - UINT32 LBR_FMT:6; - /// - /// [Bit 6] PEBS Trap. - /// - UINT32 PEBS_TRAP:1; - /// - /// [Bit 7] PEBSSaveArchRegs. - /// - UINT32 PEBS_ARCH_REG:1; - /// - /// [Bits 11:8] PEBS Record Format. - /// - UINT32 PEBS_REC_FMT:4; - /// - /// [Bit 12] 1: Freeze while SMM is supported. - /// - UINT32 SMM_FREEZE:1; - /// - /// [Bit 13] 1: Full width of counter writable via IA32_A_PMCx. - /// - UINT32 FW_WRITE:1; - UINT32 Reserved1:18; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_CAPABILITIES_REGISTER; - - -/** - Fixed-Function Performance Counter Control (R/W) Counter increments while - the results of ANDing respective enable bit in IA32_PERF_GLOBAL_CTRL with - the corresponding OS or USR bits in this MSR is true. If CPUID.0AH: EAX[7:0] - > 1. - - @param ECX MSR_IA32_FIXED_CTR_CTRL (0x0000038D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_FIXED_CTR_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_FIXED_CTR_CTRL_REGISTER. - - Example usage - @code - MSR_IA32_FIXED_CTR_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_FIXED_CTR_CTRL); - AsmWriteMsr64 (MSR_IA32_FIXED_CTR_CTRL, Msr.Uint64); - @endcode - @note MSR_IA32_FIXED_CTR_CTRL is defined as IA32_FIXED_CTR_CTRL in SDM. -**/ -#define MSR_IA32_FIXED_CTR_CTRL 0x0000038D - -/** - MSR information returned for MSR index #MSR_IA32_FIXED_CTR_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] EN0_OS: Enable Fixed Counter 0 to count while CPL = 0. - /// - UINT32 EN0_OS:1; - /// - /// [Bit 1] EN0_Usr: Enable Fixed Counter 0 to count while CPL > 0. - /// - UINT32 EN0_Usr:1; - /// - /// [Bit 2] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. - /// - UINT32 AnyThread0:1; - /// - /// [Bit 3] EN0_PMI: Enable PMI when fixed counter 0 overflows. - /// - UINT32 EN0_PMI:1; - /// - /// [Bit 4] EN1_OS: Enable Fixed Counter 1 to count while CPL = 0. - /// - UINT32 EN1_OS:1; - /// - /// [Bit 5] EN1_Usr: Enable Fixed Counter 1 to count while CPL > 0. - /// - UINT32 EN1_Usr:1; - /// - /// [Bit 6] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. - /// - UINT32 AnyThread1:1; - /// - /// [Bit 7] EN1_PMI: Enable PMI when fixed counter 1 overflows. - /// - UINT32 EN1_PMI:1; - /// - /// [Bit 8] EN2_OS: Enable Fixed Counter 2 to count while CPL = 0. - /// - UINT32 EN2_OS:1; - /// - /// [Bit 9] EN2_Usr: Enable Fixed Counter 2 to count while CPL > 0. - /// - UINT32 EN2_Usr:1; - /// - /// [Bit 10] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. If CPUID.0AH: EAX[7:0] > 2. - /// - UINT32 AnyThread2:1; - /// - /// [Bit 11] EN2_PMI: Enable PMI when fixed counter 2 overflows. - /// - UINT32 EN2_PMI:1; - UINT32 Reserved1:20; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_FIXED_CTR_CTRL_REGISTER; - - -/** - Global Performance Counter Status (RO). If CPUID.0AH: EAX[7:0] > 0. - - @param ECX MSR_IA32_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS); - @endcode - @note MSR_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_STATUS 0x0000038E - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Ovf_PMC0: Overflow status of IA32_PMC0. If CPUID.0AH: - /// EAX[15:8] > 0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Ovf_PMC1: Overflow status of IA32_PMC1. If CPUID.0AH: - /// EAX[15:8] > 1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Ovf_PMC2: Overflow status of IA32_PMC2. If CPUID.0AH: - /// EAX[15:8] > 2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Ovf_PMC3: Overflow status of IA32_PMC3. If CPUID.0AH: - /// EAX[15:8] > 3. - /// - UINT32 Ovf_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Ovf_FixedCtr0: Overflow status of IA32_FIXED_CTR0. If - /// CPUID.0AH: EAX[7:0] > 1. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Ovf_FixedCtr1: Overflow status of IA32_FIXED_CTR1. If - /// CPUID.0AH: EAX[7:0] > 1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Ovf_FixedCtr2: Overflow status of IA32_FIXED_CTR2. If - /// CPUID.0AH: EAX[7:0] > 1. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Trace_ToPA_PMI: A PMI occurred due to a ToPA entry memory - /// buffer was completely filled. If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1) - /// && IA32_RTIT_CTL.ToPA = 1. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] LBR_Frz: LBRs are frozen due to - - /// IA32_DEBUGCTL.FREEZE_LBR_ON_PMI=1, - The LBR stack overflowed. If - /// CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] CTR_Frz: Performance counters in the core PMU are frozen due - /// to - IA32_DEBUGCTL.FREEZE_PERFMON_ON_ PMI=1, - one or more core PMU - /// counters overflowed. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] ASCI: Data in the performance counters in the core PMU may - /// include contributions from the direct or indirect operation intel SGX - /// to protect an enclave. If CPUID.(EAX=07H, ECX=0):EBX[2] = 1. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Ovf_Uncore: Uncore counter overflow status. If CPUID.0AH: - /// EAX[7:0] > 2. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] OvfBuf: DS SAVE area Buffer overflow status. If CPUID.0AH: - /// EAX[7:0] > 0. - /// - UINT32 OvfBuf:1; - /// - /// [Bit 63] CondChgd: status bits of this register has changed. If - /// CPUID.0AH: EAX[7:0] > 0. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Global Performance Counter Control (R/W) Counter increments while the result - of ANDing respective enable bit in this MSR with the corresponding OS or USR - bits in the general-purpose or fixed counter control MSR is true. If - CPUID.0AH: EAX[7:0] > 0. - - @param ECX MSR_IA32_PERF_GLOBAL_CTRL (0x0000038F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_CTRL_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_CTRL, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_GLOBAL_CTRL is defined as IA32_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_CTRL 0x0000038F - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_CTRL -**/ -typedef union { - /// - /// Individual bit fields -/// - struct { - /// - /// [Bits 31:0] EN_PMCn. If CPUID.0AH: EAX[15:8] > n. - /// Enable bitmask. Only the first n-1 bits are valid. - /// Bits n..31 are reserved. - /// - UINT32 EN_PMCn:32; - /// - /// [Bits 63:32] EN_FIXED_CTRn. If CPUID.0AH: EDX[4:0] > n. - /// Enable bitmask. Only the first n-1 bits are valid. - /// Bits 31:n are reserved. - /// - UINT32 EN_FIXED_CTRn:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_CTRL_REGISTER; - - -/** - Global Performance Counter Overflow Control (R/W). If CPUID.0AH: EAX[7:0] > - 0 && CPUID.0AH: EAX[7:0] <= 3. - - @param ECX MSR_IA32_PERF_GLOBAL_OVF_CTRL (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_GLOBAL_OVF_CTRL is defined as IA32_PERF_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_OVF_CTRL 0x00000390 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_OVF_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Set 1 to Clear Ovf_PMC0 bit. If CPUID.0AH: EAX[15:8] > n. - /// Clear bitmask. Only the first n-1 bits are valid. - /// Bits 31:n are reserved. - /// - UINT32 Ovf_PMCn:32; - /// - /// [Bits 54:32] Set 1 to Clear Ovf_FIXED_CTR0 bit. - /// If CPUID.0AH: EDX[4:0] > n. - /// Clear bitmask. Only the first n-1 bits are valid. - /// Bits 22:n are reserved. - /// - UINT32 Ovf_FIXED_CTRn:23; - /// - /// [Bit 55] Set 1 to Clear Trace_ToPA_PMI bit. If (CPUID.(EAX=07H, - /// ECX=0):EBX[25] = 1) && IA32_RTIT_CTL.ToPA = 1. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved2:5; - /// - /// [Bit 61] Set 1 to Clear Ovf_Uncore bit. Introduced at Display Family / - /// Display Model 06_2EH. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Set 1 to Clear OvfBuf: bit. If CPUID.0AH: EAX[7:0] > 0. - /// - UINT32 OvfBuf:1; - /// - /// [Bit 63] Set to 1to clear CondChgd: bit. If CPUID.0AH: EAX[7:0] > 0. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER; - - -/** - Global Performance Counter Overflow Reset Control (R/W). If CPUID.0AH: - EAX[7:0] > 3. - - @param ECX MSR_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_RESET); - AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS_RESET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Set 1 to Clear Ovf_PMC0 bit. If CPUID.0AH: EAX[15:8] > n. - /// Clear bitmask. Only the first n-1 bits are valid. - /// Bits 31:n are reserved. - /// - UINT32 Ovf_PMCn:32; - /// - /// [Bits 54:32] Set 1 to Clear Ovf_FIXED_CTR0 bit. - /// If CPUID.0AH: EDX[4:0] > n. - /// Clear bitmask. Only the first n-1 bits are valid. - /// Bits 22:n are reserved. - /// - UINT32 Ovf_FIXED_CTRn:23; - /// - /// [Bit 55] Set 1 to Clear Trace_ToPA_PMI bit. If (CPUID.(EAX=07H, - /// ECX=0):EBX[25] = 1) && IA32_RTIT_CTL.ToPA[8] = 1. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved2:2; - /// - /// [Bit 58] Set 1 to Clear LBR_Frz bit. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Set 1 to Clear CTR_Frz bit. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Set 1 to Clear ASCI bit. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Set 1 to Clear Ovf_Uncore bit. Introduced at Display Family / - /// Display Model 06_2EH. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Set 1 to Clear OvfBuf: bit. If CPUID.0AH: EAX[7:0] > 0. - /// - UINT32 OvfBuf:1; - /// - /// [Bit 63] Set to 1to clear CondChgd: bit. If CPUID.0AH: EAX[7:0] > 0. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; - - -/** - Global Performance Counter Overflow Set Control (R/W). If CPUID.0AH: - EAX[7:0] > 3. - - @param ECX MSR_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_SET); - AsmWriteMsr64 (MSR_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); - @endcode - @note MSR_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_STATUS_SET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Set 1 to cause Ovf_PMCn = 1. If CPUID.0AH: EAX[7:0] > n. - /// Set bitmask. Only the first n-1 bits are valid. - /// Bits 31:n are reserved. - /// - UINT32 Ovf_PMCn:32; - /// - /// [Bits 54:32] Set 1 to cause Ovf_FIXED_CTRn = 1. - /// If CPUID.0AH: EAX[7:0] > n. - /// Set bitmask. Only the first n-1 bits are valid. - /// Bits 22:n are reserved. - /// - UINT32 Ovf_FIXED_CTRn:23; - /// - /// [Bit 55] Set 1 to cause Trace_ToPA_PMI = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved2:2; - /// - /// [Bit 58] Set 1 to cause LBR_Frz = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Set 1 to cause CTR_Frz = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Set 1 to cause ASCI = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Set 1 to cause Ovf_Uncore = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Set 1 to cause OvfBuf = 1. If CPUID.0AH: EAX[7:0] > 3. - /// - UINT32 OvfBuf:1; - UINT32 Reserved3:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; - - -/** - Indicator of core perfmon interface is in use (RO). If CPUID.0AH: EAX[7:0] > - 3. - - @param ECX MSR_IA32_PERF_GLOBAL_INUSE (0x00000392) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_INUSE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PERF_GLOBAL_INUSE_REGISTER. - - Example usage - @code - MSR_IA32_PERF_GLOBAL_INUSE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PERF_GLOBAL_INUSE); - @endcode - @note MSR_IA32_PERF_GLOBAL_INUSE is defined as IA32_PERF_GLOBAL_INUSE in SDM. -**/ -#define MSR_IA32_PERF_GLOBAL_INUSE 0x00000392 - -/** - MSR information returned for MSR index #MSR_IA32_PERF_GLOBAL_INUSE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] IA32_PERFEVTSELn in use. If CPUID.0AH: EAX[7:0] > n. - /// Status bitmask. Only the first n-1 bits are valid. - /// Bits 31:n are reserved. - /// - UINT32 IA32_PERFEVTSELn:32; - /// - /// [Bits 62:32] IA32_FIXED_CTRn in use. - /// If CPUID.0AH: EAX[7:0] > n. - /// Status bitmask. Only the first n-1 bits are valid. - /// Bits 30:n are reserved. - /// - UINT32 IA32_FIXED_CTRn:31; - /// - /// [Bit 63] PMI in use. - /// - UINT32 PMI:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PERF_GLOBAL_INUSE_REGISTER; - - -/** - PEBS Control (R/W). - - @param ECX MSR_IA32_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_IA32_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PEBS_ENABLE); - AsmWriteMsr64 (MSR_IA32_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_IA32_PEBS_ENABLE is defined as IA32_PEBS_ENABLE in SDM. -**/ -#define MSR_IA32_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_IA32_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. Introduced at Display Family / - /// Display Model 06_0FH. - /// - UINT32 Enable:1; - /// - /// [Bits 3:1] Reserved or Model specific. - /// - UINT32 Reserved1:3; - UINT32 Reserved2:28; - /// - /// [Bits 35:32] Reserved or Model specific. - /// - UINT32 Reserved3:4; - UINT32 Reserved4:28; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PEBS_ENABLE_REGISTER; - - -/** - MCn_CTL. If IA32_MCG_CAP.CNT > n. - - @param ECX MSR_IA32_MCn_CTL - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MC0_CTL); - AsmWriteMsr64 (MSR_IA32_MC0_CTL, Msr); - @endcode - @note MSR_IA32_MC0_CTL is defined as IA32_MC0_CTL in SDM. - MSR_IA32_MC1_CTL is defined as IA32_MC1_CTL in SDM. - MSR_IA32_MC2_CTL is defined as IA32_MC2_CTL in SDM. - MSR_IA32_MC3_CTL is defined as IA32_MC3_CTL in SDM. - MSR_IA32_MC4_CTL is defined as IA32_MC4_CTL in SDM. - MSR_IA32_MC5_CTL is defined as IA32_MC5_CTL in SDM. - MSR_IA32_MC6_CTL is defined as IA32_MC6_CTL in SDM. - MSR_IA32_MC7_CTL is defined as IA32_MC7_CTL in SDM. - MSR_IA32_MC8_CTL is defined as IA32_MC8_CTL in SDM. - MSR_IA32_MC9_CTL is defined as IA32_MC9_CTL in SDM. - MSR_IA32_MC10_CTL is defined as IA32_MC10_CTL in SDM. - MSR_IA32_MC11_CTL is defined as IA32_MC11_CTL in SDM. - MSR_IA32_MC12_CTL is defined as IA32_MC12_CTL in SDM. - MSR_IA32_MC13_CTL is defined as IA32_MC13_CTL in SDM. - MSR_IA32_MC14_CTL is defined as IA32_MC14_CTL in SDM. - MSR_IA32_MC15_CTL is defined as IA32_MC15_CTL in SDM. - MSR_IA32_MC16_CTL is defined as IA32_MC16_CTL in SDM. - MSR_IA32_MC17_CTL is defined as IA32_MC17_CTL in SDM. - MSR_IA32_MC18_CTL is defined as IA32_MC18_CTL in SDM. - MSR_IA32_MC19_CTL is defined as IA32_MC19_CTL in SDM. - MSR_IA32_MC20_CTL is defined as IA32_MC20_CTL in SDM. - MSR_IA32_MC21_CTL is defined as IA32_MC21_CTL in SDM. - MSR_IA32_MC22_CTL is defined as IA32_MC22_CTL in SDM. - MSR_IA32_MC23_CTL is defined as IA32_MC23_CTL in SDM. - MSR_IA32_MC24_CTL is defined as IA32_MC24_CTL in SDM. - MSR_IA32_MC25_CTL is defined as IA32_MC25_CTL in SDM. - MSR_IA32_MC26_CTL is defined as IA32_MC26_CTL in SDM. - MSR_IA32_MC27_CTL is defined as IA32_MC27_CTL in SDM. - MSR_IA32_MC28_CTL is defined as IA32_MC28_CTL in SDM. - @{ -**/ -#define MSR_IA32_MC0_CTL 0x00000400 -#define MSR_IA32_MC1_CTL 0x00000404 -#define MSR_IA32_MC2_CTL 0x00000408 -#define MSR_IA32_MC3_CTL 0x0000040C -#define MSR_IA32_MC4_CTL 0x00000410 -#define MSR_IA32_MC5_CTL 0x00000414 -#define MSR_IA32_MC6_CTL 0x00000418 -#define MSR_IA32_MC7_CTL 0x0000041C -#define MSR_IA32_MC8_CTL 0x00000420 -#define MSR_IA32_MC9_CTL 0x00000424 -#define MSR_IA32_MC10_CTL 0x00000428 -#define MSR_IA32_MC11_CTL 0x0000042C -#define MSR_IA32_MC12_CTL 0x00000430 -#define MSR_IA32_MC13_CTL 0x00000434 -#define MSR_IA32_MC14_CTL 0x00000438 -#define MSR_IA32_MC15_CTL 0x0000043C -#define MSR_IA32_MC16_CTL 0x00000440 -#define MSR_IA32_MC17_CTL 0x00000444 -#define MSR_IA32_MC18_CTL 0x00000448 -#define MSR_IA32_MC19_CTL 0x0000044C -#define MSR_IA32_MC20_CTL 0x00000450 -#define MSR_IA32_MC21_CTL 0x00000454 -#define MSR_IA32_MC22_CTL 0x00000458 -#define MSR_IA32_MC23_CTL 0x0000045C -#define MSR_IA32_MC24_CTL 0x00000460 -#define MSR_IA32_MC25_CTL 0x00000464 -#define MSR_IA32_MC26_CTL 0x00000468 -#define MSR_IA32_MC27_CTL 0x0000046C -#define MSR_IA32_MC28_CTL 0x00000470 -/// @} - - -/** - MCn_STATUS. If IA32_MCG_CAP.CNT > n. - - @param ECX MSR_IA32_MCn_STATUS - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MC0_STATUS); - AsmWriteMsr64 (MSR_IA32_MC0_STATUS, Msr); - @endcode - @note MSR_IA32_MC0_STATUS is defined as IA32_MC0_STATUS in SDM. - MSR_IA32_MC1_STATUS is defined as IA32_MC1_STATUS in SDM. - MSR_IA32_MC2_STATUS is defined as IA32_MC2_STATUS in SDM. - MSR_IA32_MC3_STATUS is defined as IA32_MC3_STATUS in SDM. - MSR_IA32_MC4_STATUS is defined as IA32_MC4_STATUS in SDM. - MSR_IA32_MC5_STATUS is defined as IA32_MC5_STATUS in SDM. - MSR_IA32_MC6_STATUS is defined as IA32_MC6_STATUS in SDM. - MSR_IA32_MC7_STATUS is defined as IA32_MC7_STATUS in SDM. - MSR_IA32_MC8_STATUS is defined as IA32_MC8_STATUS in SDM. - MSR_IA32_MC9_STATUS is defined as IA32_MC9_STATUS in SDM. - MSR_IA32_MC10_STATUS is defined as IA32_MC10_STATUS in SDM. - MSR_IA32_MC11_STATUS is defined as IA32_MC11_STATUS in SDM. - MSR_IA32_MC12_STATUS is defined as IA32_MC12_STATUS in SDM. - MSR_IA32_MC13_STATUS is defined as IA32_MC13_STATUS in SDM. - MSR_IA32_MC14_STATUS is defined as IA32_MC14_STATUS in SDM. - MSR_IA32_MC15_STATUS is defined as IA32_MC15_STATUS in SDM. - MSR_IA32_MC16_STATUS is defined as IA32_MC16_STATUS in SDM. - MSR_IA32_MC17_STATUS is defined as IA32_MC17_STATUS in SDM. - MSR_IA32_MC18_STATUS is defined as IA32_MC18_STATUS in SDM. - MSR_IA32_MC19_STATUS is defined as IA32_MC19_STATUS in SDM. - MSR_IA32_MC20_STATUS is defined as IA32_MC20_STATUS in SDM. - MSR_IA32_MC21_STATUS is defined as IA32_MC21_STATUS in SDM. - MSR_IA32_MC22_STATUS is defined as IA32_MC22_STATUS in SDM. - MSR_IA32_MC23_STATUS is defined as IA32_MC23_STATUS in SDM. - MSR_IA32_MC24_STATUS is defined as IA32_MC24_STATUS in SDM. - MSR_IA32_MC25_STATUS is defined as IA32_MC25_STATUS in SDM. - MSR_IA32_MC26_STATUS is defined as IA32_MC26_STATUS in SDM. - MSR_IA32_MC27_STATUS is defined as IA32_MC27_STATUS in SDM. - MSR_IA32_MC28_STATUS is defined as IA32_MC28_STATUS in SDM. - @{ -**/ -#define MSR_IA32_MC0_STATUS 0x00000401 -#define MSR_IA32_MC1_STATUS 0x00000405 -#define MSR_IA32_MC2_STATUS 0x00000409 -#define MSR_IA32_MC3_STATUS 0x0000040D -#define MSR_IA32_MC4_STATUS 0x00000411 -#define MSR_IA32_MC5_STATUS 0x00000415 -#define MSR_IA32_MC6_STATUS 0x00000419 -#define MSR_IA32_MC7_STATUS 0x0000041D -#define MSR_IA32_MC8_STATUS 0x00000421 -#define MSR_IA32_MC9_STATUS 0x00000425 -#define MSR_IA32_MC10_STATUS 0x00000429 -#define MSR_IA32_MC11_STATUS 0x0000042D -#define MSR_IA32_MC12_STATUS 0x00000431 -#define MSR_IA32_MC13_STATUS 0x00000435 -#define MSR_IA32_MC14_STATUS 0x00000439 -#define MSR_IA32_MC15_STATUS 0x0000043D -#define MSR_IA32_MC16_STATUS 0x00000441 -#define MSR_IA32_MC17_STATUS 0x00000445 -#define MSR_IA32_MC18_STATUS 0x00000449 -#define MSR_IA32_MC19_STATUS 0x0000044D -#define MSR_IA32_MC20_STATUS 0x00000451 -#define MSR_IA32_MC21_STATUS 0x00000455 -#define MSR_IA32_MC22_STATUS 0x00000459 -#define MSR_IA32_MC23_STATUS 0x0000045D -#define MSR_IA32_MC24_STATUS 0x00000461 -#define MSR_IA32_MC25_STATUS 0x00000465 -#define MSR_IA32_MC26_STATUS 0x00000469 -#define MSR_IA32_MC27_STATUS 0x0000046D -#define MSR_IA32_MC28_STATUS 0x00000471 -/// @} - - -/** - MCn_ADDR. If IA32_MCG_CAP.CNT > n. - - @param ECX MSR_IA32_MCn_ADDR - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MC0_ADDR); - AsmWriteMsr64 (MSR_IA32_MC0_ADDR, Msr); - @endcode - @note MSR_IA32_MC0_ADDR is defined as IA32_MC0_ADDR in SDM. - MSR_IA32_MC1_ADDR is defined as IA32_MC1_ADDR in SDM. - MSR_IA32_MC2_ADDR is defined as IA32_MC2_ADDR in SDM. - MSR_IA32_MC3_ADDR is defined as IA32_MC3_ADDR in SDM. - MSR_IA32_MC4_ADDR is defined as IA32_MC4_ADDR in SDM. - MSR_IA32_MC5_ADDR is defined as IA32_MC5_ADDR in SDM. - MSR_IA32_MC6_ADDR is defined as IA32_MC6_ADDR in SDM. - MSR_IA32_MC7_ADDR is defined as IA32_MC7_ADDR in SDM. - MSR_IA32_MC8_ADDR is defined as IA32_MC8_ADDR in SDM. - MSR_IA32_MC9_ADDR is defined as IA32_MC9_ADDR in SDM. - MSR_IA32_MC10_ADDR is defined as IA32_MC10_ADDR in SDM. - MSR_IA32_MC11_ADDR is defined as IA32_MC11_ADDR in SDM. - MSR_IA32_MC12_ADDR is defined as IA32_MC12_ADDR in SDM. - MSR_IA32_MC13_ADDR is defined as IA32_MC13_ADDR in SDM. - MSR_IA32_MC14_ADDR is defined as IA32_MC14_ADDR in SDM. - MSR_IA32_MC15_ADDR is defined as IA32_MC15_ADDR in SDM. - MSR_IA32_MC16_ADDR is defined as IA32_MC16_ADDR in SDM. - MSR_IA32_MC17_ADDR is defined as IA32_MC17_ADDR in SDM. - MSR_IA32_MC18_ADDR is defined as IA32_MC18_ADDR in SDM. - MSR_IA32_MC19_ADDR is defined as IA32_MC19_ADDR in SDM. - MSR_IA32_MC20_ADDR is defined as IA32_MC20_ADDR in SDM. - MSR_IA32_MC21_ADDR is defined as IA32_MC21_ADDR in SDM. - MSR_IA32_MC22_ADDR is defined as IA32_MC22_ADDR in SDM. - MSR_IA32_MC23_ADDR is defined as IA32_MC23_ADDR in SDM. - MSR_IA32_MC24_ADDR is defined as IA32_MC24_ADDR in SDM. - MSR_IA32_MC25_ADDR is defined as IA32_MC25_ADDR in SDM. - MSR_IA32_MC26_ADDR is defined as IA32_MC26_ADDR in SDM. - MSR_IA32_MC27_ADDR is defined as IA32_MC27_ADDR in SDM. - MSR_IA32_MC28_ADDR is defined as IA32_MC28_ADDR in SDM. - @{ -**/ -#define MSR_IA32_MC0_ADDR 0x00000402 -#define MSR_IA32_MC1_ADDR 0x00000406 -#define MSR_IA32_MC2_ADDR 0x0000040A -#define MSR_IA32_MC3_ADDR 0x0000040E -#define MSR_IA32_MC4_ADDR 0x00000412 -#define MSR_IA32_MC5_ADDR 0x00000416 -#define MSR_IA32_MC6_ADDR 0x0000041A -#define MSR_IA32_MC7_ADDR 0x0000041E -#define MSR_IA32_MC8_ADDR 0x00000422 -#define MSR_IA32_MC9_ADDR 0x00000426 -#define MSR_IA32_MC10_ADDR 0x0000042A -#define MSR_IA32_MC11_ADDR 0x0000042E -#define MSR_IA32_MC12_ADDR 0x00000432 -#define MSR_IA32_MC13_ADDR 0x00000436 -#define MSR_IA32_MC14_ADDR 0x0000043A -#define MSR_IA32_MC15_ADDR 0x0000043E -#define MSR_IA32_MC16_ADDR 0x00000442 -#define MSR_IA32_MC17_ADDR 0x00000446 -#define MSR_IA32_MC18_ADDR 0x0000044A -#define MSR_IA32_MC19_ADDR 0x0000044E -#define MSR_IA32_MC20_ADDR 0x00000452 -#define MSR_IA32_MC21_ADDR 0x00000456 -#define MSR_IA32_MC22_ADDR 0x0000045A -#define MSR_IA32_MC23_ADDR 0x0000045E -#define MSR_IA32_MC24_ADDR 0x00000462 -#define MSR_IA32_MC25_ADDR 0x00000466 -#define MSR_IA32_MC26_ADDR 0x0000046A -#define MSR_IA32_MC27_ADDR 0x0000046E -#define MSR_IA32_MC28_ADDR 0x00000472 -/// @} - - -/** - MCn_MISC. If IA32_MCG_CAP.CNT > n. - - @param ECX MSR_IA32_MCn_MISC - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_MC0_MISC); - AsmWriteMsr64 (MSR_IA32_MC0_MISC, Msr); - @endcode - @note MSR_IA32_MC0_MISC is defined as IA32_MC0_MISC in SDM. - MSR_IA32_MC1_MISC is defined as IA32_MC1_MISC in SDM. - MSR_IA32_MC2_MISC is defined as IA32_MC2_MISC in SDM. - MSR_IA32_MC3_MISC is defined as IA32_MC3_MISC in SDM. - MSR_IA32_MC4_MISC is defined as IA32_MC4_MISC in SDM. - MSR_IA32_MC5_MISC is defined as IA32_MC5_MISC in SDM. - MSR_IA32_MC6_MISC is defined as IA32_MC6_MISC in SDM. - MSR_IA32_MC7_MISC is defined as IA32_MC7_MISC in SDM. - MSR_IA32_MC8_MISC is defined as IA32_MC8_MISC in SDM. - MSR_IA32_MC9_MISC is defined as IA32_MC9_MISC in SDM. - MSR_IA32_MC10_MISC is defined as IA32_MC10_MISC in SDM. - MSR_IA32_MC11_MISC is defined as IA32_MC11_MISC in SDM. - MSR_IA32_MC12_MISC is defined as IA32_MC12_MISC in SDM. - MSR_IA32_MC13_MISC is defined as IA32_MC13_MISC in SDM. - MSR_IA32_MC14_MISC is defined as IA32_MC14_MISC in SDM. - MSR_IA32_MC15_MISC is defined as IA32_MC15_MISC in SDM. - MSR_IA32_MC16_MISC is defined as IA32_MC16_MISC in SDM. - MSR_IA32_MC17_MISC is defined as IA32_MC17_MISC in SDM. - MSR_IA32_MC18_MISC is defined as IA32_MC18_MISC in SDM. - MSR_IA32_MC19_MISC is defined as IA32_MC19_MISC in SDM. - MSR_IA32_MC20_MISC is defined as IA32_MC20_MISC in SDM. - MSR_IA32_MC21_MISC is defined as IA32_MC21_MISC in SDM. - MSR_IA32_MC22_MISC is defined as IA32_MC22_MISC in SDM. - MSR_IA32_MC23_MISC is defined as IA32_MC23_MISC in SDM. - MSR_IA32_MC24_MISC is defined as IA32_MC24_MISC in SDM. - MSR_IA32_MC25_MISC is defined as IA32_MC25_MISC in SDM. - MSR_IA32_MC26_MISC is defined as IA32_MC26_MISC in SDM. - MSR_IA32_MC27_MISC is defined as IA32_MC27_MISC in SDM. - MSR_IA32_MC28_MISC is defined as IA32_MC28_MISC in SDM. - @{ -**/ -#define MSR_IA32_MC0_MISC 0x00000403 -#define MSR_IA32_MC1_MISC 0x00000407 -#define MSR_IA32_MC2_MISC 0x0000040B -#define MSR_IA32_MC3_MISC 0x0000040F -#define MSR_IA32_MC4_MISC 0x00000413 -#define MSR_IA32_MC5_MISC 0x00000417 -#define MSR_IA32_MC6_MISC 0x0000041B -#define MSR_IA32_MC7_MISC 0x0000041F -#define MSR_IA32_MC8_MISC 0x00000423 -#define MSR_IA32_MC9_MISC 0x00000427 -#define MSR_IA32_MC10_MISC 0x0000042B -#define MSR_IA32_MC11_MISC 0x0000042F -#define MSR_IA32_MC12_MISC 0x00000433 -#define MSR_IA32_MC13_MISC 0x00000437 -#define MSR_IA32_MC14_MISC 0x0000043B -#define MSR_IA32_MC15_MISC 0x0000043F -#define MSR_IA32_MC16_MISC 0x00000443 -#define MSR_IA32_MC17_MISC 0x00000447 -#define MSR_IA32_MC18_MISC 0x0000044B -#define MSR_IA32_MC19_MISC 0x0000044F -#define MSR_IA32_MC20_MISC 0x00000453 -#define MSR_IA32_MC21_MISC 0x00000457 -#define MSR_IA32_MC22_MISC 0x0000045B -#define MSR_IA32_MC23_MISC 0x0000045F -#define MSR_IA32_MC24_MISC 0x00000463 -#define MSR_IA32_MC25_MISC 0x00000467 -#define MSR_IA32_MC26_MISC 0x0000046B -#define MSR_IA32_MC27_MISC 0x0000046F -#define MSR_IA32_MC28_MISC 0x00000473 -/// @} - - -/** - Reporting Register of Basic VMX Capabilities (R/O) See Appendix A.1, "Basic - VMX Information.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_BASIC (0x00000480) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - MSR_IA32_VMX_BASIC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_BASIC); - @endcode - @note MSR_IA32_VMX_BASIC is defined as IA32_VMX_BASIC in SDM. -**/ -#define MSR_IA32_VMX_BASIC 0x00000480 - -/** - MSR information returned for MSR index #MSR_IA32_VMX_BASIC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 30:0] VMCS revision identifier used by the processor. Processors - /// that use the same VMCS revision identifier use the same size for VMCS - /// regions (see subsequent item on bits 44:32). - /// - /// @note Earlier versions of this manual specified that the VMCS revision - /// identifier was a 32-bit field in bits 31:0 of this MSR. For all - /// processors produced prior to this change, bit 31 of this MSR was read - /// as 0. - /// - UINT32 VmcsRevisonId:31; - UINT32 MustBeZero:1; - /// - /// [Bit 44:32] Reports the number of bytes that software should allocate - /// for the VMXON region and any VMCS region. It is a value greater than - /// 0 and at most 4096(bit 44 is set if and only if bits 43:32 are clear). - /// - UINT32 VmcsSize:13; - UINT32 Reserved1:3; - /// - /// [Bit 48] Indicates the width of the physical addresses that may be used - /// for the VMXON region, each VMCS, and data structures referenced by - /// pointers in a VMCS (I/O bitmaps, virtual-APIC page, MSR areas for VMX - /// transitions). If the bit is 0, these addresses are limited to the - /// processor's physical-address width. If the bit is 1, these addresses - /// are limited to 32 bits. This bit is always 0 for processors that - /// support Intel 64 architecture. - /// - /// @note On processors that support Intel 64 architecture, the pointer - /// must not set bits beyond the processor's physical address width. - /// - UINT32 VmcsAddressWidth:1; - /// - /// [Bit 49] If bit 49 is read as 1, the logical processor supports the - /// dual-monitor treatment of system-management interrupts and - /// system-management mode. See Section 34.15 for details of this treatment. - /// - UINT32 DualMonitor:1; - /// - /// [Bit 53:50] report the memory type that should be used for the VMCS, - /// for data structures referenced by pointers in the VMCS (I/O bitmaps, - /// virtual-APIC page, MSR areas for VMX transitions), and for the MSEG - /// header. If software needs to access these data structures (e.g., to - /// modify the contents of the MSR bitmaps), it can configure the paging - /// structures to map them into the linear-address space. If it does so, - /// it should establish mappings that use the memory type reported bits - /// 53:50 in this MSR. - /// - /// As of this writing, all processors that support VMX operation indicate - /// the write-back type. - /// - /// If software needs to access these data structures (e.g., to modify - /// the contents of the MSR bitmaps), it can configure the paging - /// structures to map them into the linear-address space. If it does so, - /// it should establish mappings that use the memory type reported in this - /// MSR. - /// - /// @note Alternatively, software may map any of these regions or - /// structures with the UC memory type. (This may be necessary for the MSEG - /// header.) Doing so is discouraged unless necessary as it will cause the - /// performance of software accesses to those structures to suffer. - /// - /// - UINT32 MemoryType:4; - /// - /// [Bit 54] If bit 54 is read as 1, the processor reports information in - /// the VM-exit instruction-information field on VM exitsdue to execution - /// of the INS and OUTS instructions (see Section 27.2.4). This reporting - /// is done only if this bit is read as 1. - /// - UINT32 InsOutsReporting:1; - /// - /// [Bit 55] Bit 55 is read as 1 if any VMX controls that default to 1 may - /// be cleared to 0. See Appendix A.2 for details. It also reports support - /// for the VMX capability MSRs IA32_VMX_TRUE_PINBASED_CTLS, - /// IA32_VMX_TRUE_PROCBASED_CTLS, IA32_VMX_TRUE_EXIT_CTLS, and - /// IA32_VMX_TRUE_ENTRY_CTLS. See Appendix A.3.1, Appendix A.3.2, - /// Appendix A.4, and Appendix A.5 for details. - /// - UINT32 VmxControls:1; - UINT32 Reserved2:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_VMX_BASIC_REGISTER; - -/// -/// @{ Define value for bit field MSR_IA32_VMX_BASIC_REGISTER.MemoryType -/// -#define MSR_IA32_VMX_BASIC_REGISTER_MEMORY_TYPE_UNCACHEABLE 0x00 -#define MSR_IA32_VMX_BASIC_REGISTER_MEMORY_TYPE_WRITE_BACK 0x06 -/// -/// @} -/// - - -/** - Capability Reporting Register of Pinbased VM-execution Controls (R/O) See - Appendix A.3.1, "Pin-Based VMExecution Controls.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_PINBASED_CTLS (0x00000481) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_PINBASED_CTLS); - @endcode - @note MSR_IA32_VMX_PINBASED_CTLS is defined as IA32_VMX_PINBASED_CTLS in SDM. -**/ -#define MSR_IA32_VMX_PINBASED_CTLS 0x00000481 - - -/** - Capability Reporting Register of Primary Processor-based VM-execution - Controls (R/O) See Appendix A.3.2, "Primary Processor- Based VM-Execution - Controls.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_PROCBASED_CTLS (0x00000482) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_PROCBASED_CTLS); - @endcode - @note MSR_IA32_VMX_PROCBASED_CTLS is defined as IA32_VMX_PROCBASED_CTLS in SDM. -**/ -#define MSR_IA32_VMX_PROCBASED_CTLS 0x00000482 - - -/** - Capability Reporting Register of VM-exit Controls (R/O) See Appendix A.4, - "VM-Exit Controls.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_EXIT_CTLS (0x00000483) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_EXIT_CTLS); - @endcode - @note MSR_IA32_VMX_EXIT_CTLS is defined as IA32_VMX_EXIT_CTLS in SDM. -**/ -#define MSR_IA32_VMX_EXIT_CTLS 0x00000483 - - -/** - Capability Reporting Register of VMentry Controls (R/O) See Appendix A.5, - "VM-Entry Controls.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_ENTRY_CTLS (0x00000484) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_ENTRY_CTLS); - @endcode - @note MSR_IA32_VMX_ENTRY_CTLS is defined as IA32_VMX_ENTRY_CTLS in SDM. -**/ -#define MSR_IA32_VMX_ENTRY_CTLS 0x00000484 - - -/** - Reporting Register of Miscellaneous VMX Capabilities (R/O) See Appendix A.6, - "Miscellaneous Data.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_MISC (0x00000485) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - IA32_VMX_MISC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_MISC); - @endcode - @note MSR_IA32_VMX_MISC is defined as IA32_VMX_MISC in SDM. -**/ -#define MSR_IA32_VMX_MISC 0x00000485 - -/** - MSR information returned for MSR index #IA32_VMX_MISC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Reports a value X that specifies the relationship between the - /// rate of the VMX-preemption timer and that of the timestamp counter (TSC). - /// Specifically, the VMX-preemption timer (if it is active) counts down by - /// 1 every time bit X in the TSC changes due to a TSC increment. - /// - UINT32 VmxTimerRatio:5; - /// - /// [Bit 5] If bit 5 is read as 1, VM exits store the value of IA32_EFER.LMA - /// into the "IA-32e mode guest" VM-entry control;see Section 27.2 for more - /// details. This bit is read as 1 on any logical processor that supports - /// the 1-setting of the "unrestricted guest" VM-execution control. - /// - UINT32 VmExitEferLma:1; - /// - /// [Bit 6] reports (if set) the support for activity state 1 (HLT). - /// - UINT32 HltActivityStateSupported:1; - /// - /// [Bit 7] reports (if set) the support for activity state 2 (shutdown). - /// - UINT32 ShutdownActivityStateSupported:1; - /// - /// [Bit 8] reports (if set) the support for activity state 3 (wait-for-SIPI). - /// - UINT32 WaitForSipiActivityStateSupported:1; - UINT32 Reserved1:5; - /// - /// [Bit 14] If read as 1, Intel(R) Processor Trace (Intel PT) can be used - /// in VMX operation. If the processor supports Intel PT but does not allow - /// it to be used in VMX operation, execution of VMXON clears - /// IA32_RTIT_CTL.TraceEn (see "VMXON-Enter VMX Operation" in Chapter 30); - /// any attempt to set that bit while in VMX operation (including VMX root - /// operation) using the WRMSR instruction causes a general-protection - /// exception. - /// - UINT32 ProcessorTraceSupported:1; - /// - /// [Bit 15] If read as 1, the RDMSR instruction can be used in system- - /// management mode (SMM) to read the IA32_SMBASE MSR (MSR address 9EH). - /// See Section 34.15.6.3. - /// - UINT32 SmBaseMsrSupported:1; - /// - /// [Bits 24:16] Indicate the number of CR3-target values supported by the - /// processor. This number is a value between 0 and 256, inclusive (bit 24 - /// is set if and only if bits 23:16 are clear). - /// - UINT32 NumberOfCr3TargetValues:9; - /// - /// [Bit 27:25] Bits 27:25 is used to compute the recommended maximum - /// number of MSRs that should appear in the VM-exit MSR-store list, the - /// VM-exit MSR-load list, or the VM-entry MSR-load list. Specifically, if - /// the value bits 27:25 of IA32_VMX_MISC is N, then 512 * (N + 1) is the - /// recommended maximum number of MSRs to be included in each list. If the - /// limit is exceeded, undefined processor behavior may result (including a - /// machine check during the VMX transition). - /// - UINT32 MsrStoreListMaximum:3; - /// - /// [Bit 28] If read as 1, bit 2 of the IA32_SMM_MONITOR_CTL can be set - /// to 1. VMXOFF unblocks SMIs unless IA32_SMM_MONITOR_CTL[bit 2] is 1 - /// (see Section 34.14.4). - /// - UINT32 BlockSmiSupported:1; - /// - /// [Bit 29] read as 1, software can use VMWRITE to write to any supported - /// field in the VMCS; otherwise, VMWRITE cannot be used to modify VM-exit - /// information fields. - /// - UINT32 VmWriteSupported:1; - /// - /// [Bit 30] If read as 1, VM entry allows injection of a software - /// interrupt, software exception, or privileged software exception with an - /// instruction length of 0. - /// - UINT32 VmInjectSupported:1; - UINT32 Reserved2:1; - /// - /// [Bits 63:32] Reports the 32-bit MSEG revision identifier used by the - /// processor. - /// - UINT32 MsegRevisionIdentifier:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} IA32_VMX_MISC_REGISTER; - - -/** - Capability Reporting Register of CR0 Bits Fixed to 0 (R/O) See Appendix A.7, - "VMX-Fixed Bits in CR0.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_CR0_FIXED0 (0x00000486) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_CR0_FIXED0); - @endcode - @note MSR_IA32_VMX_CR0_FIXED0 is defined as IA32_VMX_CR0_FIXED0 in SDM. -**/ -#define MSR_IA32_VMX_CR0_FIXED0 0x00000486 - - -/** - Capability Reporting Register of CR0 Bits Fixed to 1 (R/O) See Appendix A.7, - "VMX-Fixed Bits in CR0.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_CR0_FIXED1 (0x00000487) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_CR0_FIXED1); - @endcode - @note MSR_IA32_VMX_CR0_FIXED1 is defined as IA32_VMX_CR0_FIXED1 in SDM. -**/ -#define MSR_IA32_VMX_CR0_FIXED1 0x00000487 - - -/** - Capability Reporting Register of CR4 Bits Fixed to 0 (R/O) See Appendix A.8, - "VMX-Fixed Bits in CR4.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_CR4_FIXED0 (0x00000488) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_CR4_FIXED0); - @endcode - @note MSR_IA32_VMX_CR4_FIXED0 is defined as IA32_VMX_CR4_FIXED0 in SDM. -**/ -#define MSR_IA32_VMX_CR4_FIXED0 0x00000488 - - -/** - Capability Reporting Register of CR4 Bits Fixed to 1 (R/O) See Appendix A.8, - "VMX-Fixed Bits in CR4.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_CR4_FIXED1 (0x00000489) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_CR4_FIXED1); - @endcode - @note MSR_IA32_VMX_CR4_FIXED1 is defined as IA32_VMX_CR4_FIXED1 in SDM. -**/ -#define MSR_IA32_VMX_CR4_FIXED1 0x00000489 - - -/** - Capability Reporting Register of VMCS Field Enumeration (R/O) See Appendix - A.9, "VMCS Enumeration.". If CPUID.01H:ECX.[5] = 1. - - @param ECX MSR_IA32_VMX_VMCS_ENUM (0x0000048A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_VMCS_ENUM); - @endcode - @note MSR_IA32_VMX_VMCS_ENUM is defined as IA32_VMX_VMCS_ENUM in SDM. -**/ -#define MSR_IA32_VMX_VMCS_ENUM 0x0000048A - - -/** - Capability Reporting Register of Secondary Processor-based VM-execution - Controls (R/O) See Appendix A.3.3, "Secondary Processor- Based VM-Execution - Controls.". If ( CPUID.01H:ECX.[5] && IA32_VMX_PROCBASED_C TLS[63]). - - @param ECX MSR_IA32_VMX_PROCBASED_CTLS2 (0x0000048B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_PROCBASED_CTLS2); - @endcode - @note MSR_IA32_VMX_PROCBASED_CTLS2 is defined as IA32_VMX_PROCBASED_CTLS2 in SDM. -**/ -#define MSR_IA32_VMX_PROCBASED_CTLS2 0x0000048B - - -/** - Capability Reporting Register of EPT and VPID (R/O) See Appendix A.10, - "VPID and EPT Capabilities.". If ( CPUID.01H:ECX.[5] && IA32_VMX_PROCBASED_C - TLS[63] && ( IA32_VMX_PROCBASED_C TLS2[33] IA32_VMX_PROCBASED_C TLS2[37]) ). - - @param ECX MSR_IA32_VMX_EPT_VPID_CAP (0x0000048C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_EPT_VPID_CAP); - @endcode - @note MSR_IA32_VMX_EPT_VPID_CAP is defined as IA32_VMX_EPT_VPID_CAP in SDM. -**/ -#define MSR_IA32_VMX_EPT_VPID_CAP 0x0000048C - - -/** - Capability Reporting Register of Pinbased VM-execution Flex Controls (R/O) - See Appendix A.3.1, "Pin-Based VMExecution Controls.". If ( - CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). - - @param ECX MSR_IA32_VMX_TRUE_PINBASED_CTLS (0x0000048D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_PINBASED_CTLS); - @endcode - @note MSR_IA32_VMX_TRUE_PINBASED_CTLS is defined as IA32_VMX_TRUE_PINBASED_CTLS in SDM. -**/ -#define MSR_IA32_VMX_TRUE_PINBASED_CTLS 0x0000048D - - -/** - Capability Reporting Register of Primary Processor-based VM-execution Flex - Controls (R/O) See Appendix A.3.2, "Primary Processor- Based VM-Execution - Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). - - @param ECX MSR_IA32_VMX_TRUE_PROCBASED_CTLS (0x0000048E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_PROCBASED_CTLS); - @endcode - @note MSR_IA32_VMX_TRUE_PROCBASED_CTLS is defined as IA32_VMX_TRUE_PROCBASED_CTLS in SDM. -**/ -#define MSR_IA32_VMX_TRUE_PROCBASED_CTLS 0x0000048E - - -/** - Capability Reporting Register of VM-exit Flex Controls (R/O) See Appendix - A.4, "VM-Exit Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). - - @param ECX MSR_IA32_VMX_TRUE_EXIT_CTLS (0x0000048F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_EXIT_CTLS); - @endcode - @note MSR_IA32_VMX_TRUE_EXIT_CTLS is defined as IA32_VMX_TRUE_EXIT_CTLS in SDM. -**/ -#define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048F - - -/** - Capability Reporting Register of VMentry Flex Controls (R/O) See Appendix - A.5, "VM-Entry Controls.". If( CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). - - @param ECX MSR_IA32_VMX_TRUE_ENTRY_CTLS (0x00000490) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_TRUE_ENTRY_CTLS); - @endcode - @note MSR_IA32_VMX_TRUE_ENTRY_CTLS is defined as IA32_VMX_TRUE_ENTRY_CTLS in SDM. -**/ -#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 - - -/** - Capability Reporting Register of VMfunction Controls (R/O). If( - CPUID.01H:ECX.[5] = 1 && IA32_VMX_BASIC[55] ). - - @param ECX MSR_IA32_VMX_VMFUNC (0x00000491) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_VMX_VMFUNC); - @endcode - @note MSR_IA32_VMX_VMFUNC is defined as IA32_VMX_VMFUNC in SDM. -**/ -#define MSR_IA32_VMX_VMFUNC 0x00000491 - - -/** - Full Width Writable IA32_PMCn Alias (R/W). (If CPUID.0AH: EAX[15:8] > n) && - IA32_PERF_CAPABILITIES[ 13] = 1. - - @param ECX MSR_IA32_A_PMCn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_A_PMC0); - AsmWriteMsr64 (MSR_IA32_A_PMC0, Msr); - @endcode - @note MSR_IA32_A_PMC0 is defined as IA32_A_PMC0 in SDM. - MSR_IA32_A_PMC1 is defined as IA32_A_PMC1 in SDM. - MSR_IA32_A_PMC2 is defined as IA32_A_PMC2 in SDM. - MSR_IA32_A_PMC3 is defined as IA32_A_PMC3 in SDM. - MSR_IA32_A_PMC4 is defined as IA32_A_PMC4 in SDM. - MSR_IA32_A_PMC5 is defined as IA32_A_PMC5 in SDM. - MSR_IA32_A_PMC6 is defined as IA32_A_PMC6 in SDM. - MSR_IA32_A_PMC7 is defined as IA32_A_PMC7 in SDM. - @{ -**/ -#define MSR_IA32_A_PMC0 0x000004C1 -#define MSR_IA32_A_PMC1 0x000004C2 -#define MSR_IA32_A_PMC2 0x000004C3 -#define MSR_IA32_A_PMC3 0x000004C4 -#define MSR_IA32_A_PMC4 0x000004C5 -#define MSR_IA32_A_PMC5 0x000004C6 -#define MSR_IA32_A_PMC6 0x000004C7 -#define MSR_IA32_A_PMC7 0x000004C8 -/// @} - - -/** - (R/W). If IA32_MCG_CAP.LMCE_P =1. - - @param ECX MSR_IA32_MCG_EXT_CTL (0x000004D0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_MCG_EXT_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_MCG_EXT_CTL_REGISTER. - - Example usage - @code - MSR_IA32_MCG_EXT_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_EXT_CTL); - AsmWriteMsr64 (MSR_IA32_MCG_EXT_CTL, Msr.Uint64); - @endcode - @note MSR_IA32_MCG_EXT_CTL is defined as IA32_MCG_EXT_CTL in SDM. -**/ -#define MSR_IA32_MCG_EXT_CTL 0x000004D0 - -/** - MSR information returned for MSR index #MSR_IA32_MCG_EXT_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] LMCE_EN. - /// - UINT32 LMCE_EN:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_MCG_EXT_CTL_REGISTER; - - -/** - Status and SVN Threshold of SGX Support for ACM (RO). If CPUID.(EAX=07H, - ECX=0H): EBX[2] = 1. - - @param ECX MSR_IA32_SGX_SVN_STATUS (0x00000500) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_SGX_SVN_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_SGX_SVN_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_SGX_SVN_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_SGX_SVN_STATUS); - @endcode - @note MSR_IA32_SGX_SVN_STATUS is defined as IA32_SGX_SVN_STATUS in SDM. -**/ -#define MSR_IA32_SGX_SVN_STATUS 0x00000500 - -/** - MSR information returned for MSR index #MSR_IA32_SGX_SVN_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock. See Section 42.11.3, "Interactions with Authenticated - /// Code Modules (ACMs)". - /// - UINT32 Lock:1; - UINT32 Reserved1:15; - /// - /// [Bits 23:16] SGX_SVN_SINIT. See Section 42.11.3, "Interactions with - /// Authenticated Code Modules (ACMs)". - /// - UINT32 SGX_SVN_SINIT:8; - UINT32 Reserved2:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_SGX_SVN_STATUS_REGISTER; - - -/** - Trace Output Base Register (R/W). If ((CPUID.(EAX=07H, ECX=0):EBX[25] = 1) - && ( (CPUID.(EAX=14H,ECX=0): ECX[0] = 1) (CPUID.(EAX=14H,ECX=0): ECX[2] = 1) - ) ). - - @param ECX MSR_IA32_RTIT_OUTPUT_BASE (0x00000560) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_OUTPUT_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_OUTPUT_BASE_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_OUTPUT_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_OUTPUT_BASE); - AsmWriteMsr64 (MSR_IA32_RTIT_OUTPUT_BASE, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_OUTPUT_BASE is defined as IA32_RTIT_OUTPUT_BASE in SDM. -**/ -#define MSR_IA32_RTIT_OUTPUT_BASE 0x00000560 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_OUTPUT_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:7; - /// - /// [Bits 31:7] Base physical address. - /// - UINT32 Base:25; - /// - /// [Bits 63:32] Base physical address. - /// - UINT32 BaseHi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_OUTPUT_BASE_REGISTER; - - -/** - Trace Output Mask Pointers Register (R/W). If ((CPUID.(EAX=07H, - ECX=0):EBX[25] = 1) && ( (CPUID.(EAX=14H,ECX=0): ECX[0] = 1) - (CPUID.(EAX=14H,ECX=0): ECX[2] = 1) ) ). - - @param ECX MSR_IA32_RTIT_OUTPUT_MASK_PTRS (0x00000561) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_OUTPUT_MASK_PTRS); - AsmWriteMsr64 (MSR_IA32_RTIT_OUTPUT_MASK_PTRS, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_OUTPUT_MASK_PTRS is defined as IA32_RTIT_OUTPUT_MASK_PTRS in SDM. -**/ -#define MSR_IA32_RTIT_OUTPUT_MASK_PTRS 0x00000561 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_OUTPUT_MASK_PTRS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:7; - /// - /// [Bits 31:7] MaskOrTableOffset. - /// - UINT32 MaskOrTableOffset:25; - /// - /// [Bits 63:32] Output Offset. - /// - UINT32 OutputOffset:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_OUTPUT_MASK_PTRS_REGISTER; - - -/** - Trace Control Register (R/W). If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). - - @param ECX MSR_IA32_RTIT_CTL (0x00000570) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_CTL_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_CTL); - AsmWriteMsr64 (MSR_IA32_RTIT_CTL, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_CTL is defined as IA32_RTIT_CTL in SDM. -**/ -#define MSR_IA32_RTIT_CTL 0x00000570 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] TraceEn. - /// - UINT32 TraceEn:1; - /// - /// [Bit 1] CYCEn. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). - /// - UINT32 CYCEn:1; - /// - /// [Bit 2] OS. - /// - UINT32 OS:1; - /// - /// [Bit 3] User. - /// - UINT32 User:1; - UINT32 Reserved1:2; - /// - /// [Bit 6] FabricEn. If (CPUID.(EAX=07H, ECX=0):ECX[3] = 1). - /// - UINT32 FabricEn:1; - /// - /// [Bit 7] CR3 filter. - /// - UINT32 CR3:1; - /// - /// [Bit 8] ToPA. - /// - UINT32 ToPA:1; - /// - /// [Bit 9] MTCEn. If (CPUID.(EAX=07H, ECX=0):EBX[3] = 1). - /// - UINT32 MTCEn:1; - /// - /// [Bit 10] TSCEn. - /// - UINT32 TSCEn:1; - /// - /// [Bit 11] DisRETC. - /// - UINT32 DisRETC:1; - UINT32 Reserved2:1; - /// - /// [Bit 13] BranchEn. - /// - UINT32 BranchEn:1; - /// - /// [Bits 17:14] MTCFreq. If (CPUID.(EAX=07H, ECX=0):EBX[3] = 1). - /// - UINT32 MTCFreq:4; - UINT32 Reserved3:1; - /// - /// [Bits 22:19] CYCThresh. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). - /// - UINT32 CYCThresh:4; - UINT32 Reserved4:1; - /// - /// [Bits 27:24] PSBFreq. If (CPUID.(EAX=07H, ECX=0):EBX[1] = 1). - /// - UINT32 PSBFreq:4; - UINT32 Reserved5:4; - /// - /// [Bits 35:32] ADDR0_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 0). - /// - UINT32 ADDR0_CFG:4; - /// - /// [Bits 39:36] ADDR1_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 1). - /// - UINT32 ADDR1_CFG:4; - /// - /// [Bits 43:40] ADDR2_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 2). - /// - UINT32 ADDR2_CFG:4; - /// - /// [Bits 47:44] ADDR3_CFG. If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > 3). - /// - UINT32 ADDR3_CFG:4; - UINT32 Reserved6:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_CTL_REGISTER; - - -/** - Tracing Status Register (R/W). If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). - - @param ECX MSR_IA32_RTIT_STATUS (0x00000571) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_STATUS); - AsmWriteMsr64 (MSR_IA32_RTIT_STATUS, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_STATUS is defined as IA32_RTIT_STATUS in SDM. -**/ -#define MSR_IA32_RTIT_STATUS 0x00000571 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] FilterEn, (writes ignored). - /// If (CPUID.(EAX=07H, ECX=0):EBX[2] = 1). - /// - UINT32 FilterEn:1; - /// - /// [Bit 1] ContexEn, (writes ignored). - /// - UINT32 ContexEn:1; - /// - /// [Bit 2] TriggerEn, (writes ignored). - /// - UINT32 TriggerEn:1; - UINT32 Reserved1:1; - /// - /// [Bit 4] Error. - /// - UINT32 Error:1; - /// - /// [Bit 5] Stopped. - /// - UINT32 Stopped:1; - UINT32 Reserved2:26; - /// - /// [Bits 48:32] PacketByteCnt. If (CPUID.(EAX=07H, ECX=0):EBX[1] > 3). - /// - UINT32 PacketByteCnt:17; - UINT32 Reserved3:15; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_STATUS_REGISTER; - - -/** - Trace Filter CR3 Match Register (R/W). - If (CPUID.(EAX=07H, ECX=0):EBX[25] = 1). - - @param ECX MSR_IA32_RTIT_CR3_MATCH (0x00000572) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_CR3_MATCH_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_CR3_MATCH_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_CR3_MATCH_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_CR3_MATCH); - AsmWriteMsr64 (MSR_IA32_RTIT_CR3_MATCH, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_CR3_MATCH is defined as IA32_RTIT_CR3_MATCH in SDM. -**/ -#define MSR_IA32_RTIT_CR3_MATCH 0x00000572 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_CR3_MATCH -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:5; - /// - /// [Bits 31:5] CR3[63:5] value to match. - /// - UINT32 Cr3:27; - /// - /// [Bits 63:32] CR3[63:5] value to match. - /// - UINT32 Cr3Hi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_CR3_MATCH_REGISTER; - - -/** - Region n Start Address (R/W). If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > n). - - @param ECX MSR_IA32_RTIT_ADDRn_A - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_ADDR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_ADDR_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_ADDR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_ADDR0_A); - AsmWriteMsr64 (MSR_IA32_RTIT_ADDR0_A, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_ADDR0_A is defined as IA32_RTIT_ADDR0_A in SDM. - MSR_IA32_RTIT_ADDR1_A is defined as IA32_RTIT_ADDR1_A in SDM. - MSR_IA32_RTIT_ADDR2_A is defined as IA32_RTIT_ADDR2_A in SDM. - MSR_IA32_RTIT_ADDR3_A is defined as IA32_RTIT_ADDR3_A in SDM. - @{ -**/ -#define MSR_IA32_RTIT_ADDR0_A 0x00000580 -#define MSR_IA32_RTIT_ADDR1_A 0x00000582 -#define MSR_IA32_RTIT_ADDR2_A 0x00000584 -#define MSR_IA32_RTIT_ADDR3_A 0x00000586 -/// @} - - -/** - Region n End Address (R/W). If (CPUID.(EAX=07H, ECX=1):EAX[2:0] > n). - - @param ECX MSR_IA32_RTIT_ADDRn_B - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_ADDR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_RTIT_ADDR_REGISTER. - - Example usage - @code - MSR_IA32_RTIT_ADDR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_RTIT_ADDR0_B); - AsmWriteMsr64 (MSR_IA32_RTIT_ADDR0_B, Msr.Uint64); - @endcode - @note MSR_IA32_RTIT_ADDR0_B is defined as IA32_RTIT_ADDR0_B in SDM. - MSR_IA32_RTIT_ADDR1_B is defined as IA32_RTIT_ADDR1_B in SDM. - MSR_IA32_RTIT_ADDR2_B is defined as IA32_RTIT_ADDR2_B in SDM. - MSR_IA32_RTIT_ADDR3_B is defined as IA32_RTIT_ADDR3_B in SDM. - @{ -**/ -#define MSR_IA32_RTIT_ADDR0_B 0x00000581 -#define MSR_IA32_RTIT_ADDR1_B 0x00000583 -#define MSR_IA32_RTIT_ADDR2_B 0x00000585 -#define MSR_IA32_RTIT_ADDR3_B 0x00000587 -/// @} - - -/** - MSR information returned for MSR indexes - #MSR_IA32_RTIT_ADDR0_A to #MSR_IA32_RTIT_ADDR3_A and - #MSR_IA32_RTIT_ADDR0_B to #MSR_IA32_RTIT_ADDR3_B -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Virtual Address. - /// - UINT32 VirtualAddress:32; - /// - /// [Bits 47:32] Virtual Address. - /// - UINT32 VirtualAddressHi:16; - /// - /// [Bits 63:48] SignExt_VA. - /// - UINT32 SignExt_VA:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_RTIT_ADDR_REGISTER; - - -/** - DS Save Area (R/W) Points to the linear address of the first byte of the DS - buffer management area, which is used to manage the BTS and PEBS buffers. - See Section 18.15.4, "Debug Store (DS) Mechanism.". If( CPUID.01H:EDX.DS[21] - = 1. - - [Bits 31..0] The linear address of the first byte of the DS buffer - management area, if not in IA-32e mode. - - [Bits 63..0] The linear address of the first byte of the DS buffer - management area, if IA-32e mode is active. - - @param ECX MSR_IA32_DS_AREA (0x00000600) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_DS_AREA_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_DS_AREA_REGISTER. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_DS_AREA); - AsmWriteMsr64 (MSR_IA32_DS_AREA, Msr); - @endcode - @note MSR_IA32_DS_AREA is defined as IA32_DS_AREA in SDM. -**/ -#define MSR_IA32_DS_AREA 0x00000600 - - -/** - TSC Target of Local APIC's TSC Deadline Mode (R/W). If CPUID.01H:ECX.[24] = - 1. - - @param ECX MSR_IA32_TSC_DEADLINE (0x000006E0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_TSC_DEADLINE); - AsmWriteMsr64 (MSR_IA32_TSC_DEADLINE, Msr); - @endcode - @note MSR_IA32_TSC_DEADLINE is defined as IA32_TSC_DEADLINE in SDM. -**/ -#define MSR_IA32_TSC_DEADLINE 0x000006E0 - - -/** - Enable/disable HWP (R/W). If CPUID.06H:EAX.[7] = 1. - - @param ECX MSR_IA32_PM_ENABLE (0x00000770) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PM_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PM_ENABLE_REGISTER. - - Example usage - @code - MSR_IA32_PM_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PM_ENABLE); - AsmWriteMsr64 (MSR_IA32_PM_ENABLE, Msr.Uint64); - @endcode - @note MSR_IA32_PM_ENABLE is defined as IA32_PM_ENABLE in SDM. -**/ -#define MSR_IA32_PM_ENABLE 0x00000770 - -/** - MSR information returned for MSR index #MSR_IA32_PM_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] HWP_ENABLE (R/W1-Once). See Section 14.4.2, "Enabling HWP". If - /// CPUID.06H:EAX.[7] = 1. - /// - UINT32 HWP_ENABLE:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PM_ENABLE_REGISTER; - - -/** - HWP Performance Range Enumeration (RO). If CPUID.06H:EAX.[7] = 1. - - @param ECX MSR_IA32_HWP_CAPABILITIES (0x00000771) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_HWP_CAPABILITIES_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_HWP_CAPABILITIES_REGISTER. - - Example usage - @code - MSR_IA32_HWP_CAPABILITIES_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_CAPABILITIES); - @endcode - @note MSR_IA32_HWP_CAPABILITIES is defined as IA32_HWP_CAPABILITIES in SDM. -**/ -#define MSR_IA32_HWP_CAPABILITIES 0x00000771 - -/** - MSR information returned for MSR index #MSR_IA32_HWP_CAPABILITIES -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Highest_Performance See Section 14.4.3, "HWP Performance - /// Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Highest_Performance:8; - /// - /// [Bits 15:8] Guaranteed_Performance See Section 14.4.3, "HWP - /// Performance Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Guaranteed_Performance:8; - /// - /// [Bits 23:16] Most_Efficient_Performance See Section 14.4.3, "HWP - /// Performance Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Most_Efficient_Performance:8; - /// - /// [Bits 31:24] Lowest_Performance See Section 14.4.3, "HWP Performance - /// Range and Dynamic Capabilities". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Lowest_Performance:8; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_HWP_CAPABILITIES_REGISTER; - - -/** - Power Management Control Hints for All Logical Processors in a Package - (R/W). If CPUID.06H:EAX.[11] = 1. - - @param ECX MSR_IA32_HWP_REQUEST_PKG (0x00000772) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_HWP_REQUEST_PKG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_HWP_REQUEST_PKG_REGISTER. - - Example usage - @code - MSR_IA32_HWP_REQUEST_PKG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_REQUEST_PKG); - AsmWriteMsr64 (MSR_IA32_HWP_REQUEST_PKG, Msr.Uint64); - @endcode - @note MSR_IA32_HWP_REQUEST_PKG is defined as IA32_HWP_REQUEST_PKG in SDM. -**/ -#define MSR_IA32_HWP_REQUEST_PKG 0x00000772 - -/** - MSR information returned for MSR index #MSR_IA32_HWP_REQUEST_PKG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Minimum_Performance See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[11] = 1. - /// - UINT32 Minimum_Performance:8; - /// - /// [Bits 15:8] Maximum_Performance See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[11] = 1. - /// - UINT32 Maximum_Performance:8; - /// - /// [Bits 23:16] Desired_Performance See Section 14.4.4, "Managing HWP". - /// If CPUID.06H:EAX.[11] = 1. - /// - UINT32 Desired_Performance:8; - /// - /// [Bits 31:24] Energy_Performance_Preference See Section 14.4.4, - /// "Managing HWP". If CPUID.06H:EAX.[11] = 1 && CPUID.06H:EAX.[10] = 1. - /// - UINT32 Energy_Performance_Preference:8; - /// - /// [Bits 41:32] Activity_Window See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[11] = 1 && CPUID.06H:EAX.[9] = 1. - /// - UINT32 Activity_Window:10; - UINT32 Reserved:22; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_HWP_REQUEST_PKG_REGISTER; - - -/** - Control HWP Native Interrupts (R/W). If CPUID.06H:EAX.[8] = 1. - - @param ECX MSR_IA32_HWP_INTERRUPT (0x00000773) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_HWP_INTERRUPT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_HWP_INTERRUPT_REGISTER. - - Example usage - @code - MSR_IA32_HWP_INTERRUPT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_INTERRUPT); - AsmWriteMsr64 (MSR_IA32_HWP_INTERRUPT, Msr.Uint64); - @endcode - @note MSR_IA32_HWP_INTERRUPT is defined as IA32_HWP_INTERRUPT in SDM. -**/ -#define MSR_IA32_HWP_INTERRUPT 0x00000773 - -/** - MSR information returned for MSR index #MSR_IA32_HWP_INTERRUPT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] EN_Guaranteed_Performance_Change. See Section 14.4.6, "HWP - /// Notifications". If CPUID.06H:EAX.[8] = 1. - /// - UINT32 EN_Guaranteed_Performance_Change:1; - /// - /// [Bit 1] EN_Excursion_Minimum. See Section 14.4.6, "HWP Notifications". - /// If CPUID.06H:EAX.[8] = 1. - /// - UINT32 EN_Excursion_Minimum:1; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_HWP_INTERRUPT_REGISTER; - - -/** - Power Management Control Hints to a Logical Processor (R/W). If - CPUID.06H:EAX.[7] = 1. - - @param ECX MSR_IA32_HWP_REQUEST (0x00000774) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_HWP_REQUEST_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_HWP_REQUEST_REGISTER. - - Example usage - @code - MSR_IA32_HWP_REQUEST_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_REQUEST); - AsmWriteMsr64 (MSR_IA32_HWP_REQUEST, Msr.Uint64); - @endcode - @note MSR_IA32_HWP_REQUEST is defined as IA32_HWP_REQUEST in SDM. -**/ -#define MSR_IA32_HWP_REQUEST 0x00000774 - -/** - MSR information returned for MSR index #MSR_IA32_HWP_REQUEST -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Minimum_Performance See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[7] = 1. - /// - UINT32 Minimum_Performance:8; - /// - /// [Bits 15:8] Maximum_Performance See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[7] = 1. - /// - UINT32 Maximum_Performance:8; - /// - /// [Bits 23:16] Desired_Performance See Section 14.4.4, "Managing HWP". - /// If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Desired_Performance:8; - /// - /// [Bits 31:24] Energy_Performance_Preference See Section 14.4.4, - /// "Managing HWP". If CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[10] = 1. - /// - UINT32 Energy_Performance_Preference:8; - /// - /// [Bits 41:32] Activity_Window See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[9] = 1. - /// - UINT32 Activity_Window:10; - /// - /// [Bit 42] Package_Control See Section 14.4.4, "Managing HWP". If - /// CPUID.06H:EAX.[7] = 1 && CPUID.06H:EAX.[11] = 1. - /// - UINT32 Package_Control:1; - UINT32 Reserved:21; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_HWP_REQUEST_REGISTER; - - -/** - Log bits indicating changes to Guaranteed & excursions to Minimum (R/W). If - CPUID.06H:EAX.[7] = 1. - - @param ECX MSR_IA32_HWP_STATUS (0x00000777) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_HWP_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_HWP_STATUS_REGISTER. - - Example usage - @code - MSR_IA32_HWP_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_HWP_STATUS); - AsmWriteMsr64 (MSR_IA32_HWP_STATUS, Msr.Uint64); - @endcode - @note MSR_IA32_HWP_STATUS is defined as IA32_HWP_STATUS in SDM. -**/ -#define MSR_IA32_HWP_STATUS 0x00000777 - -/** - MSR information returned for MSR index #MSR_IA32_HWP_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Guaranteed_Performance_Change (R/WC0). See Section 14.4.5, - /// "HWP Feedback". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Guaranteed_Performance_Change:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Excursion_To_Minimum (R/WC0). See Section 14.4.5, "HWP - /// Feedback". If CPUID.06H:EAX.[7] = 1. - /// - UINT32 Excursion_To_Minimum:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_HWP_STATUS_REGISTER; - - -/** - x2APIC ID Register (R/O) See x2APIC Specification. If CPUID.01H:ECX[21] = 1 - && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_APICID (0x00000802) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_APICID); - @endcode - @note MSR_IA32_X2APIC_APICID is defined as IA32_X2APIC_APICID in SDM. -**/ -#define MSR_IA32_X2APIC_APICID 0x00000802 - - -/** - x2APIC Version Register (R/O). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_VERSION (0x00000803) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_VERSION); - @endcode - @note MSR_IA32_X2APIC_VERSION is defined as IA32_X2APIC_VERSION in SDM. -**/ -#define MSR_IA32_X2APIC_VERSION 0x00000803 - - -/** - x2APIC Task Priority Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_TPR (0x00000808) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_TPR); - AsmWriteMsr64 (MSR_IA32_X2APIC_TPR, Msr); - @endcode - @note MSR_IA32_X2APIC_TPR is defined as IA32_X2APIC_TPR in SDM. -**/ -#define MSR_IA32_X2APIC_TPR 0x00000808 - - -/** - x2APIC Processor Priority Register (R/O). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_PPR (0x0000080A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_PPR); - @endcode - @note MSR_IA32_X2APIC_PPR is defined as IA32_X2APIC_PPR in SDM. -**/ -#define MSR_IA32_X2APIC_PPR 0x0000080A - - -/** - x2APIC EOI Register (W/O). If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] - = 1. - - @param ECX MSR_IA32_X2APIC_EOI (0x0000080B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = 0; - AsmWriteMsr64 (MSR_IA32_X2APIC_EOI, Msr); - @endcode - @note MSR_IA32_X2APIC_EOI is defined as IA32_X2APIC_EOI in SDM. -**/ -#define MSR_IA32_X2APIC_EOI 0x0000080B - - -/** - x2APIC Logical Destination Register (R/O). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LDR (0x0000080D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LDR); - @endcode - @note MSR_IA32_X2APIC_LDR is defined as IA32_X2APIC_LDR in SDM. -**/ -#define MSR_IA32_X2APIC_LDR 0x0000080D - - -/** - x2APIC Spurious Interrupt Vector Register (R/W). If CPUID.01H:ECX.[21] = 1 - && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_SIVR (0x0000080F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_SIVR); - AsmWriteMsr64 (MSR_IA32_X2APIC_SIVR, Msr); - @endcode - @note MSR_IA32_X2APIC_SIVR is defined as IA32_X2APIC_SIVR in SDM. -**/ -#define MSR_IA32_X2APIC_SIVR 0x0000080F - - -/** - x2APIC In-Service Register Bits (n * 32 + 31):(n * 32) (R/O). - If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_ISRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ISR0); - @endcode - @note MSR_IA32_X2APIC_ISR0 is defined as IA32_X2APIC_ISR0 in SDM. - MSR_IA32_X2APIC_ISR1 is defined as IA32_X2APIC_ISR1 in SDM. - MSR_IA32_X2APIC_ISR2 is defined as IA32_X2APIC_ISR2 in SDM. - MSR_IA32_X2APIC_ISR3 is defined as IA32_X2APIC_ISR3 in SDM. - MSR_IA32_X2APIC_ISR4 is defined as IA32_X2APIC_ISR4 in SDM. - MSR_IA32_X2APIC_ISR5 is defined as IA32_X2APIC_ISR5 in SDM. - MSR_IA32_X2APIC_ISR6 is defined as IA32_X2APIC_ISR6 in SDM. - MSR_IA32_X2APIC_ISR7 is defined as IA32_X2APIC_ISR7 in SDM. - @{ -**/ -#define MSR_IA32_X2APIC_ISR0 0x00000810 -#define MSR_IA32_X2APIC_ISR1 0x00000811 -#define MSR_IA32_X2APIC_ISR2 0x00000812 -#define MSR_IA32_X2APIC_ISR3 0x00000813 -#define MSR_IA32_X2APIC_ISR4 0x00000814 -#define MSR_IA32_X2APIC_ISR5 0x00000815 -#define MSR_IA32_X2APIC_ISR6 0x00000816 -#define MSR_IA32_X2APIC_ISR7 0x00000817 -/// @} - - -/** - x2APIC Trigger Mode Register Bits (n * 32 + ):(n * 32) (R/O). - If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_TMRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_TMR0); - @endcode - @note MSR_IA32_X2APIC_TMR0 is defined as IA32_X2APIC_TMR0 in SDM. - MSR_IA32_X2APIC_TMR1 is defined as IA32_X2APIC_TMR1 in SDM. - MSR_IA32_X2APIC_TMR2 is defined as IA32_X2APIC_TMR2 in SDM. - MSR_IA32_X2APIC_TMR3 is defined as IA32_X2APIC_TMR3 in SDM. - MSR_IA32_X2APIC_TMR4 is defined as IA32_X2APIC_TMR4 in SDM. - MSR_IA32_X2APIC_TMR5 is defined as IA32_X2APIC_TMR5 in SDM. - MSR_IA32_X2APIC_TMR6 is defined as IA32_X2APIC_TMR6 in SDM. - MSR_IA32_X2APIC_TMR7 is defined as IA32_X2APIC_TMR7 in SDM. - @{ -**/ -#define MSR_IA32_X2APIC_TMR0 0x00000818 -#define MSR_IA32_X2APIC_TMR1 0x00000819 -#define MSR_IA32_X2APIC_TMR2 0x0000081A -#define MSR_IA32_X2APIC_TMR3 0x0000081B -#define MSR_IA32_X2APIC_TMR4 0x0000081C -#define MSR_IA32_X2APIC_TMR5 0x0000081D -#define MSR_IA32_X2APIC_TMR6 0x0000081E -#define MSR_IA32_X2APIC_TMR7 0x0000081F -/// @} - - -/** - x2APIC Interrupt Request Register Bits (n* 32 + 31):(n * 32) (R/O). - If CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_IRRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_IRR0); - @endcode - @note MSR_IA32_X2APIC_IRR0 is defined as IA32_X2APIC_IRR0 in SDM. - MSR_IA32_X2APIC_IRR1 is defined as IA32_X2APIC_IRR1 in SDM. - MSR_IA32_X2APIC_IRR2 is defined as IA32_X2APIC_IRR2 in SDM. - MSR_IA32_X2APIC_IRR3 is defined as IA32_X2APIC_IRR3 in SDM. - MSR_IA32_X2APIC_IRR4 is defined as IA32_X2APIC_IRR4 in SDM. - MSR_IA32_X2APIC_IRR5 is defined as IA32_X2APIC_IRR5 in SDM. - MSR_IA32_X2APIC_IRR6 is defined as IA32_X2APIC_IRR6 in SDM. - MSR_IA32_X2APIC_IRR7 is defined as IA32_X2APIC_IRR7 in SDM. - @{ -**/ -#define MSR_IA32_X2APIC_IRR0 0x00000820 -#define MSR_IA32_X2APIC_IRR1 0x00000821 -#define MSR_IA32_X2APIC_IRR2 0x00000822 -#define MSR_IA32_X2APIC_IRR3 0x00000823 -#define MSR_IA32_X2APIC_IRR4 0x00000824 -#define MSR_IA32_X2APIC_IRR5 0x00000825 -#define MSR_IA32_X2APIC_IRR6 0x00000826 -#define MSR_IA32_X2APIC_IRR7 0x00000827 -/// @} - - -/** - x2APIC Error Status Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_ESR (0x00000828) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ESR); - AsmWriteMsr64 (MSR_IA32_X2APIC_ESR, Msr); - @endcode - @note MSR_IA32_X2APIC_ESR is defined as IA32_X2APIC_ESR in SDM. -**/ -#define MSR_IA32_X2APIC_ESR 0x00000828 - - -/** - x2APIC LVT Corrected Machine Check Interrupt Register (R/W). If - CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_CMCI (0x0000082F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_CMCI); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_CMCI, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_CMCI is defined as IA32_X2APIC_LVT_CMCI in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_CMCI 0x0000082F - - -/** - x2APIC Interrupt Command Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_ICR (0x00000830) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_ICR); - AsmWriteMsr64 (MSR_IA32_X2APIC_ICR, Msr); - @endcode - @note MSR_IA32_X2APIC_ICR is defined as IA32_X2APIC_ICR in SDM. -**/ -#define MSR_IA32_X2APIC_ICR 0x00000830 - - -/** - x2APIC LVT Timer Interrupt Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_TIMER (0x00000832) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_TIMER); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_TIMER, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_TIMER is defined as IA32_X2APIC_LVT_TIMER in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_TIMER 0x00000832 - - -/** - x2APIC LVT Thermal Sensor Interrupt Register (R/W). If CPUID.01H:ECX.[21] = - 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_THERMAL (0x00000833) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_THERMAL); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_THERMAL, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_THERMAL is defined as IA32_X2APIC_LVT_THERMAL in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_THERMAL 0x00000833 - - -/** - x2APIC LVT Performance Monitor Interrupt Register (R/W). If - CPUID.01H:ECX.[21] = 1 && IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_PMI (0x00000834) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_PMI); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_PMI, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_PMI is defined as IA32_X2APIC_LVT_PMI in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_PMI 0x00000834 - - -/** - x2APIC LVT LINT0 Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_LINT0 (0x00000835) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_LINT0); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_LINT0, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_LINT0 is defined as IA32_X2APIC_LVT_LINT0 in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_LINT0 0x00000835 - - -/** - x2APIC LVT LINT1 Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_LINT1 (0x00000836) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_LINT1); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_LINT1, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_LINT1 is defined as IA32_X2APIC_LVT_LINT1 in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_LINT1 0x00000836 - - -/** - x2APIC LVT Error Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_LVT_ERROR (0x00000837) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_LVT_ERROR); - AsmWriteMsr64 (MSR_IA32_X2APIC_LVT_ERROR, Msr); - @endcode - @note MSR_IA32_X2APIC_LVT_ERROR is defined as IA32_X2APIC_LVT_ERROR in SDM. -**/ -#define MSR_IA32_X2APIC_LVT_ERROR 0x00000837 - - -/** - x2APIC Initial Count Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_INIT_COUNT (0x00000838) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_INIT_COUNT); - AsmWriteMsr64 (MSR_IA32_X2APIC_INIT_COUNT, Msr); - @endcode - @note MSR_IA32_X2APIC_INIT_COUNT is defined as IA32_X2APIC_INIT_COUNT in SDM. -**/ -#define MSR_IA32_X2APIC_INIT_COUNT 0x00000838 - - -/** - x2APIC Current Count Register (R/O). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_CUR_COUNT (0x00000839) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_CUR_COUNT); - @endcode - @note MSR_IA32_X2APIC_CUR_COUNT is defined as IA32_X2APIC_CUR_COUNT in SDM. -**/ -#define MSR_IA32_X2APIC_CUR_COUNT 0x00000839 - - -/** - x2APIC Divide Configuration Register (R/W). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_DIV_CONF (0x0000083E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_X2APIC_DIV_CONF); - AsmWriteMsr64 (MSR_IA32_X2APIC_DIV_CONF, Msr); - @endcode - @note MSR_IA32_X2APIC_DIV_CONF is defined as IA32_X2APIC_DIV_CONF in SDM. -**/ -#define MSR_IA32_X2APIC_DIV_CONF 0x0000083E - - -/** - x2APIC Self IPI Register (W/O). If CPUID.01H:ECX.[21] = 1 && - IA32_APIC_BASE.[10] = 1. - - @param ECX MSR_IA32_X2APIC_SELF_IPI (0x0000083F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = 0; - AsmWriteMsr64 (MSR_IA32_X2APIC_SELF_IPI, Msr); - @endcode - @note MSR_IA32_X2APIC_SELF_IPI is defined as IA32_X2APIC_SELF_IPI in SDM. -**/ -#define MSR_IA32_X2APIC_SELF_IPI 0x0000083F - - -/** - Silicon Debug Feature Control (R/W). If CPUID.01H:ECX.[11] = 1. - - @param ECX MSR_IA32_DEBUG_INTERFACE (0x00000C80) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_DEBUG_INTERFACE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_DEBUG_INTERFACE_REGISTER. - - Example usage - @code - MSR_IA32_DEBUG_INTERFACE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_DEBUG_INTERFACE); - AsmWriteMsr64 (MSR_IA32_DEBUG_INTERFACE, Msr.Uint64); - @endcode - @note MSR_IA32_DEBUG_INTERFACE is defined as IA32_DEBUG_INTERFACE in SDM. -**/ -#define MSR_IA32_DEBUG_INTERFACE 0x00000C80 - -/** - MSR information returned for MSR index #MSR_IA32_DEBUG_INTERFACE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable (R/W) BIOS set 1 to enable Silicon debug features. - /// Default is 0. If CPUID.01H:ECX.[11] = 1. - /// - UINT32 Enable:1; - UINT32 Reserved1:29; - /// - /// [Bit 30] Lock (R/W): If 1, locks any further change to the MSR. The - /// lock bit is set automatically on the first SMI assertion even if not - /// explicitly set by BIOS. Default is 0. If CPUID.01H:ECX.[11] = 1. - /// - UINT32 Lock:1; - /// - /// [Bit 31] Debug Occurred (R/O): This "sticky bit" is set by hardware to - /// indicate the status of bit 0. Default is 0. If CPUID.01H:ECX.[11] = 1. - /// - UINT32 DebugOccurred:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_DEBUG_INTERFACE_REGISTER; - - -/** - L3 QOS Configuration (R/W). If ( CPUID.(EAX=10H, ECX=1):ECX.[2] = 1 ). - - @param ECX MSR_IA32_L3_QOS_CFG (0x00000C81) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_L3_QOS_CFG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_L3_QOS_CFG_REGISTER. - - Example usage - @code - MSR_IA32_L3_QOS_CFG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_L3_QOS_CFG); - AsmWriteMsr64 (MSR_IA32_L3_QOS_CFG, Msr.Uint64); - @endcode - @note MSR_IA32_L3_QOS_CFG is defined as IA32_L3_QOS_CFG in SDM. -**/ -#define MSR_IA32_L3_QOS_CFG 0x00000C81 - -/** - MSR information returned for MSR index #MSR_IA32_L3_QOS_CFG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable (R/W) Set 1 to enable L3 CAT masks and COS to operate - /// in Code and Data Prioritization (CDP) mode. - /// - UINT32 Enable:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_L3_QOS_CFG_REGISTER; - - -/** - Monitoring Event Select Register (R/W). If ( CPUID.(EAX=07H, ECX=0):EBX.[12] - = 1 ). - - @param ECX MSR_IA32_QM_EVTSEL (0x00000C8D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_QM_EVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_QM_EVTSEL_REGISTER. - - Example usage - @code - MSR_IA32_QM_EVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_QM_EVTSEL); - AsmWriteMsr64 (MSR_IA32_QM_EVTSEL, Msr.Uint64); - @endcode - @note MSR_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. -**/ -#define MSR_IA32_QM_EVTSEL 0x00000C8D - -/** - MSR information returned for MSR index #MSR_IA32_QM_EVTSEL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Event ID: ID of a supported monitoring event to report via - /// IA32_QM_CTR. - /// - UINT32 EventID:8; - UINT32 Reserved:24; - /// - /// [Bits 63:32] Resource Monitoring ID: ID for monitoring hardware to - /// report monitored data via IA32_QM_CTR. N = Ceil (Log:sub:`2` ( - /// CPUID.(EAX= 0FH, ECX=0H).EBX[31:0] +1)). - /// - UINT32 ResourceMonitoringID:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_QM_EVTSEL_REGISTER; - - -/** - Monitoring Counter Register (R/O). If ( CPUID.(EAX=07H, ECX=0):EBX.[12] = 1 - ). - - @param ECX MSR_IA32_QM_CTR (0x00000C8E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_QM_CTR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_QM_CTR_REGISTER. - - Example usage - @code - MSR_IA32_QM_CTR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_QM_CTR); - @endcode - @note MSR_IA32_QM_CTR is defined as IA32_QM_CTR in SDM. -**/ -#define MSR_IA32_QM_CTR 0x00000C8E - -/** - MSR information returned for MSR index #MSR_IA32_QM_CTR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Resource Monitored Data. - /// - UINT32 ResourceMonitoredData:32; - /// - /// [Bits 61:32] Resource Monitored Data. - /// - UINT32 ResourceMonitoredDataHi:30; - /// - /// [Bit 62] Unavailable: If 1, indicates data for this RMID is not - /// available or not monitored for this resource or RMID. - /// - UINT32 Unavailable:1; - /// - /// [Bit 63] Error: If 1, indicates and unsupported RMID or event type was - /// written to IA32_PQR_QM_EVTSEL. - /// - UINT32 Error:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_QM_CTR_REGISTER; - - -/** - Resource Association Register (R/W). If ( (CPUID.(EAX=07H, ECX=0):EBX[12] - =1) or (CPUID.(EAX=07H, ECX=0):EBX[15] =1 ) ). - - @param ECX MSR_IA32_PQR_ASSOC (0x00000C8F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PQR_ASSOC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PQR_ASSOC_REGISTER. - - Example usage - @code - MSR_IA32_PQR_ASSOC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PQR_ASSOC); - AsmWriteMsr64 (MSR_IA32_PQR_ASSOC, Msr.Uint64); - @endcode - @note MSR_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. -**/ -#define MSR_IA32_PQR_ASSOC 0x00000C8F - -/** - MSR information returned for MSR index #MSR_IA32_PQR_ASSOC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Resource Monitoring ID (R/W): ID for monitoring hardware - /// to track internal operation, e.g. memory access. N = Ceil (Log:sub:`2` - /// ( CPUID.(EAX= 0FH, ECX=0H).EBX[31:0] +1)). - /// - UINT32 ResourceMonitoringID:32; - /// - /// [Bits 63:32] COS (R/W). The class of service (COS) to enforce (on - /// writes); returns the current COS when read. If ( CPUID.(EAX=07H, - /// ECX=0):EBX.[15] = 1 ). - /// - UINT32 COS:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PQR_ASSOC_REGISTER; - - -/** - Supervisor State of MPX Configuration. (R/W). If (CPUID.(EAX=07H, - ECX=0H):EBX[14] = 1). - - @param ECX MSR_IA32_BNDCFGS (0x00000D90) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_BNDCFGS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_BNDCFGS_REGISTER. - - Example usage - @code - MSR_IA32_BNDCFGS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_BNDCFGS); - AsmWriteMsr64 (MSR_IA32_BNDCFGS, Msr.Uint64); - @endcode - @note MSR_IA32_BNDCFGS is defined as IA32_BNDCFGS in SDM. -**/ -#define MSR_IA32_BNDCFGS 0x00000D90 - -/** - MSR information returned for MSR index #MSR_IA32_BNDCFGS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] EN: Enable Intel MPX in supervisor mode. - /// - UINT32 EN:1; - /// - /// [Bit 1] BNDPRESERVE: Preserve the bounds registers for near branch - /// instructions in the absence of the BND prefix. - /// - UINT32 BNDPRESERVE:1; - UINT32 Reserved:10; - /// - /// [Bits 31:12] Base Address of Bound Directory. - /// - UINT32 Base:20; - /// - /// [Bits 63:32] Base Address of Bound Directory. - /// - UINT32 BaseHi:32; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_BNDCFGS_REGISTER; - - -/** - Extended Supervisor State Mask (R/W). If( CPUID.(0DH, 1):EAX.[3] = 1. - - @param ECX MSR_IA32_XSS (0x00000DA0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_XSS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_XSS_REGISTER. - - Example usage - @code - MSR_IA32_XSS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_XSS); - AsmWriteMsr64 (MSR_IA32_XSS, Msr.Uint64); - @endcode - @note MSR_IA32_XSS is defined as IA32_XSS in SDM. -**/ -#define MSR_IA32_XSS 0x00000DA0 - -/** - MSR information returned for MSR index #MSR_IA32_XSS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bit 8] Trace Packet Configuration State (R/W). - /// - UINT32 TracePacketConfigurationState:1; - UINT32 Reserved2:23; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_XSS_REGISTER; - - -/** - Package Level Enable/disable HDC (R/W). If CPUID.06H:EAX.[13] = 1. - - @param ECX MSR_IA32_PKG_HDC_CTL (0x00000DB0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PKG_HDC_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PKG_HDC_CTL_REGISTER. - - Example usage - @code - MSR_IA32_PKG_HDC_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PKG_HDC_CTL); - AsmWriteMsr64 (MSR_IA32_PKG_HDC_CTL, Msr.Uint64); - @endcode - @note MSR_IA32_PKG_HDC_CTL is defined as IA32_PKG_HDC_CTL in SDM. -**/ -#define MSR_IA32_PKG_HDC_CTL 0x00000DB0 - -/** - MSR information returned for MSR index #MSR_IA32_PKG_HDC_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] HDC_Pkg_Enable (R/W) Force HDC idling or wake up HDC-idled - /// logical processors in the package. See Section 14.5.2, "Package level - /// Enabling HDC". If CPUID.06H:EAX.[13] = 1. - /// - UINT32 HDC_Pkg_Enable:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PKG_HDC_CTL_REGISTER; - - -/** - Enable/disable HWP (R/W). If CPUID.06H:EAX.[13] = 1. - - @param ECX MSR_IA32_PM_CTL1 (0x00000DB1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_PM_CTL1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_PM_CTL1_REGISTER. - - Example usage - @code - MSR_IA32_PM_CTL1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_PM_CTL1); - AsmWriteMsr64 (MSR_IA32_PM_CTL1, Msr.Uint64); - @endcode - @note MSR_IA32_PM_CTL1 is defined as IA32_PM_CTL1 in SDM. -**/ -#define MSR_IA32_PM_CTL1 0x00000DB1 - -/** - MSR information returned for MSR index #MSR_IA32_PM_CTL1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] HDC_Allow_Block (R/W) Allow/Block this logical processor for - /// package level HDC control. See Section 14.5.3. - /// If CPUID.06H:EAX.[13] = 1. - /// - UINT32 HDC_Allow_Block:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_PM_CTL1_REGISTER; - - -/** - Per-Logical_Processor HDC Idle Residency (R/0). If CPUID.06H:EAX.[13] = 1. - Stall_Cycle_Cnt (R/W) Stalled cycles due to HDC forced idle on this logical - processor. See Section 14.5.4.1. If CPUID.06H:EAX.[13] = 1. - - @param ECX MSR_IA32_THREAD_STALL (0x00000DB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_THREAD_STALL); - @endcode - @note MSR_IA32_THREAD_STALL is defined as IA32_THREAD_STALL in SDM. -**/ -#define MSR_IA32_THREAD_STALL 0x00000DB2 - - -/** - Extended Feature Enables. If ( CPUID.80000001H:EDX.[2 0] - CPUID.80000001H:EDX.[2 9]). - - @param ECX MSR_IA32_EFER (0xC0000080) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_EFER_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_EFER_REGISTER. - - Example usage - @code - MSR_IA32_EFER_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER); - AsmWriteMsr64 (MSR_IA32_EFER, Msr.Uint64); - @endcode - @note MSR_IA32_EFER is defined as IA32_EFER in SDM. -**/ -#define MSR_IA32_EFER 0xC0000080 - -/** - MSR information returned for MSR index #MSR_IA32_EFER -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] SYSCALL Enable: IA32_EFER.SCE (R/W) Enables SYSCALL/SYSRET - /// instructions in 64-bit mode. - /// - UINT32 SCE:1; - UINT32 Reserved1:7; - /// - /// [Bit 8] IA-32e Mode Enable: IA32_EFER.LME (R/W) Enables IA-32e mode - /// operation. - /// - UINT32 LME:1; - UINT32 Reserved2:1; - /// - /// [Bit 10] IA-32e Mode Active: IA32_EFER.LMA (R) Indicates IA-32e mode - /// is active when set. - /// - UINT32 LMA:1; - /// - /// [Bit 11] Execute Disable Bit Enable: IA32_EFER.NXE (R/W). - /// - UINT32 NXE:1; - UINT32 Reserved3:20; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_EFER_REGISTER; - - -/** - System Call Target Address (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_STAR (0xC0000081) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_STAR); - AsmWriteMsr64 (MSR_IA32_STAR, Msr); - @endcode - @note MSR_IA32_STAR is defined as IA32_STAR in SDM. -**/ -#define MSR_IA32_STAR 0xC0000081 - - -/** - IA-32e Mode System Call Target Address (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_LSTAR (0xC0000082) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_LSTAR); - AsmWriteMsr64 (MSR_IA32_LSTAR, Msr); - @endcode - @note MSR_IA32_LSTAR is defined as IA32_LSTAR in SDM. -**/ -#define MSR_IA32_LSTAR 0xC0000082 - - -/** - System Call Flag Mask (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_FMASK (0xC0000084) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_FMASK); - AsmWriteMsr64 (MSR_IA32_FMASK, Msr); - @endcode - @note MSR_IA32_FMASK is defined as IA32_FMASK in SDM. -**/ -#define MSR_IA32_FMASK 0xC0000084 - - -/** - Map of BASE Address of FS (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_FS_BASE (0xC0000100) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_FS_BASE); - AsmWriteMsr64 (MSR_IA32_FS_BASE, Msr); - @endcode - @note MSR_IA32_FS_BASE is defined as IA32_FS_BASE in SDM. -**/ -#define MSR_IA32_FS_BASE 0xC0000100 - - -/** - Map of BASE Address of GS (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_GS_BASE (0xC0000101) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_GS_BASE); - AsmWriteMsr64 (MSR_IA32_GS_BASE, Msr); - @endcode - @note MSR_IA32_GS_BASE is defined as IA32_GS_BASE in SDM. -**/ -#define MSR_IA32_GS_BASE 0xC0000101 - - -/** - Swap Target of BASE Address of GS (R/W). If CPUID.80000001:EDX.[29] = 1. - - @param ECX MSR_IA32_KERNEL_GS_BASE (0xC0000102) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IA32_KERNEL_GS_BASE); - AsmWriteMsr64 (MSR_IA32_KERNEL_GS_BASE, Msr); - @endcode - @note MSR_IA32_KERNEL_GS_BASE is defined as IA32_KERNEL_GS_BASE in SDM. -**/ -#define MSR_IA32_KERNEL_GS_BASE 0xC0000102 - - -/** - Auxiliary TSC (RW). If CPUID.80000001H: EDX[27] = 1. - - @param ECX MSR_IA32_TSC_AUX (0xC0000103) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IA32_TSC_AUX_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IA32_TSC_AUX_REGISTER. - - Example usage - @code - MSR_IA32_TSC_AUX_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IA32_TSC_AUX); - AsmWriteMsr64 (MSR_IA32_TSC_AUX, Msr.Uint64); - @endcode - @note MSR_IA32_TSC_AUX is defined as IA32_TSC_AUX in SDM. -**/ -#define MSR_IA32_TSC_AUX 0xC0000103 - -/** - MSR information returned for MSR index #MSR_IA32_TSC_AUX -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] AUX: Auxiliary signature of TSC. - /// - UINT32 AUX:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IA32_TSC_AUX_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Cpuid.h b/UefiCpuPkg/Include/Register/Cpuid.h deleted file mode 100644 index 5eb9650553..0000000000 --- a/UefiCpuPkg/Include/Register/Cpuid.h +++ /dev/null @@ -1,3536 +0,0 @@ -/** @file - CPUID leaf definitions. - - Provides defines for CPUID leaf indexes. Data structures are provided for - registers returned by a CPUID leaf that contain one or more bit fields. - If a register returned is a single 32-bit value, then a data structure is - not provided for that register. - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials are licensed and made available under - the terms and conditions of the BSD License which accompanies this distribution. - The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 2A, - September 2016, CPUID instruction. - -**/ - -#ifndef __CPUID_H__ -#define __CPUID_H__ - -/** - CPUID Signature Information - - @param EAX CPUID_SIGNATURE (0x00) - - @retval EAX Returns the highest value the CPUID instruction recognizes for - returning basic processor information. The value is returned is - processor specific. - @retval EBX First 4 characters of a vendor identification string. - @retval ECX Last 4 characters of a vendor identification string. - @retval EDX Middle 4 characters of a vendor identification string. - - Example usage - @code - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - - AsmCpuid (CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx); - @endcode -**/ -#define CPUID_SIGNATURE 0x00 - -/// -/// @{ CPUID signature values returned by Intel processors -/// -#define CPUID_SIGNATURE_GENUINE_INTEL_EBX SIGNATURE_32 ('G', 'e', 'n', 'u') -#define CPUID_SIGNATURE_GENUINE_INTEL_EDX SIGNATURE_32 ('i', 'n', 'e', 'I') -#define CPUID_SIGNATURE_GENUINE_INTEL_ECX SIGNATURE_32 ('n', 't', 'e', 'l') -/// -/// @} -/// - - -/** - CPUID Version Information - - @param EAX CPUID_VERSION_INFO (0x01) - - @retval EAX Returns Model, Family, Stepping Information described by the - type CPUID_VERSION_INFO_EAX. - @retval EBX Returns Brand, Cache Line Size, and Initial APIC ID described by - the type CPUID_VERSION_INFO_EBX. - @retval ECX CPU Feature Information described by the type - CPUID_VERSION_INFO_ECX. - @retval EDX CPU Feature Information described by the type - CPUID_VERSION_INFO_EDX. - - Example usage - @code - CPUID_VERSION_INFO_EAX Eax; - CPUID_VERSION_INFO_EBX Ebx; - CPUID_VERSION_INFO_ECX Ecx; - CPUID_VERSION_INFO_EDX Edx; - - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_VERSION_INFO 0x01 - -/** - CPUID Version Information returned in EAX for CPUID leaf - #CPUID_VERSION_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 SteppingId:4; ///< [Bits 3:0] Stepping ID - UINT32 Model:4; ///< [Bits 7:4] Model - UINT32 FamilyId:4; ///< [Bits 11:8] Family - UINT32 ProcessorType:2; ///< [Bits 13:12] Processor Type - UINT32 Reserved1:2; ///< [Bits 15:14] Reserved - UINT32 ExtendedModelId:4; ///< [Bits 19:16] Extended Model ID - UINT32 ExtendedFamilyId:8; ///< [Bits 27:20] Extended Family ID - UINT32 Reserved2:4; ///< Reserved - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_VERSION_INFO_EAX; - -/// -/// @{ Define value for bit field CPUID_VERSION_INFO_EAX.ProcessorType -/// -#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_ORIGINAL_OEM_PROCESSOR 0x00 -#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_INTEL_OVERDRIVE_PROCESSOR 0x01 -#define CPUID_VERSION_INFO_EAX_PROCESSOR_TYPE_DUAL_PROCESSOR 0x02 -/// -/// @} -/// - -/** - CPUID Version Information returned in EBX for CPUID leaf - #CPUID_VERSION_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Provides an entry into a brand string table that contains - /// brand strings for IA-32 processors. - /// - UINT32 BrandIndex:8; - /// - /// [Bits 15:8] Indicates the size of the cache line flushed by the CLFLUSH - /// and CLFLUSHOPT instructions in 8-byte increments. This field was - /// introduced in the Pentium 4 processor. - /// - UINT32 CacheLineSize:8; - /// - /// [Bits 23:16] Maximum number of addressable IDs for logical processors - /// in this physical package. - /// - /// @note - /// The nearest power-of-2 integer that is not smaller than EBX[23:16] is - /// the number of unique initial APICIDs reserved for addressing different - /// logical processors in a physical package. This field is only valid if - /// CPUID.1.EDX.HTT[bit 28]= 1. - /// - UINT32 MaximumAddressableIdsForLogicalProcessors:8; - /// - /// [Bits 31:24] The 8-bit ID that is assigned to the local APIC on the - /// processor during power up. This field was introduced in the Pentium 4 - /// processor. - /// - UINT32 InitialLocalApicId:8; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_VERSION_INFO_EBX; - -/** - CPUID Version Information returned in ECX for CPUID leaf - #CPUID_VERSION_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Streaming SIMD Extensions 3 (SSE3). A value of 1 indicates the - /// processor supports this technology - /// - UINT32 SSE3:1; - /// - /// [Bit 1] A value of 1 indicates the processor supports the PCLMULQDQ - /// instruction. Carryless Multiplication - /// - UINT32 PCLMULQDQ:1; - /// - /// [Bit 2] 64-bit DS Area. A value of 1 indicates the processor supports - /// DS area using 64-bit layout. - /// - UINT32 DTES64:1; - /// - /// [Bit 3] MONITOR/MWAIT. A value of 1 indicates the processor supports - /// this feature. - /// - UINT32 MONITOR:1; - /// - /// [Bit 4] CPL Qualified Debug Store. A value of 1 indicates the processor - /// supports the extensions to the Debug Store feature to allow for branch - /// message storage qualified by CPL - /// - UINT32 DS_CPL:1; - /// - /// [Bit 5] Virtual Machine Extensions. A value of 1 indicates that the - /// processor supports this technology. - /// - UINT32 VMX:1; - /// - /// [Bit 6] Safer Mode Extensions. A value of 1 indicates that the processor - /// supports this technology - /// - UINT32 SMX:1; - /// - /// [Bit 7] Enhanced Intel SpeedStep(R) technology. A value of 1 indicates - /// that the processor supports this technology - /// - UINT32 EIST:1; - /// - /// [Bit 8] Thermal Monitor 2. A value of 1 indicates whether the processor - /// supports this technology - /// - UINT32 TM2:1; - /// - /// [Bit 9] A value of 1 indicates the presence of the Supplemental Streaming - /// SIMD Extensions 3 (SSSE3). A value of 0 indicates the instruction - /// extensions are not present in the processor. - /// - UINT32 SSSE3:1; - /// - /// [Bit 10] L1 Context ID. A value of 1 indicates the L1 data cache mode - /// can be set to either adaptive mode or shared mode. A value of 0 indicates - /// this feature is not supported. See definition of the IA32_MISC_ENABLE MSR - /// Bit 24 (L1 Data Cache Context Mode) for details - /// - UINT32 CNXT_ID:1; - /// - /// [Bit 11] A value of 1 indicates the processor supports IA32_DEBUG_INTERFACE - /// MSR for silicon debug - /// - UINT32 SDBG:1; - /// - /// [Bit 12] A value of 1 indicates the processor supports FMA (Fused Multiple - /// Add) extensions using YMM state. - /// - UINT32 FMA:1; - /// - /// [Bit 13] CMPXCHG16B Available. A value of 1 indicates that the feature - /// is available. - /// - UINT32 CMPXCHG16B:1; - /// - /// [Bit 14] xTPR Update Control. A value of 1 indicates that the processor - /// supports changing IA32_MISC_ENABLE[Bit 23]. - /// - UINT32 xTPR_Update_Control:1; - /// - /// [Bit 15] Perfmon and Debug Capability: A value of 1 indicates the - /// processor supports the performance and debug feature indication MSR - /// IA32_PERF_CAPABILITIES. - /// - UINT32 PDCM:1; - UINT32 Reserved:1; - /// - /// [Bit 17] Process-context identifiers. A value of 1 indicates that the - /// processor supports PCIDs and that software may set CR4.PCIDE to 1. - /// - UINT32 PCID:1; - /// - /// [Bit 18] A value of 1 indicates the processor supports the ability to - /// prefetch data from a memory mapped device. Direct Cache Access. - /// - UINT32 DCA:1; - /// - /// [Bit 19] A value of 1 indicates that the processor supports SSE4.1. - /// - UINT32 SSE4_1:1; - /// - /// [Bit 20] A value of 1 indicates that the processor supports SSE4.2. - /// - UINT32 SSE4_2:1; - /// - /// [Bit 21] A value of 1 indicates that the processor supports x2APIC - /// feature. - /// - UINT32 x2APIC:1; - /// - /// [Bit 22] A value of 1 indicates that the processor supports MOVBE - /// instruction. - /// - UINT32 MOVBE:1; - /// - /// [Bit 23] A value of 1 indicates that the processor supports the POPCNT - /// instruction. - /// - UINT32 POPCNT:1; - /// - /// [Bit 24] A value of 1 indicates that the processor's local APIC timer - /// supports one-shot operation using a TSC deadline value. - /// - UINT32 TSC_Deadline:1; - /// - /// [Bit 25] A value of 1 indicates that the processor supports the AESNI - /// instruction extensions. - /// - UINT32 AESNI:1; - /// - /// [Bit 26] A value of 1 indicates that the processor supports the - /// XSAVE/XRSTOR processor extended states feature, the XSETBV/XGETBV - /// instructions, and XCR0. - /// - UINT32 XSAVE:1; - /// - /// [Bit 27] A value of 1 indicates that the OS has set CR4.OSXSAVE[Bit 18] - /// to enable XSETBV/XGETBV instructions to access XCR0 and to support - /// processor extended state management using XSAVE/XRSTOR. - /// - UINT32 OSXSAVE:1; - /// - /// [Bit 28] A value of 1 indicates the processor supports the AVX instruction - /// extensions. - /// - UINT32 AVX:1; - /// - /// [Bit 29] A value of 1 indicates that processor supports 16-bit - /// floating-point conversion instructions. - /// - UINT32 F16C:1; - /// - /// [Bit 30] A value of 1 indicates that processor supports RDRAND instruction. - /// - UINT32 RDRAND:1; - /// - /// [Bit 31] Always returns 0. - /// - UINT32 NotUsed:1; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_VERSION_INFO_ECX; - -/** - CPUID Version Information returned in EDX for CPUID leaf - #CPUID_VERSION_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Floating Point Unit On-Chip. The processor contains an x87 FPU. - /// - UINT32 FPU:1; - /// - /// [Bit 1] Virtual 8086 Mode Enhancements. Virtual 8086 mode enhancements, - /// including CR4.VME for controlling the feature, CR4.PVI for protected - /// mode virtual interrupts, software interrupt indirection, expansion of - /// the TSS with the software indirection bitmap, and EFLAGS.VIF and - /// EFLAGS.VIP flags. - /// - UINT32 VME:1; - /// - /// [Bit 2] Debugging Extensions. Support for I/O breakpoints, including - /// CR4.DE for controlling the feature, and optional trapping of accesses to - /// DR4 and DR5. - /// - UINT32 DE:1; - /// - /// [Bit 3] Page Size Extension. Large pages of size 4 MByte are supported, - /// including CR4.PSE for controlling the feature, the defined dirty bit in - /// PDE (Page Directory Entries), optional reserved bit trapping in CR3, - /// PDEs, and PTEs. - /// - UINT32 PSE:1; - /// - /// [Bit 4] Time Stamp Counter. The RDTSC instruction is supported, - /// including CR4.TSD for controlling privilege. - /// - UINT32 TSC:1; - /// - /// [Bit 5] Model Specific Registers RDMSR and WRMSR Instructions. The - /// RDMSR and WRMSR instructions are supported. Some of the MSRs are - /// implementation dependent. - /// - UINT32 MSR:1; - /// - /// [Bit 6] Physical Address Extension. Physical addresses greater than 32 - /// bits are supported: extended page table entry formats, an extra level in - /// the page translation tables is defined, 2-MByte pages are supported - /// instead of 4 Mbyte pages if PAE bit is 1. - /// - UINT32 PAE:1; - /// - /// [Bit 7] Machine Check Exception. Exception 18 is defined for Machine - /// Checks, including CR4.MCE for controlling the feature. This feature does - /// not define the model-specific implementations of machine-check error - /// logging, reporting, and processor shutdowns. Machine Check exception - /// handlers may have to depend on processor version to do model specific - /// processing of the exception, or test for the presence of the Machine - /// Check feature. - /// - UINT32 MCE:1; - /// - /// [Bit 8] CMPXCHG8B Instruction. The compare-and-exchange 8 bytes(64 bits) - /// instruction is supported (implicitly locked and atomic). - /// - UINT32 CX8:1; - /// - /// [Bit 9] APIC On-Chip. The processor contains an Advanced Programmable - /// Interrupt Controller (APIC), responding to memory mapped commands in the - /// physical address range FFFE0000H to FFFE0FFFH (by default - some - /// processors permit the APIC to be relocated). - /// - UINT32 APIC:1; - UINT32 Reserved1:1; - /// - /// [Bit 11] SYSENTER and SYSEXIT Instructions. The SYSENTER and SYSEXIT - /// and associated MSRs are supported. - /// - UINT32 SEP:1; - /// - /// [Bit 12] Memory Type Range Registers. MTRRs are supported. The MTRRcap - /// MSR contains feature bits that describe what memory types are supported, - /// how many variable MTRRs are supported, and whether fixed MTRRs are - /// supported. - /// - UINT32 MTRR:1; - /// - /// [Bit 13] Page Global Bit. The global bit is supported in paging-structure - /// entries that map a page, indicating TLB entries that are common to - /// different processes and need not be flushed. The CR4.PGE bit controls - /// this feature. - /// - UINT32 PGE:1; - /// - /// [Bit 14] Machine Check Architecture. A value of 1 indicates the Machine - /// Check Architecture of reporting machine errors is supported. The MCG_CAP - /// MSR contains feature bits describing how many banks of error reporting - /// MSRs are supported. - /// - UINT32 MCA:1; - /// - /// [Bit 15] Conditional Move Instructions. The conditional move instruction - /// CMOV is supported. In addition, if x87 FPU is present as indicated by the - /// CPUID.FPU feature bit, then the FCOMI and FCMOV instructions are supported. - /// - UINT32 CMOV:1; - /// - /// [Bit 16] Page Attribute Table. Page Attribute Table is supported. This - /// feature augments the Memory Type Range Registers (MTRRs), allowing an - /// operating system to specify attributes of memory accessed through a - /// linear address on a 4KB granularity. - /// - UINT32 PAT:1; - /// - /// [Bit 17] 36-Bit Page Size Extension. 4-MByte pages addressing physical - /// memory beyond 4 GBytes are supported with 32-bit paging. This feature - /// indicates that upper bits of the physical address of a 4-MByte page are - /// encoded in bits 20:13 of the page-directory entry. Such physical - /// addresses are limited by MAXPHYADDR and may be up to 40 bits in size. - /// - UINT32 PSE_36:1; - /// - /// [Bit 18] Processor Serial Number. The processor supports the 96-bit - /// processor identification number feature and the feature is enabled. - /// - UINT32 PSN:1; - /// - /// [Bit 19] CLFLUSH Instruction. CLFLUSH Instruction is supported. - /// - UINT32 CLFSH:1; - UINT32 Reserved2:1; - /// - /// [Bit 21] Debug Store. The processor supports the ability to write debug - /// information into a memory resident buffer. This feature is used by the - /// branch trace store (BTS) and precise event-based sampling (PEBS) - /// facilities. - /// - UINT32 DS:1; - /// - /// [Bit 22] Thermal Monitor and Software Controlled Clock Facilities. The - /// processor implements internal MSRs that allow processor temperature to - /// be monitored and processor performance to be modulated in predefined - /// duty cycles under software control. - /// - UINT32 ACPI:1; - /// - /// [Bit 23] Intel MMX Technology. The processor supports the Intel MMX - /// technology. - /// - UINT32 MMX:1; - /// - /// [Bit 24] FXSAVE and FXRSTOR Instructions. The FXSAVE and FXRSTOR - /// instructions are supported for fast save and restore of the floating - /// point context. Presence of this bit also indicates that CR4.OSFXSR is - /// available for an operating system to indicate that it supports the - /// FXSAVE and FXRSTOR instructions. - /// - UINT32 FXSR:1; - /// - /// [Bit 25] SSE. The processor supports the SSE extensions. - /// - UINT32 SSE:1; - /// - /// [Bit 26] SSE2. The processor supports the SSE2 extensions. - /// - UINT32 SSE2:1; - /// - /// [Bit 27] Self Snoop. The processor supports the management of - /// conflicting memory types by performing a snoop of its own cache - /// structure for transactions issued to the bus. - /// - UINT32 SS:1; - /// - /// [Bit 28] Max APIC IDs reserved field is Valid. A value of 0 for HTT - /// indicates there is only a single logical processor in the package and - /// software should assume only a single APIC ID is reserved. A value of 1 - /// for HTT indicates the value in CPUID.1.EBX[23:16] (the Maximum number of - /// addressable IDs for logical processors in this package) is valid for the - /// package. - /// - UINT32 HTT:1; - /// - /// [Bit 29] Thermal Monitor. The processor implements the thermal monitor - /// automatic thermal control circuitry (TCC). - /// - UINT32 TM:1; - UINT32 Reserved3:1; - /// - /// [Bit 31] Pending Break Enable. The processor supports the use of the - /// FERR#/PBE# pin when the processor is in the stop-clock state (STPCLK# is - /// asserted) to signal the processor that an interrupt is pending and that - /// the processor should return to normal operation to handle the interrupt. - /// Bit 10 (PBE enable) in the IA32_MISC_ENABLE MSR enables this capability. - /// - UINT32 PBE:1; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_VERSION_INFO_EDX; - - -/** - CPUID Cache and TLB Information - - @param EAX CPUID_CACHE_INFO (0x02) - - @retval EAX Cache and TLB Information described by the type - CPUID_CACHE_INFO_CACHE_TLB. - CPUID_CACHE_INFO_CACHE_TLB.CacheDescriptor[0] always returns - 0x01 and must be ignored. Only valid if - CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. - @retval EBX Cache and TLB Information described by the type - CPUID_CACHE_INFO_CACHE_TLB. Only valid if - CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. - @retval ECX Cache and TLB Information described by the type - CPUID_CACHE_INFO_CACHE_TLB. Only valid if - CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. - @retval EDX Cache and TLB Information described by the type - CPUID_CACHE_INFO_CACHE_TLB. Only valid if - CPUID_CACHE_INFO_CACHE_TLB.Bits.NotValid is clear. - - Example usage - @code - CPUID_CACHE_INFO_CACHE_TLB Eax; - CPUID_CACHE_INFO_CACHE_TLB Ebx; - CPUID_CACHE_INFO_CACHE_TLB Ecx; - CPUID_CACHE_INFO_CACHE_TLB Edx; - - AsmCpuid (CPUID_CACHE_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode - - Cache Descriptor values - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Value Type Description
0x00 General Null descriptor, this byte contains no information
0x01 TLB Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries
0x02 TLB Instruction TLB: 4 MByte pages, fully associative, 2 entries
0x03 TLB Data TLB: 4 KByte pages, 4-way set associative, 64 entries
0x04 TLB Data TLB: 4 MByte pages, 4-way set associative, 8 entries
0x05 TLB Data TLB1: 4 MByte pages, 4-way set associative, 32 entries
0x06 Cache 1st-level instruction cache: 8 KBytes, 4-way set associative, - 32 byte line size
0x08 Cache 1st-level instruction cache: 16 KBytes, 4-way set associative, - 32 byte line size
0x09 Cache 1st-level instruction cache: 32KBytes, 4-way set associative, - 64 byte line size
0x0A Cache 1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size
0x0B TLB Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries
0x0C Cache 1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size
0x0D Cache 1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size
0x0E Cache 1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size
0x1D Cache 2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size
0x21 Cache 2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size
0x22 Cache 3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, - 2 lines per sector
0x23 Cache 3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, - 2 lines per sector
0x24 Cache 2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size
0x25 Cache 3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, - 2 lines per sector
0x29 Cache 3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, - 2 lines per sector
0x2C Cache 1st-level data cache: 32 KBytes, 8-way set associative, - 64 byte line size
0x30 Cache 1st-level instruction cache: 32 KBytes, 8-way set associative, - 64 byte line size
0x40 Cache No 2nd-level cache or, if processor contains a valid 2nd-level cache, - no 3rd-level cache
0x41 Cache 2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size
0x42 Cache 2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size
0x43 Cache 2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size
0x44 Cache 2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size
0x45 Cache 2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size
0x46 Cache 3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size
0x47 Cache 3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size
0x48 Cache 2nd-level cache: 3MByte, 12-way set associative, 64 byte line size
0x49 Cache 3rd-level cache: 4MB, 16-way set associative, 64-byte line size - (Intel Xeon processor MP, Family 0FH, Model 06H)
- 2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size
0x4A Cache 3rd-level cache: 6MByte, 12-way set associative, 64 byte line size
0x4B Cache 3rd-level cache: 8MByte, 16-way set associative, 64 byte line size
0x4C Cache 3rd-level cache: 12MByte, 12-way set associative, 64 byte line size
0x4D Cache 3rd-level cache: 16MByte, 16-way set associative, 64 byte line size
0x4E Cache 2nd-level cache: 6MByte, 24-way set associative, 64 byte line size
0x4F TLB Instruction TLB: 4 KByte pages, 32 entries
0x50 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries
0x51 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries
0x52 TLB Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries
0x55 TLB Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries
0x56 TLB Data TLB0: 4 MByte pages, 4-way set associative, 16 entries
0x57 TLB Data TLB0: 4 KByte pages, 4-way associative, 16 entries
0x59 TLB Data TLB0: 4 KByte pages, fully associative, 16 entries
0x5A TLB Data TLB0: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries
0x5B TLB Data TLB: 4 KByte and 4 MByte pages, 64 entries
0x5C TLB Data TLB: 4 KByte and 4 MByte pages,128 entries
0x5D TLB Data TLB: 4 KByte and 4 MByte pages,256 entries
0x60 Cache 1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size
0x61 TLB Instruction TLB: 4 KByte pages, fully associative, 48 entries
0x63 TLB Data TLB: 2 MByte or 4 MByte pages, 4-way set associative, - 32 entries and a separate array with 1 GByte pages, 4-way set associative, - 4 entries
0x64 TLB Data TLB: 4 KByte pages, 4-way set associative, 512 entries
0x66 Cache 1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size
0x67 Cache 1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size
0x68 Cache 1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size
0x6A Cache uTLB: 4 KByte pages, 8-way set associative, 64 entries
0x6B Cache DTLB: 4 KByte pages, 8-way set associative, 256 entries
0x6C Cache DTLB: 2M/4M pages, 8-way set associative, 128 entries
0x6D Cache DTLB: 1 GByte pages, fully associative, 16 entries
0x70 Cache Trace cache: 12 K-uop, 8-way set associative
0x71 Cache Trace cache: 16 K-uop, 8-way set associative
0x72 Cache Trace cache: 32 K-uop, 8-way set associative
0x76 TLB Instruction TLB: 2M/4M pages, fully associative, 8 entries
0x78 Cache 2nd-level cache: 1 MByte, 4-way set associative, 64byte line size
0x79 Cache 2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, - 2 lines per sector
0x7A Cache 2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, - 2 lines per sector
0x7B Cache 2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, - 2 lines per sector
0x7C Cache 2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, - 2 lines per sector
0x7D Cache 2nd-level cache: 2 MByte, 8-way set associative, 64byte line size
0x7F Cache 2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size
0x80 Cache 2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size
0x82 Cache 2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size
0x83 Cache 2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size
0x84 Cache 2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size
0x85 Cache 2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size
0x86 Cache 2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size
0x87 Cache 2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size
0xA0 DTLB DTLB: 4k pages, fully associative, 32 entries
0xB0 TLB Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries
0xB1 TLB Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries
0xB2 TLB Instruction TLB: 4KByte pages, 4-way set associative, 64 entries
0xB3 TLB Data TLB: 4 KByte pages, 4-way set associative, 128 entries
0xB4 TLB Data TLB1: 4 KByte pages, 4-way associative, 256 entries
0xB5 TLB Instruction TLB: 4KByte pages, 8-way set associative, 64 entries
0xB6 TLB Instruction TLB: 4KByte pages, 8-way set associative, - 128 entries
0xBA TLB Data TLB1: 4 KByte pages, 4-way associative, 64 entries
0xC0 TLB Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries
0xC1 STLB Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, - 1024 entries
0xC2 DTLB DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries
0xC3 STLB Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, - 1536 entries. Also 1GBbyte pages, 4-way, 16 entries.
0xC4 DTLB DTLB: 2M/4M Byte pages, 4-way associative, 32 entries
0xCA STLB Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries
0xD0 Cache 3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size
0xD1 Cache 3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size
0xD2 Cache 3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size
0xD6 Cache 3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size
0xD7 Cache 3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size
0xD8 Cache 3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size
0xDC Cache 3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size
0xDD Cache 3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size
0xDE Cache 3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size
0xE2 Cache 3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size
0xE3 Cache 3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size
0xE4 Cache 3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size
0xEA Cache 3rd-level cache: 12MByte, 24-way set associative, 64 byte line size
0xEB Cache 3rd-level cache: 18MByte, 24-way set associative, 64 byte line size
0xEC Cache 3rd-level cache: 24MByte, 24-way set associative, 64 byte line size
0xF0 Prefetch 64-Byte prefetching
0xF1 Prefetch 128-Byte prefetching
0xFF General CPUID leaf 2 does not report cache descriptor information, - use CPUID leaf 4 to query cache parameters
-**/ -#define CPUID_CACHE_INFO 0x02 - -/** - CPUID Cache and TLB Information returned in EAX, EBX, ECX, and EDX for CPUID - leaf #CPUID_CACHE_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:31; - /// - /// [Bit 31] If 0, then the cache descriptor bytes in the register are valid. - /// if 1, then none of the cache descriptor bytes in the register are valid. - /// - UINT32 NotValid:1; - } Bits; - /// - /// Array of Cache and TLB descriptor bytes - /// - UINT8 CacheDescriptor[4]; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_CACHE_INFO_CACHE_TLB; - - -/** - CPUID Processor Serial Number - - Processor serial number (PSN) is not supported in the Pentium 4 processor - or later. On all models, use the PSN flag (returned using CPUID) to check - for PSN support before accessing the feature. - - @param EAX CPUID_SERIAL_NUMBER (0x03) - - @retval EAX Reserved. - @retval EBX Reserved. - @retval ECX Bits 31:0 of 96 bit processor serial number. (Available in - Pentium III processor only; otherwise, the value in this - register is reserved.) - @retval EDX Bits 63:32 of 96 bit processor serial number. (Available in - Pentium III processor only; otherwise, the value in this - register is reserved.) - - Example usage - @code - UINT32 Ecx; - UINT32 Edx; - - AsmCpuid (CPUID_SERIAL_NUMBER, NULL, NULL, &Ecx, &Edx); - @endcode -**/ -#define CPUID_SERIAL_NUMBER 0x03 - - -/** - CPUID Cache Parameters - - @param EAX CPUID_CACHE_PARAMS (0x04) - @param ECX Cache Level. Valid values start at 0. Software can enumerate - the deterministic cache parameters for each level of the cache - hierarchy starting with an index value of 0, until the - parameters report the value associated with the CacheType - field in CPUID_CACHE_PARAMS_EAX is 0. - - @retval EAX Returns cache type information described by the type - CPUID_CACHE_PARAMS_EAX. - @retval EBX Returns cache line and associativity information described by - the type CPUID_CACHE_PARAMS_EBX. - @retval ECX Returns the number of sets in the cache. - @retval EDX Returns cache WINVD/INVD behavior described by the type - CPUID_CACHE_PARAMS_EDX. - - Example usage - @code - UINT32 CacheLevel; - CPUID_CACHE_PARAMS_EAX Eax; - CPUID_CACHE_PARAMS_EBX Ebx; - UINT32 Ecx; - CPUID_CACHE_PARAMS_EDX Edx; - - CacheLevel = 0; - do { - AsmCpuidEx ( - CPUID_CACHE_PARAMS, CacheLevel, - &Eax.Uint32, &Ebx.Uint32, &Ecx, &Edx.Uint32 - ); - CacheLevel++; - } while (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL); - @endcode -**/ -#define CPUID_CACHE_PARAMS 0x04 - -/** - CPUID Cache Parameters Information returned in EAX for CPUID leaf - #CPUID_CACHE_PARAMS. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Cache type field. If #CPUID_CACHE_PARAMS_CACHE_TYPE_NULL, - /// then there is no information for the requested cache level. - /// - UINT32 CacheType:5; - /// - /// [Bits 7:5] Cache level (Starts at 1). - /// - UINT32 CacheLevel:3; - /// - /// [Bit 8] Self Initializing cache level (does not need SW initialization). - /// - UINT32 SelfInitializingCache:1; - /// - /// [Bit 9] Fully Associative cache. - /// - UINT32 FullyAssociativeCache:1; - /// - /// [Bits 13:10] Reserved. - /// - UINT32 Reserved:4; - /// - /// [Bits 25:14] Maximum number of addressable IDs for logical processors - /// sharing this cache. - /// - /// Add one to the return value to get the result. - /// The nearest power-of-2 integer that is not smaller than (1 + EAX[25:14]) - /// is the number of unique initial APIC IDs reserved for addressing - /// different logical processors sharing this cache. - /// - UINT32 MaximumAddressableIdsForLogicalProcessors:12; - /// - /// [Bits 31:26] Maximum number of addressable IDs for processor cores in - /// the physical package. - /// - /// The nearest power-of-2 integer that is not smaller than (1 + EAX[31:26]) - /// is the number of unique Core_IDs reserved for addressing different - /// processor cores in a physical package. Core ID is a subset of bits of - /// the initial APIC ID. - /// The returned value is constant for valid initial values in ECX. Valid - /// ECX values start from 0. - /// - UINT32 MaximumAddressableIdsForProcessorCores:6; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_CACHE_PARAMS_EAX; - -/// -/// @{ Define value for bit field CPUID_CACHE_PARAMS_EAX.CacheType -/// -#define CPUID_CACHE_PARAMS_CACHE_TYPE_NULL 0x00 -#define CPUID_CACHE_PARAMS_CACHE_TYPE_DATA 0x01 -#define CPUID_CACHE_PARAMS_CACHE_TYPE_INSTRUCTION 0x02 -#define CPUID_CACHE_PARAMS_CACHE_TYPE_UNIFIED 0x03 -/// -/// @} -/// - -/** - CPUID Cache Parameters Information returned in EBX for CPUID leaf - #CPUID_CACHE_PARAMS. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 11:0] System Coherency Line Size. Add one to the return value to - /// get the result. - /// - UINT32 LineSize:12; - /// - /// [Bits 21:12] Physical Line Partitions. Add one to the return value to - /// get the result. - /// - UINT32 LinePartitions:10; - /// - /// [Bits 31:22] Ways of associativity. Add one to the return value to get - /// the result. - /// - UINT32 Ways:10; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_CACHE_PARAMS_EBX; - -/** - CPUID Cache Parameters Information returned in EDX for CPUID leaf - #CPUID_CACHE_PARAMS. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Write-Back Invalidate/Invalidate. - /// 0 = WBINVD/INVD from threads sharing this cache acts upon lower level - /// caches for threads sharing this cache. - /// 1 = WBINVD/INVD is not guaranteed to act upon lower level caches of - /// non-originating threads sharing this cache. - /// - UINT32 Invalidate:1; - /// - /// [Bit 1] Cache Inclusiveness. - /// 0 = Cache is not inclusive of lower cache levels. - /// 1 = Cache is inclusive of lower cache levels. - /// - UINT32 CacheInclusiveness:1; - /// - /// [Bit 2] Complex Cache Indexing. - /// 0 = Direct mapped cache. - /// 1 = A complex function is used to index the cache, potentially using all - /// address bits. - /// - UINT32 ComplexCacheIndexing:1; - UINT32 Reserved:29; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_CACHE_PARAMS_EDX; - - -/** - CPUID MONITOR/MWAIT Information - - @param EAX CPUID_MONITOR_MWAIT (0x05) - - @retval EAX Smallest monitor-line size in bytes described by the type - CPUID_MONITOR_MWAIT_EAX. - @retval EBX Largest monitor-line size in bytes described by the type - CPUID_MONITOR_MWAIT_EBX. - @retval ECX Enumeration of Monitor-Mwait extensions support described by - the type CPUID_MONITOR_MWAIT_ECX. - @retval EDX Sub C-states supported described by the type - CPUID_MONITOR_MWAIT_EDX. - - Example usage - @code - CPUID_MONITOR_MWAIT_EAX Eax; - CPUID_MONITOR_MWAIT_EBX Ebx; - CPUID_MONITOR_MWAIT_ECX Ecx; - CPUID_MONITOR_MWAIT_EDX Edx; - - AsmCpuid (CPUID_MONITOR_MWAIT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_MONITOR_MWAIT 0x05 - -/** - CPUID MONITOR/MWAIT Information returned in EAX for CPUID leaf - #CPUID_MONITOR_MWAIT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Smallest monitor-line size in bytes (default is processor's - /// monitor granularity). - /// - UINT32 SmallestMonitorLineSize:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_MONITOR_MWAIT_EAX; - -/** - CPUID MONITOR/MWAIT Information returned in EBX for CPUID leaf - #CPUID_MONITOR_MWAIT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Largest monitor-line size in bytes (default is processor's - /// monitor granularity). - /// - UINT32 LargestMonitorLineSize:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_MONITOR_MWAIT_EBX; - -/** - CPUID MONITOR/MWAIT Information returned in ECX for CPUID leaf - #CPUID_MONITOR_MWAIT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] If 0, then only EAX and EBX are valid. If 1, then EAX, EBX, ECX, - /// and EDX are valid. - /// - UINT32 ExtensionsSupported:1; - /// - /// [Bit 1] Supports treating interrupts as break-event for MWAIT, even when - /// interrupts disabled. - /// - UINT32 InterruptAsBreak:1; - UINT32 Reserved:30; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_MONITOR_MWAIT_ECX; - -/** - CPUID MONITOR/MWAIT Information returned in EDX for CPUID leaf - #CPUID_MONITOR_MWAIT. - - @note - The definition of C0 through C7 states for MWAIT extension are - processor-specific C-states, not ACPI C-states. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Number of C0 sub C-states supported using MWAIT. - /// - UINT32 C0States:4; - /// - /// [Bits 7:4] Number of C1 sub C-states supported using MWAIT. - /// - UINT32 C1States:4; - /// - /// [Bits 11:8] Number of C2 sub C-states supported using MWAIT. - /// - UINT32 C2States:4; - /// - /// [Bits 15:12] Number of C3 sub C-states supported using MWAIT. - /// - UINT32 C3States:4; - /// - /// [Bits 19:16] Number of C4 sub C-states supported using MWAIT. - /// - UINT32 C4States:4; - /// - /// [Bits 23:20] Number of C5 sub C-states supported using MWAIT. - /// - UINT32 C5States:4; - /// - /// [Bits 27:24] Number of C6 sub C-states supported using MWAIT. - /// - UINT32 C6States:4; - /// - /// [Bits 31:28] Number of C7 sub C-states supported using MWAIT. - /// - UINT32 C7States:4; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_MONITOR_MWAIT_EDX; - - -/** - CPUID Thermal and Power Management - - @param EAX CPUID_THERMAL_POWER_MANAGEMENT (0x06) - - @retval EAX Thermal and power management features described by the type - CPUID_THERMAL_POWER_MANAGEMENT_EAX. - @retval EBX Number of Interrupt Thresholds in Digital Thermal Sensor - described by the type CPUID_THERMAL_POWER_MANAGEMENT_EBX. - @retval ECX Performance features described by the type - CPUID_THERMAL_POWER_MANAGEMENT_ECX. - @retval EDX Reserved. - - Example usage - @code - CPUID_THERMAL_POWER_MANAGEMENT_EAX Eax; - CPUID_THERMAL_POWER_MANAGEMENT_EBX Ebx; - CPUID_THERMAL_POWER_MANAGEMENT_ECX Ecx; - - AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); - @endcode -**/ -#define CPUID_THERMAL_POWER_MANAGEMENT 0x06 - -/** - CPUID Thermal and Power Management Information returned in EAX for CPUID leaf - #CPUID_THERMAL_POWER_MANAGEMENT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Digital temperature sensor is supported if set. - /// - UINT32 DigitalTemperatureSensor:1; - /// - /// [Bit 1] Intel Turbo Boost Technology Available (see IA32_MISC_ENABLE[38]). - /// - UINT32 TurboBoostTechnology:1; - /// - /// [Bit 2] APIC-Timer-always-running feature is supported if set. - /// - UINT32 ARAT:1; - UINT32 Reserved1:1; - /// - /// [Bit 4] Power limit notification controls are supported if set. - /// - UINT32 PLN:1; - /// - /// [Bit 5] Clock modulation duty cycle extension is supported if set. - /// - UINT32 ECMD:1; - /// - /// [Bit 6] Package thermal management is supported if set. - /// - UINT32 PTM:1; - /// - /// [Bit 7] HWP base registers (IA32_PM_ENABLE[Bit 0], IA32_HWP_CAPABILITIES, - /// IA32_HWP_REQUEST, IA32_HWP_STATUS) are supported if set. - /// - UINT32 HWP:1; - /// - /// [Bit 8] IA32_HWP_INTERRUPT MSR is supported if set. - /// - UINT32 HWP_Notification:1; - /// - /// [Bit 9] IA32_HWP_REQUEST[Bits 41:32] is supported if set. - /// - UINT32 HWP_Activity_Window:1; - /// - /// [Bit 10] IA32_HWP_REQUEST[Bits 31:24] is supported if set. - /// - UINT32 HWP_Energy_Performance_Preference:1; - /// - /// [Bit 11] IA32_HWP_REQUEST_PKG MSR is supported if set. - /// - UINT32 HWP_Package_Level_Request:1; - UINT32 Reserved2:1; - /// - /// [Bit 13] HDC base registers IA32_PKG_HDC_CTL, IA32_PM_CTL1, - /// IA32_THREAD_STALL MSRs are supported if set. - /// - UINT32 HDC:1; - UINT32 Reserved3:18; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_THERMAL_POWER_MANAGEMENT_EAX; - -/** - CPUID Thermal and Power Management Information returned in EBX for CPUID leaf - #CPUID_THERMAL_POWER_MANAGEMENT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// {Bits 3:0] Number of Interrupt Thresholds in Digital Thermal Sensor. - /// - UINT32 InterruptThresholds:4; - UINT32 Reserved:28; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_THERMAL_POWER_MANAGEMENT_EBX; - -/** - CPUID Thermal and Power Management Information returned in ECX for CPUID leaf - #CPUID_THERMAL_POWER_MANAGEMENT. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Hardware Coordination Feedback Capability (Presence of IA32_MPERF - /// and IA32_APERF). The capability to provide a measure of delivered - /// processor performance (since last reset of the counters), as a percentage - /// of the expected processor performance when running at the TSC frequency. - /// - UINT32 HardwareCoordinationFeedback:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] If this bit is set, then the processor supports performance-energy - /// bias preference and the architectural MSR called IA32_ENERGY_PERF_BIAS - /// (1B0H). - /// - UINT32 PerformanceEnergyBias:1; - UINT32 Reserved2:28; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_THERMAL_POWER_MANAGEMENT_ECX; - - -/** - CPUID Structured Extended Feature Flags Enumeration - - @param EAX CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS (0x07) - @param ECX CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO (0x00). - - @note - If ECX contains an invalid sub-leaf index, EAX/EBX/ECX/EDX return 0. Sub-leaf - index n is invalid if n exceeds the value that sub-leaf 0 returns in EAX. - - @retval EAX The maximum input value for ECX to retrieve sub-leaf information. - @retval EBX Structured Extended Feature Flags described by the type - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX. - @retval EBX Structured Extended Feature Flags described by the type - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX. - @retval EDX Reserved. - - Example usage - @code - UINT32 Eax; - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx; - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX Ecx; - UINT32 SubLeaf; - - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, - &Eax, NULL, NULL, NULL - ); - for (SubLeaf = 0; SubLeaf <= Eax; SubLeaf++) { - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - SubLeaf, - NULL, &Ebx.Uint32, &Ecx.Uint32, NULL - ); - } - @endcode -**/ -#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS 0x07 - -/// -/// CPUID Structured Extended Feature Flags Enumeration sub-leaf -/// -#define CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO 0x00 - -/** - CPUID Structured Extended Feature Flags Enumeration in EBX for CPUID leaf - #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS sub leaf - #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Supports RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE if 1. - /// - UINT32 FSGSBASE:1; - /// - /// [Bit 1] IA32_TSC_ADJUST MSR is supported if 1. - /// - UINT32 IA32_TSC_ADJUST:1; - /// - /// [Bit 2] Intel SGX is supported if 1. See section 37.7 "DISCOVERING SUPPORT - /// FOR INTEL(R) SGX AND ENABLING ENCLAVE INSTRUCTIONS". - /// - UINT32 SGX:1; - /// - /// [Bit 3] If 1 indicates the processor supports the first group of advanced - /// bit manipulation extensions (ANDN, BEXTR, BLSI, BLSMSK, BLSR, TZCNT) - /// - UINT32 BMI1:1; - /// - /// [Bit 4] Hardware Lock Elision - /// - UINT32 HLE:1; - /// - /// [Bit 5] If 1 indicates the processor supports AVX2 instruction extensions. - /// - UINT32 AVX2:1; - /// - /// [Bit 6] x87 FPU Data Pointer updated only on x87 exceptions if 1. - /// - UINT32 FDP_EXCPTN_ONLY:1; - /// - /// [Bit 7] Supports Supervisor-Mode Execution Prevention if 1. - /// - UINT32 SMEP:1; - /// - /// [Bit 8] If 1 indicates the processor supports the second group of - /// advanced bit manipulation extensions (BZHI, MULX, PDEP, PEXT, RORX, - /// SARX, SHLX, SHRX) - /// - UINT32 BMI2:1; - /// - /// [Bit 9] Supports Enhanced REP MOVSB/STOSB if 1. - /// - UINT32 EnhancedRepMovsbStosb:1; - /// - /// [Bit 10] If 1, supports INVPCID instruction for system software that - /// manages process-context identifiers. - /// - UINT32 INVPCID:1; - /// - /// [Bit 11] Restricted Transactional Memory - /// - UINT32 RTM:1; - /// - /// [Bit 12] Supports Intel(R) Resource Director Technology (Intel(R) RDT) - /// Monitoring capability if 1. - /// - UINT32 RDT_M:1; - /// - /// [Bit 13] Deprecates FPU CS and FPU DS values if 1. - /// - UINT32 DeprecateFpuCsDs:1; - /// - /// [Bit 14] Supports Intel(R) Memory Protection Extensions if 1. - /// - UINT32 MPX:1; - /// - /// [Bit 15] Supports Intel(R) Resource Director Technology (Intel(R) RDT) - /// Allocation capability if 1. - /// - UINT32 RDT_A:1; - UINT32 Reserved2:2; - /// - /// [Bit 18] If 1 indicates the processor supports the RDSEED instruction. - /// - UINT32 RDSEED:1; - /// - /// [Bit 19] If 1 indicates the processor supports the ADCX and ADOX - /// instructions. - /// - UINT32 ADX:1; - /// - /// [Bit 20] Supports Supervisor-Mode Access Prevention (and the CLAC/STAC - /// instructions) if 1. - /// - UINT32 SMAP:1; - UINT32 Reserved3:2; - /// - /// [Bit 23] If 1 indicates the processor supports the CLFLUSHOPT instruction. - /// - UINT32 CLFLUSHOPT:1; - /// - /// [Bit 24] If 1 indicates the processor supports the CLWB instruction. - /// - UINT32 CLWB:1; - /// - /// [Bit 25] If 1 indicates the processor supports the Intel Processor Trace - /// extensions. - /// - UINT32 IntelProcessorTrace:1; - UINT32 Reserved4:3; - /// - /// [Bit 29] Supports Intel(R) Secure Hash Algorithm Extensions (Intel(R) - /// SHA Extensions) if 1. - /// - UINT32 SHA:1; - UINT32 Reserved5:2; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX; - -/** - CPUID Structured Extended Feature Flags Enumeration in ECX for CPUID leaf - #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS sub leaf - #CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] If 1 indicates the processor supports the PREFETCHWT1 instruction. - /// - UINT32 PREFETCHWT1:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Supports user-mode instruction prevention if 1. - /// - UINT32 UMIP:1; - /// - /// [Bit 3] Supports protection keys for user-mode pages if 1. - /// - UINT32 PKU:1; - /// - /// [Bit 4] If 1, OS has set CR4.PKE to enable protection keys (and the - /// RDPKRU/WRPKRU instructions). - /// - UINT32 OSPKE:1; - UINT32 Reserved2:12; - /// - /// [Bits 21:17] The value of MAWAU used by the BNDLDX and BNDSTX instructions - /// in 64-bit mode. - /// - UINT32 MAWAU:5; - /// - /// [Bit 22] Supports Read Processor ID if 1. - /// - UINT32 RDPID:1; - UINT32 Reserved3:7; - /// - /// [Bit 30] Supports SGX Launch Configuration if 1. - /// - UINT32 SGX_LC:1; - UINT32 Reserved4:1; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX; - - -/** - CPUID Direct Cache Access Information - - @param EAX CPUID_DIRECT_CACHE_ACCESS_INFO (0x09) - - @retval EAX Value of bits [31:0] of IA32_PLATFORM_DCA_CAP MSR (address 1F8H). - @retval EBX Reserved. - @retval ECX Reserved. - @retval EDX Reserved. - - Example usage - @code - UINT32 Eax; - - AsmCpuid (CPUID_DIRECT_CACHE_ACCESS_INFO, &Eax, NULL, NULL, NULL); - @endcode -**/ -#define CPUID_DIRECT_CACHE_ACCESS_INFO 0x09 - - -/** - CPUID Architectural Performance Monitoring - - @param EAX CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING (0x0A) - - @retval EAX Architectural Performance Monitoring information described by - the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX. - @retval EBX Architectural Performance Monitoring information described by - the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX. - @retval ECX Reserved. - @retval EDX Architectural Performance Monitoring information described by - the type CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX. - - Example usage - @code - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX Eax; - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX Ebx; - CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX Edx; - - AsmCpuid (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING, &Eax.Uint32, &Ebx.Uint32, NULL, &Edx.Uint32); - @endcode -**/ -#define CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING 0x0A - -/** - CPUID Architectural Performance Monitoring EAX for CPUID leaf - #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 7:0] Version ID of architectural performance monitoring. - /// - UINT32 ArchPerfMonVerID:8; - /// - /// [Bits 15:8] Number of general-purpose performance monitoring counter - /// per logical processor. - /// - /// IA32_PERFEVTSELx MSRs start at address 186H and occupy a contiguous - /// block of MSR address space. Each performance event select register is - /// paired with a corresponding performance counter in the 0C1H address - /// block. - /// - UINT32 PerformanceMonitorCounters:8; - /// - /// [Bits 23:16] Bit width of general-purpose, performance monitoring counter. - /// - /// The bit width of an IA32_PMCx MSR. This the number of valid bits for - /// read operation. On write operations, the lower-order 32 bits of the MSR - /// may be written with any value, and the high-order bits are sign-extended - /// from the value of bit 31. - /// - UINT32 PerformanceMonitorCounterWidth:8; - /// - /// [Bits 31:24] Length of EBX bit vector to enumerate architectural - /// performance monitoring events. - /// - UINT32 EbxBitVectorLength:8; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX; - -/** - CPUID Architectural Performance Monitoring EBX for CPUID leaf - #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core cycle event not available if 1. - /// - UINT32 UnhaltedCoreCycles:1; - /// - /// [Bit 1] Instruction retired event not available if 1. - /// - UINT32 InstructionsRetired:1; - /// - /// [Bit 2] Reference cycles event not available if 1. - /// - UINT32 UnhaltedReferenceCycles:1; - /// - /// [Bit 3] Last-level cache reference event not available if 1. - /// - UINT32 LastLevelCacheReferences:1; - /// - /// [Bit 4] Last-level cache misses event not available if 1. - /// - UINT32 LastLevelCacheMisses:1; - /// - /// [Bit 5] Branch instruction retired event not available if 1. - /// - UINT32 BranchInstructionsRetired:1; - /// - /// [Bit 6] Branch mispredict retired event not available if 1. - /// - UINT32 AllBranchMispredictRetired:1; - UINT32 Reserved:25; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX; - -/** - CPUID Architectural Performance Monitoring EDX for CPUID leaf - #CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Number of fixed-function performance counters - /// (if Version ID > 1). - /// - UINT32 FixedFunctionPerformanceCounters:5; - /// - /// [Bits 12:5] Bit width of fixed-function performance counters - /// (if Version ID > 1). - /// - UINT32 FixedFunctionPerformanceCounterWidth:8; - UINT32 Reserved:19; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX; - - -/** - CPUID Extended Topology Information - - @note - Most of Leaf 0BH output depends on the initial value in ECX. The EDX output - of leaf 0BH is always valid and does not vary with input value in ECX. Output - value in ECX[7:0] always equals input value in ECX[7:0]. For sub-leaves that - return an invalid level-type of 0 in ECX[15:8]; EAX and EBX will return 0. If - an input value n in ECX returns the invalid level-type of 0 in ECX[15:8], - other input values with ECX > n also return 0 in ECX[15:8]. - - @param EAX CPUID_EXTENDED_TOPOLOGY (0x0B) - @param ECX Level number - - @retval EAX Extended topology information described by the type - CPUID_EXTENDED_TOPOLOGY_EAX. - @retval EBX Extended topology information described by the type - CPUID_EXTENDED_TOPOLOGY_EBX. - @retval ECX Extended topology information described by the type - CPUID_EXTENDED_TOPOLOGY_ECX. - @retval EDX x2APIC ID the current logical processor. - - Example usage - @code - CPUID_EXTENDED_TOPOLOGY_EAX Eax; - CPUID_EXTENDED_TOPOLOGY_EBX Ebx; - CPUID_EXTENDED_TOPOLOGY_ECX Ecx; - UINT32 Edx; - UINT32 LevelNumber; - - LevelNumber = 0; - do { - AsmCpuidEx ( - CPUID_EXTENDED_TOPOLOGY, LevelNumber, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx - ); - LevelNumber++; - } while (Eax.Bits.ApicIdShift != 0); - @endcode -**/ -#define CPUID_EXTENDED_TOPOLOGY 0x0B - -/** - CPUID Extended Topology Information EAX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Number of bits to shift right on x2APIC ID to get a unique - /// topology ID of the next level type. All logical processors with the - /// same next level ID share current level. - /// - /// @note - /// Software should use this field (EAX[4:0]) to enumerate processor - /// topology of the system. - /// - UINT32 ApicIdShift:5; - UINT32 Reserved:27; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_TOPOLOGY_EAX; - -/** - CPUID Extended Topology Information EBX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Number of logical processors at this level type. The number - /// reflects configuration as shipped by Intel. - /// - /// @note - /// Software must not use EBX[15:0] to enumerate processor topology of the - /// system. This value in this field (EBX[15:0]) is only intended for - /// display/diagnostic purposes. The actual number of logical processors - /// available to BIOS/OS/Applications may be different from the value of - /// EBX[15:0], depending on software and platform hardware configurations. - /// - UINT32 LogicalProcessors:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_TOPOLOGY_EBX; - -/** - CPUID Extended Topology Information ECX for CPUID leaf #CPUID_EXTENDED_TOPOLOGY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Level number. Same value in ECX input. - /// - UINT32 LevelNumber:8; - /// - /// [Bits 15:8] Level type. - /// - /// @note - /// The value of the "level type" field is not related to level numbers in - /// any way, higher "level type" values do not mean higher levels. - /// - UINT32 LevelType:8; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_TOPOLOGY_ECX; - -/// -/// @{ Define value for CPUID_EXTENDED_TOPOLOGY_ECX.LevelType -/// -#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID 0x00 -#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT 0x01 -#define CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE 0x02 -/// -/// @} -/// - - -/** - CPUID Extended State Information - - @param EAX CPUID_EXTENDED_STATE (0x0D) - @param ECX CPUID_EXTENDED_STATE_MAIN_LEAF (0x00). - CPUID_EXTENDED_STATE_SUB_LEAF (0x01). - CPUID_EXTENDED_STATE_SIZE_OFFSET (0x02). - Sub leafs 2..n based on supported bits in XCR0 or IA32_XSS_MSR. -**/ -#define CPUID_EXTENDED_STATE 0x0D - -/** - CPUID Extended State Information Main Leaf - - @param EAX CPUID_EXTENDED_STATE (0x0D) - @param ECX CPUID_EXTENDED_STATE_MAIN_LEAF (0x00) - - @retval EAX Reports the supported bits of the lower 32 bits of XCR0. XCR0[n] - can be set to 1 only if EAX[n] is 1. The format of the extended - state main leaf is described by the type - CPUID_EXTENDED_STATE_MAIN_LEAF_EAX. - @retval EBX Maximum size (bytes, from the beginning of the XSAVE/XRSTOR save - area) required by enabled features in XCR0. May be different than - ECX if some features at the end of the XSAVE save area are not - enabled. - @retval ECX Maximum size (bytes, from the beginning of the XSAVE/XRSTOR save - area) of the XSAVE/XRSTOR save area required by all supported - features in the processor, i.e., all the valid bit fields in XCR0. - @retval EDX Reports the supported bits of the upper 32 bits of XCR0. - XCR0[n+32] can be set to 1 only if EDX[n] is 1. - - Example usage - @code - CPUID_EXTENDED_STATE_MAIN_LEAF_EAX Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF, - &Eax.Uint32, &Ebx, &Ecx, &Edx - ); - @endcode -**/ -#define CPUID_EXTENDED_STATE_MAIN_LEAF 0x00 - -/** - CPUID Extended State Information EAX for CPUID leaf #CPUID_EXTENDED_STATE, - sub-leaf #CPUID_EXTENDED_STATE_MAIN_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] x87 state. - /// - UINT32 x87:1; - /// - /// [Bit 1] SSE state. - /// - UINT32 SSE:1; - /// - /// [Bit 2] AVX state. - /// - UINT32 AVX:1; - /// - /// [Bits 4:3] MPX state. - /// - UINT32 MPX:2; - /// - /// [Bits 7:5] AVX-512 state. - /// - UINT32 AVX_512:3; - /// - /// [Bit 8] Used for IA32_XSS. - /// - UINT32 IA32_XSS:1; - /// - /// [Bit 9] PKRU state. - /// - UINT32 PKRU:1; - UINT32 Reserved:22; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_STATE_MAIN_LEAF_EAX; - -/** - CPUID Extended State Information Sub Leaf - - @param EAX CPUID_EXTENDED_STATE (0x0D) - @param ECX CPUID_EXTENDED_STATE_SUB_LEAF (0x01) - - @retval EAX The format of the extended state sub-leaf is described by the - type CPUID_EXTENDED_STATE_SUB_LEAF_EAX. - @retval EBX The size in bytes of the XSAVE area containing all states - enabled by XCRO | IA32_XSS. - @retval ECX The format of the extended state sub-leaf is described by the - type CPUID_EXTENDED_STATE_SUB_LEAF_ECX. - @retval EDX Reports the supported bits of the upper 32 bits of the - IA32_XSS MSR. IA32_XSS[n+32] can be set to 1 only if EDX[n] is 1. - - Example usage - @code - CPUID_EXTENDED_STATE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_EXTENDED_STATE_SUB_LEAF_ECX Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF, - &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx - ); - @endcode -**/ -#define CPUID_EXTENDED_STATE_SUB_LEAF 0x01 - -/** - CPUID Extended State Information EAX for CPUID leaf #CPUID_EXTENDED_STATE, - sub-leaf #CPUID_EXTENDED_STATE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] XSAVEOPT is available. - /// - UINT32 XSAVEOPT:1; - /// - /// [Bit 1] Supports XSAVEC and the compacted form of XRSTOR if set. - /// - UINT32 XSAVEC:1; - /// - /// [Bit 2] Supports XGETBV with ECX = 1 if set. - /// - UINT32 XGETBV:1; - /// - /// [Bit 3] Supports XSAVES/XRSTORS and IA32_XSS if set. - /// - UINT32 XSAVES:1; - UINT32 Reserved:28; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_STATE_SUB_LEAF_EAX; - -/** - CPUID Extended State Information ECX for CPUID leaf #CPUID_EXTENDED_STATE, - sub-leaf #CPUID_EXTENDED_STATE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Used for XCR0. - /// - UINT32 XCR0:1; - /// - /// [Bit 8] PT STate. - /// - UINT32 PT:1; - /// - /// [Bit 9] Used for XCR0. - /// - UINT32 XCR0_1:1; - UINT32 Reserved:22; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_STATE_SUB_LEAF_ECX; - -/** - CPUID Extended State Information Size and Offset Sub Leaf - - @note - Leaf 0DH output depends on the initial value in ECX. - Each sub-leaf index (starting at position 2) is supported if it corresponds to - a supported bit in either the XCR0 register or the IA32_XSS MSR. - If ECX contains an invalid sub-leaf index, EAX/EBX/ECX/EDX return 0. Sub-leaf - n (0 <= n <= 31) is invalid if sub-leaf 0 returns 0 in EAX[n] and sub-leaf 1 - returns 0 in ECX[n]. Sub-leaf n (32 <= n <= 63) is invalid if sub-leaf 0 - returns 0 in EDX[n-32] and sub-leaf 1 returns 0 in EDX[n-32]. - - @param EAX CPUID_EXTENDED_STATE (0x0D) - @param ECX CPUID_EXTENDED_STATE_SIZE_OFFSET (0x02). Sub leafs 2..n based - on supported bits in XCR0 or IA32_XSS_MSR. - - @retval EAX The size in bytes (from the offset specified in EBX) of the save - area for an extended state feature associated with a valid - sub-leaf index, n. - @retval EBX The offset in bytes of this extended state component's save area - from the beginning of the XSAVE/XRSTOR area. This field reports - 0 if the sub-leaf index, n, does not map to a valid bit in the - XCR0 register. - @retval ECX The format of the extended state components's save area as - described by the type CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX. - This field reports 0 if the sub-leaf index, n, is invalid. - @retval EDX This field reports 0 if the sub-leaf index, n, is invalid; - otherwise it is reserved. - - Example usage - @code - UINT32 Eax; - UINT32 Ebx; - CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX Ecx; - UINT32 Edx; - UINTN SubLeaf; - - for (SubLeaf = CPUID_EXTENDED_STATE_SIZE_OFFSET; SubLeaf < 32; SubLeaf++) { - AsmCpuidEx ( - CPUID_EXTENDED_STATE, SubLeaf, - &Eax, &Ebx, &Ecx.Uint32, &Edx - ); - } - @endcode -**/ -#define CPUID_EXTENDED_STATE_SIZE_OFFSET 0x02 - -/** - CPUID Extended State Information ECX for CPUID leaf #CPUID_EXTENDED_STATE, - sub-leaf #CPUID_EXTENDED_STATE_SIZE_OFFSET. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Is set if the bit n (corresponding to the sub-leaf index) is - /// supported in the IA32_XSS MSR; it is clear if bit n is instead supported - /// in XCR0. - /// - UINT32 XSS:1; - /// - /// [Bit 1] is set if, when the compacted format of an XSAVE area is used, - /// this extended state component located on the next 64-byte boundary - /// following the preceding state component (otherwise, it is located - /// immediately following the preceding state component). - /// - UINT32 Compacted:1; - UINT32 Reserved:30; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX; - - -/** - CPUID Intel Resource Director Technology (Intel RDT) Monitoring Information - - @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) - @param ECX CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF (0x00). - CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF (0x01). - -**/ -#define CPUID_INTEL_RDT_MONITORING 0x0F - -/** - CPUID Intel Resource Director Technology (Intel RDT) Monitoring Information - Enumeration Sub-leaf - - @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) - @param ECX CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF (0x00) - - @retval EAX Reserved. - @retval EBX Maximum range (zero-based) of RMID within this physical - processor of all types. - @retval ECX Reserved. - @retval EDX L3 Cache Intel RDT Monitoring Information Enumeration described by - the type CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX. - - Example usage - @code - UINT32 Ebx; - CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF, - NULL, &Ebx, NULL, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF 0x00 - -/** - CPUID Intel RDT Monitoring Information EDX for CPUID leaf - #CPUID_INTEL_RDT_MONITORING, sub-leaf - #CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Supports L3 Cache Intel RDT Monitoring if 1. - /// - UINT32 L3CacheRDT_M:1; - UINT32 Reserved2:30; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_MONITORING_ENUMERATION_SUB_LEAF_EDX; - -/** - CPUID L3 Cache Intel RDT Monitoring Capability Enumeration Sub-leaf - - @param EAX CPUID_INTEL_RDT_MONITORING (0x0F) - @param ECX CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF (0x01) - - @retval EAX Reserved. - @retval EBX Conversion factor from reported IA32_QM_CTR value to occupancy metric (bytes). - @retval ECX Maximum range (zero-based) of RMID of this resource type. - @retval EDX L3 Cache Intel RDT Monitoring Capability information described by the - type CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX. - - Example usage - @code - UINT32 Ebx; - UINT32 Ecx; - CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_MONITORING, CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF, - NULL, &Ebx, &Ecx, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF 0x01 - -/** - CPUID L3 Cache Intel RDT Monitoring Capability Information EDX for CPUID leaf - #CPUID_INTEL_RDT_MONITORING, sub-leaf - #CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Supports L3 occupancy monitoring if 1. - /// - UINT32 L3CacheOccupancyMonitoring:1; - /// - /// [Bit 1] Supports L3 Total Bandwidth monitoring if 1. - /// - UINT32 L3CacheTotalBandwidthMonitoring:1; - /// - /// [Bit 2] Supports L3 Local Bandwidth monitoring if 1. - /// - UINT32 L3CacheLocalBandwidthMonitoring:1; - UINT32 Reserved:29; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_MONITORING_L3_CACHE_SUB_LEAF_EDX; - - -/** - CPUID Intel Resource Director Technology (Intel RDT) Allocation Information - - @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10). - @param ECX CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF (0x00). - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF (0x01). - CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF (0x02). -**/ -#define CPUID_INTEL_RDT_ALLOCATION 0x10 - -/** - Intel Resource Director Technology (Intel RDT) Allocation Enumeration Sub-leaf - - @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) - @param ECX CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF (0x00). - - @retval EAX Reserved. - @retval EBX L3 and L2 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX. - @retval ECX Reserved. - @retval EDX Reserved. - - Example usage - @code - CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX Ebx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF, - NULL, &Ebx.Uint32, NULL, NULL - ); - @endcode -**/ -#define CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF 0x00 - -/** - CPUID L3 and L2 Cache Allocation Support Information EBX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Supports L3 Cache Allocation Technology if 1. - /// - UINT32 L3CacheAllocation:1; - /// - /// [Bit 2] Supports L2 Cache Allocation Technology if 1. - /// - UINT32 L2CacheAllocation:1; - UINT32 Reserved2:29; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_ENUMERATION_SUB_LEAF_EBX; - - -/** - L3 Cache Allocation Technology Enumeration Sub-leaf - - @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) - @param ECX CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF (0x01) - - @retval EAX RESID L3 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX. - @retval EBX Bit-granular map of isolation/contention of allocation units. - @retval ECX RESID L3 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX. - @retval EDX RESID L3 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX. - - Example usage - @code - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX Ecx; - CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF, - &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF 0x01 - -/** - CPUID L3 Cache Allocation Technology Information EAX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Length of the capacity bit mask for the corresponding ResID - /// using minus-one notation. - /// - UINT32 CapacityLength:5; - UINT32 Reserved:27; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EAX; - -/** - CPUID L3 Cache Allocation Technology Information ECX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Updates of COS should be infrequent if 1. - /// - UINT32 CosUpdatesInfrequent:1; - /// - /// [Bit 2] Code and Data Prioritization Technology supported if 1. - /// - UINT32 CodeDataPrioritization:1; - UINT32 Reserved2:29; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_ECX; - -/** - CPUID L3 Cache Allocation Technology Information EDX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Highest COS number supported for this ResID. - /// - UINT32 HighestCosNumber:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_L3_CACHE_SUB_LEAF_EDX; - -/** - L2 Cache Allocation Technology Enumeration Sub-leaf - - @param EAX CPUID_INTEL_RDT_ALLOCATION (0x10) - @param ECX CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF (0x02) - - @retval EAX RESID L2 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX. - @retval EBX Bit-granular map of isolation/contention of allocation units. - @retval ECX Reserved. - @retval EDX RESID L2 Cache Allocation Technology information described by - the type CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX. - - Example usage - @code - CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_RDT_ALLOCATION, CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF, - &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF 0x02 - -/** - CPUID L2 Cache Allocation Technology Information EAX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] Length of the capacity bit mask for the corresponding ResID - /// using minus-one notation. - /// - UINT32 CapacityLength:5; - UINT32 Reserved:27; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EAX; - -/** - CPUID L2 Cache Allocation Technology Information EDX for CPUID leaf - #CPUID_INTEL_RDT_ALLOCATION, sub-leaf - #CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Highest COS number supported for this ResID. - /// - UINT32 HighestCosNumber:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_RDT_ALLOCATION_L2_CACHE_SUB_LEAF_EDX; - - -/** - Intel SGX resource capability and configuration. - See Section 37.7.2 "Intel(R) SGX Resource Enumeration Leaves". - - If CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1, the processor also supports querying - CPUID with EAX=12H on Intel SGX resource capability and configuration. - - @param EAX CPUID_INTEL_SGX (0x12) - @param ECX CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF (0x00). - CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF (0x01). - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF (0x02). - Sub leafs 2..n based on the sub-leaf-type encoding (returned in EAX[3:0]) - until the sub-leaf type is invalid. - -**/ -#define CPUID_INTEL_SGX 0x12 - -/** - Sub-Leaf 0 Enumeration of Intel SGX Capabilities. - Enumerates Intel SGX capability, including enclave instruction opcode support. - - @param EAX CPUID_INTEL_SGX (0x12) - @param ECX CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF (0x00) - - @retval EAX The format of Sub-Leaf 0 Enumeration of Intel SGX Capabilities is - described by the type CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX. - @retval EBX MISCSELECT: Reports the bit vector of supported extended features - that can be written to the MISC region of the SSA. - @retval ECX Reserved. - @retval EDX The format of Sub-Leaf 0 Enumeration of Intel SGX Capabilities is - described by the type CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX. - - Example usage - @code - CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX Eax; - UINT32 Ebx; - CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF, - &Eax.Uint32, &Ebx, NULL, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF 0x00 - -/** - Sub-Leaf 0 Enumeration of Intel SGX Capabilities EAX for CPUID leaf #CPUID_INTEL_SGX, - sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] If 1, indicates leaf functions of SGX1 instruction are supported. - /// - UINT32 SGX1:1; - /// - /// [Bit 1] If 1, indicates leaf functions of SGX2 instruction are supported. - /// - UINT32 SGX2:1; - UINT32 Reserved:30; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX; - -/** - Sub-Leaf 0 Enumeration of Intel SGX Capabilities EDX for CPUID leaf #CPUID_INTEL_SGX, - sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 7:0] The maximum supported enclave size is 2^(EDX[7:0]) bytes - /// when not in 64-bit mode. - /// - UINT32 MaxEnclaveSize_Not64:8; - /// - /// [Bit 15:8] The maximum supported enclave size is 2^(EDX[15:8]) bytes - /// when operating in 64-bit mode. - /// - UINT32 MaxEnclaveSize_64:8; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX; - - -/** - Sub-Leaf 1 Enumeration of Intel SGX Capabilities. - Enumerates Intel SGX capability of processor state configuration and enclave - configuration in the SECS structure. - - @param EAX CPUID_INTEL_SGX (0x12) - @param ECX CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF (0x01) - - @retval EAX Report the valid bits of SECS.ATTRIBUTES[31:0] that software can - set with ECREATE. SECS.ATTRIBUTES[n] can be set to 1 using ECREATE - only if EAX[n] is 1, where n < 32. - @retval EBX Report the valid bits of SECS.ATTRIBUTES[63:32] that software can - set with ECREATE. SECS.ATTRIBUTES[n+32] can be set to 1 using ECREATE - only if EBX[n] is 1, where n < 32. - @retval ECX Report the valid bits of SECS.ATTRIBUTES[95:64] that software can - set with ECREATE. SECS.ATTRIBUTES[n+64] can be set to 1 using ECREATE - only if ECX[n] is 1, where n < 32. - @retval EDX Report the valid bits of SECS.ATTRIBUTES[127:96] that software can - set with ECREATE. SECS.ATTRIBUTES[n+96] can be set to 1 using ECREATE - only if EDX[n] is 1, where n < 32. - - Example usage - @code - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF, - &Eax, &Ebx, &Ecx, &Edx - ); - @endcode -**/ -#define CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF 0x01 - - -/** - Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources. - Enumerates available EPC resources. - - @param EAX CPUID_INTEL_SGX (0x12) - @param ECX CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF (0x02) - - @retval EAX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX - Resources is described by the type - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX. - @retval EBX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX - Resources is described by the type - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX. - @retval EDX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX - Resources is described by the type - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX. - @retval EDX The format of Sub-Leaf Index 2 or Higher Enumeration of Intel SGX - Resources is described by the type - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX. - - Example usage - @code - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX Eax; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX Ebx; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX Ecx; - CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX Edx; - - AsmCpuidEx ( - CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF 0x02 - -/** - Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EAX for CPUID - leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 3:0] Sub-leaf-type encoding. - /// 0000b: This sub-leaf is invalid, EBX:EAX and EDX:ECX report 0. - /// 0001b: This sub-leaf provides information on the Enclave Page Cache (EPC) - /// in EBX:EAX and EDX:ECX. - /// All other encoding are reserved. - /// - UINT32 SubLeafType:4; - UINT32 Reserved:8; - /// - /// [Bit 31:12] If EAX[3:0] = 0001b, these are bits 31:12 of the physical address of - /// the base of the EPC section. - /// - UINT32 LowAddressOfEpcSection:20; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX; - -/** - Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EBX for CPUID - leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 19:0] If EAX[3:0] = 0001b, these are bits 51:32 of the physical address of - /// the base of the EPC section. - /// - UINT32 HighAddressOfEpcSection:20; - UINT32 Reserved:12; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX; - -/** - Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources ECX for CPUID - leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 3:0] The EPC section encoding. - /// 0000b: Not valid. - /// 0001b: The EPC section is confidentiality, integrity and replay protected. - /// All other encoding are reserved. - /// - UINT32 EpcSection:4; - UINT32 Reserved:8; - /// - /// [Bit 31:12] If EAX[3:0] = 0001b, these are bits 31:12 of the size of the - /// corresponding EPC section within the Processor Reserved Memory. - /// - UINT32 LowSizeOfEpcSection:20; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX; - -/** - Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources EDX for CPUID - leaf #CPUID_INTEL_SGX, sub-leaf #CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 19:0] If EAX[3:0] = 0001b, these are bits 51:32 of the size of the - /// corresponding EPC section within the Processor Reserved Memory. - /// - UINT32 HighSizeOfEpcSection:20; - UINT32 Reserved:12; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX; - - -/** - CPUID Intel Processor Trace Information - - @param EAX CPUID_INTEL_PROCESSOR_TRACE (0x14) - @param ECX CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF (0x00). - CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF (0x01). - -**/ -#define CPUID_INTEL_PROCESSOR_TRACE 0x14 - -/** - CPUID Intel Processor Trace Information Main Leaf - - @param EAX CPUID_INTEL_PROCEDSSOR_TRACE (0x14) - @param ECX CPUID_INTEL_PROCEDSSOR_TRACE_MAIN_LEAF (0x00) - - @retval EAX Reports the maximum sub-leaf supported in leaf 14H. - @retval EBX Returns Intel processor trace information described by the - type CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX. - @retval ECX Returns Intel processor trace information described by the - type CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX. - @retval EDX Reserved. - - Example usage - @code - UINT32 Eax; - CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX Ebx; - CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX Ecx; - - AsmCpuidEx ( - CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, - &Eax, &Ebx.Uint32, &Ecx.Uint32, NULL - ); - @endcode -**/ -#define CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF 0x00 - -/** - CPUID Intel Processor Trace EBX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, - sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] If 1, indicates that IA32_RTIT_CTL.CR3Filter can be set to 1, - /// and that IA32_RTIT_CR3_MATCH MSR can be accessed. - /// - UINT32 Cr3Filter:1; - /// - /// [Bit 1] If 1, indicates support of Configurable PSB and Cycle-Accurate - /// Mode. - /// - UINT32 ConfigurablePsb:1; - /// - /// [Bit 2] If 1, indicates support of IP Filtering, TraceStop filtering, - /// and preservation of Intel PT MSRs across warm reset. - /// - UINT32 IpTraceStopFiltering:1; - /// - /// [Bit 3] If 1, indicates support of MTC timing packet and suppression of - /// COFI-based packets. - /// - UINT32 Mtc:1; - /// - /// [Bit 4] If 1, indicates support of PTWRITE. Writes can set - /// IA32_RTIT_CTL[12] (PTWEn) and IA32_RTIT_CTL[5] (FUPonPTW), and PTWRITE - /// can generate packets. - /// - UINT32 PTWrite:1; - /// - /// [Bit 5] If 1, indicates support of Power Event Trace. Writes can set - /// IA32_RTIT_CTL[4] (PwrEvtEn), enabling Power Event Trace packet - /// generation. - /// - UINT32 PowerEventTrace:1; - UINT32 Reserved:26; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX; - -/** - CPUID Intel Processor Trace ECX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, - sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] If 1, Tracing can be enabled with IA32_RTIT_CTL.ToPA = 1, hence - /// utilizing the ToPA output scheme; IA32_RTIT_OUTPUT_BASE and - /// IA32_RTIT_OUTPUT_MASK_PTRS MSRs can be accessed. - /// - UINT32 RTIT:1; - /// - /// [Bit 1] If 1, ToPA tables can hold any number of output entries, up to - /// the maximum allowed by the MaskOrTableOffset field of - /// IA32_RTIT_OUTPUT_MASK_PTRS. - /// - UINT32 ToPA:1; - /// - /// [Bit 2] If 1, indicates support of Single-Range Output scheme. - /// - UINT32 SingleRangeOutput:1; - /// - /// [Bit 3] If 1, indicates support of output to Trace Transport subsystem. - /// - UINT32 TraceTransportSubsystem:1; - UINT32 Reserved:27; - /// - /// [Bit 31] If 1, generated packets which contain IP payloads have LIP - /// values, which include the CS base component. - /// - UINT32 LIP:1; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX; - - -/** - CPUID Intel Processor Trace Information Sub-leaf - - @param EAX CPUID_INTEL_PROCEDSSOR_TRACE (0x14) - @param ECX CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF (0x01) - - @retval EAX Returns Intel processor trace information described by the - type CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX. - @retval EBX Returns Intel processor trace information described by the - type CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX. - @retval ECX Reserved. - @retval EDX Reserved. - - Example usage - @code - UINT32 MaximumSubLeaf; - UINT32 SubLeaf; - CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX Eax; - CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX Ebx; - - AsmCpuidEx ( - CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF, - &MaximumSubLeaf, NULL, NULL, NULL - ); - - for (SubLeaf = CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF; SubLeaf <= MaximumSubLeaf; SubLeaf++) { - AsmCpuidEx ( - CPUID_INTEL_PROCESSOR_TRACE, SubLeaf, - &Eax.Uint32, &Ebx.Uint32, NULL, NULL - ); - } - @endcode -**/ -#define CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF 0x01 - -/** - CPUID Intel Processor Trace EAX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, - sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Number of configurable Address Ranges for filtering. - /// - UINT32 ConfigurableAddressRanges:3; - UINT32 Reserved:13; - /// - /// [Bits 31:16] Bitmap of supported MTC period encodings - /// - UINT32 MtcPeriodEncodings:16; - - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX; - -/** - CPUID Intel Processor Trace EBX for CPUID leaf #CPUID_INTEL_PROCESSOR_TRACE, - sub-leaf #CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Bitmap of supported Cycle Threshold value encodings. - /// - UINT32 CycleThresholdEncodings:16; - /// - /// [Bits 31:16] Bitmap of supported Configurable PSB frequency encodings. - /// - UINT32 PsbFrequencyEncodings:16; - - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX; - - -/** - CPUID Time Stamp Counter and Nominal Core Crystal Clock Information - - @note - If EBX[31:0] is 0, the TSC/"core crystal clock" ratio is not enumerated. - EBX[31:0]/EAX[31:0] indicates the ratio of the TSC frequency and the core - crystal clock frequency. - If ECX is 0, the nominal core crystal clock frequency is not enumerated. - "TSC frequency" = "core crystal clock frequency" * EBX/EAX. - The core crystal clock may differ from the reference clock, bus clock, or core - clock frequencies. - - @param EAX CPUID_TIME_STAMP_COUNTER (0x15) - - @retval EAX An unsigned integer which is the denominator of the - TSC/"core crystal clock" ratio - @retval EBX An unsigned integer which is the numerator of the - TSC/"core crystal clock" ratio. - @retval ECX An unsigned integer which is the nominal frequency - of the core crystal clock in Hz. - @retval EDX Reserved. - - Example usage - @code - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - - AsmCpuid (CPUID_TIME_STAMP_COUNTER, &Eax, &Ebx, &Ecx, NULL); - @endcode -**/ -#define CPUID_TIME_STAMP_COUNTER 0x15 - - -/** - CPUID Processor Frequency Information - - @note - Data is returned from this interface in accordance with the processor's - specification and does not reflect actual values. Suitable use of this data - includes the display of processor information in like manner to the processor - brand string and for determining the appropriate range to use when displaying - processor information e.g. frequency history graphs. The returned information - should not be used for any other purpose as the returned information does not - accurately correlate to information / counters returned by other processor - interfaces. While a processor may support the Processor Frequency Information - leaf, fields that return a value of zero are not supported. - - @param EAX CPUID_TIME_STAMP_COUNTER (0x16) - - @retval EAX Returns processor base frequency information described by the - type CPUID_PROCESSOR_FREQUENCY_EAX. - @retval EBX Returns maximum frequency information described by the type - CPUID_PROCESSOR_FREQUENCY_EBX. - @retval ECX Returns bus frequency information described by the type - CPUID_PROCESSOR_FREQUENCY_ECX. - @retval EDX Reserved. - - Example usage - @code - CPUID_PROCESSOR_FREQUENCY_EAX Eax; - CPUID_PROCESSOR_FREQUENCY_EBX Ebx; - CPUID_PROCESSOR_FREQUENCY_ECX Ecx; - - AsmCpuid (CPUID_PROCESSOR_FREQUENCY, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL); - @endcode -**/ -#define CPUID_PROCESSOR_FREQUENCY 0x16 - -/** - CPUID Processor Frequency Information EAX for CPUID leaf - #CPUID_PROCESSOR_FREQUENCY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Processor Base Frequency (in MHz). - /// - UINT32 ProcessorBaseFrequency:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_PROCESSOR_FREQUENCY_EAX; - -/** - CPUID Processor Frequency Information EBX for CPUID leaf - #CPUID_PROCESSOR_FREQUENCY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Maximum Frequency (in MHz). - /// - UINT32 MaximumFrequency:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_PROCESSOR_FREQUENCY_EBX; - -/** - CPUID Processor Frequency Information ECX for CPUID leaf - #CPUID_PROCESSOR_FREQUENCY. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Bus (Reference) Frequency (in MHz). - /// - UINT32 BusFrequency:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_PROCESSOR_FREQUENCY_ECX; - - -/** - CPUID SoC Vendor Information - - @param EAX CPUID_SOC_VENDOR (0x17) - @param ECX CPUID_SOC_VENDOR_MAIN_LEAF (0x00) - CPUID_SOC_VENDOR_BRAND_STRING1 (0x01) - CPUID_SOC_VENDOR_BRAND_STRING1 (0x02) - CPUID_SOC_VENDOR_BRAND_STRING1 (0x03) - - @note - Leaf 17H output depends on the initial value in ECX. SOC Vendor Brand String - is a UTF-8 encoded string padded with trailing bytes of 00H. The complete SOC - Vendor Brand String is constructed by concatenating in ascending order of - EAX:EBX:ECX:EDX and from the sub-leaf 1 fragment towards sub-leaf 3. - -**/ -#define CPUID_SOC_VENDOR 0x17 - -/** - CPUID SoC Vendor Information - - @param EAX CPUID_SOC_VENDOR (0x17) - @param ECX CPUID_SOC_VENDOR_MAIN_LEAF (0x00) - - @retval EAX MaxSOCID_Index. Reports the maximum input value of supported - sub-leaf in leaf 17H. - @retval EBX Returns SoC Vendor information described by the type - CPUID_SOC_VENDOR_MAIN_LEAF_EBX. - @retval ECX Project ID. A unique number an SOC vendor assigns to its SOC - projects. - @retval EDX Stepping ID. A unique number within an SOC project that an SOC - vendor assigns. - - Example usage - @code - UINT32 Eax; - CPUID_SOC_VENDOR_MAIN_LEAF_EBX Ebx; - UINT32 Ecx; - UINT32 Edx; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF, - &Eax, &Ebx.Uint32, &Ecx, &Edx - ); - @endcode -**/ -#define CPUID_SOC_VENDOR_MAIN_LEAF 0x00 - -/** - CPUID SoC Vendor Information EBX for CPUID leaf #CPUID_SOC_VENDOR sub-leaf - #CPUID_SOC_VENDOR_MAIN_LEAF. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] SOC Vendor ID. - /// - UINT32 SocVendorId:16; - /// - /// [Bit 16] If 1, the SOC Vendor ID field is assigned via an industry - /// standard enumeration scheme. Otherwise, the SOC Vendor ID field is - /// assigned by Intel. - /// - UINT32 IsVendorScheme:1; - UINT32 Reserved:15; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_SOC_VENDOR_MAIN_LEAF_EBX; - -/** - CPUID SoC Vendor Information - - @param EAX CPUID_SOC_VENDOR (0x17) - @param ECX CPUID_SOC_VENDOR_BRAND_STRING1 (0x01) - - @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - - Example usage - @code - CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_SOC_VENDOR_BRAND_STRING1 0x01 - -/** - CPUID SoC Vendor Brand String for CPUID leafs #CPUID_SOC_VENDOR_BRAND_STRING1, - #CPUID_SOC_VENDOR_BRAND_STRING2, and #CPUID_SOC_VENDOR_BRAND_STRING3. -**/ -typedef union { - /// - /// 4 UTF-8 characters of Soc Vendor Brand String - /// - CHAR8 BrandString[4]; - /// - /// All fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_SOC_VENDOR_BRAND_STRING_DATA; - -/** - CPUID SoC Vendor Information - - @param EAX CPUID_SOC_VENDOR (0x17) - @param ECX CPUID_SOC_VENDOR_BRAND_STRING2 (0x02) - - @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - - Example usage - @code - CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_SOC_VENDOR_BRAND_STRING2 0x02 - -/** - CPUID SoC Vendor Information - - @param EAX CPUID_SOC_VENDOR (0x17) - @param ECX CPUID_SOC_VENDOR_BRAND_STRING3 (0x03) - - @retval EAX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EBX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval ECX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - @retval EDX SOC Vendor Brand String. UTF-8 encoded string of type - CPUID_SOC_VENDOR_BRAND_STRING_DATA. - - Example usage - @code - CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx; - CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx; - - AsmCpuidEx ( - CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3, - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 - ); - @endcode -**/ -#define CPUID_SOC_VENDOR_BRAND_STRING3 0x03 - - -/** - CPUID Extended Function - - @param EAX CPUID_EXTENDED_FUNCTION (0x80000000) - - @retval EAX Maximum Input Value for Extended Function CPUID Information. - @retval EBX Reserved. - @retval ECX Reserved. - @retval EDX Reserved. - - Example usage - @code - UINT32 Eax; - - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); - @endcode -**/ -#define CPUID_EXTENDED_FUNCTION 0x80000000 - - -/** - CPUID Extended Processor Signature and Feature Bits - - @param EAX CPUID_EXTENDED_CPU_SIG (0x80000001) - - @retval EAX CPUID_EXTENDED_CPU_SIG. - @retval EBX Reserved. - @retval ECX Extended Processor Signature and Feature Bits information - described by the type CPUID_EXTENDED_CPU_SIG_ECX. - @retval EDX Extended Processor Signature and Feature Bits information - described by the type CPUID_EXTENDED_CPU_SIG_EDX. - - Example usage - @code - UINT32 Eax; - CPUID_EXTENDED_CPU_SIG_ECX Ecx; - CPUID_EXTENDED_CPU_SIG_EDX Edx; - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, &Eax, NULL, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_EXTENDED_CPU_SIG 0x80000001 - -/** - CPUID Extended Processor Signature and Feature Bits ECX for CPUID leaf - #CPUID_EXTENDED_CPU_SIG. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] LAHF/SAHF available in 64-bit mode. - /// - UINT32 LAHF_SAHF:1; - UINT32 Reserved1:4; - /// - /// [Bit 5] LZCNT. - /// - UINT32 LZCNT:1; - UINT32 Reserved2:2; - /// - /// [Bit 8] PREFETCHW. - /// - UINT32 PREFETCHW:1; - UINT32 Reserved3:23; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_CPU_SIG_ECX; - -/** - CPUID Extended Processor Signature and Feature Bits EDX for CPUID leaf - #CPUID_EXTENDED_CPU_SIG. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:11; - /// - /// [Bit 11] SYSCALL/SYSRET available in 64-bit mode. - /// - UINT32 SYSCALL_SYSRET:1; - UINT32 Reserved2:8; - /// - /// [Bit 20] Execute Disable Bit available. - /// - UINT32 NX:1; - UINT32 Reserved3:5; - /// - /// [Bit 26] 1-GByte pages are available if 1. - /// - UINT32 Page1GB:1; - /// - /// [Bit 27] RDTSCP and IA32_TSC_AUX are available if 1. - /// - UINT32 RDTSCP:1; - UINT32 Reserved4:1; - /// - /// [Bit 29] Intel(R) 64 Architecture available if 1. - /// - UINT32 LM:1; - UINT32 Reserved5:2; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_CPU_SIG_EDX; - - -/** - CPUID Processor Brand String - - @param EAX CPUID_BRAND_STRING1 (0x80000002) - - @retval EAX Processor Brand String in type CPUID_BRAND_STRING_DATA. - @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - - Example usage - @code - CPUID_BRAND_STRING_DATA Eax; - CPUID_BRAND_STRING_DATA Ebx; - CPUID_BRAND_STRING_DATA Ecx; - CPUID_BRAND_STRING_DATA Edx; - - AsmCpuid (CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_BRAND_STRING1 0x80000002 - -/** - CPUID Processor Brand String for CPUID leafs #CPUID_BRAND_STRING1, - #CPUID_BRAND_STRING2, and #CPUID_BRAND_STRING3. -**/ -typedef union { - /// - /// 4 ASCII characters of Processor Brand String - /// - CHAR8 BrandString[4]; - /// - /// All fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_BRAND_STRING_DATA; - -/** - CPUID Processor Brand String - - @param EAX CPUID_BRAND_STRING2 (0x80000003) - - @retval EAX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - - Example usage - @code - CPUID_BRAND_STRING_DATA Eax; - CPUID_BRAND_STRING_DATA Ebx; - CPUID_BRAND_STRING_DATA Ecx; - CPUID_BRAND_STRING_DATA Edx; - - AsmCpuid (CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_BRAND_STRING2 0x80000003 - -/** - CPUID Processor Brand String - - @param EAX CPUID_BRAND_STRING3 (0x80000004) - - @retval EAX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval EBX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval ECX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - @retval EDX Processor Brand String Continued in type CPUID_BRAND_STRING_DATA. - - Example usage - @code - CPUID_BRAND_STRING_DATA Eax; - CPUID_BRAND_STRING_DATA Ebx; - CPUID_BRAND_STRING_DATA Ecx; - CPUID_BRAND_STRING_DATA Edx; - - AsmCpuid (CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32); - @endcode -**/ -#define CPUID_BRAND_STRING3 0x80000004 - - -/** - CPUID Extended Cache information - - @param EAX CPUID_EXTENDED_CACHE_INFO (0x80000006) - - @retval EAX Reserved. - @retval EBX Reserved. - @retval ECX Extended cache information described by the type - CPUID_EXTENDED_CACHE_INFO_ECX. - @retval EDX Reserved. - - Example usage - @code - CPUID_EXTENDED_CACHE_INFO_ECX Ecx; - - AsmCpuid (CPUID_EXTENDED_CACHE_INFO, NULL, NULL, &Ecx.Uint32, NULL); - @endcode -**/ -#define CPUID_EXTENDED_CACHE_INFO 0x80000006 - -/** - CPUID Extended Cache information ECX for CPUID leaf #CPUID_EXTENDED_CACHE_INFO. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Cache line size in bytes. - /// - UINT32 CacheLineSize:8; - UINT32 Reserved:4; - /// - /// [Bits 15:12] L2 Associativity field. Supported values are in the range - /// #CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DISABLED to - /// #CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_FULL - /// - UINT32 L2Associativity:4; - /// - /// [Bits 31:16] Cache size in 1K units. - /// - UINT32 CacheSize:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_CACHE_INFO_ECX; - -/// -/// @{ Define value for bit field CPUID_EXTENDED_CACHE_INFO_ECX.L2Associativity -/// -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DISABLED 0x00 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_DIRECT_MAPPED 0x01 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_2_WAY 0x02 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_4_WAY 0x04 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_8_WAY 0x06 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_16_WAY 0x08 -#define CPUID_EXTENDED_CACHE_INFO_ECX_L2_ASSOCIATIVITY_FULL 0x0F -/// -/// @} -/// - -/** - CPUID Extended Time Stamp Counter information - - @param EAX CPUID_EXTENDED_TIME_STAMP_COUNTER (0x80000007) - - @retval EAX Reserved. - @retval EBX Reserved. - @retval ECX Reserved. - @retval EDX Extended time stamp counter (TSC) information described by the - type CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX. - - Example usage - @code - CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX Edx; - - AsmCpuid (CPUID_EXTENDED_TIME_STAMP_COUNTER, NULL, NULL, NULL, &Edx.Uint32); - @endcode -**/ -#define CPUID_EXTENDED_TIME_STAMP_COUNTER 0x80000007 - -/** - CPUID Extended Time Stamp Counter information EDX for CPUID leaf - #CPUID_EXTENDED_TIME_STAMP_COUNTER. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bit 8] Invariant TSC available if 1. - /// - UINT32 InvariantTsc:1; - UINT32 Reserved2:23; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX; - - -/** - CPUID Linear Physical Address Size - - @param EAX CPUID_VIR_PHY_ADDRESS_SIZE (0x80000008) - - @retval EAX Linear/Physical Address Size described by the type - CPUID_VIR_PHY_ADDRESS_SIZE_EAX. - @retval EBX Reserved. - @retval ECX Reserved. - @retval EDX Reserved. - - Example usage - @code - CPUID_VIR_PHY_ADDRESS_SIZE_EAX Eax; - - AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Eax.Uint32, NULL, NULL, NULL); - @endcode -**/ -#define CPUID_VIR_PHY_ADDRESS_SIZE 0x80000008 - -/** - CPUID Linear Physical Address Size EAX for CPUID leaf - #CPUID_VIR_PHY_ADDRESS_SIZE. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Number of physical address bits. - /// - /// @note - /// If CPUID.80000008H:EAX[7:0] is supported, the maximum physical address - /// number supported should come from this field. - /// - UINT32 PhysicalAddressBits:8; - /// - /// [Bits 15:8] Number of linear address bits. - /// - UINT32 LinearAddressBits:8; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; -} CPUID_VIR_PHY_ADDRESS_SIZE_EAX; - -#endif diff --git a/UefiCpuPkg/Include/Register/LocalApic.h b/UefiCpuPkg/Include/Register/LocalApic.h deleted file mode 100644 index cfb6d76d8b..0000000000 --- a/UefiCpuPkg/Include/Register/LocalApic.h +++ /dev/null @@ -1,189 +0,0 @@ -/** @file - IA32 Local APIC Definitions. - - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __LOCAL_APIC_H__ -#define __LOCAL_APIC_H__ - -// -// Definition for Local APIC registers and related values -// -#define XAPIC_ID_OFFSET 0x20 -#define XAPIC_VERSION_OFFSET 0x30 -#define XAPIC_EOI_OFFSET 0x0b0 -#define XAPIC_ICR_DFR_OFFSET 0x0e0 -#define XAPIC_SPURIOUS_VECTOR_OFFSET 0x0f0 -#define XAPIC_ICR_LOW_OFFSET 0x300 -#define XAPIC_ICR_HIGH_OFFSET 0x310 -#define XAPIC_LVT_TIMER_OFFSET 0x320 -#define XAPIC_LVT_LINT0_OFFSET 0x350 -#define XAPIC_LVT_LINT1_OFFSET 0x360 -#define XAPIC_TIMER_INIT_COUNT_OFFSET 0x380 -#define XAPIC_TIMER_CURRENT_COUNT_OFFSET 0x390 -#define XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET 0x3E0 - -#define X2APIC_MSR_BASE_ADDRESS 0x800 -#define X2APIC_MSR_ICR_ADDRESS 0x830 - -#define LOCAL_APIC_DELIVERY_MODE_FIXED 0 -#define LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY 1 -#define LOCAL_APIC_DELIVERY_MODE_SMI 2 -#define LOCAL_APIC_DELIVERY_MODE_NMI 4 -#define LOCAL_APIC_DELIVERY_MODE_INIT 5 -#define LOCAL_APIC_DELIVERY_MODE_STARTUP 6 -#define LOCAL_APIC_DELIVERY_MODE_EXTINT 7 - -#define LOCAL_APIC_DESTINATION_SHORTHAND_NO_SHORTHAND 0 -#define LOCAL_APIC_DESTINATION_SHORTHAND_SELF 1 -#define LOCAL_APIC_DESTINATION_SHORTHAND_ALL_INCLUDING_SELF 2 -#define LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF 3 - -// -// Local APIC Version Register. -// -typedef union { - struct { - UINT32 Version:8; ///< The version numbers of the local APIC. - UINT32 Reserved0:8; ///< Reserved. - UINT32 MaxLvtEntry:8; ///< Number of LVT entries minus 1. - UINT32 EoiBroadcastSuppression:1; ///< 1 if EOI-broadcast suppression supported. - UINT32 Reserved1:7; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_VERSION; - -// -// Low half of Interrupt Command Register (ICR). -// -typedef union { - struct { - UINT32 Vector:8; ///< The vector number of the interrupt being sent. - UINT32 DeliveryMode:3; ///< Specifies the type of IPI to be sent. - UINT32 DestinationMode:1; ///< 0: physical destination mode, 1: logical destination mode. - UINT32 DeliveryStatus:1; ///< Indicates the IPI delivery status. This field is reserved in x2APIC mode. - UINT32 Reserved0:1; ///< Reserved. - UINT32 Level:1; ///< 0 for the INIT level de-assert delivery mode. Otherwise 1. - UINT32 TriggerMode:1; ///< 0: edge, 1: level when using the INIT level de-assert delivery mode. - UINT32 Reserved1:2; ///< Reserved. - UINT32 DestinationShorthand:2; ///< A shorthand notation to specify the destination of the interrupt. - UINT32 Reserved2:12; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_ICR_LOW; - -// -// High half of Interrupt Command Register (ICR) -// -typedef union { - struct { - UINT32 Reserved0:24; ///< Reserved. - UINT32 Destination:8; ///< Specifies the target processor or processors in xAPIC mode. - } Bits; - UINT32 Uint32; ///< Destination field expanded to 32-bit in x2APIC mode. -} LOCAL_APIC_ICR_HIGH; - -// -// Spurious-Interrupt Vector Register (SVR) -// -typedef union { - struct { - UINT32 SpuriousVector:8; ///< Spurious Vector. - UINT32 SoftwareEnable:1; ///< APIC Software Enable/Disable. - UINT32 FocusProcessorChecking:1; ///< Focus Processor Checking. - UINT32 Reserved0:2; ///< Reserved. - UINT32 EoiBroadcastSuppression:1; ///< EOI-Broadcast Suppression. - UINT32 Reserved1:19; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_SVR; - -// -// Divide Configuration Register (DCR) -// -typedef union { - struct { - UINT32 DivideValue1:2; ///< Low 2 bits of the divide value. - UINT32 Reserved0:1; ///< Always 0. - UINT32 DivideValue2:1; ///< Highest 1 bit of the divide value. - UINT32 Reserved1:28; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_DCR; - -// -// LVT Timer Register -// -typedef union { - struct { - UINT32 Vector:8; ///< The vector number of the interrupt being sent. - UINT32 Reserved0:4; ///< Reserved. - UINT32 DeliveryStatus:1; ///< 0: Idle, 1: send pending. - UINT32 Reserved1:3; ///< Reserved. - UINT32 Mask:1; ///< 0: Not masked, 1: Masked. - UINT32 TimerMode:1; ///< 0: One-shot, 1: Periodic. - UINT32 Reserved2:14; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_LVT_TIMER; - -// -// LVT LINT0/LINT1 Register -// -typedef union { - struct { - UINT32 Vector:8; ///< The vector number of the interrupt being sent. - UINT32 DeliveryMode:3; ///< Specifies the type of interrupt to be sent. - UINT32 Reserved0:1; ///< Reserved. - UINT32 DeliveryStatus:1; ///< 0: Idle, 1: send pending. - UINT32 InputPinPolarity:1; ///< Interrupt Input Pin Polarity. - UINT32 RemoteIrr:1; ///< RO. Set when the local APIC accepts the interrupt and reset when an EOI is received. - UINT32 TriggerMode:1; ///< 0:edge, 1:level. - UINT32 Mask:1; ///< 0: Not masked, 1: Masked. - UINT32 Reserved1:15; ///< Reserved. - } Bits; - UINT32 Uint32; -} LOCAL_APIC_LVT_LINT; - -// -// MSI Address Register -// -typedef union { - struct { - UINT32 Reserved0:2; ///< Reserved - UINT32 DestinationMode:1; ///< Specifies the Destination Mode. - UINT32 RedirectionHint:1; ///< Specifies the Redirection Hint. - UINT32 Reserved1:8; ///< Reserved. - UINT32 DestinationId:8; ///< Specifies the Destination ID. - UINT32 BaseAddress:12; ///< Must be 0FEEH - } Bits; - UINT32 Uint32; -} LOCAL_APIC_MSI_ADDRESS; - -// -// MSI Address Register -// -typedef union { - struct { - UINT32 Vector:8; ///< Interrupt vector in range 010h..0FEH - UINT32 DeliveryMode:3; ///< Specifies the type of interrupt to be sent. - UINT32 Reserved0:3; ///< Reserved. - UINT32 Level:1; ///< 0:Deassert, 1:Assert. Ignored for Edge triggered interrupts. - UINT32 TriggerMode:1; ///< 0:Edge, 1:Level. - UINT32 Reserved1:16; ///< Reserved. - UINT32 Reserved2:32; ///< Reserved. - } Bits; - UINT64 Uint64; -} LOCAL_APIC_MSI_DATA; - -#endif - diff --git a/UefiCpuPkg/Include/Register/Microcode.h b/UefiCpuPkg/Include/Register/Microcode.h deleted file mode 100644 index 94529a1ca2..0000000000 --- a/UefiCpuPkg/Include/Register/Microcode.h +++ /dev/null @@ -1,200 +0,0 @@ -/** @file - Microcode Definitions. - - Microcode Definitions based on contents of the - Intel(R) 64 and IA-32 Architectures Software Developer's Manual - Volume 3A, Section 9.11 Microcode Definitions - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, - June 2016, Chapter 9 Processor Management and Initialization, Section 9-11. - -**/ - -#ifndef __MICROCODE_H__ -#define __MICROCODE_H__ - -/// -/// CPU Microcode Date in BCD format -/// -typedef union { - struct { - UINT32 Year:16; - UINT32 Day:8; - UINT32 Month:8; - } Bits; - UINT32 Uint32; -} CPU_MICROCODE_DATE; - -/// -/// CPU Microcode Processor Signature format -/// -typedef union { - struct { - UINT32 Stepping:4; - UINT32 Model:4; - UINT32 Family:4; - UINT32 Type:2; - UINT32 Reserved1:2; - UINT32 ExtendedModel:4; - UINT32 ExtendedFamily:8; - UINT32 Reserved2:4; - } Bits; - UINT32 Uint32; -} CPU_MICROCODE_PROCESSOR_SIGNATURE; - -#pragma pack (1) - -/// -/// Microcode Update Format definition -/// -typedef struct { - /// - /// Version number of the update header - /// - UINT32 HeaderVersion; - /// - /// Unique version number for the update, the basis for the update - /// signature provided by the processor to indicate the current update - /// functioning within the processor. Used by the BIOS to authenticate - /// the update and verify that the processor loads successfully. The - /// value in this field cannot be used for processor stepping identification - /// alone. This is a signed 32-bit number. - /// - UINT32 UpdateRevision; - /// - /// Date of the update creation in binary format: mmddyyyy (e.g. - /// 07/18/98 is 07181998H). - /// - CPU_MICROCODE_DATE Date; - /// - /// Extended family, extended model, type, family, model, and stepping - /// of processor that requires this particular update revision (e.g., - /// 00000650H). Each microcode update is designed specifically for a - /// given extended family, extended model, type, family, model, and - /// stepping of the processor. - /// The BIOS uses the processor signature field in conjunction with the - /// CPUID instruction to determine whether or not an update is - /// appropriate to load on a processor. The information encoded within - /// this field exactly corresponds to the bit representations returned by - /// the CPUID instruction. - /// - CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature; - /// - /// Checksum of Update Data and Header. Used to verify the integrity of - /// the update header and data. Checksum is correct when the - /// summation of all the DWORDs (including the extended Processor - /// Signature Table) that comprise the microcode update result in - /// 00000000H. - /// - UINT32 Checksum; - /// - /// Version number of the loader program needed to correctly load this - /// update. The initial version is 00000001H - /// - UINT32 LoaderRevision; - /// - /// Platform type information is encoded in the lower 8 bits of this 4- - /// byte field. Each bit represents a particular platform type for a given - /// CPUID. The BIOS uses the processor flags field in conjunction with - /// the platform Id bits in MSR (17H) to determine whether or not an - /// update is appropriate to load on a processor. Multiple bits may be set - /// representing support for multiple platform IDs. - /// - UINT32 ProcessorFlags; - /// - /// Specifies the size of the encrypted data in bytes, and must be a - /// multiple of DWORDs. If this value is 00000000H, then the microcode - /// update encrypted data is 2000 bytes (or 500 DWORDs). - /// - UINT32 DataSize; - /// - /// Specifies the total size of the microcode update in bytes. It is the - /// summation of the header size, the encrypted data size and the size of - /// the optional extended signature table. This value is always a multiple - /// of 1024. - /// - UINT32 TotalSize; - /// - /// Reserved fields for future expansion. - /// - UINT8 Reserved[12]; -} CPU_MICROCODE_HEADER; - -/// -/// Extended Signature Table Header Field Definitions -/// -typedef struct { - /// - /// Specifies the number of extended signature structures (Processor - /// Signature[n], processor flags[n] and checksum[n]) that exist in this - /// microcode update - /// - UINT32 ExtendedSignatureCount; - /// - /// Checksum of update extended processor signature table. Used to - /// verify the integrity of the extended processor signature table. - /// Checksum is correct when the summation of the DWORDs that - /// comprise the extended processor signature table results in - /// 00000000H. - /// - UINT32 ExtendedChecksum; - /// - /// Reserved fields. - /// - UINT8 Reserved[12]; -} CPU_MICROCODE_EXTENDED_TABLE_HEADER; - -/// -/// Extended Signature Table Field Definitions -/// -typedef struct { - /// - /// Extended family, extended model, type, family, model, and stepping - /// of processor that requires this particular update revision (e.g., - /// 00000650H). Each microcode update is designed specifically for a - /// given extended family, extended model, type, family, model, and - /// stepping of the processor. - /// The BIOS uses the processor signature field in conjunction with the - /// CPUID instruction to determine whether or not an update is - /// appropriate to load on a processor. The information encoded within - /// this field exactly corresponds to the bit representations returned by - /// the CPUID instruction. - /// - CPU_MICROCODE_PROCESSOR_SIGNATURE ProcessorSignature; - /// - /// Platform type information is encoded in the lower 8 bits of this 4- - /// byte field. Each bit represents a particular platform type for a given - /// CPUID. The BIOS uses the processor flags field in conjunction with - /// the platform Id bits in MSR (17H) to determine whether or not an - /// update is appropriate to load on a processor. Multiple bits may be set - /// representing support for multiple platform IDs. - /// - UINT32 ProcessorFlag; - /// - /// Used by utility software to decompose a microcode update into - /// multiple microcode updates where each of the new updates is - /// constructed without the optional Extended Processor Signature - /// Table. - /// To calculate the Checksum, substitute the Primary Processor - /// Signature entry and the Processor Flags entry with the - /// corresponding Extended Patch entry. Delete the Extended Processor - /// Signature Table entries. The Checksum is correct when the - /// summation of all DWORDs that comprise the created Extended - /// Processor Patch results in 00000000H. - /// - UINT32 Checksum; -} CPU_MICROCODE_EXTENDED_TABLE; - -#pragma pack () - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr.h b/UefiCpuPkg/Include/Register/Msr.h deleted file mode 100644 index 0ac8d5bdfd..0000000000 --- a/UefiCpuPkg/Include/Register/Msr.h +++ /dev/null @@ -1,49 +0,0 @@ -/** @file - MSR Definitions. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Chapter 35. - -**/ - -#ifndef __MSR_H__ -#define __MSR_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/AtomMsr.h b/UefiCpuPkg/Include/Register/Msr/AtomMsr.h deleted file mode 100644 index b2764690f5..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/AtomMsr.h +++ /dev/null @@ -1,790 +0,0 @@ -/** @file - MSR Definitions for the Intel(R) Atom(TM) Processor Family. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.3. - -**/ - -#ifndef __ATOM_MSR_H__ -#define __ATOM_MSR_H__ - -#include - -/** - Is Intel(R) Atom(TM) Processor Family? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_ATOM_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x1C || \ - DisplayModel == 0x26 || \ - DisplayModel == 0x27 || \ - DisplayModel == 0x35 || \ - DisplayModel == 0x36 \ - ) \ - ) - -/** - Shared. Model Specific Platform ID (R). - - @param ECX MSR_ATOM_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_ATOM_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PLATFORM_ID); - @endcode - @note MSR_ATOM_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. -**/ -#define MSR_ATOM_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_ATOM_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. - /// - UINT32 MaximumQualifiedRatio:5; - UINT32 Reserved2:19; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_PLATFORM_ID_REGISTER; - - -/** - Shared. Processor Hard Power-On Configuration (R/W) Enables and disables - processor features; (R) indicates current processor configuration. - - @param ECX MSR_ATOM_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_ATOM_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_ATOM_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_ATOM_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. -**/ -#define MSR_ATOM_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_ATOM_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Always 0. - /// - UINT32 DataErrorCheckingEnable:1; - /// - /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Always 0. - /// - UINT32 ResponseErrorCheckingEnable:1; - /// - /// [Bit 3] AERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Always 0. - /// - UINT32 AERR_DriveEnable:1; - /// - /// [Bit 4] BERR# Enable for initiator bus requests (R/W) 1 = Enabled; 0 = - /// Disabled Always 0. - /// - UINT32 BERR_Enable:1; - UINT32 Reserved2:1; - UINT32 Reserved3:1; - /// - /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Always 0. - /// - UINT32 BINIT_DriverEnable:1; - UINT32 Reserved4:1; - /// - /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 10] AERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled - /// Always 0. - /// - UINT32 AERR_ObservationEnabled:1; - UINT32 Reserved5:1; - /// - /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled - /// Always 0. - /// - UINT32 BINIT_ObservationEnabled:1; - UINT32 Reserved6:1; - /// - /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. - /// - UINT32 ResetVector:1; - UINT32 Reserved7:1; - /// - /// [Bits 17:16] APIC Cluster ID (R/O) Always 00B. - /// - UINT32 APICClusterID:2; - UINT32 Reserved8:2; - /// - /// [Bits 21:20] Symmetric Arbitration ID (R/O) Always 00B. - /// - UINT32 SymmetricArbitrationID:2; - /// - /// [Bits 26:22] Integer Bus Frequency Ratio (R/O). - /// - UINT32 IntegerBusFrequencyRatio:5; - UINT32 Reserved9:5; - UINT32 Reserved10:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_EBL_CR_POWERON_REGISTER; - - -/** - Unique. Last Branch Record n From IP (R/W) One of eight pairs of last branch - record registers on the last branch record stack. The From_IP part of the - stack contains pointers to the source instruction . See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.5. - - @param ECX MSR_ATOM_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_ATOM_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_ATOM_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - @{ -**/ -#define MSR_ATOM_LASTBRANCH_0_FROM_IP 0x00000040 -#define MSR_ATOM_LASTBRANCH_1_FROM_IP 0x00000041 -#define MSR_ATOM_LASTBRANCH_2_FROM_IP 0x00000042 -#define MSR_ATOM_LASTBRANCH_3_FROM_IP 0x00000043 -#define MSR_ATOM_LASTBRANCH_4_FROM_IP 0x00000044 -#define MSR_ATOM_LASTBRANCH_5_FROM_IP 0x00000045 -#define MSR_ATOM_LASTBRANCH_6_FROM_IP 0x00000046 -#define MSR_ATOM_LASTBRANCH_7_FROM_IP 0x00000047 -/// @} - - -/** - Unique. Last Branch Record n To IP (R/W) One of eight pairs of last branch - record registers on the last branch record stack. The To_IP part of the - stack contains pointers to the destination instruction. - - @param ECX MSR_ATOM_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_ATOM_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_ATOM_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - @{ -**/ -#define MSR_ATOM_LASTBRANCH_0_TO_IP 0x00000060 -#define MSR_ATOM_LASTBRANCH_1_TO_IP 0x00000061 -#define MSR_ATOM_LASTBRANCH_2_TO_IP 0x00000062 -#define MSR_ATOM_LASTBRANCH_3_TO_IP 0x00000063 -#define MSR_ATOM_LASTBRANCH_4_TO_IP 0x00000064 -#define MSR_ATOM_LASTBRANCH_5_TO_IP 0x00000065 -#define MSR_ATOM_LASTBRANCH_6_TO_IP 0x00000066 -#define MSR_ATOM_LASTBRANCH_7_TO_IP 0x00000067 -/// @} - - -/** - Shared. Scalable Bus Speed(RO) This field indicates the intended scalable - bus clock speed for processors based on Intel Atom microarchitecture:. - - @param ECX MSR_ATOM_FSB_FREQ (0x000000CD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_FSB_FREQ_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_FSB_FREQ_REGISTER. - - Example usage - @code - MSR_ATOM_FSB_FREQ_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_FSB_FREQ); - @endcode - @note MSR_ATOM_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. -**/ -#define MSR_ATOM_FSB_FREQ 0x000000CD - -/** - MSR information returned for MSR index #MSR_ATOM_FSB_FREQ -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] - Scalable Bus Speed - /// - /// Atom Processor Family - /// --------------------- - /// 111B: 083 MHz (FSB 333) - /// 101B: 100 MHz (FSB 400) - /// 001B: 133 MHz (FSB 533) - /// 011B: 167 MHz (FSB 667) - /// - /// 133.33 MHz should be utilized if performing calculation with - /// System Bus Speed when encoding is 001B. - /// 166.67 MHz should be utilized if performing calculation with - /// System Bus Speed when - /// encoding is 011B. - /// - UINT32 ScalableBusSpeed:3; - UINT32 Reserved1:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_FSB_FREQ_REGISTER; - - -/** - Shared. - - @param ECX MSR_ATOM_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_ATOM_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_ATOM_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_ATOM_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. -**/ -#define MSR_ATOM_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_ATOM_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = - /// Indicates if the L2 is hardware-disabled. - /// - UINT32 L2HardwareEnabled:1; - UINT32 Reserved1:7; - /// - /// [Bit 8] L2 Enabled. (R/W) 1 = L2 cache has been initialized 0 = - /// Disabled (default) Until this bit is set the processor will not - /// respond to the WBINVD instruction or the assertion of the FLUSH# input. - /// - UINT32 L2Enabled:1; - UINT32 Reserved2:14; - /// - /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. - /// - UINT32 L2NotPresent:1; - UINT32 Reserved3:8; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_BBL_CR_CTL3_REGISTER; - - -/** - Shared. - - @param ECX MSR_ATOM_PERF_STATUS (0x00000198) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_PERF_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_PERF_STATUS_REGISTER. - - Example usage - @code - MSR_ATOM_PERF_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PERF_STATUS); - AsmWriteMsr64 (MSR_ATOM_PERF_STATUS, Msr.Uint64); - @endcode - @note MSR_ATOM_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. -**/ -#define MSR_ATOM_PERF_STATUS 0x00000198 - -/** - MSR information returned for MSR index #MSR_ATOM_PERF_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Current Performance State Value. - /// - UINT32 CurrentPerformanceStateValue:16; - UINT32 Reserved1:16; - UINT32 Reserved2:8; - /// - /// [Bits 44:40] Maximum Bus Ratio (R/O) Indicates maximum bus ratio - /// configured for the processor. - /// - UINT32 MaximumBusRatio:5; - UINT32 Reserved3:19; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_PERF_STATUS_REGISTER; - - -/** - Shared. - - @param ECX MSR_ATOM_THERM2_CTL (0x0000019D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_THERM2_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_THERM2_CTL_REGISTER. - - Example usage - @code - MSR_ATOM_THERM2_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_THERM2_CTL); - AsmWriteMsr64 (MSR_ATOM_THERM2_CTL, Msr.Uint64); - @endcode - @note MSR_ATOM_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. -**/ -#define MSR_ATOM_THERM2_CTL 0x0000019D - -/** - MSR information returned for MSR index #MSR_ATOM_THERM2_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = - /// Thermal Monitor 1 (thermally-initiated on-die modulation of the - /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated - /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is - /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 are enabled. - /// - UINT32 TM_SELECT:1; - UINT32 Reserved2:15; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_THERM2_CTL_REGISTER; - - -/** - Unique. Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_ATOM_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_ATOM_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_ATOM_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_ATOM_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_ATOM_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_ATOM_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. Default value is 0. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:1; - UINT32 Reserved4:1; - /// - /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by - /// the processor to indicate a pending break event within the processor 0 - /// = Indicates compatible FERR# signaling behavior This bit must be set - /// to 1 to support XAPIC interrupt model usage. - /// - UINT32 FERR:1; - /// - /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Shared. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - /// - /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the - /// thermal sensor indicates that the die temperature is at the - /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. - /// TM2 will reduce the bus to core ratio and voltage according to the - /// value last written to MSR_THERM2_CTL bits 15:0. - /// When this bit is clear (0, default), the processor does not change - /// the VID signals or the bus to core ratio when the processor enters a - /// thermally managed state. The BIOS must enable this feature if the - /// TM2 feature flag (CPUID.1:ECX[8]) is set; if the TM2 feature flag is - /// not set, this feature is not supported and BIOS must not alter the - /// contents of the TM2 bit location. The processor is operating out of - /// specification if both this bit and the TM1 bit are set to 0. - /// - UINT32 TM2:1; - UINT32 Reserved5:2; - /// - /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved6:1; - /// - /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved7:1; - /// - /// [Bit 20] Shared. Enhanced Intel SpeedStep Technology Select Lock - /// (R/WO) When set, this bit causes the following bits to become - /// read-only: - Enhanced Intel SpeedStep Technology Select Lock (this - /// bit), - Enhanced Intel SpeedStep Technology Enable bit. The bit must - /// be set before an Enhanced Intel SpeedStep Technology transition is - /// requested. This bit is cleared on reset. - /// - UINT32 EISTLock:1; - UINT32 Reserved8:1; - /// - /// [Bit 22] Unique. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved9:8; - UINT32 Reserved10:2; - /// - /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved11:29; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_IA32_MISC_ENABLE_REGISTER; - - -/** - Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-2) - that points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP (at 40H). - - @param ECX MSR_ATOM_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_ATOM_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_ATOM_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_ATOM_LASTBRANCH_TOS 0x000001C9 - - -/** - Unique. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_ATOM_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_LER_FROM_LIP); - @endcode - @note MSR_ATOM_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_ATOM_LER_FROM_LIP 0x000001DD - - -/** - Unique. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_ATOM_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_LER_TO_LIP); - @endcode - @note MSR_ATOM_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_ATOM_LER_TO_LIP 0x000001DE - - -/** - Unique. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling - (PEBS).". - - @param ECX MSR_ATOM_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_ATOM_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_ATOM_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_ATOM_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_ATOM_PEBS_ENABLE); - AsmWriteMsr64 (MSR_ATOM_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_ATOM_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_ATOM_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_ATOM_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). - /// - UINT32 Enable:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_ATOM_PEBS_ENABLE_REGISTER; - - -/** - Package. Package C2 Residency Note: C-state values are processor specific - C-state code names, unrelated to MWAIT extension C-state parameters or ACPI - C-States. Package. Package C2 Residency Counter. (R/O) Time that this - package is in processor-specific C2 states since last reset. Counts at 1 Mhz - frequency. - - @param ECX MSR_ATOM_PKG_C2_RESIDENCY (0x000003F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_PKG_C2_RESIDENCY); - AsmWriteMsr64 (MSR_ATOM_PKG_C2_RESIDENCY, Msr); - @endcode - @note MSR_ATOM_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. -**/ -#define MSR_ATOM_PKG_C2_RESIDENCY 0x000003F8 - - -/** - Package. Package C4 Residency Note: C-state values are processor specific - C-state code names, unrelated to MWAIT extension C-state parameters or ACPI - C-States. Package. Package C4 Residency Counter. (R/O) Time that this - package is in processor-specific C4 states since last reset. Counts at 1 Mhz - frequency. - - @param ECX MSR_ATOM_PKG_C4_RESIDENCY (0x000003F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_PKG_C4_RESIDENCY); - AsmWriteMsr64 (MSR_ATOM_PKG_C4_RESIDENCY, Msr); - @endcode - @note MSR_ATOM_PKG_C4_RESIDENCY is defined as MSR_PKG_C4_RESIDENCY in SDM. -**/ -#define MSR_ATOM_PKG_C4_RESIDENCY 0x000003F9 - - -/** - Package. Package C6 Residency Note: C-state values are processor specific - C-state code names, unrelated to MWAIT extension C-state parameters or ACPI - C-States. Package. Package C6 Residency Counter. (R/O) Time that this - package is in processor-specific C6 states since last reset. Counts at 1 Mhz - frequency. - - @param ECX MSR_ATOM_PKG_C6_RESIDENCY (0x000003FA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_ATOM_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_ATOM_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_ATOM_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_ATOM_PKG_C6_RESIDENCY 0x000003FA - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h b/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h deleted file mode 100644 index 90bd523c99..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/BroadwellMsr.h +++ /dev/null @@ -1,306 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Broadwell microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.13. - -**/ - -#ifndef __BROADWELL_MSR_H__ -#define __BROADWELL_MSR_H__ - -#include - -/** - Is Intel processors based on the Broadwell microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_BROADWELL_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x3D || \ - DisplayModel == 0x47 || \ - DisplayModel == 0x4F || \ - DisplayModel == 0x56 \ - ) \ - ) - -/** - Thread. See Table 35-2. See Section 18.4.2, "Global Counter Control - Facilities.". - - @param ECX MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS 0x0000038E - -/** - MSR information returned for MSR index #MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Trace_ToPA_PMI. See Section 36.2.6.2, "Table of Physical - /// Addresses (ToPA).". - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:5; - /// - /// [Bit 61] Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Ovf_BufDSSAVE. - /// - UINT32 OvfBuf:1; - /// - /// [Bit 63] CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_BROADWELL_IA32_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are processor - specific C-state code names, unrelated to MWAIT extension C-state parameters - or ACPI C-states. `See http://biosbits.org. `__. - - @param ECX MSR_BROADWELL_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_BROADWELL_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_BROADWELL_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_BROADWELL_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_BROADWELL_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power) for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 0000b: - /// C0/C1 (no package C-state support) 0001b: C2 0010b: C3 0011b: C6 - /// 0100b: C7 0101b: C7s 0110b: C8 0111b: C9 1000b: C10. - /// - UINT32 Limit:4; - UINT32 Reserved1:6; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W). - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO). - /// - UINT32 CFGLock:1; - UINT32 Reserved3:9; - /// - /// [Bit 25] C3 State Auto Demotion Enable (R/W). - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 State Auto Demotion Enable (R/W). - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 Undemotion (R/W). - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 Undemotion (R/W). - /// - UINT32 C1Undemotion:1; - /// - /// [Bit 29] Enable Package C-State Auto-demotion (R/W). - /// - UINT32 CStateAutoDemotion:1; - /// - /// [Bit 30] Enable Package C-State Undemotion (R/W). - /// - UINT32 CStateUndemotion:1; - UINT32 Reserved4:1; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_BROADWELL_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_BROADWELL_TURBO_RATIO_LIMIT); - @endcode - @note MSR_BROADWELL_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_BROADWELL_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_BROADWELL_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio - /// limit of 5core active. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio - /// limit of 6core active. - /// - UINT32 Maximum6C:8; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_BROADWELL_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_BROADWELL_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_BROADWELL_PP0_ENERGY_STATUS); - @endcode - @note MSR_BROADWELL_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_BROADWELL_PP0_ENERGY_STATUS 0x00000639 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/Core2Msr.h b/UefiCpuPkg/Include/Register/Msr/Core2Msr.h deleted file mode 100644 index 9ebca5e9b5..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/Core2Msr.h +++ /dev/null @@ -1,1134 +0,0 @@ -/** @file - MSR Definitions for the Intel(R) Core(TM) 2 Processor Family. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.2. - -**/ - -#ifndef __CORE2_MSR_H__ -#define __CORE2_MSR_H__ - -#include - -/** - Is Intel(R) Core(TM) 2 Processor Family? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_CORE2_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x0F || \ - DisplayModel == 0x17 \ - ) \ - ) - -/** - Shared. Model Specific Platform ID (R). - - @param ECX MSR_CORE2_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_CORE2_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PLATFORM_ID); - @endcode - @note MSR_CORE2_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. -**/ -#define MSR_CORE2_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_CORE2_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. - /// - UINT32 MaximumQualifiedRatio:5; - UINT32 Reserved2:19; - UINT32 Reserved3:18; - /// - /// [Bits 52:50] See Table 35-2. - /// - UINT32 PlatformId:3; - UINT32 Reserved4:11; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_PLATFORM_ID_REGISTER; - - -/** - Shared. Processor Hard Power-On Configuration (R/W) Enables and disables - processor features; (R) indicates current processor configuration. - - @param ECX MSR_CORE2_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_CORE2_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_CORE2_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_CORE2_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. -**/ -#define MSR_CORE2_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_CORE2_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Note: Not all processor implements R/W. - /// - UINT32 DataErrorCheckingEnable:1; - /// - /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Note: Not all processor implements R/W. - /// - UINT32 ResponseErrorCheckingEnable:1; - /// - /// [Bit 3] MCERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not - /// all processor implements R/W. - /// - UINT32 MCERR_DriveEnable:1; - /// - /// [Bit 4] Address Parity Enable (R/W) 1 = Enabled; 0 = Disabled Note: - /// Not all processor implements R/W. - /// - UINT32 AddressParityEnable:1; - UINT32 Reserved2:1; - UINT32 Reserved3:1; - /// - /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not - /// all processor implements R/W. - /// - UINT32 BINIT_DriverEnable:1; - /// - /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 OutputTriStateEnable:1; - /// - /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 MCERR_ObservationEnabled:1; - /// - /// [Bit 11] Intel TXT Capable Chipset. (R/O) 1 = Present; 0 = Not Present. - /// - UINT32 IntelTXTCapableChipset:1; - /// - /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 BINIT_ObservationEnabled:1; - UINT32 Reserved4:1; - /// - /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. - /// - UINT32 ResetVector:1; - UINT32 Reserved5:1; - /// - /// [Bits 17:16] APIC Cluster ID (R/O). - /// - UINT32 APICClusterID:2; - /// - /// [Bit 18] N/2 Non-Integer Bus Ratio (R/O) 0 = Integer ratio; 1 = - /// Non-integer ratio. - /// - UINT32 NonIntegerBusRatio:1; - UINT32 Reserved6:1; - /// - /// [Bits 21:20] Symmetric Arbitration ID (R/O). - /// - UINT32 SymmetricArbitrationID:2; - /// - /// [Bits 26:22] Integer Bus Frequency Ratio (R/O). - /// - UINT32 IntegerBusFrequencyRatio:5; - UINT32 Reserved7:5; - UINT32 Reserved8:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_EBL_CR_POWERON_REGISTER; - - -/** - Unique. Control Features in Intel 64Processor (R/W) See Table 35-2. - - @param ECX MSR_CORE2_FEATURE_CONTROL (0x0000003A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_CORE2_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_CORE2_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_CORE2_FEATURE_CONTROL is defined as MSR_FEATURE_CONTROL in SDM. -**/ -#define MSR_CORE2_FEATURE_CONTROL 0x0000003A - -/** - MSR information returned for MSR index #MSR_CORE2_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:3; - /// - /// [Bit 3] Unique. SMRR Enable (R/WL) When this bit is set and the lock - /// bit is set makes the SMRR_PHYS_BASE and SMRR_PHYS_MASK registers read - /// visible and writeable while in SMM. - /// - UINT32 SMRREnable:1; - UINT32 Reserved2:28; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_FEATURE_CONTROL_REGISTER; - - -/** - Unique. Last Branch Record n From IP (R/W) One of four pairs of last branch - record registers on the last branch record stack. The From_IP part of the - stack contains pointers to the source instruction. See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.5. - - @param ECX MSR_CORE2_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_CORE2_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_CORE2_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_CORE2_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_CORE2_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - @{ -**/ -#define MSR_CORE2_LASTBRANCH_0_FROM_IP 0x00000040 -#define MSR_CORE2_LASTBRANCH_1_FROM_IP 0x00000041 -#define MSR_CORE2_LASTBRANCH_2_FROM_IP 0x00000042 -#define MSR_CORE2_LASTBRANCH_3_FROM_IP 0x00000043 -/// @} - - -/** - Unique. Last Branch Record n To IP (R/W) One of four pairs of last branch - record registers on the last branch record stack. This To_IP part of the - stack contains pointers to the destination instruction. - - @param ECX MSR_CORE2_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_CORE2_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_CORE2_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_CORE2_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_CORE2_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - @{ -**/ -#define MSR_CORE2_LASTBRANCH_0_TO_IP 0x00000060 -#define MSR_CORE2_LASTBRANCH_1_TO_IP 0x00000061 -#define MSR_CORE2_LASTBRANCH_2_TO_IP 0x00000062 -#define MSR_CORE2_LASTBRANCH_3_TO_IP 0x00000063 -/// @} - - -/** - Unique. System Management Mode Base Address register (WO in SMM) - Model-specific implementation of SMRR-like interface, read visible and write - only in SMM. - - @param ECX MSR_CORE2_SMRR_PHYSBASE (0x000000A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_SMRR_PHYSBASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_SMRR_PHYSBASE_REGISTER. - - Example usage - @code - MSR_CORE2_SMRR_PHYSBASE_REGISTER Msr; - - Msr.Uint64 = 0; - AsmWriteMsr64 (MSR_CORE2_SMRR_PHYSBASE, Msr.Uint64); - @endcode - @note MSR_CORE2_SMRR_PHYSBASE is defined as MSR_SMRR_PHYSBASE in SDM. -**/ -#define MSR_CORE2_SMRR_PHYSBASE 0x000000A0 - -/** - MSR information returned for MSR index #MSR_CORE2_SMRR_PHYSBASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:12; - /// - /// [Bits 31:12] PhysBase. SMRR physical Base Address. - /// - UINT32 PhysBase:20; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_SMRR_PHYSBASE_REGISTER; - - -/** - Unique. System Management Mode Physical Address Mask register (WO in SMM) - Model-specific implementation of SMRR-like interface, read visible and write - only in SMM. - - @param ECX MSR_CORE2_SMRR_PHYSMASK (0x000000A1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_SMRR_PHYSMASK_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_SMRR_PHYSMASK_REGISTER. - - Example usage - @code - MSR_CORE2_SMRR_PHYSMASK_REGISTER Msr; - - Msr.Uint64 = 0; - AsmWriteMsr64 (MSR_CORE2_SMRR_PHYSMASK, Msr.Uint64); - @endcode - @note MSR_CORE2_SMRR_PHYSMASK is defined as MSR_SMRR_PHYSMASK in SDM. -**/ -#define MSR_CORE2_SMRR_PHYSMASK 0x000000A1 - -/** - MSR information returned for MSR index #MSR_CORE2_SMRR_PHYSMASK -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:11; - /// - /// [Bit 11] Valid. Physical address base and range mask are valid. - /// - UINT32 Valid:1; - /// - /// [Bits 31:12] PhysMask. SMRR physical address range mask. - /// - UINT32 PhysMask:20; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_SMRR_PHYSMASK_REGISTER; - - -/** - Shared. Scalable Bus Speed(RO) This field indicates the intended scalable - bus clock speed for processors based on Intel Core microarchitecture:. - - @param ECX MSR_CORE2_FSB_FREQ (0x000000CD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_FSB_FREQ_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_FSB_FREQ_REGISTER. - - Example usage - @code - MSR_CORE2_FSB_FREQ_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_FSB_FREQ); - @endcode - @note MSR_CORE2_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. -**/ -#define MSR_CORE2_FSB_FREQ 0x000000CD - -/** - MSR information returned for MSR index #MSR_CORE2_FSB_FREQ -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] - Scalable Bus Speed - /// 101B: 100 MHz (FSB 400) - /// 001B: 133 MHz (FSB 533) - /// 011B: 167 MHz (FSB 667) - /// 010B: 200 MHz (FSB 800) - /// 000B: 267 MHz (FSB 1067) - /// 100B: 333 MHz (FSB 1333) - /// - /// 133.33 MHz should be utilized if performing calculation with System - /// Bus Speed when encoding is 001B. 166.67 MHz should be utilized if - /// performing calculation with System Bus Speed when encoding is 011B. - /// 266.67 MHz should be utilized if performing calculation with System - /// Bus Speed when encoding is 000B. 333.33 MHz should be utilized if - /// performing calculation with System Bus Speed when encoding is 100B. - /// - UINT32 ScalableBusSpeed:3; - UINT32 Reserved1:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_FSB_FREQ_REGISTER; - - -/** - Shared. - - @param ECX MSR_CORE2_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_CORE2_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_CORE2_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_CORE2_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. -**/ -#define MSR_CORE2_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_CORE2_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = - /// Indicates if the L2 is hardware-disabled. - /// - UINT32 L2HardwareEnabled:1; - UINT32 Reserved1:7; - /// - /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = - /// Disabled (default) Until this bit is set the processor will not - /// respond to the WBINVD instruction or the assertion of the FLUSH# input. - /// - UINT32 L2Enabled:1; - UINT32 Reserved2:14; - /// - /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. - /// - UINT32 L2NotPresent:1; - UINT32 Reserved3:8; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_BBL_CR_CTL3_REGISTER; - - -/** - Shared. - - @param ECX MSR_CORE2_PERF_STATUS (0x00000198) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_PERF_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_PERF_STATUS_REGISTER. - - Example usage - @code - MSR_CORE2_PERF_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PERF_STATUS); - AsmWriteMsr64 (MSR_CORE2_PERF_STATUS, Msr.Uint64); - @endcode - @note MSR_CORE2_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. -**/ -#define MSR_CORE2_PERF_STATUS 0x00000198 - -/** - MSR information returned for MSR index #MSR_CORE2_PERF_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Current Performance State Value. - /// - UINT32 CurrentPerformanceStateValue:16; - UINT32 Reserved1:15; - /// - /// [Bit 31] XE Operation (R/O). If set, XE operation is enabled. Default - /// is cleared. - /// - UINT32 XEOperation:1; - UINT32 Reserved2:8; - /// - /// [Bits 44:40] Maximum Bus Ratio (R/O) Indicates maximum bus ratio - /// configured for the processor. - /// - UINT32 MaximumBusRatio:5; - UINT32 Reserved3:1; - /// - /// [Bit 46] Non-Integer Bus Ratio (R/O) Indicates non-integer bus ratio - /// is enabled. Applies processors based on Enhanced Intel Core - /// microarchitecture. - /// - UINT32 NonIntegerBusRatio:1; - UINT32 Reserved4:17; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_PERF_STATUS_REGISTER; - - -/** - Unique. - - @param ECX MSR_CORE2_THERM2_CTL (0x0000019D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_THERM2_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_THERM2_CTL_REGISTER. - - Example usage - @code - MSR_CORE2_THERM2_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_THERM2_CTL); - AsmWriteMsr64 (MSR_CORE2_THERM2_CTL, Msr.Uint64); - @endcode - @note MSR_CORE2_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. -**/ -#define MSR_CORE2_THERM2_CTL 0x0000019D - -/** - MSR information returned for MSR index #MSR_CORE2_THERM2_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = - /// Thermal Monitor 1 (thermally-initiated on-die modulation of the - /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated - /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is - /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 are enabled. - /// - UINT32 TM_SELECT:1; - UINT32 Reserved2:15; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_THERM2_CTL_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_CORE2_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_CORE2_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_CORE2_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_CORE2_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_CORE2_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_CORE2_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:1; - /// - /// [Bit 9] Hardware Prefetcher Disable (R/W) When set, disables the - /// hardware prefetcher operation on streams of data. When clear - /// (default), enables the prefetch queue. Disabling of the hardware - /// prefetcher may impact processor performance. - /// - UINT32 HardwarePrefetcherDisable:1; - /// - /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by - /// the processor to indicate a pending break event within the processor 0 - /// = Indicates compatible FERR# signaling behavior This bit must be set - /// to 1 to support XAPIC interrupt model usage. - /// - UINT32 FERR:1; - /// - /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Shared. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - /// - /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the - /// thermal sensor indicates that the die temperature is at the - /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. - /// TM2 will reduce the bus to core ratio and voltage according to the - /// value last written to MSR_THERM2_CTL bits 15:0. - /// When this bit is clear (0, default), the processor does not change - /// the VID signals or the bus to core ratio when the processor enters a - /// thermally managed state. The BIOS must enable this feature if the - /// TM2 feature flag (CPUID.1:ECX[8]) is set; if the TM2 feature flag is - /// not set, this feature is not supported and BIOS must not alter the - /// contents of the TM2 bit location. The processor is operating out of - /// specification if both this bit and the TM1 bit are set to 0. - /// - UINT32 TM2:1; - UINT32 Reserved4:2; - /// - /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - /// - /// [Bit 19] Shared. Adjacent Cache Line Prefetch Disable (R/W) When set - /// to 1, the processor fetches the cache line that contains data - /// currently required by the processor. When set to 0, the processor - /// fetches cache lines that comprise a cache line pair (128 bytes). - /// Single processor platforms should not set this bit. Server platforms - /// should set or clear this bit based on platform performance observed in - /// validation and testing. BIOS may contain a setup option that controls - /// the setting of this bit. - /// - UINT32 AdjacentCacheLinePrefetchDisable:1; - /// - /// [Bit 20] Shared. Enhanced Intel SpeedStep Technology Select Lock - /// (R/WO) When set, this bit causes the following bits to become - /// read-only: - Enhanced Intel SpeedStep Technology Select Lock (this - /// bit), - Enhanced Intel SpeedStep Technology Enable bit. The bit must - /// be set before an Enhanced Intel SpeedStep Technology transition is - /// requested. This bit is cleared on reset. - /// - UINT32 EISTLock:1; - UINT32 Reserved6:1; - /// - /// [Bit 22] Shared. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved9:2; - /// - /// [Bit 37] Unique. DCU Prefetcher Disable (R/W) When set to 1, The DCU - /// L1 data cache prefetcher is disabled. The default value after reset is - /// 0. BIOS may write '1' to disable this feature. The DCU prefetcher is - /// an L1 data cache prefetcher. When the DCU prefetcher detects multiple - /// loads from the same line done within a time limit, the DCU prefetcher - /// assumes the next line will be required. The next line is prefetched in - /// to the L1 data cache from memory or L2. - /// - UINT32 DCUPrefetcherDisable:1; - /// - /// [Bit 38] Shared. IDA Disable (R/W) When set to 1 on processors that - /// support IDA, the Intel Dynamic Acceleration feature (IDA) is disabled - /// and the IDA_Enable feature flag will be clear (CPUID.06H: EAX[1]=0). - /// When set to a 0 on processors that support IDA, CPUID.06H: EAX[1] - /// reports the processor's support of IDA is enabled. Note: the power-on - /// default value is used by BIOS to detect hardware support of IDA. If - /// power-on default value is 1, IDA is available in the processor. If - /// power-on default value is 0, IDA is not available. - /// - UINT32 IDADisable:1; - /// - /// [Bit 39] Unique. IP Prefetcher Disable (R/W) When set to 1, The IP - /// prefetcher is disabled. The default value after reset is 0. BIOS may - /// write '1' to disable this feature. The IP prefetcher is an L1 data - /// cache prefetcher. The IP prefetcher looks for sequential load history - /// to determine whether to prefetch the next expected data into the L1 - /// cache from memory or L2. - /// - UINT32 IPPrefetcherDisable:1; - UINT32 Reserved10:24; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_IA32_MISC_ENABLE_REGISTER; - - -/** - Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) - that points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP (at 40H). - - @param ECX MSR_CORE2_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_CORE2_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_CORE2_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_CORE2_LASTBRANCH_TOS 0x000001C9 - - -/** - Unique. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_CORE2_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_LER_FROM_LIP); - @endcode - @note MSR_CORE2_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_CORE2_LER_FROM_LIP 0x000001DD - - -/** - Unique. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_CORE2_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_LER_TO_LIP); - @endcode - @note MSR_CORE2_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_CORE2_LER_TO_LIP 0x000001DE - - -/** - Unique. Fixed-Function Performance Counter Register n (R/W). - - @param ECX MSR_CORE2_PERF_FIXED_CTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_PERF_FIXED_CTR0); - AsmWriteMsr64 (MSR_CORE2_PERF_FIXED_CTR0, Msr); - @endcode - @note MSR_CORE2_PERF_FIXED_CTR0 is defined as MSR_PERF_FIXED_CTR0 in SDM. - MSR_CORE2_PERF_FIXED_CTR1 is defined as MSR_PERF_FIXED_CTR1 in SDM. - MSR_CORE2_PERF_FIXED_CTR2 is defined as MSR_PERF_FIXED_CTR2 in SDM. - @{ -**/ -#define MSR_CORE2_PERF_FIXED_CTR0 0x00000309 -#define MSR_CORE2_PERF_FIXED_CTR1 0x0000030A -#define MSR_CORE2_PERF_FIXED_CTR2 0x0000030B -/// @} - - -/** - Unique. RO. This applies to processors that do not support architectural - perfmon version 2. - - @param ECX MSR_CORE2_PERF_CAPABILITIES (0x00000345) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_PERF_CAPABILITIES_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_PERF_CAPABILITIES_REGISTER. - - Example usage - @code - MSR_CORE2_PERF_CAPABILITIES_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PERF_CAPABILITIES); - AsmWriteMsr64 (MSR_CORE2_PERF_CAPABILITIES, Msr.Uint64); - @endcode - @note MSR_CORE2_PERF_CAPABILITIES is defined as MSR_PERF_CAPABILITIES in SDM. -**/ -#define MSR_CORE2_PERF_CAPABILITIES 0x00000345 - -/** - MSR information returned for MSR index #MSR_CORE2_PERF_CAPABILITIES -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 5:0] LBR Format. See Table 35-2. - /// - UINT32 LBR_FMT:6; - /// - /// [Bit 6] PEBS Record Format. - /// - UINT32 PEBS_FMT:1; - /// - /// [Bit 7] PEBSSaveArchRegs. See Table 35-2. - /// - UINT32 PEBS_ARCH_REG:1; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_PERF_CAPABILITIES_REGISTER; - - -/** - Unique. Fixed-Function-Counter Control Register (R/W). - - @param ECX MSR_CORE2_PERF_FIXED_CTR_CTRL (0x0000038D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_PERF_FIXED_CTR_CTRL); - AsmWriteMsr64 (MSR_CORE2_PERF_FIXED_CTR_CTRL, Msr); - @endcode - @note MSR_CORE2_PERF_FIXED_CTR_CTRL is defined as MSR_PERF_FIXED_CTR_CTRL in SDM. -**/ -#define MSR_CORE2_PERF_FIXED_CTR_CTRL 0x0000038D - - -/** - Unique. See Section 18.4.2, "Global Counter Control Facilities.". - - @param ECX MSR_CORE2_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_STATUS, Msr); - @endcode - @note MSR_CORE2_PERF_GLOBAL_STATUS is defined as MSR_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_CORE2_PERF_GLOBAL_STATUS 0x0000038E - - -/** - Unique. See Section 18.4.2, "Global Counter Control Facilities.". - - @param ECX MSR_CORE2_PERF_GLOBAL_CTRL (0x0000038F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_CTRL, Msr); - @endcode - @note MSR_CORE2_PERF_GLOBAL_CTRL is defined as MSR_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_CORE2_PERF_GLOBAL_CTRL 0x0000038F - - -/** - Unique. See Section 18.4.2, "Global Counter Control Facilities.". - - @param ECX MSR_CORE2_PERF_GLOBAL_OVF_CTRL (0x00000390) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_PERF_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_CORE2_PERF_GLOBAL_OVF_CTRL, Msr); - @endcode - @note MSR_CORE2_PERF_GLOBAL_OVF_CTRL is defined as MSR_PERF_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_CORE2_PERF_GLOBAL_OVF_CTRL 0x00000390 - - -/** - Unique. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling - (PEBS).". - - @param ECX MSR_CORE2_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE2_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE2_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_CORE2_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE2_PEBS_ENABLE); - AsmWriteMsr64 (MSR_CORE2_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_CORE2_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_CORE2_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_CORE2_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). - /// - UINT32 Enable:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE2_PEBS_ENABLE_REGISTER; - - -/** - Unique. GBUSQ Event Control/Counter Register (R/W) Apply to Intel Xeon - processor 7400 series (processor signature 06_1D) only. See Section 17.2.2. - - @param ECX MSR_CORE2_EMON_L3_CTR_CTLn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_EMON_L3_CTR_CTL0); - AsmWriteMsr64 (MSR_CORE2_EMON_L3_CTR_CTL0, Msr); - @endcode - @note MSR_CORE2_EMON_L3_CTR_CTL0 is defined as MSR_EMON_L3_CTR_CTL0 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL1 is defined as MSR_EMON_L3_CTR_CTL1 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL2 is defined as MSR_EMON_L3_CTR_CTL2 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL3 is defined as MSR_EMON_L3_CTR_CTL3 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL4 is defined as MSR_EMON_L3_CTR_CTL4 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL5 is defined as MSR_EMON_L3_CTR_CTL5 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL6 is defined as MSR_EMON_L3_CTR_CTL6 in SDM. - MSR_CORE2_EMON_L3_CTR_CTL7 is defined as MSR_EMON_L3_CTR_CTL7 in SDM. - @{ -**/ -#define MSR_CORE2_EMON_L3_CTR_CTL0 0x000107CC -#define MSR_CORE2_EMON_L3_CTR_CTL1 0x000107CD -#define MSR_CORE2_EMON_L3_CTR_CTL2 0x000107CE -#define MSR_CORE2_EMON_L3_CTR_CTL3 0x000107CF -#define MSR_CORE2_EMON_L3_CTR_CTL4 0x000107D0 -#define MSR_CORE2_EMON_L3_CTR_CTL5 0x000107D1 -#define MSR_CORE2_EMON_L3_CTR_CTL6 0x000107D2 -#define MSR_CORE2_EMON_L3_CTR_CTL7 0x000107D3 -/// @} - - -/** - Unique. L3/FSB Common Control Register (R/W) Apply to Intel Xeon processor - 7400 series (processor signature 06_1D) only. See Section 17.2.2. - - @param ECX MSR_CORE2_EMON_L3_GL_CTL (0x000107D8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE2_EMON_L3_GL_CTL); - AsmWriteMsr64 (MSR_CORE2_EMON_L3_GL_CTL, Msr); - @endcode - @note MSR_CORE2_EMON_L3_GL_CTL is defined as MSR_EMON_L3_GL_CTL in SDM. -**/ -#define MSR_CORE2_EMON_L3_GL_CTL 0x000107D8 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/CoreMsr.h b/UefiCpuPkg/Include/Register/Msr/CoreMsr.h deleted file mode 100644 index 4897c74d5a..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/CoreMsr.h +++ /dev/null @@ -1,1110 +0,0 @@ -/** @file - MSR Definitions for Intel Core Solo and Intel Core Duo Processors. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.19. - -**/ - -#ifndef __CORE_MSR_H__ -#define __CORE_MSR_H__ - -#include - -/** - Is Intel Core Solo and Intel Core Duo Processors? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_CORE_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x0E \ - ) \ - ) - -/** - Unique. See Section 35.22, "MSRs in Pentium Processors," and see Table 35-2. - - @param ECX MSR_CORE_P5_MC_ADDR (0x00000000) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_P5_MC_ADDR); - AsmWriteMsr64 (MSR_CORE_P5_MC_ADDR, Msr); - @endcode - @note MSR_CORE_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. -**/ -#define MSR_CORE_P5_MC_ADDR 0x00000000 - - -/** - Unique. See Section 35.22, "MSRs in Pentium Processors," and see Table 35-2. - - @param ECX MSR_CORE_P5_MC_TYPE (0x00000001) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_P5_MC_TYPE); - AsmWriteMsr64 (MSR_CORE_P5_MC_TYPE, Msr); - @endcode - @note MSR_CORE_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. -**/ -#define MSR_CORE_P5_MC_TYPE 0x00000001 - - -/** - Shared. Processor Hard Power-On Configuration (R/W) Enables and disables - processor features; (R) indicates current processor configuration. - - @param ECX MSR_CORE_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_CORE_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_CORE_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_CORE_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. -**/ -#define MSR_CORE_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_CORE_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Note: Not all processor implements R/W. - /// - UINT32 DataErrorCheckingEnable:1; - /// - /// [Bit 2] Response Error Checking Enable (R/W) 1 = Enabled; 0 = Disabled - /// Note: Not all processor implements R/W. - /// - UINT32 ResponseErrorCheckingEnable:1; - /// - /// [Bit 3] MCERR# Drive Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not - /// all processor implements R/W. - /// - UINT32 MCERR_DriveEnable:1; - /// - /// [Bit 4] Address Parity Enable (R/W) 1 = Enabled; 0 = Disabled Note: - /// Not all processor implements R/W. - /// - UINT32 AddressParityEnable:1; - UINT32 Reserved2:2; - /// - /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled; 0 = Disabled Note: Not - /// all processor implements R/W. - /// - UINT32 BINIT_DriverEnable:1; - /// - /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 OutputTriStateEnable:1; - /// - /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 MCERR_ObservationEnabled:1; - UINT32 Reserved3:1; - /// - /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 BINIT_ObservationEnabled:1; - UINT32 Reserved4:1; - /// - /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes. - /// - UINT32 ResetVector:1; - UINT32 Reserved5:1; - /// - /// [Bits 17:16] APIC Cluster ID (R/O). - /// - UINT32 APICClusterID:2; - /// - /// [Bit 18] System Bus Frequency (R/O) 1. = 100 MHz 2. = Reserved. - /// - UINT32 SystemBusFrequency:1; - UINT32 Reserved6:1; - /// - /// [Bits 21:20] Symmetric Arbitration ID (R/O). - /// - UINT32 SymmetricArbitrationID:2; - /// - /// [Bits 26:22] Clock Frequency Ratio (R/O). - /// - UINT32 ClockFrequencyRatio:5; - UINT32 Reserved7:5; - UINT32 Reserved8:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_EBL_CR_POWERON_REGISTER; - - -/** - Unique. Last Branch Record n (R/W) One of 8 last branch record registers on - the last branch record stack: bits 31-0 hold the 'from' address and bits - 63-32 hold the 'to' address. See also: - Last Branch Record Stack TOS at - 1C9H - Section 17.13, "Last Branch, Interrupt, and Exception Recording - (Pentium M Processors).". - - @param ECX MSR_CORE_LASTBRANCH_n - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_LASTBRANCH_0); - AsmWriteMsr64 (MSR_CORE_LASTBRANCH_0, Msr); - @endcode - @note MSR_CORE_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. - MSR_CORE_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. - MSR_CORE_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. - MSR_CORE_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. - MSR_CORE_LASTBRANCH_4 is defined as MSR_LASTBRANCH_4 in SDM. - MSR_CORE_LASTBRANCH_5 is defined as MSR_LASTBRANCH_5 in SDM. - MSR_CORE_LASTBRANCH_6 is defined as MSR_LASTBRANCH_6 in SDM. - MSR_CORE_LASTBRANCH_7 is defined as MSR_LASTBRANCH_7 in SDM. - @{ -**/ -#define MSR_CORE_LASTBRANCH_0 0x00000040 -#define MSR_CORE_LASTBRANCH_1 0x00000041 -#define MSR_CORE_LASTBRANCH_2 0x00000042 -#define MSR_CORE_LASTBRANCH_3 0x00000043 -#define MSR_CORE_LASTBRANCH_4 0x00000044 -#define MSR_CORE_LASTBRANCH_5 0x00000045 -#define MSR_CORE_LASTBRANCH_6 0x00000046 -#define MSR_CORE_LASTBRANCH_7 0x00000047 -/// @} - - -/** - Shared. Scalable Bus Speed (RO) This field indicates the scalable bus - clock speed:. - - @param ECX MSR_CORE_FSB_FREQ (0x000000CD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_FSB_FREQ_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_FSB_FREQ_REGISTER. - - Example usage - @code - MSR_CORE_FSB_FREQ_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_FSB_FREQ); - @endcode - @note MSR_CORE_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. -**/ -#define MSR_CORE_FSB_FREQ 0x000000CD - -/** - MSR information returned for MSR index #MSR_CORE_FSB_FREQ -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] - Scalable Bus Speed - /// 101B: 100 MHz (FSB 400) - /// 001B: 133 MHz (FSB 533) - /// 011B: 167 MHz (FSB 667) - /// - /// 133.33 MHz should be utilized if performing calculation with System Bus - /// Speed when encoding is 101B. 166.67 MHz should be utilized if - /// performing calculation with System Bus Speed when encoding is 001B. - /// - UINT32 ScalableBusSpeed:3; - UINT32 Reserved1:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_FSB_FREQ_REGISTER; - - -/** - Shared. - - @param ECX MSR_CORE_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_CORE_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_CORE_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_CORE_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. -**/ -#define MSR_CORE_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_CORE_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = - /// Indicates if the L2 is hardware-disabled. - /// - UINT32 L2HardwareEnabled:1; - UINT32 Reserved1:7; - /// - /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = - /// Disabled (default) Until this bit is set the processor will not - /// respond to the WBINVD instruction or the assertion of the FLUSH# input. - /// - UINT32 L2Enabled:1; - UINT32 Reserved2:14; - /// - /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. - /// - UINT32 L2NotPresent:1; - UINT32 Reserved3:8; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_BBL_CR_CTL3_REGISTER; - - -/** - Unique. - - @param ECX MSR_CORE_THERM2_CTL (0x0000019D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_THERM2_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_THERM2_CTL_REGISTER. - - Example usage - @code - MSR_CORE_THERM2_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_THERM2_CTL); - AsmWriteMsr64 (MSR_CORE_THERM2_CTL, Msr.Uint64); - @endcode - @note MSR_CORE_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. -**/ -#define MSR_CORE_THERM2_CTL 0x0000019D - -/** - MSR information returned for MSR index #MSR_CORE_THERM2_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = - /// Thermal Monitor 1 (thermally-initiated on-die modulation of the - /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated - /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is - /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 will be enabled. - /// - UINT32 TM_SELECT:1; - UINT32 Reserved2:15; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_THERM2_CTL_REGISTER; - - -/** - Enable Miscellaneous Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_CORE_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_CORE_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_CORE_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_CORE_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_CORE_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_CORE_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:3; - /// - /// [Bit 3] Unique. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Shared. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:2; - /// - /// [Bit 10] Shared. FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by - /// the processor to indicate a pending break event within the processor 0 - /// = Indicates compatible FERR# signaling behavior This bit must be set - /// to 1 to support XAPIC interrupt model usage. - /// - UINT32 FERR:1; - /// - /// [Bit 11] Shared. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - UINT32 Reserved4:1; - /// - /// [Bit 13] Shared. TM2 Enable (R/W) When this bit is set (1) and the - /// thermal sensor indicates that the die temperature is at the - /// pre-determined threshold, the Thermal Monitor 2 mechanism is engaged. - /// TM2 will reduce the bus to core ratio and voltage according to the - /// value last written to MSR_THERM2_CTL bits 15:0. When this bit is clear - /// (0, default), the processor does not change the VID signals or the bus - /// to core ratio when the processor enters a thermal managed state. If - /// the TM2 feature flag (ECX[8]) is not set to 1 after executing CPUID - /// with EAX = 1, then this feature is not supported and BIOS must not - /// alter the contents of this bit location. The processor is operating - /// out of spec if both this bit and the TM1 bit are set to disabled - /// states. - /// - UINT32 TM2:1; - UINT32 Reserved5:2; - /// - /// [Bit 16] Shared. Enhanced Intel SpeedStep Technology Enable (R/W) 1 = - /// Enhanced Intel SpeedStep Technology enabled. - /// - UINT32 EIST:1; - UINT32 Reserved6:1; - /// - /// [Bit 18] Shared. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved7:1; - UINT32 Reserved8:2; - /// - /// [Bit 22] Shared. Limit CPUID Maxval (R/W) See Table 35-2. Setting this - /// bit may cause behavior in software that depends on the availability of - /// CPUID leaves greater than 2. - /// - UINT32 LimitCpuidMaxval:1; - UINT32 Reserved9:9; - UINT32 Reserved10:2; - /// - /// [Bit 34] Shared. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved11:29; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_IA32_MISC_ENABLE_REGISTER; - - -/** - Unique. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) - that points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP (at 40H). - - @param ECX MSR_CORE_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_CORE_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_CORE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_CORE_LASTBRANCH_TOS 0x000001C9 - - -/** - Unique. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_CORE_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_LER_FROM_LIP); - @endcode - @note MSR_CORE_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_CORE_LER_FROM_LIP 0x000001DD - - -/** - Unique. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_CORE_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_LER_TO_LIP); - @endcode - @note MSR_CORE_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_CORE_LER_TO_LIP 0x000001DE - - -/** - Unique. - - @param ECX MSR_CORE_ROB_CR_BKUPTMPDR6 (0x000001E0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER. - - Example usage - @code - MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_ROB_CR_BKUPTMPDR6); - AsmWriteMsr64 (MSR_CORE_ROB_CR_BKUPTMPDR6, Msr.Uint64); - @endcode - @note MSR_CORE_ROB_CR_BKUPTMPDR6 is defined as ROB_CR_BKUPTMPDR6 in SDM. -**/ -#define MSR_CORE_ROB_CR_BKUPTMPDR6 0x000001E0 - -/** - MSR information returned for MSR index #MSR_CORE_ROB_CR_BKUPTMPDR6 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:2; - /// - /// [Bit 2] Fast Strings Enable bit. (Default, enabled). - /// - UINT32 FastStrings:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_ROB_CR_BKUPTMPDR6_REGISTER; - - -/** - Unique. - - @param ECX MSR_CORE_MTRRPHYSBASEn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRPHYSBASE0); - AsmWriteMsr64 (MSR_CORE_MTRRPHYSBASE0, Msr); - @endcode - @note MSR_CORE_MTRRPHYSBASE0 is defined as MTRRPHYSBASE0 in SDM. - MSR_CORE_MTRRPHYSBASE1 is defined as MTRRPHYSBASE1 in SDM. - MSR_CORE_MTRRPHYSBASE2 is defined as MTRRPHYSBASE2 in SDM. - MSR_CORE_MTRRPHYSBASE3 is defined as MTRRPHYSBASE3 in SDM. - MSR_CORE_MTRRPHYSBASE4 is defined as MTRRPHYSBASE4 in SDM. - MSR_CORE_MTRRPHYSBASE5 is defined as MTRRPHYSBASE5 in SDM. - MSR_CORE_MTRRPHYSMASK6 is defined as MTRRPHYSMASK6 in SDM. - MSR_CORE_MTRRPHYSMASK7 is defined as MTRRPHYSMASK7 in SDM. - @{ -**/ -#define MSR_CORE_MTRRPHYSBASE0 0x00000200 -#define MSR_CORE_MTRRPHYSBASE1 0x00000202 -#define MSR_CORE_MTRRPHYSBASE2 0x00000204 -#define MSR_CORE_MTRRPHYSBASE3 0x00000206 -#define MSR_CORE_MTRRPHYSBASE4 0x00000208 -#define MSR_CORE_MTRRPHYSBASE5 0x0000020A -#define MSR_CORE_MTRRPHYSMASK6 0x0000020D -#define MSR_CORE_MTRRPHYSMASK7 0x0000020F -/// @} - - -/** - Unique. - - @param ECX MSR_CORE_MTRRPHYSMASKn (0x00000201) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRPHYSMASK0); - AsmWriteMsr64 (MSR_CORE_MTRRPHYSMASK0, Msr); - @endcode - @note MSR_CORE_MTRRPHYSMASK0 is defined as MTRRPHYSMASK0 in SDM. - MSR_CORE_MTRRPHYSMASK1 is defined as MTRRPHYSMASK1 in SDM. - MSR_CORE_MTRRPHYSMASK2 is defined as MTRRPHYSMASK2 in SDM. - MSR_CORE_MTRRPHYSMASK3 is defined as MTRRPHYSMASK3 in SDM. - MSR_CORE_MTRRPHYSMASK4 is defined as MTRRPHYSMASK4 in SDM. - MSR_CORE_MTRRPHYSMASK5 is defined as MTRRPHYSMASK5 in SDM. - MSR_CORE_MTRRPHYSBASE6 is defined as MTRRPHYSBASE6 in SDM. - MSR_CORE_MTRRPHYSBASE7 is defined as MTRRPHYSBASE7 in SDM. - @{ -**/ -#define MSR_CORE_MTRRPHYSMASK0 0x00000201 -#define MSR_CORE_MTRRPHYSMASK1 0x00000203 -#define MSR_CORE_MTRRPHYSMASK2 0x00000205 -#define MSR_CORE_MTRRPHYSMASK3 0x00000207 -#define MSR_CORE_MTRRPHYSMASK4 0x00000209 -#define MSR_CORE_MTRRPHYSMASK5 0x0000020B -#define MSR_CORE_MTRRPHYSBASE6 0x0000020C -#define MSR_CORE_MTRRPHYSBASE7 0x0000020E -/// @} - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX64K_00000 (0x00000250) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX64K_00000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX64K_00000, Msr); - @endcode - @note MSR_CORE_MTRRFIX64K_00000 is defined as MTRRFIX64K_00000 in SDM. -**/ -#define MSR_CORE_MTRRFIX64K_00000 0x00000250 - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX16K_80000 (0x00000258) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX16K_80000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX16K_80000, Msr); - @endcode - @note MSR_CORE_MTRRFIX16K_80000 is defined as MTRRFIX16K_80000 in SDM. -**/ -#define MSR_CORE_MTRRFIX16K_80000 0x00000258 - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX16K_A0000 (0x00000259) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX16K_A0000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX16K_A0000, Msr); - @endcode - @note MSR_CORE_MTRRFIX16K_A0000 is defined as MTRRFIX16K_A0000 in SDM. -**/ -#define MSR_CORE_MTRRFIX16K_A0000 0x00000259 - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_C0000 (0x00000268) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_C0000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_C0000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_C0000 is defined as MTRRFIX4K_C0000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_C0000 0x00000268 - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_C8000 (0x00000269) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_C8000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_C8000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_C8000 is defined as MTRRFIX4K_C8000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_C8000 0x00000269 - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_D0000 (0x0000026A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_D0000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_D0000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_D0000 is defined as MTRRFIX4K_D0000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_D0000 0x0000026A - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_D8000 (0x0000026B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_D8000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_D8000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_D8000 is defined as MTRRFIX4K_D8000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_D8000 0x0000026B - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_E0000 (0x0000026C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_E0000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_E0000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_E0000 is defined as MTRRFIX4K_E0000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_E0000 0x0000026C - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_E8000 (0x0000026D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_E8000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_E8000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_E8000 is defined as MTRRFIX4K_E8000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_E8000 0x0000026D - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_F0000 (0x0000026E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_F0000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_F0000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_F0000 is defined as MTRRFIX4K_F0000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_F0000 0x0000026E - - -/** - Unique. - - @param ECX MSR_CORE_MTRRFIX4K_F8000 (0x0000026F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MTRRFIX4K_F8000); - AsmWriteMsr64 (MSR_CORE_MTRRFIX4K_F8000, Msr); - @endcode - @note MSR_CORE_MTRRFIX4K_F8000 is defined as MTRRFIX4K_F8000 in SDM. -**/ -#define MSR_CORE_MTRRFIX4K_F8000 0x0000026F - - -/** - Unique. See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". - - @param ECX MSR_CORE_MC4_CTL (0x0000040C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC4_CTL); - AsmWriteMsr64 (MSR_CORE_MC4_CTL, Msr); - @endcode - @note MSR_CORE_MC4_CTL is defined as MSR_MC4_CTL in SDM. -**/ -#define MSR_CORE_MC4_CTL 0x0000040C - - -/** - Unique. See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". - - @param ECX MSR_CORE_MC4_STATUS (0x0000040D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC4_STATUS); - AsmWriteMsr64 (MSR_CORE_MC4_STATUS, Msr); - @endcode - @note MSR_CORE_MC4_STATUS is defined as MSR_MC4_STATUS in SDM. -**/ -#define MSR_CORE_MC4_STATUS 0x0000040D - - -/** - Unique. See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC4_ADDR - register is either not implemented or contains no address if the ADDRV flag - in the MSR_MC4_STATUS register is clear. When not implemented in the - processor, all reads and writes to this MSR will cause a general-protection - exception. - - @param ECX MSR_CORE_MC4_ADDR (0x0000040E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC4_ADDR); - AsmWriteMsr64 (MSR_CORE_MC4_ADDR, Msr); - @endcode - @note MSR_CORE_MC4_ADDR is defined as MSR_MC4_ADDR in SDM. -**/ -#define MSR_CORE_MC4_ADDR 0x0000040E - - -/** - Unique. See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC3_ADDR - register is either not implemented or contains no address if the ADDRV flag - in the MSR_MC3_STATUS register is clear. When not implemented in the - processor, all reads and writes to this MSR will cause a general-protection - exception. - - @param ECX MSR_CORE_MC3_ADDR (0x00000412) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC3_ADDR); - AsmWriteMsr64 (MSR_CORE_MC3_ADDR, Msr); - @endcode - @note MSR_CORE_MC3_ADDR is defined as MSR_MC3_ADDR in SDM. -**/ -#define MSR_CORE_MC3_ADDR 0x00000412 - - -/** - Unique. - - @param ECX MSR_CORE_MC3_MISC (0x00000413) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC3_MISC); - AsmWriteMsr64 (MSR_CORE_MC3_MISC, Msr); - @endcode - @note MSR_CORE_MC3_MISC is defined as MSR_MC3_MISC in SDM. -**/ -#define MSR_CORE_MC3_MISC 0x00000413 - - -/** - Unique. - - @param ECX MSR_CORE_MC5_CTL (0x00000414) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC5_CTL); - AsmWriteMsr64 (MSR_CORE_MC5_CTL, Msr); - @endcode - @note MSR_CORE_MC5_CTL is defined as MSR_MC5_CTL in SDM. -**/ -#define MSR_CORE_MC5_CTL 0x00000414 - - -/** - Unique. - - @param ECX MSR_CORE_MC5_STATUS (0x00000415) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC5_STATUS); - AsmWriteMsr64 (MSR_CORE_MC5_STATUS, Msr); - @endcode - @note MSR_CORE_MC5_STATUS is defined as MSR_MC5_STATUS in SDM. -**/ -#define MSR_CORE_MC5_STATUS 0x00000415 - - -/** - Unique. - - @param ECX MSR_CORE_MC5_ADDR (0x00000416) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC5_ADDR); - AsmWriteMsr64 (MSR_CORE_MC5_ADDR, Msr); - @endcode - @note MSR_CORE_MC5_ADDR is defined as MSR_MC5_ADDR in SDM. -**/ -#define MSR_CORE_MC5_ADDR 0x00000416 - - -/** - Unique. - - @param ECX MSR_CORE_MC5_MISC (0x00000417) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_CORE_MC5_MISC); - AsmWriteMsr64 (MSR_CORE_MC5_MISC, Msr); - @endcode - @note MSR_CORE_MC5_MISC is defined as MSR_MC5_MISC in SDM. -**/ -#define MSR_CORE_MC5_MISC 0x00000417 - - -/** - Unique. See Table 35-2. - - @param ECX MSR_CORE_IA32_EFER (0xC0000080) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_CORE_IA32_EFER_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_CORE_IA32_EFER_REGISTER. - - Example usage - @code - MSR_CORE_IA32_EFER_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_CORE_IA32_EFER); - AsmWriteMsr64 (MSR_CORE_IA32_EFER, Msr.Uint64); - @endcode - @note MSR_CORE_IA32_EFER is defined as IA32_EFER in SDM. -**/ -#define MSR_CORE_IA32_EFER 0xC0000080 - -/** - MSR information returned for MSR index #MSR_CORE_IA32_EFER -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:11; - /// - /// [Bit 11] Execute Disable Bit Enable. - /// - UINT32 NXE:1; - UINT32 Reserved2:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_CORE_IA32_EFER_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h b/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h deleted file mode 100644 index 5730918ec6..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/GoldmontMsr.h +++ /dev/null @@ -1,2531 +0,0 @@ -/** @file - MSR Definitions for Intel Atom processors based on the Goldmont microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.5. - -**/ - -#ifndef __GOLDMONT_MSR_H__ -#define __GOLDMONT_MSR_H__ - -#include - -/** - Is Intel Atom processors based on the Goldmont microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_GOLDMONT_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x5C \ - ) \ - ) - -/** - Core. Control Features in Intel 64Processor (R/W). - - @param ECX MSR_GOLDMONT_FEATURE_CONTROL (0x0000003A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_GOLDMONT_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. -**/ -#define MSR_GOLDMONT_FEATURE_CONTROL 0x0000003A - -/** - MSR information returned for MSR index #MSR_GOLDMONT_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock bit (R/WL) - /// - UINT32 Lock:1; - /// - /// [Bit 1] Enable VMX inside SMX operation (R/WL) - /// - UINT32 EnableVmxInsideSmx:1; - /// - /// [Bit 2] Enable VMX outside SMX operation (R/WL) - /// - UINT32 EnableVmxOutsideSmx:1; - UINT32 Reserved1:5; - /// - /// [Bits 14:8] SENTER local function enables (R/WL) - /// - UINT32 SenterLocalFunctionEnables:7; - /// - /// [Bit 15] SENTER global functions enable (R/WL) - /// - UINT32 SenterGlobalEnable:1; - UINT32 Reserved2:2; - /// - /// [Bit 18] SGX global functions enable (R/WL) - /// - UINT32 SgxEnable:1; - UINT32 Reserved3:13; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_FEATURE_CONTROL_REGISTER; - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_GOLDMONT_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PLATFORM_INFO); - AsmWriteMsr64 (MSR_GOLDMONT_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_GOLDMONT_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - /// - /// [Bit 30] Package. Programmable TJ OFFSET (R/O) When set to 1, - /// indicates that MSR_TEMPERATURE_TARGET.[27:24] is valid and writable to - /// specify an temperature offset. - /// - UINT32 TJOFFSET:1; - UINT32 Reserved3:1; - UINT32 Reserved4:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved5:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PLATFORM_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. See http://biosbits.org. - - @param ECX MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type - MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type - MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power). for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 0000b: - /// No limit 0001b: C1 0010b: C3 0011b: C6 0100b: C7 0101b: C7S 0110b: C8 - /// 0111b: C9 1000b: C10. - /// - UINT32 Limit:4; - UINT32 Reserved1:6; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map - /// IO_read instructions sent to IO register specified by - /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register - /// until next reset. - /// - UINT32 CFGLock:1; - UINT32 Reserved3:16; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Core. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability Enhancement. - Accessible only while in SMM. - - @param ECX MSR_GOLDMONT_SMM_MCA_CAP (0x0000017D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_MCA_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_MCA_CAP_REGISTER. - - Example usage - @code - MSR_GOLDMONT_SMM_MCA_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_MCA_CAP); - AsmWriteMsr64 (MSR_GOLDMONT_SMM_MCA_CAP, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. -**/ -#define MSR_GOLDMONT_SMM_MCA_CAP 0x0000017D - -/** - MSR information returned for MSR index #MSR_GOLDMONT_SMM_MCA_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:26; - /// - /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the - /// SMM code access restriction is supported and the - /// MSR_SMM_FEATURE_CONTROL is supported. - /// - UINT32 SMM_Code_Access_Chk:1; - /// - /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the - /// SMM long flow indicator is supported and the MSR_SMM_DELAYED is - /// supported. - /// - UINT32 Long_Flow_Indication:1; - UINT32 Reserved3:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_SMM_MCA_CAP_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_GOLDMONT_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_GOLDMONT_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Package. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. Default value is 1. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Core. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:3; - /// - /// [Bit 11] Core. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Core. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - UINT32 Reserved4:3; - /// - /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] Core. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved6:3; - /// - /// [Bit 22] Core. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Package. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] Core. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved9:3; - /// - /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors - /// that support Intel Turbo Boost Technology, the turbo mode feature is - /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: - /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: - /// EAX[1] reports the processor's support of turbo mode is enabled. Note: - /// the power-on default value is used by BIOS to detect hardware support - /// of turbo mode. If power-on default value is 1, turbo mode is available - /// in the processor. If power-on default value is 0, turbo mode is not - /// available. - /// - UINT32 TurboModeDisable:1; - UINT32 Reserved10:25; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_MISC_ENABLE_REGISTER; - - -/** - Miscellaneous Feature Control (R/W). - - @param ECX MSR_GOLDMONT_MISC_FEATURE_CONTROL (0x000001A4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_MISC_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_GOLDMONT_MISC_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. -**/ -#define MSR_GOLDMONT_MISC_FEATURE_CONTROL 0x000001A4 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_MISC_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the - /// L2 hardware prefetcher, which fetches additional lines of code or data - /// into the L2 cache. - /// - UINT32 L2HardwarePrefetcherDisable:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables - /// the L1 data cache prefetcher, which fetches the next cache line into - /// L1 data cache. - /// - UINT32 DCUHardwarePrefetcherDisable:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_MISC_FEATURE_CONTROL_REGISTER; - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_GOLDMONT_MISC_PWR_MGMT (0x000001AA) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER. - - Example usage - @code - MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_MISC_PWR_MGMT); - AsmWriteMsr64 (MSR_GOLDMONT_MISC_PWR_MGMT, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. -**/ -#define MSR_GOLDMONT_MISC_PWR_MGMT 0x000001AA - -/** - MSR information returned for MSR index #MSR_GOLDMONT_MISC_PWR_MGMT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] EIST Hardware Coordination Disable (R/W) When 0, enables - /// hardware coordination of Enhanced Intel Speedstep Technology request - /// from processor cores; When 1, disables hardware coordination of - /// Enhanced Intel Speedstep Technology requests. - /// - UINT32 EISTHardwareCoordinationDisable:1; - UINT32 Reserved1:21; - /// - /// [Bit 22] Thermal Interrupt Coordination Enable (R/W) If set, then - /// thermal interrupt on one core is routed to all cores. - /// - UINT32 ThermalInterruptCoordinationEnable:1; - UINT32 Reserved2:9; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_MISC_PWR_MGMT_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode by Core Groups (RW) Specifies - Maximum Ratio Limit for each Core Group. Max ratio for groups with more - cores must decrease monotonically. For groups with less than 4 cores, the - max ratio must be 32 or less. For groups with 4-5 cores, the max ratio must - be 22 or less. For groups with more than 5 cores, the max ratio must be 16 - or less.. - - @param ECX MSR_GOLDMONT_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_RATIO_LIMIT); - AsmWriteMsr64 (MSR_GOLDMONT_TURBO_RATIO_LIMIT, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_GOLDMONT_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_GOLDMONT_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for Active cores in Group 0 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 0 threshold. - /// - UINT32 MaxRatioLimitGroup0:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for Active cores in Group 1 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 1 threshold and greater than Group 0 threshold. - /// - UINT32 MaxRatioLimitGroup1:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for Active cores in Group 2 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 2 threshold and greater than Group 1 threshold. - /// - UINT32 MaxRatioLimitGroup2:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for Active cores in Group 3 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 3 threshold and greater than Group 2 threshold. - /// - UINT32 MaxRatioLimitGroup3:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for Active cores in Group 4 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 4 threshold and greater than Group 3 threshold. - /// - UINT32 MaxRatioLimitGroup4:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for Active cores in Group 5 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 5 threshold and greater than Group 4 threshold. - /// - UINT32 MaxRatioLimitGroup5:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for Active cores in Group 6 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 6 threshold and greater than Group 5 threshold. - /// - UINT32 MaxRatioLimitGroup6:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for Active cores in Group 7 - /// Maximum turbo ratio limit when number of active cores is less or equal - /// to Group 7 threshold and greater than Group 6 threshold. - /// - UINT32 MaxRatioLimitGroup7:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. Group Size of Active Cores for Turbo Mode Operation (RW) Writes of - 0 threshold is ignored. - - @param ECX MSR_GOLDMONT_TURBO_GROUP_CORECNT (0x000001AE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER. - - Example usage - @code - MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_GROUP_CORECNT); - AsmWriteMsr64 (MSR_GOLDMONT_TURBO_GROUP_CORECNT, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_TURBO_GROUP_CORECNT is defined as MSR_TURBO_GROUP_CORECNT in SDM. -**/ -#define MSR_GOLDMONT_TURBO_GROUP_CORECNT 0x000001AE - -/** - MSR information returned for MSR index #MSR_GOLDMONT_TURBO_GROUP_CORECNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Group 0 Core Count Threshold Maximum number of - /// active cores to operate under Group 0 Max Turbo Ratio limit. - /// - UINT32 CoreCountThresholdGroup0:8; - /// - /// [Bits 15:8] Package. Group 1 Core Count Threshold Maximum number of - /// active cores to operate under Group 1 Max Turbo Ratio limit. Must be - /// greater than Group 0 Core Count. - /// - UINT32 CoreCountThresholdGroup1:8; - /// - /// [Bits 23:16] Package. Group 2 Core Count Threshold Maximum number of - /// active cores to operate under Group 2 Max Turbo Ratio limit. Must be - /// greater than Group 1 Core Count. - /// - UINT32 CoreCountThresholdGroup2:8; - /// - /// [Bits 31:24] Package. Group 3 Core Count Threshold Maximum number of - /// active cores to operate under Group 3 Max Turbo Ratio limit. Must be - /// greater than Group 2 Core Count. - /// - UINT32 CoreCountThresholdGroup3:8; - /// - /// [Bits 39:32] Package. Group 4 Core Count Threshold Maximum number of - /// active cores to operate under Group 4 Max Turbo Ratio limit. Must be - /// greater than Group 3 Core Count. - /// - UINT32 CoreCountThresholdGroup4:8; - /// - /// [Bits 47:40] Package. Group 5 Core Count Threshold Maximum number of - /// active cores to operate under Group 5 Max Turbo Ratio limit. Must be - /// greater than Group 4 Core Count. - /// - UINT32 CoreCountThresholdGroup5:8; - /// - /// [Bits 55:48] Package. Group 6 Core Count Threshold Maximum number of - /// active cores to operate under Group 6 Max Turbo Ratio limit. Must be - /// greater than Group 5 Core Count. - /// - UINT32 CoreCountThresholdGroup6:8; - /// - /// [Bits 63:56] Package. Group 7 Core Count Threshold Maximum number of - /// active cores to operate under Group 7 Max Turbo Ratio limit. Must be - /// greater than Group 6 Core Count and not less than the total number of - /// processor cores in the package. E.g. specify 255. - /// - UINT32 CoreCountThresholdGroup7:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_TURBO_GROUP_CORECNT_REGISTER; - - -/** - Core. Last Branch Record Filtering Select Register (R/W) See Section - 17.7.2, "Filtering of Last Branch Records.". - - @param ECX MSR_GOLDMONT_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LBR_SELECT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LBR_SELECT_REGISTER. - - Example usage - @code - MSR_GOLDMONT_LBR_SELECT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LBR_SELECT); - AsmWriteMsr64 (MSR_GOLDMONT_LBR_SELECT, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_GOLDMONT_LBR_SELECT 0x000001C8 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_LBR_SELECT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CPL_EQ_0. - /// - UINT32 CPL_EQ_0:1; - /// - /// [Bit 1] CPL_NEQ_0. - /// - UINT32 CPL_NEQ_0:1; - /// - /// [Bit 2] JCC. - /// - UINT32 JCC:1; - /// - /// [Bit 3] NEAR_REL_CALL. - /// - UINT32 NEAR_REL_CALL:1; - /// - /// [Bit 4] NEAR_IND_CALL. - /// - UINT32 NEAR_IND_CALL:1; - /// - /// [Bit 5] NEAR_RET. - /// - UINT32 NEAR_RET:1; - /// - /// [Bit 6] NEAR_IND_JMP. - /// - UINT32 NEAR_IND_JMP:1; - /// - /// [Bit 7] NEAR_REL_JMP. - /// - UINT32 NEAR_REL_JMP:1; - /// - /// [Bit 8] FAR_BRANCH. - /// - UINT32 FAR_BRANCH:1; - /// - /// [Bit 9] EN_CALL_STACK. - /// - UINT32 EN_CALL_STACK:1; - UINT32 Reserved1:22; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_LBR_SELECT_REGISTER; - - -/** - Core. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-4) that - points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP. - - @param ECX MSR_GOLDMONT_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_GOLDMONT_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_GOLDMONT_LASTBRANCH_TOS 0x000001C9 - - -/** - Core. Power Control Register. See http://biosbits.org. - - @param ECX MSR_GOLDMONT_POWER_CTL (0x000001FC) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_POWER_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_POWER_CTL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_POWER_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_POWER_CTL); - AsmWriteMsr64 (MSR_GOLDMONT_POWER_CTL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_POWER_CTL is defined as MSR_POWER_CTL in SDM. -**/ -#define MSR_GOLDMONT_POWER_CTL 0x000001FC - -/** - MSR information returned for MSR index #MSR_GOLDMONT_POWER_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Package. C1E Enable (R/W) When set to '1', will enable the - /// CPU to switch to the Minimum Enhanced Intel SpeedStep Technology - /// operating point when all execution cores enter MWAIT (C1). - /// - UINT32 C1EEnable:1; - UINT32 Reserved2:30; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_POWER_CTL_REGISTER; - - -/** - Package. Lower 64 Bit OwnerEpoch Component of SGX Key (RO). Low 64 bits of - an 128-bit external entropy value for key derivation of an enclave. - - @param ECX MSR_GOLDMONT_SGXOWNER0 (0x00000300) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_SGXOWNER0); - @endcode - @note MSR_GOLDMONT_SGXOWNER0 is defined as MSR_SGXOWNER0 in SDM. -**/ -#define MSR_GOLDMONT_SGXOWNER0 0x00000300 - - -/** - Package. Upper 64 Bit OwnerEpoch Component of SGX Key (RO). Upper 64 bits of - an 128-bit external entropy value for key derivation of an enclave. - - @param ECX MSR_GOLDMONT_SGXOWNER1 (0x00000301) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_SGXOWNER1); - @endcode - @note MSR_GOLDMONT_SGXOWNER1 is defined as MSR_SGXOWNER1 in SDM. -**/ -#define MSR_GOLDMONT_SGXOWNER1 0x00000301 - - -/** - Core. See Table 35-2. See Section 18.2.4, "Architectural Performance - Monitoring Version 4.". - - @param ECX MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. -**/ -#define MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 - -/** - MSR information returned for MSR index - #MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Set 1 to clear Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Set 1 to clear Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Set 1 to clear Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Set 1 to clear Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Set 1 to clear Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Set 1 to clear Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Set 1 to clear Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Set 1 to clear Trace_ToPA_PMI. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] Set 1 to clear LBR_Frz. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Set 1 to clear CTR_Frz. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Set 1 to clear ASCI. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Set 1 to clear Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Set 1 to clear Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - /// - /// [Bit 63] Set 1 to clear CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; - - -/** - Core. See Table 35-2. See Section 18.2.4, "Architectural Performance - Monitoring Version 4.". - - @param ECX MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. -**/ -#define MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 - -/** - MSR information returned for MSR index - #MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Set 1 to cause Ovf_PMC0 = 1. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Set 1 to cause Ovf_PMC1 = 1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Set 1 to cause Ovf_PMC2 = 1. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Set 1 to cause Ovf_PMC3 = 1. - /// - UINT32 Ovf_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Set 1 to cause Ovf_FixedCtr0 = 1. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Set 1 to cause Ovf_FixedCtr1 = 1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Set 1 to cause Ovf_FixedCtr2 = 1. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Set 1 to cause Trace_ToPA_PMI = 1. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] Set 1 to cause LBR_Frz = 1. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Set 1 to cause CTR_Frz = 1. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Set 1 to cause ASCI = 1. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Set 1 to cause Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Set 1 to cause Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - UINT32 Reserved4:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; - - -/** - Core. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling - (PEBS).". - - @param ECX MSR_GOLDMONT_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PEBS_ENABLE); - AsmWriteMsr64 (MSR_GOLDMONT_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_GOLDMONT_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS trigger and recording for the programmed event - /// (precise or otherwise) on IA32_PMC0. (R/W). - /// - UINT32 Enable:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PEBS_ENABLE_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_GOLDMONT_PKG_C3_RESIDENCY (0x000003F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C3_RESIDENCY); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_C3_RESIDENCY, Msr); - @endcode - @note MSR_GOLDMONT_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. -**/ -#define MSR_GOLDMONT_PKG_C3_RESIDENCY 0x000003F8 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C6 states. Count at the same frequency as the TSC. - - @param ECX MSR_GOLDMONT_PKG_C6_RESIDENCY (0x000003F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_GOLDMONT_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_GOLDMONT_PKG_C6_RESIDENCY 0x000003F9 - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_GOLDMONT_CORE_C3_RESIDENCY (0x000003FC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_CORE_C3_RESIDENCY); - AsmWriteMsr64 (MSR_GOLDMONT_CORE_C3_RESIDENCY, Msr); - @endcode - @note MSR_GOLDMONT_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. -**/ -#define MSR_GOLDMONT_CORE_C3_RESIDENCY 0x000003FC - - -/** - Package. Enhanced SMM Feature Control (SMM-RW) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_GOLDMONT_SMM_FEATURE_CONTROL (0x000004E0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_GOLDMONT_SMM_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_SMM_FEATURE_CONTROL is defined as MSR_SMM_FEATURE_CONTROL in SDM. -**/ -#define MSR_GOLDMONT_SMM_FEATURE_CONTROL 0x000004E0 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_SMM_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock (SMM-RWO) When set to '1' locks this register from - /// further changes. - /// - UINT32 Lock:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] SMM_Code_Chk_En (SMM-RW) This control bit is available only if - /// MSR_SMM_MCA_CAP[58] == 1. When set to '0' (default) none of the - /// logical processors are prevented from executing SMM code outside the - /// ranges defined by the SMRR. When set to '1' any logical processor in - /// the package that attempts to execute SMM code not within the ranges - /// defined by the SMRR will assert an unrecoverable MCE. - /// - UINT32 SMM_Code_Chk_En:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_SMM_FEATURE_CONTROL_REGISTER; - - -/** - Package. SMM Delayed (SMM-RO) Reports the interruptible state of all logical - processors in the package. Available only while in SMM and - MSR_SMM_MCA_CAP[LONG_FLOW_INDICATION] == 1. - - @param ECX MSR_GOLDMONT_SMM_DELAYED (0x000004E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_DELAYED_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_DELAYED_REGISTER. - - Example usage - @code - MSR_GOLDMONT_SMM_DELAYED_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_DELAYED); - AsmWriteMsr64 (MSR_GOLDMONT_SMM_DELAYED, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_SMM_DELAYED is defined as MSR_SMM_DELAYED in SDM. -**/ -#define MSR_GOLDMONT_SMM_DELAYED 0x000004E2 - - -/** - Package. SMM Blocked (SMM-RO) Reports the blocked state of all logical - processors in the package. Available only while in SMM. - - @param ECX MSR_GOLDMONT_SMM_BLOCKED (0x000004E3) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_BLOCKED_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_SMM_BLOCKED_REGISTER. - - Example usage - @code - MSR_GOLDMONT_SMM_BLOCKED_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_SMM_BLOCKED); - AsmWriteMsr64 (MSR_GOLDMONT_SMM_BLOCKED, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_SMM_BLOCKED is defined as MSR_SMM_BLOCKED in SDM. -**/ -#define MSR_GOLDMONT_SMM_BLOCKED 0x000004E3 - - -/** - Core. Trace Control Register (R/W). - - @param ECX MSR_GOLDMONT_IA32_RTIT_CTL (0x00000570) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_RTIT_CTL); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_RTIT_CTL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_RTIT_CTL is defined as IA32_RTIT_CTL in SDM. -**/ -#define MSR_IA32_RTIT_CTL 0x00000570 - -/** - MSR information returned for MSR index #MSR_IA32_RTIT_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] TraceEn. - /// - UINT32 TraceEn:1; - /// - /// [Bit 1] CYCEn. - /// - UINT32 CYCEn:1; - /// - /// [Bit 2] OS. - /// - UINT32 OS:1; - /// - /// [Bit 3] User. - /// - UINT32 User:1; - UINT32 Reserved1:3; - /// - /// [Bit 7] CR3 filter. - /// - UINT32 CR3:1; - /// - /// [Bit 8] ToPA. Writing 0 will #GP if also setting TraceEn. - /// - UINT32 ToPA:1; - /// - /// [Bit 9] MTCEn. - /// - UINT32 MTCEn:1; - /// - /// [Bit 10] TSCEn. - /// - UINT32 TSCEn:1; - /// - /// [Bit 11] DisRETC. - /// - UINT32 DisRETC:1; - UINT32 Reserved2:1; - /// - /// [Bit 13] BranchEn. - /// - UINT32 BranchEn:1; - /// - /// [Bits 17:14] MTCFreq. - /// - UINT32 MTCFreq:4; - UINT32 Reserved3:1; - /// - /// [Bits 22:19] CYCThresh. - /// - UINT32 CYCThresh:4; - UINT32 Reserved4:1; - /// - /// [Bits 27:24] PSBFreq. - /// - UINT32 PSBFreq:4; - UINT32 Reserved5:4; - /// - /// [Bits 35:32] ADDR0_CFG. - /// - UINT32 ADDR0_CFG:4; - /// - /// [Bits 39:36] ADDR1_CFG. - /// - UINT32 ADDR1_CFG:4; - UINT32 Reserved6:24; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_RTIT_CTL_REGISTER; - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, - "RAPL Interfaces.". - - @param ECX MSR_GOLDMONT_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_RAPL_POWER_UNIT); - @endcode - @note MSR_GOLDMONT_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_GOLDMONT_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Power Units. Power related information (in Watts) is in - /// unit of, 1W/2^PU; where PU is an unsigned integer represented by bits - /// 3:0. Default value is 1000b, indicating power unit is in 3.9 - /// milliWatts increment. - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Energy Status Units. Energy related information (in - /// Joules) is in unit of, 1Joule/ (2^ESU); where ESU is an unsigned - /// integer represented by bits 12:8. Default value is 01110b, indicating - /// energy unit is in 61 microJoules. - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Time Unit. Time related information (in seconds) is in - /// unit of, 1S/2^TU; where TU is an unsigned integer represented by bits - /// 19:16. Default value is 1010b, indicating power unit is in 0.977 - /// millisecond. - /// - UINT32 TimeUnit:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. Package C3 Interrupt Response Limit (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. - - @param ECX MSR_GOLDMONT_PKGC3_IRTL (0x0000060A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC3_IRTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC3_IRTL_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PKGC3_IRTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC3_IRTL); - AsmWriteMsr64 (MSR_GOLDMONT_PKGC3_IRTL, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PKGC3_IRTL is defined as MSR_PKGC3_IRTL in SDM. -**/ -#define MSR_GOLDMONT_PKGC3_IRTL 0x0000060A - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PKGC3_IRTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C3 state. - /// - UINT32 InterruptResponseTimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. See Table 35-18 for - /// supported time unit encodings. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PKGC3_IRTL_REGISTER; - - -/** - Package. Package C6/C7S Interrupt Response Limit 1 (R/W) This MSR defines - the interrupt response time limit used by the processor to manage transition - to package C6 or C7S state. Note: C-state values are processor specific - C-state code names, unrelated to MWAIT extension C-state parameters or ACPI - CStates. - - @param ECX MSR_GOLDMONT_PKGC_IRTL1 (0x0000060B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC_IRTL1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC_IRTL1_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PKGC_IRTL1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC_IRTL1); - AsmWriteMsr64 (MSR_GOLDMONT_PKGC_IRTL1, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PKGC_IRTL1 is defined as MSR_PKGC_IRTL1 in SDM. -**/ -#define MSR_GOLDMONT_PKGC_IRTL1 0x0000060B - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PKGC_IRTL1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C6 or C7S state. - /// - UINT32 InterruptResponseTimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. See Table 35-18 for - /// supported time unit encodings. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PKGC_IRTL1_REGISTER; - - -/** - Package. Package C7 Interrupt Response Limit 2 (R/W) This MSR defines the - interrupt response time limit used by the processor to manage transition to - package C7 state. Note: C-state values are processor specific C-state code - names, unrelated to MWAIT extension C-state parameters or ACPI CStates. - - @param ECX MSR_GOLDMONT_PKGC_IRTL2 (0x0000060C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC_IRTL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKGC_IRTL2_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PKGC_IRTL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKGC_IRTL2); - AsmWriteMsr64 (MSR_GOLDMONT_PKGC_IRTL2, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PKGC_IRTL2 is defined as MSR_PKGC_IRTL2 in SDM. -**/ -#define MSR_GOLDMONT_PKGC_IRTL2 0x0000060C - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PKGC_IRTL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C7 state. - /// - UINT32 InterruptResponseTimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. See Table 35-18 for - /// supported time unit encodings. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PKGC_IRTL2_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C2 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C2 states. Count at the same frequency as the TSC. - - @param ECX MSR_GOLDMONT_PKG_C2_RESIDENCY (0x0000060D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C2_RESIDENCY); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_C2_RESIDENCY, Msr); - @endcode - @note MSR_GOLDMONT_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. -**/ -#define MSR_GOLDMONT_PKG_C2_RESIDENCY 0x0000060D - - -/** - Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package - RAPL Domain.". - - @param ECX MSR_GOLDMONT_PKG_POWER_LIMIT (0x00000610) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_POWER_LIMIT); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_POWER_LIMIT, Msr); - @endcode - @note MSR_GOLDMONT_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. -**/ -#define MSR_GOLDMONT_PKG_POWER_LIMIT 0x00000610 - - -/** - Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_GOLDMONT_PKG_ENERGY_STATUS (0x00000611) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_ENERGY_STATUS); - @endcode - @note MSR_GOLDMONT_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. -**/ -#define MSR_GOLDMONT_PKG_ENERGY_STATUS 0x00000611 - - -/** - Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_GOLDMONT_PKG_PERF_STATUS (0x00000613) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_PERF_STATUS); - @endcode - @note MSR_GOLDMONT_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. -**/ -#define MSR_GOLDMONT_PKG_PERF_STATUS 0x00000613 - - -/** - Package. PKG RAPL Parameters (R/W). - - @param ECX MSR_GOLDMONT_PKG_POWER_INFO (0x00000614) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKG_POWER_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_PKG_POWER_INFO_REGISTER. - - Example usage - @code - MSR_GOLDMONT_PKG_POWER_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_PKG_POWER_INFO); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_POWER_INFO, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. -**/ -#define MSR_GOLDMONT_PKG_POWER_INFO 0x00000614 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_PKG_POWER_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Thermal Spec Power (R/W) See Section 14.9.3, "Package - /// RAPL Domain.". - /// - UINT32 ThermalSpecPower:15; - UINT32 Reserved1:1; - /// - /// [Bits 30:16] Minimum Power (R/W) See Section 14.9.3, "Package RAPL - /// Domain.". - /// - UINT32 MinimumPower:15; - UINT32 Reserved2:1; - /// - /// [Bits 46:32] Maximum Power (R/W) See Section 14.9.3, "Package RAPL - /// Domain.". - /// - UINT32 MaximumPower:15; - UINT32 Reserved3:1; - /// - /// [Bits 54:48] Maximum Time Window (R/W) Specified by 2^Y * (1.0 + - /// Z/4.0) * Time_Unit, where "Y" is the unsigned integer value - /// represented. by bits 52:48, "Z" is an unsigned integer represented by - /// bits 54:53. "Time_Unit" is specified by the "Time Units" field of - /// MSR_RAPL_POWER_UNIT. - /// - UINT32 MaximumTimeWindow:7; - UINT32 Reserved4:9; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_PKG_POWER_INFO_REGISTER; - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_GOLDMONT_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_GOLDMONT_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_GOLDMONT_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_GOLDMONT_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_GOLDMONT_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_ENERGY_STATUS); - @endcode - @note MSR_GOLDMONT_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_GOLDMONT_DRAM_ENERGY_STATUS 0x00000619 - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_GOLDMONT_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_PERF_STATUS); - @endcode - @note MSR_GOLDMONT_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_GOLDMONT_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_GOLDMONT_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_GOLDMONT_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_GOLDMONT_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_GOLDMONT_DRAM_POWER_INFO 0x0000061C - - -/** - Package. Note: C-state values are processor specific C-state code names,. - Package C10 Residency Counter. (R/O) Value since last reset that the entire - SOC is in an S0i3 state. Count at the same frequency as the TSC. - - @param ECX MSR_GOLDMONT_PKG_C10_RESIDENCY (0x00000632) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PKG_C10_RESIDENCY); - AsmWriteMsr64 (MSR_GOLDMONT_PKG_C10_RESIDENCY, Msr); - @endcode - @note MSR_GOLDMONT_PKG_C10_RESIDENCY is defined as MSR_PKG_C10_RESIDENCY in SDM. -**/ -#define MSR_GOLDMONT_PKG_C10_RESIDENCY 0x00000632 - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_GOLDMONT_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PP0_ENERGY_STATUS); - @endcode - @note MSR_GOLDMONT_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_GOLDMONT_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_GOLDMONT_PP1_ENERGY_STATUS (0x00000641) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_GOLDMONT_PP1_ENERGY_STATUS); - @endcode - @note MSR_GOLDMONT_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. -**/ -#define MSR_GOLDMONT_PP1_ENERGY_STATUS 0x00000641 - - -/** - Package. ConfigTDP Control (R/W). - - @param ECX MSR_GOLDMONT_TURBO_ACTIVATION_RATIO (0x0000064C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER. - - Example usage - @code - MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_TURBO_ACTIVATION_RATIO); - AsmWriteMsr64 (MSR_GOLDMONT_TURBO_ACTIVATION_RATIO, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. -**/ -#define MSR_GOLDMONT_TURBO_ACTIVATION_RATIO 0x0000064C - -/** - MSR information returned for MSR index #MSR_GOLDMONT_TURBO_ACTIVATION_RATIO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this - /// field. - /// - UINT32 MAX_NON_TURBO_RATIO:8; - UINT32 Reserved1:23; - /// - /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the - /// content of this register is locked until a reset. - /// - UINT32 TURBO_ACTIVATION_RATIO_Lock:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_TURBO_ACTIVATION_RATIO_REGISTER; - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS (0x0000064F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS 0x0000064F - -/** - MSR information returned for MSR index #MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is - /// reduced below the operating system request due to assertion of - /// external PROCHOT. - /// - UINT32 PROCHOTStatus:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - /// - /// [Bit 2] Package-Level Power Limiting PL1 Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL1. - /// - UINT32 PL1Status:1; - /// - /// [Bit 3] Package-Level PL2 Power Limiting Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL2. - /// - UINT32 PL2Status:1; - UINT32 Reserved1:5; - /// - /// [Bit 9] Core Power Limiting Status (R0) When set, frequency is reduced - /// below the operating system request due to domain-level power limiting. - /// - UINT32 PowerLimitingStatus:1; - /// - /// [Bit 10] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - /// - /// [Bit 11] Max Turbo Limit Status (R0) When set, frequency is reduced - /// below the operating system request due to multi-core turbo limits. - /// - UINT32 MaxTurboLimitStatus:1; - /// - /// [Bit 12] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - /// - /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency - /// is reduced below the operating system request due to Turbo transition - /// attenuation. This prevents performance degradation due to frequent - /// operating ratio changes. - /// - UINT32 TurboTransitionAttenuationStatus:1; - /// - /// [Bit 14] Maximum Efficiency Frequency Status (R0) When set, frequency - /// is reduced below the maximum efficiency frequency. - /// - UINT32 MaximumEfficiencyFrequencyStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - /// - /// [Bit 18] Package-Level PL1 Power Limiting Log When set, indicates - /// that the Package Level PL1 Power Limiting Status bit has asserted - /// since the log bit was last cleared. This log bit will remain set until - /// cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 19] Package-Level PL2 Power Limiting Log When set, indicates that - /// the Package Level PL2 Power Limiting Status bit has asserted since the - /// log bit was last cleared. This log bit will remain set until cleared - /// by software writing 0. - /// - UINT32 PL2Log:1; - UINT32 Reserved3:5; - /// - /// [Bit 25] Core Power Limiting Log When set, indicates that the Core - /// Power Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CorePowerLimitingLog:1; - /// - /// [Bit 26] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - /// - /// [Bit 27] Max Turbo Limit Log When set, indicates that the Max Turbo - /// Limit Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MaxTurboLimitLog:1; - /// - /// [Bit 28] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - /// - /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the - /// Turbo Transition Attenuation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 TurboTransitionAttenuationLog:1; - /// - /// [Bit 30] Maximum Efficiency Frequency Log When set, indicates that - /// the Maximum Efficiency Frequency Status bit has asserted since the log - /// bit was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 MaximumEfficiencyFrequencyLog:1; - UINT32 Reserved4:1; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_CORE_PERF_LIMIT_REASONS_REGISTER; - - -/** - Core. Last Branch Record n From IP (R/W) One of 32 pairs of last branch - record registers on the last branch record stack. The From_IP part of the - stack contains pointers to the source instruction . See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.6 and record format in Section - 17.4.8.1. - - @param ECX MSR_GOLDMONT_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER. - - Example usage - @code - MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_n_FROM_IP); - AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_n_FROM_IP, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_16_FROM_IP is defined as MSR_LASTBRANCH_16_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_17_FROM_IP is defined as MSR_LASTBRANCH_17_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_18_FROM_IP is defined as MSR_LASTBRANCH_18_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_19_FROM_IP is defined as MSR_LASTBRANCH_19_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_20_FROM_IP is defined as MSR_LASTBRANCH_20_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_21_FROM_IP is defined as MSR_LASTBRANCH_21_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_22_FROM_IP is defined as MSR_LASTBRANCH_22_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_23_FROM_IP is defined as MSR_LASTBRANCH_23_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_24_FROM_IP is defined as MSR_LASTBRANCH_24_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_25_FROM_IP is defined as MSR_LASTBRANCH_25_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_26_FROM_IP is defined as MSR_LASTBRANCH_26_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_27_FROM_IP is defined as MSR_LASTBRANCH_27_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_28_FROM_IP is defined as MSR_LASTBRANCH_28_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_29_FROM_IP is defined as MSR_LASTBRANCH_29_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_30_FROM_IP is defined as MSR_LASTBRANCH_30_FROM_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_31_FROM_IP is defined as MSR_LASTBRANCH_31_FROM_IP in SDM. - @{ -**/ -#define MSR_GOLDMONT_LASTBRANCH_0_FROM_IP 0x00000680 -#define MSR_GOLDMONT_LASTBRANCH_1_FROM_IP 0x00000681 -#define MSR_GOLDMONT_LASTBRANCH_2_FROM_IP 0x00000682 -#define MSR_GOLDMONT_LASTBRANCH_3_FROM_IP 0x00000683 -#define MSR_GOLDMONT_LASTBRANCH_4_FROM_IP 0x00000684 -#define MSR_GOLDMONT_LASTBRANCH_5_FROM_IP 0x00000685 -#define MSR_GOLDMONT_LASTBRANCH_6_FROM_IP 0x00000686 -#define MSR_GOLDMONT_LASTBRANCH_7_FROM_IP 0x00000687 -#define MSR_GOLDMONT_LASTBRANCH_8_FROM_IP 0x00000688 -#define MSR_GOLDMONT_LASTBRANCH_9_FROM_IP 0x00000689 -#define MSR_GOLDMONT_LASTBRANCH_10_FROM_IP 0x0000068A -#define MSR_GOLDMONT_LASTBRANCH_11_FROM_IP 0x0000068B -#define MSR_GOLDMONT_LASTBRANCH_12_FROM_IP 0x0000068C -#define MSR_GOLDMONT_LASTBRANCH_13_FROM_IP 0x0000068D -#define MSR_GOLDMONT_LASTBRANCH_14_FROM_IP 0x0000068E -#define MSR_GOLDMONT_LASTBRANCH_15_FROM_IP 0x0000068F -#define MSR_GOLDMONT_LASTBRANCH_16_FROM_IP 0x00000690 -#define MSR_GOLDMONT_LASTBRANCH_17_FROM_IP 0x00000691 -#define MSR_GOLDMONT_LASTBRANCH_18_FROM_IP 0x00000692 -#define MSR_GOLDMONT_LASTBRANCH_19_FROM_IP 0x00000693 -#define MSR_GOLDMONT_LASTBRANCH_20_FROM_IP 0x00000694 -#define MSR_GOLDMONT_LASTBRANCH_21_FROM_IP 0x00000695 -#define MSR_GOLDMONT_LASTBRANCH_22_FROM_IP 0x00000696 -#define MSR_GOLDMONT_LASTBRANCH_23_FROM_IP 0x00000697 -#define MSR_GOLDMONT_LASTBRANCH_24_FROM_IP 0x00000698 -#define MSR_GOLDMONT_LASTBRANCH_25_FROM_IP 0x00000699 -#define MSR_GOLDMONT_LASTBRANCH_26_FROM_IP 0x0000069A -#define MSR_GOLDMONT_LASTBRANCH_27_FROM_IP 0x0000069B -#define MSR_GOLDMONT_LASTBRANCH_28_FROM_IP 0x0000069C -#define MSR_GOLDMONT_LASTBRANCH_29_FROM_IP 0x0000069D -#define MSR_GOLDMONT_LASTBRANCH_30_FROM_IP 0x0000069E -#define MSR_GOLDMONT_LASTBRANCH_31_FROM_IP 0x0000069F -/// @} - -/** - MSR information returned for MSR indexes #MSR_GOLDMONT_LASTBRANCH_0_FROM_IP - to #MSR_GOLDMONT_LASTBRANCH_31_FROM_IP. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 31:0] From Linear Address (R/W). - /// - UINT32 FromLinearAddress:32; - /// - /// [Bit 47:32] From Linear Address (R/W). - /// - UINT32 FromLinearAddressHi:16; - /// - /// [Bits 62:48] Signed extension of bits 47:0. - /// - UINT32 SignedExtension:15; - /// - /// [Bit 63] Mispred. - /// - UINT32 Mispred:1; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_LASTBRANCH_FROM_IP_REGISTER; - - -/** - Core. Last Branch Record n To IP (R/W) One of 32 pairs of last branch record - registers on the last branch record stack. The To_IP part of the stack - contains pointers to the Destination instruction and elapsed cycles from - last LBR update. See also: - Section 17.6. - - @param ECX MSR_GOLDMONT_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER. - - Example usage - @code - MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_GOLDMONT_LASTBRANCH_0_TO_IP, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_16_TO_IP is defined as MSR_LASTBRANCH_16_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_17_TO_IP is defined as MSR_LASTBRANCH_17_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_18_TO_IP is defined as MSR_LASTBRANCH_18_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_19_TO_IP is defined as MSR_LASTBRANCH_19_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_20_TO_IP is defined as MSR_LASTBRANCH_20_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_21_TO_IP is defined as MSR_LASTBRANCH_21_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_22_TO_IP is defined as MSR_LASTBRANCH_22_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_23_TO_IP is defined as MSR_LASTBRANCH_23_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_24_TO_IP is defined as MSR_LASTBRANCH_24_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_25_TO_IP is defined as MSR_LASTBRANCH_25_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_26_TO_IP is defined as MSR_LASTBRANCH_26_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_27_TO_IP is defined as MSR_LASTBRANCH_27_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_28_TO_IP is defined as MSR_LASTBRANCH_28_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_29_TO_IP is defined as MSR_LASTBRANCH_29_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_30_TO_IP is defined as MSR_LASTBRANCH_30_TO_IP in SDM. - MSR_GOLDMONT_LASTBRANCH_31_TO_IP is defined as MSR_LASTBRANCH_31_TO_IP in SDM. - @{ -**/ -#define MSR_GOLDMONT_LASTBRANCH_0_TO_IP 0x000006C0 -#define MSR_GOLDMONT_LASTBRANCH_1_TO_IP 0x000006C1 -#define MSR_GOLDMONT_LASTBRANCH_2_TO_IP 0x000006C2 -#define MSR_GOLDMONT_LASTBRANCH_3_TO_IP 0x000006C3 -#define MSR_GOLDMONT_LASTBRANCH_4_TO_IP 0x000006C4 -#define MSR_GOLDMONT_LASTBRANCH_5_TO_IP 0x000006C5 -#define MSR_GOLDMONT_LASTBRANCH_6_TO_IP 0x000006C6 -#define MSR_GOLDMONT_LASTBRANCH_7_TO_IP 0x000006C7 -#define MSR_GOLDMONT_LASTBRANCH_8_TO_IP 0x000006C8 -#define MSR_GOLDMONT_LASTBRANCH_9_TO_IP 0x000006C9 -#define MSR_GOLDMONT_LASTBRANCH_10_TO_IP 0x000006CA -#define MSR_GOLDMONT_LASTBRANCH_11_TO_IP 0x000006CB -#define MSR_GOLDMONT_LASTBRANCH_12_TO_IP 0x000006CC -#define MSR_GOLDMONT_LASTBRANCH_13_TO_IP 0x000006CD -#define MSR_GOLDMONT_LASTBRANCH_14_TO_IP 0x000006CE -#define MSR_GOLDMONT_LASTBRANCH_15_TO_IP 0x000006CF -#define MSR_GOLDMONT_LASTBRANCH_16_TO_IP 0x000006D0 -#define MSR_GOLDMONT_LASTBRANCH_17_TO_IP 0x000006D1 -#define MSR_GOLDMONT_LASTBRANCH_18_TO_IP 0x000006D2 -#define MSR_GOLDMONT_LASTBRANCH_19_TO_IP 0x000006D3 -#define MSR_GOLDMONT_LASTBRANCH_20_TO_IP 0x000006D4 -#define MSR_GOLDMONT_LASTBRANCH_21_TO_IP 0x000006D5 -#define MSR_GOLDMONT_LASTBRANCH_22_TO_IP 0x000006D6 -#define MSR_GOLDMONT_LASTBRANCH_23_TO_IP 0x000006D7 -#define MSR_GOLDMONT_LASTBRANCH_24_TO_IP 0x000006D8 -#define MSR_GOLDMONT_LASTBRANCH_25_TO_IP 0x000006D9 -#define MSR_GOLDMONT_LASTBRANCH_26_TO_IP 0x000006DA -#define MSR_GOLDMONT_LASTBRANCH_27_TO_IP 0x000006DB -#define MSR_GOLDMONT_LASTBRANCH_28_TO_IP 0x000006DC -#define MSR_GOLDMONT_LASTBRANCH_29_TO_IP 0x000006DD -#define MSR_GOLDMONT_LASTBRANCH_30_TO_IP 0x000006DE -#define MSR_GOLDMONT_LASTBRANCH_31_TO_IP 0x000006DF -/// @} - -/** - MSR information returned for MSR indexes #MSR_GOLDMONT_LASTBRANCH_0_TO_IP to - #MSR_GOLDMONT_LASTBRANCH_31_TO_IP. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 31:0] Target Linear Address (R/W). - /// - UINT32 TargetLinearAddress:32; - /// - /// [Bit 47:32] Target Linear Address (R/W). - /// - UINT32 TargetLinearAddressHi:16; - /// - /// [Bits 63:48] Elapsed cycles from last update to the LBR. - /// - UINT32 ElapsedCycles:16; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_LASTBRANCH_TO_IP_REGISTER; - - -/** - Core. Resource Association Register (R/W). - - @param ECX MSR_GOLDMONT_IA32_PQR_ASSOC (0x00000C8F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_PQR_ASSOC); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_PQR_ASSOC, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. -**/ -#define MSR_GOLDMONT_IA32_PQR_ASSOC 0x00000C8F - -/** - MSR information returned for MSR index #MSR_GOLDMONT_IA32_PQR_ASSOC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - /// - /// [Bits 33:32] COS (R/W). - /// - UINT32 COS:2; - UINT32 Reserved2:30; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_PQR_ASSOC_REGISTER; - - -/** - Module. L2 Class Of Service Mask - COS n (R/W) if CPUID.(EAX=10H, - ECX=1):EDX.COS_MAX[15:0] >=n. - - @param ECX MSR_GOLDMONT_IA32_L2_QOS_MASK_n - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_n); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_n, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_L2_QOS_MASK_0 is defined as IA32_L2_QOS_MASK_0 in SDM. - MSR_GOLDMONT_IA32_L2_QOS_MASK_1 is defined as IA32_L2_QOS_MASK_1 in SDM. - MSR_GOLDMONT_IA32_L2_QOS_MASK_2 is defined as IA32_L2_QOS_MASK_2 in SDM. - @{ -**/ -#define MSR_GOLDMONT_IA32_L2_QOS_MASK_0 0x00000D10 -#define MSR_GOLDMONT_IA32_L2_QOS_MASK_1 0x00000D11 -#define MSR_GOLDMONT_IA32_L2_QOS_MASK_2 0x00000D12 -/// @} - -/** - MSR information returned for MSR indexes #MSR_GOLDMONT_IA32_L2_QOS_MASK_0 to - #MSR_GOLDMONT_IA32_L2_QOS_MASK_2. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] CBM: Bit vector of available L2 ways for COS 0 enforcement - /// - UINT32 CBM:8; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_L2_QOS_MASK_REGISTER; - - -/** - Package. L2 Class Of Service Mask - COS 3 (R/W) if CPUID.(EAX=10H, - ECX=1):EDX.COS_MAX[15:0] >=3. - - @param ECX MSR_GOLDMONT_IA32_L2_QOS_MASK_3 - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER. - - Example usage - @code - MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_3); - AsmWriteMsr64 (MSR_GOLDMONT_IA32_L2_QOS_MASK_3, Msr.Uint64); - @endcode - @note MSR_GOLDMONT_IA32_L2_QOS_MASK_3 is defined as IA32_L2_QOS_MASK_3 in SDM. -**/ -#define MSR_GOLDMONT_IA32_L2_QOS_MASK_3 0x00000D13 - -/** - MSR information returned for MSR index #MSR_GOLDMONT_IA32_L2_QOS_MASK_3. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 19:0] CBM: Bit vector of available L2 ways for COS 0 enforcement - /// - UINT32 CBM:20; - UINT32 Reserved1:12; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_GOLDMONT_IA32_L2_QOS_MASK_3_REGISTER; - - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h b/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h deleted file mode 100644 index b737a9e4b8..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/HaswellEMsr.h +++ /dev/null @@ -1,6352 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Haswell-E microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.12. - -**/ - -#ifndef __HASWELL_E_MSR_H__ -#define __HASWELL_E_MSR_H__ - -#include - -/** - Is Intel processors based on the Haswell-E microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_HASWELL_E_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x3F \ - ) \ - ) - -/** - Package. Configured State of Enabled Processor Core Count and Logical - Processor Count (RO) - After a Power-On RESET, enumerates factory - configuration of the number of processor cores and logical processors in the - physical package. - Following the sequence of (i) BIOS modified a - Configuration Mask which selects a subset of processor cores to be active - post RESET and (ii) a RESET event after the modification, enumerates the - current configuration of enabled processor core count and logical processor - count in the physical package. - - @param ECX MSR_HASWELL_E_CORE_THREAD_COUNT (0x00000035) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER. - - Example usage - @code - MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_CORE_THREAD_COUNT); - @endcode - @note MSR_HASWELL_E_CORE_THREAD_COUNT is defined as MSR_CORE_THREAD_COUNT in SDM. -**/ -#define MSR_HASWELL_E_CORE_THREAD_COUNT 0x00000035 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_CORE_THREAD_COUNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Core_COUNT (RO) The number of processor cores that are - /// currently enabled (by either factory configuration or BIOS - /// configuration) in the physical package. - /// - UINT32 Core_Count:16; - /// - /// [Bits 31:16] THREAD_COUNT (RO) The number of logical processors that - /// are currently enabled (by either factory configuration or BIOS - /// configuration) in the physical package. - /// - UINT32 Thread_Count:16; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_CORE_THREAD_COUNT_REGISTER; - - -/** - Thread. A Hardware Assigned ID for the Logical Processor (RO). - - @param ECX MSR_HASWELL_E_THREAD_ID_INFO (0x00000053) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_THREAD_ID_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_THREAD_ID_INFO_REGISTER. - - Example usage - @code - MSR_HASWELL_E_THREAD_ID_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_THREAD_ID_INFO); - @endcode - @note MSR_HASWELL_E_THREAD_ID_INFO is defined as MSR_THREAD_ID_INFO in SDM. -**/ -#define MSR_HASWELL_E_THREAD_ID_INFO 0x00000053 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_THREAD_ID_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Logical_Processor_ID (RO) An implementation-specific - /// numerical. value physically assigned to each logical processor. This - /// ID is not related to Initial APIC ID or x2APIC ID, it is unique within - /// a physical package. - /// - UINT32 Logical_Processor_ID:8; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_THREAD_ID_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are processor - specific C-state code names, unrelated to MWAIT extension C-state parameters - or ACPI C-states. `See http://biosbits.org. `__. - - @param ECX MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power) for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0/C1 (no package C-state support) 001b: C2 010b: C6 (non-retention) - /// 011b: C6 (retention) 111b: No Package C state limits. All C states - /// supported by the processor are available. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W). - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO). - /// - UINT32 CFGLock:1; - UINT32 Reserved3:9; - /// - /// [Bit 25] C3 State Auto Demotion Enable (R/W). - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 State Auto Demotion Enable (R/W). - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 Undemotion (R/W). - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 Undemotion (R/W). - /// - UINT32 C1Undemotion:1; - /// - /// [Bit 29] Package C State Demotion Enable (R/W). - /// - UINT32 CStateDemotion:1; - /// - /// [Bit 30] Package C State UnDemotion Enable (R/W). - /// - UINT32 CStateUndemotion:1; - UINT32 Reserved4:1; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Thread. Global Machine Check Capability (R/O). - - @param ECX MSR_HASWELL_E_IA32_MCG_CAP (0x00000179) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_MCG_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_MCG_CAP_REGISTER. - - Example usage - @code - MSR_HASWELL_E_IA32_MCG_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_MCG_CAP); - @endcode - @note MSR_HASWELL_E_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. -**/ -#define MSR_HASWELL_E_IA32_MCG_CAP 0x00000179 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_IA32_MCG_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Count. - /// - UINT32 Count:8; - /// - /// [Bit 8] MCG_CTL_P. - /// - UINT32 MCG_CTL_P:1; - /// - /// [Bit 9] MCG_EXT_P. - /// - UINT32 MCG_EXT_P:1; - /// - /// [Bit 10] MCP_CMCI_P. - /// - UINT32 MCP_CMCI_P:1; - /// - /// [Bit 11] MCG_TES_P. - /// - UINT32 MCG_TES_P:1; - UINT32 Reserved1:4; - /// - /// [Bits 23:16] MCG_EXT_CNT. - /// - UINT32 MCG_EXT_CNT:8; - /// - /// [Bit 24] MCG_SER_P. - /// - UINT32 MCG_SER_P:1; - /// - /// [Bit 25] MCG_EM_P. - /// - UINT32 MCG_EM_P:1; - /// - /// [Bit 26] MCG_ELOG_P. - /// - UINT32 MCG_ELOG_P:1; - UINT32 Reserved2:5; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_IA32_MCG_CAP_REGISTER; - - -/** - THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_HASWELL_E_SMM_MCA_CAP (0x0000017D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_SMM_MCA_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_SMM_MCA_CAP_REGISTER. - - Example usage - @code - MSR_HASWELL_E_SMM_MCA_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_SMM_MCA_CAP); - AsmWriteMsr64 (MSR_HASWELL_E_SMM_MCA_CAP, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. -**/ -#define MSR_HASWELL_E_SMM_MCA_CAP 0x0000017D - -/** - MSR information returned for MSR index #MSR_HASWELL_E_SMM_MCA_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:26; - /// - /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the - /// SMM code access restriction is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 SMM_Code_Access_Chk:1; - /// - /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the - /// SMM long flow indicator is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 Long_Flow_Indication:1; - UINT32 Reserved3:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_SMM_MCA_CAP_REGISTER; - - -/** - Package. MC Bank Error Configuration (R/W). - - @param ECX MSR_HASWELL_E_ERROR_CONTROL (0x0000017F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_ERROR_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_ERROR_CONTROL_REGISTER. - - Example usage - @code - MSR_HASWELL_E_ERROR_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_ERROR_CONTROL); - AsmWriteMsr64 (MSR_HASWELL_E_ERROR_CONTROL, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. -**/ -#define MSR_HASWELL_E_ERROR_CONTROL 0x0000017F - -/** - MSR information returned for MSR index #MSR_HASWELL_E_ERROR_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank - /// to log additional info in bits 36:32. - /// - UINT32 MemErrorLogEnable:1; - UINT32 Reserved2:30; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_ERROR_CONTROL_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT); - @endcode - @note MSR_HASWELL_E_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_HASWELL_E_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio - /// limit of 5 core active. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio - /// limit of 6 core active. - /// - UINT32 Maximum6C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio - /// limit of 7 core active. - /// - UINT32 Maximum7C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio - /// limit of 8 core active. - /// - UINT32 Maximum8C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT1 (0x000001AE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER. - - Example usage - @code - MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT1); - @endcode - @note MSR_HASWELL_E_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. -**/ -#define MSR_HASWELL_E_TURBO_RATIO_LIMIT1 0x000001AE - -/** - MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 9C Maximum turbo ratio - /// limit of 9 core active. - /// - UINT32 Maximum9C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 10C Maximum turbo ratio - /// limit of 10 core active. - /// - UINT32 Maximum10C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 11C Maximum turbo ratio - /// limit of 11 core active. - /// - UINT32 Maximum11C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 12C Maximum turbo ratio - /// limit of 12 core active. - /// - UINT32 Maximum12C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 13C Maximum turbo ratio - /// limit of 13 core active. - /// - UINT32 Maximum13C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 14C Maximum turbo ratio - /// limit of 14 core active. - /// - UINT32 Maximum14C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 15C Maximum turbo ratio - /// limit of 15 core active. - /// - UINT32 Maximum15C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for16C Maximum turbo ratio - /// limit of 16 core active. - /// - UINT32 Maximum16C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_TURBO_RATIO_LIMIT1_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_HASWELL_E_TURBO_RATIO_LIMIT2 (0x000001AF) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER. - - Example usage - @code - MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_TURBO_RATIO_LIMIT2); - @endcode - @note MSR_HASWELL_E_TURBO_RATIO_LIMIT2 is defined as MSR_TURBO_RATIO_LIMIT2 in SDM. -**/ -#define MSR_HASWELL_E_TURBO_RATIO_LIMIT2 0x000001AF - -/** - MSR information returned for MSR index #MSR_HASWELL_E_TURBO_RATIO_LIMIT2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 17C Maximum turbo ratio - /// limit of 17 core active. - /// - UINT32 Maximum17C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 18C Maximum turbo ratio - /// limit of 18 core active. - /// - UINT32 Maximum18C:8; - UINT32 Reserved1:16; - UINT32 Reserved2:31; - /// - /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, - /// the processor uses override configuration specified in - /// MSR_TURBO_RATIO_LIMIT, MSR_TURBO_RATIO_LIMIT1 and - /// MSR_TURBO_RATIO_LIMIT2. If 0, the processor uses factory-set - /// configuration (Default). - /// - UINT32 TurboRatioLimitConfigurationSemaphore:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_TURBO_RATIO_LIMIT2_REGISTER; - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O). - - @param ECX MSR_HASWELL_E_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_RAPL_POWER_UNIT); - @endcode - @note MSR_HASWELL_E_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_HASWELL_E_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Package. Energy Status Units Energy related information - /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an - /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 - /// micro-joules). - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL - /// Interfaces.". - /// - UINT32 TimeUnits:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_HASWELL_E_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_HASWELL_E_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_HASWELL_E_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_HASWELL_E_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) Energy Consumed by DRAM devices. - - @param ECX MSR_HASWELL_E_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER. - - Example usage - @code - MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_DRAM_ENERGY_STATUS); - @endcode - @note MSR_HASWELL_E_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_HASWELL_E_DRAM_ENERGY_STATUS 0x00000619 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_DRAM_ENERGY_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Energy in 15.3 micro-joules. Requires BIOS configuration - /// to enable DRAM RAPL mode 0 (Direct VR). - /// - UINT32 Energy:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_DRAM_ENERGY_STATUS_REGISTER; - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_HASWELL_E_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_PERF_STATUS); - @endcode - @note MSR_HASWELL_E_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_HASWELL_E_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_HASWELL_E_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_HASWELL_E_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_HASWELL_E_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_HASWELL_E_DRAM_POWER_INFO 0x0000061C - - -/** - Package. Configuration of PCIE PLL Relative to BCLK(R/W). - - @param ECX MSR_HASWELL_E_PCIE_PLL_RATIO (0x0000061E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER. - - Example usage - @code - MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_PCIE_PLL_RATIO); - AsmWriteMsr64 (MSR_HASWELL_E_PCIE_PLL_RATIO, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_PCIE_PLL_RATIO is defined as MSR_PCIE_PLL_RATIO in SDM. -**/ -#define MSR_HASWELL_E_PCIE_PLL_RATIO 0x0000061E - -/** - MSR information returned for MSR index #MSR_HASWELL_E_PCIE_PLL_RATIO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] Package. PCIE Ratio (R/W) 00b: Use 5:5 mapping for100MHz - /// operation (default) 01b: Use 5:4 mapping for125MHz operation 10b: Use - /// 5:3 mapping for166MHz operation 11b: Use 5:2 mapping for250MHz - /// operation. - /// - UINT32 PCIERatio:2; - /// - /// [Bit 2] Package. LPLL Select (R/W) if 1, use configured setting of - /// PCIE Ratio. - /// - UINT32 LPLLSelect:1; - /// - /// [Bit 3] Package. LONG RESET (R/W) if 1, wait additional time-out - /// before re-locking Gen2/Gen3 PLLs. - /// - UINT32 LONGRESET:1; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_PCIE_PLL_RATIO_REGISTER; - - -/** - Package. Reserved (R/O) Reads return 0. - - @param ECX MSR_HASWELL_E_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PP0_ENERGY_STATUS); - @endcode - @note MSR_HASWELL_E_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_HASWELL_E_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS (0x00000690) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS 0x00000690 - -/** - MSR information returned for MSR index #MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is - /// reduced below the operating system request due to assertion of - /// external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - /// - /// [Bit 2] Power Budget Management Status (R0) When set, frequency is - /// reduced below the operating system request due to PBM limit. - /// - UINT32 PowerBudgetManagementStatus:1; - /// - /// [Bit 3] Platform Configuration Services Status (R0) When set, - /// frequency is reduced below the operating system request due to PCS - /// limit. - /// - UINT32 PlatformConfigurationServicesStatus:1; - UINT32 Reserved1:1; - /// - /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) - /// When set, frequency is reduced below the operating system request - /// because the processor has detected that utilization is low. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - UINT32 Reserved3:1; - /// - /// [Bit 10] Multi-Core Turbo Status (R0) When set, frequency is reduced - /// below the operating system request due to Multi-Core Turbo limits. - /// - UINT32 MultiCoreTurboStatus:1; - UINT32 Reserved4:2; - /// - /// [Bit 13] Core Frequency P1 Status (R0) When set, frequency is reduced - /// below max non-turbo P1. - /// - UINT32 FrequencyP1Status:1; - /// - /// [Bit 14] Core Max n-core Turbo Frequency Limiting Status (R0) When - /// set, frequency is reduced below max n-core turbo frequency. - /// - UINT32 TurboFrequencyLimitingStatus:1; - /// - /// [Bit 15] Core Frequency Limiting Status (R0) When set, frequency is - /// reduced below the operating system request. - /// - UINT32 FrequencyLimitingStatus:1; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - /// - /// [Bit 18] Power Budget Management Log When set, indicates that the PBM - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 PowerBudgetManagementLog:1; - /// - /// [Bit 19] Platform Configuration Services Log When set, indicates that - /// the PCS Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 PlatformConfigurationServicesLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, - /// indicates that the AUBFC Status bit has asserted since the log bit was - /// last cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - UINT32 Reserved6:1; - /// - /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - UINT32 Reserved7:1; - /// - /// [Bit 26] Multi-Core Turbo Log When set, indicates that the Multi-Core - /// Turbo Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MultiCoreTurboLog:1; - UINT32 Reserved8:2; - /// - /// [Bit 29] Core Frequency P1 Log When set, indicates that the Core - /// Frequency P1 Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CoreFrequencyP1Log:1; - /// - /// [Bit 30] Core Max n-core Turbo Frequency Limiting Log When set, - /// indicates that the Core Max n-core Turbo Frequency Limiting Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 TurboFrequencyLimitingLog:1; - /// - /// [Bit 31] Core Frequency Limiting Log When set, indicates that the Core - /// Frequency Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CoreFrequencyLimitingLog:1; - UINT32 Reserved9:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_CORE_PERF_LIMIT_REASONS_REGISTER; - - -/** - THREAD. Monitoring Event Select Register (R/W). if CPUID.(EAX=07H, - ECX=0):EBX.RDT-M[bit 12] = 1. - - @param ECX MSR_HASWELL_E_IA32_QM_EVTSEL (0x00000C8D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER. - - Example usage - @code - MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_QM_EVTSEL); - AsmWriteMsr64 (MSR_HASWELL_E_IA32_QM_EVTSEL, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. -**/ -#define MSR_HASWELL_E_IA32_QM_EVTSEL 0x00000C8D - -/** - MSR information returned for MSR index #MSR_HASWELL_E_IA32_QM_EVTSEL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] EventID (RW) Event encoding: 0x0: no monitoring 0x1: L3 - /// occupancy monitoring all other encoding reserved.. - /// - UINT32 EventID:8; - UINT32 Reserved1:24; - /// - /// [Bits 41:32] RMID (RW). - /// - UINT32 RMID:10; - UINT32 Reserved2:22; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_IA32_QM_EVTSEL_REGISTER; - - -/** - THREAD. Resource Association Register (R/W).. - - @param ECX MSR_HASWELL_E_IA32_PQR_ASSOC (0x00000C8F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER. - - Example usage - @code - MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_E_IA32_PQR_ASSOC); - AsmWriteMsr64 (MSR_HASWELL_E_IA32_PQR_ASSOC, Msr.Uint64); - @endcode - @note MSR_HASWELL_E_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. -**/ -#define MSR_HASWELL_E_IA32_PQR_ASSOC 0x00000C8F - -/** - MSR information returned for MSR index #MSR_HASWELL_E_IA32_PQR_ASSOC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] RMID. - /// - UINT32 RMID:10; - UINT32 Reserved1:22; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_E_IA32_PQR_ASSOC_REGISTER; - - -/** - Package. Uncore perfmon per-socket global control. - - @param ECX MSR_HASWELL_E_PMON_GLOBAL_CTL (0x00000700) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CTL, Msr); - @endcode - @note MSR_HASWELL_E_PMON_GLOBAL_CTL is defined as MSR_PMON_GLOBAL_CTL in SDM. -**/ -#define MSR_HASWELL_E_PMON_GLOBAL_CTL 0x00000700 - - -/** - Package. Uncore perfmon per-socket global status. - - @param ECX MSR_HASWELL_E_PMON_GLOBAL_STATUS (0x00000701) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_PMON_GLOBAL_STATUS is defined as MSR_PMON_GLOBAL_STATUS in SDM. -**/ -#define MSR_HASWELL_E_PMON_GLOBAL_STATUS 0x00000701 - - -/** - Package. Uncore perfmon per-socket global configuration. - - @param ECX MSR_HASWELL_E_PMON_GLOBAL_CONFIG (0x00000702) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CONFIG); - AsmWriteMsr64 (MSR_HASWELL_E_PMON_GLOBAL_CONFIG, Msr); - @endcode - @note MSR_HASWELL_E_PMON_GLOBAL_CONFIG is defined as MSR_PMON_GLOBAL_CONFIG in SDM. -**/ -#define MSR_HASWELL_E_PMON_GLOBAL_CONFIG 0x00000702 - - -/** - Package. Uncore U-box UCLK fixed counter control. - - @param ECX MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL (0x00000703) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL is defined as MSR_U_PMON_UCLK_FIXED_CTL in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTL 0x00000703 - - -/** - Package. Uncore U-box UCLK fixed counter. - - @param ECX MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR (0x00000704) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR is defined as MSR_U_PMON_UCLK_FIXED_CTR in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_UCLK_FIXED_CTR 0x00000704 - - -/** - Package. Uncore U-box perfmon event select for U-box counter 0. - - @param ECX MSR_HASWELL_E_U_PMON_EVNTSEL0 (0x00000705) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_EVNTSEL0 is defined as MSR_U_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_EVNTSEL0 0x00000705 - - -/** - Package. Uncore U-box perfmon event select for U-box counter 1. - - @param ECX MSR_HASWELL_E_U_PMON_EVNTSEL1 (0x00000706) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_EVNTSEL1 is defined as MSR_U_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_EVNTSEL1 0x00000706 - - -/** - Package. Uncore U-box perfmon U-box wide status. - - @param ECX MSR_HASWELL_E_U_PMON_BOX_STATUS (0x00000708) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_BOX_STATUS is defined as MSR_U_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_BOX_STATUS 0x00000708 - - -/** - Package. Uncore U-box perfmon counter 0. - - @param ECX MSR_HASWELL_E_U_PMON_CTR0 (0x00000709) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_CTR0 is defined as MSR_U_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_CTR0 0x00000709 - - -/** - Package. Uncore U-box perfmon counter 1. - - @param ECX MSR_HASWELL_E_U_PMON_CTR1 (0x0000070A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_U_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_U_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_U_PMON_CTR1 is defined as MSR_U_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_U_PMON_CTR1 0x0000070A - - -/** - Package. Uncore PCU perfmon for PCU-box-wide control. - - @param ECX MSR_HASWELL_E_PCU_PMON_BOX_CTL (0x00000710) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_BOX_CTL is defined as MSR_PCU_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_BOX_CTL 0x00000710 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 0. - - @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL0 (0x00000711) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_EVNTSEL0 is defined as MSR_PCU_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_EVNTSEL0 0x00000711 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 1. - - @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL1 (0x00000712) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_EVNTSEL1 is defined as MSR_PCU_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_EVNTSEL1 0x00000712 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 2. - - @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL2 (0x00000713) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_EVNTSEL2 is defined as MSR_PCU_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_EVNTSEL2 0x00000713 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 3. - - @param ECX MSR_HASWELL_E_PCU_PMON_EVNTSEL3 (0x00000714) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_EVNTSEL3 is defined as MSR_PCU_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_EVNTSEL3 0x00000714 - - -/** - Package. Uncore PCU perfmon box-wide filter. - - @param ECX MSR_HASWELL_E_PCU_PMON_BOX_FILTER (0x00000715) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_BOX_FILTER is defined as MSR_PCU_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_BOX_FILTER 0x00000715 - - -/** - Package. Uncore PCU perfmon box wide status. - - @param ECX MSR_HASWELL_E_PCU_PMON_BOX_STATUS (0x00000716) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_BOX_STATUS is defined as MSR_PCU_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_BOX_STATUS 0x00000716 - - -/** - Package. Uncore PCU perfmon counter 0. - - @param ECX MSR_HASWELL_E_PCU_PMON_CTR0 (0x00000717) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_CTR0 is defined as MSR_PCU_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_CTR0 0x00000717 - - -/** - Package. Uncore PCU perfmon counter 1. - - @param ECX MSR_HASWELL_E_PCU_PMON_CTR1 (0x00000718) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_CTR1 is defined as MSR_PCU_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_CTR1 0x00000718 - - -/** - Package. Uncore PCU perfmon counter 2. - - @param ECX MSR_HASWELL_E_PCU_PMON_CTR2 (0x00000719) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_CTR2 is defined as MSR_PCU_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_CTR2 0x00000719 - - -/** - Package. Uncore PCU perfmon counter 3. - - @param ECX MSR_HASWELL_E_PCU_PMON_CTR3 (0x0000071A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_PCU_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_PCU_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_PCU_PMON_CTR3 is defined as MSR_PCU_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_PCU_PMON_CTR3 0x0000071A - - -/** - Package. Uncore SBo 0 perfmon for SBo 0 box-wide control. - - @param ECX MSR_HASWELL_E_S0_PMON_BOX_CTL (0x00000720) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_BOX_CTL is defined as MSR_S0_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_BOX_CTL 0x00000720 - - -/** - Package. Uncore SBo 0 perfmon event select for SBo 0 counter 0. - - @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL0 (0x00000721) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_EVNTSEL0 is defined as MSR_S0_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_EVNTSEL0 0x00000721 - - -/** - Package. Uncore SBo 0 perfmon event select for SBo 0 counter 1. - - @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL1 (0x00000722) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_EVNTSEL1 is defined as MSR_S0_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_EVNTSEL1 0x00000722 - - -/** - Package. Uncore SBo 0 perfmon event select for SBo 0 counter 2. - - @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL2 (0x00000723) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_EVNTSEL2 is defined as MSR_S0_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_EVNTSEL2 0x00000723 - - -/** - Package. Uncore SBo 0 perfmon event select for SBo 0 counter 3. - - @param ECX MSR_HASWELL_E_S0_PMON_EVNTSEL3 (0x00000724) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_EVNTSEL3 is defined as MSR_S0_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_EVNTSEL3 0x00000724 - - -/** - Package. Uncore SBo 0 perfmon box-wide filter. - - @param ECX MSR_HASWELL_E_S0_PMON_BOX_FILTER (0x00000725) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_BOX_FILTER is defined as MSR_S0_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_BOX_FILTER 0x00000725 - - -/** - Package. Uncore SBo 0 perfmon counter 0. - - @param ECX MSR_HASWELL_E_S0_PMON_CTR0 (0x00000726) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_CTR0 is defined as MSR_S0_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_CTR0 0x00000726 - - -/** - Package. Uncore SBo 0 perfmon counter 1. - - @param ECX MSR_HASWELL_E_S0_PMON_CTR1 (0x00000727) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_CTR1 is defined as MSR_S0_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_CTR1 0x00000727 - - -/** - Package. Uncore SBo 0 perfmon counter 2. - - @param ECX MSR_HASWELL_E_S0_PMON_CTR2 (0x00000728) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_CTR2 is defined as MSR_S0_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_CTR2 0x00000728 - - -/** - Package. Uncore SBo 0 perfmon counter 3. - - @param ECX MSR_HASWELL_E_S0_PMON_CTR3 (0x00000729) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S0_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_S0_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_S0_PMON_CTR3 is defined as MSR_S0_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_S0_PMON_CTR3 0x00000729 - - -/** - Package. Uncore SBo 1 perfmon for SBo 1 box-wide control. - - @param ECX MSR_HASWELL_E_S1_PMON_BOX_CTL (0x0000072A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_BOX_CTL is defined as MSR_S1_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_BOX_CTL 0x0000072A - - -/** - Package. Uncore SBo 1 perfmon event select for SBo 1 counter 0. - - @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL0 (0x0000072B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_EVNTSEL0 is defined as MSR_S1_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_EVNTSEL0 0x0000072B - - -/** - Package. Uncore SBo 1 perfmon event select for SBo 1 counter 1. - - @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL1 (0x0000072C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_EVNTSEL1 is defined as MSR_S1_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_EVNTSEL1 0x0000072C - - -/** - Package. Uncore SBo 1 perfmon event select for SBo 1 counter 2. - - @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL2 (0x0000072D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_EVNTSEL2 is defined as MSR_S1_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_EVNTSEL2 0x0000072D - - -/** - Package. Uncore SBo 1 perfmon event select for SBo 1 counter 3. - - @param ECX MSR_HASWELL_E_S1_PMON_EVNTSEL3 (0x0000072E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_EVNTSEL3 is defined as MSR_S1_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_EVNTSEL3 0x0000072E - - -/** - Package. Uncore SBo 1 perfmon box-wide filter. - - @param ECX MSR_HASWELL_E_S1_PMON_BOX_FILTER (0x0000072F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_BOX_FILTER is defined as MSR_S1_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_BOX_FILTER 0x0000072F - - -/** - Package. Uncore SBo 1 perfmon counter 0. - - @param ECX MSR_HASWELL_E_S1_PMON_CTR0 (0x00000730) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_CTR0 is defined as MSR_S1_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_CTR0 0x00000730 - - -/** - Package. Uncore SBo 1 perfmon counter 1. - - @param ECX MSR_HASWELL_E_S1_PMON_CTR1 (0x00000731) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_CTR1 is defined as MSR_S1_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_CTR1 0x00000731 - - -/** - Package. Uncore SBo 1 perfmon counter 2. - - @param ECX MSR_HASWELL_E_S1_PMON_CTR2 (0x00000732) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_CTR2 is defined as MSR_S1_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_CTR2 0x00000732 - - -/** - Package. Uncore SBo 1 perfmon counter 3. - - @param ECX MSR_HASWELL_E_S1_PMON_CTR3 (0x00000733) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S1_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_S1_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_S1_PMON_CTR3 is defined as MSR_S1_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_S1_PMON_CTR3 0x00000733 - - -/** - Package. Uncore SBo 2 perfmon for SBo 2 box-wide control. - - @param ECX MSR_HASWELL_E_S2_PMON_BOX_CTL (0x00000734) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_BOX_CTL is defined as MSR_S2_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_BOX_CTL 0x00000734 - - -/** - Package. Uncore SBo 2 perfmon event select for SBo 2 counter 0. - - @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL0 (0x00000735) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_EVNTSEL0 is defined as MSR_S2_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_EVNTSEL0 0x00000735 - - -/** - Package. Uncore SBo 2 perfmon event select for SBo 2 counter 1. - - @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL1 (0x00000736) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_EVNTSEL1 is defined as MSR_S2_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_EVNTSEL1 0x00000736 - - -/** - Package. Uncore SBo 2 perfmon event select for SBo 2 counter 2. - - @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL2 (0x00000737) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_EVNTSEL2 is defined as MSR_S2_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_EVNTSEL2 0x00000737 - - -/** - Package. Uncore SBo 2 perfmon event select for SBo 2 counter 3. - - @param ECX MSR_HASWELL_E_S2_PMON_EVNTSEL3 (0x00000738) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_EVNTSEL3 is defined as MSR_S2_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_EVNTSEL3 0x00000738 - - -/** - Package. Uncore SBo 2 perfmon box-wide filter. - - @param ECX MSR_HASWELL_E_S2_PMON_BOX_FILTER (0x00000739) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_BOX_FILTER is defined as MSR_S2_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_BOX_FILTER 0x00000739 - - -/** - Package. Uncore SBo 2 perfmon counter 0. - - @param ECX MSR_HASWELL_E_S2_PMON_CTR0 (0x0000073A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_CTR0 is defined as MSR_S2_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_CTR0 0x0000073A - - -/** - Package. Uncore SBo 2 perfmon counter 1. - - @param ECX MSR_HASWELL_E_S2_PMON_CTR1 (0x0000073B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_CTR1 is defined as MSR_S2_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_CTR1 0x0000073B - - -/** - Package. Uncore SBo 2 perfmon counter 2. - - @param ECX MSR_HASWELL_E_S2_PMON_CTR2 (0x0000073C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_CTR2 is defined as MSR_S2_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_CTR2 0x0000073C - - -/** - Package. Uncore SBo 2 perfmon counter 3. - - @param ECX MSR_HASWELL_E_S2_PMON_CTR3 (0x0000073D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S2_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_S2_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_S2_PMON_CTR3 is defined as MSR_S2_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_S2_PMON_CTR3 0x0000073D - - -/** - Package. Uncore SBo 3 perfmon for SBo 3 box-wide control. - - @param ECX MSR_HASWELL_E_S3_PMON_BOX_CTL (0x0000073E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_BOX_CTL is defined as MSR_S3_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_BOX_CTL 0x0000073E - - -/** - Package. Uncore SBo 3 perfmon event select for SBo 3 counter 0. - - @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL0 (0x0000073F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_EVNTSEL0 is defined as MSR_S3_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_EVNTSEL0 0x0000073F - - -/** - Package. Uncore SBo 3 perfmon event select for SBo 3 counter 1. - - @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL1 (0x00000740) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_EVNTSEL1 is defined as MSR_S3_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_EVNTSEL1 0x00000740 - - -/** - Package. Uncore SBo 3 perfmon event select for SBo 3 counter 2. - - @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL2 (0x00000741) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_EVNTSEL2 is defined as MSR_S3_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_EVNTSEL2 0x00000741 - - -/** - Package. Uncore SBo 3 perfmon event select for SBo 3 counter 3. - - @param ECX MSR_HASWELL_E_S3_PMON_EVNTSEL3 (0x00000742) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_EVNTSEL3 is defined as MSR_S3_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_EVNTSEL3 0x00000742 - - -/** - Package. Uncore SBo 3 perfmon box-wide filter. - - @param ECX MSR_HASWELL_E_S3_PMON_BOX_FILTER (0x00000743) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_BOX_FILTER is defined as MSR_S3_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_BOX_FILTER 0x00000743 - - -/** - Package. Uncore SBo 3 perfmon counter 0. - - @param ECX MSR_HASWELL_E_S3_PMON_CTR0 (0x00000744) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_CTR0 is defined as MSR_S3_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_CTR0 0x00000744 - - -/** - Package. Uncore SBo 3 perfmon counter 1. - - @param ECX MSR_HASWELL_E_S3_PMON_CTR1 (0x00000745) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_CTR1 is defined as MSR_S3_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_CTR1 0x00000745 - - -/** - Package. Uncore SBo 3 perfmon counter 2. - - @param ECX MSR_HASWELL_E_S3_PMON_CTR2 (0x00000746) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_CTR2 is defined as MSR_S3_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_CTR2 0x00000746 - - -/** - Package. Uncore SBo 3 perfmon counter 3. - - @param ECX MSR_HASWELL_E_S3_PMON_CTR3 (0x00000747) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_S3_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_S3_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_S3_PMON_CTR3 is defined as MSR_S3_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_S3_PMON_CTR3 0x00000747 - - -/** - Package. Uncore C-box 0 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C0_PMON_BOX_CTL (0x00000E00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_BOX_CTL is defined as MSR_C0_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_BOX_CTL 0x00000E00 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 0. - - @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL0 (0x00000E01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_EVNTSEL0 is defined as MSR_C0_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_EVNTSEL0 0x00000E01 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 1. - - @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL1 (0x00000E02) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_EVNTSEL1 is defined as MSR_C0_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_EVNTSEL1 0x00000E02 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 2. - - @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL2 (0x00000E03) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_EVNTSEL2 is defined as MSR_C0_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_EVNTSEL2 0x00000E03 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 3. - - @param ECX MSR_HASWELL_E_C0_PMON_EVNTSEL3 (0x00000E04) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_EVNTSEL3 is defined as MSR_C0_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_EVNTSEL3 0x00000E04 - - -/** - Package. Uncore C-box 0 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C0_PMON_BOX_FILTER0 (0x00000E05) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_BOX_FILTER0 is defined as MSR_C0_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_BOX_FILTER0 0x00000E05 - - -/** - Package. Uncore C-box 0 perfmon box wide filter 1. - - @param ECX MSR_HASWELL_E_C0_PMON_BOX_FILTER1 (0x00000E06) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_BOX_FILTER1 is defined as MSR_C0_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_BOX_FILTER1 0x00000E06 - - -/** - Package. Uncore C-box 0 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C0_PMON_BOX_STATUS (0x00000E07) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_BOX_STATUS is defined as MSR_C0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_BOX_STATUS 0x00000E07 - - -/** - Package. Uncore C-box 0 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C0_PMON_CTR0 (0x00000E08) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_CTR0 0x00000E08 - - -/** - Package. Uncore C-box 0 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C0_PMON_CTR1 (0x00000E09) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_CTR1 0x00000E09 - - -/** - Package. Uncore C-box 0 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C0_PMON_CTR2 (0x00000E0A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_CTR2 0x00000E0A - - -/** - Package. Uncore C-box 0 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C0_PMON_CTR3 (0x00000E0B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C0_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C0_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C0_PMON_CTR3 0x00000E0B - - -/** - Package. Uncore C-box 1 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C1_PMON_BOX_CTL (0x00000E10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_BOX_CTL is defined as MSR_C1_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_BOX_CTL 0x00000E10 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 0. - - @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL0 (0x00000E11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_EVNTSEL0 is defined as MSR_C1_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_EVNTSEL0 0x00000E11 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 1. - - @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL1 (0x00000E12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_EVNTSEL1 is defined as MSR_C1_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_EVNTSEL1 0x00000E12 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 2. - - @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL2 (0x00000E13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_EVNTSEL2 is defined as MSR_C1_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_EVNTSEL2 0x00000E13 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 3. - - @param ECX MSR_HASWELL_E_C1_PMON_EVNTSEL3 (0x00000E14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_EVNTSEL3 is defined as MSR_C1_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_EVNTSEL3 0x00000E14 - - -/** - Package. Uncore C-box 1 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C1_PMON_BOX_FILTER0 (0x00000E15) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_BOX_FILTER0 is defined as MSR_C1_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_BOX_FILTER0 0x00000E15 - - -/** - Package. Uncore C-box 1 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C1_PMON_BOX_FILTER1 (0x00000E16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_BOX_FILTER1 is defined as MSR_C1_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_BOX_FILTER1 0x00000E16 - - -/** - Package. Uncore C-box 1 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C1_PMON_BOX_STATUS (0x00000E17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_BOX_STATUS is defined as MSR_C1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_BOX_STATUS 0x00000E17 - - -/** - Package. Uncore C-box 1 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C1_PMON_CTR0 (0x00000E18) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_CTR0 0x00000E18 - - -/** - Package. Uncore C-box 1 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C1_PMON_CTR1 (0x00000E19) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_CTR1 0x00000E19 - - -/** - Package. Uncore C-box 1 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C1_PMON_CTR2 (0x00000E1A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_CTR2 0x00000E1A - - -/** - Package. Uncore C-box 1 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C1_PMON_CTR3 (0x00000E1B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C1_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C1_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C1_PMON_CTR3 0x00000E1B - - -/** - Package. Uncore C-box 2 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C2_PMON_BOX_CTL (0x00000E20) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_BOX_CTL is defined as MSR_C2_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_BOX_CTL 0x00000E20 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 0. - - @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL0 (0x00000E21) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_EVNTSEL0 is defined as MSR_C2_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_EVNTSEL0 0x00000E21 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 1. - - @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL1 (0x00000E22) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_EVNTSEL1 is defined as MSR_C2_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_EVNTSEL1 0x00000E22 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 2. - - @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL2 (0x00000E23) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_EVNTSEL2 is defined as MSR_C2_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_EVNTSEL2 0x00000E23 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 3. - - @param ECX MSR_HASWELL_E_C2_PMON_EVNTSEL3 (0x00000E24) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_EVNTSEL3 is defined as MSR_C2_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_EVNTSEL3 0x00000E24 - - -/** - Package. Uncore C-box 2 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C2_PMON_BOX_FILTER0 (0x00000E25) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_BOX_FILTER0 is defined as MSR_C2_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_BOX_FILTER0 0x00000E25 - - -/** - Package. Uncore C-box 2 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C2_PMON_BOX_FILTER1 (0x00000E26) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_BOX_FILTER1 is defined as MSR_C2_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_BOX_FILTER1 0x00000E26 - - -/** - Package. Uncore C-box 2 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C2_PMON_BOX_STATUS (0x00000E27) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_BOX_STATUS is defined as MSR_C2_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_BOX_STATUS 0x00000E27 - - -/** - Package. Uncore C-box 2 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C2_PMON_CTR0 (0x00000E28) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_CTR0 0x00000E28 - - -/** - Package. Uncore C-box 2 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C2_PMON_CTR1 (0x00000E29) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_CTR1 0x00000E29 - - -/** - Package. Uncore C-box 2 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C2_PMON_CTR2 (0x00000E2A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_CTR2 0x00000E2A - - -/** - Package. Uncore C-box 2 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C2_PMON_CTR3 (0x00000E2B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C2_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C2_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C2_PMON_CTR3 0x00000E2B - - -/** - Package. Uncore C-box 3 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C3_PMON_BOX_CTL (0x00000E30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_BOX_CTL is defined as MSR_C3_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_BOX_CTL 0x00000E30 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 0. - - @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL0 (0x00000E31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_EVNTSEL0 is defined as MSR_C3_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_EVNTSEL0 0x00000E31 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 1. - - @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL1 (0x00000E32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_EVNTSEL1 is defined as MSR_C3_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_EVNTSEL1 0x00000E32 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 2. - - @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL2 (0x00000E33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_EVNTSEL2 is defined as MSR_C3_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_EVNTSEL2 0x00000E33 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 3. - - @param ECX MSR_HASWELL_E_C3_PMON_EVNTSEL3 (0x00000E34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_EVNTSEL3 is defined as MSR_C3_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_EVNTSEL3 0x00000E34 - - -/** - Package. Uncore C-box 3 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C3_PMON_BOX_FILTER0 (0x00000E35) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_BOX_FILTER0 is defined as MSR_C3_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_BOX_FILTER0 0x00000E35 - - -/** - Package. Uncore C-box 3 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C3_PMON_BOX_FILTER1 (0x00000E36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_BOX_FILTER1 is defined as MSR_C3_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_BOX_FILTER1 0x00000E36 - - -/** - Package. Uncore C-box 3 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C3_PMON_BOX_STATUS (0x00000E37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_BOX_STATUS is defined as MSR_C3_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_BOX_STATUS 0x00000E37 - - -/** - Package. Uncore C-box 3 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C3_PMON_CTR0 (0x00000E38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_CTR0 0x00000E38 - - -/** - Package. Uncore C-box 3 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C3_PMON_CTR1 (0x00000E39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_CTR1 0x00000E39 - - -/** - Package. Uncore C-box 3 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C3_PMON_CTR2 (0x00000E3A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_CTR2 0x00000E3A - - -/** - Package. Uncore C-box 3 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C3_PMON_CTR3 (0x00000E3B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C3_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C3_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C3_PMON_CTR3 0x00000E3B - - -/** - Package. Uncore C-box 4 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C4_PMON_BOX_CTL (0x00000E40) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_BOX_CTL is defined as MSR_C4_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_BOX_CTL 0x00000E40 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 0. - - @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL0 (0x00000E41) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_EVNTSEL0 is defined as MSR_C4_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_EVNTSEL0 0x00000E41 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 1. - - @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL1 (0x00000E42) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_EVNTSEL1 is defined as MSR_C4_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_EVNTSEL1 0x00000E42 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 2. - - @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL2 (0x00000E43) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_EVNTSEL2 is defined as MSR_C4_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_EVNTSEL2 0x00000E43 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 3. - - @param ECX MSR_HASWELL_E_C4_PMON_EVNTSEL3 (0x00000E44) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_EVNTSEL3 is defined as MSR_C4_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_EVNTSEL3 0x00000E44 - - -/** - Package. Uncore C-box 4 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C4_PMON_BOX_FILTER0 (0x00000E45) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_BOX_FILTER0 is defined as MSR_C4_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_BOX_FILTER0 0x00000E45 - - -/** - Package. Uncore C-box 4 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C4_PMON_BOX_FILTER1 (0x00000E46) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_BOX_FILTER1 is defined as MSR_C4_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_BOX_FILTER1 0x00000E46 - - -/** - Package. Uncore C-box 4 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C4_PMON_BOX_STATUS (0x00000E47) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_BOX_STATUS is defined as MSR_C4_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_BOX_STATUS 0x00000E47 - - -/** - Package. Uncore C-box 4 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C4_PMON_CTR0 (0x00000E48) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_CTR0 0x00000E48 - - -/** - Package. Uncore C-box 4 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C4_PMON_CTR1 (0x00000E49) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_CTR1 0x00000E49 - - -/** - Package. Uncore C-box 4 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C4_PMON_CTR2 (0x00000E4A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_CTR2 0x00000E4A - - -/** - Package. Uncore C-box 4 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C4_PMON_CTR3 (0x00000E4B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C4_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C4_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C4_PMON_CTR3 0x00000E4B - - -/** - Package. Uncore C-box 5 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C5_PMON_BOX_CTL (0x00000E50) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_BOX_CTL is defined as MSR_C5_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_BOX_CTL 0x00000E50 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 0. - - @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL0 (0x00000E51) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_EVNTSEL0 is defined as MSR_C5_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_EVNTSEL0 0x00000E51 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 1. - - @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL1 (0x00000E52) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_EVNTSEL1 is defined as MSR_C5_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_EVNTSEL1 0x00000E52 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 2. - - @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL2 (0x00000E53) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_EVNTSEL2 is defined as MSR_C5_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_EVNTSEL2 0x00000E53 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 3. - - @param ECX MSR_HASWELL_E_C5_PMON_EVNTSEL3 (0x00000E54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_EVNTSEL3 is defined as MSR_C5_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_EVNTSEL3 0x00000E54 - - -/** - Package. Uncore C-box 5 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C5_PMON_BOX_FILTER0 (0x00000E55) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_BOX_FILTER0 is defined as MSR_C5_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_BOX_FILTER0 0x00000E55 - - -/** - Package. Uncore C-box 5 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C5_PMON_BOX_FILTER1 (0x00000E56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_BOX_FILTER1 is defined as MSR_C5_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_BOX_FILTER1 0x00000E56 - - -/** - Package. Uncore C-box 5 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C5_PMON_BOX_STATUS (0x00000E57) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_BOX_STATUS is defined as MSR_C5_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_BOX_STATUS 0x00000E57 - - -/** - Package. Uncore C-box 5 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C5_PMON_CTR0 (0x00000E58) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_CTR0 0x00000E58 - - -/** - Package. Uncore C-box 5 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C5_PMON_CTR1 (0x00000E59) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_CTR1 0x00000E59 - - -/** - Package. Uncore C-box 5 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C5_PMON_CTR2 (0x00000E5A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_CTR2 0x00000E5A - - -/** - Package. Uncore C-box 5 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C5_PMON_CTR3 (0x00000E5B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C5_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C5_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C5_PMON_CTR3 0x00000E5B - - -/** - Package. Uncore C-box 6 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C6_PMON_BOX_CTL (0x00000E60) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_BOX_CTL is defined as MSR_C6_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_BOX_CTL 0x00000E60 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 0. - - @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL0 (0x00000E61) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_EVNTSEL0 is defined as MSR_C6_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_EVNTSEL0 0x00000E61 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 1. - - @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL1 (0x00000E62) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_EVNTSEL1 is defined as MSR_C6_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_EVNTSEL1 0x00000E62 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 2. - - @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL2 (0x00000E63) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_EVNTSEL2 is defined as MSR_C6_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_EVNTSEL2 0x00000E63 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 3. - - @param ECX MSR_HASWELL_E_C6_PMON_EVNTSEL3 (0x00000E64) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_EVNTSEL3 is defined as MSR_C6_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_EVNTSEL3 0x00000E64 - - -/** - Package. Uncore C-box 6 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C6_PMON_BOX_FILTER0 (0x00000E65) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_BOX_FILTER0 is defined as MSR_C6_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_BOX_FILTER0 0x00000E65 - - -/** - Package. Uncore C-box 6 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C6_PMON_BOX_FILTER1 (0x00000E66) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_BOX_FILTER1 is defined as MSR_C6_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_BOX_FILTER1 0x00000E66 - - -/** - Package. Uncore C-box 6 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C6_PMON_BOX_STATUS (0x00000E67) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_BOX_STATUS is defined as MSR_C6_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_BOX_STATUS 0x00000E67 - - -/** - Package. Uncore C-box 6 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C6_PMON_CTR0 (0x00000E68) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_CTR0 0x00000E68 - - -/** - Package. Uncore C-box 6 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C6_PMON_CTR1 (0x00000E69) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_CTR1 0x00000E69 - - -/** - Package. Uncore C-box 6 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C6_PMON_CTR2 (0x00000E6A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_CTR2 0x00000E6A - - -/** - Package. Uncore C-box 6 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C6_PMON_CTR3 (0x00000E6B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C6_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C6_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C6_PMON_CTR3 0x00000E6B - - -/** - Package. Uncore C-box 7 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C7_PMON_BOX_CTL (0x00000E70) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_BOX_CTL is defined as MSR_C7_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_BOX_CTL 0x00000E70 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 0. - - @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL0 (0x00000E71) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_EVNTSEL0 is defined as MSR_C7_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_EVNTSEL0 0x00000E71 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 1. - - @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL1 (0x00000E72) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_EVNTSEL1 is defined as MSR_C7_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_EVNTSEL1 0x00000E72 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 2. - - @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL2 (0x00000E73) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_EVNTSEL2 is defined as MSR_C7_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_EVNTSEL2 0x00000E73 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 3. - - @param ECX MSR_HASWELL_E_C7_PMON_EVNTSEL3 (0x00000E74) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_EVNTSEL3 is defined as MSR_C7_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_EVNTSEL3 0x00000E74 - - -/** - Package. Uncore C-box 7 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C7_PMON_BOX_FILTER0 (0x00000E75) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_BOX_FILTER0 is defined as MSR_C7_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_BOX_FILTER0 0x00000E75 - - -/** - Package. Uncore C-box 7 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C7_PMON_BOX_FILTER1 (0x00000E76) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_BOX_FILTER1 is defined as MSR_C7_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_BOX_FILTER1 0x00000E76 - - -/** - Package. Uncore C-box 7 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C7_PMON_BOX_STATUS (0x00000E77) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_BOX_STATUS is defined as MSR_C7_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_BOX_STATUS 0x00000E77 - - -/** - Package. Uncore C-box 7 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C7_PMON_CTR0 (0x00000E78) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_CTR0 0x00000E78 - - -/** - Package. Uncore C-box 7 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C7_PMON_CTR1 (0x00000E79) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_CTR1 0x00000E79 - - -/** - Package. Uncore C-box 7 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C7_PMON_CTR2 (0x00000E7A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_CTR2 0x00000E7A - - -/** - Package. Uncore C-box 7 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C7_PMON_CTR3 (0x00000E7B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C7_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C7_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C7_PMON_CTR3 0x00000E7B - - -/** - Package. Uncore C-box 8 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C8_PMON_BOX_CTL (0x00000E80) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_BOX_CTL is defined as MSR_C8_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_BOX_CTL 0x00000E80 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 0. - - @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL0 (0x00000E81) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_EVNTSEL0 is defined as MSR_C8_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_EVNTSEL0 0x00000E81 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 1. - - @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL1 (0x00000E82) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_EVNTSEL1 is defined as MSR_C8_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_EVNTSEL1 0x00000E82 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 2. - - @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL2 (0x00000E83) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_EVNTSEL2 is defined as MSR_C8_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_EVNTSEL2 0x00000E83 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 3. - - @param ECX MSR_HASWELL_E_C8_PMON_EVNTSEL3 (0x00000E84) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_EVNTSEL3 is defined as MSR_C8_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_EVNTSEL3 0x00000E84 - - -/** - Package. Uncore C-box 8 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C8_PMON_BOX_FILTER0 (0x00000E85) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_BOX_FILTER0 is defined as MSR_C8_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_BOX_FILTER0 0x00000E85 - - -/** - Package. Uncore C-box 8 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C8_PMON_BOX_FILTER1 (0x00000E86) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_BOX_FILTER1 is defined as MSR_C8_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_BOX_FILTER1 0x00000E86 - - -/** - Package. Uncore C-box 8 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C8_PMON_BOX_STATUS (0x00000E87) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_BOX_STATUS is defined as MSR_C8_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_BOX_STATUS 0x00000E87 - - -/** - Package. Uncore C-box 8 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C8_PMON_CTR0 (0x00000E88) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_CTR0 0x00000E88 - - -/** - Package. Uncore C-box 8 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C8_PMON_CTR1 (0x00000E89) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_CTR1 0x00000E89 - - -/** - Package. Uncore C-box 8 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C8_PMON_CTR2 (0x00000E8A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_CTR2 0x00000E8A - - -/** - Package. Uncore C-box 8 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C8_PMON_CTR3 (0x00000E8B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C8_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C8_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C8_PMON_CTR3 0x00000E8B - - -/** - Package. Uncore C-box 9 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C9_PMON_BOX_CTL (0x00000E90) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_BOX_CTL is defined as MSR_C9_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_BOX_CTL 0x00000E90 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 0. - - @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL0 (0x00000E91) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_EVNTSEL0 is defined as MSR_C9_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_EVNTSEL0 0x00000E91 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 1. - - @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL1 (0x00000E92) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_EVNTSEL1 is defined as MSR_C9_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_EVNTSEL1 0x00000E92 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 2. - - @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL2 (0x00000E93) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_EVNTSEL2 is defined as MSR_C9_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_EVNTSEL2 0x00000E93 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 3. - - @param ECX MSR_HASWELL_E_C9_PMON_EVNTSEL3 (0x00000E94) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_EVNTSEL3 is defined as MSR_C9_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_EVNTSEL3 0x00000E94 - - -/** - Package. Uncore C-box 9 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C9_PMON_BOX_FILTER0 (0x00000E95) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_BOX_FILTER0 is defined as MSR_C9_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_BOX_FILTER0 0x00000E95 - - -/** - Package. Uncore C-box 9 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C9_PMON_BOX_FILTER1 (0x00000E96) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_BOX_FILTER1 is defined as MSR_C9_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_BOX_FILTER1 0x00000E96 - - -/** - Package. Uncore C-box 9 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C9_PMON_BOX_STATUS (0x00000E97) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_BOX_STATUS is defined as MSR_C9_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_BOX_STATUS 0x00000E97 - - -/** - Package. Uncore C-box 9 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C9_PMON_CTR0 (0x00000E98) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_CTR0 0x00000E98 - - -/** - Package. Uncore C-box 9 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C9_PMON_CTR1 (0x00000E99) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_CTR1 0x00000E99 - - -/** - Package. Uncore C-box 9 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C9_PMON_CTR2 (0x00000E9A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_CTR2 0x00000E9A - - -/** - Package. Uncore C-box 9 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C9_PMON_CTR3 (0x00000E9B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C9_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C9_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C9_PMON_CTR3 0x00000E9B - - -/** - Package. Uncore C-box 10 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C10_PMON_BOX_CTL (0x00000EA0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_BOX_CTL is defined as MSR_C10_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_BOX_CTL 0x00000EA0 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 0. - - @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL0 (0x00000EA1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_EVNTSEL0 is defined as MSR_C10_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_EVNTSEL0 0x00000EA1 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 1. - - @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL1 (0x00000EA2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_EVNTSEL1 is defined as MSR_C10_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_EVNTSEL1 0x00000EA2 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 2. - - @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL2 (0x00000EA3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_EVNTSEL2 is defined as MSR_C10_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_EVNTSEL2 0x00000EA3 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 3. - - @param ECX MSR_HASWELL_E_C10_PMON_EVNTSEL3 (0x00000EA4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_EVNTSEL3 is defined as MSR_C10_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_EVNTSEL3 0x00000EA4 - - -/** - Package. Uncore C-box 10 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C10_PMON_BOX_FILTER0 (0x00000EA5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_BOX_FILTER0 is defined as MSR_C10_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_BOX_FILTER0 0x00000EA5 - - -/** - Package. Uncore C-box 10 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C10_PMON_BOX_FILTER1 (0x00000EA6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_BOX_FILTER1 is defined as MSR_C10_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_BOX_FILTER1 0x00000EA6 - - -/** - Package. Uncore C-box 10 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C10_PMON_BOX_STATUS (0x00000EA7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_BOX_STATUS is defined as MSR_C10_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_BOX_STATUS 0x00000EA7 - - -/** - Package. Uncore C-box 10 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C10_PMON_CTR0 (0x00000EA8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_CTR0 is defined as MSR_C10_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_CTR0 0x00000EA8 - - -/** - Package. Uncore C-box 10 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C10_PMON_CTR1 (0x00000EA9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_CTR1 is defined as MSR_C10_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_CTR1 0x00000EA9 - - -/** - Package. Uncore C-box 10 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C10_PMON_CTR2 (0x00000EAA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_CTR2 is defined as MSR_C10_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_CTR2 0x00000EAA - - -/** - Package. Uncore C-box 10 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C10_PMON_CTR3 (0x00000EAB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C10_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C10_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C10_PMON_CTR3 is defined as MSR_C10_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C10_PMON_CTR3 0x00000EAB - - -/** - Package. Uncore C-box 11 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C11_PMON_BOX_CTL (0x00000EB0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_BOX_CTL is defined as MSR_C11_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_BOX_CTL 0x00000EB0 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 0. - - @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL0 (0x00000EB1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_EVNTSEL0 is defined as MSR_C11_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_EVNTSEL0 0x00000EB1 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 1. - - @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL1 (0x00000EB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_EVNTSEL1 is defined as MSR_C11_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_EVNTSEL1 0x00000EB2 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 2. - - @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL2 (0x00000EB3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_EVNTSEL2 is defined as MSR_C11_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_EVNTSEL2 0x00000EB3 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 3. - - @param ECX MSR_HASWELL_E_C11_PMON_EVNTSEL3 (0x00000EB4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_EVNTSEL3 is defined as MSR_C11_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_EVNTSEL3 0x00000EB4 - - -/** - Package. Uncore C-box 11 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C11_PMON_BOX_FILTER0 (0x00000EB5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_BOX_FILTER0 is defined as MSR_C11_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_BOX_FILTER0 0x00000EB5 - - -/** - Package. Uncore C-box 11 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C11_PMON_BOX_FILTER1 (0x00000EB6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_BOX_FILTER1 is defined as MSR_C11_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_BOX_FILTER1 0x00000EB6 - - -/** - Package. Uncore C-box 11 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C11_PMON_BOX_STATUS (0x00000EB7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_BOX_STATUS is defined as MSR_C11_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_BOX_STATUS 0x00000EB7 - - -/** - Package. Uncore C-box 11 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C11_PMON_CTR0 (0x00000EB8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_CTR0 is defined as MSR_C11_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_CTR0 0x00000EB8 - - -/** - Package. Uncore C-box 11 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C11_PMON_CTR1 (0x00000EB9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_CTR1 is defined as MSR_C11_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_CTR1 0x00000EB9 - - -/** - Package. Uncore C-box 11 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C11_PMON_CTR2 (0x00000EBA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_CTR2 is defined as MSR_C11_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_CTR2 0x00000EBA - - -/** - Package. Uncore C-box 11 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C11_PMON_CTR3 (0x00000EBB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C11_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C11_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C11_PMON_CTR3 is defined as MSR_C11_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C11_PMON_CTR3 0x00000EBB - - -/** - Package. Uncore C-box 12 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C12_PMON_BOX_CTL (0x00000EC0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_BOX_CTL is defined as MSR_C12_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_BOX_CTL 0x00000EC0 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 0. - - @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL0 (0x00000EC1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_EVNTSEL0 is defined as MSR_C12_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_EVNTSEL0 0x00000EC1 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 1. - - @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL1 (0x00000EC2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_EVNTSEL1 is defined as MSR_C12_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_EVNTSEL1 0x00000EC2 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 2. - - @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL2 (0x00000EC3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_EVNTSEL2 is defined as MSR_C12_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_EVNTSEL2 0x00000EC3 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 3. - - @param ECX MSR_HASWELL_E_C12_PMON_EVNTSEL3 (0x00000EC4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_EVNTSEL3 is defined as MSR_C12_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_EVNTSEL3 0x00000EC4 - - -/** - Package. Uncore C-box 12 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C12_PMON_BOX_FILTER0 (0x00000EC5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_BOX_FILTER0 is defined as MSR_C12_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_BOX_FILTER0 0x00000EC5 - - -/** - Package. Uncore C-box 12 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C12_PMON_BOX_FILTER1 (0x00000EC6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_BOX_FILTER1 is defined as MSR_C12_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_BOX_FILTER1 0x00000EC6 - - -/** - Package. Uncore C-box 12 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C12_PMON_BOX_STATUS (0x00000EC7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_BOX_STATUS is defined as MSR_C12_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_BOX_STATUS 0x00000EC7 - - -/** - Package. Uncore C-box 12 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C12_PMON_CTR0 (0x00000EC8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_CTR0 is defined as MSR_C12_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_CTR0 0x00000EC8 - - -/** - Package. Uncore C-box 12 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C12_PMON_CTR1 (0x00000EC9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_CTR1 is defined as MSR_C12_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_CTR1 0x00000EC9 - - -/** - Package. Uncore C-box 12 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C12_PMON_CTR2 (0x00000ECA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_CTR2 is defined as MSR_C12_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_CTR2 0x00000ECA - - -/** - Package. Uncore C-box 12 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C12_PMON_CTR3 (0x00000ECB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C12_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C12_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C12_PMON_CTR3 is defined as MSR_C12_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C12_PMON_CTR3 0x00000ECB - - -/** - Package. Uncore C-box 13 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C13_PMON_BOX_CTL (0x00000ED0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_BOX_CTL is defined as MSR_C13_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_BOX_CTL 0x00000ED0 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 0. - - @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL0 (0x00000ED1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_EVNTSEL0 is defined as MSR_C13_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_EVNTSEL0 0x00000ED1 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 1. - - @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL1 (0x00000ED2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_EVNTSEL1 is defined as MSR_C13_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_EVNTSEL1 0x00000ED2 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 2. - - @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL2 (0x00000ED3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_EVNTSEL2 is defined as MSR_C13_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_EVNTSEL2 0x00000ED3 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 3. - - @param ECX MSR_HASWELL_E_C13_PMON_EVNTSEL3 (0x00000ED4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_EVNTSEL3 is defined as MSR_C13_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_EVNTSEL3 0x00000ED4 - - -/** - Package. Uncore C-box 13 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C13_PMON_BOX_FILTER0 (0x00000ED5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_BOX_FILTER0 is defined as MSR_C13_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_BOX_FILTER0 0x00000ED5 - - -/** - Package. Uncore C-box 13 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C13_PMON_BOX_FILTER1 (0x00000ED6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_BOX_FILTER1 is defined as MSR_C13_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_BOX_FILTER1 0x00000ED6 - - -/** - Package. Uncore C-box 13 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C13_PMON_BOX_STATUS (0x00000ED7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_BOX_STATUS is defined as MSR_C13_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_BOX_STATUS 0x00000ED7 - - -/** - Package. Uncore C-box 13 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C13_PMON_CTR0 (0x00000ED8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_CTR0 is defined as MSR_C13_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_CTR0 0x00000ED8 - - -/** - Package. Uncore C-box 13 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C13_PMON_CTR1 (0x00000ED9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_CTR1 is defined as MSR_C13_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_CTR1 0x00000ED9 - - -/** - Package. Uncore C-box 13 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C13_PMON_CTR2 (0x00000EDA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_CTR2 is defined as MSR_C13_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_CTR2 0x00000EDA - - -/** - Package. Uncore C-box 13 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C13_PMON_CTR3 (0x00000EDB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C13_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C13_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C13_PMON_CTR3 is defined as MSR_C13_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C13_PMON_CTR3 0x00000EDB - - -/** - Package. Uncore C-box 14 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C14_PMON_BOX_CTL (0x00000EE0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_BOX_CTL is defined as MSR_C14_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_BOX_CTL 0x00000EE0 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 0. - - @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL0 (0x00000EE1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_EVNTSEL0 is defined as MSR_C14_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_EVNTSEL0 0x00000EE1 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 1. - - @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL1 (0x00000EE2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_EVNTSEL1 is defined as MSR_C14_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_EVNTSEL1 0x00000EE2 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 2. - - @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL2 (0x00000EE3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_EVNTSEL2 is defined as MSR_C14_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_EVNTSEL2 0x00000EE3 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 3. - - @param ECX MSR_HASWELL_E_C14_PMON_EVNTSEL3 (0x00000EE4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_EVNTSEL3 is defined as MSR_C14_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_EVNTSEL3 0x00000EE4 - - -/** - Package. Uncore C-box 14 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C14_PMON_BOX_FILTER (0x00000EE5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_BOX_FILTER is defined as MSR_C14_PMON_BOX_FILTER in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_BOX_FILTER 0x00000EE5 - - -/** - Package. Uncore C-box 14 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C14_PMON_BOX_FILTER1 (0x00000EE6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_BOX_FILTER1 is defined as MSR_C14_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_BOX_FILTER1 0x00000EE6 - - -/** - Package. Uncore C-box 14 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C14_PMON_BOX_STATUS (0x00000EE7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_BOX_STATUS is defined as MSR_C14_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_BOX_STATUS 0x00000EE7 - - -/** - Package. Uncore C-box 14 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C14_PMON_CTR0 (0x00000EE8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_CTR0 is defined as MSR_C14_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_CTR0 0x00000EE8 - - -/** - Package. Uncore C-box 14 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C14_PMON_CTR1 (0x00000EE9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_CTR1 is defined as MSR_C14_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_CTR1 0x00000EE9 - - -/** - Package. Uncore C-box 14 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C14_PMON_CTR2 (0x00000EEA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_CTR2 is defined as MSR_C14_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_CTR2 0x00000EEA - - -/** - Package. Uncore C-box 14 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C14_PMON_CTR3 (0x00000EEB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C14_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C14_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C14_PMON_CTR3 is defined as MSR_C14_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C14_PMON_CTR3 0x00000EEB - - -/** - Package. Uncore C-box 15 perfmon local box wide control. - - @param ECX MSR_HASWELL_E_C15_PMON_BOX_CTL (0x00000EF0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_BOX_CTL is defined as MSR_C15_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_BOX_CTL 0x00000EF0 - - -/** - Package. Uncore C-box 15 perfmon event select for C-box 15 counter 0. - - @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL0 (0x00000EF1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_EVNTSEL0 is defined as MSR_C15_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_EVNTSEL0 0x00000EF1 - - -/** - Package. Uncore C-box 15 perfmon event select for C-box 15 counter 1. - - @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL1 (0x00000EF2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_EVNTSEL1 is defined as MSR_C15_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_EVNTSEL1 0x00000EF2 - - -/** - Package. Uncore C-box 15 perfmon event select for C-box 15 counter 2. - - @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL2 (0x00000EF3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_EVNTSEL2 is defined as MSR_C15_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_EVNTSEL2 0x00000EF3 - - -/** - Package. Uncore C-box 15 perfmon event select for C-box 15 counter 3. - - @param ECX MSR_HASWELL_E_C15_PMON_EVNTSEL3 (0x00000EF4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_EVNTSEL3 is defined as MSR_C15_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_EVNTSEL3 0x00000EF4 - - -/** - Package. Uncore C-box 15 perfmon box wide filter0. - - @param ECX MSR_HASWELL_E_C15_PMON_BOX_FILTER0 (0x00000EF5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_BOX_FILTER0 is defined as MSR_C15_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_BOX_FILTER0 0x00000EF5 - - -/** - Package. Uncore C-box 15 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C15_PMON_BOX_FILTER1 (0x00000EF6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_BOX_FILTER1 is defined as MSR_C15_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_BOX_FILTER1 0x00000EF6 - - -/** - Package. Uncore C-box 15 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C15_PMON_BOX_STATUS (0x00000EF7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_BOX_STATUS is defined as MSR_C15_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_BOX_STATUS 0x00000EF7 - - -/** - Package. Uncore C-box 15 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C15_PMON_CTR0 (0x00000EF8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_CTR0 is defined as MSR_C15_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_CTR0 0x00000EF8 - - -/** - Package. Uncore C-box 15 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C15_PMON_CTR1 (0x00000EF9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_CTR1 is defined as MSR_C15_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_CTR1 0x00000EF9 - - -/** - Package. Uncore C-box 15 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C15_PMON_CTR2 (0x00000EFA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_CTR2 is defined as MSR_C15_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_CTR2 0x00000EFA - - -/** - Package. Uncore C-box 15 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C15_PMON_CTR3 (0x00000EFB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C15_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C15_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C15_PMON_CTR3 is defined as MSR_C15_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C15_PMON_CTR3 0x00000EFB - - -/** - Package. Uncore C-box 16 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C16_PMON_BOX_CTL (0x00000F00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_BOX_CTL is defined as MSR_C16_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_BOX_CTL 0x00000F00 - - -/** - Package. Uncore C-box 16 perfmon event select for C-box 16 counter 0. - - @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL0 (0x00000F01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_EVNTSEL0 is defined as MSR_C16_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_EVNTSEL0 0x00000F01 - - -/** - Package. Uncore C-box 16 perfmon event select for C-box 16 counter 1. - - @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL1 (0x00000F02) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_EVNTSEL1 is defined as MSR_C16_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_EVNTSEL1 0x00000F02 - - -/** - Package. Uncore C-box 16 perfmon event select for C-box 16 counter 2. - - @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL2 (0x00000F03) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_EVNTSEL2 is defined as MSR_C16_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_EVNTSEL2 0x00000F03 - - -/** - Package. Uncore C-box 16 perfmon event select for C-box 16 counter 3. - - @param ECX MSR_HASWELL_E_C16_PMON_EVNTSEL3 (0x00000F04) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_EVNTSEL3 is defined as MSR_C16_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_EVNTSEL3 0x00000F04 - - -/** - Package. Uncore C-box 16 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C16_PMON_BOX_FILTER0 (0x00000F05) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_BOX_FILTER0 is defined as MSR_C16_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_BOX_FILTER0 0x00000F05 - - -/** - Package. Uncore C-box 16 perfmon box wide filter 1. - - @param ECX MSR_HASWELL_E_C16_PMON_BOX_FILTER1 (0x00000F06) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_BOX_FILTER1 is defined as MSR_C16_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_BOX_FILTER1 0x00000F06 - - -/** - Package. Uncore C-box 16 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C16_PMON_BOX_STATUS (0x00000F07) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_BOX_STATUS is defined as MSR_C16_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_BOX_STATUS 0x00000F07 - - -/** - Package. Uncore C-box 16 perfmon counter 0. - - @param ECX MSR_HASWELL_E_C16_PMON_CTR0 (0x00000F08) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_CTR0 is defined as MSR_C16_PMON_CTR0 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_CTR0 0x00000F08 - - -/** - Package. Uncore C-box 16 perfmon counter 1. - - @param ECX MSR_HASWELL_E_C16_PMON_CTR1 (0x00000F09) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR1); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR1, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_CTR1 is defined as MSR_C16_PMON_CTR1 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_CTR1 0x00000F09 - - -/** - Package. Uncore C-box 16 perfmon counter 2. - - @param ECX MSR_HASWELL_E_C16_PMON_CTR2 (0x00000F0A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR2); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR2, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_CTR2 is defined as MSR_C16_PMON_CTR2 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_CTR2 0x00000F0A - - -/** - Package. Uncore C-box 16 perfmon counter 3. - - @param ECX MSR_HASWELL_E_C16_PMON_CTR3 (0x00000E0B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C16_PMON_CTR3); - AsmWriteMsr64 (MSR_HASWELL_E_C16_PMON_CTR3, Msr); - @endcode - @note MSR_HASWELL_E_C16_PMON_CTR3 is defined as MSR_C16_PMON_CTR3 in SDM. -**/ -#define MSR_HASWELL_E_C16_PMON_CTR3 0x00000E0B - - -/** - Package. Uncore C-box 17 perfmon for box-wide control. - - @param ECX MSR_HASWELL_E_C17_PMON_BOX_CTL (0x00000F10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_CTL, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_BOX_CTL is defined as MSR_C17_PMON_BOX_CTL in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_BOX_CTL 0x00000F10 - - -/** - Package. Uncore C-box 17 perfmon event select for C-box 17 counter 0. - - @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL0 (0x00000F11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_EVNTSEL0 is defined as MSR_C17_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_EVNTSEL0 0x00000F11 - - -/** - Package. Uncore C-box 17 perfmon event select for C-box 17 counter 1. - - @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL1 (0x00000F12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_EVNTSEL1 is defined as MSR_C17_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_EVNTSEL1 0x00000F12 - - -/** - Package. Uncore C-box 17 perfmon event select for C-box 17 counter 2. - - @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL2 (0x00000F13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_EVNTSEL2 is defined as MSR_C17_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_EVNTSEL2 0x00000F13 - - -/** - Package. Uncore C-box 17 perfmon event select for C-box 17 counter 3. - - @param ECX MSR_HASWELL_E_C17_PMON_EVNTSEL3 (0x00000F14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_EVNTSEL3 is defined as MSR_C17_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_EVNTSEL3 0x00000F14 - - -/** - Package. Uncore C-box 17 perfmon box wide filter 0. - - @param ECX MSR_HASWELL_E_C17_PMON_BOX_FILTER0 (0x00000F15) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER0); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER0, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_BOX_FILTER0 is defined as MSR_C17_PMON_BOX_FILTER0 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_BOX_FILTER0 0x00000F15 - - -/** - Package. Uncore C-box 17 perfmon box wide filter1. - - @param ECX MSR_HASWELL_E_C17_PMON_BOX_FILTER1 (0x00000F16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_BOX_FILTER1 is defined as MSR_C17_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_BOX_FILTER1 0x00000F16 - -/** - Package. Uncore C-box 17 perfmon box wide status. - - @param ECX MSR_HASWELL_E_C17_PMON_BOX_STATUS (0x00000F17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_BOX_STATUS is defined as MSR_C17_PMON_BOX_STATUS in SDM. -**/ -#define MSR_HASWELL_E_C17_PMON_BOX_STATUS 0x00000F17 - - -/** - Package. Uncore C-box 17 perfmon counter n. - - @param ECX MSR_HASWELL_E_C17_PMON_CTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_E_C17_PMON_CTR0); - AsmWriteMsr64 (MSR_HASWELL_E_C17_PMON_CTR0, Msr); - @endcode - @note MSR_HASWELL_E_C17_PMON_CTR0 is defined as MSR_C17_PMON_CTR0 in SDM. - MSR_HASWELL_E_C17_PMON_CTR1 is defined as MSR_C17_PMON_CTR1 in SDM. - MSR_HASWELL_E_C17_PMON_CTR2 is defined as MSR_C17_PMON_CTR2 in SDM. - MSR_HASWELL_E_C17_PMON_CTR3 is defined as MSR_C17_PMON_CTR3 in SDM. - @{ -**/ -#define MSR_HASWELL_E_C17_PMON_CTR0 0x00000F18 -#define MSR_HASWELL_E_C17_PMON_CTR1 0x00000F19 -#define MSR_HASWELL_E_C17_PMON_CTR2 0x00000F1A -#define MSR_HASWELL_E_C17_PMON_CTR3 0x00000F1B -/// @} - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h b/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h deleted file mode 100644 index 3cd15846b4..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/HaswellMsr.h +++ /dev/null @@ -1,2637 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Haswell microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.11. - -**/ - -#ifndef __HASWELL_MSR_H__ -#define __HASWELL_MSR_H__ - -#include - -/** - Is Intel processors based on the Haswell microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_HASWELL_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x3C || \ - DisplayModel == 0x45 || \ - DisplayModel == 0x46 \ - ) \ - ) - -/** - Package. - - @param ECX MSR_HASWELL_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_HASWELL_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PLATFORM_INFO); - AsmWriteMsr64 (MSR_HASWELL_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_HASWELL_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_HASWELL_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_HASWELL_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - UINT32 Reserved3:2; - /// - /// [Bit 32] Package. Low Power Mode Support (LPM) (R/O) When set to 1, - /// indicates that LPM is supported, and when set to 0, indicates LPM is - /// not supported. - /// - UINT32 LowPowerModeSupport:1; - /// - /// [Bits 34:33] Package. Number of ConfigTDP Levels (R/O) 00: Only Base - /// TDP level available. 01: One additional TDP level available. 02: Two - /// additional TDP level available. 11: Reserved. - /// - UINT32 ConfigTDPLevels:2; - UINT32 Reserved4:5; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - /// - /// [Bits 55:48] Package. Minimum Operating Ratio (R/O) Contains the - /// minimum supported operating ratio in units of 100 MHz. - /// - UINT32 MinimumOperatingRatio:8; - UINT32 Reserved5:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PLATFORM_INFO_REGISTER; - - -/** - THREAD. Performance Event Select for Counter n (R/W) Supports all fields - described inTable 35-2 and the fields below. - - @param ECX MSR_HASWELL_IA32_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_IA32_PERFEVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_IA32_PERFEVTSEL_REGISTER. - - Example usage - @code - MSR_HASWELL_IA32_PERFEVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_IA32_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_IA32_PERFEVTSEL0, Msr.Uint64); - @endcode - @note MSR_HASWELL_IA32_PERFEVTSEL0 is defined as IA32_PERFEVTSEL0 in SDM. - MSR_HASWELL_IA32_PERFEVTSEL1 is defined as IA32_PERFEVTSEL1 in SDM. - MSR_HASWELL_IA32_PERFEVTSEL3 is defined as IA32_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_HASWELL_IA32_PERFEVTSEL0 0x00000186 -#define MSR_HASWELL_IA32_PERFEVTSEL1 0x00000187 -#define MSR_HASWELL_IA32_PERFEVTSEL3 0x00000189 -/// @} - -/** - MSR information returned for MSR indexes #MSR_HASWELL_IA32_PERFEVTSEL0, - #MSR_HASWELL_IA32_PERFEVTSEL1, and #MSR_HASWELL_IA32_PERFEVTSEL3. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Event Select: Selects a performance event logic unit. - /// - UINT32 EventSelect:8; - /// - /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to - /// detect on the selected event logic. - /// - UINT32 UMASK:8; - /// - /// [Bit 16] USR: Counts while in privilege level is not ring 0. - /// - UINT32 USR:1; - /// - /// [Bit 17] OS: Counts while in privilege level is ring 0. - /// - UINT32 OS:1; - /// - /// [Bit 18] Edge: Enables edge detection if set. - /// - UINT32 E:1; - /// - /// [Bit 19] PC: enables pin control. - /// - UINT32 PC:1; - /// - /// [Bit 20] INT: enables interrupt on counter overflow. - /// - UINT32 INT:1; - /// - /// [Bit 21] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. - /// - UINT32 ANY:1; - /// - /// [Bit 22] EN: enables the corresponding performance counter to commence - /// counting when this bit is set. - /// - UINT32 EN:1; - /// - /// [Bit 23] INV: invert the CMASK. - /// - UINT32 INV:1; - /// - /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding - /// performance counter increments each cycle if the event count is - /// greater than or equal to the CMASK. - /// - UINT32 CMASK:8; - UINT32 Reserved:32; - /// - /// [Bit 32] IN_TX: see Section 18.11.5.1 When IN_TX (bit 32) is set, - /// AnyThread (bit 21) should be cleared to prevent incorrect results. - /// - UINT32 IN_TX:1; - UINT32 Reserved2:31; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_IA32_PERFEVTSEL_REGISTER; - - -/** - THREAD. Performance Event Select for Counter 2 (R/W) Supports all fields - described inTable 35-2 and the fields below. - - @param ECX MSR_HASWELL_IA32_PERFEVTSEL2 (0x00000188) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER. - - Example usage - @code - MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_IA32_PERFEVTSEL2); - AsmWriteMsr64 (MSR_HASWELL_IA32_PERFEVTSEL2, Msr.Uint64); - @endcode - @note MSR_HASWELL_IA32_PERFEVTSEL2 is defined as IA32_PERFEVTSEL2 in SDM. -**/ -#define MSR_HASWELL_IA32_PERFEVTSEL2 0x00000188 - -/** - MSR information returned for MSR index #MSR_HASWELL_IA32_PERFEVTSEL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Event Select: Selects a performance event logic unit. - /// - UINT32 EventSelect:8; - /// - /// [Bits 15:8] UMask: Qualifies the microarchitectural condition to - /// detect on the selected event logic. - /// - UINT32 UMASK:8; - /// - /// [Bit 16] USR: Counts while in privilege level is not ring 0. - /// - UINT32 USR:1; - /// - /// [Bit 17] OS: Counts while in privilege level is ring 0. - /// - UINT32 OS:1; - /// - /// [Bit 18] Edge: Enables edge detection if set. - /// - UINT32 E:1; - /// - /// [Bit 19] PC: enables pin control. - /// - UINT32 PC:1; - /// - /// [Bit 20] INT: enables interrupt on counter overflow. - /// - UINT32 INT:1; - /// - /// [Bit 21] AnyThread: When set to 1, it enables counting the associated - /// event conditions occurring across all logical processors sharing a - /// processor core. When set to 0, the counter only increments the - /// associated event conditions occurring in the logical processor which - /// programmed the MSR. - /// - UINT32 ANY:1; - /// - /// [Bit 22] EN: enables the corresponding performance counter to commence - /// counting when this bit is set. - /// - UINT32 EN:1; - /// - /// [Bit 23] INV: invert the CMASK. - /// - UINT32 INV:1; - /// - /// [Bits 31:24] CMASK: When CMASK is not zero, the corresponding - /// performance counter increments each cycle if the event count is - /// greater than or equal to the CMASK. - /// - UINT32 CMASK:8; - UINT32 Reserved:32; - /// - /// [Bit 32] IN_TX: see Section 18.11.5.1 When IN_TX (bit 32) is set, - /// AnyThread (bit 21) should be cleared to prevent incorrect results. - /// - UINT32 IN_TX:1; - /// - /// [Bit 33] IN_TXCP: see Section 18.11.5.1 When IN_TXCP=1 & IN_TX=1 and - /// in sampling, spurious PMI may occur and transactions may continuously - /// abort near overflow conditions. Software should favor using IN_TXCP - /// for counting over sampling. If sampling, software should use large - /// "sample-after" value after clearing the counter configured to use - /// IN_TXCP and also always reset the counter even when no overflow - /// condition was reported. - /// - UINT32 IN_TXCP:1; - UINT32 Reserved2:30; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_IA32_PERFEVTSEL2_REGISTER; - - -/** - Thread. Last Branch Record Filtering Select Register (R/W). - - @param ECX MSR_HASWELL_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_LBR_SELECT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_LBR_SELECT_REGISTER. - - Example usage - @code - MSR_HASWELL_LBR_SELECT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_LBR_SELECT); - AsmWriteMsr64 (MSR_HASWELL_LBR_SELECT, Msr.Uint64); - @endcode - @note MSR_HASWELL_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_HASWELL_LBR_SELECT 0x000001C8 - -/** - MSR information returned for MSR index #MSR_HASWELL_LBR_SELECT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CPL_EQ_0. - /// - UINT32 CPL_EQ_0:1; - /// - /// [Bit 1] CPL_NEQ_0. - /// - UINT32 CPL_NEQ_0:1; - /// - /// [Bit 2] JCC. - /// - UINT32 JCC:1; - /// - /// [Bit 3] NEAR_REL_CALL. - /// - UINT32 NEAR_REL_CALL:1; - /// - /// [Bit 4] NEAR_IND_CALL. - /// - UINT32 NEAR_IND_CALL:1; - /// - /// [Bit 5] NEAR_RET. - /// - UINT32 NEAR_RET:1; - /// - /// [Bit 6] NEAR_IND_JMP. - /// - UINT32 NEAR_IND_JMP:1; - /// - /// [Bit 7] NEAR_REL_JMP. - /// - UINT32 NEAR_REL_JMP:1; - /// - /// [Bit 8] FAR_BRANCH. - /// - UINT32 FAR_BRANCH:1; - /// - /// [Bit 9] EN_CALL_STACK. - /// - UINT32 EN_CALL_STACK:1; - UINT32 Reserved1:22; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_LBR_SELECT_REGISTER; - - -/** - Package. Package C6/C7 Interrupt Response Limit 1 (R/W) This MSR defines - the interrupt response time limit used by the processor to manage transition - to package C6 or C7 state. The latency programmed in this register is for - the shorter-latency sub C-states used by an MWAIT hint to C6 or C7 state. - Note: C-state values are processor specific C-state code names, unrelated to - MWAIT extension C-state parameters or ACPI C-States. - - @param ECX MSR_HASWELL_PKGC_IRTL1 (0x0000060B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKGC_IRTL1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKGC_IRTL1_REGISTER. - - Example usage - @code - MSR_HASWELL_PKGC_IRTL1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKGC_IRTL1); - AsmWriteMsr64 (MSR_HASWELL_PKGC_IRTL1, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKGC_IRTL1 is defined as MSR_PKGC_IRTL1 in SDM. -**/ -#define MSR_HASWELL_PKGC_IRTL1 0x0000060B - -/** - MSR information returned for MSR index #MSR_HASWELL_PKGC_IRTL1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C6 or C7 state. - /// - UINT32 InterruptResponseTimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. See Table 35-18 for - /// supported time unit encodings. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKGC_IRTL1_REGISTER; - - -/** - Package. Package C6/C7 Interrupt Response Limit 2 (R/W) This MSR defines - the interrupt response time limit used by the processor to manage transition - to package C6 or C7 state. The latency programmed in this register is for - the longer-latency sub Cstates used by an MWAIT hint to C6 or C7 state. - Note: C-state values are processor specific C-state code names, unrelated to - MWAIT extension C-state parameters or ACPI C-States. - - @param ECX MSR_HASWELL_PKGC_IRTL2 (0x0000060C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKGC_IRTL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKGC_IRTL2_REGISTER. - - Example usage - @code - MSR_HASWELL_PKGC_IRTL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKGC_IRTL2); - AsmWriteMsr64 (MSR_HASWELL_PKGC_IRTL2, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKGC_IRTL2 is defined as MSR_PKGC_IRTL2 in SDM. -**/ -#define MSR_HASWELL_PKGC_IRTL2 0x0000060C - -/** - MSR information returned for MSR index #MSR_HASWELL_PKGC_IRTL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C6 or C7 state. - /// - UINT32 InterruptResponseTimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. See Table 35-18 for - /// supported time unit encodings. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKGC_IRTL2_REGISTER; - - -/** - Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_HASWELL_PKG_PERF_STATUS (0x00000613) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_PKG_PERF_STATUS); - @endcode - @note MSR_HASWELL_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. -**/ -#define MSR_HASWELL_PKG_PERF_STATUS 0x00000613 - - -/** - Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_HASWELL_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_DRAM_ENERGY_STATUS); - @endcode - @note MSR_HASWELL_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_HASWELL_DRAM_ENERGY_STATUS 0x00000619 - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_HASWELL_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_DRAM_PERF_STATUS); - @endcode - @note MSR_HASWELL_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_HASWELL_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. Base TDP Ratio (R/O). - - @param ECX MSR_HASWELL_CONFIG_TDP_NOMINAL (0x00000648) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER. - - Example usage - @code - MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_NOMINAL); - @endcode - @note MSR_HASWELL_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. -**/ -#define MSR_HASWELL_CONFIG_TDP_NOMINAL 0x00000648 - -/** - MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_NOMINAL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Config_TDP_Base Base TDP level ratio to be used for this - /// specific processor (in units of 100 MHz). - /// - UINT32 Config_TDP_Base:8; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_CONFIG_TDP_NOMINAL_REGISTER; - - -/** - Package. ConfigTDP Level 1 ratio and power level (R/O). - - @param ECX MSR_HASWELL_CONFIG_TDP_LEVEL1 (0x00000649) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER. - - Example usage - @code - MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_LEVEL1); - @endcode - @note MSR_HASWELL_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. -**/ -#define MSR_HASWELL_CONFIG_TDP_LEVEL1 0x00000649 - -/** - MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_LEVEL1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] PKG_TDP_LVL1. Power setting for ConfigTDP Level 1. - /// - UINT32 PKG_TDP_LVL1:15; - UINT32 Reserved1:1; - /// - /// [Bits 23:16] Config_TDP_LVL1_Ratio. ConfigTDP level 1 ratio to be used - /// for this specific processor. - /// - UINT32 Config_TDP_LVL1_Ratio:8; - UINT32 Reserved2:8; - /// - /// [Bits 46:32] PKG_MAX_PWR_LVL1. Max Power setting allowed for ConfigTDP - /// Level 1. - /// - UINT32 PKG_MAX_PWR_LVL1:15; - /// - /// [Bits 62:47] PKG_MIN_PWR_LVL1. MIN Power setting allowed for ConfigTDP - /// Level 1. - /// - UINT32 PKG_MIN_PWR_LVL1:16; - UINT32 Reserved3:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_CONFIG_TDP_LEVEL1_REGISTER; - - -/** - Package. ConfigTDP Level 2 ratio and power level (R/O). - - @param ECX MSR_HASWELL_CONFIG_TDP_LEVEL2 (0x0000064A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER. - - Example usage - @code - MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_LEVEL2); - @endcode - @note MSR_HASWELL_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. -**/ -#define MSR_HASWELL_CONFIG_TDP_LEVEL2 0x0000064A - -/** - MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_LEVEL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] PKG_TDP_LVL2. Power setting for ConfigTDP Level 2. - /// - UINT32 PKG_TDP_LVL2:15; - UINT32 Reserved1:1; - /// - /// [Bits 23:16] Config_TDP_LVL2_Ratio. ConfigTDP level 2 ratio to be used - /// for this specific processor. - /// - UINT32 Config_TDP_LVL2_Ratio:8; - UINT32 Reserved2:8; - /// - /// [Bits 46:32] PKG_MAX_PWR_LVL2. Max Power setting allowed for ConfigTDP - /// Level 2. - /// - UINT32 PKG_MAX_PWR_LVL2:15; - /// - /// [Bits 62:47] PKG_MIN_PWR_LVL2. MIN Power setting allowed for ConfigTDP - /// Level 2. - /// - UINT32 PKG_MIN_PWR_LVL2:16; - UINT32 Reserved3:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_CONFIG_TDP_LEVEL2_REGISTER; - - -/** - Package. ConfigTDP Control (R/W). - - @param ECX MSR_HASWELL_CONFIG_TDP_CONTROL (0x0000064B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER. - - Example usage - @code - MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CONFIG_TDP_CONTROL); - AsmWriteMsr64 (MSR_HASWELL_CONFIG_TDP_CONTROL, Msr.Uint64); - @endcode - @note MSR_HASWELL_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. -**/ -#define MSR_HASWELL_CONFIG_TDP_CONTROL 0x0000064B - -/** - MSR information returned for MSR index #MSR_HASWELL_CONFIG_TDP_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] TDP_LEVEL (RW/L) System BIOS can program this field. - /// - UINT32 TDP_LEVEL:2; - UINT32 Reserved1:29; - /// - /// [Bit 31] Config_TDP_Lock (RW/L) When this bit is set, the content of - /// this register is locked until a reset. - /// - UINT32 Config_TDP_Lock:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_CONFIG_TDP_CONTROL_REGISTER; - - -/** - Package. ConfigTDP Control (R/W). - - @param ECX MSR_HASWELL_TURBO_ACTIVATION_RATIO (0x0000064C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER. - - Example usage - @code - MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_TURBO_ACTIVATION_RATIO); - AsmWriteMsr64 (MSR_HASWELL_TURBO_ACTIVATION_RATIO, Msr.Uint64); - @endcode - @note MSR_HASWELL_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. -**/ -#define MSR_HASWELL_TURBO_ACTIVATION_RATIO 0x0000064C - -/** - MSR information returned for MSR index #MSR_HASWELL_TURBO_ACTIVATION_RATIO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this - /// field. - /// - UINT32 MAX_NON_TURBO_RATIO:8; - UINT32 Reserved1:23; - /// - /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the - /// content of this register is locked until a reset. - /// - UINT32 TURBO_ACTIVATION_RATIO_Lock:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_TURBO_ACTIVATION_RATIO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are processor - specific C-state code names, unrelated to MWAIT extension C-state parameters - or ACPI Cstates. `See http://biosbits.org. `__. - - @param ECX MSR_HASWELL_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_HASWELL_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_HASWELL_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_HASWELL_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power) for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 0000b: - /// C0/C1 (no package C-state support) 0001b: C2 0010b: C3 0011b: C6 - /// 0100b: C7 0101b: C7s Package C states C7 are not available to - /// processor with signature 06_3CH. - /// - UINT32 Limit:4; - UINT32 Reserved1:6; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W). - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO). - /// - UINT32 CFGLock:1; - UINT32 Reserved3:9; - /// - /// [Bit 25] C3 State Auto Demotion Enable (R/W). - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 State Auto Demotion Enable (R/W). - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 Undemotion (R/W). - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 Undemotion (R/W). - /// - UINT32 C1Undemotion:1; - UINT32 Reserved4:3; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_HASWELL_SMM_MCA_CAP (0x0000017D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_SMM_MCA_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_SMM_MCA_CAP_REGISTER. - - Example usage - @code - MSR_HASWELL_SMM_MCA_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_SMM_MCA_CAP); - AsmWriteMsr64 (MSR_HASWELL_SMM_MCA_CAP, Msr.Uint64); - @endcode - @note MSR_HASWELL_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. -**/ -#define MSR_HASWELL_SMM_MCA_CAP 0x0000017D - -/** - MSR information returned for MSR index #MSR_HASWELL_SMM_MCA_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:26; - /// - /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the - /// SMM code access restriction is supported and the - /// MSR_SMM_FEATURE_CONTROL is supported. - /// - UINT32 SMM_Code_Access_Chk:1; - /// - /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the - /// SMM long flow indicator is supported and the MSR_SMM_DELAYED is - /// supported. - /// - UINT32 Long_Flow_Indication:1; - UINT32 Reserved3:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_SMM_MCA_CAP_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_HASWELL_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_TURBO_RATIO_LIMIT); - @endcode - @note MSR_HASWELL_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_HASWELL_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_HASWELL_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. Uncore PMU global control. - - @param ECX MSR_HASWELL_UNC_PERF_GLOBAL_CTRL (0x00000391) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER. - - Example usage - @code - MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); - @endcode - @note MSR_HASWELL_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_HASWELL_UNC_PERF_GLOBAL_CTRL 0x00000391 - -/** - MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_GLOBAL_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core 0 select. - /// - UINT32 PMI_Sel_Core0:1; - /// - /// [Bit 1] Core 1 select. - /// - UINT32 PMI_Sel_Core1:1; - /// - /// [Bit 2] Core 2 select. - /// - UINT32 PMI_Sel_Core2:1; - /// - /// [Bit 3] Core 3 select. - /// - UINT32 PMI_Sel_Core3:1; - UINT32 Reserved1:15; - UINT32 Reserved2:10; - /// - /// [Bit 29] Enable all uncore counters. - /// - UINT32 EN:1; - /// - /// [Bit 30] Enable wake on PMI. - /// - UINT32 WakePMI:1; - /// - /// [Bit 31] Enable Freezing counter when overflow. - /// - UINT32 FREEZE:1; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_UNC_PERF_GLOBAL_CTRL_REGISTER; - - -/** - Package. Uncore PMU main status. - - @param ECX MSR_HASWELL_UNC_PERF_GLOBAL_STATUS (0x00000392) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_HASWELL_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_HASWELL_UNC_PERF_GLOBAL_STATUS 0x00000392 - -/** - MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fixed counter overflowed. - /// - UINT32 Fixed:1; - /// - /// [Bit 1] An ARB counter overflowed. - /// - UINT32 ARB:1; - UINT32 Reserved1:1; - /// - /// [Bit 3] A CBox counter overflowed (on any slice). - /// - UINT32 CBox:1; - UINT32 Reserved2:28; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_UNC_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Package. Uncore fixed counter control (R/W). - - @param ECX MSR_HASWELL_UNC_PERF_FIXED_CTRL (0x00000394) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER. - - Example usage - @code - MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTRL); - AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTRL, Msr.Uint64); - @endcode - @note MSR_HASWELL_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. -**/ -#define MSR_HASWELL_UNC_PERF_FIXED_CTRL 0x00000394 - -/** - MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_FIXED_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:20; - /// - /// [Bit 20] Enable overflow propagation. - /// - UINT32 EnableOverflow:1; - UINT32 Reserved2:1; - /// - /// [Bit 22] Enable counting. - /// - UINT32 EnableCounting:1; - UINT32 Reserved3:9; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_UNC_PERF_FIXED_CTRL_REGISTER; - - -/** - Package. Uncore fixed counter. - - @param ECX MSR_HASWELL_UNC_PERF_FIXED_CTR (0x00000395) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER. - - Example usage - @code - MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTR); - AsmWriteMsr64 (MSR_HASWELL_UNC_PERF_FIXED_CTR, Msr.Uint64); - @endcode - @note MSR_HASWELL_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. -**/ -#define MSR_HASWELL_UNC_PERF_FIXED_CTR 0x00000395 - -/** - MSR information returned for MSR index #MSR_HASWELL_UNC_PERF_FIXED_CTR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Current count. - /// - UINT32 CurrentCount:32; - /// - /// [Bits 47:32] Current count. - /// - UINT32 CurrentCountHi:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_UNC_PERF_FIXED_CTR_REGISTER; - - -/** - Package. Uncore C-Box configuration information (R/O). - - @param ECX MSR_HASWELL_UNC_CBO_CONFIG (0x00000396) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_CBO_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_UNC_CBO_CONFIG_REGISTER. - - Example usage - @code - MSR_HASWELL_UNC_CBO_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_CONFIG); - @endcode - @note MSR_HASWELL_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_CONFIG 0x00000396 - -/** - MSR information returned for MSR index #MSR_HASWELL_UNC_CBO_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Encoded number of C-Box, derive value by "-1". - /// - UINT32 CBox:4; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_UNC_CBO_CONFIG_REGISTER; - - -/** - Package. Uncore Arb unit, performance counter 0. - - @param ECX MSR_HASWELL_UNC_ARB_PERFCTR0 (0x000003B0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR0); - AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR0, Msr); - @endcode - @note MSR_HASWELL_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. -**/ -#define MSR_HASWELL_UNC_ARB_PERFCTR0 0x000003B0 - - -/** - Package. Uncore Arb unit, performance counter 1. - - @param ECX MSR_HASWELL_UNC_ARB_PERFCTR1 (0x000003B1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR1); - AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFCTR1, Msr); - @endcode - @note MSR_HASWELL_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. -**/ -#define MSR_HASWELL_UNC_ARB_PERFCTR1 0x000003B1 - - -/** - Package. Uncore Arb unit, counter 0 event select MSR. - - @param ECX MSR_HASWELL_UNC_ARB_PERFEVTSEL0 (0x000003B2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL0, Msr); - @endcode - @note MSR_HASWELL_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. -**/ -#define MSR_HASWELL_UNC_ARB_PERFEVTSEL0 0x000003B2 - - -/** - Package. Uncore Arb unit, counter 1 event select MSR. - - @param ECX MSR_HASWELL_UNC_ARB_PERFEVTSEL1 (0x000003B3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL1); - AsmWriteMsr64 (MSR_HASWELL_UNC_ARB_PERFEVTSEL1, Msr); - @endcode - @note MSR_HASWELL_UNC_ARB_PERFEVTSEL1 is defined as MSR_UNC_ARB_PERFEVTSEL1 in SDM. -**/ -#define MSR_HASWELL_UNC_ARB_PERFEVTSEL1 0x000003B3 - - -/** - Package. Enhanced SMM Feature Control (SMM-RW) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_HASWELL_SMM_FEATURE_CONTROL (0x000004E0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_SMM_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_HASWELL_SMM_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_HASWELL_SMM_FEATURE_CONTROL is defined as MSR_SMM_FEATURE_CONTROL in SDM. -**/ -#define MSR_HASWELL_SMM_FEATURE_CONTROL 0x000004E0 - -/** - MSR information returned for MSR index #MSR_HASWELL_SMM_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock (SMM-RWO) When set to '1' locks this register from - /// further changes. - /// - UINT32 Lock:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] SMM_Code_Chk_En (SMM-RW) This control bit is available only if - /// MSR_SMM_MCA_CAP[58] == 1. When set to '0' (default) none of the - /// logical processors are prevented from executing SMM code outside the - /// ranges defined by the SMRR. When set to '1' any logical processor in - /// the package that attempts to execute SMM code not within the ranges - /// defined by the SMRR will assert an unrecoverable MCE. - /// - UINT32 SMM_Code_Chk_En:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_SMM_FEATURE_CONTROL_REGISTER; - - -/** - Package. SMM Delayed (SMM-RO) Reports the interruptible state of all logical - processors in the package. Available only while in SMM and - MSR_SMM_MCA_CAP[LONG_FLOW_INDICATION] == 1. - - [Bits 31:0] LOG_PROC_STATE (SMM-RO) Each bit represents a logical - processor of its state in a long flow of internal operation which - delays servicing an interrupt. The corresponding bit will be set at - the start of long events such as: Microcode Update Load, C6, WBINVD, - Ratio Change, Throttle. The bit is automatically cleared at the end of - each long event. The reset value of this field is 0. Only bit - positions below N = CPUID.(EAX=0BH, ECX=PKG_LVL):EBX[15:0] can be - updated. - - [Bits 63:32] LOG_PROC_STATE (SMM-RO) Each bit represents a logical - processor of its state in a long flow of internal operation which - delays servicing an interrupt. The corresponding bit will be set at - the start of long events such as: Microcode Update Load, C6, WBINVD, - Ratio Change, Throttle. The bit is automatically cleared at the end of - each long event. The reset value of this field is 0. Only bit - positions below N = CPUID.(EAX=0BH, ECX=PKG_LVL):EBX[15:0] can be - updated. - - @param ECX MSR_HASWELL_SMM_DELAYED (0x000004E2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_SMM_DELAYED); - @endcode - @note MSR_HASWELL_SMM_DELAYED is defined as MSR_SMM_DELAYED in SDM. -**/ -#define MSR_HASWELL_SMM_DELAYED 0x000004E2 - - -/** - Package. SMM Blocked (SMM-RO) Reports the blocked state of all logical - processors in the package. Available only while in SMM. - - [Bits 31:0] LOG_PROC_STATE (SMM-RO) Each bit represents a logical - processor of its blocked state to service an SMI. The corresponding - bit will be set if the logical processor is in one of the following - states: Wait For SIPI or SENTER Sleep. The reset value of this field - is 0FFFH. Only bit positions below N = CPUID.(EAX=0BH, - ECX=PKG_LVL):EBX[15:0] can be updated. - - - [Bits 63:32] LOG_PROC_STATE (SMM-RO) Each bit represents a logical - processor of its blocked state to service an SMI. The corresponding - bit will be set if the logical processor is in one of the following - states: Wait For SIPI or SENTER Sleep. The reset value of this field - is 0FFFH. Only bit positions below N = CPUID.(EAX=0BH, - ECX=PKG_LVL):EBX[15:0] can be updated. - - @param ECX MSR_HASWELL_SMM_BLOCKED (0x000004E3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_SMM_BLOCKED); - @endcode - @note MSR_HASWELL_SMM_BLOCKED is defined as MSR_SMM_BLOCKED in SDM. -**/ -#define MSR_HASWELL_SMM_BLOCKED 0x000004E3 - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O). - - @param ECX MSR_HASWELL_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_HASWELL_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_RAPL_POWER_UNIT); - @endcode - @note MSR_HASWELL_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_HASWELL_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_HASWELL_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Package. Energy Status Units Energy related information - /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an - /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 - /// micro-joules). - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL - /// Interfaces.". - /// - UINT32 TimeUnits:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_HASWELL_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_PP0_ENERGY_STATUS); - @endcode - @note MSR_HASWELL_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_HASWELL_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. PP1 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 - RAPL Domains.". - - @param ECX MSR_HASWELL_PP1_POWER_LIMIT (0x00000640) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_PP1_POWER_LIMIT); - AsmWriteMsr64 (MSR_HASWELL_PP1_POWER_LIMIT, Msr); - @endcode - @note MSR_HASWELL_PP1_POWER_LIMIT is defined as MSR_PP1_POWER_LIMIT in SDM. -**/ -#define MSR_HASWELL_PP1_POWER_LIMIT 0x00000640 - - -/** - Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_HASWELL_PP1_ENERGY_STATUS (0x00000641) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_PP1_ENERGY_STATUS); - @endcode - @note MSR_HASWELL_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. -**/ -#define MSR_HASWELL_PP1_ENERGY_STATUS 0x00000641 - - -/** - Package. PP1 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_HASWELL_PP1_POLICY (0x00000642) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_PP1_POLICY); - AsmWriteMsr64 (MSR_HASWELL_PP1_POLICY, Msr); - @endcode - @note MSR_HASWELL_PP1_POLICY is defined as MSR_PP1_POLICY in SDM. -**/ -#define MSR_HASWELL_PP1_POLICY 0x00000642 - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_HASWELL_CORE_PERF_LIMIT_REASONS (0x00000690) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_HASWELL_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_HASWELL_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_HASWELL_CORE_PERF_LIMIT_REASONS 0x00000690 - -/** - MSR information returned for MSR index #MSR_HASWELL_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is - /// reduced below the operating system request due to assertion of - /// external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:2; - /// - /// [Bit 4] Graphics Driver Status (R0) When set, frequency is reduced - /// below the operating system request due to Processor Graphics driver - /// override. - /// - UINT32 GraphicsDriverStatus:1; - /// - /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) - /// When set, frequency is reduced below the operating system request - /// because the processor has detected that utilization is low. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - /// - /// [Bit 9] Core Power Limiting Status (R0) When set, frequency is reduced - /// below the operating system request due to domain-level power limiting. - /// - UINT32 PLStatus:1; - /// - /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL1. - /// - UINT32 PL1Status:1; - /// - /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL2. - /// - UINT32 PL2Status:1; - /// - /// [Bit 12] Max Turbo Limit Status (R0) When set, frequency is reduced - /// below the operating system request due to multi-core turbo limits. - /// - UINT32 MaxTurboLimitStatus:1; - /// - /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency - /// is reduced below the operating system request due to Turbo transition - /// attenuation. This prevents performance degradation due to frequent - /// operating ratio changes. - /// - UINT32 TurboTransitionAttenuationStatus:1; - UINT32 Reserved3:2; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved4:2; - /// - /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics - /// Driver Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 GraphicsDriverLog:1; - /// - /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, - /// indicates that the Autonomous Utilization-Based Frequency Control - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - /// - /// [Bit 25] Core Power Limiting Log When set, indicates that the Core - /// Power Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 PLLog:1; - /// - /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates - /// that the Package Level PL1 Power Limiting Status bit has asserted - /// since the log bit was last cleared. This log bit will remain set until - /// cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that - /// the Package Level PL2 Power Limiting Status bit has asserted since the - /// log bit was last cleared. This log bit will remain set until cleared - /// by software writing 0. - /// - UINT32 PL2Log:1; - /// - /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo - /// Limit Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MaxTurboLimitLog:1; - /// - /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the - /// Turbo Transition Attenuation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 TurboTransitionAttenuationLog:1; - UINT32 Reserved6:2; - UINT32 Reserved7:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_CORE_PERF_LIMIT_REASONS_REGISTER; - - -/** - Package. Indicator of Frequency Clipping in the Processor Graphics (R/W) - (frequency refers to processor graphics frequency). - - @param ECX MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS (0x000006B0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS is defined as MSR_GRAPHICS_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS 0x000006B0 - -/** - MSR information returned for MSR index - #MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the - /// operating system request due to assertion of external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:2; - /// - /// [Bit 4] Graphics Driver Status (R0) When set, frequency is reduced - /// below the operating system request due to Processor Graphics driver - /// override. - /// - UINT32 GraphicsDriverStatus:1; - /// - /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) - /// When set, frequency is reduced below the operating system request - /// because the processor has detected that utilization is low. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - /// - /// [Bit 9] Graphics Power Limiting Status (R0) When set, frequency is - /// reduced below the operating system request due to domain-level power - /// limiting. - /// - UINT32 GraphicsPowerLimitingStatus:1; - /// - /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL1. - /// - UINT32 PL1STatus:1; - /// - /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL2. - /// - UINT32 PL2Status:1; - UINT32 Reserved3:4; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved4:2; - /// - /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics - /// Driver Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 GraphicsDriverLog:1; - /// - /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, - /// indicates that the Autonomous Utilization-Based Frequency Control - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - /// - /// [Bit 25] Core Power Limiting Log When set, indicates that the Core - /// Power Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CorePowerLimitingLog:1; - /// - /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates - /// that the Package Level PL1 Power Limiting Status bit has asserted - /// since the log bit was last cleared. This log bit will remain set until - /// cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that - /// the Package Level PL2 Power Limiting Status bit has asserted since the - /// log bit was last cleared. This log bit will remain set until cleared - /// by software writing 0. - /// - UINT32 PL2Log:1; - /// - /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo - /// Limit Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MaxTurboLimitLog:1; - /// - /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the - /// Turbo Transition Attenuation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 TurboTransitionAttenuationLog:1; - UINT32 Reserved6:2; - UINT32 Reserved7:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_GRAPHICS_PERF_LIMIT_REASONS_REGISTER; - - -/** - Package. Indicator of Frequency Clipping in the Ring Interconnect (R/W) - (frequency refers to ring interconnect in the uncore). - - @param ECX MSR_HASWELL_RING_PERF_LIMIT_REASONS (0x000006B1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_RING_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_HASWELL_RING_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_HASWELL_RING_PERF_LIMIT_REASONS is defined as MSR_RING_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_HASWELL_RING_PERF_LIMIT_REASONS 0x000006B1 - -/** - MSR information returned for MSR index #MSR_HASWELL_RING_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the - /// operating system request due to assertion of external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:4; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - UINT32 Reserved3:1; - /// - /// [Bit 10] Package-Level Power Limiting PL1 Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL1. - /// - UINT32 PL1STatus:1; - /// - /// [Bit 11] Package-Level PL2 Power Limiting Status (R0) When set, - /// frequency is reduced below the operating system request due to - /// package-level power limiting PL2. - /// - UINT32 PL2Status:1; - UINT32 Reserved4:4; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved5:2; - /// - /// [Bit 20] Graphics Driver Log When set, indicates that the Graphics - /// Driver Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 GraphicsDriverLog:1; - /// - /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, - /// indicates that the Autonomous Utilization-Based Frequency Control - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - UINT32 Reserved6:1; - /// - /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - /// - /// [Bit 25] Core Power Limiting Log When set, indicates that the Core - /// Power Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CorePowerLimitingLog:1; - /// - /// [Bit 26] Package-Level PL1 Power Limiting Log When set, indicates - /// that the Package Level PL1 Power Limiting Status bit has asserted - /// since the log bit was last cleared. This log bit will remain set until - /// cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package-Level PL2 Power Limiting Log When set, indicates that - /// the Package Level PL2 Power Limiting Status bit has asserted since the - /// log bit was last cleared. This log bit will remain set until cleared - /// by software writing 0. - /// - UINT32 PL2Log:1; - /// - /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo - /// Limit Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MaxTurboLimitLog:1; - /// - /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the - /// Turbo Transition Attenuation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 TurboTransitionAttenuationLog:1; - UINT32 Reserved7:2; - UINT32 Reserved8:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_RING_PERF_LIMIT_REASONS_REGISTER; - - -/** - Package. Uncore C-Box 0, counter 0 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 (0x00000700) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_0_PERFEVTSEL0 0x00000700 - - -/** - Package. Uncore C-Box 0, counter 1 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 (0x00000701) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_0_PERFEVTSEL1 0x00000701 - - -/** - Package. Uncore C-Box 0, performance counter 0. - - @param ECX MSR_HASWELL_UNC_CBO_0_PERFCTR0 (0x00000706) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_0_PERFCTR0 0x00000706 - - -/** - Package. Uncore C-Box 0, performance counter 1. - - @param ECX MSR_HASWELL_UNC_CBO_0_PERFCTR1 (0x00000707) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_0_PERFCTR1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_0_PERFCTR1 0x00000707 - - -/** - Package. Uncore C-Box 1, counter 0 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 (0x00000710) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_1_PERFEVTSEL0 0x00000710 - - -/** - Package. Uncore C-Box 1, counter 1 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 (0x00000711) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_1_PERFEVTSEL1 0x00000711 - - -/** - Package. Uncore C-Box 1, performance counter 0. - - @param ECX MSR_HASWELL_UNC_CBO_1_PERFCTR0 (0x00000716) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_1_PERFCTR0 0x00000716 - - -/** - Package. Uncore C-Box 1, performance counter 1. - - @param ECX MSR_HASWELL_UNC_CBO_1_PERFCTR1 (0x00000717) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_1_PERFCTR1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_1_PERFCTR1 0x00000717 - - -/** - Package. Uncore C-Box 2, counter 0 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 (0x00000720) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_2_PERFEVTSEL0 0x00000720 - - -/** - Package. Uncore C-Box 2, counter 1 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 (0x00000721) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_2_PERFEVTSEL1 0x00000721 - - -/** - Package. Uncore C-Box 2, performance counter 0. - - @param ECX MSR_HASWELL_UNC_CBO_2_PERFCTR0 (0x00000726) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_2_PERFCTR0 0x00000726 - - -/** - Package. Uncore C-Box 2, performance counter 1. - - @param ECX MSR_HASWELL_UNC_CBO_2_PERFCTR1 (0x00000727) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_2_PERFCTR1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_2_PERFCTR1 0x00000727 - - -/** - Package. Uncore C-Box 3, counter 0 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 (0x00000730) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_3_PERFEVTSEL0 0x00000730 - - -/** - Package. Uncore C-Box 3, counter 1 event select MSR. - - @param ECX MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 (0x00000731) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_3_PERFEVTSEL1 0x00000731 - - -/** - Package. Uncore C-Box 3, performance counter 0. - - @param ECX MSR_HASWELL_UNC_CBO_3_PERFCTR0 (0x00000736) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR0); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR0, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_3_PERFCTR0 0x00000736 - - -/** - Package. Uncore C-Box 3, performance counter 1. - - @param ECX MSR_HASWELL_UNC_CBO_3_PERFCTR1 (0x00000737) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR1); - AsmWriteMsr64 (MSR_HASWELL_UNC_CBO_3_PERFCTR1, Msr); - @endcode - @note MSR_HASWELL_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. -**/ -#define MSR_HASWELL_UNC_CBO_3_PERFCTR1 0x00000737 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. - - @param ECX MSR_HASWELL_PKG_C8_RESIDENCY (0x00000630) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER. - - Example usage - @code - MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C8_RESIDENCY); - AsmWriteMsr64 (MSR_HASWELL_PKG_C8_RESIDENCY, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKG_C8_RESIDENCY is defined as MSR_PKG_C8_RESIDENCY in SDM. -**/ -#define MSR_HASWELL_PKG_C8_RESIDENCY 0x00000630 - -/** - MSR information returned for MSR index #MSR_HASWELL_PKG_C8_RESIDENCY -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Package C8 Residency Counter. (R/O) Value since last reset - /// that this package is in processor-specific C8 states. Count at the - /// same frequency as the TSC. - /// - UINT32 C8ResidencyCounter:32; - /// - /// [Bits 59:32] Package C8 Residency Counter. (R/O) Value since last - /// reset that this package is in processor-specific C8 states. Count at - /// the same frequency as the TSC. - /// - UINT32 C8ResidencyCounterHi:28; - UINT32 Reserved:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKG_C8_RESIDENCY_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. - - @param ECX MSR_HASWELL_PKG_C9_RESIDENCY (0x00000631) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER. - - Example usage - @code - MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C9_RESIDENCY); - AsmWriteMsr64 (MSR_HASWELL_PKG_C9_RESIDENCY, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKG_C9_RESIDENCY is defined as MSR_PKG_C9_RESIDENCY in SDM. -**/ -#define MSR_HASWELL_PKG_C9_RESIDENCY 0x00000631 - -/** - MSR information returned for MSR index #MSR_HASWELL_PKG_C9_RESIDENCY -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Package C9 Residency Counter. (R/O) Value since last reset - /// that this package is in processor-specific C9 states. Count at the - /// same frequency as the TSC. - /// - UINT32 C9ResidencyCounter:32; - /// - /// [Bits 59:32] Package C9 Residency Counter. (R/O) Value since last - /// reset that this package is in processor-specific C9 states. Count at - /// the same frequency as the TSC. - /// - UINT32 C9ResidencyCounterHi:28; - UINT32 Reserved:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKG_C9_RESIDENCY_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. - - @param ECX MSR_HASWELL_PKG_C10_RESIDENCY (0x00000632) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER. - - Example usage - @code - MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_HASWELL_PKG_C10_RESIDENCY); - AsmWriteMsr64 (MSR_HASWELL_PKG_C10_RESIDENCY, Msr.Uint64); - @endcode - @note MSR_HASWELL_PKG_C10_RESIDENCY is defined as MSR_PKG_C10_RESIDENCY in SDM. -**/ -#define MSR_HASWELL_PKG_C10_RESIDENCY 0x00000632 - -/** - MSR information returned for MSR index #MSR_HASWELL_PKG_C10_RESIDENCY -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Package C10 Residency Counter. (R/O) Value since last - /// reset that this package is in processor-specific C10 states. Count at - /// the same frequency as the TSC. - /// - UINT32 C10ResidencyCounter:32; - /// - /// [Bits 59:32] Package C10 Residency Counter. (R/O) Value since last - /// reset that this package is in processor-specific C10 states. Count at - /// the same frequency as the TSC. - /// - UINT32 C10ResidencyCounterHi:28; - UINT32 Reserved:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_HASWELL_PKG_C10_RESIDENCY_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h b/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h deleted file mode 100644 index 9eb07994ec..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/IvyBridgeMsr.h +++ /dev/null @@ -1,2892 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Ivy Bridge microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.10. - -**/ - -#ifndef __IVY_BRIDGE_MSR_H__ -#define __IVY_BRIDGE_MSR_H__ - -#include - -/** - Is Intel processors based on the Ivy Bridge microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_IVY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x3A \ - ) \ - ) - -/** - Package. See http://biosbits.org. - - @param ECX MSR_IVY_BRIDGE_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_IVY_BRIDGE_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - UINT32 Reserved3:2; - /// - /// [Bit 32] Package. Low Power Mode Support (LPM) (R/O) When set to 1, - /// indicates that LPM is supported, and when set to 0, indicates LPM is - /// not supported. - /// - UINT32 LowPowerModeSupport:1; - /// - /// [Bits 34:33] Package. Number of ConfigTDP Levels (R/O) 00: Only Base - /// TDP level available. 01: One additional TDP level available. 02: Two - /// additional TDP level available. 11: Reserved. - /// - UINT32 ConfigTDPLevels:2; - UINT32 Reserved4:5; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - /// - /// [Bits 55:48] Package. Minimum Operating Ratio (R/O) Contains the - /// minimum supported operating ratio in units of 100 MHz. - /// - UINT32 MinimumOperatingRatio:8; - UINT32 Reserved5:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_PLATFORM_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI C-States. See http://biosbits.org. - - @param ECX MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power). for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0/C1 (no package C-sate support) 001b: C2 010b: C6 no retention 011b: - /// C6 retention 100b: C7 101b: C7s 111: No package C-state limit. Note: - /// This field cannot be used to limit package C-state to C3. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map - /// IO_read instructions sent to IO register specified by - /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register - /// until next reset. - /// - UINT32 CFGLock:1; - UINT32 Reserved3:9; - /// - /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C6/C7 requests to C3 based on uncore - /// auto-demote information. - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C3/C6/C7 requests to C1 based on uncore - /// auto-demote information. - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 undemotion (R/W) When set, enables undemotion from - /// demoted C3. - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 undemotion (R/W) When set, enables undemotion from - /// demoted C1. - /// - UINT32 C1Undemotion:1; - UINT32 Reserved4:3; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_IVY_BRIDGE_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PP0_ENERGY_STATUS); - @endcode - @note MSR_IVY_BRIDGE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. Base TDP Ratio (R/O). - - @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL (0x00000648) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL); - @endcode - @note MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. -**/ -#define MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL 0x00000648 - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Config_TDP_Base Base TDP level ratio to be used for this - /// specific processor (in units of 100 MHz). - /// - UINT32 Config_TDP_Base:8; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_CONFIG_TDP_NOMINAL_REGISTER; - - -/** - Package. ConfigTDP Level 1 ratio and power level (R/O). - - @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 (0x00000649) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1); - @endcode - @note MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 0x00000649 - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] PKG_TDP_LVL1. Power setting for ConfigTDP Level 1. - /// - UINT32 PKG_TDP_LVL1:15; - UINT32 Reserved1:1; - /// - /// [Bits 23:16] Config_TDP_LVL1_Ratio. ConfigTDP level 1 ratio to be used - /// for this specific processor. - /// - UINT32 Config_TDP_LVL1_Ratio:8; - UINT32 Reserved2:8; - /// - /// [Bits 46:32] PKG_MAX_PWR_LVL1. Max Power setting allowed for ConfigTDP - /// Level 1. - /// - UINT32 PKG_MAX_PWR_LVL1:15; - UINT32 Reserved3:1; - /// - /// [Bits 62:48] PKG_MIN_PWR_LVL1. MIN Power setting allowed for ConfigTDP - /// Level 1. - /// - UINT32 PKG_MIN_PWR_LVL1:15; - UINT32 Reserved4:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL1_REGISTER; - - -/** - Package. ConfigTDP Level 2 ratio and power level (R/O). - - @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 (0x0000064A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2); - @endcode - @note MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 0x0000064A - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] PKG_TDP_LVL2. Power setting for ConfigTDP Level 2. - /// - UINT32 PKG_TDP_LVL2:15; - UINT32 Reserved1:1; - /// - /// [Bits 23:16] Config_TDP_LVL2_Ratio. ConfigTDP level 2 ratio to be used - /// for this specific processor. - /// - UINT32 Config_TDP_LVL2_Ratio:8; - UINT32 Reserved2:8; - /// - /// [Bits 46:32] PKG_MAX_PWR_LVL2. Max Power setting allowed for ConfigTDP - /// Level 2. - /// - UINT32 PKG_MAX_PWR_LVL2:15; - UINT32 Reserved3:1; - /// - /// [Bits 62:48] PKG_MIN_PWR_LVL2. MIN Power setting allowed for ConfigTDP - /// Level 2. - /// - UINT32 PKG_MIN_PWR_LVL2:15; - UINT32 Reserved4:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_CONFIG_TDP_LEVEL2_REGISTER; - - -/** - Package. ConfigTDP Control (R/W). - - @param ECX MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL (0x0000064B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. -**/ -#define MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL 0x0000064B - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] TDP_LEVEL (RW/L) System BIOS can program this field. - /// - UINT32 TDP_LEVEL:2; - UINT32 Reserved1:29; - /// - /// [Bit 31] Config_TDP_Lock (RW/L) When this bit is set, the content of - /// this register is locked until a reset. - /// - UINT32 Config_TDP_Lock:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_CONFIG_TDP_CONTROL_REGISTER; - - -/** - Package. ConfigTDP Control (R/W). - - @param ECX MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO (0x0000064C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO); - AsmWriteMsr64 (MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. -**/ -#define MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO 0x0000064C - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] MAX_NON_TURBO_RATIO (RW/L) System BIOS can program this - /// field. - /// - UINT32 MAX_NON_TURBO_RATIO:8; - UINT32 Reserved1:23; - /// - /// [Bit 31] TURBO_ACTIVATION_RATIO_Lock (RW/L) When this bit is set, the - /// content of this register is locked until a reset. - /// - UINT32 TURBO_ACTIVATION_RATIO_Lock:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_TURBO_ACTIVATION_RATIO_REGISTER; - - -/** - Package. Protected Processor Inventory Number Enable Control (R/W). - - @param ECX MSR_IVY_BRIDGE_PPIN_CTL (0x0000004E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PPIN_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PPIN_CTL_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_PPIN_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PPIN_CTL, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_PPIN_CTL is defined as MSR_PPIN_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_PPIN_CTL 0x0000004E - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_PPIN_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] LockOut (R/WO) Set 1to prevent further writes to MSR_PPIN_CTL. - /// Writing 1 to MSR_PPINCTL[bit 0] is permitted only if MSR_PPIN_CTL[bit - /// 1] is clear, Default is 0. BIOS should provide an opt-in menu to - /// enable the user to turn on MSR_PPIN_CTL[bit 1] for privileged - /// inventory initialization agent to access MSR_PPIN. After reading - /// MSR_PPIN, the privileged inventory initialization agent should write - /// '01b' to MSR_PPIN_CTL to disable further access to MSR_PPIN and - /// prevent unauthorized modification to MSR_PPIN_CTL. - /// - UINT32 LockOut:1; - /// - /// [Bit 1] Enable_PPIN (R/W) If 1, enables MSR_PPIN to be accessible - /// using RDMSR. Once set, attempt to write 1 to MSR_PPIN_CTL[bit 0] will - /// cause #GP. If 0, an attempt to read MSR_PPIN will cause #GP. Default - /// is 0. - /// - UINT32 Enable_PPIN:1; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_PPIN_CTL_REGISTER; - - -/** - Package. Protected Processor Inventory Number (R/O). Protected Processor - Inventory Number (R/O) A unique value within a given CPUID - family/model/stepping signature that a privileged inventory initialization - agent can access to identify each physical processor, when access to - MSR_PPIN is enabled. Access to MSR_PPIN is permitted only if - MSR_PPIN_CTL[bits 1:0] = '10b'. - - @param ECX MSR_IVY_BRIDGE_PPIN (0x0000004F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PPIN); - @endcode - @note MSR_IVY_BRIDGE_PPIN is defined as MSR_PPIN in SDM. -**/ -#define MSR_IVY_BRIDGE_PPIN 0x0000004F - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_IVY_BRIDGE_PLATFORM_INFO_1 (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_PLATFORM_INFO_1 is defined as MSR_PLATFORM_INFO_1 in SDM. -**/ -#define MSR_IVY_BRIDGE_PLATFORM_INFO_1 0x000000CE - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_PLATFORM_INFO_1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:7; - /// - /// [Bit 23] Package. PPIN_CAP (R/O) When set to 1, indicates that - /// Protected Processor Inventory Number (PPIN) capability can be enabled - /// for privileged system inventory agent to read PPIN from MSR_PPIN. When - /// set to 0, PPIN capability is not supported. An attempt to access - /// MSR_PPIN_CTL or MSR_PPIN will cause #GP. - /// - UINT32 PPIN_CAP:1; - UINT32 Reserved3:4; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - /// - /// [Bit 30] Package. Programmable TJ OFFSET (R/O) When set to 1, - /// indicates that MSR_TEMPERATURE_TARGET.[27:24] is valid and writable to - /// specify an temperature offset. - /// - UINT32 TJOFFSET:1; - UINT32 Reserved4:1; - UINT32 Reserved5:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved6:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_PLATFORM_INFO_1_REGISTER; - - -/** - Package. MC Bank Error Configuration (R/W). - - @param ECX MSR_IVY_BRIDGE_ERROR_CONTROL (0x0000017F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_ERROR_CONTROL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_ERROR_CONTROL, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. -**/ -#define MSR_IVY_BRIDGE_ERROR_CONTROL 0x0000017F - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_ERROR_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank - /// to log additional info in bits 36:32. - /// - UINT32 MemErrorLogEnable:1; - UINT32 Reserved2:30; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_ERROR_CONTROL_REGISTER; - - -/** - Package. - - @param ECX MSR_IVY_BRIDGE_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_IVY_BRIDGE_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_IVY_BRIDGE_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (RO) The minimum temperature at which - /// PROCHOT# will be asserted. The value is degree C. - /// - UINT32 TemperatureTarget:8; - /// - /// [Bits 27:24] TCC Activation Offset (R/W) Specifies a temperature - /// offset in degrees C from the temperature target (bits 23:16). PROCHOT# - /// will assert at the offset target temperature. Write is permitted only - /// MSR_PLATFORM_INFO.[30] is set. - /// - UINT32 TCCActivationOffset:4; - UINT32 Reserved2:4; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_TEMPERATURE_TARGET_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 (0x000001AE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1); - @endcode - @note MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. -**/ -#define MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 0x000001AE - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 9C Maximum turbo ratio - /// limit of 9 core active. - /// - UINT32 Maximum9C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 10C Maximum turbo ratio - /// limit of 10core active. - /// - UINT32 Maximum10C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 11C Maximum turbo ratio - /// limit of 11 core active. - /// - UINT32 Maximum11C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 12C Maximum turbo ratio - /// limit of 12 core active. - /// - UINT32 Maximum12C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 13C Maximum turbo ratio - /// limit of 13 core active. - /// - UINT32 Maximum13C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 14C Maximum turbo ratio - /// limit of 14 core active. - /// - UINT32 Maximum14C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 15C Maximum turbo ratio - /// limit of 15 core active. - /// - UINT32 Maximum15C:8; - UINT32 Reserved:7; - /// - /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, - /// the processor uses override configuration specified in - /// MSR_TURBO_RATIO_LIMIT and MSR_TURBO_RATIO_LIMIT1. If 0, the processor - /// uses factory-set configuration (Default). - /// - UINT32 TurboRatioLimitConfigurationSemaphore:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_TURBO_RATIO_LIMIT1_REGISTER; - - -/** - Package. Misc MAC information of Integrated I/O. (R/O) see Section 15.3.2.4. - - @param ECX MSR_IVY_BRIDGE_IA32_MC6_MISC (0x0000041B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC6_MISC); - @endcode - @note MSR_IVY_BRIDGE_IA32_MC6_MISC is defined as IA32_MC6_MISC in SDM. -**/ -#define MSR_IVY_BRIDGE_IA32_MC6_MISC 0x0000041B - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_IA32_MC6_MISC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 5:0] Recoverable Address LSB. - /// - UINT32 RecoverableAddressLSB:6; - /// - /// [Bits 8:6] Address Mode. - /// - UINT32 AddressMode:3; - UINT32 Reserved1:7; - /// - /// [Bits 31:16] PCI Express Requestor ID. - /// - UINT32 PCIExpressRequestorID:16; - /// - /// [Bits 39:32] PCI Express Segment Number. - /// - UINT32 PCIExpressSegmentNumber:8; - UINT32 Reserved2:24; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_IA32_MC6_MISC_REGISTER; - - -/** - Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section - 15.3.2.4, "IA32_MCi_MISC MSRs.". - - Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) - and its corresponding slice of L3. - - @param ECX MSR_IVY_BRIDGE_IA32_MCi_CTL - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_IA32_MC29_CTL is defined as IA32_MC29_CTL in SDM. - MSR_IVY_BRIDGE_IA32_MC30_CTL is defined as IA32_MC30_CTL in SDM. - MSR_IVY_BRIDGE_IA32_MC31_CTL is defined as IA32_MC31_CTL in SDM. - @{ -**/ -#define MSR_IVY_BRIDGE_IA32_MC29_CTL 0x00000474 -#define MSR_IVY_BRIDGE_IA32_MC30_CTL 0x00000478 -#define MSR_IVY_BRIDGE_IA32_MC31_CTL 0x0000047C -/// @} - - -/** - Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section - 15.3.2.4, "IA32_MCi_MISC MSRs.". - - Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) - and its corresponding slice of L3. - - @param ECX MSR_IVY_BRIDGE_IA32_MCi_STATUS - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_STATUS); - AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_STATUS, Msr); - @endcode - @note MSR_IVY_BRIDGE_IA32_MC29_STATUS is defined as IA32_MC29_STATUS in SDM. - MSR_IVY_BRIDGE_IA32_MC30_STATUS is defined as IA32_MC30_STATUS in SDM. - MSR_IVY_BRIDGE_IA32_MC31_STATUS is defined as IA32_MC31_STATUS in SDM. - @{ -**/ -#define MSR_IVY_BRIDGE_IA32_MC29_STATUS 0x00000475 -#define MSR_IVY_BRIDGE_IA32_MC30_STATUS 0x00000479 -#define MSR_IVY_BRIDGE_IA32_MC31_STATUS 0x0000047D -/// @} - - -/** - Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section - 15.3.2.4, "IA32_MCi_MISC MSRs.". - - Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) - and its corresponding slice of L3. - - @param ECX MSR_IVY_BRIDGE_IA32_MCi_ADDR - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_ADDR); - AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_ADDR, Msr); - @endcode - @note MSR_IVY_BRIDGE_IA32_MC29_ADDR is defined as IA32_MC29_ADDR in SDM. - MSR_IVY_BRIDGE_IA32_MC30_ADDR is defined as IA32_MC30_ADDR in SDM. - MSR_IVY_BRIDGE_IA32_MC31_ADDR is defined as IA32_MC31_ADDR in SDM. - @{ -**/ -#define MSR_IVY_BRIDGE_IA32_MC29_ADDR 0x00000476 -#define MSR_IVY_BRIDGE_IA32_MC30_ADDR 0x0000047A -#define MSR_IVY_BRIDGE_IA32_MC31_ADDR 0x0000047E -/// @} - - -/** - Package. See Section 15.3.2.1, "IA32_MCi_CTL MSRs." through Section - 15.3.2.4, "IA32_MCi_MISC MSRs.". - - Bank MC29 through MC31 reports MC error from a specific CBo (core broadcast) - and its corresponding slice of L3. - - @param ECX MSR_IVY_BRIDGE_IA32_MCi_MISC - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_IA32_MC29_MISC); - AsmWriteMsr64 (MSR_IVY_BRIDGE_IA32_MC29_MISC, Msr); - @endcode - @note MSR_IVY_BRIDGE_IA32_MC29_MISC is defined as IA32_MC29_MISC in SDM. - MSR_IVY_BRIDGE_IA32_MC30_MISC is defined as IA32_MC30_MISC in SDM. - MSR_IVY_BRIDGE_IA32_MC31_MISC is defined as IA32_MC31_MISC in SDM. - @{ -**/ -#define MSR_IVY_BRIDGE_IA32_MC29_MISC 0x00000477 -#define MSR_IVY_BRIDGE_IA32_MC30_MISC 0x0000047B -#define MSR_IVY_BRIDGE_IA32_MC31_MISC 0x0000047F -/// @} - - -/** - Package. Package RAPL Perf Status (R/O). - - @param ECX MSR_IVY_BRIDGE_PKG_PERF_STATUS (0x00000613) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PKG_PERF_STATUS); - @endcode - @note MSR_IVY_BRIDGE_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_PKG_PERF_STATUS 0x00000613 - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_IVY_BRIDGE_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_IVY_BRIDGE_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_IVY_BRIDGE_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS); - @endcode - @note MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_DRAM_ENERGY_STATUS 0x00000619 - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_IVY_BRIDGE_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_PERF_STATUS); - @endcode - @note MSR_IVY_BRIDGE_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_IVY_BRIDGE_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_IVY_BRIDGE_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_IVY_BRIDGE_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_IVY_BRIDGE_DRAM_POWER_INFO 0x0000061C - - -/** - Thread. See Section 18.8.1.1, "Precise Event Based Sampling (PEBS).". - - @param ECX MSR_IVY_BRIDGE_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PEBS_ENABLE); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_IVY_BRIDGE_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_IVY_BRIDGE_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_IVY_BRIDGE_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). - /// - UINT32 PEBS_EN_PMC0:1; - /// - /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). - /// - UINT32 PEBS_EN_PMC1:1; - /// - /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). - /// - UINT32 PEBS_EN_PMC2:1; - /// - /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). - /// - UINT32 PEBS_EN_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). - /// - UINT32 LL_EN_PMC0:1; - /// - /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). - /// - UINT32 LL_EN_PMC1:1; - /// - /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). - /// - UINT32 LL_EN_PMC2:1; - /// - /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). - /// - UINT32 LL_EN_PMC3:1; - UINT32 Reserved2:28; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_IVY_BRIDGE_PEBS_ENABLE_REGISTER; - - -/** - Package. Uncore perfmon per-socket global control. - - @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_CTL (0x00000C00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_PMON_GLOBAL_CTL is defined as MSR_PMON_GLOBAL_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_PMON_GLOBAL_CTL 0x00000C00 - - -/** - Package. Uncore perfmon per-socket global status. - - @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS (0x00000C01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS, Msr); - @endcode - @note MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS is defined as MSR_PMON_GLOBAL_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_PMON_GLOBAL_STATUS 0x00000C01 - - -/** - Package. Uncore perfmon per-socket global configuration. - - @param ECX MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG (0x00000C06) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG, Msr); - @endcode - @note MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG is defined as MSR_PMON_GLOBAL_CONFIG in SDM. -**/ -#define MSR_IVY_BRIDGE_PMON_GLOBAL_CONFIG 0x00000C06 - - -/** - Package. Uncore U-box perfmon U-box wide status. - - @param ECX MSR_IVY_BRIDGE_U_PMON_BOX_STATUS (0x00000C15) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_U_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_IVY_BRIDGE_U_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_IVY_BRIDGE_U_PMON_BOX_STATUS is defined as MSR_U_PMON_BOX_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_U_PMON_BOX_STATUS 0x00000C15 - - -/** - Package. Uncore PCU perfmon box wide status. - - @param ECX MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS (0x00000C35) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS is defined as MSR_PCU_PMON_BOX_STATUS in SDM. -**/ -#define MSR_IVY_BRIDGE_PCU_PMON_BOX_STATUS 0x00000C35 - - -/** - Package. Uncore C-box 0 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 (0x00000D1A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 is defined as MSR_C0_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C0_PMON_BOX_FILTER1 0x00000D1A - - -/** - Package. Uncore C-box 1 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 (0x00000D3A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 is defined as MSR_C1_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C1_PMON_BOX_FILTER1 0x00000D3A - - -/** - Package. Uncore C-box 2 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 (0x00000D5A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 is defined as MSR_C2_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C2_PMON_BOX_FILTER1 0x00000D5A - - -/** - Package. Uncore C-box 3 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 (0x00000D7A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 is defined as MSR_C3_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C3_PMON_BOX_FILTER1 0x00000D7A - - -/** - Package. Uncore C-box 4 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 (0x00000D9A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 is defined as MSR_C4_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C4_PMON_BOX_FILTER1 0x00000D9A - - -/** - Package. Uncore C-box 5 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 (0x00000DBA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 is defined as MSR_C5_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C5_PMON_BOX_FILTER1 0x00000DBA - - -/** - Package. Uncore C-box 6 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 (0x00000DDA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 is defined as MSR_C6_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C6_PMON_BOX_FILTER1 0x00000DDA - - -/** - Package. Uncore C-box 7 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 (0x00000DFA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 is defined as MSR_C7_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C7_PMON_BOX_FILTER1 0x00000DFA - - -/** - Package. Uncore C-box 8 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_CTL (0x00000E04) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_BOX_CTL is defined as MSR_C8_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_BOX_CTL 0x00000E04 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 0. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 (0x00000E10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 is defined as MSR_C8_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL0 0x00000E10 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 1. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 (0x00000E11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 is defined as MSR_C8_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL1 0x00000E11 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 2. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 (0x00000E12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 is defined as MSR_C8_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL2 0x00000E12 - - -/** - Package. Uncore C-box 8 perfmon event select for C-box 8 counter 3. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 (0x00000E13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 is defined as MSR_C8_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_EVNTSEL3 0x00000E13 - - -/** - Package. Uncore C-box 8 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER (0x00000E14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER is defined as MSR_C8_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER 0x00000E14 - - -/** - Package. Uncore C-box 8 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR0 (0x00000E16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_CTR0 0x00000E16 - - -/** - Package. Uncore C-box 8 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR1 (0x00000E17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_CTR1 0x00000E17 - - -/** - Package. Uncore C-box 8 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR2 (0x00000E18) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_CTR2 0x00000E18 - - -/** - Package. Uncore C-box 8 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_CTR3 (0x00000E19) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_CTR3 0x00000E19 - - -/** - Package. Uncore C-box 8 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 (0x00000E1A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 is defined as MSR_C8_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C8_PMON_BOX_FILTER1 0x00000E1A - - -/** - Package. Uncore C-box 9 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_CTL (0x00000E24) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_BOX_CTL is defined as MSR_C9_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_BOX_CTL 0x00000E24 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 0. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 (0x00000E30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 is defined as MSR_C9_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL0 0x00000E30 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 1. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 (0x00000E31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 is defined as MSR_C9_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL1 0x00000E31 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 2. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 (0x00000E32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 is defined as MSR_C9_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL2 0x00000E32 - - -/** - Package. Uncore C-box 9 perfmon event select for C-box 9 counter 3. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 (0x00000E33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 is defined as MSR_C9_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_EVNTSEL3 0x00000E33 - - -/** - Package. Uncore C-box 9 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER (0x00000E34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER is defined as MSR_C9_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER 0x00000E34 - - -/** - Package. Uncore C-box 9 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR0 (0x00000E36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_CTR0 0x00000E36 - - -/** - Package. Uncore C-box 9 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR1 (0x00000E37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_CTR1 0x00000E37 - - -/** - Package. Uncore C-box 9 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR2 (0x00000E38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_CTR2 0x00000E38 - - -/** - Package. Uncore C-box 9 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_CTR3 (0x00000E39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_CTR3 0x00000E39 - - -/** - Package. Uncore C-box 9 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 (0x00000E3A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 is defined as MSR_C9_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C9_PMON_BOX_FILTER1 0x00000E3A - - -/** - Package. Uncore C-box 10 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_CTL (0x00000E44) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_BOX_CTL is defined as MSR_C10_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_BOX_CTL 0x00000E44 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 0. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 (0x00000E50) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 is defined as MSR_C10_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL0 0x00000E50 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 1. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 (0x00000E51) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 is defined as MSR_C10_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL1 0x00000E51 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 2. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 (0x00000E52) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 is defined as MSR_C10_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL2 0x00000E52 - - -/** - Package. Uncore C-box 10 perfmon event select for C-box 10 counter 3. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 (0x00000E53) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 is defined as MSR_C10_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_EVNTSEL3 0x00000E53 - - -/** - Package. Uncore C-box 10 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER (0x00000E54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER is defined as MSR_C10_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER 0x00000E54 - - -/** - Package. Uncore C-box 10 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR0 (0x00000E56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_CTR0 is defined as MSR_C10_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_CTR0 0x00000E56 - - -/** - Package. Uncore C-box 10 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR1 (0x00000E57) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_CTR1 is defined as MSR_C10_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_CTR1 0x00000E57 - - -/** - Package. Uncore C-box 10 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR2 (0x00000E58) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_CTR2 is defined as MSR_C10_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_CTR2 0x00000E58 - - -/** - Package. Uncore C-box 10 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_CTR3 (0x00000E59) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_CTR3 is defined as MSR_C10_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_CTR3 0x00000E59 - - -/** - Package. Uncore C-box 10 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 (0x00000E5A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 is defined as MSR_C10_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C10_PMON_BOX_FILTER1 0x00000E5A - - -/** - Package. Uncore C-box 11 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_CTL (0x00000E64) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_BOX_CTL is defined as MSR_C11_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_BOX_CTL 0x00000E64 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 0. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 (0x00000E70) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 is defined as MSR_C11_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL0 0x00000E70 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 1. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 (0x00000E71) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 is defined as MSR_C11_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL1 0x00000E71 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 2. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 (0x00000E72) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 is defined as MSR_C11_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL2 0x00000E72 - - -/** - Package. Uncore C-box 11 perfmon event select for C-box 11 counter 3. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 (0x00000E73) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 is defined as MSR_C11_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_EVNTSEL3 0x00000E73 - - -/** - Package. Uncore C-box 11 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER (0x00000E74) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER is defined as MSR_C11_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER 0x00000E74 - - -/** - Package. Uncore C-box 11 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR0 (0x00000E76) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_CTR0 is defined as MSR_C11_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_CTR0 0x00000E76 - - -/** - Package. Uncore C-box 11 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR1 (0x00000E77) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_CTR1 is defined as MSR_C11_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_CTR1 0x00000E77 - - -/** - Package. Uncore C-box 11 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR2 (0x00000E78) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_CTR2 is defined as MSR_C11_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_CTR2 0x00000E78 - - -/** - Package. Uncore C-box 11 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_CTR3 (0x00000E79) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_CTR3 is defined as MSR_C11_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_CTR3 0x00000E79 - - -/** - Package. Uncore C-box 11 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 (0x00000E7A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 is defined as MSR_C11_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C11_PMON_BOX_FILTER1 0x00000E7A - - -/** - Package. Uncore C-box 12 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_CTL (0x00000E84) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_BOX_CTL is defined as MSR_C12_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_BOX_CTL 0x00000E84 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 0. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 (0x00000E90) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 is defined as MSR_C12_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL0 0x00000E90 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 1. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 (0x00000E91) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 is defined as MSR_C12_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL1 0x00000E91 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 2. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 (0x00000E92) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 is defined as MSR_C12_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL2 0x00000E92 - - -/** - Package. Uncore C-box 12 perfmon event select for C-box 12 counter 3. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 (0x00000E93) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 is defined as MSR_C12_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_EVNTSEL3 0x00000E93 - - -/** - Package. Uncore C-box 12 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER (0x00000E94) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER is defined as MSR_C12_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER 0x00000E94 - - -/** - Package. Uncore C-box 12 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR0 (0x00000E96) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_CTR0 is defined as MSR_C12_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_CTR0 0x00000E96 - - -/** - Package. Uncore C-box 12 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR1 (0x00000E97) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_CTR1 is defined as MSR_C12_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_CTR1 0x00000E97 - - -/** - Package. Uncore C-box 12 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR2 (0x00000E98) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_CTR2 is defined as MSR_C12_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_CTR2 0x00000E98 - - -/** - Package. Uncore C-box 12 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_CTR3 (0x00000E99) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_CTR3 is defined as MSR_C12_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_CTR3 0x00000E99 - - -/** - Package. Uncore C-box 12 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 (0x00000E9A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 is defined as MSR_C12_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C12_PMON_BOX_FILTER1 0x00000E9A - - -/** - Package. Uncore C-box 13 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_CTL (0x00000EA4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_BOX_CTL is defined as MSR_C13_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_BOX_CTL 0x00000EA4 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 0. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 (0x00000EB0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 is defined as MSR_C13_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL0 0x00000EB0 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 1. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 (0x00000EB1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 is defined as MSR_C13_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL1 0x00000EB1 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 2. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 (0x00000EB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 is defined as MSR_C13_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL2 0x00000EB2 - - -/** - Package. Uncore C-box 13 perfmon event select for C-box 13 counter 3. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 (0x00000EB3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 is defined as MSR_C13_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_EVNTSEL3 0x00000EB3 - - -/** - Package. Uncore C-box 13 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER (0x00000EB4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER is defined as MSR_C13_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER 0x00000EB4 - - -/** - Package. Uncore C-box 13 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR0 (0x00000EB6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_CTR0 is defined as MSR_C13_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_CTR0 0x00000EB6 - - -/** - Package. Uncore C-box 13 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR1 (0x00000EB7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_CTR1 is defined as MSR_C13_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_CTR1 0x00000EB7 - - -/** - Package. Uncore C-box 13 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR2 (0x00000EB8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_CTR2 is defined as MSR_C13_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_CTR2 0x00000EB8 - - -/** - Package. Uncore C-box 13 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_CTR3 (0x00000EB9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_CTR3 is defined as MSR_C13_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_CTR3 0x00000EB9 - - -/** - Package. Uncore C-box 13 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 (0x00000EBA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 is defined as MSR_C13_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C13_PMON_BOX_FILTER1 0x00000EBA - - -/** - Package. Uncore C-box 14 perfmon local box wide control. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_CTL (0x00000EC4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_CTL, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_BOX_CTL is defined as MSR_C14_PMON_BOX_CTL in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_BOX_CTL 0x00000EC4 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 0. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 (0x00000ED0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 is defined as MSR_C14_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL0 0x00000ED0 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 1. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 (0x00000ED1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 is defined as MSR_C14_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL1 0x00000ED1 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 2. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 (0x00000ED2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 is defined as MSR_C14_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL2 0x00000ED2 - - -/** - Package. Uncore C-box 14 perfmon event select for C-box 14 counter 3. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 (0x00000ED3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 is defined as MSR_C14_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_EVNTSEL3 0x00000ED3 - - -/** - Package. Uncore C-box 14 perfmon box wide filter. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER (0x00000ED4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER is defined as MSR_C14_PMON_BOX_FILTER in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER 0x00000ED4 - - -/** - Package. Uncore C-box 14 perfmon counter 0. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR0 (0x00000ED6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR0); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR0, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_CTR0 is defined as MSR_C14_PMON_CTR0 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_CTR0 0x00000ED6 - - -/** - Package. Uncore C-box 14 perfmon counter 1. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR1 (0x00000ED7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_CTR1 is defined as MSR_C14_PMON_CTR1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_CTR1 0x00000ED7 - - -/** - Package. Uncore C-box 14 perfmon counter 2. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR2 (0x00000ED8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR2); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR2, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_CTR2 is defined as MSR_C14_PMON_CTR2 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_CTR2 0x00000ED8 - - -/** - Package. Uncore C-box 14 perfmon counter 3. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_CTR3 (0x00000ED9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR3); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_CTR3, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_CTR3 is defined as MSR_C14_PMON_CTR3 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_CTR3 0x00000ED9 - - -/** - Package. Uncore C-box 14 perfmon box wide filter1. - - @param ECX MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 (0x00000EDA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1); - AsmWriteMsr64 (MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1, Msr); - @endcode - @note MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 is defined as MSR_C14_PMON_BOX_FILTER1 in SDM. -**/ -#define MSR_IVY_BRIDGE_C14_PMON_BOX_FILTER1 0x00000EDA - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h b/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h deleted file mode 100644 index 94aebba4d1..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/NehalemMsr.h +++ /dev/null @@ -1,7430 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Nehalem microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.6. - -**/ - -#ifndef __NEHALEM_MSR_H__ -#define __NEHALEM_MSR_H__ - -#include - -/** - Is Intel processors based on the Nehalem microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_NEHALEM_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x1A || \ - DisplayModel == 0x1E || \ - DisplayModel == 0x1F || \ - DisplayModel == 0x2E \ - ) \ - ) - -/** - Package. Model Specific Platform ID (R). - - @param ECX MSR_NEHALEM_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_NEHALEM_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PLATFORM_ID); - @endcode - @note MSR_NEHALEM_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. -**/ -#define MSR_NEHALEM_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:18; - /// - /// [Bits 52:50] See Table 35-2. - /// - UINT32 PlatformId:3; - UINT32 Reserved3:11; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PLATFORM_ID_REGISTER; - - -/** - Thread. SMI Counter (R/O). - - @param ECX MSR_NEHALEM_SMI_COUNT (0x00000034) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_SMI_COUNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_SMI_COUNT_REGISTER. - - Example usage - @code - MSR_NEHALEM_SMI_COUNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_SMI_COUNT); - @endcode - @note MSR_NEHALEM_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. -**/ -#define MSR_NEHALEM_SMI_COUNT 0x00000034 - -/** - MSR information returned for MSR index #MSR_NEHALEM_SMI_COUNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] SMI Count (R/O) Running count of SMI events since last - /// RESET. - /// - UINT32 SMICount:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_SMI_COUNT_REGISTER; - - -/** - Package. see http://biosbits.org. - - @param ECX MSR_NEHALEM_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_NEHALEM_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PLATFORM_INFO); - AsmWriteMsr64 (MSR_NEHALEM_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_NEHALEM_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_NEHALEM_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. The invariant TSC - /// frequency can be computed by multiplying this ratio by 133.33 MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDC-TDP Limit for Turbo Mode (R/O) - /// When set to 1, indicates that TDC/TDP Limits for Turbo mode are - /// programmable, and when set to 0, indicates TDC and TDP Limits for - /// Turbo mode are not programmable. - /// - UINT32 TDC_TDPLimit:1; - UINT32 Reserved3:2; - UINT32 Reserved4:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 133.33MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved5:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PLATFORM_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. See http://biosbits.org. - - @param ECX MSR_NEHALEM_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_NEHALEM_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_NEHALEM_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power). for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0 (no package C-sate support) 001b: C1 (Behavior is the same as 000b) - /// 010b: C3 011b: C6 100b: C7 101b and 110b: Reserved 111: No package - /// C-state limit. Note: This field cannot be used to limit package - /// C-state to C3. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map - /// IO_read instructions sent to IO register specified by - /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register - /// until next reset. - /// - UINT32 CFGLock:1; - UINT32 Reserved3:8; - /// - /// [Bit 24] Interrupt filtering enable (R/W) When set, processor cores - /// in a deep C-State will wake only when the event message is destined - /// for that core. When 0, all processor cores in a deep C-State will wake - /// for an event message. - /// - UINT32 InterruptFiltering:1; - /// - /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C6/C7 requests to C3 based on uncore - /// auto-demote information. - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C3/C6/C7 requests to C1 based on uncore - /// auto-demote information. - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 Undemotion (R/W). - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 Undemotion (R/W). - /// - UINT32 C1Undemotion:1; - /// - /// [Bit 29] Package C State Demotion Enable (R/W). - /// - UINT32 CStateDemotion:1; - /// - /// [Bit 30] Package C State UnDemotion Enable (R/W). - /// - UINT32 CStateUndemotion:1; - UINT32 Reserved4:1; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Core. Power Management IO Redirection in C-state (R/W) See - http://biosbits.org. - - @param ECX MSR_NEHALEM_PMG_IO_CAPTURE_BASE (0x000000E4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER. - - Example usage - @code - MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PMG_IO_CAPTURE_BASE); - AsmWriteMsr64 (MSR_NEHALEM_PMG_IO_CAPTURE_BASE, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. -**/ -#define MSR_NEHALEM_PMG_IO_CAPTURE_BASE 0x000000E4 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PMG_IO_CAPTURE_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address - /// visible to software for IO redirection. If IO MWAIT Redirection is - /// enabled, reads to this address will be consumed by the power - /// management logic and decoded to MWAIT instructions. When IO port - /// address redirection is enabled, this is the IO port address reported - /// to the OS/software. - /// - UINT32 Lvl2Base:16; - /// - /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the - /// maximum C-State code name to be included when IO read to MWAIT - /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 000b - C3 - /// is the max C-State to include 001b - C6 is the max C-State to include - /// 010b - C7 is the max C-State to include. - /// - UINT32 CStateRange:3; - UINT32 Reserved1:13; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PMG_IO_CAPTURE_BASE_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_NEHALEM_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_NEHALEM_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_NEHALEM_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_NEHALEM_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_NEHALEM_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Thread. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. Default value is 1. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Thread. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:3; - /// - /// [Bit 11] Thread. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Thread. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - UINT32 Reserved4:3; - /// - /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] Thread. ENABLE MONITOR FSM. (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved6:3; - /// - /// [Bit 22] Thread. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Thread. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] Thread. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved9:3; - /// - /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors - /// that support Intel Turbo Boost Technology, the turbo mode feature is - /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: - /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: - /// EAX[1] reports the processor's support of turbo mode is enabled. Note: - /// the power-on default value is used by BIOS to detect hardware support - /// of turbo mode. If power-on default value is 1, turbo mode is available - /// in the processor. If power-on default value is 0, turbo mode is not - /// available. - /// - UINT32 TurboModeDisable:1; - UINT32 Reserved10:25; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_IA32_MISC_ENABLE_REGISTER; - - -/** - Thread. - - @param ECX MSR_NEHALEM_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_NEHALEM_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_NEHALEM_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_NEHALEM_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_NEHALEM_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (R) The minimum temperature at which - /// PROCHOT# will be asserted. The value is degree C. - /// - UINT32 TemperatureTarget:8; - UINT32 Reserved2:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_TEMPERATURE_TARGET_REGISTER; - - -/** - Miscellaneous Feature Control (R/W). - - @param ECX MSR_NEHALEM_MISC_FEATURE_CONTROL (0x000001A4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_MISC_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_NEHALEM_MISC_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_NEHALEM_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. -**/ -#define MSR_NEHALEM_MISC_FEATURE_CONTROL 0x000001A4 - -/** - MSR information returned for MSR index #MSR_NEHALEM_MISC_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the - /// L2 hardware prefetcher, which fetches additional lines of code or data - /// into the L2 cache. - /// - UINT32 L2HardwarePrefetcherDisable:1; - /// - /// [Bit 1] Core. L2 Adjacent Cache Line Prefetcher Disable (R/W) If 1, - /// disables the adjacent cache line prefetcher, which fetches the cache - /// line that comprises a cache line pair (128 bytes). - /// - UINT32 L2AdjacentCacheLinePrefetcherDisable:1; - /// - /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables - /// the L1 data cache prefetcher, which fetches the next cache line into - /// L1 data cache. - /// - UINT32 DCUHardwarePrefetcherDisable:1; - /// - /// [Bit 3] Core. DCU IP Prefetcher Disable (R/W) If 1, disables the L1 - /// data cache IP prefetcher, which uses sequential load history (based on - /// instruction Pointer of previous loads) to determine whether to - /// prefetch additional lines. - /// - UINT32 DCUIPPrefetcherDisable:1; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_MISC_FEATURE_CONTROL_REGISTER; - - -/** - Thread. Offcore Response Event Select Register (R/W). - - @param ECX MSR_NEHALEM_OFFCORE_RSP_0 (0x000001A6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_OFFCORE_RSP_0); - AsmWriteMsr64 (MSR_NEHALEM_OFFCORE_RSP_0, Msr); - @endcode - @note MSR_NEHALEM_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. -**/ -#define MSR_NEHALEM_OFFCORE_RSP_0 0x000001A6 - - -/** - See http://biosbits.org. - - @param ECX MSR_NEHALEM_MISC_PWR_MGMT (0x000001AA) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_MISC_PWR_MGMT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_MISC_PWR_MGMT_REGISTER. - - Example usage - @code - MSR_NEHALEM_MISC_PWR_MGMT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_MISC_PWR_MGMT); - AsmWriteMsr64 (MSR_NEHALEM_MISC_PWR_MGMT, Msr.Uint64); - @endcode - @note MSR_NEHALEM_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. -**/ -#define MSR_NEHALEM_MISC_PWR_MGMT 0x000001AA - -/** - MSR information returned for MSR index #MSR_NEHALEM_MISC_PWR_MGMT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Package. EIST Hardware Coordination Disable (R/W) When 0, - /// enables hardware coordination of Enhanced Intel Speedstep Technology - /// request from processor cores; When 1, disables hardware coordination - /// of Enhanced Intel Speedstep Technology requests. - /// - UINT32 EISTHardwareCoordinationDisable:1; - /// - /// [Bit 1] Thread. Energy/Performance Bias Enable (R/W) This bit makes - /// the IA32_ENERGY_PERF_BIAS register (MSR 1B0h) visible to software with - /// Ring 0 privileges. This bit's status (1 or 0) is also reflected by - /// CPUID.(EAX=06h):ECX[3]. - /// - UINT32 EnergyPerformanceBiasEnable:1; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_MISC_PWR_MGMT_REGISTER; - - -/** - See http://biosbits.org. - - @param ECX MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT (0x000001AC) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER. - - Example usage - @code - MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT); - AsmWriteMsr64 (MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT, Msr.Uint64); - @endcode - @note MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT is defined as MSR_TURBO_POWER_CURRENT_LIMIT in SDM. -**/ -#define MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT 0x000001AC - -/** - MSR information returned for MSR index #MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Package. TDP Limit (R/W) TDP limit in 1/8 Watt - /// granularity. - /// - UINT32 TDPLimit:15; - /// - /// [Bit 15] Package. TDP Limit Override Enable (R/W) A value = 0 - /// indicates override is not active, and a value = 1 indicates active. - /// - UINT32 TDPLimitOverrideEnable:1; - /// - /// [Bits 30:16] Package. TDC Limit (R/W) TDC limit in 1/8 Amp - /// granularity. - /// - UINT32 TDCLimit:15; - /// - /// [Bit 31] Package. TDC Limit Override Enable (R/W) A value = 0 - /// indicates override is not active, and a value = 1 indicates active. - /// - UINT32 TDCLimitOverrideEnable:1; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_TURBO_POWER_CURRENT_LIMIT_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_NEHALEM_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_TURBO_RATIO_LIMIT); - @endcode - @note MSR_NEHALEM_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_NEHALEM_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Core. Last Branch Record Filtering Select Register (R/W) See Section - 17.7.2, "Filtering of Last Branch Records.". - - @param ECX MSR_NEHALEM_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_LBR_SELECT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_LBR_SELECT_REGISTER. - - Example usage - @code - MSR_NEHALEM_LBR_SELECT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_LBR_SELECT); - AsmWriteMsr64 (MSR_NEHALEM_LBR_SELECT, Msr.Uint64); - @endcode - @note MSR_NEHALEM_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_NEHALEM_LBR_SELECT 0x000001C8 - -/** - MSR information returned for MSR index #MSR_NEHALEM_LBR_SELECT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CPL_EQ_0. - /// - UINT32 CPL_EQ_0:1; - /// - /// [Bit 1] CPL_NEQ_0. - /// - UINT32 CPL_NEQ_0:1; - /// - /// [Bit 2] JCC. - /// - UINT32 JCC:1; - /// - /// [Bit 3] NEAR_REL_CALL. - /// - UINT32 NEAR_REL_CALL:1; - /// - /// [Bit 4] NEAR_IND_CALL. - /// - UINT32 NEAR_IND_CALL:1; - /// - /// [Bit 5] NEAR_RET. - /// - UINT32 NEAR_RET:1; - /// - /// [Bit 6] NEAR_IND_JMP. - /// - UINT32 NEAR_IND_JMP:1; - /// - /// [Bit 7] NEAR_REL_JMP. - /// - UINT32 NEAR_REL_JMP:1; - /// - /// [Bit 8] FAR_BRANCH. - /// - UINT32 FAR_BRANCH:1; - UINT32 Reserved1:23; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_LBR_SELECT_REGISTER; - - -/** - Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) - that points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP (at 680H). - - @param ECX MSR_NEHALEM_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_NEHALEM_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_NEHALEM_LASTBRANCH_TOS 0x000001C9 - - -/** - Thread. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_NEHALEM_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_LER_FROM_LIP); - @endcode - @note MSR_NEHALEM_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_NEHALEM_LER_FROM_LIP 0x000001DD - - -/** - Thread. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_NEHALEM_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_LER_TO_LIP); - @endcode - @note MSR_NEHALEM_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_NEHALEM_LER_TO_LIP 0x000001DE - - -/** - Core. Power Control Register. See http://biosbits.org. - - @param ECX MSR_NEHALEM_POWER_CTL (0x000001FC) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_POWER_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_POWER_CTL_REGISTER. - - Example usage - @code - MSR_NEHALEM_POWER_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_POWER_CTL); - AsmWriteMsr64 (MSR_NEHALEM_POWER_CTL, Msr.Uint64); - @endcode - @note MSR_NEHALEM_POWER_CTL is defined as MSR_POWER_CTL in SDM. -**/ -#define MSR_NEHALEM_POWER_CTL 0x000001FC - -/** - MSR information returned for MSR index #MSR_NEHALEM_POWER_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Package. C1E Enable (R/W) When set to '1', will enable the - /// CPU to switch to the Minimum Enhanced Intel SpeedStep Technology - /// operating point when all execution cores enter MWAIT (C1). - /// - UINT32 C1EEnable:1; - UINT32 Reserved2:30; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_POWER_CTL_REGISTER; - - -/** - Thread. (RO). - - @param ECX MSR_NEHALEM_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PERF_GLOBAL_STATUS); - @endcode - @note MSR_NEHALEM_PERF_GLOBAL_STATUS is defined as MSR_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_NEHALEM_PERF_GLOBAL_STATUS 0x0000038E - -/** - MSR information returned for MSR index #MSR_NEHALEM_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:29; - /// - /// [Bit 61] UNC_Ovf Uncore overflowed if 1. - /// - UINT32 Ovf_Uncore:1; - UINT32 Reserved3:2; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Thread. (R/W). - - @param ECX MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER. - - Example usage - @code - MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL is defined as MSR_PERF_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL 0x00000390 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:29; - /// - /// [Bit 61] CLR_UNC_Ovf Set 1 to clear UNC_Ovf. - /// - UINT32 Ovf_Uncore:1; - UINT32 Reserved3:2; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PERF_GLOBAL_OVF_CTRL_REGISTER; - - -/** - Thread. See Section 18.8.1.1, "Processor Event Based Sampling (PEBS).". - - @param ECX MSR_NEHALEM_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_NEHALEM_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PEBS_ENABLE); - AsmWriteMsr64 (MSR_NEHALEM_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_NEHALEM_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). - /// - UINT32 PEBS_EN_PMC0:1; - /// - /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). - /// - UINT32 PEBS_EN_PMC1:1; - /// - /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). - /// - UINT32 PEBS_EN_PMC2:1; - /// - /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). - /// - UINT32 PEBS_EN_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). - /// - UINT32 LL_EN_PMC0:1; - /// - /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). - /// - UINT32 LL_EN_PMC1:1; - /// - /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). - /// - UINT32 LL_EN_PMC2:1; - /// - /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). - /// - UINT32 LL_EN_PMC3:1; - UINT32 Reserved2:28; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PEBS_ENABLE_REGISTER; - - -/** - Thread. See Section 18.8.1.2, "Load Latency Performance Monitoring - Facility.". - - @param ECX MSR_NEHALEM_PEBS_LD_LAT (0x000003F6) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_PEBS_LD_LAT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_PEBS_LD_LAT_REGISTER. - - Example usage - @code - MSR_NEHALEM_PEBS_LD_LAT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_PEBS_LD_LAT); - AsmWriteMsr64 (MSR_NEHALEM_PEBS_LD_LAT, Msr.Uint64); - @endcode - @note MSR_NEHALEM_PEBS_LD_LAT is defined as MSR_PEBS_LD_LAT in SDM. -**/ -#define MSR_NEHALEM_PEBS_LD_LAT 0x000003F6 - -/** - MSR information returned for MSR index #MSR_NEHALEM_PEBS_LD_LAT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Minimum threshold latency value of tagged load operation - /// that will be counted. (R/W). - /// - UINT32 MinimumThreshold:16; - UINT32 Reserved1:16; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_PEBS_LD_LAT_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_NEHALEM_PKG_C3_RESIDENCY (0x000003F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C3_RESIDENCY); - AsmWriteMsr64 (MSR_NEHALEM_PKG_C3_RESIDENCY, Msr); - @endcode - @note MSR_NEHALEM_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. -**/ -#define MSR_NEHALEM_PKG_C3_RESIDENCY 0x000003F8 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C6 states. Count at the same frequency as the TSC. - - @param ECX MSR_NEHALEM_PKG_C6_RESIDENCY (0x000003F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_NEHALEM_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_NEHALEM_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_NEHALEM_PKG_C6_RESIDENCY 0x000003F9 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C7 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C7 states. Count at the same frequency as the TSC. - - @param ECX MSR_NEHALEM_PKG_C7_RESIDENCY (0x000003FA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_PKG_C7_RESIDENCY); - AsmWriteMsr64 (MSR_NEHALEM_PKG_C7_RESIDENCY, Msr); - @endcode - @note MSR_NEHALEM_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. -**/ -#define MSR_NEHALEM_PKG_C7_RESIDENCY 0x000003FA - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_NEHALEM_CORE_C3_RESIDENCY (0x000003FC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_CORE_C3_RESIDENCY); - AsmWriteMsr64 (MSR_NEHALEM_CORE_C3_RESIDENCY, Msr); - @endcode - @note MSR_NEHALEM_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. -**/ -#define MSR_NEHALEM_CORE_C3_RESIDENCY 0x000003FC - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C6 states. Count at the same frequency as the TSC. - - @param ECX MSR_NEHALEM_CORE_C6_RESIDENCY (0x000003FD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_CORE_C6_RESIDENCY); - AsmWriteMsr64 (MSR_NEHALEM_CORE_C6_RESIDENCY, Msr); - @endcode - @note MSR_NEHALEM_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. -**/ -#define MSR_NEHALEM_CORE_C6_RESIDENCY 0x000003FD - - -/** - Thread. Last Branch Record n From IP (R/W) One of sixteen pairs of last - branch record registers on the last branch record stack. The From_IP part of - the stack contains pointers to the source instruction. See also: - Last - Branch Record Stack TOS at 1C9H - Section 17.7.1 and record format in - Section 17.4.8.1. - - @param ECX MSR_NEHALEM_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_NEHALEM_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. - MSR_NEHALEM_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. - @{ -**/ -#define MSR_NEHALEM_LASTBRANCH_0_FROM_IP 0x00000680 -#define MSR_NEHALEM_LASTBRANCH_1_FROM_IP 0x00000681 -#define MSR_NEHALEM_LASTBRANCH_2_FROM_IP 0x00000682 -#define MSR_NEHALEM_LASTBRANCH_3_FROM_IP 0x00000683 -#define MSR_NEHALEM_LASTBRANCH_4_FROM_IP 0x00000684 -#define MSR_NEHALEM_LASTBRANCH_5_FROM_IP 0x00000685 -#define MSR_NEHALEM_LASTBRANCH_6_FROM_IP 0x00000686 -#define MSR_NEHALEM_LASTBRANCH_7_FROM_IP 0x00000687 -#define MSR_NEHALEM_LASTBRANCH_8_FROM_IP 0x00000688 -#define MSR_NEHALEM_LASTBRANCH_9_FROM_IP 0x00000689 -#define MSR_NEHALEM_LASTBRANCH_10_FROM_IP 0x0000068A -#define MSR_NEHALEM_LASTBRANCH_11_FROM_IP 0x0000068B -#define MSR_NEHALEM_LASTBRANCH_12_FROM_IP 0x0000068C -#define MSR_NEHALEM_LASTBRANCH_13_FROM_IP 0x0000068D -#define MSR_NEHALEM_LASTBRANCH_14_FROM_IP 0x0000068E -#define MSR_NEHALEM_LASTBRANCH_15_FROM_IP 0x0000068F -/// @} - - -/** - Thread. Last Branch Record n To IP (R/W) One of sixteen pairs of last branch - record registers on the last branch record stack. This part of the stack - contains pointers to the destination instruction. - - @param ECX MSR_NEHALEM_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_NEHALEM_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_NEHALEM_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. - MSR_NEHALEM_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. - @{ -**/ -#define MSR_NEHALEM_LASTBRANCH_0_TO_IP 0x000006C0 -#define MSR_NEHALEM_LASTBRANCH_1_TO_IP 0x000006C1 -#define MSR_NEHALEM_LASTBRANCH_2_TO_IP 0x000006C2 -#define MSR_NEHALEM_LASTBRANCH_3_TO_IP 0x000006C3 -#define MSR_NEHALEM_LASTBRANCH_4_TO_IP 0x000006C4 -#define MSR_NEHALEM_LASTBRANCH_5_TO_IP 0x000006C5 -#define MSR_NEHALEM_LASTBRANCH_6_TO_IP 0x000006C6 -#define MSR_NEHALEM_LASTBRANCH_7_TO_IP 0x000006C7 -#define MSR_NEHALEM_LASTBRANCH_8_TO_IP 0x000006C8 -#define MSR_NEHALEM_LASTBRANCH_9_TO_IP 0x000006C9 -#define MSR_NEHALEM_LASTBRANCH_10_TO_IP 0x000006CA -#define MSR_NEHALEM_LASTBRANCH_11_TO_IP 0x000006CB -#define MSR_NEHALEM_LASTBRANCH_12_TO_IP 0x000006CC -#define MSR_NEHALEM_LASTBRANCH_13_TO_IP 0x000006CD -#define MSR_NEHALEM_LASTBRANCH_14_TO_IP 0x000006CE -#define MSR_NEHALEM_LASTBRANCH_15_TO_IP 0x000006CF -/// @} - - -/** - Package. - - @param ECX MSR_NEHALEM_GQ_SNOOP_MESF (0x00000301) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER. - - Example usage - @code - MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_NEHALEM_GQ_SNOOP_MESF); - AsmWriteMsr64 (MSR_NEHALEM_GQ_SNOOP_MESF, Msr.Uint64); - @endcode - @note MSR_NEHALEM_GQ_SNOOP_MESF is defined as MSR_GQ_SNOOP_MESF in SDM. -**/ -#define MSR_NEHALEM_GQ_SNOOP_MESF 0x00000301 - -/** - MSR information returned for MSR index #MSR_NEHALEM_GQ_SNOOP_MESF -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] From M to S (R/W). - /// - UINT32 FromMtoS:1; - /// - /// [Bit 1] From E to S (R/W). - /// - UINT32 FromEtoS:1; - /// - /// [Bit 2] From S to S (R/W). - /// - UINT32 FromStoS:1; - /// - /// [Bit 3] From F to S (R/W). - /// - UINT32 FromFtoS:1; - /// - /// [Bit 4] From M to I (R/W). - /// - UINT32 FromMtoI:1; - /// - /// [Bit 5] From E to I (R/W). - /// - UINT32 FromEtoI:1; - /// - /// [Bit 6] From S to I (R/W). - /// - UINT32 FromStoI:1; - /// - /// [Bit 7] From F to I (R/W). - /// - UINT32 FromFtoI:1; - UINT32 Reserved1:24; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_NEHALEM_GQ_SNOOP_MESF_REGISTER; - - -/** - Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL (0x00000391) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL is defined as MSR_UNCORE_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_CTRL 0x00000391 - - -/** - Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS (0x00000392) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS is defined as MSR_UNCORE_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_STATUS 0x00000392 - - -/** - Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL (0x00000393) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL is defined as MSR_UNCORE_PERF_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_UNCORE_PERF_GLOBAL_OVF_CTRL 0x00000393 - - -/** - Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_FIXED_CTR0 (0x00000394) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR0, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_FIXED_CTR0 is defined as MSR_UNCORE_FIXED_CTR0 in SDM. -**/ -#define MSR_NEHALEM_UNCORE_FIXED_CTR0 0x00000394 - - -/** - Package. See Section 18.8.2.1, "Uncore Performance Monitoring Management - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL (0x00000395) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL is defined as MSR_UNCORE_FIXED_CTR_CTRL in SDM. -**/ -#define MSR_NEHALEM_UNCORE_FIXED_CTR_CTRL 0x00000395 - - -/** - Package. See Section 18.8.2.3, "Uncore Address/Opcode Match MSR.". - - @param ECX MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH (0x00000396) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH is defined as MSR_UNCORE_ADDR_OPCODE_MATCH in SDM. -**/ -#define MSR_NEHALEM_UNCORE_ADDR_OPCODE_MATCH 0x00000396 - - -/** - Package. See Section 18.8.2.2, "Uncore Performance Event Configuration - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_PMCi - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PMC0); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PMC0, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_PMC0 is defined as MSR_UNCORE_PMC0 in SDM. - MSR_NEHALEM_UNCORE_PMC1 is defined as MSR_UNCORE_PMC1 in SDM. - MSR_NEHALEM_UNCORE_PMC2 is defined as MSR_UNCORE_PMC2 in SDM. - MSR_NEHALEM_UNCORE_PMC3 is defined as MSR_UNCORE_PMC3 in SDM. - MSR_NEHALEM_UNCORE_PMC4 is defined as MSR_UNCORE_PMC4 in SDM. - MSR_NEHALEM_UNCORE_PMC5 is defined as MSR_UNCORE_PMC5 in SDM. - MSR_NEHALEM_UNCORE_PMC6 is defined as MSR_UNCORE_PMC6 in SDM. - MSR_NEHALEM_UNCORE_PMC7 is defined as MSR_UNCORE_PMC7 in SDM. - @{ -**/ -#define MSR_NEHALEM_UNCORE_PMC0 0x000003B0 -#define MSR_NEHALEM_UNCORE_PMC1 0x000003B1 -#define MSR_NEHALEM_UNCORE_PMC2 0x000003B2 -#define MSR_NEHALEM_UNCORE_PMC3 0x000003B3 -#define MSR_NEHALEM_UNCORE_PMC4 0x000003B4 -#define MSR_NEHALEM_UNCORE_PMC5 0x000003B5 -#define MSR_NEHALEM_UNCORE_PMC6 0x000003B6 -#define MSR_NEHALEM_UNCORE_PMC7 0x000003B7 -/// @} - -/** - Package. See Section 18.8.2.2, "Uncore Performance Event Configuration - Facility.". - - @param ECX MSR_NEHALEM_UNCORE_PERFEVTSELi - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_UNCORE_PERFEVTSEL0); - AsmWriteMsr64 (MSR_NEHALEM_UNCORE_PERFEVTSEL0, Msr); - @endcode - @note MSR_NEHALEM_UNCORE_PERFEVTSEL0 is defined as MSR_UNCORE_PERFEVTSEL0 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL1 is defined as MSR_UNCORE_PERFEVTSEL1 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL2 is defined as MSR_UNCORE_PERFEVTSEL2 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL3 is defined as MSR_UNCORE_PERFEVTSEL3 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL4 is defined as MSR_UNCORE_PERFEVTSEL4 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL5 is defined as MSR_UNCORE_PERFEVTSEL5 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL6 is defined as MSR_UNCORE_PERFEVTSEL6 in SDM. - MSR_NEHALEM_UNCORE_PERFEVTSEL7 is defined as MSR_UNCORE_PERFEVTSEL7 in SDM. - @{ -**/ -#define MSR_NEHALEM_UNCORE_PERFEVTSEL0 0x000003C0 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL1 0x000003C1 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL2 0x000003C2 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL3 0x000003C3 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL4 0x000003C4 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL5 0x000003C5 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL6 0x000003C6 -#define MSR_NEHALEM_UNCORE_PERFEVTSEL7 0x000003C7 -/// @} - - -/** - Package. Uncore W-box perfmon fixed counter. - - @param ECX MSR_NEHALEM_W_PMON_FIXED_CTR (0x00000394) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_FIXED_CTR is defined as MSR_W_PMON_FIXED_CTR in SDM. -**/ -#define MSR_NEHALEM_W_PMON_FIXED_CTR 0x00000394 - - -/** - Package. Uncore U-box perfmon fixed counter control MSR. - - @param ECX MSR_NEHALEM_W_PMON_FIXED_CTR_CTL (0x00000395) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR_CTL); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_FIXED_CTR_CTL, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_FIXED_CTR_CTL is defined as MSR_W_PMON_FIXED_CTR_CTL in SDM. -**/ -#define MSR_NEHALEM_W_PMON_FIXED_CTR_CTL 0x00000395 - - -/** - Package. Uncore U-box perfmon global control MSR. - - @param ECX MSR_NEHALEM_U_PMON_GLOBAL_CTRL (0x00000C00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_CTRL, Msr); - @endcode - @note MSR_NEHALEM_U_PMON_GLOBAL_CTRL is defined as MSR_U_PMON_GLOBAL_CTRL in SDM. -**/ -#define MSR_NEHALEM_U_PMON_GLOBAL_CTRL 0x00000C00 - - -/** - Package. Uncore U-box perfmon global status MSR. - - @param ECX MSR_NEHALEM_U_PMON_GLOBAL_STATUS (0x00000C01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_STATUS, Msr); - @endcode - @note MSR_NEHALEM_U_PMON_GLOBAL_STATUS is defined as MSR_U_PMON_GLOBAL_STATUS in SDM. -**/ -#define MSR_NEHALEM_U_PMON_GLOBAL_STATUS 0x00000C01 - - -/** - Package. Uncore U-box perfmon global overflow control MSR. - - @param ECX MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL (0x00000C02) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL is defined as MSR_U_PMON_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_U_PMON_GLOBAL_OVF_CTRL 0x00000C02 - - -/** - Package. Uncore U-box perfmon event select MSR. - - @param ECX MSR_NEHALEM_U_PMON_EVNT_SEL (0x00000C10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_EVNT_SEL); - AsmWriteMsr64 (MSR_NEHALEM_U_PMON_EVNT_SEL, Msr); - @endcode - @note MSR_NEHALEM_U_PMON_EVNT_SEL is defined as MSR_U_PMON_EVNT_SEL in SDM. -**/ -#define MSR_NEHALEM_U_PMON_EVNT_SEL 0x00000C10 - - -/** - Package. Uncore U-box perfmon counter MSR. - - @param ECX MSR_NEHALEM_U_PMON_CTR (0x00000C11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_U_PMON_CTR); - AsmWriteMsr64 (MSR_NEHALEM_U_PMON_CTR, Msr); - @endcode - @note MSR_NEHALEM_U_PMON_CTR is defined as MSR_U_PMON_CTR in SDM. -**/ -#define MSR_NEHALEM_U_PMON_CTR 0x00000C11 - - -/** - Package. Uncore B-box 0 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_B0_PMON_BOX_CTRL (0x00000C20) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_BOX_CTRL is defined as MSR_B0_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_BOX_CTRL 0x00000C20 - - -/** - Package. Uncore B-box 0 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_B0_PMON_BOX_STATUS (0x00000C21) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_BOX_STATUS is defined as MSR_B0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_BOX_STATUS 0x00000C21 - - -/** - Package. Uncore B-box 0 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL (0x00000C22) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL is defined as MSR_B0_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_BOX_OVF_CTRL 0x00000C22 - - -/** - Package. Uncore B-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL0 (0x00000C30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_EVNT_SEL0 is defined as MSR_B0_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_EVNT_SEL0 0x00000C30 - - -/** - Package. Uncore B-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B0_PMON_CTR0 (0x00000C31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_CTR0 is defined as MSR_B0_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_CTR0 0x00000C31 - - -/** - Package. Uncore B-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL1 (0x00000C32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_EVNT_SEL1 is defined as MSR_B0_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_EVNT_SEL1 0x00000C32 - - -/** - Package. Uncore B-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B0_PMON_CTR1 (0x00000C33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_CTR1 is defined as MSR_B0_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_CTR1 0x00000C33 - - -/** - Package. Uncore B-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL2 (0x00000C34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_EVNT_SEL2 is defined as MSR_B0_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_EVNT_SEL2 0x00000C34 - - -/** - Package. Uncore B-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B0_PMON_CTR2 (0x00000C35) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_CTR2 is defined as MSR_B0_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_CTR2 0x00000C35 - - -/** - Package. Uncore B-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B0_PMON_EVNT_SEL3 (0x00000C36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_EVNT_SEL3 is defined as MSR_B0_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_EVNT_SEL3 0x00000C36 - - -/** - Package. Uncore B-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B0_PMON_CTR3 (0x00000C37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_CTR3 is defined as MSR_B0_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_CTR3 0x00000C37 - - -/** - Package. Uncore S-box 0 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_S0_PMON_BOX_CTRL (0x00000C40) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_BOX_CTRL is defined as MSR_S0_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_BOX_CTRL 0x00000C40 - - -/** - Package. Uncore S-box 0 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_S0_PMON_BOX_STATUS (0x00000C41) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_BOX_STATUS is defined as MSR_S0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_BOX_STATUS 0x00000C41 - - -/** - Package. Uncore S-box 0 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL (0x00000C42) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL is defined as MSR_S0_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_BOX_OVF_CTRL 0x00000C42 - - -/** - Package. Uncore S-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL0 (0x00000C50) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_EVNT_SEL0 is defined as MSR_S0_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_EVNT_SEL0 0x00000C50 - - -/** - Package. Uncore S-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S0_PMON_CTR0 (0x00000C51) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_CTR0 is defined as MSR_S0_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_CTR0 0x00000C51 - - -/** - Package. Uncore S-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL1 (0x00000C52) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_EVNT_SEL1 is defined as MSR_S0_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_EVNT_SEL1 0x00000C52 - - -/** - Package. Uncore S-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S0_PMON_CTR1 (0x00000C53) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_CTR1 is defined as MSR_S0_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_CTR1 0x00000C53 - - -/** - Package. Uncore S-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL2 (0x00000C54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_EVNT_SEL2 is defined as MSR_S0_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_EVNT_SEL2 0x00000C54 - - -/** - Package. Uncore S-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S0_PMON_CTR2 (0x00000C55) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_CTR2 is defined as MSR_S0_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_CTR2 0x00000C55 - - -/** - Package. Uncore S-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S0_PMON_EVNT_SEL3 (0x00000C56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_EVNT_SEL3 is defined as MSR_S0_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_EVNT_SEL3 0x00000C56 - - -/** - Package. Uncore S-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S0_PMON_CTR3 (0x00000C57) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_CTR3 is defined as MSR_S0_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_CTR3 0x00000C57 - - -/** - Package. Uncore B-box 1 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_B1_PMON_BOX_CTRL (0x00000C60) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_BOX_CTRL is defined as MSR_B1_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_BOX_CTRL 0x00000C60 - - -/** - Package. Uncore B-box 1 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_B1_PMON_BOX_STATUS (0x00000C61) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_BOX_STATUS is defined as MSR_B1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_BOX_STATUS 0x00000C61 - - -/** - Package. Uncore B-box 1 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL (0x00000C62) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL is defined as MSR_B1_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_BOX_OVF_CTRL 0x00000C62 - - -/** - Package. Uncore B-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL0 (0x00000C70) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_EVNT_SEL0 is defined as MSR_B1_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_EVNT_SEL0 0x00000C70 - - -/** - Package. Uncore B-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B1_PMON_CTR0 (0x00000C71) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_CTR0 is defined as MSR_B1_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_CTR0 0x00000C71 - - -/** - Package. Uncore B-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL1 (0x00000C72) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_EVNT_SEL1 is defined as MSR_B1_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_EVNT_SEL1 0x00000C72 - - -/** - Package. Uncore B-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B1_PMON_CTR1 (0x00000C73) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_CTR1 is defined as MSR_B1_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_CTR1 0x00000C73 - - -/** - Package. Uncore B-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL2 (0x00000C74) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_EVNT_SEL2 is defined as MSR_B1_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_EVNT_SEL2 0x00000C74 - - -/** - Package. Uncore B-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B1_PMON_CTR2 (0x00000C75) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_CTR2 is defined as MSR_B1_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_CTR2 0x00000C75 - - -/** - Package. Uncore B-box 1vperfmon event select MSR. - - @param ECX MSR_NEHALEM_B1_PMON_EVNT_SEL3 (0x00000C76) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_EVNT_SEL3 is defined as MSR_B1_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_EVNT_SEL3 0x00000C76 - - -/** - Package. Uncore B-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_B1_PMON_CTR3 (0x00000C77) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_CTR3 is defined as MSR_B1_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_CTR3 0x00000C77 - - -/** - Package. Uncore W-box perfmon local box control MSR. - - @param ECX MSR_NEHALEM_W_PMON_BOX_CTRL (0x00000C80) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_BOX_CTRL is defined as MSR_W_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_W_PMON_BOX_CTRL 0x00000C80 - - -/** - Package. Uncore W-box perfmon local box status MSR. - - @param ECX MSR_NEHALEM_W_PMON_BOX_STATUS (0x00000C81) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_BOX_STATUS is defined as MSR_W_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_W_PMON_BOX_STATUS 0x00000C81 - - -/** - Package. Uncore W-box perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_W_PMON_BOX_OVF_CTRL (0x00000C82) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_BOX_OVF_CTRL is defined as MSR_W_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_W_PMON_BOX_OVF_CTRL 0x00000C82 - - -/** - Package. Uncore W-box perfmon event select MSR. - - @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL0 (0x00000C90) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_EVNT_SEL0 is defined as MSR_W_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_EVNT_SEL0 0x00000C90 - - -/** - Package. Uncore W-box perfmon counter MSR. - - @param ECX MSR_NEHALEM_W_PMON_CTR0 (0x00000C91) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_CTR0 is defined as MSR_W_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_CTR0 0x00000C91 - - -/** - Package. Uncore W-box perfmon event select MSR. - - @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL1 (0x00000C92) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_EVNT_SEL1 is defined as MSR_W_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_EVNT_SEL1 0x00000C92 - - -/** - Package. Uncore W-box perfmon counter MSR. - - @param ECX MSR_NEHALEM_W_PMON_CTR1 (0x00000C93) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_CTR1 is defined as MSR_W_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_CTR1 0x00000C93 - - -/** - Package. Uncore W-box perfmon event select MSR. - - @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL2 (0x00000C94) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_EVNT_SEL2 is defined as MSR_W_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_EVNT_SEL2 0x00000C94 - - -/** - Package. Uncore W-box perfmon counter MSR. - - @param ECX MSR_NEHALEM_W_PMON_CTR2 (0x00000C95) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_CTR2 is defined as MSR_W_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_CTR2 0x00000C95 - - -/** - Package. Uncore W-box perfmon event select MSR. - - @param ECX MSR_NEHALEM_W_PMON_EVNT_SEL3 (0x00000C96) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_EVNT_SEL3 is defined as MSR_W_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_EVNT_SEL3 0x00000C96 - - -/** - Package. Uncore W-box perfmon counter MSR. - - @param ECX MSR_NEHALEM_W_PMON_CTR3 (0x00000C97) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_W_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_W_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_W_PMON_CTR3 is defined as MSR_W_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_W_PMON_CTR3 0x00000C97 - - -/** - Package. Uncore M-box 0 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_M0_PMON_BOX_CTRL (0x00000CA0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_BOX_CTRL is defined as MSR_M0_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_BOX_CTRL 0x00000CA0 - - -/** - Package. Uncore M-box 0 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_M0_PMON_BOX_STATUS (0x00000CA1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_BOX_STATUS is defined as MSR_M0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_BOX_STATUS 0x00000CA1 - - -/** - Package. Uncore M-box 0 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL (0x00000CA2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL is defined as MSR_M0_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_BOX_OVF_CTRL 0x00000CA2 - - -/** - Package. Uncore M-box 0 perfmon time stamp unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_TIMESTAMP (0x00000CA4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_TIMESTAMP); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_TIMESTAMP, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_TIMESTAMP is defined as MSR_M0_PMON_TIMESTAMP in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_TIMESTAMP 0x00000CA4 - - -/** - Package. Uncore M-box 0 perfmon DSP unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_DSP (0x00000CA5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_DSP); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_DSP, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_DSP is defined as MSR_M0_PMON_DSP in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_DSP 0x00000CA5 - - -/** - Package. Uncore M-box 0 perfmon ISS unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_ISS (0x00000CA6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ISS); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ISS, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_ISS is defined as MSR_M0_PMON_ISS in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_ISS 0x00000CA6 - - -/** - Package. Uncore M-box 0 perfmon MAP unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_MAP (0x00000CA7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MAP); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MAP, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_MAP is defined as MSR_M0_PMON_MAP in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_MAP 0x00000CA7 - - -/** - Package. Uncore M-box 0 perfmon MIC THR select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_MSC_THR (0x00000CA8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MSC_THR); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MSC_THR, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_MSC_THR is defined as MSR_M0_PMON_MSC_THR in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_MSC_THR 0x00000CA8 - - -/** - Package. Uncore M-box 0 perfmon PGT unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_PGT (0x00000CA9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_PGT); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_PGT, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_PGT is defined as MSR_M0_PMON_PGT in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_PGT 0x00000CA9 - - -/** - Package. Uncore M-box 0 perfmon PLD unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_PLD (0x00000CAA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_PLD); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_PLD, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_PLD is defined as MSR_M0_PMON_PLD in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_PLD 0x00000CAA - - -/** - Package. Uncore M-box 0 perfmon ZDP unit select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_ZDP (0x00000CAB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ZDP); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ZDP, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_ZDP is defined as MSR_M0_PMON_ZDP in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_ZDP 0x00000CAB - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL0 (0x00000CB0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL0 is defined as MSR_M0_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL0 0x00000CB0 - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR0 (0x00000CB1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR0 is defined as MSR_M0_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR0 0x00000CB1 - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL1 (0x00000CB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL1 is defined as MSR_M0_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL1 0x00000CB2 - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR1 (0x00000CB3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR1 is defined as MSR_M0_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR1 0x00000CB3 - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL2 (0x00000CB4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL2 is defined as MSR_M0_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL2 0x00000CB4 - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR2 (0x00000CB5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR2 is defined as MSR_M0_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR2 0x00000CB5 - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL3 (0x00000CB6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL3 is defined as MSR_M0_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL3 0x00000CB6 - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR3 (0x00000CB7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR3 is defined as MSR_M0_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR3 0x00000CB7 - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL4 (0x00000CB8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL4 is defined as MSR_M0_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL4 0x00000CB8 - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR4 (0x00000CB9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR4 is defined as MSR_M0_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR4 0x00000CB9 - - -/** - Package. Uncore M-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M0_PMON_EVNT_SEL5 (0x00000CBA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_EVNT_SEL5 is defined as MSR_M0_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_EVNT_SEL5 0x00000CBA - - -/** - Package. Uncore M-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M0_PMON_CTR5 (0x00000CBB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_CTR5 is defined as MSR_M0_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_CTR5 0x00000CBB - - -/** - Package. Uncore S-box 1 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_S1_PMON_BOX_CTRL (0x00000CC0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_BOX_CTRL is defined as MSR_S1_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_BOX_CTRL 0x00000CC0 - - -/** - Package. Uncore S-box 1 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_S1_PMON_BOX_STATUS (0x00000CC1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_BOX_STATUS is defined as MSR_S1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_BOX_STATUS 0x00000CC1 - - -/** - Package. Uncore S-box 1 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL (0x00000CC2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL is defined as MSR_S1_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_BOX_OVF_CTRL 0x00000CC2 - - -/** - Package. Uncore S-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL0 (0x00000CD0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_EVNT_SEL0 is defined as MSR_S1_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_EVNT_SEL0 0x00000CD0 - - -/** - Package. Uncore S-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S1_PMON_CTR0 (0x00000CD1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_CTR0 is defined as MSR_S1_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_CTR0 0x00000CD1 - - -/** - Package. Uncore S-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL1 (0x00000CD2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_EVNT_SEL1 is defined as MSR_S1_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_EVNT_SEL1 0x00000CD2 - - -/** - Package. Uncore S-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S1_PMON_CTR1 (0x00000CD3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_CTR1 is defined as MSR_S1_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_CTR1 0x00000CD3 - - -/** - Package. Uncore S-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL2 (0x00000CD4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_EVNT_SEL2 is defined as MSR_S1_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_EVNT_SEL2 0x00000CD4 - - -/** - Package. Uncore S-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S1_PMON_CTR2 (0x00000CD5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_CTR2 is defined as MSR_S1_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_CTR2 0x00000CD5 - - -/** - Package. Uncore S-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_S1_PMON_EVNT_SEL3 (0x00000CD6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_EVNT_SEL3 is defined as MSR_S1_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_EVNT_SEL3 0x00000CD6 - - -/** - Package. Uncore S-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_S1_PMON_CTR3 (0x00000CD7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_CTR3 is defined as MSR_S1_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_CTR3 0x00000CD7 - - -/** - Package. Uncore M-box 1 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_M1_PMON_BOX_CTRL (0x00000CE0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_BOX_CTRL is defined as MSR_M1_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_BOX_CTRL 0x00000CE0 - - -/** - Package. Uncore M-box 1 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_M1_PMON_BOX_STATUS (0x00000CE1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_BOX_STATUS is defined as MSR_M1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_BOX_STATUS 0x00000CE1 - - -/** - Package. Uncore M-box 1 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL (0x00000CE2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL is defined as MSR_M1_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_BOX_OVF_CTRL 0x00000CE2 - - -/** - Package. Uncore M-box 1 perfmon time stamp unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_TIMESTAMP (0x00000CE4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_TIMESTAMP); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_TIMESTAMP, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_TIMESTAMP is defined as MSR_M1_PMON_TIMESTAMP in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_TIMESTAMP 0x00000CE4 - - -/** - Package. Uncore M-box 1 perfmon DSP unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_DSP (0x00000CE5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_DSP); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_DSP, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_DSP is defined as MSR_M1_PMON_DSP in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_DSP 0x00000CE5 - - -/** - Package. Uncore M-box 1 perfmon ISS unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_ISS (0x00000CE6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ISS); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ISS, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_ISS is defined as MSR_M1_PMON_ISS in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_ISS 0x00000CE6 - - -/** - Package. Uncore M-box 1 perfmon MAP unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_MAP (0x00000CE7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MAP); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MAP, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_MAP is defined as MSR_M1_PMON_MAP in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_MAP 0x00000CE7 - - -/** - Package. Uncore M-box 1 perfmon MIC THR select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_MSC_THR (0x00000CE8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MSC_THR); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MSC_THR, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_MSC_THR is defined as MSR_M1_PMON_MSC_THR in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_MSC_THR 0x00000CE8 - - -/** - Package. Uncore M-box 1 perfmon PGT unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_PGT (0x00000CE9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_PGT); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_PGT, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_PGT is defined as MSR_M1_PMON_PGT in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_PGT 0x00000CE9 - - -/** - Package. Uncore M-box 1 perfmon PLD unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_PLD (0x00000CEA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_PLD); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_PLD, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_PLD is defined as MSR_M1_PMON_PLD in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_PLD 0x00000CEA - - -/** - Package. Uncore M-box 1 perfmon ZDP unit select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_ZDP (0x00000CEB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ZDP); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ZDP, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_ZDP is defined as MSR_M1_PMON_ZDP in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_ZDP 0x00000CEB - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL0 (0x00000CF0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL0 is defined as MSR_M1_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL0 0x00000CF0 - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR0 (0x00000CF1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR0 is defined as MSR_M1_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR0 0x00000CF1 - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL1 (0x00000CF2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL1 is defined as MSR_M1_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL1 0x00000CF2 - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR1 (0x00000CF3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR1 is defined as MSR_M1_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR1 0x00000CF3 - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL2 (0x00000CF4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL2 is defined as MSR_M1_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL2 0x00000CF4 - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR2 (0x00000CF5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR2 is defined as MSR_M1_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR2 0x00000CF5 - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL3 (0x00000CF6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL3 is defined as MSR_M1_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL3 0x00000CF6 - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR3 (0x00000CF7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR3 is defined as MSR_M1_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR3 0x00000CF7 - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL4 (0x00000CF8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL4 is defined as MSR_M1_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL4 0x00000CF8 - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR4 (0x00000CF9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR4 is defined as MSR_M1_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR4 0x00000CF9 - - -/** - Package. Uncore M-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_M1_PMON_EVNT_SEL5 (0x00000CFA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_EVNT_SEL5 is defined as MSR_M1_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_EVNT_SEL5 0x00000CFA - - -/** - Package. Uncore M-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_M1_PMON_CTR5 (0x00000CFB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_CTR5 is defined as MSR_M1_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_CTR5 0x00000CFB - - -/** - Package. Uncore C-box 0 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C0_PMON_BOX_CTRL (0x00000D00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_BOX_CTRL is defined as MSR_C0_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_BOX_CTRL 0x00000D00 - - -/** - Package. Uncore C-box 0 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C0_PMON_BOX_STATUS (0x00000D01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_BOX_STATUS is defined as MSR_C0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_BOX_STATUS 0x00000D01 - - -/** - Package. Uncore C-box 0 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL (0x00000D02) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL is defined as MSR_C0_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_BOX_OVF_CTRL 0x00000D02 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL0 (0x00000D10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL0 is defined as MSR_C0_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL0 0x00000D10 - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR0 (0x00000D11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR0 0x00000D11 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL1 (0x00000D12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL1 is defined as MSR_C0_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL1 0x00000D12 - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR1 (0x00000D13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR1 0x00000D13 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL2 (0x00000D14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL2 is defined as MSR_C0_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL2 0x00000D14 - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR2 (0x00000D15) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR2 0x00000D15 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL3 (0x00000D16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL3 is defined as MSR_C0_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL3 0x00000D16 - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR3 (0x00000D17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR3 0x00000D17 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL4 (0x00000D18) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL4 is defined as MSR_C0_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL4 0x00000D18 - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR4 (0x00000D19) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR4 is defined as MSR_C0_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR4 0x00000D19 - - -/** - Package. Uncore C-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C0_PMON_EVNT_SEL5 (0x00000D1A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_EVNT_SEL5 is defined as MSR_C0_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_EVNT_SEL5 0x00000D1A - - -/** - Package. Uncore C-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C0_PMON_CTR5 (0x00000D1B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C0_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C0_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C0_PMON_CTR5 is defined as MSR_C0_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C0_PMON_CTR5 0x00000D1B - - -/** - Package. Uncore C-box 4 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C4_PMON_BOX_CTRL (0x00000D20) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_BOX_CTRL is defined as MSR_C4_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_BOX_CTRL 0x00000D20 - - -/** - Package. Uncore C-box 4 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C4_PMON_BOX_STATUS (0x00000D21) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_BOX_STATUS is defined as MSR_C4_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_BOX_STATUS 0x00000D21 - - -/** - Package. Uncore C-box 4 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL (0x00000D22) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL is defined as MSR_C4_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_BOX_OVF_CTRL 0x00000D22 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL0 (0x00000D30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL0 is defined as MSR_C4_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL0 0x00000D30 - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR0 (0x00000D31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR0 0x00000D31 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL1 (0x00000D32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL1 is defined as MSR_C4_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL1 0x00000D32 - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR1 (0x00000D33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR1 0x00000D33 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL2 (0x00000D34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL2 is defined as MSR_C4_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL2 0x00000D34 - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR2 (0x00000D35) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR2 0x00000D35 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL3 (0x00000D36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL3 is defined as MSR_C4_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL3 0x00000D36 - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR3 (0x00000D37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR3 0x00000D37 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL4 (0x00000D38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL4 is defined as MSR_C4_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL4 0x00000D38 - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR4 (0x00000D39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR4 is defined as MSR_C4_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR4 0x00000D39 - - -/** - Package. Uncore C-box 4 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C4_PMON_EVNT_SEL5 (0x00000D3A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_EVNT_SEL5 is defined as MSR_C4_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_EVNT_SEL5 0x00000D3A - - -/** - Package. Uncore C-box 4 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C4_PMON_CTR5 (0x00000D3B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C4_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C4_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C4_PMON_CTR5 is defined as MSR_C4_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C4_PMON_CTR5 0x00000D3B - - -/** - Package. Uncore C-box 2 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C2_PMON_BOX_CTRL (0x00000D40) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_BOX_CTRL is defined as MSR_C2_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_BOX_CTRL 0x00000D40 - - -/** - Package. Uncore C-box 2 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C2_PMON_BOX_STATUS (0x00000D41) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_BOX_STATUS is defined as MSR_C2_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_BOX_STATUS 0x00000D41 - - -/** - Package. Uncore C-box 2 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL (0x00000D42) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL is defined as MSR_C2_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_BOX_OVF_CTRL 0x00000D42 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL0 (0x00000D50) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL0 is defined as MSR_C2_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL0 0x00000D50 - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR0 (0x00000D51) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR0 0x00000D51 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL1 (0x00000D52) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL1 is defined as MSR_C2_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL1 0x00000D52 - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR1 (0x00000D53) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR1 0x00000D53 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL2 (0x00000D54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL2 is defined as MSR_C2_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL2 0x00000D54 - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR2 (0x00000D55) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR2 0x00000D55 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL3 (0x00000D56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL3 is defined as MSR_C2_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL3 0x00000D56 - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR3 (0x00000D57) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR3 0x00000D57 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL4 (0x00000D58) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL4 is defined as MSR_C2_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL4 0x00000D58 - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR4 (0x00000D59) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR4 is defined as MSR_C2_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR4 0x00000D59 - - -/** - Package. Uncore C-box 2 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C2_PMON_EVNT_SEL5 (0x00000D5A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_EVNT_SEL5 is defined as MSR_C2_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_EVNT_SEL5 0x00000D5A - - -/** - Package. Uncore C-box 2 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C2_PMON_CTR5 (0x00000D5B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C2_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C2_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C2_PMON_CTR5 is defined as MSR_C2_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C2_PMON_CTR5 0x00000D5B - - -/** - Package. Uncore C-box 6 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C6_PMON_BOX_CTRL (0x00000D60) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_BOX_CTRL is defined as MSR_C6_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_BOX_CTRL 0x00000D60 - - -/** - Package. Uncore C-box 6 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C6_PMON_BOX_STATUS (0x00000D61) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_BOX_STATUS is defined as MSR_C6_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_BOX_STATUS 0x00000D61 - - -/** - Package. Uncore C-box 6 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL (0x00000D62) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL is defined as MSR_C6_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_BOX_OVF_CTRL 0x00000D62 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL0 (0x00000D70) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL0 is defined as MSR_C6_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL0 0x00000D70 - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR0 (0x00000D71) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR0 0x00000D71 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL1 (0x00000D72) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL1 is defined as MSR_C6_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL1 0x00000D72 - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR1 (0x00000D73) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR1 0x00000D73 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL2 (0x00000D74) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL2 is defined as MSR_C6_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL2 0x00000D74 - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR2 (0x00000D75) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR2 0x00000D75 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL3 (0x00000D76) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL3 is defined as MSR_C6_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL3 0x00000D76 - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR3 (0x00000D77) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR3 0x00000D77 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL4 (0x00000D78) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL4 is defined as MSR_C6_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL4 0x00000D78 - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR4 (0x00000D79) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR4 is defined as MSR_C6_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR4 0x00000D79 - - -/** - Package. Uncore C-box 6 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C6_PMON_EVNT_SEL5 (0x00000D7A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_EVNT_SEL5 is defined as MSR_C6_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_EVNT_SEL5 0x00000D7A - - -/** - Package. Uncore C-box 6 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C6_PMON_CTR5 (0x00000D7B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C6_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C6_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C6_PMON_CTR5 is defined as MSR_C6_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C6_PMON_CTR5 0x00000D7B - - -/** - Package. Uncore C-box 1 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C1_PMON_BOX_CTRL (0x00000D80) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_BOX_CTRL is defined as MSR_C1_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_BOX_CTRL 0x00000D80 - - -/** - Package. Uncore C-box 1 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C1_PMON_BOX_STATUS (0x00000D81) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_BOX_STATUS is defined as MSR_C1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_BOX_STATUS 0x00000D81 - - -/** - Package. Uncore C-box 1 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL (0x00000D82) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL is defined as MSR_C1_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_BOX_OVF_CTRL 0x00000D82 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL0 (0x00000D90) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL0 is defined as MSR_C1_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL0 0x00000D90 - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR0 (0x00000D91) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR0 0x00000D91 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL1 (0x00000D92) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL1 is defined as MSR_C1_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL1 0x00000D92 - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR1 (0x00000D93) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR1 0x00000D93 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL2 (0x00000D94) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL2 is defined as MSR_C1_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL2 0x00000D94 - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR2 (0x00000D95) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR2 0x00000D95 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL3 (0x00000D96) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL3 is defined as MSR_C1_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL3 0x00000D96 - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR3 (0x00000D97) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR3 0x00000D97 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL4 (0x00000D98) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL4 is defined as MSR_C1_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL4 0x00000D98 - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR4 (0x00000D99) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR4 is defined as MSR_C1_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR4 0x00000D99 - - -/** - Package. Uncore C-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C1_PMON_EVNT_SEL5 (0x00000D9A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_EVNT_SEL5 is defined as MSR_C1_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_EVNT_SEL5 0x00000D9A - - -/** - Package. Uncore C-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C1_PMON_CTR5 (0x00000D9B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C1_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C1_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C1_PMON_CTR5 is defined as MSR_C1_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C1_PMON_CTR5 0x00000D9B - - -/** - Package. Uncore C-box 5 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C5_PMON_BOX_CTRL (0x00000DA0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_BOX_CTRL is defined as MSR_C5_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_BOX_CTRL 0x00000DA0 - - -/** - Package. Uncore C-box 5 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C5_PMON_BOX_STATUS (0x00000DA1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_BOX_STATUS is defined as MSR_C5_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_BOX_STATUS 0x00000DA1 - - -/** - Package. Uncore C-box 5 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL (0x00000DA2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL is defined as MSR_C5_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_BOX_OVF_CTRL 0x00000DA2 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL0 (0x00000DB0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL0 is defined as MSR_C5_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL0 0x00000DB0 - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR0 (0x00000DB1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR0 0x00000DB1 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL1 (0x00000DB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL1 is defined as MSR_C5_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL1 0x00000DB2 - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR1 (0x00000DB3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR1 0x00000DB3 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL2 (0x00000DB4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL2 is defined as MSR_C5_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL2 0x00000DB4 - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR2 (0x00000DB5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR2 0x00000DB5 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL3 (0x00000DB6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL3 is defined as MSR_C5_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL3 0x00000DB6 - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR3 (0x00000DB7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR3 0x00000DB7 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL4 (0x00000DB8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL4 is defined as MSR_C5_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL4 0x00000DB8 - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR4 (0x00000DB9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR4 is defined as MSR_C5_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR4 0x00000DB9 - - -/** - Package. Uncore C-box 5 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C5_PMON_EVNT_SEL5 (0x00000DBA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_EVNT_SEL5 is defined as MSR_C5_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_EVNT_SEL5 0x00000DBA - - -/** - Package. Uncore C-box 5 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C5_PMON_CTR5 (0x00000DBB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C5_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C5_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C5_PMON_CTR5 is defined as MSR_C5_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C5_PMON_CTR5 0x00000DBB - - -/** - Package. Uncore C-box 3 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C3_PMON_BOX_CTRL (0x00000DC0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_BOX_CTRL is defined as MSR_C3_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_BOX_CTRL 0x00000DC0 - - -/** - Package. Uncore C-box 3 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C3_PMON_BOX_STATUS (0x00000DC1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_BOX_STATUS is defined as MSR_C3_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_BOX_STATUS 0x00000DC1 - - -/** - Package. Uncore C-box 3 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL (0x00000DC2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL is defined as MSR_C3_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_BOX_OVF_CTRL 0x00000DC2 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL0 (0x00000DD0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL0 is defined as MSR_C3_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL0 0x00000DD0 - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR0 (0x00000DD1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR0 0x00000DD1 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL1 (0x00000DD2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL1 is defined as MSR_C3_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL1 0x00000DD2 - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR1 (0x00000DD3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR1 0x00000DD3 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL2 (0x00000DD4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL2 is defined as MSR_C3_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL2 0x00000DD4 - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR2 (0x00000DD5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR2 0x00000DD5 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL3 (0x00000DD6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL3 is defined as MSR_C3_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL3 0x00000DD6 - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR3 (0x00000DD7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR3 0x00000DD7 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL4 (0x00000DD8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL4 is defined as MSR_C3_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL4 0x00000DD8 - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR4 (0x00000DD9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR4 is defined as MSR_C3_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR4 0x00000DD9 - - -/** - Package. Uncore C-box 3 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C3_PMON_EVNT_SEL5 (0x00000DDA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_EVNT_SEL5 is defined as MSR_C3_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_EVNT_SEL5 0x00000DDA - - -/** - Package. Uncore C-box 3 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C3_PMON_CTR5 (0x00000DDB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C3_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C3_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C3_PMON_CTR5 is defined as MSR_C3_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C3_PMON_CTR5 0x00000DDB - - -/** - Package. Uncore C-box 7 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_C7_PMON_BOX_CTRL (0x00000DE0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_BOX_CTRL is defined as MSR_C7_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_BOX_CTRL 0x00000DE0 - - -/** - Package. Uncore C-box 7 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_C7_PMON_BOX_STATUS (0x00000DE1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_BOX_STATUS is defined as MSR_C7_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_BOX_STATUS 0x00000DE1 - - -/** - Package. Uncore C-box 7 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL (0x00000DE2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL is defined as MSR_C7_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_BOX_OVF_CTRL 0x00000DE2 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL0 (0x00000DF0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL0 is defined as MSR_C7_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL0 0x00000DF0 - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR0 (0x00000DF1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR0 0x00000DF1 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL1 (0x00000DF2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL1 is defined as MSR_C7_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL1 0x00000DF2 - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR1 (0x00000DF3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR1 0x00000DF3 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL2 (0x00000DF4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL2 is defined as MSR_C7_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL2 0x00000DF4 - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR2 (0x00000DF5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR2 0x00000DF5 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL3 (0x00000DF6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL3 is defined as MSR_C7_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL3 0x00000DF6 - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR3 (0x00000DF7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR3 0x00000DF7 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL4 (0x00000DF8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL4 is defined as MSR_C7_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL4 0x00000DF8 - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR4 (0x00000DF9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR4 is defined as MSR_C7_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR4 0x00000DF9 - - -/** - Package. Uncore C-box 7 perfmon event select MSR. - - @param ECX MSR_NEHALEM_C7_PMON_EVNT_SEL5 (0x00000DFA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_EVNT_SEL5 is defined as MSR_C7_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_EVNT_SEL5 0x00000DFA - - -/** - Package. Uncore C-box 7 perfmon counter MSR. - - @param ECX MSR_NEHALEM_C7_PMON_CTR5 (0x00000DFB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_C7_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_C7_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_C7_PMON_CTR5 is defined as MSR_C7_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_C7_PMON_CTR5 0x00000DFB - - -/** - Package. Uncore R-box 0 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_R0_PMON_BOX_CTRL (0x00000E00) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_BOX_CTRL is defined as MSR_R0_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_BOX_CTRL 0x00000E00 - - -/** - Package. Uncore R-box 0 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_R0_PMON_BOX_STATUS (0x00000E01) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_BOX_STATUS is defined as MSR_R0_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_BOX_STATUS 0x00000E01 - - -/** - Package. Uncore R-box 0 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL (0x00000E02) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL is defined as MSR_R0_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_BOX_OVF_CTRL 0x00000E02 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 0 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P0 (0x00000E04) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P0); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P0, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P0 is defined as MSR_R0_PMON_IPERF0_P0 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P0 0x00000E04 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 1 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P1 (0x00000E05) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P1); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P1, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P1 is defined as MSR_R0_PMON_IPERF0_P1 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P1 0x00000E05 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 2 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P2 (0x00000E06) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P2); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P2, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P2 is defined as MSR_R0_PMON_IPERF0_P2 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P2 0x00000E06 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 3 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P3 (0x00000E07) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P3); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P3, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P3 is defined as MSR_R0_PMON_IPERF0_P3 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P3 0x00000E07 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 4 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P4 (0x00000E08) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P4); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P4, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P4 is defined as MSR_R0_PMON_IPERF0_P4 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P4 0x00000E08 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 5 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P5 (0x00000E09) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P5); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P5, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P5 is defined as MSR_R0_PMON_IPERF0_P5 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P5 0x00000E09 - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 6 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P6 (0x00000E0A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P6); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P6, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P6 is defined as MSR_R0_PMON_IPERF0_P6 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P6 0x00000E0A - - -/** - Package. Uncore R-box 0 perfmon IPERF0 unit Port 7 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_IPERF0_P7 (0x00000E0B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P7); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_IPERF0_P7, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_IPERF0_P7 is defined as MSR_R0_PMON_IPERF0_P7 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_IPERF0_P7 0x00000E0B - - -/** - Package. Uncore R-box 0 perfmon QLX unit Port 0 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_QLX_P0 (0x00000E0C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P0); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P0, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_QLX_P0 is defined as MSR_R0_PMON_QLX_P0 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_QLX_P0 0x00000E0C - - -/** - Package. Uncore R-box 0 perfmon QLX unit Port 1 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_QLX_P1 (0x00000E0D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P1); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P1, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_QLX_P1 is defined as MSR_R0_PMON_QLX_P1 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_QLX_P1 0x00000E0D - - -/** - Package. Uncore R-box 0 perfmon QLX unit Port 2 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_QLX_P2 (0x00000E0E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P2); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P2, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_QLX_P2 is defined as MSR_R0_PMON_QLX_P2 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_QLX_P2 0x00000E0E - - -/** - Package. Uncore R-box 0 perfmon QLX unit Port 3 select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_QLX_P3 (0x00000E0F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_QLX_P3); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_QLX_P3, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_QLX_P3 is defined as MSR_R0_PMON_QLX_P3 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_QLX_P3 0x00000E0F - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL0 (0x00000E10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL0 is defined as MSR_R0_PMON_EVNT_SEL0 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL0 0x00000E10 - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR0 (0x00000E11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR0); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR0, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR0 is defined as MSR_R0_PMON_CTR0 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR0 0x00000E11 - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL1 (0x00000E12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL1); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL1, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL1 is defined as MSR_R0_PMON_EVNT_SEL1 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL1 0x00000E12 - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR1 (0x00000E13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR1); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR1, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR1 is defined as MSR_R0_PMON_CTR1 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR1 0x00000E13 - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL2 (0x00000E14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL2); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL2, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL2 is defined as MSR_R0_PMON_EVNT_SEL2 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL2 0x00000E14 - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR2 (0x00000E15) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR2); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR2, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR2 is defined as MSR_R0_PMON_CTR2 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR2 0x00000E15 - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL3 (0x00000E16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL3); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL3, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL3 is defined as MSR_R0_PMON_EVNT_SEL3 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL3 0x00000E16 - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR3 (0x00000E17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR3); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR3, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR3 is defined as MSR_R0_PMON_CTR3 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR3 0x00000E17 - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL4 (0x00000E18) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL4); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL4, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL4 is defined as MSR_R0_PMON_EVNT_SEL4 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL4 0x00000E18 - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR4 (0x00000E19) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR4); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR4, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR4 is defined as MSR_R0_PMON_CTR4 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR4 0x00000E19 - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL5 (0x00000E1A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL5); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL5, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL5 is defined as MSR_R0_PMON_EVNT_SEL5 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL5 0x00000E1A - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR5 (0x00000E1B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR5); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR5, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR5 is defined as MSR_R0_PMON_CTR5 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR5 0x00000E1B - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL6 (0x00000E1C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL6); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL6, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL6 is defined as MSR_R0_PMON_EVNT_SEL6 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL6 0x00000E1C - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR6 (0x00000E1D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR6); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR6, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR6 is defined as MSR_R0_PMON_CTR6 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR6 0x00000E1D - - -/** - Package. Uncore R-box 0 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R0_PMON_EVNT_SEL7 (0x00000E1E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL7); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_EVNT_SEL7, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_EVNT_SEL7 is defined as MSR_R0_PMON_EVNT_SEL7 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_EVNT_SEL7 0x00000E1E - - -/** - Package. Uncore R-box 0 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R0_PMON_CTR7 (0x00000E1F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R0_PMON_CTR7); - AsmWriteMsr64 (MSR_NEHALEM_R0_PMON_CTR7, Msr); - @endcode - @note MSR_NEHALEM_R0_PMON_CTR7 is defined as MSR_R0_PMON_CTR7 in SDM. -**/ -#define MSR_NEHALEM_R0_PMON_CTR7 0x00000E1F - - -/** - Package. Uncore R-box 1 perfmon local box control MSR. - - @param ECX MSR_NEHALEM_R1_PMON_BOX_CTRL (0x00000E20) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_BOX_CTRL is defined as MSR_R1_PMON_BOX_CTRL in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_BOX_CTRL 0x00000E20 - - -/** - Package. Uncore R-box 1 perfmon local box status MSR. - - @param ECX MSR_NEHALEM_R1_PMON_BOX_STATUS (0x00000E21) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_BOX_STATUS is defined as MSR_R1_PMON_BOX_STATUS in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_BOX_STATUS 0x00000E21 - - -/** - Package. Uncore R-box 1 perfmon local box overflow control MSR. - - @param ECX MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL (0x00000E22) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL is defined as MSR_R1_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_BOX_OVF_CTRL 0x00000E22 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 8 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P8 (0x00000E24) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P8); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P8, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P8 is defined as MSR_R1_PMON_IPERF1_P8 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P8 0x00000E24 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 9 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P9 (0x00000E25) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P9); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P9, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P9 is defined as MSR_R1_PMON_IPERF1_P9 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P9 0x00000E25 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 10 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P10 (0x00000E26) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P10); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P10, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P10 is defined as MSR_R1_PMON_IPERF1_P10 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P10 0x00000E26 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 11 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P11 (0x00000E27) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P11); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P11, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P11 is defined as MSR_R1_PMON_IPERF1_P11 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P11 0x00000E27 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 12 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P12 (0x00000E28) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P12); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P12, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P12 is defined as MSR_R1_PMON_IPERF1_P12 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P12 0x00000E28 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 13 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P13 (0x00000E29) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P13); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P13, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P13 is defined as MSR_R1_PMON_IPERF1_P13 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P13 0x00000E29 - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 14 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P14 (0x00000E2A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P14); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P14, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P14 is defined as MSR_R1_PMON_IPERF1_P14 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P14 0x00000E2A - - -/** - Package. Uncore R-box 1 perfmon IPERF1 unit Port 15 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_IPERF1_P15 (0x00000E2B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P15); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_IPERF1_P15, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_IPERF1_P15 is defined as MSR_R1_PMON_IPERF1_P15 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_IPERF1_P15 0x00000E2B - - -/** - Package. Uncore R-box 1 perfmon QLX unit Port 4 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_QLX_P4 (0x00000E2C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P4); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P4, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_QLX_P4 is defined as MSR_R1_PMON_QLX_P4 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_QLX_P4 0x00000E2C - - -/** - Package. Uncore R-box 1 perfmon QLX unit Port 5 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_QLX_P5 (0x00000E2D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P5); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P5, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_QLX_P5 is defined as MSR_R1_PMON_QLX_P5 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_QLX_P5 0x00000E2D - - -/** - Package. Uncore R-box 1 perfmon QLX unit Port 6 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_QLX_P6 (0x00000E2E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P6); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P6, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_QLX_P6 is defined as MSR_R1_PMON_QLX_P6 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_QLX_P6 0x00000E2E - - -/** - Package. Uncore R-box 1 perfmon QLX unit Port 7 select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_QLX_P7 (0x00000E2F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_QLX_P7); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_QLX_P7, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_QLX_P7 is defined as MSR_R1_PMON_QLX_P7 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_QLX_P7 0x00000E2F - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL8 (0x00000E30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL8); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL8, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL8 is defined as MSR_R1_PMON_EVNT_SEL8 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL8 0x00000E30 - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR8 (0x00000E31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR8); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR8, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR8 is defined as MSR_R1_PMON_CTR8 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR8 0x00000E31 - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL9 (0x00000E32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL9); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL9, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL9 is defined as MSR_R1_PMON_EVNT_SEL9 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL9 0x00000E32 - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR9 (0x00000E33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR9); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR9, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR9 is defined as MSR_R1_PMON_CTR9 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR9 0x00000E33 - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL10 (0x00000E34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL10); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL10, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL10 is defined as MSR_R1_PMON_EVNT_SEL10 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL10 0x00000E34 - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR10 (0x00000E35) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR10); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR10, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR10 is defined as MSR_R1_PMON_CTR10 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR10 0x00000E35 - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL11 (0x00000E36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL11); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL11, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL11 is defined as MSR_R1_PMON_EVNT_SEL11 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL11 0x00000E36 - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR11 (0x00000E37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR11); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR11, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR11 is defined as MSR_R1_PMON_CTR11 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR11 0x00000E37 - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL12 (0x00000E38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL12); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL12, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL12 is defined as MSR_R1_PMON_EVNT_SEL12 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL12 0x00000E38 - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR12 (0x00000E39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR12); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR12, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR12 is defined as MSR_R1_PMON_CTR12 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR12 0x00000E39 - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL13 (0x00000E3A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL13); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL13, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL13 is defined as MSR_R1_PMON_EVNT_SEL13 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL13 0x00000E3A - - -/** - Package. Uncore R-box 1perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR13 (0x00000E3B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR13); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR13, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR13 is defined as MSR_R1_PMON_CTR13 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR13 0x00000E3B - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL14 (0x00000E3C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL14); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL14, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL14 is defined as MSR_R1_PMON_EVNT_SEL14 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL14 0x00000E3C - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR14 (0x00000E3D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR14); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR14, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR14 is defined as MSR_R1_PMON_CTR14 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR14 0x00000E3D - - -/** - Package. Uncore R-box 1 perfmon event select MSR. - - @param ECX MSR_NEHALEM_R1_PMON_EVNT_SEL15 (0x00000E3E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL15); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_EVNT_SEL15, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_EVNT_SEL15 is defined as MSR_R1_PMON_EVNT_SEL15 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_EVNT_SEL15 0x00000E3E - - -/** - Package. Uncore R-box 1 perfmon counter MSR. - - @param ECX MSR_NEHALEM_R1_PMON_CTR15 (0x00000E3F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_R1_PMON_CTR15); - AsmWriteMsr64 (MSR_NEHALEM_R1_PMON_CTR15, Msr); - @endcode - @note MSR_NEHALEM_R1_PMON_CTR15 is defined as MSR_R1_PMON_CTR15 in SDM. -**/ -#define MSR_NEHALEM_R1_PMON_CTR15 0x00000E3F - - -/** - Package. Uncore B-box 0 perfmon local box match MSR. - - @param ECX MSR_NEHALEM_B0_PMON_MATCH (0x00000E45) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_MATCH, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_MATCH is defined as MSR_B0_PMON_MATCH in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_MATCH 0x00000E45 - - -/** - Package. Uncore B-box 0 perfmon local box mask MSR. - - @param ECX MSR_NEHALEM_B0_PMON_MASK (0x00000E46) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B0_PMON_MASK); - AsmWriteMsr64 (MSR_NEHALEM_B0_PMON_MASK, Msr); - @endcode - @note MSR_NEHALEM_B0_PMON_MASK is defined as MSR_B0_PMON_MASK in SDM. -**/ -#define MSR_NEHALEM_B0_PMON_MASK 0x00000E46 - - -/** - Package. Uncore S-box 0 perfmon local box match MSR. - - @param ECX MSR_NEHALEM_S0_PMON_MATCH (0x00000E49) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_MATCH, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_MATCH is defined as MSR_S0_PMON_MATCH in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_MATCH 0x00000E49 - - -/** - Package. Uncore S-box 0 perfmon local box mask MSR. - - @param ECX MSR_NEHALEM_S0_PMON_MASK (0x00000E4A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S0_PMON_MASK); - AsmWriteMsr64 (MSR_NEHALEM_S0_PMON_MASK, Msr); - @endcode - @note MSR_NEHALEM_S0_PMON_MASK is defined as MSR_S0_PMON_MASK in SDM. -**/ -#define MSR_NEHALEM_S0_PMON_MASK 0x00000E4A - - -/** - Package. Uncore B-box 1 perfmon local box match MSR. - - @param ECX MSR_NEHALEM_B1_PMON_MATCH (0x00000E4D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_MATCH, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_MATCH is defined as MSR_B1_PMON_MATCH in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_MATCH 0x00000E4D - - -/** - Package. Uncore B-box 1 perfmon local box mask MSR. - - @param ECX MSR_NEHALEM_B1_PMON_MASK (0x00000E4E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_B1_PMON_MASK); - AsmWriteMsr64 (MSR_NEHALEM_B1_PMON_MASK, Msr); - @endcode - @note MSR_NEHALEM_B1_PMON_MASK is defined as MSR_B1_PMON_MASK in SDM. -**/ -#define MSR_NEHALEM_B1_PMON_MASK 0x00000E4E - - -/** - Package. Uncore M-box 0 perfmon local box address match/mask config MSR. - - @param ECX MSR_NEHALEM_M0_PMON_MM_CONFIG (0x00000E54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_MM_CONFIG); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_MM_CONFIG, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_MM_CONFIG is defined as MSR_M0_PMON_MM_CONFIG in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_MM_CONFIG 0x00000E54 - - -/** - Package. Uncore M-box 0 perfmon local box address match MSR. - - @param ECX MSR_NEHALEM_M0_PMON_ADDR_MATCH (0x00000E55) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MATCH, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_ADDR_MATCH is defined as MSR_M0_PMON_ADDR_MATCH in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_ADDR_MATCH 0x00000E55 - - -/** - Package. Uncore M-box 0 perfmon local box address mask MSR. - - @param ECX MSR_NEHALEM_M0_PMON_ADDR_MASK (0x00000E56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MASK); - AsmWriteMsr64 (MSR_NEHALEM_M0_PMON_ADDR_MASK, Msr); - @endcode - @note MSR_NEHALEM_M0_PMON_ADDR_MASK is defined as MSR_M0_PMON_ADDR_MASK in SDM. -**/ -#define MSR_NEHALEM_M0_PMON_ADDR_MASK 0x00000E56 - - -/** - Package. Uncore S-box 1 perfmon local box match MSR. - - @param ECX MSR_NEHALEM_S1_PMON_MATCH (0x00000E59) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_MATCH, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_MATCH is defined as MSR_S1_PMON_MATCH in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_MATCH 0x00000E59 - - -/** - Package. Uncore S-box 1 perfmon local box mask MSR. - - @param ECX MSR_NEHALEM_S1_PMON_MASK (0x00000E5A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_S1_PMON_MASK); - AsmWriteMsr64 (MSR_NEHALEM_S1_PMON_MASK, Msr); - @endcode - @note MSR_NEHALEM_S1_PMON_MASK is defined as MSR_S1_PMON_MASK in SDM. -**/ -#define MSR_NEHALEM_S1_PMON_MASK 0x00000E5A - - -/** - Package. Uncore M-box 1 perfmon local box address match/mask config MSR. - - @param ECX MSR_NEHALEM_M1_PMON_MM_CONFIG (0x00000E5C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_MM_CONFIG); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_MM_CONFIG, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_MM_CONFIG is defined as MSR_M1_PMON_MM_CONFIG in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_MM_CONFIG 0x00000E5C - - -/** - Package. Uncore M-box 1 perfmon local box address match MSR. - - @param ECX MSR_NEHALEM_M1_PMON_ADDR_MATCH (0x00000E5D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MATCH); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MATCH, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_ADDR_MATCH is defined as MSR_M1_PMON_ADDR_MATCH in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_ADDR_MATCH 0x00000E5D - - -/** - Package. Uncore M-box 1 perfmon local box address mask MSR. - - @param ECX MSR_NEHALEM_M1_PMON_ADDR_MASK (0x00000E5E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MASK); - AsmWriteMsr64 (MSR_NEHALEM_M1_PMON_ADDR_MASK, Msr); - @endcode - @note MSR_NEHALEM_M1_PMON_ADDR_MASK is defined as MSR_M1_PMON_ADDR_MASK in SDM. -**/ -#define MSR_NEHALEM_M1_PMON_ADDR_MASK 0x00000E5E - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/P6Msr.h b/UefiCpuPkg/Include/Register/Msr/P6Msr.h deleted file mode 100644 index aec2e2c868..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/P6Msr.h +++ /dev/null @@ -1,1712 +0,0 @@ -/** @file - MSR Definitions for P6 Family Processors. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.21. - -**/ - -#ifndef __P6_MSR_H__ -#define __P6_MSR_H__ - -#include - -/** - Is P6 Family Processors? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_P6_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x03 || \ - DisplayModel == 0x05 || \ - DisplayModel == 0x07 || \ - DisplayModel == 0x08 || \ - DisplayModel == 0x0A || \ - DisplayModel == 0x0B \ - ) \ - ) - -/** - See Section 35.22, "MSRs in Pentium Processors.". - - @param ECX MSR_P6_P5_MC_ADDR (0x00000000) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_P5_MC_ADDR); - AsmWriteMsr64 (MSR_P6_P5_MC_ADDR, Msr); - @endcode - @note MSR_P6_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. -**/ -#define MSR_P6_P5_MC_ADDR 0x00000000 - - -/** - See Section 35.22, "MSRs in Pentium Processors.". - - @param ECX MSR_P6_P5_MC_TYPE (0x00000001) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_P5_MC_TYPE); - AsmWriteMsr64 (MSR_P6_P5_MC_TYPE, Msr); - @endcode - @note MSR_P6_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. -**/ -#define MSR_P6_P5_MC_TYPE 0x00000001 - - -/** - See Section 17.14, "Time-Stamp Counter.". - - @param ECX MSR_P6_TSC (0x00000010) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_TSC); - AsmWriteMsr64 (MSR_P6_TSC, Msr); - @endcode - @note MSR_P6_TSC is defined as TSC in SDM. -**/ -#define MSR_P6_TSC 0x00000010 - - -/** - Platform ID (R) The operating system can use this MSR to determine "slot" - information for the processor and the proper microcode update to load. - - @param ECX MSR_P6_IA32_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_IA32_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_IA32_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_P6_IA32_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_IA32_PLATFORM_ID); - @endcode - @note MSR_P6_IA32_PLATFORM_ID is defined as IA32_PLATFORM_ID in SDM. -**/ -#define MSR_P6_IA32_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_P6_IA32_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:18; - /// - /// [Bits 52:50] Platform Id (R) Contains information concerning the - /// intended platform for the processor. - /// - /// 52 51 50 - /// 0 0 0 Processor Flag 0. - /// 0 0 1 Processor Flag 1 - /// 0 1 0 Processor Flag 2 - /// 0 1 1 Processor Flag 3 - /// 1 0 0 Processor Flag 4 - /// 1 0 1 Processor Flag 5 - /// 1 1 0 Processor Flag 6 - /// 1 1 1 Processor Flag 7 - /// - UINT32 PlatformId:3; - /// - /// [Bits 56:53] L2 Cache Latency Read. - /// - UINT32 L2CacheLatencyRead:4; - UINT32 Reserved3:3; - /// - /// [Bit 60] Clock Frequency Ratio Read. - /// - UINT32 ClockFrequencyRatioRead:1; - UINT32 Reserved4:3; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_IA32_PLATFORM_ID_REGISTER; - - -/** - Section 10.4.4, "Local APIC Status and Location.". - - @param ECX MSR_P6_APIC_BASE (0x0000001B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_APIC_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_APIC_BASE_REGISTER. - - Example usage - @code - MSR_P6_APIC_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_APIC_BASE); - AsmWriteMsr64 (MSR_P6_APIC_BASE, Msr.Uint64); - @endcode - @note MSR_P6_APIC_BASE is defined as APIC_BASE in SDM. -**/ -#define MSR_P6_APIC_BASE 0x0000001B - -/** - MSR information returned for MSR index #MSR_P6_APIC_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bit 8] Boot Strap Processor indicator Bit 1 = BSP. - /// - UINT32 BSP:1; - UINT32 Reserved2:2; - /// - /// [Bit 11] APIC Global Enable Bit - Permanent till reset 1 = Enabled 0 = - /// Disabled. - /// - UINT32 EN:1; - /// - /// [Bits 31:12] APIC Base Address. - /// - UINT32 ApicBase:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_APIC_BASE_REGISTER; - - -/** - Processor Hard Power-On Configuration (R/W) Enables and disables processor - features; (R) indicates current processor configuration. - - @param ECX MSR_P6_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_P6_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_P6_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_P6_EBL_CR_POWERON is defined as EBL_CR_POWERON in SDM. -**/ -#define MSR_P6_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_P6_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Data Error Checking Enable (R/W) 1 = Enabled 0 = Disabled. - /// - UINT32 DataErrorCheckingEnable:1; - /// - /// [Bit 2] Response Error Checking Enable FRCERR Observation Enable (R/W) - /// 1 = Enabled 0 = Disabled. - /// - UINT32 ResponseErrorCheckingEnable:1; - /// - /// [Bit 3] AERR# Drive Enable (R/W) 1 = Enabled 0 = Disabled. - /// - UINT32 AERR_DriveEnable:1; - /// - /// [Bit 4] BERR# Enable for Initiator Bus Requests (R/W) 1 = Enabled 0 = - /// Disabled. - /// - UINT32 BERR_Enable:1; - UINT32 Reserved2:1; - /// - /// [Bit 6] BERR# Driver Enable for Initiator Internal Errors (R/W) 1 = - /// Enabled 0 = Disabled. - /// - UINT32 BERR_DriverEnable:1; - /// - /// [Bit 7] BINIT# Driver Enable (R/W) 1 = Enabled 0 = Disabled. - /// - UINT32 BINIT_DriverEnable:1; - /// - /// [Bit 8] Output Tri-state Enabled (R) 1 = Enabled 0 = Disabled. - /// - UINT32 OutputTriStateEnable:1; - /// - /// [Bit 9] Execute BIST (R) 1 = Enabled 0 = Disabled. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 10] AERR# Observation Enabled (R) 1 = Enabled 0 = Disabled. - /// - UINT32 AERR_ObservationEnabled:1; - UINT32 Reserved3:1; - /// - /// [Bit 12] BINIT# Observation Enabled (R) 1 = Enabled 0 = Disabled. - /// - UINT32 BINIT_ObservationEnabled:1; - /// - /// [Bit 13] In Order Queue Depth (R) 1 = 1 0 = 8. - /// - UINT32 InOrderQueueDepth:1; - /// - /// [Bit 14] 1-MByte Power on Reset Vector (R) 1 = 1MByte 0 = 4GBytes. - /// - UINT32 ResetVector:1; - /// - /// [Bit 15] FRC Mode Enable (R) 1 = Enabled 0 = Disabled. - /// - UINT32 FRCModeEnable:1; - /// - /// [Bits 17:16] APIC Cluster ID (R). - /// - UINT32 APICClusterID:2; - /// - /// [Bits 19:18] System Bus Frequency (R) 00 = 66MHz 10 = 100Mhz 01 = - /// 133MHz 11 = Reserved. - /// - UINT32 SystemBusFrequency:2; - /// - /// [Bits 21:20] Symmetric Arbitration ID (R). - /// - UINT32 SymmetricArbitrationID:2; - /// - /// [Bits 25:22] Clock Frequency Ratio (R). - /// - UINT32 ClockFrequencyRatio:4; - /// - /// [Bit 26] Low Power Mode Enable (R/W). - /// - UINT32 LowPowerModeEnable:1; - /// - /// [Bit 27] Clock Frequency Ratio. - /// - UINT32 ClockFrequencyRatio1:1; - UINT32 Reserved4:4; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_EBL_CR_POWERON_REGISTER; - - -/** - Test Control Register. - - @param ECX MSR_P6_TEST_CTL (0x00000033) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_TEST_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_TEST_CTL_REGISTER. - - Example usage - @code - MSR_P6_TEST_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_TEST_CTL); - AsmWriteMsr64 (MSR_P6_TEST_CTL, Msr.Uint64); - @endcode - @note MSR_P6_TEST_CTL is defined as TEST_CTL in SDM. -**/ -#define MSR_P6_TEST_CTL 0x00000033 - -/** - MSR information returned for MSR index #MSR_P6_TEST_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:30; - /// - /// [Bit 30] Streaming Buffer Disable. - /// - UINT32 StreamingBufferDisable:1; - /// - /// [Bit 31] Disable LOCK# Assertion for split locked access. - /// - UINT32 Disable_LOCK:1; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_TEST_CTL_REGISTER; - - -/** - BIOS Update Trigger Register. - - @param ECX MSR_P6_BIOS_UPDT_TRIG (0x00000079) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BIOS_UPDT_TRIG); - AsmWriteMsr64 (MSR_P6_BIOS_UPDT_TRIG, Msr); - @endcode - @note MSR_P6_BIOS_UPDT_TRIG is defined as BIOS_UPDT_TRIG in SDM. -**/ -#define MSR_P6_BIOS_UPDT_TRIG 0x00000079 - - -/** - Chunk n data register D[63:0]: used to write to and read from the L2. - - @param ECX MSR_P6_BBL_CR_Dn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BBL_CR_D0); - AsmWriteMsr64 (MSR_P6_BBL_CR_D0, Msr); - @endcode - @note MSR_P6_BBL_CR_D0 is defined as BBL_CR_D0 in SDM. - MSR_P6_BBL_CR_D1 is defined as BBL_CR_D1 in SDM. - MSR_P6_BBL_CR_D2 is defined as BBL_CR_D2 in SDM. - @{ -**/ -#define MSR_P6_BBL_CR_D0 0x00000088 -#define MSR_P6_BBL_CR_D1 0x00000089 -#define MSR_P6_BBL_CR_D2 0x0000008A -/// @} - - -/** - BIOS Update Signature Register or Chunk 3 data register D[63:0] Used to - write to and read from the L2 depending on the usage model. - - @param ECX MSR_P6_BIOS_SIGN (0x0000008B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BIOS_SIGN); - AsmWriteMsr64 (MSR_P6_BIOS_SIGN, Msr); - @endcode - @note MSR_P6_BIOS_SIGN is defined as BIOS_SIGN in SDM. -**/ -#define MSR_P6_BIOS_SIGN 0x0000008B - - -/** - - - @param ECX MSR_P6_PERFCTR0 (0x000000C1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_PERFCTR0); - AsmWriteMsr64 (MSR_P6_PERFCTR0, Msr); - @endcode - @note MSR_P6_PERFCTR0 is defined as PERFCTR0 in SDM. - MSR_P6_PERFCTR1 is defined as PERFCTR1 in SDM. - @{ -**/ -#define MSR_P6_PERFCTR0 0x000000C1 -#define MSR_P6_PERFCTR1 0x000000C2 -/// @} - - -/** - - - @param ECX MSR_P6_MTRRCAP (0x000000FE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRCAP); - AsmWriteMsr64 (MSR_P6_MTRRCAP, Msr); - @endcode - @note MSR_P6_MTRRCAP is defined as MTRRCAP in SDM. -**/ -#define MSR_P6_MTRRCAP 0x000000FE - - -/** - Address register: used to send specified address (A31-A3) to L2 during cache - initialization accesses. - - @param ECX MSR_P6_BBL_CR_ADDR (0x00000116) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_ADDR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_ADDR_REGISTER. - - Example usage - @code - MSR_P6_BBL_CR_ADDR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_ADDR); - AsmWriteMsr64 (MSR_P6_BBL_CR_ADDR, Msr.Uint64); - @endcode - @note MSR_P6_BBL_CR_ADDR is defined as BBL_CR_ADDR in SDM. -**/ -#define MSR_P6_BBL_CR_ADDR 0x00000116 - -/** - MSR information returned for MSR index #MSR_P6_BBL_CR_ADDR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:3; - /// - /// [Bits 31:3] Address bits - /// - UINT32 Address:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_BBL_CR_ADDR_REGISTER; - - -/** - Data ECC register D[7:0]: used to write ECC and read ECC to/from L2. - - @param ECX MSR_P6_BBL_CR_DECC (0x00000118) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BBL_CR_DECC); - AsmWriteMsr64 (MSR_P6_BBL_CR_DECC, Msr); - @endcode - @note MSR_P6_BBL_CR_DECC is defined as BBL_CR_DECC in SDM. -**/ -#define MSR_P6_BBL_CR_DECC 0x00000118 - - -/** - Control register: used to program L2 commands to be issued via cache - configuration accesses mechanism. Also receives L2 lookup response. - - @param ECX MSR_P6_BBL_CR_CTL (0x00000119) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_CTL_REGISTER. - - Example usage - @code - MSR_P6_BBL_CR_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_CTL); - AsmWriteMsr64 (MSR_P6_BBL_CR_CTL, Msr.Uint64); - @endcode - @note MSR_P6_BBL_CR_CTL is defined as BBL_CR_CTL in SDM. -**/ -#define MSR_P6_BBL_CR_CTL 0x00000119 - -/** - MSR information returned for MSR index #MSR_P6_BBL_CR_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 4:0] L2 Command - /// Data Read w/ LRU update (RLU) - /// Tag Read w/ Data Read (TRR) - /// Tag Inquire (TI) - /// L2 Control Register Read (CR) - /// L2 Control Register Write (CW) - /// Tag Write w/ Data Read (TWR) - /// Tag Write w/ Data Write (TWW) - /// Tag Write (TW). - /// - UINT32 L2Command:5; - /// - /// [Bits 6:5] State to L2 - /// - UINT32 StateToL2:2; - UINT32 Reserved:1; - /// - /// [Bits 9:8] Way to L2. - /// - UINT32 WayToL2:2; - /// - /// [Bits 11:10] Way 0 - 00, Way 1 - 01, Way 2 - 10, Way 3 - 11. - /// - UINT32 Way:2; - /// - /// [Bits 13:12] Modified - 11,Exclusive - 10, Shared - 01, Invalid - 00. - /// - UINT32 MESI:2; - /// - /// [Bits 15:14] State from L2. - /// - UINT32 StateFromL2:2; - UINT32 Reserved2:1; - /// - /// [Bit 17] L2 Hit. - /// - UINT32 L2Hit:1; - UINT32 Reserved3:1; - /// - /// [Bits 20:19] User supplied ECC. - /// - UINT32 UserEcc:2; - /// - /// [Bit 21] Processor number Disable = 1 Enable = 0 Reserved. - /// - UINT32 ProcessorNumber:1; - UINT32 Reserved4:10; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_BBL_CR_CTL_REGISTER; - - -/** - Trigger register: used to initiate a cache configuration accesses access, - Write only with Data = 0. - - @param ECX MSR_P6_BBL_CR_TRIG (0x0000011A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BBL_CR_TRIG); - AsmWriteMsr64 (MSR_P6_BBL_CR_TRIG, Msr); - @endcode - @note MSR_P6_BBL_CR_TRIG is defined as BBL_CR_TRIG in SDM. -**/ -#define MSR_P6_BBL_CR_TRIG 0x0000011A - - -/** - Busy register: indicates when a cache configuration accesses L2 command is - in progress. D[0] = 1 = BUSY. - - @param ECX MSR_P6_BBL_CR_BUSY (0x0000011B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_BBL_CR_BUSY); - AsmWriteMsr64 (MSR_P6_BBL_CR_BUSY, Msr); - @endcode - @note MSR_P6_BBL_CR_BUSY is defined as BBL_CR_BUSY in SDM. -**/ -#define MSR_P6_BBL_CR_BUSY 0x0000011B - - -/** - Control register 3: used to configure the L2 Cache. - - @param ECX MSR_P6_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_P6_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_P6_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_P6_BBL_CR_CTL3 is defined as BBL_CR_CTL3 in SDM. -**/ -#define MSR_P6_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_P6_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Configured (read/write ). - /// - UINT32 L2Configured:1; - /// - /// [Bits 4:1] L2 Cache Latency (read/write). - /// - UINT32 L2CacheLatency:4; - /// - /// [Bit 5] ECC Check Enable (read/write). - /// - UINT32 ECCCheckEnable:1; - /// - /// [Bit 6] Address Parity Check Enable (read/write). - /// - UINT32 AddressParityCheckEnable:1; - /// - /// [Bit 7] CRTN Parity Check Enable (read/write). - /// - UINT32 CRTNParityCheckEnable:1; - /// - /// [Bit 8] L2 Enabled (read/write). - /// - UINT32 L2Enabled:1; - /// - /// [Bits 10:9] L2 Associativity (read only) Direct Mapped 2 Way 4 Way - /// Reserved. - /// - UINT32 L2Associativity:2; - /// - /// [Bits 12:11] Number of L2 banks (read only). - /// - UINT32 L2Banks:2; - /// - /// [Bits 17:13] Cache size per bank (read/write) 256KBytes 512KBytes - /// 1MByte 2MByte 4MBytes. - /// - UINT32 CacheSizePerBank:5; - /// - /// [Bit 18] Cache State error checking enable (read/write). - /// - UINT32 CacheStateErrorEnable:1; - UINT32 Reserved1:1; - /// - /// [Bits 22:20] L2 Physical Address Range support 64GBytes 32GBytes - /// 16GBytes 8GBytes 4GBytes 2GBytes 1GBytes 512MBytes. - /// - UINT32 L2AddressRange:3; - /// - /// [Bit 23] L2 Hardware Disable (read only). - /// - UINT32 L2HardwareDisable:1; - UINT32 Reserved2:1; - /// - /// [Bit 25] Cache bus fraction (read only). - /// - UINT32 CacheBusFraction:1; - UINT32 Reserved3:6; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_BBL_CR_CTL3_REGISTER; - - -/** - CS register target for CPL 0 code. - - @param ECX MSR_P6_SYSENTER_CS_MSR (0x00000174) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_SYSENTER_CS_MSR); - AsmWriteMsr64 (MSR_P6_SYSENTER_CS_MSR, Msr); - @endcode - @note MSR_P6_SYSENTER_CS_MSR is defined as SYSENTER_CS_MSR in SDM. -**/ -#define MSR_P6_SYSENTER_CS_MSR 0x00000174 - - -/** - Stack pointer for CPL 0 stack. - - @param ECX MSR_P6_SYSENTER_ESP_MSR (0x00000175) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_SYSENTER_ESP_MSR); - AsmWriteMsr64 (MSR_P6_SYSENTER_ESP_MSR, Msr); - @endcode - @note MSR_P6_SYSENTER_ESP_MSR is defined as SYSENTER_ESP_MSR in SDM. -**/ -#define MSR_P6_SYSENTER_ESP_MSR 0x00000175 - - -/** - CPL 0 code entry point. - - @param ECX MSR_P6_SYSENTER_EIP_MSR (0x00000176) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_SYSENTER_EIP_MSR); - AsmWriteMsr64 (MSR_P6_SYSENTER_EIP_MSR, Msr); - @endcode - @note MSR_P6_SYSENTER_EIP_MSR is defined as SYSENTER_EIP_MSR in SDM. -**/ -#define MSR_P6_SYSENTER_EIP_MSR 0x00000176 - - -/** - - - @param ECX MSR_P6_MCG_CAP (0x00000179) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MCG_CAP); - AsmWriteMsr64 (MSR_P6_MCG_CAP, Msr); - @endcode - @note MSR_P6_MCG_CAP is defined as MCG_CAP in SDM. -**/ -#define MSR_P6_MCG_CAP 0x00000179 - - -/** - - - @param ECX MSR_P6_MCG_STATUS (0x0000017A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MCG_STATUS); - AsmWriteMsr64 (MSR_P6_MCG_STATUS, Msr); - @endcode - @note MSR_P6_MCG_STATUS is defined as MCG_STATUS in SDM. -**/ -#define MSR_P6_MCG_STATUS 0x0000017A - - -/** - - - @param ECX MSR_P6_MCG_CTL (0x0000017B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MCG_CTL); - AsmWriteMsr64 (MSR_P6_MCG_CTL, Msr); - @endcode - @note MSR_P6_MCG_CTL is defined as MCG_CTL in SDM. -**/ -#define MSR_P6_MCG_CTL 0x0000017B - - -/** - - - @param ECX MSR_P6_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_PERFEVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_PERFEVTSEL_REGISTER. - - Example usage - @code - MSR_P6_PERFEVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_PERFEVTSEL0); - AsmWriteMsr64 (MSR_P6_PERFEVTSEL0, Msr.Uint64); - @endcode - @note MSR_P6_PERFEVTSEL0 is defined as PERFEVTSEL0 in SDM. - MSR_P6_PERFEVTSEL1 is defined as PERFEVTSEL1 in SDM. - @{ -**/ -#define MSR_P6_PERFEVTSEL0 0x00000186 -#define MSR_P6_PERFEVTSEL1 0x00000187 -/// @} - -/** - MSR information returned for MSR indexes #MSR_P6_PERFEVTSEL0 and - #MSR_P6_PERFEVTSEL1. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Event Select Refer to Performance Counter section for a - /// list of event encodings. - /// - UINT32 EventSelect:8; - /// - /// [Bits 15:8] UMASK (Unit Mask) Unit mask register set to 0 to enable - /// all count options. - /// - UINT32 UMASK:8; - /// - /// [Bit 16] USER Controls the counting of events at Privilege levels of - /// 1, 2, and 3. - /// - UINT32 USR:1; - /// - /// [Bit 17] OS Controls the counting of events at Privilege level of 0. - /// - UINT32 OS:1; - /// - /// [Bit 18] E Occurrence/Duration Mode Select 1 = Occurrence 0 = Duration. - /// - UINT32 E:1; - /// - /// [Bit 19] PC Enabled the signaling of performance counter overflow via - /// BP0 pin. - /// - UINT32 PC:1; - /// - /// [Bit 20] INT Enables the signaling of counter overflow via input to - /// APIC 1 = Enable 0 = Disable. - /// - UINT32 INT:1; - UINT32 Reserved1:1; - /// - /// [Bit 22] ENABLE Enables the counting of performance events in both - /// counters 1 = Enable 0 = Disable. - /// - UINT32 EN:1; - /// - /// [Bit 23] INV Inverts the result of the CMASK condition 1 = Inverted 0 - /// = Non-Inverted. - /// - UINT32 INV:1; - /// - /// [Bits 31:24] CMASK (Counter Mask). - /// - UINT32 CMASK:8; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_PERFEVTSEL_REGISTER; - - -/** - - - @param ECX MSR_P6_DEBUGCTLMSR (0x000001D9) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_DEBUGCTLMSR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_DEBUGCTLMSR_REGISTER. - - Example usage - @code - MSR_P6_DEBUGCTLMSR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_DEBUGCTLMSR); - AsmWriteMsr64 (MSR_P6_DEBUGCTLMSR, Msr.Uint64); - @endcode - @note MSR_P6_DEBUGCTLMSR is defined as DEBUGCTLMSR in SDM. -**/ -#define MSR_P6_DEBUGCTLMSR 0x000001D9 - -/** - MSR information returned for MSR index #MSR_P6_DEBUGCTLMSR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable/Disable Last Branch Records. - /// - UINT32 LBR:1; - /// - /// [Bit 1] Branch Trap Flag. - /// - UINT32 BTF:1; - /// - /// [Bit 2] Performance Monitoring/Break Point Pins. - /// - UINT32 PB0:1; - /// - /// [Bit 3] Performance Monitoring/Break Point Pins. - /// - UINT32 PB1:1; - /// - /// [Bit 4] Performance Monitoring/Break Point Pins. - /// - UINT32 PB2:1; - /// - /// [Bit 5] Performance Monitoring/Break Point Pins. - /// - UINT32 PB3:1; - /// - /// [Bit 6] Enable/Disable Execution Trace Messages. - /// - UINT32 TR:1; - UINT32 Reserved1:25; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_DEBUGCTLMSR_REGISTER; - - -/** - - - @param ECX MSR_P6_LASTBRANCHFROMIP (0x000001DB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_LASTBRANCHFROMIP); - AsmWriteMsr64 (MSR_P6_LASTBRANCHFROMIP, Msr); - @endcode - @note MSR_P6_LASTBRANCHFROMIP is defined as LASTBRANCHFROMIP in SDM. -**/ -#define MSR_P6_LASTBRANCHFROMIP 0x000001DB - - -/** - - - @param ECX MSR_P6_LASTBRANCHTOIP (0x000001DC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_LASTBRANCHTOIP); - AsmWriteMsr64 (MSR_P6_LASTBRANCHTOIP, Msr); - @endcode - @note MSR_P6_LASTBRANCHTOIP is defined as LASTBRANCHTOIP in SDM. -**/ -#define MSR_P6_LASTBRANCHTOIP 0x000001DC - - -/** - - - @param ECX MSR_P6_LASTINTFROMIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_LASTINTFROMIP); - AsmWriteMsr64 (MSR_P6_LASTINTFROMIP, Msr); - @endcode - @note MSR_P6_LASTINTFROMIP is defined as LASTINTFROMIP in SDM. -**/ -#define MSR_P6_LASTINTFROMIP 0x000001DD - - -/** - - - @param ECX MSR_P6_LASTINTTOIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_LASTINTTOIP); - AsmWriteMsr64 (MSR_P6_LASTINTTOIP, Msr); - @endcode - @note MSR_P6_LASTINTTOIP is defined as LASTINTTOIP in SDM. -**/ -#define MSR_P6_LASTINTTOIP 0x000001DE - - -/** - - - @param ECX MSR_P6_ROB_CR_BKUPTMPDR6 (0x000001E0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER. - - Example usage - @code - MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_ROB_CR_BKUPTMPDR6); - AsmWriteMsr64 (MSR_P6_ROB_CR_BKUPTMPDR6, Msr.Uint64); - @endcode - @note MSR_P6_ROB_CR_BKUPTMPDR6 is defined as ROB_CR_BKUPTMPDR6 in SDM. -**/ -#define MSR_P6_ROB_CR_BKUPTMPDR6 0x000001E0 - -/** - MSR information returned for MSR index #MSR_P6_ROB_CR_BKUPTMPDR6 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:2; - /// - /// [Bit 2] Fast Strings Enable bit. Default is enabled. - /// - UINT32 FastStrings:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_ROB_CR_BKUPTMPDR6_REGISTER; - - -/** - - - @param ECX MSR_P6_MTRRPHYSBASEn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRPHYSBASE0); - AsmWriteMsr64 (MSR_P6_MTRRPHYSBASE0, Msr); - @endcode - @note MSR_P6_MTRRPHYSBASE0 is defined as MTRRPHYSBASE0 in SDM. - MSR_P6_MTRRPHYSBASE1 is defined as MTRRPHYSBASE1 in SDM. - MSR_P6_MTRRPHYSBASE2 is defined as MTRRPHYSBASE2 in SDM. - MSR_P6_MTRRPHYSBASE3 is defined as MTRRPHYSBASE3 in SDM. - MSR_P6_MTRRPHYSBASE4 is defined as MTRRPHYSBASE4 in SDM. - MSR_P6_MTRRPHYSBASE5 is defined as MTRRPHYSBASE5 in SDM. - MSR_P6_MTRRPHYSBASE6 is defined as MTRRPHYSBASE6 in SDM. - MSR_P6_MTRRPHYSBASE7 is defined as MTRRPHYSBASE7 in SDM. - @{ -**/ -#define MSR_P6_MTRRPHYSBASE0 0x00000200 -#define MSR_P6_MTRRPHYSBASE1 0x00000202 -#define MSR_P6_MTRRPHYSBASE2 0x00000204 -#define MSR_P6_MTRRPHYSBASE3 0x00000206 -#define MSR_P6_MTRRPHYSBASE4 0x00000208 -#define MSR_P6_MTRRPHYSBASE5 0x0000020A -#define MSR_P6_MTRRPHYSBASE6 0x0000020C -#define MSR_P6_MTRRPHYSBASE7 0x0000020E -/// @} - - -/** - - - @param ECX MSR_P6_MTRRPHYSMASKn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRPHYSMASK0); - AsmWriteMsr64 (MSR_P6_MTRRPHYSMASK0, Msr); - @endcode - @note MSR_P6_MTRRPHYSMASK0 is defined as MTRRPHYSMASK0 in SDM. - MSR_P6_MTRRPHYSMASK1 is defined as MTRRPHYSMASK1 in SDM. - MSR_P6_MTRRPHYSMASK2 is defined as MTRRPHYSMASK2 in SDM. - MSR_P6_MTRRPHYSMASK3 is defined as MTRRPHYSMASK3 in SDM. - MSR_P6_MTRRPHYSMASK4 is defined as MTRRPHYSMASK4 in SDM. - MSR_P6_MTRRPHYSMASK5 is defined as MTRRPHYSMASK5 in SDM. - MSR_P6_MTRRPHYSMASK6 is defined as MTRRPHYSMASK6 in SDM. - MSR_P6_MTRRPHYSMASK7 is defined as MTRRPHYSMASK7 in SDM. - @{ -**/ -#define MSR_P6_MTRRPHYSMASK0 0x00000201 -#define MSR_P6_MTRRPHYSMASK1 0x00000203 -#define MSR_P6_MTRRPHYSMASK2 0x00000205 -#define MSR_P6_MTRRPHYSMASK3 0x00000207 -#define MSR_P6_MTRRPHYSMASK4 0x00000209 -#define MSR_P6_MTRRPHYSMASK5 0x0000020B -#define MSR_P6_MTRRPHYSMASK6 0x0000020D -#define MSR_P6_MTRRPHYSMASK7 0x0000020F -/// @} - - -/** - - - @param ECX MSR_P6_MTRRFIX64K_00000 (0x00000250) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX64K_00000); - AsmWriteMsr64 (MSR_P6_MTRRFIX64K_00000, Msr); - @endcode - @note MSR_P6_MTRRFIX64K_00000 is defined as MTRRFIX64K_00000 in SDM. -**/ -#define MSR_P6_MTRRFIX64K_00000 0x00000250 - - -/** - - - @param ECX MSR_P6_MTRRFIX16K_80000 (0x00000258) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX16K_80000); - AsmWriteMsr64 (MSR_P6_MTRRFIX16K_80000, Msr); - @endcode - @note MSR_P6_MTRRFIX16K_80000 is defined as MTRRFIX16K_80000 in SDM. -**/ -#define MSR_P6_MTRRFIX16K_80000 0x00000258 - - -/** - - - @param ECX MSR_P6_MTRRFIX16K_A0000 (0x00000259) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX16K_A0000); - AsmWriteMsr64 (MSR_P6_MTRRFIX16K_A0000, Msr); - @endcode - @note MSR_P6_MTRRFIX16K_A0000 is defined as MTRRFIX16K_A0000 in SDM. -**/ -#define MSR_P6_MTRRFIX16K_A0000 0x00000259 - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_C0000 (0x00000268) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_C0000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_C0000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_C0000 is defined as MTRRFIX4K_C0000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_C0000 0x00000268 - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_C8000 (0x00000269) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_C8000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_C8000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_C8000 is defined as MTRRFIX4K_C8000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_C8000 0x00000269 - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_D0000 (0x0000026A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_D0000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_D0000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_D0000 is defined as MTRRFIX4K_D0000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_D0000 0x0000026A - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_D8000 (0x0000026B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_D8000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_D8000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_D8000 is defined as MTRRFIX4K_D8000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_D8000 0x0000026B - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_E0000 (0x0000026C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_E0000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_E0000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_E0000 is defined as MTRRFIX4K_E0000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_E0000 0x0000026C - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_E8000 (0x0000026D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_E8000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_E8000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_E8000 is defined as MTRRFIX4K_E8000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_E8000 0x0000026D - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_F0000 (0x0000026E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_F0000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_F0000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_F0000 is defined as MTRRFIX4K_F0000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_F0000 0x0000026E - - -/** - - - @param ECX MSR_P6_MTRRFIX4K_F8000 (0x0000026F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MTRRFIX4K_F8000); - AsmWriteMsr64 (MSR_P6_MTRRFIX4K_F8000, Msr); - @endcode - @note MSR_P6_MTRRFIX4K_F8000 is defined as MTRRFIX4K_F8000 in SDM. -**/ -#define MSR_P6_MTRRFIX4K_F8000 0x0000026F - - -/** - - - @param ECX MSR_P6_MTRRDEFTYPE (0x000002FF) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_MTRRDEFTYPE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_MTRRDEFTYPE_REGISTER. - - Example usage - @code - MSR_P6_MTRRDEFTYPE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_MTRRDEFTYPE); - AsmWriteMsr64 (MSR_P6_MTRRDEFTYPE, Msr.Uint64); - @endcode - @note MSR_P6_MTRRDEFTYPE is defined as MTRRDEFTYPE in SDM. -**/ -#define MSR_P6_MTRRDEFTYPE 0x000002FF - -/** - MSR information returned for MSR index #MSR_P6_MTRRDEFTYPE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Default memory type. - /// - UINT32 Type:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] Fixed MTRR enable. - /// - UINT32 FE:1; - /// - /// [Bit 11] MTRR Enable. - /// - UINT32 E:1; - UINT32 Reserved2:20; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_MTRRDEFTYPE_REGISTER; - - -/** - - - @param ECX MSR_P6_MC0_CTL (0x00000400) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MC0_CTL); - AsmWriteMsr64 (MSR_P6_MC0_CTL, Msr); - @endcode - @note MSR_P6_MC0_CTL is defined as MC0_CTL in SDM. - MSR_P6_MC1_CTL is defined as MC1_CTL in SDM. - MSR_P6_MC2_CTL is defined as MC2_CTL in SDM. - MSR_P6_MC3_CTL is defined as MC3_CTL in SDM. - MSR_P6_MC4_CTL is defined as MC4_CTL in SDM. - @{ -**/ -#define MSR_P6_MC0_CTL 0x00000400 -#define MSR_P6_MC1_CTL 0x00000404 -#define MSR_P6_MC2_CTL 0x00000408 -#define MSR_P6_MC3_CTL 0x00000410 -#define MSR_P6_MC4_CTL 0x0000040C -/// @} - - -/** - - Bit definitions for MSR_P6_MC4_STATUS are the same as MSR_P6_MC0_STATUS, - except bits 0, 4, 57, and 61 are hardcoded to 1. - - @param ECX MSR_P6_MCn_STATUS - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_P6_MC_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_P6_MC_STATUS_REGISTER. - - Example usage - @code - MSR_P6_MC_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_P6_MC0_STATUS); - AsmWriteMsr64 (MSR_P6_MC0_STATUS, Msr.Uint64); - @endcode - @note MSR_P6_MC0_STATUS is defined as MC0_STATUS in SDM. - MSR_P6_MC1_STATUS is defined as MC1_STATUS in SDM. - MSR_P6_MC2_STATUS is defined as MC2_STATUS in SDM. - MSR_P6_MC3_STATUS is defined as MC3_STATUS in SDM. - MSR_P6_MC4_STATUS is defined as MC4_STATUS in SDM. - @{ -**/ -#define MSR_P6_MC0_STATUS 0x00000401 -#define MSR_P6_MC1_STATUS 0x00000405 -#define MSR_P6_MC2_STATUS 0x00000409 -#define MSR_P6_MC3_STATUS 0x00000411 -#define MSR_P6_MC4_STATUS 0x0000040D -/// @} - -/** - MSR information returned for MSR index #MSR_P6_MC0_STATUS to - #MSR_P6_MC4_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] MC_STATUS_MCACOD. - /// - UINT32 MC_STATUS_MCACOD:16; - /// - /// [Bits 31:16] MC_STATUS_MSCOD. - /// - UINT32 MC_STATUS_MSCOD:16; - UINT32 Reserved:25; - /// - /// [Bit 57] MC_STATUS_DAM. - /// - UINT32 MC_STATUS_DAM:1; - /// - /// [Bit 58] MC_STATUS_ADDRV. - /// - UINT32 MC_STATUS_ADDRV:1; - /// - /// [Bit 59] MC_STATUS_MISCV. - /// - UINT32 MC_STATUS_MISCV:1; - /// - /// [Bit 60] MC_STATUS_EN. (Note: For MC0_STATUS only, this bit is - /// hardcoded to 1.). - /// - UINT32 MC_STATUS_EN:1; - /// - /// [Bit 61] MC_STATUS_UC. - /// - UINT32 MC_STATUS_UC:1; - /// - /// [Bit 62] MC_STATUS_O. - /// - UINT32 MC_STATUS_O:1; - /// - /// [Bit 63] MC_STATUS_V. - /// - UINT32 MC_STATUS_V:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_P6_MC_STATUS_REGISTER; - - -/** - - MSR_P6_MC4_ADDR is defined in MCA architecture but not implemented in P6 Family processors. - - @param ECX MSR_P6_MC0_ADDR (0x00000402) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MC0_ADDR); - AsmWriteMsr64 (MSR_P6_MC0_ADDR, Msr); - @endcode - @note MSR_P6_MC0_ADDR is defined as MC0_ADDR in SDM. - MSR_P6_MC1_ADDR is defined as MC1_ADDR in SDM. - MSR_P6_MC2_ADDR is defined as MC2_ADDR in SDM. - MSR_P6_MC3_ADDR is defined as MC3_ADDR in SDM. - MSR_P6_MC4_ADDR is defined as MC4_ADDR in SDM. - @{ -**/ -#define MSR_P6_MC0_ADDR 0x00000402 -#define MSR_P6_MC1_ADDR 0x00000406 -#define MSR_P6_MC2_ADDR 0x0000040A -#define MSR_P6_MC3_ADDR 0x00000412 -#define MSR_P6_MC4_ADDR 0x0000040E -/// @} - - -/** - Defined in MCA architecture but not implemented in the P6 family processors. - - @param ECX MSR_P6_MC0_MISC (0x00000403) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_P6_MC0_MISC); - AsmWriteMsr64 (MSR_P6_MC0_MISC, Msr); - @endcode - @note MSR_P6_MC0_MISC is defined as MC0_MISC in SDM. - MSR_P6_MC1_MISC is defined as MC1_MISC in SDM. - MSR_P6_MC2_MISC is defined as MC2_MISC in SDM. - MSR_P6_MC3_MISC is defined as MC3_MISC in SDM. - MSR_P6_MC4_MISC is defined as MC4_MISC in SDM. - @{ -**/ -#define MSR_P6_MC0_MISC 0x00000403 -#define MSR_P6_MC1_MISC 0x00000407 -#define MSR_P6_MC2_MISC 0x0000040B -#define MSR_P6_MC3_MISC 0x00000413 -#define MSR_P6_MC4_MISC 0x0000040F -/// @} - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h b/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h deleted file mode 100644 index 8922d56e2f..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/Pentium4Msr.h +++ /dev/null @@ -1,2730 +0,0 @@ -/** @file - MSR Definitions for Pentium(R) 4 Processors. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.18. - -**/ - -#ifndef __PENTIUM_4_MSR_H__ -#define __PENTIUM_4_MSR_H__ - -#include - -/** - Is Pentium(R) 4 Processors? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_PENTIUM_4_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x0F \ - ) - -/** - 3, 4, 6. Shared. See Section 8.10.5, "Monitor/Mwait Address Range - Determination.". - - @param ECX MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE (0x00000006) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE); - AsmWriteMsr64 (MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE, Msr); - @endcode - @note MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE is defined as IA32_MONITOR_FILTER_LINE_SIZE in SDM. -**/ -#define MSR_PENTIUM_4_IA32_MONITOR_FILTER_LINE_SIZE 0x00000006 - - -/** - 0, 1, 2, 3, 4, 6. Shared. Processor Hard Power-On Configuration (R/W) - Enables and disables processor features; (R) indicates current processor - configuration. - - @param ECX MSR_PENTIUM_4_EBC_HARD_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_HARD_POWERON); - AsmWriteMsr64 (MSR_PENTIUM_4_EBC_HARD_POWERON, Msr.Uint64); - @endcode - @note MSR_PENTIUM_4_EBC_HARD_POWERON is defined as MSR_EBC_HARD_POWERON in SDM. -**/ -#define MSR_PENTIUM_4_EBC_HARD_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_EBC_HARD_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Output Tri-state Enabled (R) Indicates whether tri-state - /// output is enabled (1) or disabled (0) as set by the strapping of SMI#. - /// The value in this bit is written on the deassertion of RESET#; the bit - /// is set to 1 when the address bus signal is asserted. - /// - UINT32 OutputTriStateEnabled:1; - /// - /// [Bit 1] Execute BIST (R) Indicates whether the execution of the BIST - /// is enabled (1) or disabled (0) as set by the strapping of INIT#. The - /// value in this bit is written on the deassertion of RESET#; the bit is - /// set to 1 when the address bus signal is asserted. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 2] In Order Queue Depth (R) Indicates whether the in order queue - /// depth for the system bus is 1 (1) or up to 12 (0) as set by the - /// strapping of A7#. The value in this bit is written on the deassertion - /// of RESET#; the bit is set to 1 when the address bus signal is asserted. - /// - UINT32 InOrderQueueDepth:1; - /// - /// [Bit 3] MCERR# Observation Disabled (R) Indicates whether MCERR# - /// observation is enabled (0) or disabled (1) as determined by the - /// strapping of A9#. The value in this bit is written on the deassertion - /// of RESET#; the bit is set to 1 when the address bus signal is asserted. - /// - UINT32 MCERR_ObservationDisabled:1; - /// - /// [Bit 4] BINIT# Observation Enabled (R) Indicates whether BINIT# - /// observation is enabled (0) or disabled (1) as determined by the - /// strapping of A10#. The value in this bit is written on the deassertion - /// of RESET#; the bit is set to 1 when the address bus signal is asserted. - /// - UINT32 BINIT_ObservationEnabled:1; - /// - /// [Bits 6:5] APIC Cluster ID (R) Contains the logical APIC cluster ID - /// value as set by the strapping of A12# and A11#. The logical cluster ID - /// value is written into the field on the deassertion of RESET#; the - /// field is set to 1 when the address bus signal is asserted. - /// - UINT32 APICClusterID:2; - /// - /// [Bit 7] Bus Park Disable (R) Indicates whether bus park is enabled - /// (0) or disabled (1) as set by the strapping of A15#. The value in this - /// bit is written on the deassertion of RESET#; the bit is set to 1 when - /// the address bus signal is asserted. - /// - UINT32 BusParkDisable:1; - UINT32 Reserved1:4; - /// - /// [Bits 13:12] Agent ID (R) Contains the logical agent ID value as set - /// by the strapping of BR[3:0]. The logical ID value is written into the - /// field on the deassertion of RESET#; the field is set to 1 when the - /// address bus signal is asserted. - /// - UINT32 AgentID:2; - UINT32 Reserved2:18; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_EBC_HARD_POWERON_REGISTER; - - -/** - 0, 1, 2, 3, 4, 6. Shared. Processor Soft Power-On Configuration (R/W) - Enables and disables processor features. - - @param ECX MSR_PENTIUM_4_EBC_SOFT_POWERON (0x0000002B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_SOFT_POWERON); - AsmWriteMsr64 (MSR_PENTIUM_4_EBC_SOFT_POWERON, Msr.Uint64); - @endcode - @note MSR_PENTIUM_4_EBC_SOFT_POWERON is defined as MSR_EBC_SOFT_POWERON in SDM. -**/ -#define MSR_PENTIUM_4_EBC_SOFT_POWERON 0x0000002B - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_EBC_SOFT_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] RCNT/SCNT On Request Encoding Enable (R/W) Controls the - /// driving of RCNT/SCNT on the request encoding. Set to enable (1); clear - /// to disabled (0, default). - /// - UINT32 RCNT_SCNT:1; - /// - /// [Bit 1] Data Error Checking Disable (R/W) Set to disable system data - /// bus parity checking; clear to enable parity checking. - /// - UINT32 DataErrorCheckingDisable:1; - /// - /// [Bit 2] Response Error Checking Disable (R/W) Set to disable - /// (default); clear to enable. - /// - UINT32 ResponseErrorCheckingDisable:1; - /// - /// [Bit 3] Address/Request Error Checking Disable (R/W) Set to disable - /// (default); clear to enable. - /// - UINT32 AddressRequestErrorCheckingDisable:1; - /// - /// [Bit 4] Initiator MCERR# Disable (R/W) Set to disable MCERR# driving - /// for initiator bus requests (default); clear to enable. - /// - UINT32 InitiatorMCERR_Disable:1; - /// - /// [Bit 5] Internal MCERR# Disable (R/W) Set to disable MCERR# driving - /// for initiator internal errors (default); clear to enable. - /// - UINT32 InternalMCERR_Disable:1; - /// - /// [Bit 6] BINIT# Driver Disable (R/W) Set to disable BINIT# driver - /// (default); clear to enable driver. - /// - UINT32 BINIT_DriverDisable:1; - UINT32 Reserved1:25; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_EBC_SOFT_POWERON_REGISTER; - - -/** - 2,3, 4, 6. Shared. Processor Frequency Configuration The bit field layout of - this MSR varies according to the MODEL value in the CPUID version - information. The following bit field layout applies to Pentium 4 and Xeon - Processors with MODEL encoding equal or greater than 2. (R) The field - Indicates the current processor frequency configuration. - - @param ECX MSR_PENTIUM_4_EBC_FREQUENCY_ID (0x0000002C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_FREQUENCY_ID); - @endcode - @note MSR_PENTIUM_4_EBC_FREQUENCY_ID is defined as MSR_EBC_FREQUENCY_ID in SDM. -**/ -#define MSR_PENTIUM_4_EBC_FREQUENCY_ID 0x0000002C - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_EBC_FREQUENCY_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 18:16] Scalable Bus Speed (R/W) Indicates the intended scalable - /// bus speed: *EncodingScalable Bus Speed* - /// - /// 000B 100 MHz (Model 2). - /// 000B 266 MHz (Model 3 or 4) - /// 001B 133 MHz - /// 010B 200 MHz - /// 011B 166 MHz - /// 100B 333 MHz (Model 6) - /// - /// 133.33 MHz should be utilized if performing calculation with System - /// Bus Speed when encoding is 001B. 166.67 MHz should be utilized if - /// performing calculation with System Bus Speed when encoding is 011B. - /// 266.67 MHz should be utilized if performing calculation with System - /// Bus Speed when encoding is 000B and model encoding = 3 or 4. 333.33 - /// MHz should be utilized if performing calculation with System Bus - /// Speed when encoding is 100B and model encoding = 6. All other values - /// are reserved. - /// - UINT32 ScalableBusSpeed:3; - UINT32 Reserved2:5; - /// - /// [Bits 31:24] Core Clock Frequency to System Bus Frequency Ratio (R) - /// The processor core clock frequency to system bus frequency ratio - /// observed at the de-assertion of the reset pin. - /// - UINT32 ClockRatio:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_EBC_FREQUENCY_ID_REGISTER; - - -/** - 0, 1. Shared. Processor Frequency Configuration (R) The bit field layout of - this MSR varies according to the MODEL value of the CPUID version - information. This bit field layout applies to Pentium 4 and Xeon Processors - with MODEL encoding less than 2. Indicates current processor frequency - configuration. - - @param ECX MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 (0x0000002C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_EBC_FREQUENCY_ID_1); - @endcode - @note MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 is defined as MSR_EBC_FREQUENCY_ID_1 in SDM. -**/ -#define MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 0x0000002C - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_EBC_FREQUENCY_ID_1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:21; - /// - /// [Bits 23:21] Scalable Bus Speed (R/W) Indicates the intended scalable - /// bus speed: *Encoding* *Scalable Bus Speed* - /// - /// 000B 100 MHz All others values reserved. - /// - UINT32 ScalableBusSpeed:3; - UINT32 Reserved2:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_EBC_FREQUENCY_ID_1_REGISTER; - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EAX/RAX Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RAX (0x00000180) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RAX); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RAX, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RAX is defined as MSR_MCG_RAX in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RAX 0x00000180 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EBX/RBX Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RBX (0x00000181) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RBX); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RBX, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RBX is defined as MSR_MCG_RBX in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RBX 0x00000181 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check ECX/RCX Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RCX (0x00000182) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RCX); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RCX, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RCX is defined as MSR_MCG_RCX in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RCX 0x00000182 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EDX/RDX Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RDX (0x00000183) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RDX); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RDX, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RDX is defined as MSR_MCG_RDX in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RDX 0x00000183 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check ESI/RSI Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RSI (0x00000184) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RSI); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RSI, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RSI is defined as MSR_MCG_RSI in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RSI 0x00000184 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EDI/RDI Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RDI (0x00000185) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RDI); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RDI, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RDI is defined as MSR_MCG_RDI in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RDI 0x00000185 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EBP/RBP Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RBP (0x00000186) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RBP); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RBP, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RBP is defined as MSR_MCG_RBP in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RBP 0x00000186 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check ESP/RSP Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RSP (0x00000187) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RSP); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RSP, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RSP is defined as MSR_MCG_RSP in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RSP 0x00000187 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EFLAGS/RFLAG Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RFLAGS (0x00000188) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RFLAGS); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RFLAGS, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RFLAGS is defined as MSR_MCG_RFLAGS in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RFLAGS 0x00000188 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check EIP/RIP Save State See Section - 15.3.2.6, "IA32_MCG Extended Machine Check State MSRs.". Contains register - state at time of machine check error. When in non-64-bit modes at the time - of the error, bits 63-32 do not contain valid data. - - @param ECX MSR_PENTIUM_4_MCG_RIP (0x00000189) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_RIP); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_RIP, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_RIP is defined as MSR_MCG_RIP in SDM. -**/ -#define MSR_PENTIUM_4_MCG_RIP 0x00000189 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check Miscellaneous See Section 15.3.2.6, - "IA32_MCG Extended Machine Check State MSRs.". - - @param ECX MSR_PENTIUM_4_MCG_MISC (0x0000018A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_MCG_MISC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_MCG_MISC_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_MCG_MISC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_MCG_MISC); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_MISC, Msr.Uint64); - @endcode - @note MSR_PENTIUM_4_MCG_MISC is defined as MSR_MCG_MISC in SDM. -**/ -#define MSR_PENTIUM_4_MCG_MISC 0x0000018A - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_MCG_MISC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] DS When set, the bit indicates that a page assist or page - /// fault occurred during DS normal operation. The processors response is - /// to shut down. The bit is used as an aid for debugging DS handling - /// code. It is the responsibility of the user (BIOS or operating system) - /// to clear this bit for normal operation. - /// - UINT32 DS:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_MCG_MISC_REGISTER; - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R8 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R8 (0x00000190) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R8); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R8, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R8 is defined as MSR_MCG_R8 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R8 0x00000190 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R9D/R9 See Section 15.3.2.6, - "IA32_MCG Extended Machine Check State MSRs.". Registers R8-15 (and the - associated state-save MSRs) exist only in Intel 64 processors. These - registers contain valid information only when the processor is operating in - 64-bit mode at the time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R9 (0x00000191) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R9); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R9, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R9 is defined as MSR_MCG_R9 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R9 0x00000191 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R10 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R10 (0x00000192) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R10); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R10, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R10 is defined as MSR_MCG_R10 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R10 0x00000192 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R11 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R11 (0x00000193) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R11); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R11, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R11 is defined as MSR_MCG_R11 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R11 0x00000193 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R12 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R12 (0x00000194) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R12); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R12, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R12 is defined as MSR_MCG_R12 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R12 0x00000194 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R13 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R13 (0x00000195) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R13); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R13, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R13 is defined as MSR_MCG_R13 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R13 0x00000195 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R14 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R14 (0x00000196) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R14); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R14, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R14 is defined as MSR_MCG_R14 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R14 0x00000196 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Machine Check R15 See Section 15.3.2.6, "IA32_MCG - Extended Machine Check State MSRs.". Registers R8-15 (and the associated - state-save MSRs) exist only in Intel 64 processors. These registers contain - valid information only when the processor is operating in 64-bit mode at the - time of the error. - - @param ECX MSR_PENTIUM_4_MCG_R15 (0x00000197) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MCG_R15); - AsmWriteMsr64 (MSR_PENTIUM_4_MCG_R15, Msr); - @endcode - @note MSR_PENTIUM_4_MCG_R15 is defined as MSR_MCG_R15 in SDM. -**/ -#define MSR_PENTIUM_4_MCG_R15 0x00000197 - - -/** - Thermal Monitor 2 Control. 3,. Shared. For Family F, Model 3 processors: - When read, specifies the value of the target TM2 transition last written. - When set, it sets the next target value for TM2 transition. 4, 6. Shared. - For Family F, Model 4 and Model 6 processors: When read, specifies the value - of the target TM2 transition last written. Writes may cause #GP exceptions. - - @param ECX MSR_PENTIUM_4_THERM2_CTL (0x0000019D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_THERM2_CTL); - AsmWriteMsr64 (MSR_PENTIUM_4_THERM2_CTL, Msr); - @endcode - @note MSR_PENTIUM_4_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. -**/ -#define MSR_PENTIUM_4_THERM2_CTL 0x0000019D - - -/** - 0, 1, 2, 3, 4, 6. Shared. Enable Miscellaneous Processor Features (R/W). - - @param ECX MSR_PENTIUM_4_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_PENTIUM_4_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_PENTIUM_4_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_PENTIUM_4_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fast-Strings Enable. See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] x87 FPU Fopcode Compatibility Mode Enable. - /// - UINT32 FPU:1; - /// - /// [Bit 3] Thermal Monitor 1 Enable See Section 14.7.2, "Thermal - /// Monitor," and see Table 35-2. - /// - UINT32 TM1:1; - /// - /// [Bit 4] Split-Lock Disable When set, the bit causes an #AC exception - /// to be issued instead of a split-lock cycle. Operating systems that set - /// this bit must align system structures to avoid split-lock scenarios. - /// When the bit is clear (default), normal split-locks are issued to the - /// bus. - /// This debug feature is specific to the Pentium 4 processor. - /// - UINT32 SplitLockDisable:1; - UINT32 Reserved2:1; - /// - /// [Bit 6] Third-Level Cache Disable (R/W) When set, the third-level - /// cache is disabled; when clear (default) the third-level cache is - /// enabled. This flag is reserved for processors that do not have a - /// third-level cache. Note that the bit controls only the third-level - /// cache; and only if overall caching is enabled through the CD flag of - /// control register CR0, the page-level cache controls, and/or the MTRRs. - /// See Section 11.5.4, "Disabling and Enabling the L3 Cache.". - /// - UINT32 ThirdLevelCacheDisable:1; - /// - /// [Bit 7] Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - /// - /// [Bit 8] Suppress Lock Enable When set, assertion of LOCK on the bus is - /// suppressed during a Split Lock access. When clear (default), LOCK is - /// not suppressed. - /// - UINT32 SuppressLockEnable:1; - /// - /// [Bit 9] Prefetch Queue Disable When set, disables the prefetch queue. - /// When clear (default), enables the prefetch queue. - /// - UINT32 PrefetchQueueDisable:1; - /// - /// [Bit 10] FERR# Interrupt Reporting Enable (R/W) When set, interrupt - /// reporting through the FERR# pin is enabled; when clear, this interrupt - /// reporting function is disabled. - /// When this flag is set and the processor is in the stop-clock state - /// (STPCLK# is asserted), asserting the FERR# pin signals to the - /// processor that an interrupt (such as, INIT#, BINIT#, INTR, NMI, - /// SMI#, or RESET#) is pending and that the processor should return to - /// normal operation to handle the interrupt. This flag does not affect - /// the normal operation of the FERR# pin (to indicate an unmasked - /// floatingpoint error) when the STPCLK# pin is not asserted. - /// - UINT32 FERR:1; - /// - /// [Bit 11] Branch Trace Storage Unavailable (BTS_UNAVILABLE) (R) See - /// Table 35-2. When set, the processor does not support branch trace - /// storage (BTS); when clear, BTS is supported. - /// - UINT32 BTS:1; - /// - /// [Bit 12] PEBS_UNAVILABLE: Processor Event Based Sampling Unavailable - /// (R) See Table 35-2. When set, the processor does not support processor - /// event-based sampling (PEBS); when clear, PEBS is supported. - /// - UINT32 PEBS:1; - /// - /// [Bit 13] 3. TM2 Enable (R/W) When this bit is set (1) and the thermal - /// sensor indicates that the die temperature is at the predetermined - /// threshold, the Thermal Monitor 2 mechanism is engaged. TM2 will reduce - /// the bus to core ratio and voltage according to the value last written - /// to MSR_THERM2_CTL bits 15:0. When this bit is clear (0, default), the - /// processor does not change the VID signals or the bus to core ratio - /// when the processor enters a thermal managed state. If the TM2 feature - /// flag (ECX[8]) is not set to 1 after executing CPUID with EAX = 1, then - /// this feature is not supported and BIOS must not alter the contents of - /// this bit location. The processor is operating out of spec if both this - /// bit and the TM1 bit are set to disabled states. - /// - UINT32 TM2:1; - UINT32 Reserved3:4; - /// - /// [Bit 18] 3, 4, 6. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - /// - /// [Bit 19] Adjacent Cache Line Prefetch Disable (R/W) When set to 1, - /// the processor fetches the cache line of the 128-byte sector containing - /// currently required data. When set to 0, the processor fetches both - /// cache lines in the sector. - /// Single processor platforms should not set this bit. Server platforms - /// should set or clear this bit based on platform performance observed - /// in validation and testing. BIOS may contain a setup option that - /// controls the setting of this bit. - /// - UINT32 AdjacentCacheLinePrefetchDisable:1; - UINT32 Reserved4:2; - /// - /// [Bit 22] 3, 4, 6. Limit CPUID MAXVAL (R/W) See Table 35-2. Setting - /// this can cause unexpected behavior to software that depends on the - /// availability of CPUID leaves greater than 3. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Shared. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - /// - /// [Bit 24] L1 Data Cache Context Mode (R/W) When set, the L1 data cache - /// is placed in shared mode; when clear (default), the cache is placed in - /// adaptive mode. This bit is only enabled for IA-32 processors that - /// support Intel Hyper-Threading Technology. See Section 11.5.6, "L1 Data - /// Cache Context Mode." When L1 is running in adaptive mode and CR3s are - /// identical, data in L1 is shared across logical processors. Otherwise, - /// L1 is not shared and cache use is competitive. If the Context ID - /// feature flag (ECX[10]) is set to 0 after executing CPUID with EAX = 1, - /// the ability to switch modes is not supported. BIOS must not alter the - /// contents of IA32_MISC_ENABLE[24]. - /// - UINT32 L1DataCacheContextMode:1; - UINT32 Reserved5:7; - UINT32 Reserved6:2; - /// - /// [Bit 34] Unique. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved7:29; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_IA32_MISC_ENABLE_REGISTER; - - -/** - 3, 4, 6. Shared. Platform Feature Requirements (R). - - @param ECX MSR_PENTIUM_4_PLATFORM_BRV (0x000001A1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_PLATFORM_BRV_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_PLATFORM_BRV_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_PLATFORM_BRV_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_PLATFORM_BRV); - @endcode - @note MSR_PENTIUM_4_PLATFORM_BRV is defined as MSR_PLATFORM_BRV in SDM. -**/ -#define MSR_PENTIUM_4_PLATFORM_BRV 0x000001A1 - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_PLATFORM_BRV -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:18; - /// - /// [Bit 18] PLATFORM Requirements When set to 1, indicates the processor - /// has specific platform requirements. The details of the platform - /// requirements are listed in the respective data sheets of the processor. - /// - UINT32 PLATFORM:1; - UINT32 Reserved2:13; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_PLATFORM_BRV_REGISTER; - - -/** - 0, 1, 2, 3, 4, 6. Unique. Last Exception Record From Linear IP (R) Contains - a pointer to the last branch instruction that the processor executed prior - to the last exception that was generated or the last interrupt that was - handled. See Section 17.11.3, "Last Exception Records.". Unique. From Linear - IP Linear address of the last branch instruction (If IA32e mode is active). - From Linear IP Linear address of the last branch instruction. Reserved. - - @param ECX MSR_PENTIUM_4_LER_FROM_LIP (0x000001D7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LER_FROM_LIP); - @endcode - @note MSR_PENTIUM_4_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_PENTIUM_4_LER_FROM_LIP 0x000001D7 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Last Exception Record To Linear IP (R) This area - contains a pointer to the target of the last branch instruction that the - processor executed prior to the last exception that was generated or the - last interrupt that was handled. See Section 17.11.3, "Last Exception - Records.". Unique. From Linear IP Linear address of the target of the last - branch instruction (If IA-32e mode is active). From Linear IP Linear address - of the target of the last branch instruction. Reserved. - - @param ECX MSR_PENTIUM_4_LER_TO_LIP (0x000001D8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LER_TO_LIP); - @endcode - @note MSR_PENTIUM_4_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_PENTIUM_4_LER_TO_LIP 0x000001D8 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Debug Control (R/W) Controls how several debug - features are used. Bit definitions are discussed in the referenced section. - See Section 17.11.1, "MSR_DEBUGCTLA MSR.". - - @param ECX MSR_PENTIUM_4_DEBUGCTLA (0x000001D9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_DEBUGCTLA); - AsmWriteMsr64 (MSR_PENTIUM_4_DEBUGCTLA, Msr); - @endcode - @note MSR_PENTIUM_4_DEBUGCTLA is defined as MSR_DEBUGCTLA in SDM. -**/ -#define MSR_PENTIUM_4_DEBUGCTLA 0x000001D9 - - -/** - 0, 1, 2, 3, 4, 6. Unique. Last Branch Record Stack TOS (R/W) Contains an - index (0-3 or 0-15) that points to the top of the last branch record stack - (that is, that points the index of the MSR containing the most recent branch - record). See Section 17.11.2, "LBR Stack for Processors Based on Intel - NetBurst(R) Microarchitecture"; and addresses 1DBH-1DEH and 680H-68FH. - - @param ECX MSR_PENTIUM_4_LASTBRANCH_TOS (0x000001DA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_PENTIUM_4_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_PENTIUM_4_LASTBRANCH_TOS 0x000001DA - - -/** - 0, 1, 2. Unique. Last Branch Record n (R/W) One of four last branch record - registers on the last branch record stack. It contains pointers to the - source and destination instruction for one of the last four branches, - exceptions, or interrupts that the processor took. MSR_LASTBRANCH_0 through - MSR_LASTBRANCH_3 at 1DBH-1DEH are available only on family 0FH, models - 0H-02H. They have been replaced by the MSRs at 680H68FH and 6C0H-6CFH. See - Section 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording - for Processors based on Skylake Microarchitecture.". - - @param ECX MSR_PENTIUM_4_LASTBRANCH_n - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0); - AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0, Msr); - @endcode - @note MSR_PENTIUM_4_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. - MSR_PENTIUM_4_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. - MSR_PENTIUM_4_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. - MSR_PENTIUM_4_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_LASTBRANCH_0 0x000001DB -#define MSR_PENTIUM_4_LASTBRANCH_1 0x000001DC -#define MSR_PENTIUM_4_LASTBRANCH_2 0x000001DD -#define MSR_PENTIUM_4_LASTBRANCH_3 0x000001DE -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". - - @param ECX MSR_PENTIUM_4_BPU_COUNTERn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_COUNTER0); - AsmWriteMsr64 (MSR_PENTIUM_4_BPU_COUNTER0, Msr); - @endcode - @note MSR_PENTIUM_4_BPU_COUNTER0 is defined as MSR_BPU_COUNTER0 in SDM. - MSR_PENTIUM_4_BPU_COUNTER1 is defined as MSR_BPU_COUNTER1 in SDM. - MSR_PENTIUM_4_BPU_COUNTER2 is defined as MSR_BPU_COUNTER2 in SDM. - MSR_PENTIUM_4_BPU_COUNTER3 is defined as MSR_BPU_COUNTER3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_BPU_COUNTER0 0x00000300 -#define MSR_PENTIUM_4_BPU_COUNTER1 0x00000301 -#define MSR_PENTIUM_4_BPU_COUNTER2 0x00000302 -#define MSR_PENTIUM_4_BPU_COUNTER3 0x00000303 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". - - @param ECX MSR_PENTIUM_4_MS_COUNTERn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_COUNTER0); - AsmWriteMsr64 (MSR_PENTIUM_4_MS_COUNTER0, Msr); - @endcode - @note MSR_PENTIUM_4_MS_COUNTER0 is defined as MSR_MS_COUNTER0 in SDM. - MSR_PENTIUM_4_MS_COUNTER1 is defined as MSR_MS_COUNTER1 in SDM. - MSR_PENTIUM_4_MS_COUNTER2 is defined as MSR_MS_COUNTER2 in SDM. - MSR_PENTIUM_4_MS_COUNTER3 is defined as MSR_MS_COUNTER3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_MS_COUNTER0 0x00000304 -#define MSR_PENTIUM_4_MS_COUNTER1 0x00000305 -#define MSR_PENTIUM_4_MS_COUNTER2 0x00000306 -#define MSR_PENTIUM_4_MS_COUNTER3 0x00000307 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". - - @param ECX MSR_PENTIUM_4_FLAME_COUNTERn (0x00000308) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_COUNTER0); - AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_COUNTER0, Msr); - @endcode - @note MSR_PENTIUM_4_FLAME_COUNTER0 is defined as MSR_FLAME_COUNTER0 in SDM. - MSR_PENTIUM_4_FLAME_COUNTER1 is defined as MSR_FLAME_COUNTER1 in SDM. - MSR_PENTIUM_4_FLAME_COUNTER2 is defined as MSR_FLAME_COUNTER2 in SDM. - MSR_PENTIUM_4_FLAME_COUNTER3 is defined as MSR_FLAME_COUNTER3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_FLAME_COUNTER0 0x00000308 -#define MSR_PENTIUM_4_FLAME_COUNTER1 0x00000309 -#define MSR_PENTIUM_4_FLAME_COUNTER2 0x0000030A -#define MSR_PENTIUM_4_FLAME_COUNTER3 0x0000030B -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.2, "Performance Counters.". - - @param ECX MSR_PENTIUM_4_IQ_COUNTERn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_COUNTER0); - AsmWriteMsr64 (MSR_PENTIUM_4_IQ_COUNTER0, Msr); - @endcode - @note MSR_PENTIUM_4_IQ_COUNTER0 is defined as MSR_IQ_COUNTER0 in SDM. - MSR_PENTIUM_4_IQ_COUNTER1 is defined as MSR_IQ_COUNTER1 in SDM. - MSR_PENTIUM_4_IQ_COUNTER2 is defined as MSR_IQ_COUNTER2 in SDM. - MSR_PENTIUM_4_IQ_COUNTER3 is defined as MSR_IQ_COUNTER3 in SDM. - MSR_PENTIUM_4_IQ_COUNTER4 is defined as MSR_IQ_COUNTER4 in SDM. - MSR_PENTIUM_4_IQ_COUNTER5 is defined as MSR_IQ_COUNTER5 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_IQ_COUNTER0 0x0000030C -#define MSR_PENTIUM_4_IQ_COUNTER1 0x0000030D -#define MSR_PENTIUM_4_IQ_COUNTER2 0x0000030E -#define MSR_PENTIUM_4_IQ_COUNTER3 0x0000030F -#define MSR_PENTIUM_4_IQ_COUNTER4 0x00000310 -#define MSR_PENTIUM_4_IQ_COUNTER5 0x00000311 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". - - @param ECX MSR_PENTIUM_4_BPU_CCCRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_CCCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_BPU_CCCR0, Msr); - @endcode - @note MSR_PENTIUM_4_BPU_CCCR0 is defined as MSR_BPU_CCCR0 in SDM. - MSR_PENTIUM_4_BPU_CCCR1 is defined as MSR_BPU_CCCR1 in SDM. - MSR_PENTIUM_4_BPU_CCCR2 is defined as MSR_BPU_CCCR2 in SDM. - MSR_PENTIUM_4_BPU_CCCR3 is defined as MSR_BPU_CCCR3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_BPU_CCCR0 0x00000360 -#define MSR_PENTIUM_4_BPU_CCCR1 0x00000361 -#define MSR_PENTIUM_4_BPU_CCCR2 0x00000362 -#define MSR_PENTIUM_4_BPU_CCCR3 0x00000363 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". - - @param ECX MSR_PENTIUM_4_MS_CCCRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_CCCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_MS_CCCR0, Msr); - @endcode - @note MSR_PENTIUM_4_MS_CCCR0 is defined as MSR_MS_CCCR0 in SDM. - MSR_PENTIUM_4_MS_CCCR1 is defined as MSR_MS_CCCR1 in SDM. - MSR_PENTIUM_4_MS_CCCR2 is defined as MSR_MS_CCCR2 in SDM. - MSR_PENTIUM_4_MS_CCCR3 is defined as MSR_MS_CCCR3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_MS_CCCR0 0x00000364 -#define MSR_PENTIUM_4_MS_CCCR1 0x00000365 -#define MSR_PENTIUM_4_MS_CCCR2 0x00000366 -#define MSR_PENTIUM_4_MS_CCCR3 0x00000367 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". - - @param ECX MSR_PENTIUM_4_FLAME_CCCRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_CCCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_CCCR0, Msr); - @endcode - @note MSR_PENTIUM_4_FLAME_CCCR0 is defined as MSR_FLAME_CCCR0 in SDM. - MSR_PENTIUM_4_FLAME_CCCR1 is defined as MSR_FLAME_CCCR1 in SDM. - MSR_PENTIUM_4_FLAME_CCCR2 is defined as MSR_FLAME_CCCR2 in SDM. - MSR_PENTIUM_4_FLAME_CCCR3 is defined as MSR_FLAME_CCCR3 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_FLAME_CCCR0 0x00000368 -#define MSR_PENTIUM_4_FLAME_CCCR1 0x00000369 -#define MSR_PENTIUM_4_FLAME_CCCR2 0x0000036A -#define MSR_PENTIUM_4_FLAME_CCCR3 0x0000036B -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.3, "CCCR MSRs.". - - @param ECX MSR_PENTIUM_4_IQ_CCCRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_CCCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_IQ_CCCR0, Msr); - @endcode - @note MSR_PENTIUM_4_IQ_CCCR0 is defined as MSR_IQ_CCCR0 in SDM. - MSR_PENTIUM_4_IQ_CCCR1 is defined as MSR_IQ_CCCR1 in SDM. - MSR_PENTIUM_4_IQ_CCCR2 is defined as MSR_IQ_CCCR2 in SDM. - MSR_PENTIUM_4_IQ_CCCR3 is defined as MSR_IQ_CCCR3 in SDM. - MSR_PENTIUM_4_IQ_CCCR4 is defined as MSR_IQ_CCCR4 in SDM. - MSR_PENTIUM_4_IQ_CCCR5 is defined as MSR_IQ_CCCR5 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_IQ_CCCR0 0x0000036C -#define MSR_PENTIUM_4_IQ_CCCR1 0x0000036D -#define MSR_PENTIUM_4_IQ_CCCR2 0x0000036E -#define MSR_PENTIUM_4_IQ_CCCR3 0x0000036F -#define MSR_PENTIUM_4_IQ_CCCR4 0x00000370 -#define MSR_PENTIUM_4_IQ_CCCR5 0x00000371 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_BSU_ESCR0 (0x000003A0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BSU_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_BSU_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_BSU_ESCR0 is defined as MSR_BSU_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_BSU_ESCR0 0x000003A0 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_BSU_ESCR1 (0x000003A1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BSU_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_BSU_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_BSU_ESCR1 is defined as MSR_BSU_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_BSU_ESCR1 0x000003A1 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FSB_ESCR0 (0x000003A2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FSB_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_FSB_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_FSB_ESCR0 is defined as MSR_FSB_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_FSB_ESCR0 0x000003A2 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FSB_ESCR1 (0x000003A3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FSB_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_FSB_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_FSB_ESCR1 is defined as MSR_FSB_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_FSB_ESCR1 0x000003A3 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FIRM_ESCR0 (0x000003A4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FIRM_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_FIRM_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_FIRM_ESCR0 is defined as MSR_FIRM_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_FIRM_ESCR0 0x000003A4 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FIRM_ESCR1 (0x000003A5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FIRM_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_FIRM_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_FIRM_ESCR1 is defined as MSR_FIRM_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_FIRM_ESCR1 0x000003A5 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FLAME_ESCR0 (0x000003A6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_FLAME_ESCR0 is defined as MSR_FLAME_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_FLAME_ESCR0 0x000003A6 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_FLAME_ESCR1 (0x000003A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_FLAME_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_FLAME_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_FLAME_ESCR1 is defined as MSR_FLAME_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_FLAME_ESCR1 0x000003A7 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_DAC_ESCR0 (0x000003A8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_DAC_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_DAC_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_DAC_ESCR0 is defined as MSR_DAC_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_DAC_ESCR0 0x000003A8 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_DAC_ESCR1 (0x000003A9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_DAC_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_DAC_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_DAC_ESCR1 is defined as MSR_DAC_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_DAC_ESCR1 0x000003A9 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_MOB_ESCR0 (0x000003AA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MOB_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_MOB_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_MOB_ESCR0 is defined as MSR_MOB_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_MOB_ESCR0 0x000003AA - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_MOB_ESCR1 (0x000003AB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MOB_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_MOB_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_MOB_ESCR1 is defined as MSR_MOB_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_MOB_ESCR1 0x000003AB - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_PMH_ESCR0 (0x000003AC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_PMH_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_PMH_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_PMH_ESCR0 is defined as MSR_PMH_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_PMH_ESCR0 0x000003AC - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_PMH_ESCR1 (0x000003AD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_PMH_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_PMH_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_PMH_ESCR1 is defined as MSR_PMH_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_PMH_ESCR1 0x000003AD - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_SAAT_ESCR0 (0x000003AE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_SAAT_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_SAAT_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_SAAT_ESCR0 is defined as MSR_SAAT_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_SAAT_ESCR0 0x000003AE - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_SAAT_ESCR1 (0x000003AF) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_SAAT_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_SAAT_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_SAAT_ESCR1 is defined as MSR_SAAT_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_SAAT_ESCR1 0x000003AF - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_U2L_ESCR0 (0x000003B0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_U2L_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_U2L_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_U2L_ESCR0 is defined as MSR_U2L_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_U2L_ESCR0 0x000003B0 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_U2L_ESCR1 (0x000003B1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_U2L_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_U2L_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_U2L_ESCR1 is defined as MSR_U2L_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_U2L_ESCR1 0x000003B1 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_BPU_ESCR0 (0x000003B2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_BPU_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_BPU_ESCR0 is defined as MSR_BPU_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_BPU_ESCR0 0x000003B2 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_BPU_ESCR1 (0x000003B3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_BPU_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_BPU_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_BPU_ESCR1 is defined as MSR_BPU_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_BPU_ESCR1 0x000003B3 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_IS_ESCR0 (0x000003B4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IS_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_IS_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_IS_ESCR0 is defined as MSR_IS_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_IS_ESCR0 0x000003B4 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_IS_ESCR1 (0x000003B5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IS_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_IS_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_IS_ESCR1 is defined as MSR_IS_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_IS_ESCR1 0x000003B5 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_ITLB_ESCR0 (0x000003B6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_ITLB_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_ITLB_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_ITLB_ESCR0 is defined as MSR_ITLB_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_ITLB_ESCR0 0x000003B6 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_ITLB_ESCR1 (0x000003B7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_ITLB_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_ITLB_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_ITLB_ESCR1 is defined as MSR_ITLB_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_ITLB_ESCR1 0x000003B7 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_CRU_ESCR0 (0x000003B8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_CRU_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_CRU_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_CRU_ESCR0 is defined as MSR_CRU_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_CRU_ESCR0 0x000003B8 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_CRU_ESCR1 (0x000003B9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_CRU_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_CRU_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_CRU_ESCR1 is defined as MSR_CRU_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_CRU_ESCR1 0x000003B9 - - -/** - 0, 1, 2. Shared. See Section 18.15.1, "ESCR MSRs." This MSR is not available - on later processors. It is only available on processor family 0FH, models - 01H-02H. - - @param ECX MSR_PENTIUM_4_IQ_ESCR0 (0x000003BA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_IQ_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_IQ_ESCR0 is defined as MSR_IQ_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_IQ_ESCR0 0x000003BA - - -/** - 0, 1, 2. Shared. See Section 18.15.1, "ESCR MSRs." This MSR is not available - on later processors. It is only available on processor family 0FH, models - 01H-02H. - - @param ECX MSR_PENTIUM_4_IQ_ESCR1 (0x000003BB) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IQ_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_IQ_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_IQ_ESCR1 is defined as MSR_IQ_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_IQ_ESCR1 0x000003BB - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_RAT_ESCR0 (0x000003BC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_RAT_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_RAT_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_RAT_ESCR0 is defined as MSR_RAT_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_RAT_ESCR0 0x000003BC - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_RAT_ESCR1 (0x000003BD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_RAT_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_RAT_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_RAT_ESCR1 is defined as MSR_RAT_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_RAT_ESCR1 0x000003BD - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_SSU_ESCR0 (0x000003BE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_SSU_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_SSU_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_SSU_ESCR0 is defined as MSR_SSU_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_SSU_ESCR0 0x000003BE - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_MS_ESCR0 (0x000003C0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_MS_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_MS_ESCR0 is defined as MSR_MS_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_MS_ESCR0 0x000003C0 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_MS_ESCR1 (0x000003C1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_MS_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_MS_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_MS_ESCR1 is defined as MSR_MS_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_MS_ESCR1 0x000003C1 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_TBPU_ESCR0 (0x000003C2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_TBPU_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_TBPU_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_TBPU_ESCR0 is defined as MSR_TBPU_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_TBPU_ESCR0 0x000003C2 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_TBPU_ESCR1 (0x000003C3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_TBPU_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_TBPU_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_TBPU_ESCR1 is defined as MSR_TBPU_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_TBPU_ESCR1 0x000003C3 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_TC_ESCR0 (0x000003C4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_TC_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_TC_ESCR0 is defined as MSR_TC_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_TC_ESCR0 0x000003C4 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_TC_ESCR1 (0x000003C5) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_TC_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_TC_ESCR1 is defined as MSR_TC_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_TC_ESCR1 0x000003C5 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_IX_ESCR0 (0x000003C8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IX_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_IX_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_IX_ESCR0 is defined as MSR_IX_ESCR0 in SDM. -**/ -#define MSR_PENTIUM_4_IX_ESCR0 0x000003C8 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_IX_ESCR1 (0x000003C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IX_ESCR1); - AsmWriteMsr64 (MSR_PENTIUM_4_IX_ESCR1, Msr); - @endcode - @note MSR_PENTIUM_4_IX_ESCR1 is defined as MSR_IX_ESCR1 in SDM. -**/ -#define MSR_PENTIUM_4_IX_ESCR1 0x000003C9 - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_ALF_ESCRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_ALF_ESCR0); - AsmWriteMsr64 (MSR_PENTIUM_4_ALF_ESCR0, Msr); - @endcode - @note MSR_PENTIUM_4_ALF_ESCR0 is defined as MSR_ALF_ESCR0 in SDM. - MSR_PENTIUM_4_ALF_ESCR1 is defined as MSR_ALF_ESCR1 in SDM. - MSR_PENTIUM_4_CRU_ESCR2 is defined as MSR_CRU_ESCR2 in SDM. - MSR_PENTIUM_4_CRU_ESCR3 is defined as MSR_CRU_ESCR3 in SDM. - MSR_PENTIUM_4_CRU_ESCR4 is defined as MSR_CRU_ESCR4 in SDM. - MSR_PENTIUM_4_CRU_ESCR5 is defined as MSR_CRU_ESCR5 in SDM. - @{ -**/ -#define MSR_PENTIUM_4_ALF_ESCR0 0x000003CA -#define MSR_PENTIUM_4_ALF_ESCR1 0x000003CB -#define MSR_PENTIUM_4_CRU_ESCR2 0x000003CC -#define MSR_PENTIUM_4_CRU_ESCR3 0x000003CD -#define MSR_PENTIUM_4_CRU_ESCR4 0x000003E0 -#define MSR_PENTIUM_4_CRU_ESCR5 0x000003E1 -/// @} - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Section 18.15.1, "ESCR MSRs.". - - @param ECX MSR_PENTIUM_4_TC_PRECISE_EVENT (0x000003F0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_TC_PRECISE_EVENT); - AsmWriteMsr64 (MSR_PENTIUM_4_TC_PRECISE_EVENT, Msr); - @endcode - @note MSR_PENTIUM_4_TC_PRECISE_EVENT is defined as MSR_TC_PRECISE_EVENT in SDM. -**/ -#define MSR_PENTIUM_4_TC_PRECISE_EVENT 0x000003F0 - - -/** - 0, 1, 2, 3, 4, 6. Shared. Processor Event Based Sampling (PEBS) (R/W) - Controls the enabling of processor event sampling and replay tagging. - - @param ECX MSR_PENTIUM_4_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_4_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_PENTIUM_4_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_4_PEBS_ENABLE); - AsmWriteMsr64 (MSR_PENTIUM_4_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_PENTIUM_4_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_PENTIUM_4_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_PENTIUM_4_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 12:0] See Table 19-33. - /// - UINT32 EventNum:13; - UINT32 Reserved1:11; - /// - /// [Bit 24] UOP Tag Enables replay tagging when set. - /// - UINT32 UOP:1; - /// - /// [Bit 25] ENABLE_PEBS_MY_THR (R/W) Enables PEBS for the target logical - /// processor when set; disables PEBS when clear (default). See Section - /// 18.16.3, "IA32_PEBS_ENABLE MSR," for an explanation of the target - /// logical processor. This bit is called ENABLE_PEBS in IA-32 processors - /// that do not support Intel HyperThreading Technology. - /// - UINT32 ENABLE_PEBS_MY_THR:1; - /// - /// [Bit 26] ENABLE_PEBS_OTH_THR (R/W) Enables PEBS for the target logical - /// processor when set; disables PEBS when clear (default). See Section - /// 18.16.3, "IA32_PEBS_ENABLE MSR," for an explanation of the target - /// logical processor. This bit is reserved for IA-32 processors that do - /// not support Intel Hyper-Threading Technology. - /// - UINT32 ENABLE_PEBS_OTH_THR:1; - UINT32 Reserved2:5; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_4_PEBS_ENABLE_REGISTER; - - -/** - 0, 1, 2, 3, 4, 6. Shared. See Table 19-33. - - @param ECX MSR_PENTIUM_4_PEBS_MATRIX_VERT (0x000003F2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_PEBS_MATRIX_VERT); - AsmWriteMsr64 (MSR_PENTIUM_4_PEBS_MATRIX_VERT, Msr); - @endcode - @note MSR_PENTIUM_4_PEBS_MATRIX_VERT is defined as MSR_PEBS_MATRIX_VERT in SDM. -**/ -#define MSR_PENTIUM_4_PEBS_MATRIX_VERT 0x000003F2 - - -/** - 3, 4, 6. Unique. Last Branch Record n (R/W) One of 16 pairs of last branch - record registers on the last branch record stack (680H-68FH). This part of - the stack contains pointers to the source instruction for one of the last 16 - branches, exceptions, or interrupts taken by the processor. The MSRs at - 680H-68FH, 6C0H-6CfH are not available in processor releases before family - 0FH, model 03H. These MSRs replace MSRs previously located at - 1DBH-1DEH.which performed the same function for early releases. See Section - 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording for - Processors based on Skylake Microarchitecture.". - - @param ECX MSR_PENTIUM_4_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. - @{ -**/ -#define MSR_PENTIUM_4_LASTBRANCH_0_FROM_IP 0x00000680 -#define MSR_PENTIUM_4_LASTBRANCH_1_FROM_IP 0x00000681 -#define MSR_PENTIUM_4_LASTBRANCH_2_FROM_IP 0x00000682 -#define MSR_PENTIUM_4_LASTBRANCH_3_FROM_IP 0x00000683 -#define MSR_PENTIUM_4_LASTBRANCH_4_FROM_IP 0x00000684 -#define MSR_PENTIUM_4_LASTBRANCH_5_FROM_IP 0x00000685 -#define MSR_PENTIUM_4_LASTBRANCH_6_FROM_IP 0x00000686 -#define MSR_PENTIUM_4_LASTBRANCH_7_FROM_IP 0x00000687 -#define MSR_PENTIUM_4_LASTBRANCH_8_FROM_IP 0x00000688 -#define MSR_PENTIUM_4_LASTBRANCH_9_FROM_IP 0x00000689 -#define MSR_PENTIUM_4_LASTBRANCH_10_FROM_IP 0x0000068A -#define MSR_PENTIUM_4_LASTBRANCH_11_FROM_IP 0x0000068B -#define MSR_PENTIUM_4_LASTBRANCH_12_FROM_IP 0x0000068C -#define MSR_PENTIUM_4_LASTBRANCH_13_FROM_IP 0x0000068D -#define MSR_PENTIUM_4_LASTBRANCH_14_FROM_IP 0x0000068E -#define MSR_PENTIUM_4_LASTBRANCH_15_FROM_IP 0x0000068F -/// @} - - -/** - 3, 4, 6. Unique. Last Branch Record n (R/W) One of 16 pairs of last branch - record registers on the last branch record stack (6C0H-6CFH). This part of - the stack contains pointers to the destination instruction for one of the - last 16 branches, exceptions, or interrupts that the processor took. See - Section 17.10, "Last Branch, Call Stack, Interrupt, and Exception Recording - for Processors based on Skylake Microarchitecture.". - - @param ECX MSR_PENTIUM_4_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_PENTIUM_4_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_PENTIUM_4_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. - MSR_PENTIUM_4_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. - @{ -**/ -#define MSR_PENTIUM_4_LASTBRANCH_0_TO_IP 0x000006C0 -#define MSR_PENTIUM_4_LASTBRANCH_1_TO_IP 0x000006C1 -#define MSR_PENTIUM_4_LASTBRANCH_2_TO_IP 0x000006C2 -#define MSR_PENTIUM_4_LASTBRANCH_3_TO_IP 0x000006C3 -#define MSR_PENTIUM_4_LASTBRANCH_4_TO_IP 0x000006C4 -#define MSR_PENTIUM_4_LASTBRANCH_5_TO_IP 0x000006C5 -#define MSR_PENTIUM_4_LASTBRANCH_6_TO_IP 0x000006C6 -#define MSR_PENTIUM_4_LASTBRANCH_7_TO_IP 0x000006C7 -#define MSR_PENTIUM_4_LASTBRANCH_8_TO_IP 0x000006C8 -#define MSR_PENTIUM_4_LASTBRANCH_9_TO_IP 0x000006C9 -#define MSR_PENTIUM_4_LASTBRANCH_10_TO_IP 0x000006CA -#define MSR_PENTIUM_4_LASTBRANCH_11_TO_IP 0x000006CB -#define MSR_PENTIUM_4_LASTBRANCH_12_TO_IP 0x000006CC -#define MSR_PENTIUM_4_LASTBRANCH_13_TO_IP 0x000006CD -#define MSR_PENTIUM_4_LASTBRANCH_14_TO_IP 0x000006CE -#define MSR_PENTIUM_4_LASTBRANCH_15_TO_IP 0x000006CF -/// @} - - -/** - 3, 4. Shared. IFSB BUSQ Event Control and Counter Register (R/W) See - Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP - with Up to 8-MByte L3 Cache.". - - @param ECX MSR_PENTIUM_4_IFSB_BUSQ0 (0x000107CC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_BUSQ0); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_BUSQ0, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_BUSQ0 is defined as MSR_IFSB_BUSQ0 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_BUSQ0 0x000107CC - - -/** - 3, 4. Shared. IFSB BUSQ Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_IFSB_BUSQ1 (0x000107CD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_BUSQ1); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_BUSQ1, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_BUSQ1 is defined as MSR_IFSB_BUSQ1 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_BUSQ1 0x000107CD - - -/** - 3, 4. Shared. IFSB SNPQ Event Control and Counter Register (R/W) See - Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP - with Up to 8-MByte L3 Cache.". - - @param ECX MSR_PENTIUM_4_IFSB_SNPQ0 (0x000107CE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_SNPQ0); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_SNPQ0, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_SNPQ0 is defined as MSR_IFSB_SNPQ0 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_SNPQ0 0x000107CE - - -/** - 3, 4. Shared. IFSB SNPQ Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_IFSB_SNPQ1 (0x000107CF) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_SNPQ1); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_SNPQ1, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_SNPQ1 is defined as MSR_IFSB_SNPQ1 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_SNPQ1 0x000107CF - - -/** - 3, 4. Shared. EFSB DRDY Event Control and Counter Register (R/W) See - Section 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP - with Up to 8-MByte L3 Cache" for details. - - @param ECX MSR_PENTIUM_4_EFSB_DRDY0 (0x000107D0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EFSB_DRDY0); - AsmWriteMsr64 (MSR_PENTIUM_4_EFSB_DRDY0, Msr); - @endcode - @note MSR_PENTIUM_4_EFSB_DRDY0 is defined as MSR_EFSB_DRDY0 in SDM. -**/ -#define MSR_PENTIUM_4_EFSB_DRDY0 0x000107D0 - - -/** - 3, 4. Shared. EFSB DRDY Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EFSB_DRDY1 (0x000107D1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EFSB_DRDY1); - AsmWriteMsr64 (MSR_PENTIUM_4_EFSB_DRDY1, Msr); - @endcode - @note MSR_PENTIUM_4_EFSB_DRDY1 is defined as MSR_EFSB_DRDY1 in SDM. -**/ -#define MSR_PENTIUM_4_EFSB_DRDY1 0x000107D1 - - -/** - 3, 4. Shared. IFSB Latency Event Control Register (R/W) See Section 18.21, - "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte - L3 Cache" for details. - - @param ECX MSR_PENTIUM_4_IFSB_CTL6 (0x000107D2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_CTL6); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_CTL6, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_CTL6 is defined as MSR_IFSB_CTL6 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_CTL6 0x000107D2 - - -/** - 3, 4. Shared. IFSB Latency Event Counter Register (R/W) See Section 18.21, - "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte - L3 Cache.". - - @param ECX MSR_PENTIUM_4_IFSB_CNTR7 (0x000107D3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_IFSB_CNTR7); - AsmWriteMsr64 (MSR_PENTIUM_4_IFSB_CNTR7, Msr); - @endcode - @note MSR_PENTIUM_4_IFSB_CNTR7 is defined as MSR_IFSB_CNTR7 in SDM. -**/ -#define MSR_PENTIUM_4_IFSB_CNTR7 0x000107D3 - - -/** - 6. Shared. GBUSQ Event Control and Counter Register (R/W) See Section 18.21, - "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte - L3 Cache.". - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL0 (0x000107CC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL0); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL0, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL0 is defined as MSR_EMON_L3_CTR_CTL0 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL0 0x000107CC - - -/** - 6. Shared. GBUSQ Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL1 (0x000107CD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL1); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL1, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL1 is defined as MSR_EMON_L3_CTR_CTL1 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL1 0x000107CD - - -/** - 6. Shared. GSNPQ Event Control and Counter Register (R/W) See Section - 18.21, "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to - 8-MByte L3 Cache.". - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL2 (0x000107CE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL2); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL2, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL2 is defined as MSR_EMON_L3_CTR_CTL2 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL2 0x000107CE - - -/** - 6. Shared. GSNPQ Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL3 (0x000107CF) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL3); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL3, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL3 is defined as MSR_EMON_L3_CTR_CTL3 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL3 0x000107CF - - -/** - 6. Shared. FSB Event Control and Counter Register (R/W) See Section 18.21, - "Performance Monitoring on 64-bit Intel Xeon Processor MP with Up to 8-MByte - L3 Cache" for details. - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL4 (0x000107D0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL4); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL4, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL4 is defined as MSR_EMON_L3_CTR_CTL4 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL4 0x000107D0 - - -/** - 6. Shared. FSB Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL5 (0x000107D1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL5); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL5, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL5 is defined as MSR_EMON_L3_CTR_CTL5 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL5 0x000107D1 - - -/** - 6. Shared. FSB Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL6 (0x000107D2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL6); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL6, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL6 is defined as MSR_EMON_L3_CTR_CTL6 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL6 0x000107D2 - - -/** - 6. Shared. FSB Event Control and Counter Register (R/W). - - @param ECX MSR_PENTIUM_4_EMON_L3_CTR_CTL7 (0x000107D3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL7); - AsmWriteMsr64 (MSR_PENTIUM_4_EMON_L3_CTR_CTL7, Msr); - @endcode - @note MSR_PENTIUM_4_EMON_L3_CTR_CTL7 is defined as MSR_EMON_L3_CTR_CTL7 in SDM. -**/ -#define MSR_PENTIUM_4_EMON_L3_CTR_CTL7 0x000107D3 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h b/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h deleted file mode 100644 index 70d54c81ee..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/PentiumMMsr.h +++ /dev/null @@ -1,684 +0,0 @@ -/** @file - MSR Definitions for Pentium M Processors. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.20. - -**/ - -#ifndef __PENTIUM_M_MSR_H__ -#define __PENTIUM_M_MSR_H__ - -#include - -/** - Is Pentium M Processors? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_PENTIUM_M_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x0D \ - ) \ - ) - -/** - See Section 35.22, "MSRs in Pentium Processors.". - - @param ECX MSR_PENTIUM_M_P5_MC_ADDR (0x00000000) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_P5_MC_ADDR); - AsmWriteMsr64 (MSR_PENTIUM_M_P5_MC_ADDR, Msr); - @endcode - @note MSR_PENTIUM_M_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. -**/ -#define MSR_PENTIUM_M_P5_MC_ADDR 0x00000000 - - -/** - See Section 35.22, "MSRs in Pentium Processors.". - - @param ECX MSR_PENTIUM_M_P5_MC_TYPE (0x00000001) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_P5_MC_TYPE); - AsmWriteMsr64 (MSR_PENTIUM_M_P5_MC_TYPE, Msr); - @endcode - @note MSR_PENTIUM_M_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. -**/ -#define MSR_PENTIUM_M_P5_MC_TYPE 0x00000001 - - -/** - Processor Hard Power-On Configuration (R/W) Enables and disables processor - features. (R) Indicates current processor configuration. - - @param ECX MSR_PENTIUM_M_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_PENTIUM_M_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_PENTIUM_M_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. -**/ -#define MSR_PENTIUM_M_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_PENTIUM_M_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] Data Error Checking Enable (R) 0 = Disabled Always 0 on the - /// Pentium M processor. - /// - UINT32 DataErrorCheckingEnable:1; - /// - /// [Bit 2] Response Error Checking Enable (R) 0 = Disabled Always 0 on - /// the Pentium M processor. - /// - UINT32 ResponseErrorCheckingEnable:1; - /// - /// [Bit 3] MCERR# Drive Enable (R) 0 = Disabled Always 0 on the Pentium - /// M processor. - /// - UINT32 MCERR_DriveEnable:1; - /// - /// [Bit 4] Address Parity Enable (R) 0 = Disabled Always 0 on the Pentium - /// M processor. - /// - UINT32 AddressParityEnable:1; - UINT32 Reserved2:2; - /// - /// [Bit 7] BINIT# Driver Enable (R) 1 = Enabled; 0 = Disabled Always 0 on - /// the Pentium M processor. - /// - UINT32 BINIT_DriverEnable:1; - /// - /// [Bit 8] Output Tri-state Enabled (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 OutputTriStateEnable:1; - /// - /// [Bit 9] Execute BIST (R/O) 1 = Enabled; 0 = Disabled. - /// - UINT32 ExecuteBIST:1; - /// - /// [Bit 10] MCERR# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled - /// Always 0 on the Pentium M processor. - /// - UINT32 MCERR_ObservationEnabled:1; - UINT32 Reserved3:1; - /// - /// [Bit 12] BINIT# Observation Enabled (R/O) 1 = Enabled; 0 = Disabled - /// Always 0 on the Pentium M processor. - /// - UINT32 BINIT_ObservationEnabled:1; - UINT32 Reserved4:1; - /// - /// [Bit 14] 1 MByte Power on Reset Vector (R/O) 1 = 1 MByte; 0 = 4 GBytes - /// Always 0 on the Pentium M processor. - /// - UINT32 ResetVector:1; - UINT32 Reserved5:1; - /// - /// [Bits 17:16] APIC Cluster ID (R/O) Always 00B on the Pentium M - /// processor. - /// - UINT32 APICClusterID:2; - /// - /// [Bit 18] System Bus Frequency (R/O) 1. = 100 MHz 2. = Reserved Always - /// 0 on the Pentium M processor. - /// - UINT32 SystemBusFrequency:1; - UINT32 Reserved6:1; - /// - /// [Bits 21:20] Symmetric Arbitration ID (R/O) Always 00B on the Pentium - /// M processor. - /// - UINT32 SymmetricArbitrationID:2; - /// - /// [Bits 26:22] Clock Frequency Ratio (R/O). - /// - UINT32 ClockFrequencyRatio:5; - UINT32 Reserved7:5; - UINT32 Reserved8:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_M_EBL_CR_POWERON_REGISTER; - - -/** - Last Branch Record n (R/W) One of 8 last branch record registers on the last - branch record stack: bits 31-0 hold the 'from' address and bits 63-32 hold - the to address. See also: - Last Branch Record Stack TOS at 1C9H - Section - 17.13, "Last Branch, Interrupt, and Exception Recording (Pentium M - Processors)". - - @param ECX MSR_PENTIUM_M_LASTBRANCH_n - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_LASTBRANCH_0); - AsmWriteMsr64 (MSR_PENTIUM_M_LASTBRANCH_0, Msr); - @endcode - @note MSR_PENTIUM_M_LASTBRANCH_0 is defined as MSR_LASTBRANCH_0 in SDM. - MSR_PENTIUM_M_LASTBRANCH_1 is defined as MSR_LASTBRANCH_1 in SDM. - MSR_PENTIUM_M_LASTBRANCH_2 is defined as MSR_LASTBRANCH_2 in SDM. - MSR_PENTIUM_M_LASTBRANCH_3 is defined as MSR_LASTBRANCH_3 in SDM. - MSR_PENTIUM_M_LASTBRANCH_4 is defined as MSR_LASTBRANCH_4 in SDM. - MSR_PENTIUM_M_LASTBRANCH_5 is defined as MSR_LASTBRANCH_5 in SDM. - MSR_PENTIUM_M_LASTBRANCH_6 is defined as MSR_LASTBRANCH_6 in SDM. - MSR_PENTIUM_M_LASTBRANCH_7 is defined as MSR_LASTBRANCH_7 in SDM. - @{ -**/ -#define MSR_PENTIUM_M_LASTBRANCH_0 0x00000040 -#define MSR_PENTIUM_M_LASTBRANCH_1 0x00000041 -#define MSR_PENTIUM_M_LASTBRANCH_2 0x00000042 -#define MSR_PENTIUM_M_LASTBRANCH_3 0x00000043 -#define MSR_PENTIUM_M_LASTBRANCH_4 0x00000044 -#define MSR_PENTIUM_M_LASTBRANCH_5 0x00000045 -#define MSR_PENTIUM_M_LASTBRANCH_6 0x00000046 -#define MSR_PENTIUM_M_LASTBRANCH_7 0x00000047 -/// @} - - -/** - Reserved. - - @param ECX MSR_PENTIUM_M_BBL_CR_CTL (0x00000119) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_BBL_CR_CTL); - AsmWriteMsr64 (MSR_PENTIUM_M_BBL_CR_CTL, Msr); - @endcode - @note MSR_PENTIUM_M_BBL_CR_CTL is defined as MSR_BBL_CR_CTL in SDM. -**/ -#define MSR_PENTIUM_M_BBL_CR_CTL 0x00000119 - - -/** - - - @param ECX MSR_PENTIUM_M_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_PENTIUM_M_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_PENTIUM_M_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. -**/ -#define MSR_PENTIUM_M_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_PENTIUM_M_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = - /// Indicates if the L2 is hardware-disabled. - /// - UINT32 L2HardwareEnabled:1; - UINT32 Reserved1:4; - /// - /// [Bit 5] ECC Check Enable (RO) This bit enables ECC checking on the - /// cache data bus. ECC is always generated on write cycles. 1. = Disabled - /// (default) 2. = Enabled For the Pentium M processor, ECC checking on - /// the cache data bus is always enabled. - /// - UINT32 ECCCheckEnable:1; - UINT32 Reserved2:2; - /// - /// [Bit 8] L2 Enabled (R/W) 1 = L2 cache has been initialized 0 = - /// Disabled (default) Until this bit is set the processor will not - /// respond to the WBINVD instruction or the assertion of the FLUSH# input. - /// - UINT32 L2Enabled:1; - UINT32 Reserved3:14; - /// - /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. - /// - UINT32 L2NotPresent:1; - UINT32 Reserved4:8; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_M_BBL_CR_CTL3_REGISTER; - - -/** - - - @param ECX MSR_PENTIUM_M_THERM2_CTL (0x0000019D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_THERM2_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_THERM2_CTL_REGISTER. - - Example usage - @code - MSR_PENTIUM_M_THERM2_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_THERM2_CTL); - AsmWriteMsr64 (MSR_PENTIUM_M_THERM2_CTL, Msr.Uint64); - @endcode - @note MSR_PENTIUM_M_THERM2_CTL is defined as MSR_THERM2_CTL in SDM. -**/ -#define MSR_PENTIUM_M_THERM2_CTL 0x0000019D - -/** - MSR information returned for MSR index #MSR_PENTIUM_M_THERM2_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bit 16] TM_SELECT (R/W) Mode of automatic thermal monitor: 1. = - /// Thermal Monitor 1 (thermally-initiated on-die modulation of the - /// stop-clock duty cycle) 2. = Thermal Monitor 2 (thermally-initiated - /// frequency transitions) If bit 3 of the IA32_MISC_ENABLE register is - /// cleared, TM_SELECT has no effect. Neither TM1 nor TM2 will be enabled. - /// - UINT32 TM_SELECT:1; - UINT32 Reserved2:15; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_M_THERM2_CTL_REGISTER; - - -/** - Enable Miscellaneous Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_PENTIUM_M_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_PENTIUM_M_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_PENTIUM_M_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_PENTIUM_M_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_PENTIUM_M_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_PENTIUM_M_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:3; - /// - /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) 1 = Setting - /// this bit enables the thermal control circuit (TCC) portion of the - /// Intel Thermal Monitor feature. This allows processor clocks to be - /// automatically modulated based on the processor's thermal sensor - /// operation. 0 = Disabled (default). The automatic thermal control - /// circuit enable bit determines if the thermal control circuit (TCC) - /// will be activated when the processor's internal thermal sensor - /// determines the processor is about to exceed its maximum operating - /// temperature. When the TCC is activated and TM1 is enabled, the - /// processors clocks will be forced to a 50% duty cycle. BIOS must enable - /// this feature. The bit should not be confused with the on-demand - /// thermal control circuit enable bit. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Performance Monitoring Available (R) 1 = Performance - /// monitoring enabled 0 = Performance monitoring disabled. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:2; - /// - /// [Bit 10] FERR# Multiplexing Enable (R/W) 1 = FERR# asserted by the - /// processor to indicate a pending break event within the processor 0 = - /// Indicates compatible FERR# signaling behavior This bit must be set to - /// 1 to support XAPIC interrupt model usage. - /// **Branch Trace Storage Unavailable (RO)** 1 = Processor doesn't - /// support branch trace storage (BTS) 0 = BTS is supported - /// - UINT32 FERR:1; - /// - /// [Bit 11] Branch Trace Storage Unavailable (RO) - /// 1 = Processor doesn't support branch trace storage (BTS) - /// 0 = BTS is supported - /// - UINT32 BTS:1; - /// - /// [Bit 12] Processor Event Based Sampling Unavailable (RO) 1 = - /// Processor does not support processor event based sampling (PEBS); 0 = - /// PEBS is supported. The Pentium M processor does not support PEBS. - /// - UINT32 PEBS:1; - UINT32 Reserved5:3; - /// - /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W) 1 = - /// Enhanced Intel SpeedStep Technology enabled. On the Pentium M - /// processor, this bit may be configured to be read-only. - /// - UINT32 EIST:1; - UINT32 Reserved6:6; - /// - /// [Bit 23] xTPR Message Disable (R/W) When set to 1, xTPR messages are - /// disabled. xTPR messages are optional messages that allow the processor - /// to inform the chipset of its priority. The default is processor - /// specific. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_PENTIUM_M_IA32_MISC_ENABLE_REGISTER; - - -/** - Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) that points - to the MSR containing the most recent branch record. See also: - - MSR_LASTBRANCH_0_FROM_IP (at 40H) - Section 17.13, "Last Branch, Interrupt, - and Exception Recording (Pentium M Processors)". - - @param ECX MSR_PENTIUM_M_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_PENTIUM_M_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_PENTIUM_M_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_PENTIUM_M_LASTBRANCH_TOS 0x000001C9 - - -/** - Debug Control (R/W) Controls how several debug features are used. Bit - definitions are discussed in the referenced section. See Section 17.13, - "Last Branch, Interrupt, and Exception Recording (Pentium M Processors).". - - @param ECX MSR_PENTIUM_M_DEBUGCTLB (0x000001D9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_DEBUGCTLB); - AsmWriteMsr64 (MSR_PENTIUM_M_DEBUGCTLB, Msr); - @endcode - @note MSR_PENTIUM_M_DEBUGCTLB is defined as MSR_DEBUGCTLB in SDM. -**/ -#define MSR_PENTIUM_M_DEBUGCTLB 0x000001D9 - - -/** - Last Exception Record To Linear IP (R) This area contains a pointer to the - target of the last branch instruction that the processor executed prior to - the last exception that was generated or the last interrupt that was - handled. See Section 17.13, "Last Branch, Interrupt, and Exception Recording - (Pentium M Processors)" and Section 17.14.2, "Last Branch and Last Exception - MSRs.". - - @param ECX MSR_PENTIUM_M_LER_TO_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_LER_TO_LIP); - @endcode - @note MSR_PENTIUM_M_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_PENTIUM_M_LER_TO_LIP 0x000001DD - - -/** - Last Exception Record From Linear IP (R) Contains a pointer to the last - branch instruction that the processor executed prior to the last exception - that was generated or the last interrupt that was handled. See Section - 17.13, "Last Branch, Interrupt, and Exception Recording (Pentium M - Processors)" and Section 17.14.2, "Last Branch and Last Exception MSRs.". - - @param ECX MSR_PENTIUM_M_LER_FROM_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_LER_FROM_LIP); - @endcode - @note MSR_PENTIUM_M_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_PENTIUM_M_LER_FROM_LIP 0x000001DE - - -/** - See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". - - @param ECX MSR_PENTIUM_M_MC4_CTL (0x0000040C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_CTL); - AsmWriteMsr64 (MSR_PENTIUM_M_MC4_CTL, Msr); - @endcode - @note MSR_PENTIUM_M_MC4_CTL is defined as MSR_MC4_CTL in SDM. -**/ -#define MSR_PENTIUM_M_MC4_CTL 0x0000040C - - -/** - See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". - - @param ECX MSR_PENTIUM_M_MC4_STATUS (0x0000040D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_STATUS); - AsmWriteMsr64 (MSR_PENTIUM_M_MC4_STATUS, Msr); - @endcode - @note MSR_PENTIUM_M_MC4_STATUS is defined as MSR_MC4_STATUS in SDM. -**/ -#define MSR_PENTIUM_M_MC4_STATUS 0x0000040D - - -/** - See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC4_ADDR register is - either not implemented or contains no address if the ADDRV flag in the - MSR_MC4_STATUS register is clear. When not implemented in the processor, all - reads and writes to this MSR will cause a general-protection exception. - - @param ECX MSR_PENTIUM_M_MC4_ADDR (0x0000040E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC4_ADDR); - AsmWriteMsr64 (MSR_PENTIUM_M_MC4_ADDR, Msr); - @endcode - @note MSR_PENTIUM_M_MC4_ADDR is defined as MSR_MC4_ADDR in SDM. -**/ -#define MSR_PENTIUM_M_MC4_ADDR 0x0000040E - - -/** - See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". - - @param ECX MSR_PENTIUM_M_MC3_CTL (0x00000410) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_CTL); - AsmWriteMsr64 (MSR_PENTIUM_M_MC3_CTL, Msr); - @endcode - @note MSR_PENTIUM_M_MC3_CTL is defined as MSR_MC3_CTL in SDM. -**/ -#define MSR_PENTIUM_M_MC3_CTL 0x00000410 - - -/** - See Section 15.3.2.2, "IA32_MCi_STATUS MSRS.". - - @param ECX MSR_PENTIUM_M_MC3_STATUS (0x00000411) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_STATUS); - AsmWriteMsr64 (MSR_PENTIUM_M_MC3_STATUS, Msr); - @endcode - @note MSR_PENTIUM_M_MC3_STATUS is defined as MSR_MC3_STATUS in SDM. -**/ -#define MSR_PENTIUM_M_MC3_STATUS 0x00000411 - - -/** - See Section 15.3.2.3, "IA32_MCi_ADDR MSRs." The MSR_MC3_ADDR register is - either not implemented or contains no address if the ADDRV flag in the - MSR_MC3_STATUS register is clear. When not implemented in the processor, all - reads and writes to this MSR will cause a general-protection exception. - - @param ECX MSR_PENTIUM_M_MC3_ADDR (0x00000412) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_M_MC3_ADDR); - AsmWriteMsr64 (MSR_PENTIUM_M_MC3_ADDR, Msr); - @endcode - @note MSR_PENTIUM_M_MC3_ADDR is defined as MSR_MC3_ADDR in SDM. -**/ -#define MSR_PENTIUM_M_MC3_ADDR 0x00000412 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h b/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h deleted file mode 100644 index 9b2578bac8..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/PentiumMsr.h +++ /dev/null @@ -1,145 +0,0 @@ -/** @file - MSR Definitions for Pentium Processors. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.22. - -**/ - -#ifndef __PENTIUM_MSR_H__ -#define __PENTIUM_MSR_H__ - -#include - -/** - Is Pentium Processors? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_PENTIUM_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x05 && \ - ( \ - DisplayModel == 0x01 || \ - DisplayModel == 0x02 || \ - DisplayModel == 0x04 \ - ) \ - ) - -/** - See Section 15.10.2, "Pentium Processor Machine-Check Exception Handling.". - - @param ECX MSR_PENTIUM_P5_MC_ADDR (0x00000000) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_P5_MC_ADDR); - AsmWriteMsr64 (MSR_PENTIUM_P5_MC_ADDR, Msr); - @endcode - @note MSR_PENTIUM_P5_MC_ADDR is defined as P5_MC_ADDR in SDM. -**/ -#define MSR_PENTIUM_P5_MC_ADDR 0x00000000 - - -/** - See Section 15.10.2, "Pentium Processor Machine-Check Exception Handling.". - - @param ECX MSR_PENTIUM_P5_MC_TYPE (0x00000001) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_P5_MC_TYPE); - AsmWriteMsr64 (MSR_PENTIUM_P5_MC_TYPE, Msr); - @endcode - @note MSR_PENTIUM_P5_MC_TYPE is defined as P5_MC_TYPE in SDM. -**/ -#define MSR_PENTIUM_P5_MC_TYPE 0x00000001 - - -/** - See Section 17.15, "Time-Stamp Counter.". - - @param ECX MSR_PENTIUM_TSC (0x00000010) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_TSC); - AsmWriteMsr64 (MSR_PENTIUM_TSC, Msr); - @endcode - @note MSR_PENTIUM_TSC is defined as TSC in SDM. -**/ -#define MSR_PENTIUM_TSC 0x00000010 - - -/** - See Section 18.24.1, "Control and Event Select Register (CESR).". - - @param ECX MSR_PENTIUM_CESR (0x00000011) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_CESR); - AsmWriteMsr64 (MSR_PENTIUM_CESR, Msr); - @endcode - @note MSR_PENTIUM_CESR is defined as CESR in SDM. -**/ -#define MSR_PENTIUM_CESR 0x00000011 - - -/** - Section 18.24.3, "Events Counted.". - - @param ECX MSR_PENTIUM_CTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_PENTIUM_CTR0); - AsmWriteMsr64 (MSR_PENTIUM_CTR0, Msr); - @endcode - @note MSR_PENTIUM_CTR0 is defined as CTR0 in SDM. - MSR_PENTIUM_CTR1 is defined as CTR1 in SDM. - @{ -**/ -#define MSR_PENTIUM_CTR0 0x00000012 -#define MSR_PENTIUM_CTR1 0x00000013 -/// @} - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h b/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h deleted file mode 100644 index c8a0b971d3..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/SandyBridgeMsr.h +++ /dev/null @@ -1,4796 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Sandy Bridge microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.9. - -**/ - -#ifndef __SANDY_BRIDGE_MSR_H__ -#define __SANDY_BRIDGE_MSR_H__ - -#include - -/** - Is Intel processors based on the Sandy Bridge microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_SANDY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x2A || \ - DisplayModel == 0x2D \ - ) \ - ) - -/** - Thread. SMI Counter (R/O). - - @param ECX MSR_SANDY_BRIDGE_SMI_COUNT (0x00000034) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_SMI_COUNT); - @endcode - @note MSR_SANDY_BRIDGE_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. -**/ -#define MSR_SANDY_BRIDGE_SMI_COUNT 0x00000034 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_SMI_COUNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] SMI Count (R/O) Count SMIs. - /// - UINT32 SMICount:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_SMI_COUNT_REGISTER; - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_SANDY_BRIDGE_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PLATFORM_INFO); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_SANDY_BRIDGE_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - UINT32 Reserved3:2; - UINT32 Reserved4:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved5:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PLATFORM_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. See http://biosbits.org. - - @param ECX MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power). for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0/C1 (no package C-sate support) 001b: C2 010b: C6 no retention 011b: - /// C6 retention 100b: C7 101b: C7s 111: No package C-state limit. Note: - /// This field cannot be used to limit package C-state to C3. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map - /// IO_read instructions sent to IO register specified by - /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register - /// until next reset. - /// - UINT32 CFGLock:1; - UINT32 Reserved3:9; - /// - /// [Bit 25] C3 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C6/C7 requests to C3 based on uncore - /// auto-demote information. - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 state auto demotion enable (R/W) When set, the processor - /// will conditionally demote C3/C6/C7 requests to C1 based on uncore - /// auto-demote information. - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 undemotion (R/W) When set, enables undemotion from - /// demoted C3. - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 undemotion (R/W) When set, enables undemotion from - /// demoted C1. - /// - UINT32 C1Undemotion:1; - UINT32 Reserved4:3; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Core. Power Management IO Redirection in C-state (R/W) See - http://biosbits.org. - - @param ECX MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE (0x000000E4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. -**/ -#define MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE 0x000000E4 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address - /// visible to software for IO redirection. If IO MWAIT Redirection is - /// enabled, reads to this address will be consumed by the power - /// management logic and decoded to MWAIT instructions. When IO port - /// address redirection is enabled, this is the IO port address reported - /// to the OS/software. - /// - UINT32 Lvl2Base:16; - /// - /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the - /// maximum C-State code name to be included when IO read to MWAIT - /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 000b - C3 - /// is the max C-State to include 001b - C6 is the max C-State to include - /// 010b - C7 is the max C-State to include. - /// - UINT32 CStateRange:3; - UINT32 Reserved1:13; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PMG_IO_CAPTURE_BASE_REGISTER; - - -/** - Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP - handler to handle unsuccessful read of this MSR. - - @param ECX MSR_SANDY_BRIDGE_FEATURE_CONFIG (0x0000013C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. -**/ -#define MSR_SANDY_BRIDGE_FEATURE_CONFIG 0x0000013C - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_FEATURE_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this - /// MSR, the configuration of AES instruction set availability is as - /// follows: 11b: AES instructions are not available until next RESET. - /// otherwise, AES instructions are available. Note, AES instruction set - /// is not available if read is unsuccessful. If the configuration is not - /// 01b, AES instruction can be mis-configured if a privileged agent - /// unintentionally writes 11b. - /// - UINT32 AESConfiguration:2; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER; - - -/** - Core. See Table 35-2; If CPUID.0AH:EAX[15:8] = 8. - - @param ECX MSR_SANDY_BRIDGE_IA32_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4, Msr); - @endcode - @note MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4 is defined as IA32_PERFEVTSEL4 in SDM. - MSR_SANDY_BRIDGE_IA32_PERFEVTSEL5 is defined as IA32_PERFEVTSEL5 in SDM. - MSR_SANDY_BRIDGE_IA32_PERFEVTSEL6 is defined as IA32_PERFEVTSEL6 in SDM. - MSR_SANDY_BRIDGE_IA32_PERFEVTSEL7 is defined as IA32_PERFEVTSEL7 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL4 0x0000018A -#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL5 0x0000018B -#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL6 0x0000018C -#define MSR_SANDY_BRIDGE_IA32_PERFEVTSEL7 0x0000018D -/// @} - - -/** - Package. - - @param ECX MSR_SANDY_BRIDGE_PERF_STATUS (0x00000198) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PERF_STATUS); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PERF_STATUS, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PERF_STATUS is defined as MSR_PERF_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_PERF_STATUS 0x00000198 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PERF_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - /// - /// [Bits 47:32] Core Voltage (R/O) P-state core voltage can be computed - /// by MSR_PERF_STATUS[37:32] * (float) 1/(2^13). - /// - UINT32 CoreVoltage:16; - UINT32 Reserved2:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PERF_STATUS_REGISTER; - - -/** - Thread. Clock Modulation (R/W) See Table 35-2 IA32_CLOCK_MODULATION MSR was - originally named IA32_THERM_CONTROL MSR. - - @param ECX MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION (0x0000019A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION is defined as IA32_CLOCK_MODULATION in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION 0x0000019A - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] On demand Clock Modulation Duty Cycle (R/W) In 6.25% - /// increment. - /// - UINT32 OnDemandClockModulationDutyCycle:4; - /// - /// [Bit 4] On demand Clock Modulation Enable (R/W). - /// - UINT32 OnDemandClockModulationEnable:1; - UINT32 Reserved1:27; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_SANDY_BRIDGE_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:6; - /// - /// [Bit 7] Thread. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved2:3; - /// - /// [Bit 11] Thread. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Thread. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - UINT32 Reserved3:3; - /// - /// [Bit 16] Package. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved4:1; - /// - /// [Bit 18] Thread. ENABLE MONITOR FSM. (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved5:3; - /// - /// [Bit 22] Thread. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Thread. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved6:8; - UINT32 Reserved7:2; - /// - /// [Bit 34] Thread. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved8:3; - /// - /// [Bit 38] Package. Turbo Mode Disable (R/W) When set to 1 on processors - /// that support Intel Turbo Boost Technology, the turbo mode feature is - /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: - /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: - /// EAX[1] reports the processor's support of turbo mode is enabled. Note: - /// the power-on default value is used by BIOS to detect hardware support - /// of turbo mode. If power-on default value is 1, turbo mode is available - /// in the processor. If power-on default value is 0, turbo mode is not - /// available. - /// - UINT32 TurboModeDisable:1; - UINT32 Reserved9:25; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_MISC_ENABLE_REGISTER; - - -/** - Unique. - - @param ECX MSR_SANDY_BRIDGE_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_SANDY_BRIDGE_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (R) The minimum temperature at which - /// PROCHOT# will be asserted. The value is degree C. - /// - UINT32 TemperatureTarget:8; - UINT32 Reserved2:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_TEMPERATURE_TARGET_REGISTER; - - -/** - Miscellaneous Feature Control (R/W). - - @param ECX MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL (0x000001A4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. -**/ -#define MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL 0x000001A4 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the - /// L2 hardware prefetcher, which fetches additional lines of code or data - /// into the L2 cache. - /// - UINT32 L2HardwarePrefetcherDisable:1; - /// - /// [Bit 1] Core. L2 Adjacent Cache Line Prefetcher Disable (R/W) If 1, - /// disables the adjacent cache line prefetcher, which fetches the cache - /// line that comprises a cache line pair (128 bytes). - /// - UINT32 L2AdjacentCacheLinePrefetcherDisable:1; - /// - /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables - /// the L1 data cache prefetcher, which fetches the next cache line into - /// L1 data cache. - /// - UINT32 DCUHardwarePrefetcherDisable:1; - /// - /// [Bit 3] Core. DCU IP Prefetcher Disable (R/W) If 1, disables the L1 - /// data cache IP prefetcher, which uses sequential load history (based on - /// instruction Pointer of previous loads) to determine whether to - /// prefetch additional lines. - /// - UINT32 DCUIPPrefetcherDisable:1; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_MISC_FEATURE_CONTROL_REGISTER; - - -/** - Thread. Offcore Response Event Select Register (R/W). - - @param ECX MSR_SANDY_BRIDGE_OFFCORE_RSP_0 (0x000001A6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_OFFCORE_RSP_0 0x000001A6 - - -/** - Thread. Offcore Response Event Select Register (R/W). - - @param ECX MSR_SANDY_BRIDGE_OFFCORE_RSP_1 (0x000001A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_OFFCORE_RSP_1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_OFFCORE_RSP_1 0x000001A7 - - -/** - See http://biosbits.org. - - @param ECX MSR_SANDY_BRIDGE_MISC_PWR_MGMT (0x000001AA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_MISC_PWR_MGMT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_MISC_PWR_MGMT, Msr); - @endcode - @note MSR_SANDY_BRIDGE_MISC_PWR_MGMT is defined as MSR_MISC_PWR_MGMT in SDM. -**/ -#define MSR_SANDY_BRIDGE_MISC_PWR_MGMT 0x000001AA - - -/** - Thread. Last Branch Record Filtering Select Register (R/W) See Section - 17.7.2, "Filtering of Last Branch Records.". - - @param ECX MSR_SANDY_BRIDGE_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_LBR_SELECT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_LBR_SELECT, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_SANDY_BRIDGE_LBR_SELECT 0x000001C8 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_LBR_SELECT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CPL_EQ_0. - /// - UINT32 CPL_EQ_0:1; - /// - /// [Bit 1] CPL_NEQ_0. - /// - UINT32 CPL_NEQ_0:1; - /// - /// [Bit 2] JCC. - /// - UINT32 JCC:1; - /// - /// [Bit 3] NEAR_REL_CALL. - /// - UINT32 NEAR_REL_CALL:1; - /// - /// [Bit 4] NEAR_IND_CALL. - /// - UINT32 NEAR_IND_CALL:1; - /// - /// [Bit 5] NEAR_RET. - /// - UINT32 NEAR_RET:1; - /// - /// [Bit 6] NEAR_IND_JMP. - /// - UINT32 NEAR_IND_JMP:1; - /// - /// [Bit 7] NEAR_REL_JMP. - /// - UINT32 NEAR_REL_JMP:1; - /// - /// [Bit 8] FAR_BRANCH. - /// - UINT32 FAR_BRANCH:1; - UINT32 Reserved1:23; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_LBR_SELECT_REGISTER; - - -/** - Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-3) - that points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP (at 680H). - - @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_SANDY_BRIDGE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_SANDY_BRIDGE_LASTBRANCH_TOS 0x000001C9 - - -/** - Thread. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_SANDY_BRIDGE_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LER_FROM_LIP); - @endcode - @note MSR_SANDY_BRIDGE_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_SANDY_BRIDGE_LER_FROM_LIP 0x000001DD - - -/** - Thread. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_SANDY_BRIDGE_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LER_TO_LIP); - @endcode - @note MSR_SANDY_BRIDGE_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_SANDY_BRIDGE_LER_TO_LIP 0x000001DE - - -/** - Core. See http://biosbits.org. - - @param ECX MSR_SANDY_BRIDGE_POWER_CTL (0x000001FC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_POWER_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_POWER_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_POWER_CTL is defined as MSR_POWER_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_POWER_CTL 0x000001FC - - -/** - Package. Always 0 (CMCI not supported). - - @param ECX MSR_SANDY_BRIDGE_IA32_MC4_CTL2 (0x00000284) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_IA32_MC4_CTL2 is defined as IA32_MC4_CTL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_MC4_CTL2 0x00000284 - - -/** - See Table 35-2. See Section 18.4.2, "Global Counter Control Facilities.". - - @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS 0x0000038E - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Thread. Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Thread. Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Thread. Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - /// - /// [Bit 4] Core. Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). - /// - UINT32 Ovf_PMC4:1; - /// - /// [Bit 5] Core. Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). - /// - UINT32 Ovf_PMC5:1; - /// - /// [Bit 6] Core. Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). - /// - UINT32 Ovf_PMC6:1; - /// - /// [Bit 7] Core. Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). - /// - UINT32 Ovf_PMC7:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Thread. Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Thread. Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:26; - /// - /// [Bit 61] Thread. Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Thread. Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - /// - /// [Bit 63] Thread. CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Thread. See Table 35-2. See Section 18.4.2, "Global Counter Control - Facilities.". - - @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL (0x0000038F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL is defined as IA32_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL 0x0000038F - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Set 1 to enable PMC0 to count. - /// - UINT32 PCM0_EN:1; - /// - /// [Bit 1] Thread. Set 1 to enable PMC1 to count. - /// - UINT32 PCM1_EN:1; - /// - /// [Bit 2] Thread. Set 1 to enable PMC2 to count. - /// - UINT32 PCM2_EN:1; - /// - /// [Bit 3] Thread. Set 1 to enable PMC3 to count. - /// - UINT32 PCM3_EN:1; - /// - /// [Bit 4] Core. Set 1 to enable PMC4 to count (if CPUID.0AH:EAX[15:8] > - /// 4). - /// - UINT32 PCM4_EN:1; - /// - /// [Bit 5] Core. Set 1 to enable PMC5 to count (if CPUID.0AH:EAX[15:8] > - /// 5). - /// - UINT32 PCM5_EN:1; - /// - /// [Bit 6] Core. Set 1 to enable PMC6 to count (if CPUID.0AH:EAX[15:8] > - /// 6). - /// - UINT32 PCM6_EN:1; - /// - /// [Bit 7] Core. Set 1 to enable PMC7 to count (if CPUID.0AH:EAX[15:8] > - /// 7). - /// - UINT32 PCM7_EN:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Set 1 to enable FixedCtr0 to count. - /// - UINT32 FIXED_CTR0:1; - /// - /// [Bit 33] Thread. Set 1 to enable FixedCtr1 to count. - /// - UINT32 FIXED_CTR1:1; - /// - /// [Bit 34] Thread. Set 1 to enable FixedCtr2 to count. - /// - UINT32 FIXED_CTR2:1; - UINT32 Reserved2:29; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_CTRL_REGISTER; - - -/** - See Table 35-2. See Section 18.4.2, "Global Counter Control Facilities.". - - @param ECX MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL is defined as IA32_PERF_GLOBAL_OVF_CTRL in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL 0x00000390 - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Set 1 to clear Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Thread. Set 1 to clear Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Thread. Set 1 to clear Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Thread. Set 1 to clear Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - /// - /// [Bit 4] Core. Set 1 to clear Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). - /// - UINT32 Ovf_PMC4:1; - /// - /// [Bit 5] Core. Set 1 to clear Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). - /// - UINT32 Ovf_PMC5:1; - /// - /// [Bit 6] Core. Set 1 to clear Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). - /// - UINT32 Ovf_PMC6:1; - /// - /// [Bit 7] Core. Set 1 to clear Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). - /// - UINT32 Ovf_PMC7:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Set 1 to clear Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Thread. Set 1 to clear Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Thread. Set 1 to clear Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:26; - /// - /// [Bit 61] Thread. Set 1 to clear Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Thread. Set 1 to clear Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - /// - /// [Bit 63] Thread. Set 1 to clear CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_PERF_GLOBAL_OVF_CTRL_REGISTER; - - -/** - Thread. See Section 18.8.1.1, "Processor Event Based Sampling (PEBS).". - - @param ECX MSR_SANDY_BRIDGE_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_ENABLE); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_SANDY_BRIDGE_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS on IA32_PMC0. (R/W). - /// - UINT32 PEBS_EN_PMC0:1; - /// - /// [Bit 1] Enable PEBS on IA32_PMC1. (R/W). - /// - UINT32 PEBS_EN_PMC1:1; - /// - /// [Bit 2] Enable PEBS on IA32_PMC2. (R/W). - /// - UINT32 PEBS_EN_PMC2:1; - /// - /// [Bit 3] Enable PEBS on IA32_PMC3. (R/W). - /// - UINT32 PEBS_EN_PMC3:1; - UINT32 Reserved1:28; - /// - /// [Bit 32] Enable Load Latency on IA32_PMC0. (R/W). - /// - UINT32 LL_EN_PMC0:1; - /// - /// [Bit 33] Enable Load Latency on IA32_PMC1. (R/W). - /// - UINT32 LL_EN_PMC1:1; - /// - /// [Bit 34] Enable Load Latency on IA32_PMC2. (R/W). - /// - UINT32 LL_EN_PMC2:1; - /// - /// [Bit 35] Enable Load Latency on IA32_PMC3. (R/W). - /// - UINT32 LL_EN_PMC3:1; - UINT32 Reserved2:27; - /// - /// [Bit 63] Enable Precise Store. (R/W). - /// - UINT32 PS_EN:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PEBS_ENABLE_REGISTER; - - -/** - Thread. see See Section 18.8.1.2, "Load Latency Performance Monitoring - Facility.". - - @param ECX MSR_SANDY_BRIDGE_PEBS_LD_LAT (0x000003F6) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_LD_LAT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_LD_LAT, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PEBS_LD_LAT is defined as MSR_PEBS_LD_LAT in SDM. -**/ -#define MSR_SANDY_BRIDGE_PEBS_LD_LAT 0x000003F6 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_LD_LAT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] Minimum threshold latency value of tagged load operation - /// that will be counted. (R/W). - /// - UINT32 MinimumThreshold:16; - UINT32 Reserved1:16; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PEBS_LD_LAT_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C3 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY (0x000003F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_C3_RESIDENCY 0x000003F8 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C6 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY (0x000003F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_C6_RESIDENCY 0x000003F9 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C7 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C7 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY (0x000003FA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_C7_RESIDENCY 0x000003FA - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C3 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C3 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY (0x000003FC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY is defined as MSR_CORE_C3_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_CORE_C3_RESIDENCY 0x000003FC - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C6 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY (0x000003FD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_CORE_C6_RESIDENCY 0x000003FD - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C7 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C7 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY (0x000003FE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY is defined as MSR_CORE_C7_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_CORE_C7_RESIDENCY 0x000003FE - - -/** - Core. See Section 15.3.2.1, "IA32_MCi_CTL MSRs.". - - @param ECX MSR_SANDY_BRIDGE_IA32_MC4_CTL (0x00000410) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_IA32_MC4_CTL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_IA32_MC4_CTL is defined as IA32_MC4_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_MC4_CTL 0x00000410 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_IA32_MC4_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PCU Hardware Error (R/W) When set, enables signaling of PCU - /// hardware detected errors. - /// - UINT32 PCUHardwareError:1; - /// - /// [Bit 1] PCU Controller Error (R/W) When set, enables signaling of PCU - /// controller detected errors. - /// - UINT32 PCUControllerError:1; - /// - /// [Bit 2] PCU Firmware Error (R/W) When set, enables signaling of PCU - /// firmware detected errors. - /// - UINT32 PCUFirmwareError:1; - UINT32 Reserved1:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_IA32_MC4_CTL_REGISTER; - - -/** - Thread. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. - - @param ECX MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM (0x0000048C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM); - @endcode - @note MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. -**/ -#define MSR_SANDY_BRIDGE_IA32_VMX_EPT_VPID_ENUM 0x0000048C - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, - "RAPL Interfaces.". - - @param ECX MSR_SANDY_BRIDGE_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_RAPL_POWER_UNIT); - @endcode - @note MSR_SANDY_BRIDGE_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_RAPL_POWER_UNIT 0x00000606 - - -/** - Package. Package C3 Interrupt Response Limit (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. - - @param ECX MSR_SANDY_BRIDGE_PKGC3_IRTL (0x0000060A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC3_IRTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC3_IRTL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PKGC3_IRTL is defined as MSR_PKGC3_IRTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKGC3_IRTL 0x0000060A - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC3_IRTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C3 state. - /// - UINT32 TimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. The following time unit - /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: - /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PKGC3_IRTL_REGISTER; - - -/** - Package. Package C6 Interrupt Response Limit (R/W) This MSR defines the - budget allocated for the package to exit from C6 to a C0 state, where - interrupt request can be delivered to the core and serviced. Additional - core-exit latency amy be applicable depending on the actual C-state the core - is in. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. - - @param ECX MSR_SANDY_BRIDGE_PKGC6_IRTL (0x0000060B) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC6_IRTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC6_IRTL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PKGC6_IRTL is defined as MSR_PKGC6_IRTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKGC6_IRTL 0x0000060B - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC6_IRTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C6 state. - /// - UINT32 TimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. The following time unit - /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: - /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PKGC6_IRTL_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C2 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C2 states. Count at the same frequency as the TSC. - - @param ECX MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY (0x0000060D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_C2_RESIDENCY 0x0000060D - - -/** - Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package - RAPL Domain.". - - @param ECX MSR_SANDY_BRIDGE_PKG_POWER_LIMIT (0x00000610) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_LIMIT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_LIMIT, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_POWER_LIMIT 0x00000610 - - -/** - Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS (0x00000611) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_ENERGY_STATUS 0x00000611 - - -/** - Package. PKG RAPL Parameters (R/W) See Section 14.9.3, "Package RAPL - Domain.". - - @param ECX MSR_SANDY_BRIDGE_PKG_POWER_INFO (0x00000614) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_INFO); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKG_POWER_INFO, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_POWER_INFO 0x00000614 - - -/** - Package. PP0 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 - RAPL Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP0_POWER_LIMIT (0x00000638) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_POWER_LIMIT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP0_POWER_LIMIT, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP0_POWER_LIMIT 0x00000638 - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP0_ENERGY_STATUS 0x00000639 - - -/** - Thread. Last Branch Record n From IP (R/W) One of sixteen pairs of last - branch record registers on the last branch record stack. This part of the - stack contains pointers to the source instruction. See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.7.1 and record format in Section - 17.4.8.1. - - @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_8_FROM_IP is defined as MSR_LASTBRANCH_8_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_9_FROM_IP is defined as MSR_LASTBRANCH_9_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_10_FROM_IP is defined as MSR_LASTBRANCH_10_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_11_FROM_IP is defined as MSR_LASTBRANCH_11_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_12_FROM_IP is defined as MSR_LASTBRANCH_12_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_13_FROM_IP is defined as MSR_LASTBRANCH_13_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_14_FROM_IP is defined as MSR_LASTBRANCH_14_FROM_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_15_FROM_IP is defined as MSR_LASTBRANCH_15_FROM_IP in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_LASTBRANCH_0_FROM_IP 0x00000680 -#define MSR_SANDY_BRIDGE_LASTBRANCH_1_FROM_IP 0x00000681 -#define MSR_SANDY_BRIDGE_LASTBRANCH_2_FROM_IP 0x00000682 -#define MSR_SANDY_BRIDGE_LASTBRANCH_3_FROM_IP 0x00000683 -#define MSR_SANDY_BRIDGE_LASTBRANCH_4_FROM_IP 0x00000684 -#define MSR_SANDY_BRIDGE_LASTBRANCH_5_FROM_IP 0x00000685 -#define MSR_SANDY_BRIDGE_LASTBRANCH_6_FROM_IP 0x00000686 -#define MSR_SANDY_BRIDGE_LASTBRANCH_7_FROM_IP 0x00000687 -#define MSR_SANDY_BRIDGE_LASTBRANCH_8_FROM_IP 0x00000688 -#define MSR_SANDY_BRIDGE_LASTBRANCH_9_FROM_IP 0x00000689 -#define MSR_SANDY_BRIDGE_LASTBRANCH_10_FROM_IP 0x0000068A -#define MSR_SANDY_BRIDGE_LASTBRANCH_11_FROM_IP 0x0000068B -#define MSR_SANDY_BRIDGE_LASTBRANCH_12_FROM_IP 0x0000068C -#define MSR_SANDY_BRIDGE_LASTBRANCH_13_FROM_IP 0x0000068D -#define MSR_SANDY_BRIDGE_LASTBRANCH_14_FROM_IP 0x0000068E -#define MSR_SANDY_BRIDGE_LASTBRANCH_15_FROM_IP 0x0000068F -/// @} - - -/** - Thread. Last Branch Record n To IP (R/W) One of sixteen pairs of last branch - record registers on the last branch record stack. This part of the stack - contains pointers to the destination instruction. - - @param ECX MSR_SANDY_BRIDGE_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_8_TO_IP is defined as MSR_LASTBRANCH_8_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_9_TO_IP is defined as MSR_LASTBRANCH_9_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_10_TO_IP is defined as MSR_LASTBRANCH_10_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_11_TO_IP is defined as MSR_LASTBRANCH_11_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_12_TO_IP is defined as MSR_LASTBRANCH_12_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_13_TO_IP is defined as MSR_LASTBRANCH_13_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_14_TO_IP is defined as MSR_LASTBRANCH_14_TO_IP in SDM. - MSR_SANDY_BRIDGE_LASTBRANCH_15_TO_IP is defined as MSR_LASTBRANCH_15_TO_IP in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_LASTBRANCH_0_TO_IP 0x000006C0 -#define MSR_SANDY_BRIDGE_LASTBRANCH_1_TO_IP 0x000006C1 -#define MSR_SANDY_BRIDGE_LASTBRANCH_2_TO_IP 0x000006C2 -#define MSR_SANDY_BRIDGE_LASTBRANCH_3_TO_IP 0x000006C3 -#define MSR_SANDY_BRIDGE_LASTBRANCH_4_TO_IP 0x000006C4 -#define MSR_SANDY_BRIDGE_LASTBRANCH_5_TO_IP 0x000006C5 -#define MSR_SANDY_BRIDGE_LASTBRANCH_6_TO_IP 0x000006C6 -#define MSR_SANDY_BRIDGE_LASTBRANCH_7_TO_IP 0x000006C7 -#define MSR_SANDY_BRIDGE_LASTBRANCH_8_TO_IP 0x000006C8 -#define MSR_SANDY_BRIDGE_LASTBRANCH_9_TO_IP 0x000006C9 -#define MSR_SANDY_BRIDGE_LASTBRANCH_10_TO_IP 0x000006CA -#define MSR_SANDY_BRIDGE_LASTBRANCH_11_TO_IP 0x000006CB -#define MSR_SANDY_BRIDGE_LASTBRANCH_12_TO_IP 0x000006CC -#define MSR_SANDY_BRIDGE_LASTBRANCH_13_TO_IP 0x000006CD -#define MSR_SANDY_BRIDGE_LASTBRANCH_14_TO_IP 0x000006CE -#define MSR_SANDY_BRIDGE_LASTBRANCH_15_TO_IP 0x000006CF -/// @} - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT); - @endcode - @note MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio - /// limit of 5 core active. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio - /// limit of 6 core active. - /// - UINT32 Maximum6C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio - /// limit of 7 core active. - /// - UINT32 Maximum7C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio - /// limit of 8 core active. - /// - UINT32 Maximum8C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. Uncore PMU global control. - - @param ECX MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL (0x00000391) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL 0x00000391 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Slice 0 select. - /// - UINT32 PMI_Sel_Slice0:1; - /// - /// [Bit 1] Slice 1 select. - /// - UINT32 PMI_Sel_Slice1:1; - /// - /// [Bit 2] Slice 2 select. - /// - UINT32 PMI_Sel_Slice2:1; - /// - /// [Bit 3] Slice 3 select. - /// - UINT32 PMI_Sel_Slice3:1; - /// - /// [Bit 4] Slice 4 select. - /// - UINT32 PMI_Sel_Slice4:1; - UINT32 Reserved1:14; - UINT32 Reserved2:10; - /// - /// [Bit 29] Enable all uncore counters. - /// - UINT32 EN:1; - /// - /// [Bit 30] Enable wake on PMI. - /// - UINT32 WakePMI:1; - /// - /// [Bit 31] Enable Freezing counter when overflow. - /// - UINT32 FREEZE:1; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_CTRL_REGISTER; - - -/** - Package. Uncore PMU main status. - - @param ECX MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS (0x00000392) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS 0x00000392 - -/** - MSR information returned for MSR index - #MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fixed counter overflowed. - /// - UINT32 Fixed:1; - /// - /// [Bit 1] An ARB counter overflowed. - /// - UINT32 ARB:1; - UINT32 Reserved1:1; - /// - /// [Bit 3] A CBox counter overflowed (on any slice). - /// - UINT32 CBox:1; - UINT32 Reserved2:28; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_UNC_PERF_GLOBAL_STATUS_REGISTER; - - -/** - Package. Uncore fixed counter control (R/W). - - @param ECX MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL (0x00000394) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL 0x00000394 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:20; - /// - /// [Bit 20] Enable overflow propagation. - /// - UINT32 EnableOverflow:1; - UINT32 Reserved2:1; - /// - /// [Bit 22] Enable counting. - /// - UINT32 EnableCounting:1; - UINT32 Reserved3:9; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTRL_REGISTER; - - -/** - Package. Uncore fixed counter. - - @param ECX MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR (0x00000395) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR 0x00000395 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Current count. - /// - UINT32 CurrentCount:32; - /// - /// [Bits 47:32] Current count. - /// - UINT32 CurrentCountHi:16; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_UNC_PERF_FIXED_CTR_REGISTER; - - -/** - Package. Uncore C-Box configuration information (R/O). - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_CONFIG (0x00000396) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_CONFIG); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_CONFIG 0x00000396 - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_UNC_CBO_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Report the number of C-Box units with performance counters, - /// including processor cores and processor graphics". - /// - UINT32 CBox:4; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_UNC_CBO_CONFIG_REGISTER; - - -/** - Package. Uncore Arb unit, performance counter 0. - - @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 (0x000003B0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR0 0x000003B0 - - -/** - Package. Uncore Arb unit, performance counter 1. - - @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 (0x000003B1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_ARB_PERFCTR1 0x000003B1 - - -/** - Package. Uncore Arb unit, counter 0 event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 (0x000003B2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL0 0x000003B2 - - -/** - Package. Uncore Arb unit, counter 1 event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 (0x000003B3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 is defined as MSR_UNC_ARB_PERFEVTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_UNC_ARB_PERFEVTSEL1 0x000003B3 - - -/** - Package. Package C7 Interrupt Response Limit (R/W) This MSR defines the - budget allocated for the package to exit from C7 to a C0 state, where - interrupt request can be delivered to the core and serviced. Additional - core-exit latency amy be applicable depending on the actual C-state the core - is in. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. - - @param ECX MSR_SANDY_BRIDGE_PKGC7_IRTL (0x0000060C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKGC7_IRTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PKGC7_IRTL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PKGC7_IRTL is defined as MSR_PKGC7_IRTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKGC7_IRTL 0x0000060C - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PKGC7_IRTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] Interrupt response time limit (R/W) Specifies the limit - /// that should be used to decide if the package should be put into a - /// package C7 state. - /// - UINT32 TimeLimit:10; - /// - /// [Bits 12:10] Time Unit (R/W) Specifies the encoding value of time - /// unit of the interrupt response time limit. The following time unit - /// encodings are supported: 000b: 1 ns 001b: 32 ns 010b: 1024 ns 011b: - /// 32768 ns 100b: 1048576 ns 101b: 33554432 ns. - /// - UINT32 TimeUnit:3; - UINT32 Reserved1:2; - /// - /// [Bit 15] Valid (R/W) Indicates whether the values in bits 12:0 are - /// valid and can be used by the processor for package C-sate management. - /// - UINT32 Valid:1; - UINT32 Reserved2:16; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PKGC7_IRTL_REGISTER; - - -/** - Package. PP0 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP0_POLICY (0x0000063A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP0_POLICY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP0_POLICY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PP0_POLICY is defined as MSR_PP0_POLICY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP0_POLICY 0x0000063A - - -/** - Package. PP1 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 - RAPL Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP1_POWER_LIMIT (0x00000640) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_POWER_LIMIT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP1_POWER_LIMIT, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PP1_POWER_LIMIT is defined as MSR_PP1_POWER_LIMIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP1_POWER_LIMIT 0x00000640 - - -/** - Package. PP1 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS (0x00000641) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS is defined as MSR_PP1_ENERGY_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP1_ENERGY_STATUS 0x00000641 - - -/** - Package. PP1 Balance Policy (R/W) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_SANDY_BRIDGE_PP1_POLICY (0x00000642) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PP1_POLICY); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PP1_POLICY, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PP1_POLICY is defined as MSR_PP1_POLICY in SDM. -**/ -#define MSR_SANDY_BRIDGE_PP1_POLICY 0x00000642 - - -/** - Package. Uncore C-Box 0, counter n event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL2 is defined as MSR_UNC_CBO_0_PERFEVTSEL2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL3 is defined as MSR_UNC_CBO_0_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL0 0x00000700 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL1 0x00000701 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL2 0x00000702 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFEVTSEL3 0x00000703 -/// @} - - -/** - Package. Uncore C-Box n, unit status for counter 0-3. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_n_UNIT_STATUS - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS is defined as MSR_UNC_CBO_0_UNIT_STATUS in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_UNIT_STATUS is defined as MSR_UNC_CBO_1_UNIT_STATUS in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_UNIT_STATUS is defined as MSR_UNC_CBO_2_UNIT_STATUS in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_UNIT_STATUS is defined as MSR_UNC_CBO_3_UNIT_STATUS in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_UNIT_STATUS is defined as MSR_UNC_CBO_4_UNIT_STATUS in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_0_UNIT_STATUS 0x00000705 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_UNIT_STATUS 0x00000715 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_UNIT_STATUS 0x00000725 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_UNIT_STATUS 0x00000735 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_UNIT_STATUS 0x00000745 -/// @} - - -/** - Package. Uncore C-Box 0, performance counter n. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR2 is defined as MSR_UNC_CBO_0_PERFCTR2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR3 is defined as MSR_UNC_CBO_0_PERFCTR3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR0 0x00000706 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR1 0x00000707 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR2 0x00000708 -#define MSR_SANDY_BRIDGE_UNC_CBO_0_PERFCTR3 0x00000709 -/// @} - - -/** - Package. Uncore C-Box 1, counter n event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL2 is defined as MSR_UNC_CBO_1_PERFEVTSEL2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL3 is defined as MSR_UNC_CBO_1_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL0 0x00000710 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL1 0x00000711 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL2 0x00000712 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFEVTSEL3 0x00000713 -/// @} - - -/** - Package. Uncore C-Box 1, performance counter n. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR2 is defined as MSR_UNC_CBO_1_PERFCTR2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR3 is defined as MSR_UNC_CBO_1_PERFCTR3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR0 0x00000716 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR1 0x00000717 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR2 0x00000718 -#define MSR_SANDY_BRIDGE_UNC_CBO_1_PERFCTR3 0x00000719 -/// @} - - -/** - Package. Uncore C-Box 2, counter n event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL2 is defined as MSR_UNC_CBO_2_PERFEVTSEL2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL3 is defined as MSR_UNC_CBO_2_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL0 0x00000720 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL1 0x00000721 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL2 0x00000722 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFEVTSEL3 0x00000723 -/// @} - - -/** - Package. Uncore C-Box 2, performance counter n. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR2 is defined as MSR_UNC_CBO_2_PERFCTR2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR3 is defined as MSR_UNC_CBO_2_PERFCTR3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR0 0x00000726 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR1 0x00000727 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR2 0x00000728 -#define MSR_SANDY_BRIDGE_UNC_CBO_2_PERFCTR3 0x00000729 -/// @} - - -/** - Package. Uncore C-Box 3, counter n event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL2 is defined as MSR_UNC_CBO_3_PERFEVTSEL2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL3 is defined as MSR_UNC_CBO_3_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL0 0x00000730 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL1 0x00000731 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL2 0x00000732 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFEVTSEL3 0x00000733 -/// @} - - -/** - Package. Uncore C-Box 3, performance counter n. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR2 is defined as MSR_UNC_CBO_3_PERFCTR2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR3 is defined as MSR_UNC_CBO_3_PERFCTR3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR0 0x00000736 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR1 0x00000737 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR2 0x00000738 -#define MSR_SANDY_BRIDGE_UNC_CBO_3_PERFCTR3 0x00000739 -/// @} - - -/** - Package. Uncore C-Box 4, counter n event select MSR. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0 is defined as MSR_UNC_CBO_4_PERFEVTSEL0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL1 is defined as MSR_UNC_CBO_4_PERFEVTSEL1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL2 is defined as MSR_UNC_CBO_4_PERFEVTSEL2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL3 is defined as MSR_UNC_CBO_4_PERFEVTSEL3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL0 0x00000740 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL1 0x00000741 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL2 0x00000742 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFEVTSEL3 0x00000743 -/// @} - - -/** - Package. Uncore C-Box 4, performance counter n. - - @param ECX MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0 is defined as MSR_UNC_CBO_4_PERFCTR0 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR1 is defined as MSR_UNC_CBO_4_PERFCTR1 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR2 is defined as MSR_UNC_CBO_4_PERFCTR2 in SDM. - MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR3 is defined as MSR_UNC_CBO_4_PERFCTR3 in SDM. - @{ -**/ -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR0 0x00000746 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR1 0x00000747 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR2 0x00000748 -#define MSR_SANDY_BRIDGE_UNC_CBO_4_PERFCTR3 0x00000749 -/// @} - - -/** - Package. MC Bank Error Configuration (R/W). - - @param ECX MSR_SANDY_BRIDGE_ERROR_CONTROL (0x0000017F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_ERROR_CONTROL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_ERROR_CONTROL, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_ERROR_CONTROL is defined as MSR_ERROR_CONTROL in SDM. -**/ -#define MSR_SANDY_BRIDGE_ERROR_CONTROL 0x0000017F - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_ERROR_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:1; - /// - /// [Bit 1] MemError Log Enable (R/W) When set, enables IMC status bank - /// to log additional info in bits 36:32. - /// - UINT32 MemErrorLogEnable:1; - UINT32 Reserved2:30; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_ERROR_CONTROL_REGISTER; - - -/** - Package. - - @param ECX MSR_SANDY_BRIDGE_PEBS_NUM_ALT (0x0000039C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER. - - Example usage - @code - MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_PEBS_NUM_ALT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PEBS_NUM_ALT, Msr.Uint64); - @endcode - @note MSR_SANDY_BRIDGE_PEBS_NUM_ALT is defined as MSR_PEBS_NUM_ALT in SDM. -**/ -#define MSR_SANDY_BRIDGE_PEBS_NUM_ALT 0x0000039C - -/** - MSR information returned for MSR index #MSR_SANDY_BRIDGE_PEBS_NUM_ALT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] ENABLE_PEBS_NUM_ALT (RW) Write 1 to enable alternate PEBS - /// counting logic for specific events requiring additional configuration, - /// see Table 19-15. - /// - UINT32 ENABLE_PEBS_NUM_ALT:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SANDY_BRIDGE_PEBS_NUM_ALT_REGISTER; - - -/** - Package. Package RAPL Perf Status (R/O). - - @param ECX MSR_SANDY_BRIDGE_PKG_PERF_STATUS (0x00000613) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PKG_PERF_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_PKG_PERF_STATUS 0x00000613 - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_SANDY_BRIDGE_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_DRAM_ENERGY_STATUS 0x00000619 - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_SANDY_BRIDGE_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_PERF_STATUS); - @endcode - @note MSR_SANDY_BRIDGE_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_SANDY_BRIDGE_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_SANDY_BRIDGE_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_SANDY_BRIDGE_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_SANDY_BRIDGE_DRAM_POWER_INFO 0x0000061C - - -/** - Package. Uncore U-box UCLK fixed counter control. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL (0x00000C08) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL is defined as MSR_U_PMON_UCLK_FIXED_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTL 0x00000C08 - - -/** - Package. Uncore U-box UCLK fixed counter. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR (0x00000C09) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR is defined as MSR_U_PMON_UCLK_FIXED_CTR in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_UCLK_FIXED_CTR 0x00000C09 - - -/** - Package. Uncore U-box perfmon event select for U-box counter 0. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 (0x00000C10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 is defined as MSR_U_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_EVNTSEL0 0x00000C10 - - -/** - Package. Uncore U-box perfmon event select for U-box counter 1. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 (0x00000C11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 is defined as MSR_U_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_EVNTSEL1 0x00000C11 - - -/** - Package. Uncore U-box perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_CTR0 (0x00000C16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_CTR0 is defined as MSR_U_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_CTR0 0x00000C16 - - -/** - Package. Uncore U-box perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_U_PMON_CTR1 (0x00000C17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_U_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_U_PMON_CTR1 is defined as MSR_U_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_U_PMON_CTR1 0x00000C17 - - -/** - Package. Uncore PCU perfmon for PCU-box-wide control. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL (0x00000C24) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL is defined as MSR_PCU_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_BOX_CTL 0x00000C24 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 0. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 (0x00000C30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 is defined as MSR_PCU_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL0 0x00000C30 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 1. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 (0x00000C31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 is defined as MSR_PCU_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL1 0x00000C31 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 2. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 (0x00000C32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 is defined as MSR_PCU_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL2 0x00000C32 - - -/** - Package. Uncore PCU perfmon event select for PCU counter 3. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 (0x00000C33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 is defined as MSR_PCU_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_EVNTSEL3 0x00000C33 - - -/** - Package. Uncore PCU perfmon box-wide filter. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER (0x00000C34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER is defined as MSR_PCU_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_BOX_FILTER 0x00000C34 - - -/** - Package. Uncore PCU perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR0 (0x00000C36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_CTR0 is defined as MSR_PCU_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_CTR0 0x00000C36 - - -/** - Package. Uncore PCU perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR1 (0x00000C37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_CTR1 is defined as MSR_PCU_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_CTR1 0x00000C37 - - -/** - Package. Uncore PCU perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR2 (0x00000C38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_CTR2 is defined as MSR_PCU_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_CTR2 0x00000C38 - - -/** - Package. Uncore PCU perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_PCU_PMON_CTR3 (0x00000C39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_PCU_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_PCU_PMON_CTR3 is defined as MSR_PCU_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_PCU_PMON_CTR3 0x00000C39 - - -/** - Package. Uncore C-box 0 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL (0x00000D04) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL is defined as MSR_C0_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_BOX_CTL 0x00000D04 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 (0x00000D10) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 is defined as MSR_C0_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL0 0x00000D10 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 (0x00000D11) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 is defined as MSR_C0_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL1 0x00000D11 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 (0x00000D12) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 is defined as MSR_C0_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL2 0x00000D12 - - -/** - Package. Uncore C-box 0 perfmon event select for C-box 0 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 (0x00000D13) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 is defined as MSR_C0_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_EVNTSEL3 0x00000D13 - - -/** - Package. Uncore C-box 0 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER (0x00000D14) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER is defined as MSR_C0_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_BOX_FILTER 0x00000D14 - - -/** - Package. Uncore C-box 0 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR0 (0x00000D16) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_CTR0 is defined as MSR_C0_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_CTR0 0x00000D16 - - -/** - Package. Uncore C-box 0 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR1 (0x00000D17) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_CTR1 is defined as MSR_C0_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_CTR1 0x00000D17 - - -/** - Package. Uncore C-box 0 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR2 (0x00000D18) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_CTR2 is defined as MSR_C0_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_CTR2 0x00000D18 - - -/** - Package. Uncore C-box 0 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C0_PMON_CTR3 (0x00000D19) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C0_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C0_PMON_CTR3 is defined as MSR_C0_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C0_PMON_CTR3 0x00000D19 - - -/** - Package. Uncore C-box 1 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL (0x00000D24) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL is defined as MSR_C1_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_BOX_CTL 0x00000D24 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 (0x00000D30) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 is defined as MSR_C1_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL0 0x00000D30 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 (0x00000D31) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 is defined as MSR_C1_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL1 0x00000D31 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 (0x00000D32) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 is defined as MSR_C1_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL2 0x00000D32 - - -/** - Package. Uncore C-box 1 perfmon event select for C-box 1 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 (0x00000D33) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 is defined as MSR_C1_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_EVNTSEL3 0x00000D33 - - -/** - Package. Uncore C-box 1 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER (0x00000D34) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER is defined as MSR_C1_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_BOX_FILTER 0x00000D34 - - -/** - Package. Uncore C-box 1 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR0 (0x00000D36) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_CTR0 is defined as MSR_C1_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_CTR0 0x00000D36 - - -/** - Package. Uncore C-box 1 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR1 (0x00000D37) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_CTR1 is defined as MSR_C1_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_CTR1 0x00000D37 - - -/** - Package. Uncore C-box 1 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR2 (0x00000D38) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_CTR2 is defined as MSR_C1_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_CTR2 0x00000D38 - - -/** - Package. Uncore C-box 1 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C1_PMON_CTR3 (0x00000D39) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C1_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C1_PMON_CTR3 is defined as MSR_C1_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C1_PMON_CTR3 0x00000D39 - - -/** - Package. Uncore C-box 2 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL (0x00000D44) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL is defined as MSR_C2_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_BOX_CTL 0x00000D44 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 (0x00000D50) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 is defined as MSR_C2_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL0 0x00000D50 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 (0x00000D51) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 is defined as MSR_C2_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL1 0x00000D51 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 (0x00000D52) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 is defined as MSR_C2_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL2 0x00000D52 - - -/** - Package. Uncore C-box 2 perfmon event select for C-box 2 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 (0x00000D53) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 is defined as MSR_C2_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_EVNTSEL3 0x00000D53 - - -/** - Package. Uncore C-box 2 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER (0x00000D54) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER is defined as MSR_C2_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_BOX_FILTER 0x00000D54 - - -/** - Package. Uncore C-box 2 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR0 (0x00000D56) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_CTR0 is defined as MSR_C2_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_CTR0 0x00000D56 - - -/** - Package. Uncore C-box 2 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR1 (0x00000D57) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_CTR1 is defined as MSR_C2_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_CTR1 0x00000D57 - - -/** - Package. Uncore C-box 2 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR2 (0x00000D58) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_CTR2 is defined as MSR_C2_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_CTR2 0x00000D58 - - -/** - Package. Uncore C-box 2 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C2_PMON_CTR3 (0x00000D59) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C2_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C2_PMON_CTR3 is defined as MSR_C2_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C2_PMON_CTR3 0x00000D59 - - -/** - Package. Uncore C-box 3 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL (0x00000D64) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL is defined as MSR_C3_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_BOX_CTL 0x00000D64 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 (0x00000D70) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 is defined as MSR_C3_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL0 0x00000D70 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 (0x00000D71) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 is defined as MSR_C3_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL1 0x00000D71 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 (0x00000D72) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 is defined as MSR_C3_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL2 0x00000D72 - - -/** - Package. Uncore C-box 3 perfmon event select for C-box 3 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 (0x00000D73) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 is defined as MSR_C3_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_EVNTSEL3 0x00000D73 - - -/** - Package. Uncore C-box 3 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER (0x00000D74) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER is defined as MSR_C3_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_BOX_FILTER 0x00000D74 - - -/** - Package. Uncore C-box 3 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR0 (0x00000D76) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_CTR0 is defined as MSR_C3_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_CTR0 0x00000D76 - - -/** - Package. Uncore C-box 3 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR1 (0x00000D77) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_CTR1 is defined as MSR_C3_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_CTR1 0x00000D77 - - -/** - Package. Uncore C-box 3 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR2 (0x00000D78) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_CTR2 is defined as MSR_C3_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_CTR2 0x00000D78 - - -/** - Package. Uncore C-box 3 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C3_PMON_CTR3 (0x00000D79) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C3_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C3_PMON_CTR3 is defined as MSR_C3_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C3_PMON_CTR3 0x00000D79 - - -/** - Package. Uncore C-box 4 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL (0x00000D84) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL is defined as MSR_C4_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_BOX_CTL 0x00000D84 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 (0x00000D90) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 is defined as MSR_C4_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL0 0x00000D90 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 (0x00000D91) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 is defined as MSR_C4_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL1 0x00000D91 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 (0x00000D92) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 is defined as MSR_C4_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL2 0x00000D92 - - -/** - Package. Uncore C-box 4 perfmon event select for C-box 4 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 (0x00000D93) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 is defined as MSR_C4_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_EVNTSEL3 0x00000D93 - - -/** - Package. Uncore C-box 4 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER (0x00000D94) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER is defined as MSR_C4_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_BOX_FILTER 0x00000D94 - - -/** - Package. Uncore C-box 4 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR0 (0x00000D96) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_CTR0 is defined as MSR_C4_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_CTR0 0x00000D96 - - -/** - Package. Uncore C-box 4 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR1 (0x00000D97) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_CTR1 is defined as MSR_C4_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_CTR1 0x00000D97 - - -/** - Package. Uncore C-box 4 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR2 (0x00000D98) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_CTR2 is defined as MSR_C4_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_CTR2 0x00000D98 - - -/** - Package. Uncore C-box 4 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C4_PMON_CTR3 (0x00000D99) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C4_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C4_PMON_CTR3 is defined as MSR_C4_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C4_PMON_CTR3 0x00000D99 - - -/** - Package. Uncore C-box 5 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL (0x00000DA4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL is defined as MSR_C5_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_BOX_CTL 0x00000DA4 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 (0x00000DB0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 is defined as MSR_C5_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL0 0x00000DB0 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 (0x00000DB1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 is defined as MSR_C5_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL1 0x00000DB1 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 (0x00000DB2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 is defined as MSR_C5_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL2 0x00000DB2 - - -/** - Package. Uncore C-box 5 perfmon event select for C-box 5 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 (0x00000DB3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 is defined as MSR_C5_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_EVNTSEL3 0x00000DB3 - - -/** - Package. Uncore C-box 5 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER (0x00000DB4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER is defined as MSR_C5_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_BOX_FILTER 0x00000DB4 - - -/** - Package. Uncore C-box 5 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR0 (0x00000DB6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_CTR0 is defined as MSR_C5_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_CTR0 0x00000DB6 - - -/** - Package. Uncore C-box 5 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR1 (0x00000DB7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_CTR1 is defined as MSR_C5_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_CTR1 0x00000DB7 - - -/** - Package. Uncore C-box 5 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR2 (0x00000DB8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_CTR2 is defined as MSR_C5_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_CTR2 0x00000DB8 - - -/** - Package. Uncore C-box 5 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C5_PMON_CTR3 (0x00000DB9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C5_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C5_PMON_CTR3 is defined as MSR_C5_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C5_PMON_CTR3 0x00000DB9 - - -/** - Package. Uncore C-box 6 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL (0x00000DC4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL is defined as MSR_C6_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_BOX_CTL 0x00000DC4 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 (0x00000DD0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 is defined as MSR_C6_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL0 0x00000DD0 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 (0x00000DD1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 is defined as MSR_C6_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL1 0x00000DD1 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 (0x00000DD2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 is defined as MSR_C6_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL2 0x00000DD2 - - -/** - Package. Uncore C-box 6 perfmon event select for C-box 6 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 (0x00000DD3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 is defined as MSR_C6_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_EVNTSEL3 0x00000DD3 - - -/** - Package. Uncore C-box 6 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER (0x00000DD4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER is defined as MSR_C6_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_BOX_FILTER 0x00000DD4 - - -/** - Package. Uncore C-box 6 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR0 (0x00000DD6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_CTR0 is defined as MSR_C6_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_CTR0 0x00000DD6 - - -/** - Package. Uncore C-box 6 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR1 (0x00000DD7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_CTR1 is defined as MSR_C6_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_CTR1 0x00000DD7 - - -/** - Package. Uncore C-box 6 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR2 (0x00000DD8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_CTR2 is defined as MSR_C6_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_CTR2 0x00000DD8 - - -/** - Package. Uncore C-box 6 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C6_PMON_CTR3 (0x00000DD9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C6_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C6_PMON_CTR3 is defined as MSR_C6_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C6_PMON_CTR3 0x00000DD9 - - -/** - Package. Uncore C-box 7 perfmon local box wide control. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL (0x00000DE4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL is defined as MSR_C7_PMON_BOX_CTL in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_BOX_CTL 0x00000DE4 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 0. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 (0x00000DF0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 is defined as MSR_C7_PMON_EVNTSEL0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL0 0x00000DF0 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 1. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 (0x00000DF1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 is defined as MSR_C7_PMON_EVNTSEL1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL1 0x00000DF1 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 2. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 (0x00000DF2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 is defined as MSR_C7_PMON_EVNTSEL2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL2 0x00000DF2 - - -/** - Package. Uncore C-box 7 perfmon event select for C-box 7 counter 3. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 (0x00000DF3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 is defined as MSR_C7_PMON_EVNTSEL3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_EVNTSEL3 0x00000DF3 - - -/** - Package. Uncore C-box 7 perfmon box wide filter. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER (0x00000DF4) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER is defined as MSR_C7_PMON_BOX_FILTER in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_BOX_FILTER 0x00000DF4 - - -/** - Package. Uncore C-box 7 perfmon counter 0. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR0 (0x00000DF6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR0); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR0, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_CTR0 is defined as MSR_C7_PMON_CTR0 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_CTR0 0x00000DF6 - - -/** - Package. Uncore C-box 7 perfmon counter 1. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR1 (0x00000DF7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR1); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR1, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_CTR1 is defined as MSR_C7_PMON_CTR1 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_CTR1 0x00000DF7 - - -/** - Package. Uncore C-box 7 perfmon counter 2. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR2 (0x00000DF8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR2); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR2, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_CTR2 is defined as MSR_C7_PMON_CTR2 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_CTR2 0x00000DF8 - - -/** - Package. Uncore C-box 7 perfmon counter 3. - - @param ECX MSR_SANDY_BRIDGE_C7_PMON_CTR3 (0x00000DF9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR3); - AsmWriteMsr64 (MSR_SANDY_BRIDGE_C7_PMON_CTR3, Msr); - @endcode - @note MSR_SANDY_BRIDGE_C7_PMON_CTR3 is defined as MSR_C7_PMON_CTR3 in SDM. -**/ -#define MSR_SANDY_BRIDGE_C7_PMON_CTR3 0x00000DF9 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h b/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h deleted file mode 100644 index ec09bf3c13..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/SilvermontMsr.h +++ /dev/null @@ -1,1570 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Silvermont microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.4. - -**/ - -#ifndef __SILVERMONT_MSR_H__ -#define __SILVERMONT_MSR_H__ - -#include - -/** - Is Intel processors based on the Silvermont microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_SILVERMONT_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x37 || \ - DisplayModel == 0x4A || \ - DisplayModel == 0x4D || \ - DisplayModel == 0x5A || \ - DisplayModel == 0x5D \ - ) \ - ) - -/** - Module. Model Specific Platform ID (R). - - @param ECX MSR_SILVERMONT_PLATFORM_ID (0x00000017) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PLATFORM_ID_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PLATFORM_ID_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PLATFORM_ID_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PLATFORM_ID); - @endcode - @note MSR_SILVERMONT_PLATFORM_ID is defined as MSR_PLATFORM_ID in SDM. -**/ -#define MSR_SILVERMONT_PLATFORM_ID 0x00000017 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PLATFORM_ID -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 12:8] Maximum Qualified Ratio (R) The maximum allowed bus ratio. - /// - UINT32 MaximumQualifiedRatio:5; - UINT32 Reserved2:19; - UINT32 Reserved3:18; - /// - /// [Bits 52:50] See Table 35-2. - /// - UINT32 PlatformId:3; - UINT32 Reserved4:11; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PLATFORM_ID_REGISTER; - - -/** - Module. Processor Hard Power-On Configuration (R/W) Writes ignored. - - @param ECX MSR_SILVERMONT_EBL_CR_POWERON (0x0000002A) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_EBL_CR_POWERON_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_EBL_CR_POWERON_REGISTER. - - Example usage - @code - MSR_SILVERMONT_EBL_CR_POWERON_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_EBL_CR_POWERON); - AsmWriteMsr64 (MSR_SILVERMONT_EBL_CR_POWERON, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_EBL_CR_POWERON is defined as MSR_EBL_CR_POWERON in SDM. -**/ -#define MSR_SILVERMONT_EBL_CR_POWERON 0x0000002A - -/** - MSR information returned for MSR index #MSR_SILVERMONT_EBL_CR_POWERON -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_EBL_CR_POWERON_REGISTER; - - -/** - Core. SMI Counter (R/O). - - @param ECX MSR_SILVERMONT_SMI_COUNT (0x00000034) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_SMI_COUNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_SMI_COUNT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_SMI_COUNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_SMI_COUNT); - @endcode - @note MSR_SILVERMONT_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. -**/ -#define MSR_SILVERMONT_SMI_COUNT 0x00000034 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_SMI_COUNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] SMI Count (R/O) Running count of SMI events since last - /// RESET. - /// - UINT32 SMICount:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_SMI_COUNT_REGISTER; - - -/** - Core. Control Features in Intel 64 Processor (R/W). See Table 35-2. - - @param ECX MSR_IA32_SILVERMONT_FEATURE_CONTROL (0x0000003A) - @param EAX Lower 32-bits of MSR value. - Described by the type - MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type - MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_IA32_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_SILVERMONT_IA32_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_IA32_FEATURE_CONTROL is defined as IA32_FEATURE_CONTROL in SDM. -**/ -#define MSR_SILVERMONT_IA32_FEATURE_CONTROL 0x0000003A - -/** - MSR information returned for MSR index #MSR_SILVERMONT_IA32_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Lock (R/WL). - /// - UINT32 Lock:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Enable VMX outside SMX operation (R/WL). - /// - UINT32 EnableVmxOutsideSmx:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_IA32_FEATURE_CONTROL_REGISTER; - - -/** - Core. Last Branch Record n From IP (R/W) One of eight pairs of last branch - record registers on the last branch record stack. The From_IP part of the - stack contains pointers to the source instruction. See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.5 and record format in Section - 17.4.8.1. - - @param ECX MSR_SILVERMONT_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_0_FROM_IP); - AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_0_FROM_IP, Msr); - @endcode - @note MSR_SILVERMONT_LASTBRANCH_0_FROM_IP is defined as MSR_LASTBRANCH_0_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_1_FROM_IP is defined as MSR_LASTBRANCH_1_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_2_FROM_IP is defined as MSR_LASTBRANCH_2_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_3_FROM_IP is defined as MSR_LASTBRANCH_3_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_4_FROM_IP is defined as MSR_LASTBRANCH_4_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_5_FROM_IP is defined as MSR_LASTBRANCH_5_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_6_FROM_IP is defined as MSR_LASTBRANCH_6_FROM_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_7_FROM_IP is defined as MSR_LASTBRANCH_7_FROM_IP in SDM. - @{ -**/ -#define MSR_SILVERMONT_LASTBRANCH_0_FROM_IP 0x00000040 -#define MSR_SILVERMONT_LASTBRANCH_1_FROM_IP 0x00000041 -#define MSR_SILVERMONT_LASTBRANCH_2_FROM_IP 0x00000042 -#define MSR_SILVERMONT_LASTBRANCH_3_FROM_IP 0x00000043 -#define MSR_SILVERMONT_LASTBRANCH_4_FROM_IP 0x00000044 -#define MSR_SILVERMONT_LASTBRANCH_5_FROM_IP 0x00000045 -#define MSR_SILVERMONT_LASTBRANCH_6_FROM_IP 0x00000046 -#define MSR_SILVERMONT_LASTBRANCH_7_FROM_IP 0x00000047 -/// @} - - -/** - Core. Last Branch Record n To IP (R/W) One of eight pairs of last branch - record registers on the last branch record stack. The To_IP part of the - stack contains pointers to the destination instruction. - - @param ECX MSR_SILVERMONT_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_0_TO_IP); - AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_0_TO_IP, Msr); - @endcode - @note MSR_SILVERMONT_LASTBRANCH_0_TO_IP is defined as MSR_LASTBRANCH_0_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_1_TO_IP is defined as MSR_LASTBRANCH_1_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_2_TO_IP is defined as MSR_LASTBRANCH_2_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_3_TO_IP is defined as MSR_LASTBRANCH_3_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_4_TO_IP is defined as MSR_LASTBRANCH_4_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_5_TO_IP is defined as MSR_LASTBRANCH_5_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_6_TO_IP is defined as MSR_LASTBRANCH_6_TO_IP in SDM. - MSR_SILVERMONT_LASTBRANCH_7_TO_IP is defined as MSR_LASTBRANCH_7_TO_IP in SDM. - @{ -**/ -#define MSR_SILVERMONT_LASTBRANCH_0_TO_IP 0x00000060 -#define MSR_SILVERMONT_LASTBRANCH_1_TO_IP 0x00000061 -#define MSR_SILVERMONT_LASTBRANCH_2_TO_IP 0x00000062 -#define MSR_SILVERMONT_LASTBRANCH_3_TO_IP 0x00000063 -#define MSR_SILVERMONT_LASTBRANCH_4_TO_IP 0x00000064 -#define MSR_SILVERMONT_LASTBRANCH_5_TO_IP 0x00000065 -#define MSR_SILVERMONT_LASTBRANCH_6_TO_IP 0x00000066 -#define MSR_SILVERMONT_LASTBRANCH_7_TO_IP 0x00000067 -/// @} - - -/** - Module. Scalable Bus Speed(RO) This field indicates the intended scalable - bus clock speed for processors based on Silvermont microarchitecture:. - - @param ECX MSR_SILVERMONT_FSB_FREQ (0x000000CD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_FSB_FREQ_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_FSB_FREQ_REGISTER. - - Example usage - @code - MSR_SILVERMONT_FSB_FREQ_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_FSB_FREQ); - @endcode - @note MSR_SILVERMONT_FSB_FREQ is defined as MSR_FSB_FREQ in SDM. -**/ -#define MSR_SILVERMONT_FSB_FREQ 0x000000CD - -/** - MSR information returned for MSR index #MSR_SILVERMONT_FSB_FREQ -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Scalable Bus Speed - /// - /// Silvermont Processor Family - /// --------------------------- - /// 100B: 080.0 MHz - /// 000B: 083.3 MHz - /// 001B: 100.0 MHz - /// 010B: 133.3 MHz - /// 011B: 116.7 MHz - /// - /// Airmont Processor Family - /// --------------------------- - /// 0000B: 083.3 MHz - /// 0001B: 100.0 MHz - /// 0010B: 133.3 MHz - /// 0011B: 116.7 MHz - /// 0100B: 080.0 MHz - /// 0101B: 093.3 MHz - /// 0110B: 090.0 MHz - /// 0111B: 088.9 MHz - /// 1000B: 087.5 MHz - /// - UINT32 ScalableBusSpeed:4; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_FSB_FREQ_REGISTER; - - -/** - Module. C-State Configuration Control (R/W) Note: C-state values are - processor specific C-state code names, unrelated to MWAIT extension C-state - parameters or ACPI CStates. See http://biosbits.org. - - @param ECX MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power). for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0 (no package C-sate support) 001b: C1 (Behavior is the same as 000b) - /// 100b: C4 110b: C6 111b: C7 (Silvermont only). - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W) When set, will map - /// IO_read instructions sent to IO register specified by - /// MSR_PMG_IO_CAPTURE_BASE to MWAIT instructions. - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO) When set, lock bits 15:0 of this register - /// until next reset. - /// - UINT32 CFGLock:1; - UINT32 Reserved3:16; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Module. Power Management IO Redirection in C-state (R/W) See - http://biosbits.org. - - @param ECX MSR_SILVERMONT_PMG_IO_CAPTURE_BASE (0x000000E4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PMG_IO_CAPTURE_BASE); - AsmWriteMsr64 (MSR_SILVERMONT_PMG_IO_CAPTURE_BASE, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. -**/ -#define MSR_SILVERMONT_PMG_IO_CAPTURE_BASE 0x000000E4 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PMG_IO_CAPTURE_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] LVL_2 Base Address (R/W) Specifies the base address - /// visible to software for IO redirection. If IO MWAIT Redirection is - /// enabled, reads to this address will be consumed by the power - /// management logic and decoded to MWAIT instructions. When IO port - /// address redirection is enabled, this is the IO port address reported - /// to the OS/software. - /// - UINT32 Lvl2Base:16; - /// - /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the - /// maximum C-State code name to be included when IO read to MWAIT - /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 100b - C4 - /// is the max C-State to include 110b - C6 is the max C-State to include - /// 111b - C7 is the max C-State to include. - /// - UINT32 CStateRange:3; - UINT32 Reserved1:13; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PMG_IO_CAPTURE_BASE_REGISTER; - - -/** - Module. - - @param ECX MSR_SILVERMONT_BBL_CR_CTL3 (0x0000011E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_BBL_CR_CTL3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_BBL_CR_CTL3_REGISTER. - - Example usage - @code - MSR_SILVERMONT_BBL_CR_CTL3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_BBL_CR_CTL3); - AsmWriteMsr64 (MSR_SILVERMONT_BBL_CR_CTL3, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_BBL_CR_CTL3 is defined as MSR_BBL_CR_CTL3 in SDM. -**/ -#define MSR_SILVERMONT_BBL_CR_CTL3 0x0000011E - -/** - MSR information returned for MSR index #MSR_SILVERMONT_BBL_CR_CTL3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] L2 Hardware Enabled (RO) 1 = If the L2 is hardware-enabled 0 = - /// Indicates if the L2 is hardware-disabled. - /// - UINT32 L2HardwareEnabled:1; - UINT32 Reserved1:7; - /// - /// [Bit 8] L2 Enabled. (R/W) 1 = L2 cache has been initialized 0 = - /// Disabled (default) Until this bit is set the processor will not - /// respond to the WBINVD instruction or the assertion of the FLUSH# input. - /// - UINT32 L2Enabled:1; - UINT32 Reserved2:14; - /// - /// [Bit 23] L2 Not Present (RO) 1. = L2 Present 2. = L2 Not Present. - /// - UINT32 L2NotPresent:1; - UINT32 Reserved3:8; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_BBL_CR_CTL3_REGISTER; - - -/** - Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP - handler to handle unsuccessful read of this MSR. - - @param ECX MSR_SILVERMONT_FEATURE_CONFIG (0x0000013C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_FEATURE_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_FEATURE_CONFIG_REGISTER. - - Example usage - @code - MSR_SILVERMONT_FEATURE_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_FEATURE_CONFIG); - AsmWriteMsr64 (MSR_SILVERMONT_FEATURE_CONFIG, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. -**/ -#define MSR_SILVERMONT_FEATURE_CONFIG 0x0000013C - -/** - MSR information returned for MSR index #MSR_SILVERMONT_FEATURE_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this - /// MSR, the configuration of AES instruction set availability is as - /// follows: 11b: AES instructions are not available until next RESET. - /// otherwise, AES instructions are available. Note, AES instruction set - /// is not available if read is unsuccessful. If the configuration is not - /// 01b, AES instruction can be mis-configured if a privileged agent - /// unintentionally writes 11b. - /// - UINT32 AESConfiguration:2; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_FEATURE_CONFIG_REGISTER; - - -/** - Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_SILVERMONT_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_SILVERMONT_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_SILVERMONT_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. Fast-Strings Enable See Table 35-2. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Module. Automatic Thermal Control Circuit Enable (R/W) See - /// Table 35-2. Default value is 0. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Core. Performance Monitoring Available (R) See Table 35-2. - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:3; - /// - /// [Bit 11] Core. Branch Trace Storage Unavailable (RO) See Table 35-2. - /// - UINT32 BTS:1; - /// - /// [Bit 12] Core. Processor Event Based Sampling Unavailable (RO) See - /// Table 35-2. - /// - UINT32 PEBS:1; - UINT32 Reserved4:3; - /// - /// [Bit 16] Module. Enhanced Intel SpeedStep Technology Enable (R/W) See - /// Table 35-2. - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] Core. ENABLE MONITOR FSM (R/W) See Table 35-2. - /// - UINT32 MONITOR:1; - UINT32 Reserved6:3; - /// - /// [Bit 22] Core. Limit CPUID Maxval (R/W) See Table 35-2. - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] Module. xTPR Message Disable (R/W) See Table 35-2. - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] Core. XD Bit Disable (R/W) See Table 35-2. - /// - UINT32 XD:1; - UINT32 Reserved9:3; - /// - /// [Bit 38] Module. Turbo Mode Disable (R/W) When set to 1 on processors - /// that support Intel Turbo Boost Technology, the turbo mode feature is - /// disabled and the IDA_Enable feature flag will be clear (CPUID.06H: - /// EAX[1]=0). When set to a 0 on processors that support IDA, CPUID.06H: - /// EAX[1] reports the processor's support of turbo mode is enabled. Note: - /// the power-on default value is used by BIOS to detect hardware support - /// of turbo mode. If power-on default value is 1, turbo mode is available - /// in the processor. If power-on default value is 0, turbo mode is not - /// available. - /// - UINT32 TurboModeDisable:1; - UINT32 Reserved10:25; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_IA32_MISC_ENABLE_REGISTER; - - -/** - Package. - - @param ECX MSR_SILVERMONT_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_SILVERMONT_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_SILVERMONT_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (R) The default thermal throttling or - /// PROCHOT# activation temperature in degree C, The effective temperature - /// for thermal throttling or PROCHOT# activation is "Temperature Target" - /// + "Target Offset". - /// - UINT32 TemperatureTarget:8; - /// - /// [Bits 29:24] Target Offset (R/W) Specifies an offset in degrees C to - /// adjust the throttling and PROCHOT# activation temperature from the - /// default target specified in TEMPERATURE_TARGET (bits 23:16). - /// - UINT32 TargetOffset:6; - UINT32 Reserved2:2; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_TEMPERATURE_TARGET_REGISTER; - - -/** - Miscellaneous Feature Control (R/W). - - @param ECX MSR_SILVERMONT_MISC_FEATURE_CONTROL (0x000001A4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_MISC_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_SILVERMONT_MISC_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. -**/ -#define MSR_SILVERMONT_MISC_FEATURE_CONTROL 0x000001A4 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_MISC_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the - /// L2 hardware prefetcher, which fetches additional lines of code or data - /// into the L2 cache. - /// - UINT32 L2HardwarePrefetcherDisable:1; - UINT32 Reserved1:1; - /// - /// [Bit 2] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables - /// the L1 data cache prefetcher, which fetches the next cache line into - /// L1 data cache. - /// - UINT32 DCUHardwarePrefetcherDisable:1; - UINT32 Reserved2:29; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_MISC_FEATURE_CONTROL_REGISTER; - - -/** - Module. Offcore Response Event Select Register (R/W). - - @param ECX MSR_SILVERMONT_OFFCORE_RSP_0 (0x000001A6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_OFFCORE_RSP_0); - AsmWriteMsr64 (MSR_SILVERMONT_OFFCORE_RSP_0, Msr); - @endcode - @note MSR_SILVERMONT_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. -**/ -#define MSR_SILVERMONT_OFFCORE_RSP_0 0x000001A6 - - -/** - Module. Offcore Response Event Select Register (R/W). - - @param ECX MSR_SILVERMONT_OFFCORE_RSP_1 (0x000001A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_OFFCORE_RSP_1); - AsmWriteMsr64 (MSR_SILVERMONT_OFFCORE_RSP_1, Msr); - @endcode - @note MSR_SILVERMONT_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. -**/ -#define MSR_SILVERMONT_OFFCORE_RSP_1 0x000001A7 - - -/** - Package. Maximum Ratio Limit of Turbo Mode (RW). - - @param ECX MSR_SILVERMONT_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_TURBO_RATIO_LIMIT); - AsmWriteMsr64 (MSR_SILVERMONT_TURBO_RATIO_LIMIT, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_SILVERMONT_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_SILVERMONT_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio - /// limit of 5 core active. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio - /// limit of 6 core active. - /// - UINT32 Maximum6C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 7C Maximum turbo ratio - /// limit of 7 core active. - /// - UINT32 Maximum7C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for 8C Maximum turbo ratio - /// limit of 8 core active. - /// - UINT32 Maximum8C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Core. Last Branch Record Filtering Select Register (R/W) See Section - 17.7.2, "Filtering of Last Branch Records.". - - @param ECX MSR_SILVERMONT_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_LBR_SELECT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_LBR_SELECT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_LBR_SELECT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_LBR_SELECT); - AsmWriteMsr64 (MSR_SILVERMONT_LBR_SELECT, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_SILVERMONT_LBR_SELECT 0x000001C8 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_LBR_SELECT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CPL_EQ_0. - /// - UINT32 CPL_EQ_0:1; - /// - /// [Bit 1] CPL_NEQ_0. - /// - UINT32 CPL_NEQ_0:1; - /// - /// [Bit 2] JCC. - /// - UINT32 JCC:1; - /// - /// [Bit 3] NEAR_REL_CALL. - /// - UINT32 NEAR_REL_CALL:1; - /// - /// [Bit 4] NEAR_IND_CALL. - /// - UINT32 NEAR_IND_CALL:1; - /// - /// [Bit 5] NEAR_RET. - /// - UINT32 NEAR_RET:1; - /// - /// [Bit 6] NEAR_IND_JMP. - /// - UINT32 NEAR_IND_JMP:1; - /// - /// [Bit 7] NEAR_REL_JMP. - /// - UINT32 NEAR_REL_JMP:1; - /// - /// [Bit 8] FAR_BRANCH. - /// - UINT32 FAR_BRANCH:1; - UINT32 Reserved1:23; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_LBR_SELECT_REGISTER; - - -/** - Core. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-2) that - points to the MSR containing the most recent branch record. See - MSR_LASTBRANCH_0_FROM_IP. - - @param ECX MSR_SILVERMONT_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_SILVERMONT_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_SILVERMONT_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_SILVERMONT_LASTBRANCH_TOS 0x000001C9 - - -/** - Core. Last Exception Record From Linear IP (R) Contains a pointer to the - last branch instruction that the processor executed prior to the last - exception that was generated or the last interrupt that was handled. - - @param ECX MSR_SILVERMONT_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_LER_FROM_LIP); - @endcode - @note MSR_SILVERMONT_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_SILVERMONT_LER_FROM_LIP 0x000001DD - - -/** - Core. Last Exception Record To Linear IP (R) This area contains a pointer - to the target of the last branch instruction that the processor executed - prior to the last exception that was generated or the last interrupt that - was handled. - - @param ECX MSR_SILVERMONT_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_LER_TO_LIP); - @endcode - @note MSR_SILVERMONT_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_SILVERMONT_LER_TO_LIP 0x000001DE - - -/** - Core. See Table 35-2. See Section 18.4.4, "Processor Event Based Sampling - (PEBS).". - - @param ECX MSR_SILVERMONT_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PEBS_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PEBS_ENABLE_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PEBS_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PEBS_ENABLE); - AsmWriteMsr64 (MSR_SILVERMONT_PEBS_ENABLE, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_SILVERMONT_PEBS_ENABLE 0x000003F1 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PEBS_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Enable PEBS for precise event on IA32_PMC0. (R/W). - /// - UINT32 PEBS:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PEBS_ENABLE_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. Package C6 - Residency Counter. (R/O) Value since last reset that this package is in - processor-specific C6 states. Counts at the TSC Frequency. - - @param ECX MSR_SILVERMONT_PKG_C6_RESIDENCY (0x000003FA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_SILVERMONT_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_SILVERMONT_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_SILVERMONT_PKG_C6_RESIDENCY 0x000003FA - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C6 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C6 states. Counts at the TSC Frequency. - - @param ECX MSR_SILVERMONT_CORE_C6_RESIDENCY (0x000003FD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_CORE_C6_RESIDENCY); - AsmWriteMsr64 (MSR_SILVERMONT_CORE_C6_RESIDENCY, Msr); - @endcode - @note MSR_SILVERMONT_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. -**/ -#define MSR_SILVERMONT_CORE_C6_RESIDENCY 0x000003FD - - -/** - Core. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. - - @param ECX MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM (0x0000048C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM); - @endcode - @note MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. -**/ -#define MSR_SILVERMONT_IA32_VMX_EPT_VPID_ENUM 0x0000048C - - -/** - Core. Capability Reporting Register of VM-function Controls (R/O) See Table - 35-2. - - @param ECX MSR_SILVERMONT_IA32_VMX_FMFUNC (0x00000491) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_IA32_VMX_FMFUNC); - @endcode - @note MSR_SILVERMONT_IA32_VMX_FMFUNC is defined as IA32_VMX_FMFUNC in SDM. -**/ -#define MSR_SILVERMONT_IA32_VMX_FMFUNC 0x00000491 - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI CStates. CORE C1 - Residency Counter. (R/O) Value since last reset that this core is in - processor-specific C1 states. Counts at the TSC frequency. - - @param ECX MSR_SILVERMONT_CORE_C1_RESIDENCY (0x00000660) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_CORE_C1_RESIDENCY); - AsmWriteMsr64 (MSR_SILVERMONT_CORE_C1_RESIDENCY, Msr); - @endcode - @note MSR_SILVERMONT_CORE_C1_RESIDENCY is defined as MSR_CORE_C1_RESIDENCY in SDM. -**/ -#define MSR_SILVERMONT_CORE_C1_RESIDENCY 0x00000660 - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O) See Section 14.9.1, - "RAPL Interfaces.". - - @param ECX MSR_SILVERMONT_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_RAPL_POWER_UNIT); - @endcode - @note MSR_SILVERMONT_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_SILVERMONT_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Power Units. Power related information (in milliWatts) is - /// based on the multiplier, 2^PU; where PU is an unsigned integer - /// represented by bits 3:0. Default value is 0101b, indicating power unit - /// is in 32 milliWatts increment. - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Energy Status Units. Energy related information (in - /// microJoules) is based on the multiplier, 2^ESU; where ESU is an - /// unsigned integer represented by bits 12:8. Default value is 00101b, - /// indicating energy unit is in 32 microJoules increment. - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Time Unit. The value is 0000b, indicating time unit is in - /// one second. - /// - UINT32 TimeUnits:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. PKG RAPL Power Limit Control (R/W). - - @param ECX MSR_SILVERMONT_PKG_POWER_LIMIT (0x00000610) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_POWER_LIMIT); - AsmWriteMsr64 (MSR_SILVERMONT_PKG_POWER_LIMIT, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. -**/ -#define MSR_SILVERMONT_PKG_POWER_LIMIT 0x00000610 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PKG_POWER_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Package Power Limit #1. (R/W) See Section 14.9.3, "Package - /// RAPL Domain." and MSR_RAPL_POWER_UNIT in Table 35-8. - /// - UINT32 Limit:15; - /// - /// [Bit 15] Enable Power Limit #1. (R/W) See Section 14.9.3, "Package - /// RAPL Domain.". - /// - UINT32 Enable:1; - /// - /// [Bit 16] Package Clamping Limitation #1. (R/W) See Section 14.9.3, - /// "Package RAPL Domain.". - /// - UINT32 ClampingLimit:1; - /// - /// [Bits 23:17] Time Window for Power Limit #1. (R/W) in unit of second. - /// If 0 is specified in bits [23:17], defaults to 1 second window. - /// - UINT32 Time:7; - UINT32 Reserved1:8; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PKG_POWER_LIMIT_REGISTER; - - -/** - Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain." - and MSR_RAPL_POWER_UNIT in Table 35-8. - - @param ECX MSR_SILVERMONT_PKG_ENERGY_STATUS (0x00000611) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_PKG_ENERGY_STATUS); - @endcode - @note MSR_SILVERMONT_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. -**/ -#define MSR_SILVERMONT_PKG_ENERGY_STATUS 0x00000611 - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains." and MSR_RAPL_POWER_UNIT in Table 35-8. - - @param ECX MSR_SILVERMONT_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_PP0_ENERGY_STATUS); - @endcode - @note MSR_SILVERMONT_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_SILVERMONT_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. Core C6 demotion policy config MSR. Controls per-core C6 demotion - policy. Writing a value of 0 disables core level HW demotion policy. - - @param ECX MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG (0x00000668) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG); - AsmWriteMsr64 (MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG, Msr); - @endcode - @note MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG is defined as MSR_CC6_DEMOTION_POLICY_CONFIG in SDM. -**/ -#define MSR_SILVERMONT_CC6_DEMOTION_POLICY_CONFIG 0x00000668 - - -/** - Package. Module C6 demotion policy config MSR. Controls module (i.e. two - cores sharing the second-level cache) C6 demotion policy. Writing a value of - 0 disables module level HW demotion policy. - - @param ECX MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG (0x00000669) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG); - AsmWriteMsr64 (MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG, Msr); - @endcode - @note MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG is defined as MSR_MC6_DEMOTION_POLICY_CONFIG in SDM. -**/ -#define MSR_SILVERMONT_MC6_DEMOTION_POLICY_CONFIG 0x00000669 - - -/** - Module. Module C6 Residency Counter (R/0) Note: C-state values are processor - specific C-state code names, unrelated to MWAIT extension C-state parameters - or ACPI CStates. Time that this module is in module-specific C6 states since - last reset. Counts at 1 Mhz frequency. - - @param ECX MSR_SILVERMONT_MC6_RESIDENCY_COUNTER (0x00000664) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SILVERMONT_MC6_RESIDENCY_COUNTER); - @endcode - @note MSR_SILVERMONT_MC6_RESIDENCY_COUNTER is defined as MSR_MC6_RESIDENCY_COUNTER in SDM. -**/ -#define MSR_SILVERMONT_MC6_RESIDENCY_COUNTER 0x00000664 - - -/** - Package. PKG RAPL Parameter (R/0). - - @param ECX MSR_SILVERMONT_PKG_POWER_INFO (0x0000066E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_POWER_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PKG_POWER_INFO_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PKG_POWER_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PKG_POWER_INFO); - @endcode - @note MSR_SILVERMONT_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. -**/ -#define MSR_SILVERMONT_PKG_POWER_INFO 0x0000066E - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PKG_POWER_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Thermal Spec Power. (R/0) The unsigned integer value is - /// the equivalent of thermal specification power of the package domain. - /// The unit of this field is specified by the "Power Units" field of - /// MSR_RAPL_POWER_UNIT. - /// - UINT32 ThermalSpecPower:15; - UINT32 Reserved1:17; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PKG_POWER_INFO_REGISTER; - - -/** - Package. PP0 RAPL Power Limit Control (R/W). - - @param ECX MSR_SILVERMONT_PP0_POWER_LIMIT (0x00000638) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER. - - Example usage - @code - MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SILVERMONT_PP0_POWER_LIMIT); - AsmWriteMsr64 (MSR_SILVERMONT_PP0_POWER_LIMIT, Msr.Uint64); - @endcode - @note MSR_SILVERMONT_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. -**/ -#define MSR_SILVERMONT_PP0_POWER_LIMIT 0x00000638 - -/** - MSR information returned for MSR index #MSR_SILVERMONT_PP0_POWER_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] PP0 Power Limit #1. (R/W) See Section 14.9.4, "PP0/PP1 - /// RAPL Domains." and MSR_RAPL_POWER_UNIT in Table 35-8. - /// - UINT32 Limit:15; - /// - /// [Bit 15] Enable Power Limit #1. (R/W) See Section 14.9.4, "PP0/PP1 - /// RAPL Domains.". - /// - UINT32 Enable:1; - UINT32 Reserved1:1; - /// - /// [Bits 23:17] Time Window for Power Limit #1. (R/W) Specifies the time - /// duration over which the average power must remain below - /// PP0_POWER_LIMIT #1(14:0). Supported Encodings: 0x0: 1 second time - /// duration. 0x1: 5 second time duration (Default). 0x2: 10 second time - /// duration. 0x3: 15 second time duration. 0x4: 20 second time duration. - /// 0x5: 25 second time duration. 0x6: 30 second time duration. 0x7: 35 - /// second time duration. 0x8: 40 second time duration. 0x9: 45 second - /// time duration. 0xA: 50 second time duration. 0xB-0x7F - reserved. - /// - UINT32 Time:7; - UINT32 Reserved2:8; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SILVERMONT_PP0_POWER_LIMIT_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h b/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h deleted file mode 100644 index 7166e5f9e0..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/SkylakeMsr.h +++ /dev/null @@ -1,2257 +0,0 @@ -/** @file - MSR Definitions for Intel processors based on the Skylake microarchitecture. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.15. - -**/ - -#ifndef __SKYLAKE_MSR_H__ -#define __SKYLAKE_MSR_H__ - -#include - -/** - Is Intel processors based on the Skylake microarchitecture? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_SKYLAKE_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x4E || \ - DisplayModel == 0x5E \ - ) \ - ) - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_SKYLAKE_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_TURBO_RATIO_LIMIT); - @endcode - @note MSR_SKYLAKE_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_SKYLAKE_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_SKYLAKE_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Thread. Last Branch Record Stack TOS (R/W) Contains an index (bits 0-4) - that points to the MSR containing the most recent branch record. - - @param ECX MSR_SKYLAKE_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_SKYLAKE_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_SKYLAKE_LASTBRANCH_TOS 0x000001C9 - - -/** - Package. Lower 64 Bit OwnerEpoch Component of SGX Key (RO). Low 64 bits of - an 128-bit external entropy value for key derivation of an enclave. - - @param ECX MSR_SKYLAKE_SGXOWNER0 (0x00000300) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_SGXOWNER0); - @endcode - @note MSR_SKYLAKE_SGXOWNER0 is defined as MSR_SGXOWNER0 in SDM. -**/ -#define MSR_SKYLAKE_SGXOWNER0 0x00000300 - - -/** - Package. Upper 64 Bit OwnerEpoch Component of SGX Key (RO). Upper 64 bits of - an 128-bit external entropy value for key derivation of an enclave. - - @param ECX MSR_SKYLAKE_SGXOWNER1 (0x00000301) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_SGXOWNER1); - @endcode - @note MSR_SKYLAKE_SGXOWNER1 is defined as MSR_SGXOWNER1 in SDM. -**/ -#define MSR_SKYLAKE_SGXOWNER1 0x00000301 - - -/** - See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring - Version 4.". - - @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS (0x0000038E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS is defined as IA32_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS 0x0000038E - -/** - MSR information returned for MSR index #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Thread. Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Thread. Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Thread. Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - /// - /// [Bit 4] Thread. Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). - /// - UINT32 Ovf_PMC4:1; - /// - /// [Bit 5] Thread. Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). - /// - UINT32 Ovf_PMC5:1; - /// - /// [Bit 6] Thread. Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). - /// - UINT32 Ovf_PMC6:1; - /// - /// [Bit 7] Thread. Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). - /// - UINT32 Ovf_PMC7:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Thread. Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Thread. Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Thread. Trace_ToPA_PMI. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] Thread. LBR_Frz. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Thread. CTR_Frz. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Thread. ASCI. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Thread. Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Thread. Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - /// - /// [Bit 63] Thread. CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_REGISTER; - - -/** - See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring - Version 4.". - - @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET (0x00000390) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER. - - Example usage - @code - MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET); - AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET is defined as IA32_PERF_GLOBAL_STATUS_RESET in SDM. -**/ -#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET 0x00000390 - -/** - MSR information returned for MSR index - #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Set 1 to clear Ovf_PMC0. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Thread. Set 1 to clear Ovf_PMC1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Thread. Set 1 to clear Ovf_PMC2. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Thread. Set 1 to clear Ovf_PMC3. - /// - UINT32 Ovf_PMC3:1; - /// - /// [Bit 4] Thread. Set 1 to clear Ovf_PMC4 (if CPUID.0AH:EAX[15:8] > 4). - /// - UINT32 Ovf_PMC4:1; - /// - /// [Bit 5] Thread. Set 1 to clear Ovf_PMC5 (if CPUID.0AH:EAX[15:8] > 5). - /// - UINT32 Ovf_PMC5:1; - /// - /// [Bit 6] Thread. Set 1 to clear Ovf_PMC6 (if CPUID.0AH:EAX[15:8] > 6). - /// - UINT32 Ovf_PMC6:1; - /// - /// [Bit 7] Thread. Set 1 to clear Ovf_PMC7 (if CPUID.0AH:EAX[15:8] > 7). - /// - UINT32 Ovf_PMC7:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Set 1 to clear Ovf_FixedCtr0. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Thread. Set 1 to clear Ovf_FixedCtr1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Thread. Set 1 to clear Ovf_FixedCtr2. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Thread. Set 1 to clear Trace_ToPA_PMI. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] Thread. Set 1 to clear LBR_Frz. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Thread. Set 1 to clear CTR_Frz. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Thread. Set 1 to clear ASCI. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Thread. Set 1 to clear Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Thread. Set 1 to clear Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - /// - /// [Bit 63] Thread. Set 1 to clear CondChgd. - /// - UINT32 CondChgd:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_RESET_REGISTER; - - -/** - See Table 35-2. See Section 18.2.4, "Architectural Performance Monitoring - Version 4.". - - @param ECX MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET (0x00000391) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER. - - Example usage - @code - MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET); - AsmWriteMsr64 (MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET is defined as IA32_PERF_GLOBAL_STATUS_SET in SDM. -**/ -#define MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET 0x00000391 - -/** - MSR information returned for MSR index - #MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Thread. Set 1 to cause Ovf_PMC0 = 1. - /// - UINT32 Ovf_PMC0:1; - /// - /// [Bit 1] Thread. Set 1 to cause Ovf_PMC1 = 1. - /// - UINT32 Ovf_PMC1:1; - /// - /// [Bit 2] Thread. Set 1 to cause Ovf_PMC2 = 1. - /// - UINT32 Ovf_PMC2:1; - /// - /// [Bit 3] Thread. Set 1 to cause Ovf_PMC3 = 1. - /// - UINT32 Ovf_PMC3:1; - /// - /// [Bit 4] Thread. Set 1 to cause Ovf_PMC4=1 (if CPUID.0AH:EAX[15:8] > 4). - /// - UINT32 Ovf_PMC4:1; - /// - /// [Bit 5] Thread. Set 1 to cause Ovf_PMC5=1 (if CPUID.0AH:EAX[15:8] > 5). - /// - UINT32 Ovf_PMC5:1; - /// - /// [Bit 6] Thread. Set 1 to cause Ovf_PMC6=1 (if CPUID.0AH:EAX[15:8] > 6). - /// - UINT32 Ovf_PMC6:1; - /// - /// [Bit 7] Thread. Set 1 to cause Ovf_PMC7=1 (if CPUID.0AH:EAX[15:8] > 7). - /// - UINT32 Ovf_PMC7:1; - UINT32 Reserved1:24; - /// - /// [Bit 32] Thread. Set 1 to cause Ovf_FixedCtr0 = 1. - /// - UINT32 Ovf_FixedCtr0:1; - /// - /// [Bit 33] Thread. Set 1 to cause Ovf_FixedCtr1 = 1. - /// - UINT32 Ovf_FixedCtr1:1; - /// - /// [Bit 34] Thread. Set 1 to cause Ovf_FixedCtr2 = 1. - /// - UINT32 Ovf_FixedCtr2:1; - UINT32 Reserved2:20; - /// - /// [Bit 55] Thread. Set 1 to cause Trace_ToPA_PMI = 1. - /// - UINT32 Trace_ToPA_PMI:1; - UINT32 Reserved3:2; - /// - /// [Bit 58] Thread. Set 1 to cause LBR_Frz = 1. - /// - UINT32 LBR_Frz:1; - /// - /// [Bit 59] Thread. Set 1 to cause CTR_Frz = 1. - /// - UINT32 CTR_Frz:1; - /// - /// [Bit 60] Thread. Set 1 to cause ASCI = 1. - /// - UINT32 ASCI:1; - /// - /// [Bit 61] Thread. Set 1 to cause Ovf_Uncore. - /// - UINT32 Ovf_Uncore:1; - /// - /// [Bit 62] Thread. Set 1 to cause Ovf_BufDSSAVE. - /// - UINT32 Ovf_BufDSSAVE:1; - UINT32 Reserved4:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_IA32_PERF_GLOBAL_STATUS_SET_REGISTER; - - -/** - Thread. FrontEnd Precise Event Condition Select (R/W). - - @param ECX MSR_SKYLAKE_PEBS_FRONTEND (0x000003F7) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PEBS_FRONTEND_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PEBS_FRONTEND_REGISTER. - - Example usage - @code - MSR_SKYLAKE_PEBS_FRONTEND_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PEBS_FRONTEND); - AsmWriteMsr64 (MSR_SKYLAKE_PEBS_FRONTEND, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_PEBS_FRONTEND is defined as MSR_PEBS_FRONTEND in SDM. -**/ -#define MSR_SKYLAKE_PEBS_FRONTEND 0x000003F7 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_PEBS_FRONTEND -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Event Code Select. - /// - UINT32 EventCodeSelect:3; - UINT32 Reserved1:1; - /// - /// [Bit 4] Event Code Select High. - /// - UINT32 EventCodeSelectHigh:1; - UINT32 Reserved2:3; - /// - /// [Bits 19:8] IDQ_Bubble_Length Specifier. - /// - UINT32 IDQ_Bubble_Length:12; - /// - /// [Bits 22:20] IDQ_Bubble_Width Specifier. - /// - UINT32 IDQ_Bubble_Width:3; - UINT32 Reserved3:9; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_PEBS_FRONTEND_REGISTER; - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_SKYLAKE_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_PP0_ENERGY_STATUS); - @endcode - @note MSR_SKYLAKE_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_SKYLAKE_PP0_ENERGY_STATUS 0x00000639 - - -/** - Platform*. Platform Energy Counter. (R/O). This MSR is valid only if both - platform vendor hardware implementation and BIOS enablement support it. This - MSR will read 0 if not valid. - - @param ECX MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER (0x0000064D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER. - - Example usage - @code - MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER); - @endcode - @note MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER is defined as MSR_PLATFORM_ENERGY_COUNTER in SDM. -**/ -#define MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER 0x0000064D - -/** - MSR information returned for MSR index #MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Total energy consumed by all devices in the platform that - /// receive power from integrated power delivery mechanism, Included - /// platform devices are processor cores, SOC, memory, add-on or - /// peripheral devices that get powered directly from the platform power - /// delivery means. The energy units are specified in the - /// MSR_RAPL_POWER_UNIT.Enery_Status_Unit. - /// - UINT32 TotalEnergy:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_PLATFORM_ENERGY_COUNTER_REGISTER; - - -/** - Thread. Productive Performance Count. (R/O). Hardware's view of workload - scalability. See Section 14.4.5.1. - - @param ECX MSR_SKYLAKE_PPERF (0x0000064E) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_PPERF); - @endcode - @note MSR_SKYLAKE_PPERF is defined as MSR_PPERF in SDM. -**/ -#define MSR_SKYLAKE_PPERF 0x0000064E - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS (0x0000064F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS 0x0000064F - -/** - MSR information returned for MSR index #MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced below the - /// operating system request due to assertion of external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:2; - /// - /// [Bit 4] Residency State Regulation Status (R0) When set, frequency is - /// reduced below the operating system request due to residency state - /// regulation limit. - /// - UINT32 ResidencyStateRegulationStatus:1; - /// - /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency - /// is reduced below the operating system request due to Running Average - /// Thermal Limit (RATL). - /// - UINT32 RunningAverageThermalLimitStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from a - /// processor Voltage Regulator (VR). - /// - UINT32 VRThermAlertStatus:1; - /// - /// [Bit 7] VR Therm Design Current Status (R0) When set, frequency is - /// reduced below the operating system request due to VR thermal design - /// current limit. - /// - UINT32 VRThermDesignCurrentStatus:1; - /// - /// [Bit 8] Other Status (R0) When set, frequency is reduced below the - /// operating system request due to electrical or other constraints. - /// - UINT32 OtherStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When - /// set, frequency is reduced below the operating system request due to - /// package/platform-level power limiting PL1. - /// - UINT32 PL1Status:1; - /// - /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When - /// set, frequency is reduced below the operating system request due to - /// package/platform-level power limiting PL2/PL3. - /// - UINT32 PL2Status:1; - /// - /// [Bit 12] Max Turbo Limit Status (R0) When set, frequency is reduced - /// below the operating system request due to multi-core turbo limits. - /// - UINT32 MaxTurboLimitStatus:1; - /// - /// [Bit 13] Turbo Transition Attenuation Status (R0) When set, frequency - /// is reduced below the operating system request due to Turbo transition - /// attenuation. This prevents performance degradation due to frequent - /// operating ratio changes. - /// - UINT32 TurboTransitionAttenuationStatus:1; - UINT32 Reserved3:2; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved4:2; - /// - /// [Bit 20] Residency State Regulation Log When set, indicates that the - /// Residency State Regulation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 ResidencyStateRegulationLog:1; - /// - /// [Bit 21] Running Average Thermal Limit Log When set, indicates that - /// the RATL Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 RunningAverageThermalLimitLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - /// - /// [Bit 23] VR Thermal Design Current Log When set, indicates that the - /// VR TDC Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermalDesignCurrentLog:1; - /// - /// [Bit 24] Other Log When set, indicates that the Other Status bit has - /// asserted since the log bit was last cleared. This log bit will remain - /// set until cleared by software writing 0. - /// - UINT32 OtherLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, - /// indicates that the Package or Platform Level PL1 Power Limiting Status - /// bit has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, - /// indicates that the Package or Platform Level PL2/PL3 Power Limiting - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 PL2Log:1; - /// - /// [Bit 28] Max Turbo Limit Log When set, indicates that the Max Turbo - /// Limit Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MaxTurboLimitLog:1; - /// - /// [Bit 29] Turbo Transition Attenuation Log When set, indicates that the - /// Turbo Transition Attenuation Status bit has asserted since the log bit - /// was last cleared. This log bit will remain set until cleared by - /// software writing 0. - /// - UINT32 TurboTransitionAttenuationLog:1; - UINT32 Reserved6:2; - UINT32 Reserved7:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_CORE_PERF_LIMIT_REASONS_REGISTER; - - -/** - Package. HDC Configuration (R/W).. - - @param ECX MSR_SKYLAKE_PKG_HDC_CONFIG (0x00000652) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER. - - Example usage - @code - MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_CONFIG); - AsmWriteMsr64 (MSR_SKYLAKE_PKG_HDC_CONFIG, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_PKG_HDC_CONFIG is defined as MSR_PKG_HDC_CONFIG in SDM. -**/ -#define MSR_SKYLAKE_PKG_HDC_CONFIG 0x00000652 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_PKG_HDC_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] PKG_Cx_Monitor. Configures Package Cx state threshold for - /// MSR_PKG_HDC_DEEP_RESIDENCY. - /// - UINT32 PKG_Cx_Monitor:3; - UINT32 Reserved1:29; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_PKG_HDC_CONFIG_REGISTER; - - -/** - Core. Core HDC Idle Residency. (R/O). Core_Cx_Duty_Cycle_Cnt. - - @param ECX MSR_SKYLAKE_CORE_HDC_RESIDENCY (0x00000653) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_CORE_HDC_RESIDENCY); - @endcode - @note MSR_SKYLAKE_CORE_HDC_RESIDENCY is defined as MSR_CORE_HDC_RESIDENCY in SDM. -**/ -#define MSR_SKYLAKE_CORE_HDC_RESIDENCY 0x00000653 - - -/** - Package. Accumulate the cycles the package was in C2 state and at least one - logical processor was in forced idle. (R/O). Pkg_C2_Duty_Cycle_Cnt. - - @param ECX MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY (0x00000655) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY); - @endcode - @note MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY is defined as MSR_PKG_HDC_SHALLOW_RESIDENCY in SDM. -**/ -#define MSR_SKYLAKE_PKG_HDC_SHALLOW_RESIDENCY 0x00000655 - - -/** - Package. Package Cx HDC Idle Residency. (R/O). Pkg_Cx_Duty_Cycle_Cnt. - - @param ECX MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY (0x00000656) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY); - @endcode - @note MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY is defined as MSR_PKG_HDC_DEEP_RESIDENCY in SDM. -**/ -#define MSR_SKYLAKE_PKG_HDC_DEEP_RESIDENCY 0x00000656 - - -/** - Package. Core-count Weighted C0 Residency. (R/O). Increment at the same rate - as the TSC. The increment each cycle is weighted by the number of processor - cores in the package that reside in C0. If N cores are simultaneously in C0, - then each cycle the counter increments by N. - - @param ECX MSR_SKYLAKE_WEIGHTED_CORE_C0 (0x00000658) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_WEIGHTED_CORE_C0); - @endcode - @note MSR_SKYLAKE_WEIGHTED_CORE_C0 is defined as MSR_WEIGHTED_CORE_C0 in SDM. -**/ -#define MSR_SKYLAKE_WEIGHTED_CORE_C0 0x00000658 - - -/** - Package. Any Core C0 Residency. (R/O). Increment at the same rate as the - TSC. The increment each cycle is one if any processor core in the package is - in C0. - - @param ECX MSR_SKYLAKE_ANY_CORE_C0 (0x00000659) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_ANY_CORE_C0); - @endcode - @note MSR_SKYLAKE_ANY_CORE_C0 is defined as MSR_ANY_CORE_C0 in SDM. -**/ -#define MSR_SKYLAKE_ANY_CORE_C0 0x00000659 - - -/** - Package. Any Graphics Engine C0 Residency. (R/O). Increment at the same rate - as the TSC. The increment each cycle is one if any processor graphic - device's compute engines are in C0. - - @param ECX MSR_SKYLAKE_ANY_GFXE_C0 (0x0000065A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_ANY_GFXE_C0); - @endcode - @note MSR_SKYLAKE_ANY_GFXE_C0 is defined as MSR_ANY_GFXE_C0 in SDM. -**/ -#define MSR_SKYLAKE_ANY_GFXE_C0 0x0000065A - - -/** - Package. Core and Graphics Engine Overlapped C0 Residency. (R/O). Increment - at the same rate as the TSC. The increment each cycle is one if at least one - compute engine of the processor graphics is in C0 and at least one processor - core in the package is also in C0. - - @param ECX MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 (0x0000065B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0); - @endcode - @note MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 is defined as MSR_CORE_GFXE_OVERLAP_C0 in SDM. -**/ -#define MSR_SKYLAKE_CORE_GFXE_OVERLAP_C0 0x0000065B - - -/** - Platform*. Platform Power Limit Control (R/W-L) Allows platform BIOS to - limit power consumption of the platform devices to the specified values. The - Long Duration power consumption is specified via Platform_Power_Limit_1 and - Platform_Power_Limit_1_Time. The Short Duration power consumption limit is - specified via the Platform_Power_Limit_2 with duration chosen by the - processor. The processor implements an exponential-weighted algorithm in the - placement of the time windows. - - @param ECX MSR_SKYLAKE_PLATFORM_POWER_LIMIT (0x0000065C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER. - - Example usage - @code - MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_PLATFORM_POWER_LIMIT); - AsmWriteMsr64 (MSR_SKYLAKE_PLATFORM_POWER_LIMIT, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_PLATFORM_POWER_LIMIT is defined as MSR_PLATFORM_POWER_LIMIT in SDM. -**/ -#define MSR_SKYLAKE_PLATFORM_POWER_LIMIT 0x0000065C - -/** - MSR information returned for MSR index #MSR_SKYLAKE_PLATFORM_POWER_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 14:0] Platform Power Limit #1. Average Power limit value which - /// the platform must not exceed over a time window as specified by - /// Power_Limit_1_TIME field. The default value is the Thermal Design - /// Power (TDP) and varies with product skus. The unit is specified in - /// MSR_RAPLPOWER_UNIT. - /// - UINT32 PlatformPowerLimit1:15; - /// - /// [Bit 15] Enable Platform Power Limit #1. When set, enables the - /// processor to apply control policy such that the platform power does - /// not exceed Platform Power limit #1 over the time window specified by - /// Power Limit #1 Time Window. - /// - UINT32 EnablePlatformPowerLimit1:1; - /// - /// [Bit 16] Platform Clamping Limitation #1. When set, allows the - /// processor to go below the OS requested P states in order to maintain - /// the power below specified Platform Power Limit #1 value. This bit is - /// writeable only when CPUID (EAX=6):EAX[4] is set. - /// - UINT32 PlatformClampingLimitation1:1; - /// - /// [Bits 23:17] Time Window for Platform Power Limit #1. Specifies the - /// duration of the time window over which Platform Power Limit 1 value - /// should be maintained for sustained long duration. This field is made - /// up of two numbers from the following equation: Time Window = (float) - /// ((1+(X/4))*(2^Y)), where: X. = POWER_LIMIT_1_TIME[23:22] Y. = - /// POWER_LIMIT_1_TIME[21:17]. The maximum allowed value in this field is - /// defined in MSR_PKG_POWER_INFO[PKG_MAX_WIN]. The default value is 0DH, - /// The unit is specified in MSR_RAPLPOWER_UNIT[Time Unit]. - /// - UINT32 Time:7; - UINT32 Reserved1:8; - /// - /// [Bits 46:32] Platform Power Limit #2. Average Power limit value which - /// the platform must not exceed over the Short Duration time window - /// chosen by the processor. The recommended default value is 1.25 times - /// the Long Duration Power Limit (i.e. Platform Power Limit # 1). - /// - UINT32 PlatformPowerLimit2:15; - /// - /// [Bit 47] Enable Platform Power Limit #2. When set, enables the - /// processor to apply control policy such that the platform power does - /// not exceed Platform Power limit #2 over the Short Duration time window. - /// - UINT32 EnablePlatformPowerLimit2:1; - /// - /// [Bit 48] Platform Clamping Limitation #2. When set, allows the - /// processor to go below the OS requested P states in order to maintain - /// the power below specified Platform Power Limit #2 value. - /// - UINT32 PlatformClampingLimitation2:1; - UINT32 Reserved2:14; - /// - /// [Bit 63] Lock. Setting this bit will lock all other bits of this MSR - /// until system RESET. - /// - UINT32 Lock:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_PLATFORM_POWER_LIMIT_REGISTER; - - -/** - Thread. Last Branch Record n From IP (R/W) One of 32 triplets of last - branch record registers on the last branch record stack. This part of the - stack contains pointers to the source instruction. See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.10. - - @param ECX MSR_SKYLAKE_LASTBRANCH_n_FROM_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_16_FROM_IP); - AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_16_FROM_IP, Msr); - @endcode - @note MSR_SKYLAKE_LASTBRANCH_16_FROM_IP is defined as MSR_LASTBRANCH_16_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_17_FROM_IP is defined as MSR_LASTBRANCH_17_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_18_FROM_IP is defined as MSR_LASTBRANCH_18_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_19_FROM_IP is defined as MSR_LASTBRANCH_19_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_20_FROM_IP is defined as MSR_LASTBRANCH_20_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_21_FROM_IP is defined as MSR_LASTBRANCH_21_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_22_FROM_IP is defined as MSR_LASTBRANCH_22_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_23_FROM_IP is defined as MSR_LASTBRANCH_23_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_24_FROM_IP is defined as MSR_LASTBRANCH_24_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_25_FROM_IP is defined as MSR_LASTBRANCH_25_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_26_FROM_IP is defined as MSR_LASTBRANCH_26_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_27_FROM_IP is defined as MSR_LASTBRANCH_27_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_28_FROM_IP is defined as MSR_LASTBRANCH_28_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_29_FROM_IP is defined as MSR_LASTBRANCH_29_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_30_FROM_IP is defined as MSR_LASTBRANCH_30_FROM_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_31_FROM_IP is defined as MSR_LASTBRANCH_31_FROM_IP in SDM. - @{ -**/ -#define MSR_SKYLAKE_LASTBRANCH_16_FROM_IP 0x00000690 -#define MSR_SKYLAKE_LASTBRANCH_17_FROM_IP 0x00000691 -#define MSR_SKYLAKE_LASTBRANCH_18_FROM_IP 0x00000692 -#define MSR_SKYLAKE_LASTBRANCH_19_FROM_IP 0x00000693 -#define MSR_SKYLAKE_LASTBRANCH_20_FROM_IP 0x00000694 -#define MSR_SKYLAKE_LASTBRANCH_21_FROM_IP 0x00000695 -#define MSR_SKYLAKE_LASTBRANCH_22_FROM_IP 0x00000696 -#define MSR_SKYLAKE_LASTBRANCH_23_FROM_IP 0x00000697 -#define MSR_SKYLAKE_LASTBRANCH_24_FROM_IP 0x00000698 -#define MSR_SKYLAKE_LASTBRANCH_25_FROM_IP 0x00000699 -#define MSR_SKYLAKE_LASTBRANCH_26_FROM_IP 0x0000069A -#define MSR_SKYLAKE_LASTBRANCH_27_FROM_IP 0x0000069B -#define MSR_SKYLAKE_LASTBRANCH_28_FROM_IP 0x0000069C -#define MSR_SKYLAKE_LASTBRANCH_29_FROM_IP 0x0000069D -#define MSR_SKYLAKE_LASTBRANCH_30_FROM_IP 0x0000069E -#define MSR_SKYLAKE_LASTBRANCH_31_FROM_IP 0x0000069F -/// @} - - -/** - Package. Indicator of Frequency Clipping in the Processor Graphics (R/W) - (frequency refers to processor graphics frequency). - - @param ECX MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS (0x000006B0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS is defined as MSR_GRAPHICS_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS 0x000006B0 - -/** - MSR information returned for MSR index - #MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced due to - /// assertion of external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced due to a - /// thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:3; - /// - /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency - /// is reduced due to running average thermal limit. - /// - UINT32 RunningAverageThermalLimitStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced due - /// to a thermal alert from a processor Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - /// - /// [Bit 7] VR Thermal Design Current Status (R0) When set, frequency is - /// reduced due to VR TDC limit. - /// - UINT32 VRThermalDesignCurrentStatus:1; - /// - /// [Bit 8] Other Status (R0) When set, frequency is reduced due to - /// electrical or other constraints. - /// - UINT32 OtherStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When - /// set, frequency is reduced due to package/platform-level power limiting - /// PL1. - /// - UINT32 PL1Status:1; - /// - /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When - /// set, frequency is reduced due to package/platform-level power limiting - /// PL2/PL3. - /// - UINT32 PL2Status:1; - /// - /// [Bit 12] Inefficient Operation Status (R0) When set, processor - /// graphics frequency is operating below target frequency. - /// - UINT32 InefficientOperationStatus:1; - UINT32 Reserved3:3; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved4:3; - /// - /// [Bit 21] Running Average Thermal Limit Log When set, indicates that - /// the RATL Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 RunningAverageThermalLimitLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - /// - /// [Bit 23] VR Thermal Design Current Log When set, indicates that the - /// VR Therm Alert Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 VRThermalDesignCurrentLog:1; - /// - /// [Bit 24] Other Log When set, indicates that the OTHER Status bit has - /// asserted since the log bit was last cleared. This log bit will remain - /// set until cleared by software writing 0. - /// - UINT32 OtherLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, - /// indicates that the Package/Platform Level PL1 Power Limiting Status - /// bit has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, - /// indicates that the Package/Platform Level PL2 Power Limiting Status - /// bit has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PL2Log:1; - /// - /// [Bit 28] Inefficient Operation Log When set, indicates that the - /// Inefficient Operation Status bit has asserted since the log bit was - /// last cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 InefficientOperationLog:1; - UINT32 Reserved6:3; - UINT32 Reserved7:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_GRAPHICS_PERF_LIMIT_REASONS_REGISTER; - - -/** - Package. Indicator of Frequency Clipping in the Ring Interconnect (R/W) - (frequency refers to ring interconnect in the uncore). - - @param ECX MSR_SKYLAKE_RING_PERF_LIMIT_REASONS (0x000006B1) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_RING_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_SKYLAKE_RING_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_RING_PERF_LIMIT_REASONS is defined as MSR_RING_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_SKYLAKE_RING_PERF_LIMIT_REASONS 0x000006B1 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_RING_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, frequency is reduced due to - /// assertion of external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced due to a - /// thermal event. - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:3; - /// - /// [Bit 5] Running Average Thermal Limit Status (R0) When set, frequency - /// is reduced due to running average thermal limit. - /// - UINT32 RunningAverageThermalLimitStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced due - /// to a thermal alert from a processor Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - /// - /// [Bit 7] VR Thermal Design Current Status (R0) When set, frequency is - /// reduced due to VR TDC limit. - /// - UINT32 VRThermalDesignCurrentStatus:1; - /// - /// [Bit 8] Other Status (R0) When set, frequency is reduced due to - /// electrical or other constraints. - /// - UINT32 OtherStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 10] Package/Platform-Level Power Limiting PL1 Status (R0) When - /// set, frequency is reduced due to package/Platform-level power limiting - /// PL1. - /// - UINT32 PL1Status:1; - /// - /// [Bit 11] Package/Platform-Level PL2 Power Limiting Status (R0) When - /// set, frequency is reduced due to package/Platform-level power limiting - /// PL2/PL3. - /// - UINT32 PL2Status:1; - UINT32 Reserved3:4; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - UINT32 Reserved4:3; - /// - /// [Bit 21] Running Average Thermal Limit Log When set, indicates that - /// the RATL Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 RunningAverageThermalLimitLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - /// - /// [Bit 23] VR Thermal Design Current Log When set, indicates that the - /// VR Therm Alert Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 VRThermalDesignCurrentLog:1; - /// - /// [Bit 24] Other Log When set, indicates that the OTHER Status bit has - /// asserted since the log bit was last cleared. This log bit will remain - /// set until cleared by software writing 0. - /// - UINT32 OtherLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 26] Package/Platform-Level PL1 Power Limiting Log When set, - /// indicates that the Package/Platform Level PL1 Power Limiting Status - /// bit has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PL1Log:1; - /// - /// [Bit 27] Package/Platform-Level PL2 Power Limiting Log When set, - /// indicates that the Package/Platform Level PL2 Power Limiting Status - /// bit has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PL2Log:1; - UINT32 Reserved6:4; - UINT32 Reserved7:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_RING_PERF_LIMIT_REASONS_REGISTER; - - -/** - Thread. Last Branch Record n To IP (R/W) One of 32 triplets of last branch - record registers on the last branch record stack. This part of the stack - contains pointers to the destination instruction. See also: - Last Branch - Record Stack TOS at 1C9H - Section 17.10. - - @param ECX MSR_SKYLAKE_LASTBRANCH_n_TO_IP - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_LASTBRANCH_16_TO_IP); - AsmWriteMsr64 (MSR_SKYLAKE_LASTBRANCH_16_TO_IP, Msr); - @endcode - @note MSR_SKYLAKE_LASTBRANCH_16_TO_IP is defined as MSR_LASTBRANCH_16_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_17_TO_IP is defined as MSR_LASTBRANCH_17_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_18_TO_IP is defined as MSR_LASTBRANCH_18_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_19_TO_IP is defined as MSR_LASTBRANCH_19_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_20_TO_IP is defined as MSR_LASTBRANCH_20_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_21_TO_IP is defined as MSR_LASTBRANCH_21_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_22_TO_IP is defined as MSR_LASTBRANCH_22_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_23_TO_IP is defined as MSR_LASTBRANCH_23_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_24_TO_IP is defined as MSR_LASTBRANCH_24_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_25_TO_IP is defined as MSR_LASTBRANCH_25_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_26_TO_IP is defined as MSR_LASTBRANCH_26_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_27_TO_IP is defined as MSR_LASTBRANCH_27_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_28_TO_IP is defined as MSR_LASTBRANCH_28_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_29_TO_IP is defined as MSR_LASTBRANCH_29_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_30_TO_IP is defined as MSR_LASTBRANCH_30_TO_IP in SDM. - MSR_SKYLAKE_LASTBRANCH_31_TO_IP is defined as MSR_LASTBRANCH_31_TO_IP in SDM. - @{ -**/ -#define MSR_SKYLAKE_LASTBRANCH_16_TO_IP 0x000006D0 -#define MSR_SKYLAKE_LASTBRANCH_17_TO_IP 0x000006D1 -#define MSR_SKYLAKE_LASTBRANCH_18_TO_IP 0x000006D2 -#define MSR_SKYLAKE_LASTBRANCH_19_TO_IP 0x000006D3 -#define MSR_SKYLAKE_LASTBRANCH_20_TO_IP 0x000006D4 -#define MSR_SKYLAKE_LASTBRANCH_21_TO_IP 0x000006D5 -#define MSR_SKYLAKE_LASTBRANCH_22_TO_IP 0x000006D6 -#define MSR_SKYLAKE_LASTBRANCH_23_TO_IP 0x000006D7 -#define MSR_SKYLAKE_LASTBRANCH_24_TO_IP 0x000006D8 -#define MSR_SKYLAKE_LASTBRANCH_25_TO_IP 0x000006D9 -#define MSR_SKYLAKE_LASTBRANCH_26_TO_IP 0x000006DA -#define MSR_SKYLAKE_LASTBRANCH_27_TO_IP 0x000006DB -#define MSR_SKYLAKE_LASTBRANCH_28_TO_IP 0x000006DC -#define MSR_SKYLAKE_LASTBRANCH_29_TO_IP 0x000006DD -#define MSR_SKYLAKE_LASTBRANCH_30_TO_IP 0x000006DE -#define MSR_SKYLAKE_LASTBRANCH_31_TO_IP 0x000006DF -/// @} - - -/** - Thread. Last Branch Record n Additional Information (R/W) One of 32 triplet - of last branch record registers on the last branch record stack. This part - of the stack contains flag, TSX-related and elapsed cycle information. See - also: - Last Branch Record Stack TOS at 1C9H - Section 17.7.1, "LBR - Stack.". - - @param ECX MSR_SKYLAKE_LBR_INFO_n - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_LBR_INFO_0); - AsmWriteMsr64 (MSR_SKYLAKE_LBR_INFO_0, Msr); - @endcode - @note MSR_SKYLAKE_LBR_INFO_0 is defined as MSR_LBR_INFO_0 in SDM. - MSR_SKYLAKE_LBR_INFO_1 is defined as MSR_LBR_INFO_1 in SDM. - MSR_SKYLAKE_LBR_INFO_2 is defined as MSR_LBR_INFO_2 in SDM. - MSR_SKYLAKE_LBR_INFO_3 is defined as MSR_LBR_INFO_3 in SDM. - MSR_SKYLAKE_LBR_INFO_4 is defined as MSR_LBR_INFO_4 in SDM. - MSR_SKYLAKE_LBR_INFO_5 is defined as MSR_LBR_INFO_5 in SDM. - MSR_SKYLAKE_LBR_INFO_6 is defined as MSR_LBR_INFO_6 in SDM. - MSR_SKYLAKE_LBR_INFO_7 is defined as MSR_LBR_INFO_7 in SDM. - MSR_SKYLAKE_LBR_INFO_8 is defined as MSR_LBR_INFO_8 in SDM. - MSR_SKYLAKE_LBR_INFO_9 is defined as MSR_LBR_INFO_9 in SDM. - MSR_SKYLAKE_LBR_INFO_10 is defined as MSR_LBR_INFO_10 in SDM. - MSR_SKYLAKE_LBR_INFO_11 is defined as MSR_LBR_INFO_11 in SDM. - MSR_SKYLAKE_LBR_INFO_12 is defined as MSR_LBR_INFO_12 in SDM. - MSR_SKYLAKE_LBR_INFO_13 is defined as MSR_LBR_INFO_13 in SDM. - MSR_SKYLAKE_LBR_INFO_14 is defined as MSR_LBR_INFO_14 in SDM. - MSR_SKYLAKE_LBR_INFO_15 is defined as MSR_LBR_INFO_15 in SDM. - MSR_SKYLAKE_LBR_INFO_16 is defined as MSR_LBR_INFO_16 in SDM. - MSR_SKYLAKE_LBR_INFO_17 is defined as MSR_LBR_INFO_17 in SDM. - MSR_SKYLAKE_LBR_INFO_18 is defined as MSR_LBR_INFO_18 in SDM. - MSR_SKYLAKE_LBR_INFO_19 is defined as MSR_LBR_INFO_19 in SDM. - MSR_SKYLAKE_LBR_INFO_20 is defined as MSR_LBR_INFO_20 in SDM. - MSR_SKYLAKE_LBR_INFO_21 is defined as MSR_LBR_INFO_21 in SDM. - MSR_SKYLAKE_LBR_INFO_22 is defined as MSR_LBR_INFO_22 in SDM. - MSR_SKYLAKE_LBR_INFO_23 is defined as MSR_LBR_INFO_23 in SDM. - MSR_SKYLAKE_LBR_INFO_24 is defined as MSR_LBR_INFO_24 in SDM. - MSR_SKYLAKE_LBR_INFO_25 is defined as MSR_LBR_INFO_25 in SDM. - MSR_SKYLAKE_LBR_INFO_26 is defined as MSR_LBR_INFO_26 in SDM. - MSR_SKYLAKE_LBR_INFO_27 is defined as MSR_LBR_INFO_27 in SDM. - MSR_SKYLAKE_LBR_INFO_28 is defined as MSR_LBR_INFO_28 in SDM. - MSR_SKYLAKE_LBR_INFO_29 is defined as MSR_LBR_INFO_29 in SDM. - MSR_SKYLAKE_LBR_INFO_30 is defined as MSR_LBR_INFO_30 in SDM. - MSR_SKYLAKE_LBR_INFO_31 is defined as MSR_LBR_INFO_31 in SDM. - @{ -**/ -#define MSR_SKYLAKE_LBR_INFO_0 0x00000DC0 -#define MSR_SKYLAKE_LBR_INFO_1 0x00000DC1 -#define MSR_SKYLAKE_LBR_INFO_2 0x00000DC2 -#define MSR_SKYLAKE_LBR_INFO_3 0x00000DC3 -#define MSR_SKYLAKE_LBR_INFO_4 0x00000DC4 -#define MSR_SKYLAKE_LBR_INFO_5 0x00000DC5 -#define MSR_SKYLAKE_LBR_INFO_6 0x00000DC6 -#define MSR_SKYLAKE_LBR_INFO_7 0x00000DC7 -#define MSR_SKYLAKE_LBR_INFO_8 0x00000DC8 -#define MSR_SKYLAKE_LBR_INFO_9 0x00000DC9 -#define MSR_SKYLAKE_LBR_INFO_10 0x00000DCA -#define MSR_SKYLAKE_LBR_INFO_11 0x00000DCB -#define MSR_SKYLAKE_LBR_INFO_12 0x00000DCC -#define MSR_SKYLAKE_LBR_INFO_13 0x00000DCD -#define MSR_SKYLAKE_LBR_INFO_14 0x00000DCE -#define MSR_SKYLAKE_LBR_INFO_15 0x00000DCF -#define MSR_SKYLAKE_LBR_INFO_16 0x00000DD0 -#define MSR_SKYLAKE_LBR_INFO_17 0x00000DD1 -#define MSR_SKYLAKE_LBR_INFO_18 0x00000DD2 -#define MSR_SKYLAKE_LBR_INFO_19 0x00000DD3 -#define MSR_SKYLAKE_LBR_INFO_20 0x00000DD4 -#define MSR_SKYLAKE_LBR_INFO_21 0x00000DD5 -#define MSR_SKYLAKE_LBR_INFO_22 0x00000DD6 -#define MSR_SKYLAKE_LBR_INFO_23 0x00000DD7 -#define MSR_SKYLAKE_LBR_INFO_24 0x00000DD8 -#define MSR_SKYLAKE_LBR_INFO_25 0x00000DD9 -#define MSR_SKYLAKE_LBR_INFO_26 0x00000DDA -#define MSR_SKYLAKE_LBR_INFO_27 0x00000DDB -#define MSR_SKYLAKE_LBR_INFO_28 0x00000DDC -#define MSR_SKYLAKE_LBR_INFO_29 0x00000DDD -#define MSR_SKYLAKE_LBR_INFO_30 0x00000DDE -#define MSR_SKYLAKE_LBR_INFO_31 0x00000DDF -/// @} - - -/** - Package. Uncore fixed counter control (R/W). - - @param ECX MSR_SKYLAKE_UNC_PERF_FIXED_CTRL (0x00000394) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER. - - Example usage - @code - MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTRL); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTRL, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_UNC_PERF_FIXED_CTRL is defined as MSR_UNC_PERF_FIXED_CTRL in SDM. -**/ -#define MSR_SKYLAKE_UNC_PERF_FIXED_CTRL 0x00000394 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_FIXED_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:20; - /// - /// [Bit 20] Enable overflow propagation. - /// - UINT32 EnableOverflow:1; - UINT32 Reserved2:1; - /// - /// [Bit 22] Enable counting. - /// - UINT32 EnableCounting:1; - UINT32 Reserved3:9; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_UNC_PERF_FIXED_CTRL_REGISTER; - - -/** - Package. Uncore fixed counter. - - @param ECX MSR_SKYLAKE_UNC_PERF_FIXED_CTR (0x00000395) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER. - - Example usage - @code - MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTR); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_FIXED_CTR, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_UNC_PERF_FIXED_CTR is defined as MSR_UNC_PERF_FIXED_CTR in SDM. -**/ -#define MSR_SKYLAKE_UNC_PERF_FIXED_CTR 0x00000395 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_FIXED_CTR -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Current count. - /// - UINT32 CurrentCount:32; - /// - /// [Bits 43:32] Current count. - /// - UINT32 CurrentCountHi:12; - UINT32 Reserved:20; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_UNC_PERF_FIXED_CTR_REGISTER; - - -/** - Package. Uncore C-Box configuration information (R/O). - - @param ECX MSR_SKYLAKE_UNC_CBO_CONFIG (0x00000396) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER. - - Example usage - @code - MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_CONFIG); - @endcode - @note MSR_SKYLAKE_UNC_CBO_CONFIG is defined as MSR_UNC_CBO_CONFIG in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_CONFIG 0x00000396 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_UNC_CBO_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Specifies the number of C-Box units with programmable - /// counters (including processor cores and processor graphics),. - /// - UINT32 CBox:4; - UINT32 Reserved1:28; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_UNC_CBO_CONFIG_REGISTER; - - -/** - Package. Uncore Arb unit, performance counter 0. - - @param ECX MSR_SKYLAKE_UNC_ARB_PERFCTR0 (0x000003B0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_ARB_PERFCTR0 is defined as MSR_UNC_ARB_PERFCTR0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_ARB_PERFCTR0 0x000003B0 - - -/** - Package. Uncore Arb unit, performance counter 1. - - @param ECX MSR_SKYLAKE_UNC_ARB_PERFCTR1 (0x000003B1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFCTR1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_ARB_PERFCTR1 is defined as MSR_UNC_ARB_PERFCTR1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_ARB_PERFCTR1 0x000003B1 - - -/** - Package. Uncore Arb unit, counter 0 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 (0x000003B2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 is defined as MSR_UNC_ARB_PERFEVTSEL0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_ARB_PERFEVTSEL0 0x000003B2 - - -/** - Package. Uncore Arb unit, counter 1 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 (0x000003B3) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 is defined as MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_ARB_PERFEVTSEL1 0x000003B3 - - -/** - Package. Uncore C-Box 0, counter 0 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 (0x00000700) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 is defined as MSR_UNC_CBO_0_PERFEVTSEL0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL0 0x00000700 - - -/** - Package. Uncore C-Box 0, counter 1 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 (0x00000701) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 is defined as MSR_UNC_CBO_0_PERFEVTSEL1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_0_PERFEVTSEL1 0x00000701 - - -/** - Package. Uncore C-Box 0, performance counter 0. - - @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 (0x00000706) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 is defined as MSR_UNC_CBO_0_PERFCTR0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_0_PERFCTR0 0x00000706 - - -/** - Package. Uncore C-Box 0, performance counter 1. - - @param ECX MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 (0x00000707) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_0_PERFCTR1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 is defined as MSR_UNC_CBO_0_PERFCTR1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_0_PERFCTR1 0x00000707 - - -/** - Package. Uncore C-Box 1, counter 0 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 (0x00000710) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 is defined as MSR_UNC_CBO_1_PERFEVTSEL0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL0 0x00000710 - - -/** - Package. Uncore C-Box 1, counter 1 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 (0x00000711) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 is defined as MSR_UNC_CBO_1_PERFEVTSEL1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_1_PERFEVTSEL1 0x00000711 - - -/** - Package. Uncore C-Box 1, performance counter 0. - - @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 (0x00000716) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 is defined as MSR_UNC_CBO_1_PERFCTR0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_1_PERFCTR0 0x00000716 - - -/** - Package. Uncore C-Box 1, performance counter 1. - - @param ECX MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 (0x00000717) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_1_PERFCTR1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 is defined as MSR_UNC_CBO_1_PERFCTR1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_1_PERFCTR1 0x00000717 - - -/** - Package. Uncore C-Box 2, counter 0 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 (0x00000720) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 is defined as MSR_UNC_CBO_2_PERFEVTSEL0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL0 0x00000720 - - -/** - Package. Uncore C-Box 2, counter 1 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 (0x00000721) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 is defined as MSR_UNC_CBO_2_PERFEVTSEL1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_2_PERFEVTSEL1 0x00000721 - - -/** - Package. Uncore C-Box 2, performance counter 0. - - @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 (0x00000726) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 is defined as MSR_UNC_CBO_2_PERFCTR0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_2_PERFCTR0 0x00000726 - - -/** - Package. Uncore C-Box 2, performance counter 1. - - @param ECX MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 (0x00000727) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_2_PERFCTR1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 is defined as MSR_UNC_CBO_2_PERFCTR1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_2_PERFCTR1 0x00000727 - - -/** - Package. Uncore C-Box 3, counter 0 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 (0x00000730) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 is defined as MSR_UNC_CBO_3_PERFEVTSEL0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL0 0x00000730 - - -/** - Package. Uncore C-Box 3, counter 1 event select MSR. - - @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 (0x00000731) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 is defined as MSR_UNC_CBO_3_PERFEVTSEL1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_3_PERFEVTSEL1 0x00000731 - - -/** - Package. Uncore C-Box 3, performance counter 0. - - @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 (0x00000736) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR0); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR0, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 is defined as MSR_UNC_CBO_3_PERFCTR0 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_3_PERFCTR0 0x00000736 - - -/** - Package. Uncore C-Box 3, performance counter 1. - - @param ECX MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 (0x00000737) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR1); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_CBO_3_PERFCTR1, Msr); - @endcode - @note MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 is defined as MSR_UNC_CBO_3_PERFCTR1 in SDM. -**/ -#define MSR_SKYLAKE_UNC_CBO_3_PERFCTR1 0x00000737 - - -/** - Package. Uncore PMU global control. - - @param ECX MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL (0x00000E01) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER. - - Example usage - @code - MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL is defined as MSR_UNC_PERF_GLOBAL_CTRL in SDM. -**/ -#define MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL 0x00000E01 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Slice 0 select. - /// - UINT32 PMI_Sel_Slice0:1; - /// - /// [Bit 1] Slice 1 select. - /// - UINT32 PMI_Sel_Slice1:1; - /// - /// [Bit 2] Slice 2 select. - /// - UINT32 PMI_Sel_Slice2:1; - /// - /// [Bit 3] Slice 3 select. - /// - UINT32 PMI_Sel_Slice3:1; - /// - /// [Bit 4] Slice 4select. - /// - UINT32 PMI_Sel_Slice4:1; - UINT32 Reserved1:14; - UINT32 Reserved2:10; - /// - /// [Bit 29] Enable all uncore counters. - /// - UINT32 EN:1; - /// - /// [Bit 30] Enable wake on PMI. - /// - UINT32 WakePMI:1; - /// - /// [Bit 31] Enable Freezing counter when overflow. - /// - UINT32 FREEZE:1; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_UNC_PERF_GLOBAL_CTRL_REGISTER; - - -/** - Package. Uncore PMU main status. - - @param ECX MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS (0x00000E02) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER. - - Example usage - @code - MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS); - AsmWriteMsr64 (MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS, Msr.Uint64); - @endcode - @note MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS is defined as MSR_UNC_PERF_GLOBAL_STATUS in SDM. -**/ -#define MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS 0x00000E02 - -/** - MSR information returned for MSR index #MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fixed counter overflowed. - /// - UINT32 Fixed:1; - /// - /// [Bit 1] An ARB counter overflowed. - /// - UINT32 ARB:1; - UINT32 Reserved1:1; - /// - /// [Bit 3] A CBox counter overflowed (on any slice). - /// - UINT32 CBox:1; - UINT32 Reserved2:28; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_SKYLAKE_UNC_PERF_GLOBAL_STATUS_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h b/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h deleted file mode 100644 index ad7128ae95..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/Xeon5600Msr.h +++ /dev/null @@ -1,203 +0,0 @@ -/** @file - MSR Definitions for Intel(R) Xeon(R) Processor Series 5600. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.7. - -**/ - -#ifndef __XEON_5600_MSR_H__ -#define __XEON_5600_MSR_H__ - -#include - -/** - Is Intel(R) Xeon(R) Processor Series 5600? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_XEON_5600_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x25 || \ - DisplayModel == 0x2C \ - ) \ - ) - -/** - Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP - handler to handle unsuccessful read of this MSR. - - @param ECX MSR_XEON_5600_FEATURE_CONFIG (0x0000013C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_5600_FEATURE_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_5600_FEATURE_CONFIG_REGISTER. - - Example usage - @code - MSR_XEON_5600_FEATURE_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_5600_FEATURE_CONFIG); - AsmWriteMsr64 (MSR_XEON_5600_FEATURE_CONFIG, Msr.Uint64); - @endcode - @note MSR_XEON_5600_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. -**/ -#define MSR_XEON_5600_FEATURE_CONFIG 0x0000013C - -/** - MSR information returned for MSR index #MSR_XEON_5600_FEATURE_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this - /// MSR, the configuration of AES instruction set availability is as - /// follows: 11b: AES instructions are not available until next RESET. - /// otherwise, AES instructions are available. Note, AES instruction set - /// is not available if read is unsuccessful. If the configuration is not - /// 01b, AES instruction can be mis-configured if a privileged agent - /// unintentionally writes 11b. - /// - UINT32 AESConfiguration:2; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_5600_FEATURE_CONFIG_REGISTER; - - -/** - Thread. Offcore Response Event Select Register (R/W). - - @param ECX MSR_XEON_5600_OFFCORE_RSP_1 (0x000001A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_5600_OFFCORE_RSP_1); - AsmWriteMsr64 (MSR_XEON_5600_OFFCORE_RSP_1, Msr); - @endcode - @note MSR_XEON_5600_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. -**/ -#define MSR_XEON_5600_OFFCORE_RSP_1 0x000001A7 - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_XEON_5600_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_5600_TURBO_RATIO_LIMIT); - @endcode - @note MSR_XEON_5600_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_XEON_5600_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C Maximum turbo ratio - /// limit of 1 core active. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C Maximum turbo ratio - /// limit of 2 core active. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C Maximum turbo ratio - /// limit of 3 core active. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C Maximum turbo ratio - /// limit of 4 core active. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C Maximum turbo ratio - /// limit of 5 core active. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C Maximum turbo ratio - /// limit of 6 core active. - /// - UINT32 Maximum6C:8; - UINT32 Reserved:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_5600_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. See Table 35-2. - - @param ECX MSR_XEON_5600_IA32_ENERGY_PERF_BIAS (0x000001B0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_5600_IA32_ENERGY_PERF_BIAS); - AsmWriteMsr64 (MSR_XEON_5600_IA32_ENERGY_PERF_BIAS, Msr); - @endcode - @note MSR_XEON_5600_IA32_ENERGY_PERF_BIAS is defined as IA32_ENERGY_PERF_BIAS in SDM. -**/ -#define MSR_XEON_5600_IA32_ENERGY_PERF_BIAS 0x000001B0 - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h b/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h deleted file mode 100644 index 7b31288a35..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/XeonDMsr.h +++ /dev/null @@ -1,1219 +0,0 @@ -/** @file - MSR Definitions for Intel(R) Xeon(R) Processor D product Family. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.14. - -**/ - -#ifndef __XEON_D_MSR_H__ -#define __XEON_D_MSR_H__ - -#include - -/** - Is Intel(R) Xeon(R) Processor D product Family? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_XEON_D_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x4F || \ - DisplayModel == 0x56 \ - ) \ - ) - -/** - Package. Protected Processor Inventory Number Enable Control (R/W). - - @param ECX MSR_XEON_D_PPIN_CTL (0x0000004E) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_PPIN_CTL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_PPIN_CTL_REGISTER. - - Example usage - @code - MSR_XEON_D_PPIN_CTL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PPIN_CTL); - AsmWriteMsr64 (MSR_XEON_D_PPIN_CTL, Msr.Uint64); - @endcode - @note MSR_XEON_D_PPIN_CTL is defined as MSR_PPIN_CTL in SDM. -**/ -#define MSR_XEON_D_PPIN_CTL 0x0000004E - -/** - MSR information returned for MSR index #MSR_XEON_D_PPIN_CTL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] LockOut (R/WO) See Table 35-24. - /// - UINT32 LockOut:1; - /// - /// [Bit 1] Enable_PPIN (R/W) See Table 35-24. - /// - UINT32 Enable_PPIN:1; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_PPIN_CTL_REGISTER; - - -/** - Package. Protected Processor Inventory Number (R/O). Protected Processor - Inventory Number (R/O) See Table 35-24. - - @param ECX MSR_XEON_D_PPIN (0x0000004F) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_D_PPIN); - @endcode - @note MSR_XEON_D_PPIN is defined as MSR_PPIN in SDM. -**/ -#define MSR_XEON_D_PPIN 0x0000004F - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_XEON_D_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_XEON_D_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PLATFORM_INFO); - AsmWriteMsr64 (MSR_XEON_D_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_XEON_D_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_XEON_D_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_XEON_D_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) See Table 35-24. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:7; - /// - /// [Bit 23] Package. PPIN_CAP (R/O) See Table 35-24. - /// - UINT32 PPIN_CAP:1; - UINT32 Reserved3:4; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) See - /// Table 35-24. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) See - /// Table 35-24. - /// - UINT32 TDPLimit:1; - /// - /// [Bit 30] Package. Programmable TJ OFFSET (R/O) See Table 35-24. - /// - UINT32 TJOFFSET:1; - UINT32 Reserved4:1; - UINT32 Reserved5:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) See Table 35-24. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved6:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_PLATFORM_INFO_REGISTER; - - -/** - Core. C-State Configuration Control (R/W) Note: C-state values are processor - specific C-state code names, unrelated to MWAIT extension C-state parameters - or ACPI C-states. `See http://biosbits.org. `__. - - @param ECX MSR_XEON_D_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_XEON_D_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_XEON_D_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_XEON_D_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_XEON_D_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) Specifies the lowest - /// processor-specific C-state code name (consuming the least power) for - /// the package. The default is set as factory-configured package C-state - /// limit. The following C-state code name encodings are supported: 000b: - /// C0/C1 (no package C-state support) 001b: C2 010b: C6 (non-retention) - /// 011b: C6 (retention) 111b: No Package C state limits. All C states - /// supported by the processor are available. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W). - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO). - /// - UINT32 CFGLock:1; - /// - /// [Bit 16] Automatic C-State Conversion Enable (R/W) If 1, the processor - /// will convert HALT or MWAT(C1) to MWAIT(C6). - /// - UINT32 CStateConversion:1; - UINT32 Reserved3:8; - /// - /// [Bit 25] C3 State Auto Demotion Enable (R/W). - /// - UINT32 C3AutoDemotion:1; - /// - /// [Bit 26] C1 State Auto Demotion Enable (R/W). - /// - UINT32 C1AutoDemotion:1; - /// - /// [Bit 27] Enable C3 Undemotion (R/W). - /// - UINT32 C3Undemotion:1; - /// - /// [Bit 28] Enable C1 Undemotion (R/W). - /// - UINT32 C1Undemotion:1; - /// - /// [Bit 29] Package C State Demotion Enable (R/W). - /// - UINT32 CStateDemotion:1; - /// - /// [Bit 30] Package C State UnDemotion Enable (R/W). - /// - UINT32 CStateUndemotion:1; - UINT32 Reserved4:1; - UINT32 Reserved5:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Thread. Global Machine Check Capability (R/O). - - @param ECX MSR_XEON_D_IA32_MCG_CAP (0x00000179) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_MCG_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_MCG_CAP_REGISTER. - - Example usage - @code - MSR_XEON_D_IA32_MCG_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_MCG_CAP); - @endcode - @note MSR_XEON_D_IA32_MCG_CAP is defined as IA32_MCG_CAP in SDM. -**/ -#define MSR_XEON_D_IA32_MCG_CAP 0x00000179 - -/** - MSR information returned for MSR index #MSR_XEON_D_IA32_MCG_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Count. - /// - UINT32 Count:8; - /// - /// [Bit 8] MCG_CTL_P. - /// - UINT32 MCG_CTL_P:1; - /// - /// [Bit 9] MCG_EXT_P. - /// - UINT32 MCG_EXT_P:1; - /// - /// [Bit 10] MCP_CMCI_P. - /// - UINT32 MCP_CMCI_P:1; - /// - /// [Bit 11] MCG_TES_P. - /// - UINT32 MCG_TES_P:1; - UINT32 Reserved1:4; - /// - /// [Bits 23:16] MCG_EXT_CNT. - /// - UINT32 MCG_EXT_CNT:8; - /// - /// [Bit 24] MCG_SER_P. - /// - UINT32 MCG_SER_P:1; - /// - /// [Bit 25] MCG_EM_P. - /// - UINT32 MCG_EM_P:1; - /// - /// [Bit 26] MCG_ELOG_P. - /// - UINT32 MCG_ELOG_P:1; - UINT32 Reserved2:5; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_IA32_MCG_CAP_REGISTER; - - -/** - THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_XEON_D_SMM_MCA_CAP (0x0000017D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_SMM_MCA_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_SMM_MCA_CAP_REGISTER. - - Example usage - @code - MSR_XEON_D_SMM_MCA_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_SMM_MCA_CAP); - AsmWriteMsr64 (MSR_XEON_D_SMM_MCA_CAP, Msr.Uint64); - @endcode - @note MSR_XEON_D_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. -**/ -#define MSR_XEON_D_SMM_MCA_CAP 0x0000017D - -/** - MSR information returned for MSR index #MSR_XEON_D_SMM_MCA_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:26; - /// - /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the - /// SMM code access restriction is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 SMM_Code_Access_Chk:1; - /// - /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the - /// SMM long flow indicator is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 Long_Flow_Indication:1; - UINT32 Reserved3:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_SMM_MCA_CAP_REGISTER; - - -/** - Package. - - @param ECX MSR_XEON_D_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_XEON_D_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_XEON_D_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_XEON_D_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_XEON_D_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_XEON_D_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (RO) See Table 35-24. - /// - UINT32 TemperatureTarget:8; - /// - /// [Bits 27:24] TCC Activation Offset (R/W) See Table 35-24. - /// - UINT32 TCCActivationOffset:4; - UINT32 Reserved2:4; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_TEMPERATURE_TARGET_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT); - @endcode - @note MSR_XEON_D_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_XEON_D_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 1C. - /// - UINT32 Maximum1C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 2C. - /// - UINT32 Maximum2C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 3C. - /// - UINT32 Maximum3C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 4C. - /// - UINT32 Maximum4C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 5C. - /// - UINT32 Maximum5C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 6C. - /// - UINT32 Maximum6C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 7C. - /// - UINT32 Maximum7C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for 8C. - /// - UINT32 Maximum8C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Package. Maximum Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT1 (0x000001AE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER. - - Example usage - @code - MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT1); - @endcode - @note MSR_XEON_D_TURBO_RATIO_LIMIT1 is defined as MSR_TURBO_RATIO_LIMIT1 in SDM. -**/ -#define MSR_XEON_D_TURBO_RATIO_LIMIT1 0x000001AE - -/** - MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT1 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] Package. Maximum Ratio Limit for 9C. - /// - UINT32 Maximum9C:8; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for 10C. - /// - UINT32 Maximum10C:8; - /// - /// [Bits 23:16] Package. Maximum Ratio Limit for 11C. - /// - UINT32 Maximum11C:8; - /// - /// [Bits 31:24] Package. Maximum Ratio Limit for 12C. - /// - UINT32 Maximum12C:8; - /// - /// [Bits 39:32] Package. Maximum Ratio Limit for 13C. - /// - UINT32 Maximum13C:8; - /// - /// [Bits 47:40] Package. Maximum Ratio Limit for 14C. - /// - UINT32 Maximum14C:8; - /// - /// [Bits 55:48] Package. Maximum Ratio Limit for 15C. - /// - UINT32 Maximum15C:8; - /// - /// [Bits 63:56] Package. Maximum Ratio Limit for 16C. - /// - UINT32 Maximum16C:8; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_TURBO_RATIO_LIMIT1_REGISTER; - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O). - - @param ECX MSR_XEON_D_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_XEON_D_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_RAPL_POWER_UNIT); - @endcode - @note MSR_XEON_D_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_XEON_D_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_XEON_D_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Package. Energy Status Units Energy related information - /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an - /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 - /// micro-joules). - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL - /// Interfaces.". - /// - UINT32 TimeUnits:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_XEON_D_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_XEON_D_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_XEON_D_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_XEON_D_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) Energy consumed by DRAM devices. - - @param ECX MSR_XEON_D_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER. - - Example usage - @code - MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_DRAM_ENERGY_STATUS); - @endcode - @note MSR_XEON_D_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_XEON_D_DRAM_ENERGY_STATUS 0x00000619 - -/** - MSR information returned for MSR index #MSR_XEON_D_DRAM_ENERGY_STATUS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] Energy in 15.3 micro-joules. Requires BIOS configuration - /// to enable DRAM RAPL mode 0 (Direct VR). - /// - UINT32 Energy:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_DRAM_ENERGY_STATUS_REGISTER; - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_XEON_D_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_PERF_STATUS); - @endcode - @note MSR_XEON_D_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_XEON_D_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_XEON_D_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_D_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_XEON_D_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_XEON_D_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_XEON_D_DRAM_POWER_INFO 0x0000061C - - -/** - Package. Reserved (R/O) Reads return 0. - - @param ECX MSR_XEON_D_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_D_PP0_ENERGY_STATUS); - @endcode - @note MSR_XEON_D_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_XEON_D_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_XEON_D_CORE_PERF_LIMIT_REASONS (0x00000690) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_XEON_D_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_XEON_D_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_XEON_D_CORE_PERF_LIMIT_REASONS 0x00000690 - -/** - MSR information returned for MSR index #MSR_XEON_D_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0) When set, processor core frequency is - /// reduced below the operating system request due to assertion of - /// external PROCHOT. - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0) When set, frequency is reduced below the - /// operating system request due to a thermal event. - /// - UINT32 ThermalStatus:1; - /// - /// [Bit 2] Power Budget Management Status (R0) When set, frequency is - /// reduced below the operating system request due to PBM limit. - /// - UINT32 PowerBudgetManagementStatus:1; - /// - /// [Bit 3] Platform Configuration Services Status (R0) When set, - /// frequency is reduced below the operating system request due to PCS - /// limit. - /// - UINT32 PlatformConfigurationServicesStatus:1; - UINT32 Reserved1:1; - /// - /// [Bit 5] Autonomous Utilization-Based Frequency Control Status (R0) - /// When set, frequency is reduced below the operating system request - /// because the processor has detected that utilization is low. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlStatus:1; - /// - /// [Bit 6] VR Therm Alert Status (R0) When set, frequency is reduced - /// below the operating system request due to a thermal alert from the - /// Voltage Regulator. - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0) When set, frequency is - /// reduced below the operating system request due to electrical design - /// point constraints (e.g. maximum electrical current consumption). - /// - UINT32 ElectricalDesignPointStatus:1; - UINT32 Reserved3:1; - /// - /// [Bit 10] Multi-Core Turbo Status (R0) When set, frequency is reduced - /// below the operating system request due to Multi-Core Turbo limits. - /// - UINT32 MultiCoreTurboStatus:1; - UINT32 Reserved4:2; - /// - /// [Bit 13] Core Frequency P1 Status (R0) When set, frequency is reduced - /// below max non-turbo P1. - /// - UINT32 FrequencyP1Status:1; - /// - /// [Bit 14] Core Max n-core Turbo Frequency Limiting Status (R0) When - /// set, frequency is reduced below max n-core turbo frequency. - /// - UINT32 TurboFrequencyLimitingStatus:1; - /// - /// [Bit 15] Core Frequency Limiting Status (R0) When set, frequency is - /// reduced below the operating system request. - /// - UINT32 FrequencyLimitingStatus:1; - /// - /// [Bit 16] PROCHOT Log When set, indicates that the PROCHOT Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 PROCHOT_Log:1; - /// - /// [Bit 17] Thermal Log When set, indicates that the Thermal Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 ThermalLog:1; - /// - /// [Bit 18] Power Budget Management Log When set, indicates that the PBM - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 PowerBudgetManagementLog:1; - /// - /// [Bit 19] Platform Configuration Services Log When set, indicates that - /// the PCS Status bit has asserted since the log bit was last cleared. - /// This log bit will remain set until cleared by software writing 0. - /// - UINT32 PlatformConfigurationServicesLog:1; - UINT32 Reserved5:1; - /// - /// [Bit 21] Autonomous Utilization-Based Frequency Control Log When set, - /// indicates that the AUBFC Status bit has asserted since the log bit was - /// last cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 AutonomousUtilizationBasedFrequencyControlLog:1; - /// - /// [Bit 22] VR Therm Alert Log When set, indicates that the VR Therm - /// Alert Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 VRThermAlertLog:1; - UINT32 Reserved6:1; - /// - /// [Bit 24] Electrical Design Point Log When set, indicates that the EDP - /// Status bit has asserted since the log bit was last cleared. This log - /// bit will remain set until cleared by software writing 0. - /// - UINT32 ElectricalDesignPointLog:1; - UINT32 Reserved7:1; - /// - /// [Bit 26] Multi-Core Turbo Log When set, indicates that the Multi-Core - /// Turbo Status bit has asserted since the log bit was last cleared. This - /// log bit will remain set until cleared by software writing 0. - /// - UINT32 MultiCoreTurboLog:1; - UINT32 Reserved8:2; - /// - /// [Bit 29] Core Frequency P1 Log When set, indicates that the Core - /// Frequency P1 Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CoreFrequencyP1Log:1; - /// - /// [Bit 30] Core Max n-core Turbo Frequency Limiting Log When set, - /// indicates that the Core Max n-core Turbo Frequency Limiting Status bit - /// has asserted since the log bit was last cleared. This log bit will - /// remain set until cleared by software writing 0. - /// - UINT32 TurboFrequencyLimitingLog:1; - /// - /// [Bit 31] Core Frequency Limiting Log When set, indicates that the Core - /// Frequency Limiting Status bit has asserted since the log bit was last - /// cleared. This log bit will remain set until cleared by software - /// writing 0. - /// - UINT32 CoreFrequencyLimitingLog:1; - UINT32 Reserved9:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_CORE_PERF_LIMIT_REASONS_REGISTER; - - -/** - THREAD. Monitoring Event Select Register (R/W) if CPUID.(EAX=07H, - ECX=0):EBX.RDT-M[bit 12] = 1. - - @param ECX MSR_XEON_D_IA32_QM_EVTSEL (0x00000C8D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_QM_EVTSEL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_QM_EVTSEL_REGISTER. - - Example usage - @code - MSR_XEON_D_IA32_QM_EVTSEL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_QM_EVTSEL); - AsmWriteMsr64 (MSR_XEON_D_IA32_QM_EVTSEL, Msr.Uint64); - @endcode - @note MSR_XEON_D_IA32_QM_EVTSEL is defined as IA32_QM_EVTSEL in SDM. -**/ -#define MSR_XEON_D_IA32_QM_EVTSEL 0x00000C8D - -/** - MSR information returned for MSR index #MSR_XEON_D_IA32_QM_EVTSEL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 7:0] EventID (RW) Event encoding: 0x00: no monitoring 0x01: L3 - /// occupancy monitoring 0x02: Total memory bandwidth monitoring 0x03: - /// Local memory bandwidth monitoring All other encoding reserved. - /// - UINT32 EventID:8; - UINT32 Reserved1:24; - /// - /// [Bits 41:32] RMID (RW). - /// - UINT32 RMID:10; - UINT32 Reserved2:22; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_IA32_QM_EVTSEL_REGISTER; - - -/** - THREAD. Resource Association Register (R/W). - - @param ECX MSR_XEON_D_IA32_PQR_ASSOC (0x00000C8F) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_PQR_ASSOC_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_PQR_ASSOC_REGISTER. - - Example usage - @code - MSR_XEON_D_IA32_PQR_ASSOC_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_PQR_ASSOC); - AsmWriteMsr64 (MSR_XEON_D_IA32_PQR_ASSOC, Msr.Uint64); - @endcode - @note MSR_XEON_D_IA32_PQR_ASSOC is defined as IA32_PQR_ASSOC in SDM. -**/ -#define MSR_XEON_D_IA32_PQR_ASSOC 0x00000C8F - -/** - MSR information returned for MSR index #MSR_XEON_D_IA32_PQR_ASSOC -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 9:0] RMID. - /// - UINT32 RMID:10; - UINT32 Reserved1:22; - /// - /// [Bits 51:32] COS (R/W). - /// - UINT32 COS:20; - UINT32 Reserved2:12; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_IA32_PQR_ASSOC_REGISTER; - - -/** - Package. L3 Class Of Service Mask - COS n (R/W) if CPUID.(EAX=10H, - ECX=1):EDX.COS_MAX[15:0] >= n. - - @param ECX MSR_XEON_D_IA32_L3_QOS_MASK_n - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER. - - Example usage - @code - MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_L3_QOS_MASK_0); - AsmWriteMsr64 (MSR_XEON_D_IA32_L3_QOS_MASK_0, Msr.Uint64); - @endcode - @note MSR_XEON_D_IA32_L3_QOS_MASK_0 is defined as IA32_L3_QOS_MASK_0 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_1 is defined as IA32_L3_QOS_MASK_1 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_2 is defined as IA32_L3_QOS_MASK_2 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_3 is defined as IA32_L3_QOS_MASK_3 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_4 is defined as IA32_L3_QOS_MASK_4 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_5 is defined as IA32_L3_QOS_MASK_5 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_6 is defined as IA32_L3_QOS_MASK_6 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_7 is defined as IA32_L3_QOS_MASK_7 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_8 is defined as IA32_L3_QOS_MASK_8 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_9 is defined as IA32_L3_QOS_MASK_9 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_10 is defined as IA32_L3_QOS_MASK_10 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_11 is defined as IA32_L3_QOS_MASK_11 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_12 is defined as IA32_L3_QOS_MASK_12 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_13 is defined as IA32_L3_QOS_MASK_13 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_14 is defined as IA32_L3_QOS_MASK_14 in SDM. - MSR_XEON_D_IA32_L3_QOS_MASK_15 is defined as IA32_L3_QOS_MASK_15 in SDM. - @{ -**/ -#define MSR_XEON_D_IA32_L3_QOS_MASK_0 0x00000C90 -#define MSR_XEON_D_IA32_L3_QOS_MASK_1 0x00000C91 -#define MSR_XEON_D_IA32_L3_QOS_MASK_2 0x00000C92 -#define MSR_XEON_D_IA32_L3_QOS_MASK_3 0x00000C93 -#define MSR_XEON_D_IA32_L3_QOS_MASK_4 0x00000C94 -#define MSR_XEON_D_IA32_L3_QOS_MASK_5 0x00000C95 -#define MSR_XEON_D_IA32_L3_QOS_MASK_6 0x00000C96 -#define MSR_XEON_D_IA32_L3_QOS_MASK_7 0x00000C97 -#define MSR_XEON_D_IA32_L3_QOS_MASK_8 0x00000C98 -#define MSR_XEON_D_IA32_L3_QOS_MASK_9 0x00000C99 -#define MSR_XEON_D_IA32_L3_QOS_MASK_10 0x00000C9A -#define MSR_XEON_D_IA32_L3_QOS_MASK_11 0x00000C9B -#define MSR_XEON_D_IA32_L3_QOS_MASK_12 0x00000C9C -#define MSR_XEON_D_IA32_L3_QOS_MASK_13 0x00000C9D -#define MSR_XEON_D_IA32_L3_QOS_MASK_14 0x00000C9E -#define MSR_XEON_D_IA32_L3_QOS_MASK_15 0x00000C9F -/// @} - -/** - MSR information returned for MSR indexes #MSR_XEON_D_IA32_L3_QOS_MASK_0 - to #MSR_XEON_D_IA32_L3_QOS_MASK_15. -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 19:0] CBM: Bit vector of available L3 ways for COS 0 enforcement. - /// - UINT32 CBM:20; - UINT32 Reserved2:12; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_IA32_L3_QOS_MASK_REGISTER; - - -/** - Package. Config Ratio Limit of Turbo Mode RO if MSR_PLATFORM_INFO.[28] = 0, - RW if MSR_PLATFORM_INFO.[28] = 1. - - @param ECX MSR_XEON_D_TURBO_RATIO_LIMIT3 (0x000001AC) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER. - - Example usage - @code - MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_TURBO_RATIO_LIMIT3); - @endcode - @note MSR_XEON_D_TURBO_RATIO_LIMIT3 is defined as MSR_TURBO_RATIO_LIMIT3 in SDM. -**/ -#define MSR_XEON_D_TURBO_RATIO_LIMIT3 0x000001AC - -/** - MSR information returned for MSR index #MSR_XEON_D_TURBO_RATIO_LIMIT3 -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:31; - /// - /// [Bit 63] Package. Semaphore for Turbo Ratio Limit Configuration If 1, - /// the processor uses override configuration specified in - /// MSR_TURBO_RATIO_LIMIT, MSR_TURBO_RATIO_LIMIT1. If 0, the processor - /// uses factory-set configuration (Default). - /// - UINT32 TurboRatioLimitConfigurationSemaphore:1; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_TURBO_RATIO_LIMIT3_REGISTER; - - -/** - Package. Cache Allocation Technology Configuration (R/W). - - @param ECX MSR_XEON_D_IA32_L3_QOS_CFG (0x00000C81) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER. - - Example usage - @code - MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_D_IA32_L3_QOS_CFG); - AsmWriteMsr64 (MSR_XEON_D_IA32_L3_QOS_CFG, Msr.Uint64); - @endcode - @note MSR_XEON_D_IA32_L3_QOS_CFG is defined as IA32_L3_QOS_CFG in SDM. -**/ -#define MSR_XEON_D_IA32_L3_QOS_CFG 0x00000C81 - -/** - MSR information returned for MSR index #MSR_XEON_D_IA32_L3_QOS_CFG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] CAT Enable. Set 1 to enable Cache Allocation Technology. - /// - UINT32 CAT:1; - UINT32 Reserved1:31; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_D_IA32_L3_QOS_CFG_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h b/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h deleted file mode 100644 index d509660c52..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/XeonE7Msr.h +++ /dev/null @@ -1,373 +0,0 @@ -/** @file - MSR Definitions for Intel(R) Xeon(R) Processor E7 Family. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.8. - -**/ - -#ifndef __XEON_E7_MSR_H__ -#define __XEON_E7_MSR_H__ - -#include - -/** - Is Intel(R) Xeon(R) Processor E7 Family? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_XEON_E7_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x2F \ - ) \ - ) - -/** - Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP - handler to handle unsuccessful read of this MSR. - - @param ECX MSR_XEON_E7_FEATURE_CONFIG (0x0000013C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_E7_FEATURE_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_E7_FEATURE_CONFIG_REGISTER. - - Example usage - @code - MSR_XEON_E7_FEATURE_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_E7_FEATURE_CONFIG); - AsmWriteMsr64 (MSR_XEON_E7_FEATURE_CONFIG, Msr.Uint64); - @endcode - @note MSR_XEON_E7_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. -**/ -#define MSR_XEON_E7_FEATURE_CONFIG 0x0000013C - -/** - MSR information returned for MSR index #MSR_XEON_E7_FEATURE_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this - /// MSR, the configuration of AES instruction set availability is as - /// follows: 11b: AES instructions are not available until next RESET. - /// otherwise, AES instructions are available. Note, AES instruction set - /// is not available if read is unsuccessful. If the configuration is not - /// 01b, AES instruction can be mis-configured if a privileged agent - /// unintentionally writes 11b. - /// - UINT32 AESConfiguration:2; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_E7_FEATURE_CONFIG_REGISTER; - - -/** - Thread. Offcore Response Event Select Register (R/W). - - @param ECX MSR_XEON_E7_OFFCORE_RSP_1 (0x000001A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_OFFCORE_RSP_1); - AsmWriteMsr64 (MSR_XEON_E7_OFFCORE_RSP_1, Msr); - @endcode - @note MSR_XEON_E7_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. -**/ -#define MSR_XEON_E7_OFFCORE_RSP_1 0x000001A7 - - -/** - Package. Reserved Attempt to read/write will cause #UD. - - @param ECX MSR_XEON_E7_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_TURBO_RATIO_LIMIT); - AsmWriteMsr64 (MSR_XEON_E7_TURBO_RATIO_LIMIT, Msr); - @endcode - @note MSR_XEON_E7_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_XEON_E7_TURBO_RATIO_LIMIT 0x000001AD - - -/** - Package. Uncore C-box 8 perfmon local box control MSR. - - @param ECX MSR_XEON_E7_C8_PMON_BOX_CTRL (0x00000F40) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_XEON_E7_C8_PMON_BOX_CTRL is defined as MSR_C8_PMON_BOX_CTRL in SDM. -**/ -#define MSR_XEON_E7_C8_PMON_BOX_CTRL 0x00000F40 - - -/** - Package. Uncore C-box 8 perfmon local box status MSR. - - @param ECX MSR_XEON_E7_C8_PMON_BOX_STATUS (0x00000F41) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_XEON_E7_C8_PMON_BOX_STATUS is defined as MSR_C8_PMON_BOX_STATUS in SDM. -**/ -#define MSR_XEON_E7_C8_PMON_BOX_STATUS 0x00000F41 - - -/** - Package. Uncore C-box 8 perfmon local box overflow control MSR. - - @param ECX MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL (0x00000F42) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL is defined as MSR_C8_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_XEON_E7_C8_PMON_BOX_OVF_CTRL 0x00000F42 - - -/** - Package. Uncore C-box 8 perfmon event select MSR. - - @param ECX MSR_XEON_E7_C8_PMON_EVNT_SELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_XEON_E7_C8_PMON_EVNT_SEL0 is defined as MSR_C8_PMON_EVNT_SEL0 in SDM. - MSR_XEON_E7_C8_PMON_EVNT_SEL1 is defined as MSR_C8_PMON_EVNT_SEL1 in SDM. - MSR_XEON_E7_C8_PMON_EVNT_SEL2 is defined as MSR_C8_PMON_EVNT_SEL2 in SDM. - MSR_XEON_E7_C8_PMON_EVNT_SEL3 is defined as MSR_C8_PMON_EVNT_SEL3 in SDM. - MSR_XEON_E7_C8_PMON_EVNT_SEL4 is defined as MSR_C8_PMON_EVNT_SEL4 in SDM. - MSR_XEON_E7_C8_PMON_EVNT_SEL5 is defined as MSR_C8_PMON_EVNT_SEL5 in SDM. - @{ -**/ -#define MSR_XEON_E7_C8_PMON_EVNT_SEL0 0x00000F50 -#define MSR_XEON_E7_C8_PMON_EVNT_SEL1 0x00000F52 -#define MSR_XEON_E7_C8_PMON_EVNT_SEL2 0x00000F54 -#define MSR_XEON_E7_C8_PMON_EVNT_SEL3 0x00000F56 -#define MSR_XEON_E7_C8_PMON_EVNT_SEL4 0x00000F58 -#define MSR_XEON_E7_C8_PMON_EVNT_SEL5 0x00000F5A -/// @} - - -/** - Package. Uncore C-box 8 perfmon counter MSR. - - @param ECX MSR_XEON_E7_C8_PMON_CTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C8_PMON_CTR0); - AsmWriteMsr64 (MSR_XEON_E7_C8_PMON_CTR0, Msr); - @endcode - @note MSR_XEON_E7_C8_PMON_CTR0 is defined as MSR_C8_PMON_CTR0 in SDM. - MSR_XEON_E7_C8_PMON_CTR1 is defined as MSR_C8_PMON_CTR1 in SDM. - MSR_XEON_E7_C8_PMON_CTR2 is defined as MSR_C8_PMON_CTR2 in SDM. - MSR_XEON_E7_C8_PMON_CTR3 is defined as MSR_C8_PMON_CTR3 in SDM. - MSR_XEON_E7_C8_PMON_CTR4 is defined as MSR_C8_PMON_CTR4 in SDM. - MSR_XEON_E7_C8_PMON_CTR5 is defined as MSR_C8_PMON_CTR5 in SDM. - @{ -**/ -#define MSR_XEON_E7_C8_PMON_CTR0 0x00000F51 -#define MSR_XEON_E7_C8_PMON_CTR1 0x00000F53 -#define MSR_XEON_E7_C8_PMON_CTR2 0x00000F55 -#define MSR_XEON_E7_C8_PMON_CTR3 0x00000F57 -#define MSR_XEON_E7_C8_PMON_CTR4 0x00000F59 -#define MSR_XEON_E7_C8_PMON_CTR5 0x00000F5B -/// @} - - -/** - Package. Uncore C-box 9 perfmon local box control MSR. - - @param ECX MSR_XEON_E7_C9_PMON_BOX_CTRL (0x00000FC0) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_CTRL); - AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_CTRL, Msr); - @endcode - @note MSR_XEON_E7_C9_PMON_BOX_CTRL is defined as MSR_C9_PMON_BOX_CTRL in SDM. -**/ -#define MSR_XEON_E7_C9_PMON_BOX_CTRL 0x00000FC0 - - -/** - Package. Uncore C-box 9 perfmon local box status MSR. - - @param ECX MSR_XEON_E7_C9_PMON_BOX_STATUS (0x00000FC1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_STATUS); - AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_STATUS, Msr); - @endcode - @note MSR_XEON_E7_C9_PMON_BOX_STATUS is defined as MSR_C9_PMON_BOX_STATUS in SDM. -**/ -#define MSR_XEON_E7_C9_PMON_BOX_STATUS 0x00000FC1 - - -/** - Package. Uncore C-box 9 perfmon local box overflow control MSR. - - @param ECX MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL (0x00000FC2) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL); - AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL, Msr); - @endcode - @note MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL is defined as MSR_C9_PMON_BOX_OVF_CTRL in SDM. -**/ -#define MSR_XEON_E7_C9_PMON_BOX_OVF_CTRL 0x00000FC2 - - -/** - Package. Uncore C-box 9 perfmon event select MSR. - - @param ECX MSR_XEON_E7_C9_PMON_EVNT_SELn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_EVNT_SEL0); - AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_EVNT_SEL0, Msr); - @endcode - @note MSR_XEON_E7_C9_PMON_EVNT_SEL0 is defined as MSR_C9_PMON_EVNT_SEL0 in SDM. - MSR_XEON_E7_C9_PMON_EVNT_SEL1 is defined as MSR_C9_PMON_EVNT_SEL1 in SDM. - MSR_XEON_E7_C9_PMON_EVNT_SEL2 is defined as MSR_C9_PMON_EVNT_SEL2 in SDM. - MSR_XEON_E7_C9_PMON_EVNT_SEL3 is defined as MSR_C9_PMON_EVNT_SEL3 in SDM. - MSR_XEON_E7_C9_PMON_EVNT_SEL4 is defined as MSR_C9_PMON_EVNT_SEL4 in SDM. - MSR_XEON_E7_C9_PMON_EVNT_SEL5 is defined as MSR_C9_PMON_EVNT_SEL5 in SDM. - @{ -**/ -#define MSR_XEON_E7_C9_PMON_EVNT_SEL0 0x00000FD0 -#define MSR_XEON_E7_C9_PMON_EVNT_SEL1 0x00000FD2 -#define MSR_XEON_E7_C9_PMON_EVNT_SEL2 0x00000FD4 -#define MSR_XEON_E7_C9_PMON_EVNT_SEL3 0x00000FD6 -#define MSR_XEON_E7_C9_PMON_EVNT_SEL4 0x00000FD8 -#define MSR_XEON_E7_C9_PMON_EVNT_SEL5 0x00000FDA -/// @} - - -/** - Package. Uncore C-box 9 perfmon counter MSR. - - @param ECX MSR_XEON_E7_C9_PMON_CTRn - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_E7_C9_PMON_CTR0); - AsmWriteMsr64 (MSR_XEON_E7_C9_PMON_CTR0, Msr); - @endcode - @note MSR_XEON_E7_C9_PMON_CTR0 is defined as MSR_C9_PMON_CTR0 in SDM. - MSR_XEON_E7_C9_PMON_CTR1 is defined as MSR_C9_PMON_CTR1 in SDM. - MSR_XEON_E7_C9_PMON_CTR2 is defined as MSR_C9_PMON_CTR2 in SDM. - MSR_XEON_E7_C9_PMON_CTR3 is defined as MSR_C9_PMON_CTR3 in SDM. - MSR_XEON_E7_C9_PMON_CTR4 is defined as MSR_C9_PMON_CTR4 in SDM. - MSR_XEON_E7_C9_PMON_CTR5 is defined as MSR_C9_PMON_CTR5 in SDM. - @{ -**/ -#define MSR_XEON_E7_C9_PMON_CTR0 0x00000FD1 -#define MSR_XEON_E7_C9_PMON_CTR1 0x00000FD3 -#define MSR_XEON_E7_C9_PMON_CTR2 0x00000FD5 -#define MSR_XEON_E7_C9_PMON_CTR3 0x00000FD7 -#define MSR_XEON_E7_C9_PMON_CTR4 0x00000FD9 -#define MSR_XEON_E7_C9_PMON_CTR5 0x00000FDB -/// @} - -#endif diff --git a/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h b/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h deleted file mode 100644 index 43354d15c9..0000000000 --- a/UefiCpuPkg/Include/Register/Msr/XeonPhiMsr.h +++ /dev/null @@ -1,1405 +0,0 @@ -/** @file - MSR Definitions for Intel(R) Xeon(R) Phi(TM) processor Family. - - Provides defines for Machine Specific Registers(MSR) indexes. Data structures - are provided for MSRs that contain one or more bit fields. If the MSR value - returned is a single 32-bit or 64-bit value, then a data structure is not - provided for that MSR. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - Intel(R) 64 and IA-32 Architectures Software Developer's Manual, Volume 3, - September 2016, Chapter 35 Model-Specific-Registers (MSR), Section 35.17. - -**/ - -#ifndef __XEON_PHI_MSR_H__ -#define __XEON_PHI_MSR_H__ - -#include - -/** - Is Intel(R) Xeon(R) Phi(TM) processor Family? - - @param DisplayFamily Display Family ID - @param DisplayModel Display Model ID - - @retval TRUE Yes, it is. - @retval FALSE No, it isn't. -**/ -#define IS_XEON_PHI_PROCESSOR(DisplayFamily, DisplayModel) \ - (DisplayFamily == 0x06 && \ - ( \ - DisplayModel == 0x57 \ - ) \ - ) - -/** - Thread. SMI Counter (R/O). - - @param ECX MSR_XEON_PHI_SMI_COUNT (0x00000034) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_SMI_COUNT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_SMI_COUNT_REGISTER. - - Example usage - @code - MSR_XEON_PHI_SMI_COUNT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_SMI_COUNT); - @endcode - @note MSR_XEON_PHI_SMI_COUNT is defined as MSR_SMI_COUNT in SDM. -**/ -#define MSR_XEON_PHI_SMI_COUNT 0x00000034 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_SMI_COUNT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 31:0] SMI Count (R/O). - /// - UINT32 SMICount:32; - UINT32 Reserved:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_SMI_COUNT_REGISTER; - - -/** - Package. See http://biosbits.org. - - @param ECX MSR_XEON_PHI_PLATFORM_INFO (0x000000CE) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PLATFORM_INFO_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PLATFORM_INFO_REGISTER. - - Example usage - @code - MSR_XEON_PHI_PLATFORM_INFO_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PLATFORM_INFO); - AsmWriteMsr64 (MSR_XEON_PHI_PLATFORM_INFO, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_PLATFORM_INFO is defined as MSR_PLATFORM_INFO in SDM. -**/ -#define MSR_XEON_PHI_PLATFORM_INFO 0x000000CE - -/** - MSR information returned for MSR index #MSR_XEON_PHI_PLATFORM_INFO -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:8; - /// - /// [Bits 15:8] Package. Maximum Non-Turbo Ratio (R/O) The is the ratio - /// of the frequency that invariant TSC runs at. Frequency = ratio * 100 - /// MHz. - /// - UINT32 MaximumNonTurboRatio:8; - UINT32 Reserved2:12; - /// - /// [Bit 28] Package. Programmable Ratio Limit for Turbo Mode (R/O) When - /// set to 1, indicates that Programmable Ratio Limits for Turbo mode is - /// enabled, and when set to 0, indicates Programmable Ratio Limits for - /// Turbo mode is disabled. - /// - UINT32 RatioLimit:1; - /// - /// [Bit 29] Package. Programmable TDP Limit for Turbo Mode (R/O) When - /// set to 1, indicates that TDP Limits for Turbo mode are programmable, - /// and when set to 0, indicates TDP Limit for Turbo mode is not - /// programmable. - /// - UINT32 TDPLimit:1; - UINT32 Reserved3:2; - UINT32 Reserved4:8; - /// - /// [Bits 47:40] Package. Maximum Efficiency Ratio (R/O) The is the - /// minimum ratio (maximum efficiency) that the processor can operates, in - /// units of 100MHz. - /// - UINT32 MaximumEfficiencyRatio:8; - UINT32 Reserved5:16; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_PLATFORM_INFO_REGISTER; - - -/** - Module. C-State Configuration Control (R/W). - - @param ECX MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL (0x000000E2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER. - - Example usage - @code - MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL is defined as MSR_PKG_CST_CONFIG_CONTROL in SDM. -**/ -#define MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL 0x000000E2 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 2:0] Package C-State Limit (R/W) The following C-state code - /// name encodings are supported: 000b: C0/C1 001b: C2 010b: C6 No - /// Retention 011b: C6 Retention 111b: No limit. - /// - UINT32 Limit:3; - UINT32 Reserved1:7; - /// - /// [Bit 10] I/O MWAIT Redirection Enable (R/W). - /// - UINT32 IO_MWAIT:1; - UINT32 Reserved2:4; - /// - /// [Bit 15] CFG Lock (R/WO). - /// - UINT32 CFGLock:1; - UINT32 Reserved3:16; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_PKG_CST_CONFIG_CONTROL_REGISTER; - - -/** - Module. Power Management IO Redirection in C-state (R/W). - - @param ECX MSR_XEON_PHI_PMG_IO_CAPTURE_BASE (0x000000E4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER. - - Example usage - @code - MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_PMG_IO_CAPTURE_BASE); - AsmWriteMsr64 (MSR_XEON_PHI_PMG_IO_CAPTURE_BASE, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_PMG_IO_CAPTURE_BASE is defined as MSR_PMG_IO_CAPTURE_BASE in SDM. -**/ -#define MSR_XEON_PHI_PMG_IO_CAPTURE_BASE 0x000000E4 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_PMG_IO_CAPTURE_BASE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 15:0] LVL_2 Base Address (R/W). - /// - UINT32 Lvl2Base:16; - /// - /// [Bits 18:16] C-state Range (R/W) Specifies the encoding value of the - /// maximum C-State code name to be included when IO read to MWAIT - /// redirection is enabled by MSR_PKG_CST_CONFIG_CONTROL[bit10]: 100b - C4 - /// is the max C-State to include 110b - C6 is the max C-State to include. - /// - UINT32 CStateRange:3; - UINT32 Reserved1:13; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_PMG_IO_CAPTURE_BASE_REGISTER; - - -/** - Core. AES Configuration (RW-L) Privileged post-BIOS agent must provide a #GP - handler to handle unsuccessful read of this MSR. - - @param ECX MSR_XEON_PHI_FEATURE_CONFIG (0x0000013C) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_FEATURE_CONFIG_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_FEATURE_CONFIG_REGISTER. - - Example usage - @code - MSR_XEON_PHI_FEATURE_CONFIG_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_FEATURE_CONFIG); - AsmWriteMsr64 (MSR_XEON_PHI_FEATURE_CONFIG, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_FEATURE_CONFIG is defined as MSR_FEATURE_CONFIG in SDM. -**/ -#define MSR_XEON_PHI_FEATURE_CONFIG 0x0000013C - -/** - MSR information returned for MSR index #MSR_XEON_PHI_FEATURE_CONFIG -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 1:0] AES Configuration (RW-L) Upon a successful read of this - /// MSR, the configuration of AES instruction set availability is as - /// follows: 11b: AES instructions are not available until next RESET. - /// otherwise, AES instructions are available. Note, AES instruction set - /// is not available if read is unsuccessful. If the configuration is not - /// 01b, AES instruction can be mis-configured if a privileged agent - /// unintentionally writes 11b. - /// - UINT32 AESConfiguration:2; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_FEATURE_CONFIG_REGISTER; - - -/** - THREAD. Enhanced SMM Capabilities (SMM-RO) Reports SMM capability - Enhancement. Accessible only while in SMM. - - @param ECX MSR_XEON_PHI_SMM_MCA_CAP (0x0000017D) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_SMM_MCA_CAP_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_SMM_MCA_CAP_REGISTER. - - Example usage - @code - MSR_XEON_PHI_SMM_MCA_CAP_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_SMM_MCA_CAP); - AsmWriteMsr64 (MSR_XEON_PHI_SMM_MCA_CAP, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_SMM_MCA_CAP is defined as MSR_SMM_MCA_CAP in SDM. -**/ -#define MSR_XEON_PHI_SMM_MCA_CAP 0x0000017D - -/** - MSR information returned for MSR index #MSR_XEON_PHI_SMM_MCA_CAP -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:32; - UINT32 Reserved2:26; - /// - /// [Bit 58] SMM_Code_Access_Chk (SMM-RO) If set to 1 indicates that the - /// SMM code access restriction is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 SMM_Code_Access_Chk:1; - /// - /// [Bit 59] Long_Flow_Indication (SMM-RO) If set to 1 indicates that the - /// SMM long flow indicator is supported and a host-space interface - /// available to SMM handler. - /// - UINT32 Long_Flow_Indication:1; - UINT32 Reserved3:4; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_SMM_MCA_CAP_REGISTER; - - -/** - Thread. Enable Misc. Processor Features (R/W) Allows a variety of processor - functions to be enabled and disabled. - - @param ECX MSR_XEON_PHI_IA32_MISC_ENABLE (0x000001A0) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER. - - Example usage - @code - MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_IA32_MISC_ENABLE); - AsmWriteMsr64 (MSR_XEON_PHI_IA32_MISC_ENABLE, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_IA32_MISC_ENABLE is defined as IA32_MISC_ENABLE in SDM. -**/ -#define MSR_XEON_PHI_IA32_MISC_ENABLE 0x000001A0 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_IA32_MISC_ENABLE -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Fast-Strings Enable. - /// - UINT32 FastStrings:1; - UINT32 Reserved1:2; - /// - /// [Bit 3] Automatic Thermal Control Circuit Enable (R/W) Default value - /// is 1. - /// - UINT32 AutomaticThermalControlCircuit:1; - UINT32 Reserved2:3; - /// - /// [Bit 7] Performance Monitoring Available (R). - /// - UINT32 PerformanceMonitoring:1; - UINT32 Reserved3:3; - /// - /// [Bit 11] Branch Trace Storage Unavailable (RO). - /// - UINT32 BTS:1; - /// - /// [Bit 12] Processor Event Based Sampling Unavailable (RO). - /// - UINT32 PEBS:1; - UINT32 Reserved4:3; - /// - /// [Bit 16] Enhanced Intel SpeedStep Technology Enable (R/W). - /// - UINT32 EIST:1; - UINT32 Reserved5:1; - /// - /// [Bit 18] ENABLE MONITOR FSM (R/W). - /// - UINT32 MONITOR:1; - UINT32 Reserved6:3; - /// - /// [Bit 22] Limit CPUID Maxval (R/W). - /// - UINT32 LimitCpuidMaxval:1; - /// - /// [Bit 23] xTPR Message Disable (R/W). - /// - UINT32 xTPR_Message_Disable:1; - UINT32 Reserved7:8; - UINT32 Reserved8:2; - /// - /// [Bit 34] XD Bit Disable (R/W). - /// - UINT32 XD:1; - UINT32 Reserved9:3; - /// - /// [Bit 38] Turbo Mode Disable (R/W). - /// - UINT32 TurboModeDisable:1; - UINT32 Reserved10:25; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_IA32_MISC_ENABLE_REGISTER; - - -/** - Package. - - @param ECX MSR_XEON_PHI_TEMPERATURE_TARGET (0x000001A2) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER. - - Example usage - @code - MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_TEMPERATURE_TARGET); - AsmWriteMsr64 (MSR_XEON_PHI_TEMPERATURE_TARGET, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_TEMPERATURE_TARGET is defined as MSR_TEMPERATURE_TARGET in SDM. -**/ -#define MSR_XEON_PHI_TEMPERATURE_TARGET 0x000001A2 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_TEMPERATURE_TARGET -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved1:16; - /// - /// [Bits 23:16] Temperature Target (R). - /// - UINT32 TemperatureTarget:8; - /// - /// [Bits 29:24] Target Offset (R/W). - /// - UINT32 TargetOffset:6; - UINT32 Reserved2:2; - UINT32 Reserved3:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_TEMPERATURE_TARGET_REGISTER; - - -/** - Miscellaneous Feature Control (R/W). - - @param ECX MSR_XEON_PHI_MISC_FEATURE_CONTROL (0x000001A4) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER. - - Example usage - @code - MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_MISC_FEATURE_CONTROL); - AsmWriteMsr64 (MSR_XEON_PHI_MISC_FEATURE_CONTROL, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_MISC_FEATURE_CONTROL is defined as MSR_MISC_FEATURE_CONTROL in SDM. -**/ -#define MSR_XEON_PHI_MISC_FEATURE_CONTROL 0x000001A4 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_MISC_FEATURE_CONTROL -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] Core. DCU Hardware Prefetcher Disable (R/W) If 1, disables the - /// L1 data cache prefetcher. - /// - UINT32 DCUHardwarePrefetcherDisable:1; - /// - /// [Bit 1] Core. L2 Hardware Prefetcher Disable (R/W) If 1, disables the - /// L2 hardware prefetcher. - /// - UINT32 L2HardwarePrefetcherDisable:1; - UINT32 Reserved1:30; - UINT32 Reserved2:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_MISC_FEATURE_CONTROL_REGISTER; - - -/** - Shared. Offcore Response Event Select Register (R/W). - - @param ECX MSR_XEON_PHI_OFFCORE_RSP_0 (0x000001A6) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_OFFCORE_RSP_0); - AsmWriteMsr64 (MSR_XEON_PHI_OFFCORE_RSP_0, Msr); - @endcode - @note MSR_XEON_PHI_OFFCORE_RSP_0 is defined as MSR_OFFCORE_RSP_0 in SDM. -**/ -#define MSR_XEON_PHI_OFFCORE_RSP_0 0x000001A6 - - -/** - Shared. Offcore Response Event Select Register (R/W). - - @param ECX MSR_XEON_PHI_OFFCORE_RSP_1 (0x000001A7) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_OFFCORE_RSP_1); - AsmWriteMsr64 (MSR_XEON_PHI_OFFCORE_RSP_1, Msr); - @endcode - @note MSR_XEON_PHI_OFFCORE_RSP_1 is defined as MSR_OFFCORE_RSP_1 in SDM. -**/ -#define MSR_XEON_PHI_OFFCORE_RSP_1 0x000001A7 - - -/** - Package. Maximum Ratio Limit of Turbo Mode for Groups of Cores (RW). - - @param ECX MSR_XEON_PHI_TURBO_RATIO_LIMIT (0x000001AD) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER. - - Example usage - @code - MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_TURBO_RATIO_LIMIT); - AsmWriteMsr64 (MSR_XEON_PHI_TURBO_RATIO_LIMIT, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_TURBO_RATIO_LIMIT is defined as MSR_TURBO_RATIO_LIMIT in SDM. -**/ -#define MSR_XEON_PHI_TURBO_RATIO_LIMIT 0x000001AD - -/** - MSR information returned for MSR index #MSR_XEON_PHI_TURBO_RATIO_LIMIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - UINT32 Reserved:1; - /// - /// [Bits 7:1] Package. Maximum Number of Cores in Group 0 Number active - /// processor cores which operates under the maximum ratio limit for group - /// 0. - /// - UINT32 MaxCoresGroup0:7; - /// - /// [Bits 15:8] Package. Maximum Ratio Limit for Group 0 Maximum turbo - /// ratio limit when the number of active cores are not more than the - /// group 0 maximum core count. - /// - UINT32 MaxRatioLimitGroup0:8; - /// - /// [Bits 20:16] Package. Number of Incremental Cores Added to Group 1 - /// Group 1, which includes the specified number of additional cores plus - /// the cores in group 0, operates under the group 1 turbo max ratio limit - /// = "group 0 Max ratio limit" - "group ratio delta for group 1". - /// - UINT32 MaxIncrementalCoresGroup1:5; - /// - /// [Bits 23:21] Package. Group Ratio Delta for Group 1 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// to Group 0. - /// - UINT32 DeltaRatioGroup1:3; - /// - /// [Bits 28:24] Package. Number of Incremental Cores Added to Group 2 - /// Group 2, which includes the specified number of additional cores plus - /// all the cores in group 1, operates under the group 2 turbo max ratio - /// limit = "group 1 Max ratio limit" - "group ratio delta for group 2". - /// - UINT32 MaxIncrementalCoresGroup2:5; - /// - /// [Bits 31:29] Package. Group Ratio Delta for Group 2 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// for Group 1. - /// - UINT32 DeltaRatioGroup2:3; - /// - /// [Bits 36:32] Package. Number of Incremental Cores Added to Group 3 - /// Group 3, which includes the specified number of additional cores plus - /// all the cores in group 2, operates under the group 3 turbo max ratio - /// limit = "group 2 Max ratio limit" - "group ratio delta for group 3". - /// - UINT32 MaxIncrementalCoresGroup3:5; - /// - /// [Bits 39:37] Package. Group Ratio Delta for Group 3 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// for Group 2. - /// - UINT32 DeltaRatioGroup3:3; - /// - /// [Bits 44:40] Package. Number of Incremental Cores Added to Group 4 - /// Group 4, which includes the specified number of additional cores plus - /// all the cores in group 3, operates under the group 4 turbo max ratio - /// limit = "group 3 Max ratio limit" - "group ratio delta for group 4". - /// - UINT32 MaxIncrementalCoresGroup4:5; - /// - /// [Bits 47:45] Package. Group Ratio Delta for Group 4 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// for Group 3. - /// - UINT32 DeltaRatioGroup4:3; - /// - /// [Bits 52:48] Package. Number of Incremental Cores Added to Group 5 - /// Group 5, which includes the specified number of additional cores plus - /// all the cores in group 4, operates under the group 5 turbo max ratio - /// limit = "group 4 Max ratio limit" - "group ratio delta for group 5". - /// - UINT32 MaxIncrementalCoresGroup5:5; - /// - /// [Bits 55:53] Package. Group Ratio Delta for Group 5 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// for Group 4. - /// - UINT32 DeltaRatioGroup5:3; - /// - /// [Bits 60:56] Package. Number of Incremental Cores Added to Group 6 - /// Group 6, which includes the specified number of additional cores plus - /// all the cores in group 5, operates under the group 6 turbo max ratio - /// limit = "group 5 Max ratio limit" - "group ratio delta for group 6". - /// - UINT32 MaxIncrementalCoresGroup6:5; - /// - /// [Bits 63:61] Package. Group Ratio Delta for Group 6 An unsigned - /// integer specifying the ratio decrement relative to the Max ratio limit - /// for Group 5. - /// - UINT32 DeltaRatioGroup6:3; - } Bits; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_TURBO_RATIO_LIMIT_REGISTER; - - -/** - Thread. Last Branch Record Filtering Select Register (R/W). - - @param ECX MSR_XEON_PHI_LBR_SELECT (0x000001C8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_LBR_SELECT); - AsmWriteMsr64 (MSR_XEON_PHI_LBR_SELECT, Msr); - @endcode - @note MSR_XEON_PHI_LBR_SELECT is defined as MSR_LBR_SELECT in SDM. -**/ -#define MSR_XEON_PHI_LBR_SELECT 0x000001C8 - - -/** - Thread. Last Branch Record Stack TOS (R/W). - - @param ECX MSR_XEON_PHI_LASTBRANCH_TOS (0x000001C9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_LASTBRANCH_TOS); - AsmWriteMsr64 (MSR_XEON_PHI_LASTBRANCH_TOS, Msr); - @endcode - @note MSR_XEON_PHI_LASTBRANCH_TOS is defined as MSR_LASTBRANCH_TOS in SDM. -**/ -#define MSR_XEON_PHI_LASTBRANCH_TOS 0x000001C9 - - -/** - Thread. Last Exception Record From Linear IP (R). - - @param ECX MSR_XEON_PHI_LER_FROM_LIP (0x000001DD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_LER_FROM_LIP); - @endcode - @note MSR_XEON_PHI_LER_FROM_LIP is defined as MSR_LER_FROM_LIP in SDM. -**/ -#define MSR_XEON_PHI_LER_FROM_LIP 0x000001DD - - -/** - Thread. Last Exception Record To Linear IP (R). - - @param ECX MSR_XEON_PHI_LER_TO_LIP (0x000001DE) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_LER_TO_LIP); - @endcode - @note MSR_XEON_PHI_LER_TO_LIP is defined as MSR_LER_TO_LIP in SDM. -**/ -#define MSR_XEON_PHI_LER_TO_LIP 0x000001DE - - -/** - Thread. See Table 35-2. - - @param ECX MSR_XEON_PHI_PEBS_ENABLE (0x000003F1) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PEBS_ENABLE); - AsmWriteMsr64 (MSR_XEON_PHI_PEBS_ENABLE, Msr); - @endcode - @note MSR_XEON_PHI_PEBS_ENABLE is defined as MSR_PEBS_ENABLE in SDM. -**/ -#define MSR_XEON_PHI_PEBS_ENABLE 0x000003F1 - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. Package C3 - Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_PKG_C3_RESIDENCY (0x000003F8) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C3_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_C3_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_PKG_C3_RESIDENCY is defined as MSR_PKG_C3_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_PKG_C3_RESIDENCY 0x000003F8 - - -/** - Package. Package C6 Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_PKG_C6_RESIDENCY (0x000003F9) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C6_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_C6_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_PKG_C6_RESIDENCY is defined as MSR_PKG_C6_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_PKG_C6_RESIDENCY 0x000003F9 - - -/** - Package. Package C7 Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_PKG_C7_RESIDENCY (0x000003FA) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C7_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_C7_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_PKG_C7_RESIDENCY is defined as MSR_PKG_C7_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_PKG_C7_RESIDENCY 0x000003FA - - -/** - Module. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. Module C0 - Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_MC0_RESIDENCY (0x000003FC) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_MC0_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_MC0_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_MC0_RESIDENCY is defined as MSR_MC0_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_MC0_RESIDENCY 0x000003FC - - -/** - Module. Module C6 Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_MC6_RESIDENCY (0x000003FD) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_MC6_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_MC6_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_MC6_RESIDENCY is defined as MSR_MC6_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_MC6_RESIDENCY 0x000003FD - - -/** - Core. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. CORE C6 - Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_CORE_C6_RESIDENCY (0x000003FF) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_CORE_C6_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_CORE_C6_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_CORE_C6_RESIDENCY is defined as MSR_CORE_C6_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_CORE_C6_RESIDENCY 0x000003FF - - -/** - Core. Capability Reporting Register of EPT and VPID (R/O) See Table 35-2. - - @param ECX MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM (0x0000048C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM); - @endcode - @note MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM is defined as IA32_VMX_EPT_VPID_ENUM in SDM. -**/ -#define MSR_XEON_PHI_IA32_VMX_EPT_VPID_ENUM 0x0000048C - - -/** - Core. Capability Reporting Register of VM-function Controls (R/O) See Table - 35-2. - - @param ECX MSR_XEON_PHI_IA32_VMX_FMFUNC (0x00000491) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_IA32_VMX_FMFUNC); - @endcode - @note MSR_XEON_PHI_IA32_VMX_FMFUNC is defined as IA32_VMX_FMFUNC in SDM. -**/ -#define MSR_XEON_PHI_IA32_VMX_FMFUNC 0x00000491 - - -/** - Package. Unit Multipliers used in RAPL Interfaces (R/O). - - @param ECX MSR_XEON_PHI_RAPL_POWER_UNIT (0x00000606) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER. - - Example usage - @code - MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_RAPL_POWER_UNIT); - @endcode - @note MSR_XEON_PHI_RAPL_POWER_UNIT is defined as MSR_RAPL_POWER_UNIT in SDM. -**/ -#define MSR_XEON_PHI_RAPL_POWER_UNIT 0x00000606 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_RAPL_POWER_UNIT -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bits 3:0] Package. Power Units See Section 14.9.1, "RAPL Interfaces.". - /// - UINT32 PowerUnits:4; - UINT32 Reserved1:4; - /// - /// [Bits 12:8] Package. Energy Status Units Energy related information - /// (in Joules) is based on the multiplier, 1/2^ESU; where ESU is an - /// unsigned integer represented by bits 12:8. Default value is 0EH (or 61 - /// micro-joules). - /// - UINT32 EnergyStatusUnits:5; - UINT32 Reserved2:3; - /// - /// [Bits 19:16] Package. Time Units See Section 14.9.1, "RAPL - /// Interfaces.". - /// - UINT32 TimeUnits:4; - UINT32 Reserved3:12; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_RAPL_POWER_UNIT_REGISTER; - - -/** - Package. Note: C-state values are processor specific C-state code names, - unrelated to MWAIT extension C-state parameters or ACPI C-States. Package C2 - Residency Counter. (R/O). - - @param ECX MSR_XEON_PHI_PKG_C2_RESIDENCY (0x0000060D) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_C2_RESIDENCY); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_C2_RESIDENCY, Msr); - @endcode - @note MSR_XEON_PHI_PKG_C2_RESIDENCY is defined as MSR_PKG_C2_RESIDENCY in SDM. -**/ -#define MSR_XEON_PHI_PKG_C2_RESIDENCY 0x0000060D - - -/** - Package. PKG RAPL Power Limit Control (R/W) See Section 14.9.3, "Package - RAPL Domain.". - - @param ECX MSR_XEON_PHI_PKG_POWER_LIMIT (0x00000610) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_POWER_LIMIT); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_POWER_LIMIT, Msr); - @endcode - @note MSR_XEON_PHI_PKG_POWER_LIMIT is defined as MSR_PKG_POWER_LIMIT in SDM. -**/ -#define MSR_XEON_PHI_PKG_POWER_LIMIT 0x00000610 - - -/** - Package. PKG Energy Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_XEON_PHI_PKG_ENERGY_STATUS (0x00000611) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_ENERGY_STATUS); - @endcode - @note MSR_XEON_PHI_PKG_ENERGY_STATUS is defined as MSR_PKG_ENERGY_STATUS in SDM. -**/ -#define MSR_XEON_PHI_PKG_ENERGY_STATUS 0x00000611 - - -/** - Package. PKG Perf Status (R/O) See Section 14.9.3, "Package RAPL Domain.". - - @param ECX MSR_XEON_PHI_PKG_PERF_STATUS (0x00000613) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_PERF_STATUS); - @endcode - @note MSR_XEON_PHI_PKG_PERF_STATUS is defined as MSR_PKG_PERF_STATUS in SDM. -**/ -#define MSR_XEON_PHI_PKG_PERF_STATUS 0x00000613 - - -/** - Package. PKG RAPL Parameters (R/W) See Section 14.9.3, "Package RAPL - Domain.". - - @param ECX MSR_XEON_PHI_PKG_POWER_INFO (0x00000614) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PKG_POWER_INFO); - AsmWriteMsr64 (MSR_XEON_PHI_PKG_POWER_INFO, Msr); - @endcode - @note MSR_XEON_PHI_PKG_POWER_INFO is defined as MSR_PKG_POWER_INFO in SDM. -**/ -#define MSR_XEON_PHI_PKG_POWER_INFO 0x00000614 - - -/** - Package. DRAM RAPL Power Limit Control (R/W) See Section 14.9.5, "DRAM RAPL - Domain.". - - @param ECX MSR_XEON_PHI_DRAM_POWER_LIMIT (0x00000618) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_POWER_LIMIT); - AsmWriteMsr64 (MSR_XEON_PHI_DRAM_POWER_LIMIT, Msr); - @endcode - @note MSR_XEON_PHI_DRAM_POWER_LIMIT is defined as MSR_DRAM_POWER_LIMIT in SDM. -**/ -#define MSR_XEON_PHI_DRAM_POWER_LIMIT 0x00000618 - - -/** - Package. DRAM Energy Status (R/O) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_XEON_PHI_DRAM_ENERGY_STATUS (0x00000619) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_ENERGY_STATUS); - @endcode - @note MSR_XEON_PHI_DRAM_ENERGY_STATUS is defined as MSR_DRAM_ENERGY_STATUS in SDM. -**/ -#define MSR_XEON_PHI_DRAM_ENERGY_STATUS 0x00000619 - - -/** - Package. DRAM Performance Throttling Status (R/O) See Section 14.9.5, "DRAM - RAPL Domain.". - - @param ECX MSR_XEON_PHI_DRAM_PERF_STATUS (0x0000061B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_PERF_STATUS); - @endcode - @note MSR_XEON_PHI_DRAM_PERF_STATUS is defined as MSR_DRAM_PERF_STATUS in SDM. -**/ -#define MSR_XEON_PHI_DRAM_PERF_STATUS 0x0000061B - - -/** - Package. DRAM RAPL Parameters (R/W) See Section 14.9.5, "DRAM RAPL Domain.". - - @param ECX MSR_XEON_PHI_DRAM_POWER_INFO (0x0000061C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_DRAM_POWER_INFO); - AsmWriteMsr64 (MSR_XEON_PHI_DRAM_POWER_INFO, Msr); - @endcode - @note MSR_XEON_PHI_DRAM_POWER_INFO is defined as MSR_DRAM_POWER_INFO in SDM. -**/ -#define MSR_XEON_PHI_DRAM_POWER_INFO 0x0000061C - - -/** - Package. PP0 RAPL Power Limit Control (R/W) See Section 14.9.4, "PP0/PP1 - RAPL Domains.". - - @param ECX MSR_XEON_PHI_PP0_POWER_LIMIT (0x00000638) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PP0_POWER_LIMIT); - AsmWriteMsr64 (MSR_XEON_PHI_PP0_POWER_LIMIT, Msr); - @endcode - @note MSR_XEON_PHI_PP0_POWER_LIMIT is defined as MSR_PP0_POWER_LIMIT in SDM. -**/ -#define MSR_XEON_PHI_PP0_POWER_LIMIT 0x00000638 - - -/** - Package. PP0 Energy Status (R/O) See Section 14.9.4, "PP0/PP1 RAPL - Domains.". - - @param ECX MSR_XEON_PHI_PP0_ENERGY_STATUS (0x00000639) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_PP0_ENERGY_STATUS); - @endcode - @note MSR_XEON_PHI_PP0_ENERGY_STATUS is defined as MSR_PP0_ENERGY_STATUS in SDM. -**/ -#define MSR_XEON_PHI_PP0_ENERGY_STATUS 0x00000639 - - -/** - Package. Base TDP Ratio (R/O) See Table 35-23. - - @param ECX MSR_XEON_PHI_CONFIG_TDP_NOMINAL (0x00000648) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_NOMINAL); - @endcode - @note MSR_XEON_PHI_CONFIG_TDP_NOMINAL is defined as MSR_CONFIG_TDP_NOMINAL in SDM. -**/ -#define MSR_XEON_PHI_CONFIG_TDP_NOMINAL 0x00000648 - - -/** - Package. ConfigTDP Level 1 ratio and power level (R/O). See Table 35-23. - - @param ECX MSR_XEON_PHI_CONFIG_TDP_LEVEL1 (0x00000649) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_LEVEL1); - @endcode - @note MSR_XEON_PHI_CONFIG_TDP_LEVEL1 is defined as MSR_CONFIG_TDP_LEVEL1 in SDM. -**/ -#define MSR_XEON_PHI_CONFIG_TDP_LEVEL1 0x00000649 - - -/** - Package. ConfigTDP Level 2 ratio and power level (R/O). See Table 35-23. - - @param ECX MSR_XEON_PHI_CONFIG_TDP_LEVEL2 (0x0000064A) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_LEVEL2); - @endcode - @note MSR_XEON_PHI_CONFIG_TDP_LEVEL2 is defined as MSR_CONFIG_TDP_LEVEL2 in SDM. -**/ -#define MSR_XEON_PHI_CONFIG_TDP_LEVEL2 0x0000064A - - -/** - Package. ConfigTDP Control (R/W) See Table 35-23. - - @param ECX MSR_XEON_PHI_CONFIG_TDP_CONTROL (0x0000064B) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_CONFIG_TDP_CONTROL); - AsmWriteMsr64 (MSR_XEON_PHI_CONFIG_TDP_CONTROL, Msr); - @endcode - @note MSR_XEON_PHI_CONFIG_TDP_CONTROL is defined as MSR_CONFIG_TDP_CONTROL in SDM. -**/ -#define MSR_XEON_PHI_CONFIG_TDP_CONTROL 0x0000064B - - -/** - Package. ConfigTDP Control (R/W) See Table 35-23. - - @param ECX MSR_XEON_PHI_TURBO_ACTIVATION_RATIO (0x0000064C) - @param EAX Lower 32-bits of MSR value. - @param EDX Upper 32-bits of MSR value. - - Example usage - @code - UINT64 Msr; - - Msr = AsmReadMsr64 (MSR_XEON_PHI_TURBO_ACTIVATION_RATIO); - AsmWriteMsr64 (MSR_XEON_PHI_TURBO_ACTIVATION_RATIO, Msr); - @endcode - @note MSR_XEON_PHI_TURBO_ACTIVATION_RATIO is defined as MSR_TURBO_ACTIVATION_RATIO in SDM. -**/ -#define MSR_XEON_PHI_TURBO_ACTIVATION_RATIO 0x0000064C - - -/** - Package. Indicator of Frequency Clipping in Processor Cores (R/W) (frequency - refers to processor core frequency). - - @param ECX MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS (0x00000690) - @param EAX Lower 32-bits of MSR value. - Described by the type MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER. - @param EDX Upper 32-bits of MSR value. - Described by the type MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER. - - Example usage - @code - MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER Msr; - - Msr.Uint64 = AsmReadMsr64 (MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS); - AsmWriteMsr64 (MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS, Msr.Uint64); - @endcode - @note MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS is defined as MSR_CORE_PERF_LIMIT_REASONS in SDM. -**/ -#define MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS 0x00000690 - -/** - MSR information returned for MSR index #MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS -**/ -typedef union { - /// - /// Individual bit fields - /// - struct { - /// - /// [Bit 0] PROCHOT Status (R0). - /// - UINT32 PROCHOT_Status:1; - /// - /// [Bit 1] Thermal Status (R0). - /// - UINT32 ThermalStatus:1; - UINT32 Reserved1:4; - /// - /// [Bit 6] VR Therm Alert Status (R0). - /// - UINT32 VRThermAlertStatus:1; - UINT32 Reserved2:1; - /// - /// [Bit 8] Electrical Design Point Status (R0). - /// - UINT32 ElectricalDesignPointStatus:1; - UINT32 Reserved3:23; - UINT32 Reserved4:32; - } Bits; - /// - /// All bit fields as a 32-bit value - /// - UINT32 Uint32; - /// - /// All bit fields as a 64-bit value - /// - UINT64 Uint64; -} MSR_XEON_PHI_CORE_PERF_LIMIT_REASONS_REGISTER; - -#endif diff --git a/UefiCpuPkg/Include/Register/SmramSaveStateMap.h b/UefiCpuPkg/Include/Register/SmramSaveStateMap.h deleted file mode 100644 index a7c7562df8..0000000000 --- a/UefiCpuPkg/Include/Register/SmramSaveStateMap.h +++ /dev/null @@ -1,190 +0,0 @@ -/** @file -SMRAM Save State Map Definitions. - -SMRAM Save State Map definitions based on contents of the -Intel(R) 64 and IA-32 Architectures Software Developer's Manual - Volume 3C, Section 34.4 SMRAM - Volume 3C, Section 34.5 SMI Handler Execution Environment - Volume 3C, Section 34.7 Managing Synchronous and Asynchronous SMIs - -Copyright (c) 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __SMRAM_SAVE_STATE_MAP_H__ -#define __SMRAM_SAVE_STATE_MAP_H__ - -/// -/// Default SMBASE address -/// -#define SMM_DEFAULT_SMBASE 0x30000 - -/// -/// Offset of SMM handler from SMBASE -/// -#define SMM_HANDLER_OFFSET 0x8000 - -/// -/// Offset of SMRAM Save State Map from SMBASE -/// -#define SMRAM_SAVE_STATE_MAP_OFFSET 0xfc00 - -#pragma pack (1) - -/// -/// 32-bit SMRAM Save State Map -/// -typedef struct { - UINT8 Reserved[0x200]; // 7c00h - // Padded an extra 0x200 bytes so 32-bit and 64-bit - // SMRAM Save State Maps are the same size - UINT8 Reserved1[0xf8]; // 7e00h - UINT32 SMBASE; // 7ef8h - UINT32 SMMRevId; // 7efch - UINT16 IORestart; // 7f00h - UINT16 AutoHALTRestart; // 7f02h - UINT8 Reserved2[0x9C]; // 7f08h - UINT32 IOMemAddr; // 7fa0h - UINT32 IOMisc; // 7fa4h - UINT32 _ES; // 7fa8h - UINT32 _CS; // 7fach - UINT32 _SS; // 7fb0h - UINT32 _DS; // 7fb4h - UINT32 _FS; // 7fb8h - UINT32 _GS; // 7fbch - UINT32 Reserved3; // 7fc0h - UINT32 _TR; // 7fc4h - UINT32 _DR7; // 7fc8h - UINT32 _DR6; // 7fcch - UINT32 _EAX; // 7fd0h - UINT32 _ECX; // 7fd4h - UINT32 _EDX; // 7fd8h - UINT32 _EBX; // 7fdch - UINT32 _ESP; // 7fe0h - UINT32 _EBP; // 7fe4h - UINT32 _ESI; // 7fe8h - UINT32 _EDI; // 7fech - UINT32 _EIP; // 7ff0h - UINT32 _EFLAGS; // 7ff4h - UINT32 _CR3; // 7ff8h - UINT32 _CR0; // 7ffch -} SMRAM_SAVE_STATE_MAP32; - -/// -/// 64-bit SMRAM Save State Map -/// -typedef struct { - UINT8 Reserved1[0x1d0]; // 7c00h - UINT32 GdtBaseHiDword; // 7dd0h - UINT32 LdtBaseHiDword; // 7dd4h - UINT32 IdtBaseHiDword; // 7dd8h - UINT8 Reserved2[0xc]; // 7ddch - UINT64 IO_EIP; // 7de8h - UINT8 Reserved3[0x50]; // 7df0h - UINT32 _CR4; // 7e40h - UINT8 Reserved4[0x48]; // 7e44h - UINT32 GdtBaseLoDword; // 7e8ch - UINT32 Reserved5; // 7e90h - UINT32 IdtBaseLoDword; // 7e94h - UINT32 Reserved6; // 7e98h - UINT32 LdtBaseLoDword; // 7e9ch - UINT8 Reserved7[0x38]; // 7ea0h - UINT64 EptVmxControl; // 7ed8h - UINT32 EnEptVmxControl; // 7ee0h - UINT8 Reserved8[0x14]; // 7ee4h - UINT32 SMBASE; // 7ef8h - UINT32 SMMRevId; // 7efch - UINT16 IORestart; // 7f00h - UINT16 AutoHALTRestart; // 7f02h - UINT8 Reserved9[0x18]; // 7f04h - UINT64 _R15; // 7f1ch - UINT64 _R14; - UINT64 _R13; - UINT64 _R12; - UINT64 _R11; - UINT64 _R10; - UINT64 _R9; - UINT64 _R8; - UINT64 _RAX; // 7f5ch - UINT64 _RCX; - UINT64 _RDX; - UINT64 _RBX; - UINT64 _RSP; - UINT64 _RBP; - UINT64 _RSI; - UINT64 _RDI; - UINT64 IOMemAddr; // 7f9ch - UINT32 IOMisc; // 7fa4h - UINT32 _ES; // 7fa8h - UINT32 _CS; - UINT32 _SS; - UINT32 _DS; - UINT32 _FS; - UINT32 _GS; - UINT32 _LDTR; // 7fc0h - UINT32 _TR; - UINT64 _DR7; // 7fc8h - UINT64 _DR6; - UINT64 _RIP; // 7fd8h - UINT64 IA32_EFER; // 7fe0h - UINT64 _RFLAGS; // 7fe8h - UINT64 _CR3; // 7ff0h - UINT64 _CR0; // 7ff8h -} SMRAM_SAVE_STATE_MAP64; - -/// -/// Union of 32-bit and 64-bit SMRAM Save State Maps -/// -typedef union { - SMRAM_SAVE_STATE_MAP32 x86; - SMRAM_SAVE_STATE_MAP64 x64; -} SMRAM_SAVE_STATE_MAP; - -/// -/// Minimum SMM Revision ID that supports IOMisc field in SMRAM Save State Map -/// -#define SMRAM_SAVE_STATE_MIN_REV_ID_IOMISC 0x30004 - -/// -/// SMRAM Save State Map IOMisc I/O Length Values -/// -#define SMM_IO_LENGTH_BYTE 0x01 -#define SMM_IO_LENGTH_WORD 0x02 -#define SMM_IO_LENGTH_DWORD 0x04 - -/// -/// SMRAM Save State Map IOMisc I/O Instruction Type Values -/// -#define SMM_IO_TYPE_IN_IMMEDIATE 0x9 -#define SMM_IO_TYPE_IN_DX 0x1 -#define SMM_IO_TYPE_OUT_IMMEDIATE 0x8 -#define SMM_IO_TYPE_OUT_DX 0x0 -#define SMM_IO_TYPE_INS 0x3 -#define SMM_IO_TYPE_OUTS 0x2 -#define SMM_IO_TYPE_REP_INS 0x7 -#define SMM_IO_TYPE_REP_OUTS 0x6 - -/// -/// SMRAM Save State Map IOMisc structure -/// -typedef union { - struct { - UINT32 SmiFlag:1; - UINT32 Length:3; - UINT32 Type:4; - UINT32 Reserved1:8; - UINT32 Port:16; - } Bits; - UINT32 Uint32; -} SMRAM_SAVE_STATE_IOMISC; - -#pragma pack () - -#endif diff --git a/UefiCpuPkg/Include/Register/StmApi.h b/UefiCpuPkg/Include/Register/StmApi.h deleted file mode 100644 index 6fb5971b44..0000000000 --- a/UefiCpuPkg/Include/Register/StmApi.h +++ /dev/null @@ -1,954 +0,0 @@ -/** @file - STM API definition - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - SMI Transfer Monitor (STM) User Guide Revision 1.00 - -**/ - -#ifndef _STM_API_H_ -#define _STM_API_H_ - -#include -#include -#include - -#pragma pack (1) - -/** - STM Header Structures -**/ - -typedef struct { - UINT32 Intel64ModeSupported :1; ///> bitfield - UINT32 EptSupported :1; ///> bitfield - UINT32 Reserved :30; ///> must be 0 -} STM_FEAT; - -#define STM_SPEC_VERSION_MAJOR 1 -#define STM_SPEC_VERSION_MINOR 0 - -typedef struct { - UINT8 StmSpecVerMajor; - UINT8 StmSpecVerMinor; - /// - /// Must be zero - /// - UINT16 Reserved; - UINT32 StaticImageSize; - UINT32 PerProcDynamicMemorySize; - UINT32 AdditionalDynamicMemorySize; - STM_FEAT StmFeatures; - UINT32 NumberOfRevIDs; - UINT32 StmSmmRevID[1]; - /// - /// The total STM_HEADER should be 4K. - /// -} SOFTWARE_STM_HEADER; - -typedef struct { - MSEG_HEADER HwStmHdr; - SOFTWARE_STM_HEADER SwStmHdr; -} STM_HEADER; - - -/** - VMCALL API Numbers - API number convention: BIOS facing VMCALL interfaces have bit 16 clear -**/ - -/** - StmMapAddressRange enables a SMM guest to create a non-1:1 virtual to - physical mapping of an address range into the SMM guest's virtual - memory space. - - @param EAX #STM_API_MAP_ADDRESS_RANGE (0x00000001) - @param EBX Low 32 bits of physical address of caller allocated - STM_MAP_ADDRESS_RANGE_DESCRIPTOR structure. - @param ECX High 32 bits of physical address of caller allocated - STM_MAP_ADDRESS_RANGE_DESCRIPTOR structure. If Intel64Mode is - clear (0), ECX must be 0. - - @note All fields of STM_MAP_ADDRESS_RANGE_DESCRIPTOR are inputs only. They - are not modified by StmMapAddressRange. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. - The memory range was mapped as requested. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_SECURITY_VIOLATION - The requested mapping contains a protected resource. - @retval EAX #ERROR_STM_CACHE_TYPE_NOT_SUPPORTED - The requested cache type could not be satisfied. - @retval EAX #ERROR_STM_PAGE_NOT_FOUND - Page count must not be zero. - @retval EAX #ERROR_STM_FUNCTION_NOT_SUPPORTED - STM supports EPT and has not implemented StmMapAddressRange(). - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_MAP_ADDRESS_RANGE 0x00000001 - -/** - STM Map Address Range Descriptor for #STM_API_MAP_ADDRESS_RANGE VMCALL -**/ -typedef struct { - UINT64 PhysicalAddress; - UINT64 VirtualAddress; - UINT32 PageCount; - UINT32 PatCacheType; -} STM_MAP_ADDRESS_RANGE_DESCRIPTOR; - -/** - Define values for PatCacheType field of #STM_MAP_ADDRESS_RANGE_DESCRIPTOR - @{ -**/ -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_ST_UC 0x00 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WC 0x01 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WT 0x04 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WP 0x05 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_WB 0x06 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_UC 0x07 -#define STM_MAP_ADDRESS_RANGE_PAT_CACHE_TYPE_FOLLOW_MTRR 0xFFFFFFFF -/// @} - -/** - StmUnmapAddressRange enables a SMM guest to remove mappings from its page - table. - - If TXT_PROCESSOR_SMM_DESCRIPTOR.EptEnabled bit is set by the STM, BIOS can - control its own page tables. In this case, the STM implementation may - optionally return ERROR_STM_FUNCTION_NOT_SUPPORTED. - - @param EAX #STM_API_UNMAP_ADDRESS_RANGE (0x00000002) - @param EBX Low 32 bits of virtual address of caller allocated - STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR structure. - @param ECX High 32 bits of virtual address of caller allocated - STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR structure. If Intel64Mode is - clear (0), ECX must be zero. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The memory range was unmapped - as requested. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_FUNCTION_NOT_SUPPORTED - STM supports EPT and has not implemented StmUnmapAddressRange(). - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_UNMAP_ADDRESS_RANGE 0x00000002 - -/** - STM Unmap Address Range Descriptor for #STM_API_UNMAP_ADDRESS_RANGE VMCALL -**/ -typedef struct { - UINT64 VirtualAddress; - UINT32 Length; -} STM_UNMAP_ADDRESS_RANGE_DESCRIPTOR; - - -/** - Since the normal OS environment runs with a different set of page tables than - the SMM guest, virtual mappings will certainly be different. In order to do a - guest virtual to host physical translation of an address from the normal OS - code (EIP for example), it is necessary to walk the page tables governing the - OS page mappings. Since the SMM guest has no direct access to the page tables, - it must ask the STM to do this page table walk. This is supported via the - StmAddressLookup VMCALL. All OS page table formats need to be supported, - (e.g. PAE, PSE, Intel64, EPT, etc.) - - StmAddressLookup takes a CR3 value and a virtual address from the interrupted - code as input and returns the corresponding physical address. It also - optionally maps the physical address into the SMM guest's virtual address - space. This new mapping persists ONLY for the duration of the SMI and if - needed in subsequent SMIs it must be remapped. PAT cache types follow the - interrupted environment's page table. - - If EPT is enabled, OS CR3 only provides guest physical address information, - but the SMM guest might also need to know the host physical address. Since - SMM does not have direct access rights to EPT (it is protected by the STM), - SMM can input InterruptedEptp to let STM help to walk through it, and output - the host physical address. - - @param EAX #STM_API_ADDRESS_LOOKUP (0x00000003) - @param EBX Low 32 bits of virtual address of caller allocated - STM_ADDRESS_LOOKUP_DESCRIPTOR structure. - @param ECX High 32 bits of virtual address of caller allocated - STM_ADDRESS_LOOKUP_DESCRIPTOR structure. If Intel64Mode is - clear (0), ECX must be zero. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. PhysicalAddress contains the - host physical address determined by walking the interrupted SMM - guest's page tables. SmmGuestVirtualAddress contains the SMM - guest's virtual mapping of the requested address. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_SECURITY_VIOLATION - The requested page was a protected page. - @retval EAX #ERROR_STM_PAGE_NOT_FOUND - The requested virtual address did not exist in the page given - page table. - @retval EAX #ERROR_STM_BAD_CR3 - The CR3 input was invalid. CR3 values must be from one of the - interrupted guest, or from the interrupted guest of another - processor. - @retval EAX #ERROR_STM_PHYSICAL_OVER_4G - The resulting physical address is greater than 4G and no virtual - address was supplied. The STM could not determine what address - within the SMM guest's virtual address space to do the mapping. - STM_ADDRESS_LOOKUP_DESCRIPTOR field PhysicalAddress contains the - physical address determined by walking the interrupted - environment's page tables. - @retval EAX #ERROR_STM_VIRTUAL_SPACE_TOO_SMALL - A specific virtual mapping was requested, but - SmmGuestVirtualAddress + Length exceeds 4G and the SMI handler - is running in 32 bit mode. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_ADDRESS_LOOKUP 0x00000003 - -/** - STM Lookup Address Range Descriptor for #STM_API_ADDRESS_LOOKUP VMCALL -**/ -typedef struct { - UINT64 InterruptedGuestVirtualAddress; - UINT32 Length; - UINT64 InterruptedCr3; - UINT64 InterruptedEptp; - UINT32 MapToSmmGuest:2; - UINT32 InterruptedCr4Pae:1; - UINT32 InterruptedCr4Pse:1; - UINT32 InterruptedIa32eMode:1; - UINT32 Reserved1:27; - UINT32 Reserved2; - UINT64 PhysicalAddress; - UINT64 SmmGuestVirtualAddress; -} STM_ADDRESS_LOOKUP_DESCRIPTOR; - -/** - Define values for the MapToSmmGuest field of #STM_ADDRESS_LOOKUP_DESCRIPTOR - @{ -**/ -#define STM_ADDRESS_LOOKUP_DESCRIPTOR_DO_NOT_MAP 0 -#define STM_ADDRESS_LOOKUP_DESCRIPTOR_ONE_TO_ONE 1 -#define STM_ADDRESS_LOOKUP_DESCRIPTOR_VIRTUAL_ADDRESS_SPECIFIED 3 -/// @} - - -/** - When returning from a protection exception (see section 6.2), the SMM guest - can instruct the STM to take one of two paths. It can either request a value - be logged to the TXT.ERRORCODE register and subsequently reset the machine - (indicating it couldn't resolve the problem), or it can request that the STM - resume the SMM guest again with the specified register state. - - Unlike other VMCALL interfaces, StmReturnFromProtectionException behaves more - like a jump or an IRET instruction than a "call". It does not return directly - to the caller, but indirectly to a different location specified on the - caller's stack (see section 6.2) or not at all. - - If the SMM guest STM protection exception handler itself causes a protection - exception (e.g. a single nested exception), or more than 100 un-nested - exceptions occur within the scope of a single SMI event, the STM must write - STM_CRASH_PROTECTION_EXCEPTION_FAILURE to the TXT.ERRORCODE register and - assert TXT.CMD.SYS_RESET. The reason for these restrictions is to simplify - the code requirements while still enabling a reasonable debugging capability. - - @param EAX #STM_API_RETURN_FROM_PROTECTION_EXCEPTION (0x00000004) - @param EBX If 0, resume SMM guest using register state found on exception - stack. If in range 0x01..0x0F, EBX contains a BIOS error code - which the STM must record in the TXT.ERRORCODE register and - subsequently reset the system via TXT.CMD.SYS_RESET. The value - of the TXT.ERRORCODE register is calculated as follows: - - TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC - - Values 0x10..0xFFFFFFFF are reserved, do not use. - -**/ -#define STM_API_RETURN_FROM_PROTECTION_EXCEPTION 0x00000004 - - -/** - VMCALL API Numbers - API number convention: MLE facing VMCALL interfaces have bit 16 set. - - The STM configuration lifecycle is as follows: - 1. SENTER->SINIT->MLE: MLE begins execution with SMI disabled (masked). - 2. MLE invokes #STM_API_INITIALIZE_PROTECTION VMCALL to prepare STM for - setup of initial protection profile. This is done on a single CPU and - has global effect. - 3. MLE invokes #STM_API_PROTECT_RESOURCE VMCALL to define the initial - protection profile. The protection profile is global across all CPUs. - 4. MLE invokes #STM_API_START VMCALL to enable the STM to begin receiving - SMI events. This must be done on every logical CPU. - 5. MLE may invoke #STM_API_PROTECT_RESOURCE VMCALL or - #STM_API_UNPROTECT_RESOURCE VMCALL during runtime as many times as - necessary. - 6. MLE invokes #STM_API_STOP VMCALL to disable the STM. SMI is again masked - following #STM_API_STOP VMCALL. -**/ - -/** - StartStmVmcall() is used to configure an STM that is present in MSEG. SMIs - should remain disabled from the invocation of GETSEC[SENTER] until they are - re-enabled by StartStmVMCALL(). When StartStmVMCALL() returns, SMI is - enabled and the STM has been started and is active. Prior to invoking - StartStmVMCALL(), the MLE root should first invoke - InitializeProtectionVMCALL() followed by as many iterations of - ProtectResourceVMCALL() as necessary to establish the initial protection - profile. StartStmVmcall() must be invoked on all processor threads. - - @param EAX #STM_API_START (0x00010001) - @param EDX STM configuration options. These provide the MLE with the - ability to pass configuration parameters to the STM. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The STM has been configured - and is now active and the guarding all requested resources. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_ALREADY_STARTED - The STM is already configured and active. STM remains active and - guarding previously enabled resource list. - @retval EAX #ERROR_STM_WITHOUT_SMX_UNSUPPORTED - The StartStmVMCALL() was invoked from VMX root mode, but outside - of SMX. This error code indicates the STM or platform does not - support the STM outside of SMX. The SMI handler remains active - and operates in legacy mode. See Appendix C - @retval EAX #ERROR_STM_UNSUPPORTED_MSR_BIT - The CPU doesn't support the MSR bit. The STM is not active. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_START (BIT16 | 1) - -/** - Bit values for EDX input parameter to #STM_API_START VMCALL - @{ -**/ -#define STM_CONFIG_SMI_UNBLOCKING_BY_VMX_OFF BIT0 -/// @} - - -/** - The StopStmVMCALL() is invoked by the MLE to teardown an active STM. This is - normally done as part of a full teardown of the SMX environment when the - system is being shut down. At the time the call is invoked, SMI is enabled - and the STM is active. When the call returns, the STM has been stopped and - all STM context is discarded and SMI is disabled. - - @param EAX #STM_API_STOP (0x00010002) - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The STM has been stopped and - is no longer processing SMI events. SMI is blocked. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_STOPPED - The STM was not active. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_STOP (BIT16 | 2) - - -/** - The ProtectResourceVMCALL() is invoked by the MLE root to request protection - of specific resources. The request is defined by a STM_RESOURCE_LIST, which - may contain more than one resource descriptor. Each resource descriptor is - processed separately by the STM. Whether or not protection for any specific - resource is granted is returned by the STM via the ReturnStatus bit in the - associated STM_RSC_DESC_HEADER. - - @param EAX #STM_API_PROTECT_RESOURCE (0x00010003) - @param EBX Low 32 bits of physical address of caller allocated - STM_RESOURCE_LIST. Bits 11:0 are ignored and assumed to be zero, - making the buffer 4K aligned. - @param ECX High 32 bits of physical address of caller allocated - STM_RESOURCE_LIST. - - @note All fields of STM_RESOURCE_LIST are inputs only, except for the - ReturnStatus bit. On input, the ReturnStatus bit must be clear. On - return, the ReturnStatus bit is set for each resource request granted, - and clear for each resource request denied. There are no other fields - modified by ProtectResourceVMCALL(). The STM_RESOURCE_LIST must be - contained entirely within a single 4K page. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The STM has successfully - merged the entire protection request into the active protection - profile. There is therefore no need to check the ReturnStatus - bits in the STM_RESOURCE_LIST. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_UNPROTECTABLE_RESOURCE - At least one of the requested resource protections intersects a - BIOS required resource. Therefore, the caller must walk through - the STM_RESOURCE_LIST to determine which of the requested - resources was not granted protection. The entire list must be - traversed since there may be multiple failures. - @retval EAX #ERROR_STM_MALFORMED_RESOURCE_LIST - The resource list could not be parsed correctly, or did not - terminate before crossing a 4K page boundary. The caller must - walk through the STM_RESOURCE_LIST to determine which of the - requested resources was not granted protection. The entire list - must be traversed since there may be multiple failures. - @retval EAX #ERROR_STM_OUT_OF_RESOURCES - The STM has encountered an internal error and cannot complete - the request. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_PROTECT_RESOURCE (BIT16 | 3) - - -/** - The UnProtectResourceVMCALL() is invoked by the MLE root to request that the - STM allow the SMI handler access to the specified resources. - - @param EAX #STM_API_UNPROTECT_RESOURCE (0x00010004) - @param EBX Low 32 bits of physical address of caller allocated - STM_RESOURCE_LIST. Bits 11:0 are ignored and assumed to be zero, - making the buffer 4K aligned. - @param ECX High 32 bits of physical address of caller allocated - STM_RESOURCE_LIST. - - @note All fields of STM_RESOURCE_LIST are inputs only, except for the - ReturnStatus bit. On input, the ReturnStatus bit must be clear. On - return, the ReturnStatus bit is set for each resource processed. For - a properly formed STM_RESOURCE_LIST, this should be all resources - listed. There are no other fields modified by - UnProtectResourceVMCALL(). The STM_RESOURCE_LIST must be contained - entirely within a single 4K page. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The requested resources are - not being guarded by the STM. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_MALFORMED_RESOURCE_LIST - The resource list could not be parsed correctly, or did not - terminate before crossing a 4K page boundary. The caller must - walk through the STM_RESOURCE_LIST to determine which of the - requested resources were not able to be unprotected. The entire - list must be traversed since there may be multiple failures. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_UNPROTECT_RESOURCE (BIT16 | 4) - - -/** - The GetBiosResourcesVMCALL() is invoked by the MLE root to request the list - of BIOS required resources from the STM. - - @param EAX #STM_API_GET_BIOS_RESOURCES (0x00010005) - @param EBX Low 32 bits of physical address of caller allocated destination - buffer. Bits 11:0 are ignored and assumed to be zero, making the - buffer 4K aligned. - @param ECX High 32 bits of physical address of caller allocated destination - buffer. - @param EDX Indicates which page of the BIOS resource list to copy into the - destination buffer. The first page is indicated by 0, the second - page by 1, etc. - - @retval CF 0 - No error, EAX set to STM_SUCCESS. The destination buffer - contains the BIOS required resources. If the page retrieved is - the last page, EDX will be cleared to 0. If there are more pages - to retrieve, EDX is incremented to the next page index. Calling - software should iterate on GetBiosResourcesVMCALL() until EDX is - returned cleared to 0. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_PAGE_NOT_FOUND - The page index supplied in EDX input was out of range. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - @retval EDX Page index of next page to read. A return of EDX=0 signifies - that the entire list has been read. - @note EDX is both an input and an output register. - - @note All other registers unmodified. -**/ -#define STM_API_GET_BIOS_RESOURCES (BIT16 | 5) - - -/** - The ManageVmcsDatabaseVMCALL() is invoked by the MLE root to add or remove an - MLE guest (including the MLE root) from the list of protected domains. - - @param EAX #STM_API_MANAGE_VMCS_DATABASE (0x00010006) - @param EBX Low 32 bits of physical address of caller allocated - STM_VMCS_DATABASE_REQUEST. Bits 11:0 are ignored and assumed to - be zero, making the buffer 4K aligned. - @param ECX High 32 bits of physical address of caller allocated - STM_VMCS_DATABASE_REQUEST. - - @note All fields of STM_VMCS_DATABASE_REQUEST are inputs only. They are not - modified by ManageVmcsDatabaseVMCALL(). - - @retval CF 0 - No error, EAX set to STM_SUCCESS. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_INVALID_VMCS - Indicates a request to remove a VMCS from the database was made, - but the referenced VMCS was not found in the database. - @retval EAX #ERROR_STM_VMCS_PRESENT - Indicates a request to add a VMCS to the database was made, but - the referenced VMCS was already present in the database. - @retval EAX #ERROR_INVALID_PARAMETER - Indicates non-zero reserved field. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred - - @note All other registers unmodified. -**/ -#define STM_API_MANAGE_VMCS_DATABASE (BIT16 | 6) - -/** - STM VMCS Database Request for #STM_API_MANAGE_VMCS_DATABASE VMCALL -**/ -typedef struct { - /// - /// bits 11:0 are reserved and must be 0 - /// - UINT64 VmcsPhysPointer; - UINT32 DomainType :4; - UINT32 XStatePolicy :2; - UINT32 DegradationPolicy :4; - /// - /// Must be 0 - /// - UINT32 Reserved1 :22; - UINT32 AddOrRemove; -} STM_VMCS_DATABASE_REQUEST; - -/** - Values for the DomainType field of #STM_VMCS_DATABASE_REQUEST - @{ -**/ -#define DOMAIN_UNPROTECTED 0 -#define DOMAIN_DISALLOWED_IO_OUT BIT0 -#define DOMAIN_DISALLOWED_IO_IN BIT1 -#define DOMAIN_INTEGRITY BIT2 -#define DOMAIN_CONFIDENTIALITY BIT3 -#define DOMAIN_INTEGRITY_PROT_OUT_IN (DOMAIN_INTEGRITY) -#define DOMAIN_FULLY_PROT_OUT_IN (DOMAIN_CONFIDENTIALITY | DOMAIN_INTEGRITY) -#define DOMAIN_FULLY_PROT (DOMAIN_FULLY_PROT_OUT_IN | DOMAIN_DISALLOWED_IO_IN | DOMAIN_DISALLOWED_IO_OUT) -/// @} - -/** - Values for the XStatePolicy field of #STM_VMCS_DATABASE_REQUEST - @{ -**/ -#define XSTATE_READWRITE 0x00 -#define XSTATE_READONLY 0x01 -#define XSTATE_SCRUB 0x03 -/// @} - -/** - Values for the AddOrRemove field of #STM_VMCS_DATABASE_REQUEST - @{ -**/ -#define STM_VMCS_DATABASE_REQUEST_ADD 1 -#define STM_VMCS_DATABASE_REQUEST_REMOVE 0 -/// @} - - -/** - InitializeProtectionVMCALL() prepares the STM for setup of the initial - protection profile which is subsequently communicated via one or more - invocations of ProtectResourceVMCALL(), prior to invoking StartStmVMCALL(). - It is only necessary to invoke InitializeProtectionVMCALL() on one processor - thread. InitializeProtectionVMCALL() does not alter whether SMIs are masked - or unmasked. The STM should return back to the MLE with "Blocking by SMI" set - to 1 in the GUEST_INTERRUPTIBILITY field for the VMCS the STM created for the - MLE guest. - - @param EAX #STM_API_INITIALIZE_PROTECTION (0x00010007) - - @retval CF 0 - No error, EAX set to STM_SUCCESS, EBX bits set to indicate STM - capabilities as defined below. The STM has set up an empty - protection profile, except for the resources that it sets up to - protect itself. The STM must not allow the SMI handler to map - any pages from the MSEG Base to the top of TSEG. The STM must - also not allow SMI handler access to those MSRs which the STM - requires for its own protection. - @retval CF 1 - An error occurred, EAX holds relevant error value. - @retval EAX #ERROR_STM_ALREADY_STARTED - The STM is already configured and active. The STM remains active - and guarding the previously enabled resource list. - @retval EAX #ERROR_STM_UNPROTECTABLE - The STM determines that based on the platform configuration, the - STM is unable to protect itself. For example, the BIOS required - resource list contains memory pages in MSEG. - @retval EAX #ERROR_STM_UNSPECIFIED - An unspecified error occurred. - - @note All other registers unmodified. -**/ -#define STM_API_INITIALIZE_PROTECTION (BIT16 | 7) - -/** - Byte granular support bits returned in EBX from #STM_API_INITIALIZE_PROTECTION - @{ -**/ -#define STM_RSC_BGI BIT1 -#define STM_RSC_BGM BIT2 -#define STM_RSC_MSR BIT3 -/// @} - - -/** - The ManageEventLogVMCALL() is invoked by the MLE root to control the logging - feature. It consists of several sub-functions to facilitate establishment of - the log itself, configuring what events will be logged, and functions to - start, stop, and clear the log. - - @param EAX #STM_API_MANAGE_EVENT_LOG (0x00010008) - @param EBX Low 32 bits of physical address of caller allocated - STM_EVENT_LOG_MANAGEMENT_REQUEST. Bits 11:0 are ignored and - assumed to be zero, making the buffer 4K aligned. - @param ECX High 32 bits of physical address of caller allocated - STM_EVENT_LOG_MANAGEMENT_REQUEST. - - @retval CF=0 - No error, EAX set to STM_SUCCESS. - @retval CF=1 - An error occurred, EAX holds relevant error value. See subfunction - descriptions below for details. - - @note All other registers unmodified. -**/ -#define STM_API_MANAGE_EVENT_LOG (BIT16 | 8) - -/// -/// STM Event Log Management Request for #STM_API_MANAGE_EVENT_LOG VMCALL -/// -typedef struct { - UINT32 SubFunctionIndex; - union { - struct { - UINT32 PageCount; - // - // number of elements is PageCount - // - UINT64 Pages[]; - } LogBuffer; - // - // bitmap of EVENT_TYPE - // - UINT32 EventEnableBitmap; - } Data; -} STM_EVENT_LOG_MANAGEMENT_REQUEST; - -/** - Defines values for the SubFunctionIndex field of - #STM_EVENT_LOG_MANAGEMENT_REQUEST - @{ -**/ -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_NEW_LOG 1 -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_CONFIGURE_LOG 2 -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_START_LOG 3 -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_STOP_LOG 4 -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_CLEAR_LOG 5 -#define STM_EVENT_LOG_MANAGEMENT_REQUEST_DELETE_LOG 6 -/// @} - -/** - Log Entry Header -**/ -typedef struct { - UINT32 EventSerialNumber; - UINT16 Type; - UINT16 Lock :1; - UINT16 Valid :1; - UINT16 ReadByMle :1; - UINT16 Wrapped :1; - UINT16 Reserved :12; -} LOG_ENTRY_HEADER; - -/** - Enum values for the Type field of #LOG_ENTRY_HEADER -**/ -typedef enum { - EvtLogStarted, - EvtLogStopped, - EvtLogInvalidParameterDetected, - EvtHandledProtectionException, - /// - /// unhandled protection exceptions result in reset & cannot be logged - /// - EvtBiosAccessToUnclaimedResource, - EvtMleResourceProtectionGranted, - EvtMleResourceProtectionDenied, - EvtMleResourceUnprotect, - EvtMleResourceUnprotectError, - EvtMleDomainTypeDegraded, - /// - /// add more here - /// - EvtMleMax, - /// - /// Not used - /// - EvtInvalid = 0xFFFFFFFF, -} EVENT_TYPE; - -typedef struct { - UINT32 Reserved; -} ENTRY_EVT_LOG_STARTED; - -typedef struct { - UINT32 Reserved; -} ENTRY_EVT_LOG_STOPPED; - -typedef struct { - UINT32 VmcallApiNumber; -} ENTRY_EVT_LOG_INVALID_PARAM; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_LOG_HANDLED_PROTECTION_EXCEPTION; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_BIOS_ACCESS_UNCLAIMED_RSC; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_MLE_RSC_PROT_GRANTED; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_MLE_RSC_PROT_DENIED; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_MLE_RSC_UNPROT; - -typedef struct { - STM_RSC Resource; -} ENTRY_EVT_MLE_RSC_UNPROT_ERROR; - -typedef struct { - UINT64 VmcsPhysPointer; - UINT8 ExpectedDomainType; - UINT8 DegradedDomainType; -} ENTRY_EVT_MLE_DOMAIN_TYPE_DEGRADED; - -typedef union { - ENTRY_EVT_LOG_STARTED Started; - ENTRY_EVT_LOG_STOPPED Stopped; - ENTRY_EVT_LOG_INVALID_PARAM InvalidParam; - ENTRY_EVT_LOG_HANDLED_PROTECTION_EXCEPTION HandledProtectionException; - ENTRY_EVT_BIOS_ACCESS_UNCLAIMED_RSC BiosUnclaimedRsc; - ENTRY_EVT_MLE_RSC_PROT_GRANTED MleRscProtGranted; - ENTRY_EVT_MLE_RSC_PROT_DENIED MleRscProtDenied; - ENTRY_EVT_MLE_RSC_UNPROT MleRscUnprot; - ENTRY_EVT_MLE_RSC_UNPROT_ERROR MleRscUnprotError; - ENTRY_EVT_MLE_DOMAIN_TYPE_DEGRADED MleDomainTypeDegraded; -} LOG_ENTRY_DATA; - -typedef struct { - LOG_ENTRY_HEADER Hdr; - LOG_ENTRY_DATA Data; -} STM_LOG_ENTRY; - -/** - Maximum STM Log Entry Size -**/ -#define STM_LOG_ENTRY_SIZE 256 - - -/** - STM Protection Exception Stack Frame Structures -**/ - -typedef struct { - UINT32 Rdi; - UINT32 Rsi; - UINT32 Rbp; - UINT32 Rdx; - UINT32 Rcx; - UINT32 Rbx; - UINT32 Rax; - UINT32 Cr3; - UINT32 Cr2; - UINT32 Cr0; - UINT32 VmcsExitInstructionInfo; - UINT32 VmcsExitInstructionLength; - UINT64 VmcsExitQualification; - /// - /// An TXT_SMM_PROTECTION_EXCEPTION_TYPE num value - /// - UINT32 ErrorCode; - UINT32 Rip; - UINT32 Cs; - UINT32 Rflags; - UINT32 Rsp; - UINT32 Ss; -} STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32; - -typedef struct { - UINT64 R15; - UINT64 R14; - UINT64 R13; - UINT64 R12; - UINT64 R11; - UINT64 R10; - UINT64 R9; - UINT64 R8; - UINT64 Rdi; - UINT64 Rsi; - UINT64 Rbp; - UINT64 Rdx; - UINT64 Rcx; - UINT64 Rbx; - UINT64 Rax; - UINT64 Cr8; - UINT64 Cr3; - UINT64 Cr2; - UINT64 Cr0; - UINT64 VmcsExitInstructionInfo; - UINT64 VmcsExitInstructionLength; - UINT64 VmcsExitQualification; - /// - /// An TXT_SMM_PROTECTION_EXCEPTION_TYPE num value - /// - UINT64 ErrorCode; - UINT64 Rip; - UINT64 Cs; - UINT64 Rflags; - UINT64 Rsp; - UINT64 Ss; -} STM_PROTECTION_EXCEPTION_STACK_FRAME_X64; - -typedef union { - STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32 *Ia32StackFrame; - STM_PROTECTION_EXCEPTION_STACK_FRAME_X64 *X64StackFrame; -} STM_PROTECTION_EXCEPTION_STACK_FRAME; - -/** - Enum values for the ErrorCode field in - #STM_PROTECTION_EXCEPTION_STACK_FRAME_IA32 and - #STM_PROTECTION_EXCEPTION_STACK_FRAME_X64 -**/ -typedef enum { - TxtSmmPageViolation = 1, - TxtSmmMsrViolation, - TxtSmmRegisterViolation, - TxtSmmIoViolation, - TxtSmmPciViolation -} TXT_SMM_PROTECTION_EXCEPTION_TYPE; - -/** - TXT Pocessor SMM Descriptor (PSD) structures -**/ - -typedef struct { - UINT64 SpeRip; - UINT64 SpeRsp; - UINT16 SpeSs; - UINT16 PageViolationException:1; - UINT16 MsrViolationException:1; - UINT16 RegisterViolationException:1; - UINT16 IoViolationException:1; - UINT16 PciViolationException:1; - UINT16 Reserved1:11; - UINT32 Reserved2; -} STM_PROTECTION_EXCEPTION_HANDLER; - -typedef struct { - UINT8 ExecutionDisableOutsideSmrr:1; - UINT8 Intel64Mode:1; - UINT8 Cr4Pae : 1; - UINT8 Cr4Pse : 1; - UINT8 Reserved1 : 4; -} STM_SMM_ENTRY_STATE; - -typedef struct { - UINT8 SmramToVmcsRestoreRequired : 1; ///> BIOS restore hint - UINT8 ReinitializeVmcsRequired : 1; ///> BIOS request - UINT8 Reserved2 : 6; -} STM_SMM_RESUME_STATE; - -typedef struct { - UINT8 DomainType : 4; ///> STM input to BIOS on each SMI - UINT8 XStatePolicy : 2; ///> STM input to BIOS on each SMI - UINT8 EptEnabled : 1; - UINT8 Reserved3 : 1; -} STM_SMM_STATE; - -#define TXT_SMM_PSD_OFFSET 0xfb00 -#define TXT_PROCESSOR_SMM_DESCRIPTOR_SIGNATURE SIGNATURE_64('T', 'X', 'T', 'P', 'S', 'S', 'I', 'G') -#define TXT_PROCESSOR_SMM_DESCRIPTOR_VERSION_MAJOR 1 -#define TXT_PROCESSOR_SMM_DESCRIPTOR_VERSION_MINOR 0 - -typedef struct { - UINT64 Signature; - UINT16 Size; - UINT8 SmmDescriptorVerMajor; - UINT8 SmmDescriptorVerMinor; - UINT32 LocalApicId; - STM_SMM_ENTRY_STATE SmmEntryState; - STM_SMM_RESUME_STATE SmmResumeState; - STM_SMM_STATE StmSmmState; - UINT8 Reserved4; - UINT16 SmmCs; - UINT16 SmmDs; - UINT16 SmmSs; - UINT16 SmmOtherSegment; - UINT16 SmmTr; - UINT16 Reserved5; - UINT64 SmmCr3; - UINT64 SmmStmSetupRip; - UINT64 SmmStmTeardownRip; - UINT64 SmmSmiHandlerRip; - UINT64 SmmSmiHandlerRsp; - UINT64 SmmGdtPtr; - UINT32 SmmGdtSize; - UINT32 RequiredStmSmmRevId; - STM_PROTECTION_EXCEPTION_HANDLER StmProtectionExceptionHandler; - UINT64 Reserved6; - UINT64 BiosHwResourceRequirementsPtr; - // extend area - UINT64 AcpiRsdp; - UINT8 PhysicalAddressBits; -} TXT_PROCESSOR_SMM_DESCRIPTOR; - -#pragma pack () - -#endif diff --git a/UefiCpuPkg/Include/Register/StmResourceDescriptor.h b/UefiCpuPkg/Include/Register/StmResourceDescriptor.h deleted file mode 100644 index 1518462ec0..0000000000 --- a/UefiCpuPkg/Include/Register/StmResourceDescriptor.h +++ /dev/null @@ -1,228 +0,0 @@ -/** @file - STM Resource Descriptor - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - SMI Transfer Monitor (STM) User Guide Revision 1.00 - -**/ - -#ifndef _STM_RESOURCE_DESCRIPTOR_H_ -#define _STM_RESOURCE_DESCRIPTOR_H_ - -#pragma pack (1) - -/** - STM Resource Descriptor Header -**/ -typedef struct { - UINT32 RscType; - UINT16 Length; - UINT16 ReturnStatus:1; - UINT16 Reserved:14; - UINT16 IgnoreResource:1; -} STM_RSC_DESC_HEADER; - -/** - Define values for the RscType field of #STM_RSC_DESC_HEADER - @{ -**/ -#define END_OF_RESOURCES 0 -#define MEM_RANGE 1 -#define IO_RANGE 2 -#define MMIO_RANGE 3 -#define MACHINE_SPECIFIC_REG 4 -#define PCI_CFG_RANGE 5 -#define TRAPPED_IO_RANGE 6 -#define ALL_RESOURCES 7 -#define REGISTER_VIOLATION 8 -#define MAX_DESC_TYPE 8 -/// @} - -/** - STM Resource End Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT64 ResourceListContinuation; -} STM_RSC_END; - -/** - STM Resource Memory Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT64 Base; - UINT64 Length; - UINT32 RWXAttributes:3; - UINT32 Reserved:29; - UINT32 Reserved_2; -} STM_RSC_MEM_DESC; - -/** - Define values for the RWXAttributes field of #STM_RSC_MEM_DESC - @{ -**/ -#define STM_RSC_MEM_R 0x1 -#define STM_RSC_MEM_W 0x2 -#define STM_RSC_MEM_X 0x4 -/// @} - -/** - STM Resource I/O Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT16 Base; - UINT16 Length; - UINT32 Reserved; -} STM_RSC_IO_DESC; - -/** - STM Resource MMIO Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT64 Base; - UINT64 Length; - UINT32 RWXAttributes:3; - UINT32 Reserved:29; - UINT32 Reserved_2; -} STM_RSC_MMIO_DESC; - -/** - Define values for the RWXAttributes field of #STM_RSC_MMIO_DESC - @{ -**/ -#define STM_RSC_MMIO_R 0x1 -#define STM_RSC_MMIO_W 0x2 -#define STM_RSC_MMIO_X 0x4 -/// @} - -/** - STM Resource MSR Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT32 MsrIndex; - UINT32 KernelModeProcessing:1; - UINT32 Reserved:31; - UINT64 ReadMask; - UINT64 WriteMask; -} STM_RSC_MSR_DESC; - -/** - STM PCI Device Path node used for the PciDevicePath field of - #STM_RSC_PCI_CFG_DESC -**/ -typedef struct { - /// - /// Must be 1, indicating Hardware Device Path - /// - UINT8 Type; - /// - /// Must be 1, indicating PCI - /// - UINT8 Subtype; - /// - /// sizeof(STM_PCI_DEVICE_PATH_NODE) which is 6 - /// - UINT16 Length; - UINT8 PciFunction; - UINT8 PciDevice; -} STM_PCI_DEVICE_PATH_NODE; - -/** - STM Resource PCI Configuration Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT16 RWAttributes:2; - UINT16 Reserved:14; - UINT16 Base; - UINT16 Length; - UINT8 OriginatingBusNumber; - UINT8 LastNodeIndex; - STM_PCI_DEVICE_PATH_NODE PciDevicePath[1]; -//STM_PCI_DEVICE_PATH_NODE PciDevicePath[LastNodeIndex + 1]; -} STM_RSC_PCI_CFG_DESC; - -/** - Define values for the RWAttributes field of #STM_RSC_PCI_CFG_DESC - @{ -**/ -#define STM_RSC_PCI_CFG_R 0x1 -#define STM_RSC_PCI_CFG_W 0x2 -/// @} - -/** - STM Resource Trapped I/O Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT16 Base; - UINT16 Length; - UINT16 In:1; - UINT16 Out:1; - UINT16 Api:1; - UINT16 Reserved1:13; - UINT16 Reserved2; -} STM_RSC_TRAPPED_IO_DESC; - -/** - STM Resource All Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; -} STM_RSC_ALL_RESOURCES_DESC; - -/** - STM Register Volation Descriptor -**/ -typedef struct { - STM_RSC_DESC_HEADER Hdr; - UINT32 RegisterType; - UINT32 Reserved; - UINT64 ReadMask; - UINT64 WriteMask; -} STM_REGISTER_VIOLATION_DESC; - -/** - Enum values for the RWAttributes field of #STM_REGISTER_VIOLATION_DESC -**/ -typedef enum { - StmRegisterCr0, - StmRegisterCr2, - StmRegisterCr3, - StmRegisterCr4, - StmRegisterCr8, - StmRegisterMax, -} STM_REGISTER_VIOLATION_TYPE; - -/** - Union of all STM resource types -**/ -typedef union { - STM_RSC_DESC_HEADER Header; - STM_RSC_END End; - STM_RSC_MEM_DESC Mem; - STM_RSC_IO_DESC Io; - STM_RSC_MMIO_DESC Mmio; - STM_RSC_MSR_DESC Msr; - STM_RSC_PCI_CFG_DESC PciCfg; - STM_RSC_TRAPPED_IO_DESC TrappedIo; - STM_RSC_ALL_RESOURCES_DESC All; - STM_REGISTER_VIOLATION_DESC RegisterViolation; -} STM_RSC; - -#pragma pack () - -#endif diff --git a/UefiCpuPkg/Include/Register/StmStatusCode.h b/UefiCpuPkg/Include/Register/StmStatusCode.h deleted file mode 100644 index f1fcb8b6ef..0000000000 --- a/UefiCpuPkg/Include/Register/StmStatusCode.h +++ /dev/null @@ -1,78 +0,0 @@ -/** @file - STM Status Codes - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Specification Reference: - SMI Transfer Monitor (STM) User Guide Revision 1.00 - -**/ - -#ifndef _STM_STATUS_CODE_H_ -#define _STM_STATUS_CODE_H_ - -/** - STM Status Codes -**/ -typedef UINT32 STM_STATUS; - -/** - Success code have BIT31 clear. - All error codes have BIT31 set. - STM errors have BIT16 set. - SMM errors have BIT17 set - Errors that apply to both STM and SMM have bits BIT15, BT16, and BIT17 set. - STM TXT.ERRORCODE codes have BIT30 set. - @{ -**/ -#define STM_SUCCESS 0x00000000 -#define SMM_SUCCESS 0x00000000 -#define ERROR_STM_SECURITY_VIOLATION (BIT31 | BIT16 | 0x0001) -#define ERROR_STM_CACHE_TYPE_NOT_SUPPORTED (BIT31 | BIT16 | 0x0002) -#define ERROR_STM_PAGE_NOT_FOUND (BIT31 | BIT16 | 0x0003) -#define ERROR_STM_BAD_CR3 (BIT31 | BIT16 | 0x0004) -#define ERROR_STM_PHYSICAL_OVER_4G (BIT31 | BIT16 | 0x0005) -#define ERROR_STM_VIRTUAL_SPACE_TOO_SMALL (BIT31 | BIT16 | 0x0006) -#define ERROR_STM_UNPROTECTABLE_RESOURCE (BIT31 | BIT16 | 0x0007) -#define ERROR_STM_ALREADY_STARTED (BIT31 | BIT16 | 0x0008) -#define ERROR_STM_WITHOUT_SMX_UNSUPPORTED (BIT31 | BIT16 | 0x0009) -#define ERROR_STM_STOPPED (BIT31 | BIT16 | 0x000A) -#define ERROR_STM_BUFFER_TOO_SMALL (BIT31 | BIT16 | 0x000B) -#define ERROR_STM_INVALID_VMCS_DATABASE (BIT31 | BIT16 | 0x000C) -#define ERROR_STM_MALFORMED_RESOURCE_LIST (BIT31 | BIT16 | 0x000D) -#define ERROR_STM_INVALID_PAGECOUNT (BIT31 | BIT16 | 0x000E) -#define ERROR_STM_LOG_ALLOCATED (BIT31 | BIT16 | 0x000F) -#define ERROR_STM_LOG_NOT_ALLOCATED (BIT31 | BIT16 | 0x0010) -#define ERROR_STM_LOG_NOT_STOPPED (BIT31 | BIT16 | 0x0011) -#define ERROR_STM_LOG_NOT_STARTED (BIT31 | BIT16 | 0x0012) -#define ERROR_STM_RESERVED_BIT_SET (BIT31 | BIT16 | 0x0013) -#define ERROR_STM_NO_EVENTS_ENABLED (BIT31 | BIT16 | 0x0014) -#define ERROR_STM_OUT_OF_RESOURCES (BIT31 | BIT16 | 0x0015) -#define ERROR_STM_FUNCTION_NOT_SUPPORTED (BIT31 | BIT16 | 0x0016) -#define ERROR_STM_UNPROTECTABLE (BIT31 | BIT16 | 0x0017) -#define ERROR_STM_UNSUPPORTED_MSR_BIT (BIT31 | BIT16 | 0x0018) -#define ERROR_STM_UNSPECIFIED (BIT31 | BIT16 | 0xFFFF) -#define ERROR_SMM_BAD_BUFFER (BIT31 | BIT17 | 0x0001) -#define ERROR_SMM_INVALID_RSC (BIT31 | BIT17 | 0x0004) -#define ERROR_SMM_INVALID_BUFFER_SIZE (BIT31 | BIT17 | 0x0005) -#define ERROR_SMM_BUFFER_TOO_SHORT (BIT31 | BIT17 | 0x0006) -#define ERROR_SMM_INVALID_LIST (BIT31 | BIT17 | 0x0007) -#define ERROR_SMM_OUT_OF_MEMORY (BIT31 | BIT17 | 0x0008) -#define ERROR_SMM_AFTER_INIT (BIT31 | BIT17 | 0x0009) -#define ERROR_SMM_UNSPECIFIED (BIT31 | BIT17 | 0xFFFF) -#define ERROR_INVALID_API (BIT31 | BIT17 | BIT16 | BIT15 | 0x0001) -#define ERROR_INVALID_PARAMETER (BIT31 | BIT17 | BIT16 | BIT15 | 0x0002) -#define STM_CRASH_PROTECTION_EXCEPTION (BIT31 | BIT30 | 0xF001) -#define STM_CRASH_PROTECTION_EXCEPTION_FAILURE (BIT31 | BIT30 | 0xF002) -#define STM_CRASH_DOMAIN_DEGRADATION_FAILURE (BIT31 | BIT30 | 0xF003) -#define STM_CRASH_BIOS_PANIC (BIT31 | BIT30 | 0xE000) -/// @} - -#endif diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf deleted file mode 100644 index b397ce0dc6..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# This library defines some routines that are generic for IA32 family CPU. -# -# The library routines are UEFI specification compliant. -# -# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BaseUefiCpuLib - MODULE_UNI_FILE = BaseUefiCpuLib.uni - FILE_GUID = 34C24FD7-7A90-45c2-89FD-946473D9CE98 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = UefiCpuLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.IA32] - Ia32/InitializeFpu.asm - Ia32/InitializeFpu.nasm - Ia32/InitializeFpu.S - -[Sources.X64] - X64/InitializeFpu.asm - X64/InitializeFpu.nasm - X64/InitializeFpu.S - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - UefiCpuLib - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni deleted file mode 100644 index 1a1c0d2411..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// This library defines some routines that are generic for IA32 family CPU. -// -// The library routines are UEFI specification compliant. -// -// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Defines generic routines for IA32 family CPUs." - -#string STR_MODULE_DESCRIPTION #language en-US "The library routines comply with the UEFI Specification." - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S b/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S deleted file mode 100644 index 4972bc2e7f..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.S +++ /dev/null @@ -1,73 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* -#------------------------------------------------------------------------------ - -# -# Float control word initial value: -# all exceptions masked, double-precision, round-to-nearest -# -ASM_PFX(mFpuControlWord): .word 0x027F -# -# Multimedia-extensions control word: -# all exceptions masked, round-to-nearest, flush to zero for masked underflow -# -ASM_PFX(mMmxControlWord): .long 0x01F80 - -# -# Initializes floating point units for requirement of UEFI specification. -# -# This function initializes floating-point control word to 0x027F (all exceptions -# masked,double-precision, round-to-nearest) and multimedia-extensions control word -# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -# for masked underflow). -# -ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - pushl %ebx - - # - # Initialize floating point units - # - finit - fldcw ASM_PFX(mFpuControlWord) - - # - # Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test - # whether the processor supports SSE instruction. - # - movl $1, %eax - cpuid - btl $25, %edx - jnc Done - - # - # Set OSFXSR bit 9 in CR4 - # - movl %cr4, %eax - or $0x200, %eax - movl %eax, %cr4 - - # - # The processor should support SSE instruction and we can use - # ldmxcsr instruction - # - ldmxcsr ASM_PFX(mMmxControlWord) - -Done: - popl %ebx - - ret - -#END - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm b/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm deleted file mode 100644 index 3c31da98f6..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.asm +++ /dev/null @@ -1,79 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2009, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* -;------------------------------------------------------------------------------ - - - .686 - .model flat,C - .const -; -; Float control word initial value: -; all exceptions masked, double-precision, round-to-nearest -; -mFpuControlWord DW 027Fh -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underflow -; -mMmxControlWord DD 01F80h - - .xmm - .code - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exceptions -; masked,double-precision, round-to-nearest) and multimedia-extensions control word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -; for masked underflow). -; -InitializeFloatingPointUnits PROC PUBLIC - - push ebx - - ; - ; Initialize floating point units - ; - finit - fldcw mFpuControlWord - - ; - ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test - ; whether the processor supports SSE instruction. - ; - mov eax, 1 - cpuid - bt edx, 25 - jnc Done - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov eax, cr4 - or eax, BIT9 - mov cr4, eax - - ; - ; The processor should support SSE instruction and we can use - ; ldmxcsr instruction - ; - ldmxcsr mMmxControlWord -Done: - pop ebx - - ret - -InitializeFloatingPointUnits ENDP - -END diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm b/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm deleted file mode 100644 index 55085e019f..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm +++ /dev/null @@ -1,74 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2016, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* -;------------------------------------------------------------------------------ - - SECTION .rdata - -; -; Float control word initial value: -; all exceptions masked, double-precision, round-to-nearest -; -mFpuControlWord: DW 0x27F -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underflow -; -mMmxControlWord: DD 0x1F80 - - SECTION .text - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exceptions -; masked,double-precision, round-to-nearest) and multimedia-extensions control word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -; for masked underflow). -; -global ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - push ebx - - ; - ; Initialize floating point units - ; - finit - fldcw [mFpuControlWord] - - ; - ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test - ; whether the processor supports SSE instruction. - ; - mov eax, 1 - cpuid - bt edx, 25 - jnc Done - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov eax, cr4 - or eax, BIT9 - mov cr4, eax - - ; - ; The processor should support SSE instruction and we can use - ; ldmxcsr instruction - ; - ldmxcsr [mMmxControlWord] -Done: - pop ebx - - ret - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S b/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S deleted file mode 100644 index 97d9f72338..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.S +++ /dev/null @@ -1,57 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* -#------------------------------------------------------------------------------ - -# -# Initializes floating point units for requirement of UEFI specification. -# -# This function initializes floating-point control word to 0x037F (all exceptions -# masked,double-extended-precision, round-to-nearest) and multimedia-extensions control word -# (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -# for masked underflow). -# -ASM_GLOBAL ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - # - # Initialize floating point units - # - finit - - # - # Float control word initial value: - # all exceptions masked, double-precision, round-to-nearest - # - pushq $0x037F - lea (%rsp), %rax - fldcw (%rax) - popq %rax - - # - # Set OSFXSR bit 9 in CR4 - # - movq %cr4, %rax - or $0x200, %rax - movq %rax, %cr4 - - # - # Multimedia-extensions control word: - # all exceptions masked, round-to-nearest, flush to zero for masked underflow - # - pushq $0x01F80 - lea (%rsp), %rax - ldmxcsr (%rax) - popq %rax - - ret - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm b/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm deleted file mode 100644 index 331af15cc6..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.asm +++ /dev/null @@ -1,62 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* -;------------------------------------------------------------------------------ - - -.const -; -; Float control word initial value: -; all exceptions masked, double-extended-precision, round-to-nearest -; -mFpuControlWord DW 037Fh -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underflow -; -mMmxControlWord DD 01F80h - -.code - - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exceptions -; masked,double-precision, round-to-nearest) and multimedia-extensions control word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -; for masked underflow). -; -InitializeFloatingPointUnits PROC PUBLIC - - ; - ; Initialize floating point units - ; - ; The following opcodes stand for instruction 'finit' - ; to be supported by some 64-bit assemblers - ; - DB 9Bh, 0DBh, 0E3h - fldcw mFpuControlWord - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov rax, cr4 - or rax, BIT9 - mov cr4, rax - - ldmxcsr mMmxControlWord - - ret -InitializeFloatingPointUnits ENDP - -END diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm b/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm deleted file mode 100644 index 904b64e510..0000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm +++ /dev/null @@ -1,60 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* -;------------------------------------------------------------------------------ - - SECTION .rdata -; -; Float control word initial value: -; all exceptions masked, double-extended-precision, round-to-nearest -; -mFpuControlWord: DW 0x37F -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underflow -; -mMmxControlWord: DD 0x1F80 - -DEFAULT REL -SECTION .text - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exceptions -; masked,double-precision, round-to-nearest) and multimedia-extensions control word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero -; for masked underflow). -; -global ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - ; - ; Initialize floating point units - ; - ; The following opcodes stand for instruction 'finit' - ; to be supported by some 64-bit assemblers - ; - DB 0x9B, 0xDB, 0xE3 - fldcw [mFpuControlWord] - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov rax, cr4 - or rax, BIT9 - mov cr4, rax - - ldmxcsr [mMmxControlWord] - - ret - diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c deleted file mode 100644 index f81bbb2252..0000000000 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ /dev/null @@ -1,1093 +0,0 @@ -/** @file - Local APIC Library. - - This local APIC library instance supports xAPIC mode only. - - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// -// Library internal functions -// - -/** - Determine if the CPU supports the Local APIC Base Address MSR. - - @retval TRUE The CPU supports the Local APIC Base Address MSR. - @retval FALSE The CPU does not support the Local APIC Base Address MSR. - -**/ -BOOLEAN -LocalApicBaseAddressMsrSupported ( - VOID - ) -{ - UINT32 RegEax; - UINTN FamilyId; - - AsmCpuid (1, &RegEax, NULL, NULL, NULL); - FamilyId = BitFieldRead32 (RegEax, 8, 11); - if (FamilyId == 0x04 || FamilyId == 0x05) { - // - // CPUs with a FamilyId of 0x04 or 0x05 do not support the - // Local APIC Base Address MSR - // - return FALSE; - } - return TRUE; -} - -/** - Retrieve the base address of local APIC. - - @return The base address of local APIC. - -**/ -UINTN -EFIAPI -GetLocalApicBaseAddress ( - VOID - ) -{ - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // If CPU does not support Local APIC Base Address MSR, then retrieve - // Local APIC Base Address from PCD - // - return PcdGet32 (PcdCpuLocalApicBaseAddress); - } - - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - - return (UINTN)(LShiftU64 ((UINT64) ApicBaseMsr.Bits.ApicBaseHi, 32)) + - (((UINTN)ApicBaseMsr.Bits.ApicBase) << 12); -} - -/** - Set the base address of local APIC. - - If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). - - @param[in] BaseAddress Local APIC base address to be set. - -**/ -VOID -EFIAPI -SetLocalApicBaseAddress ( - IN UINTN BaseAddress - ) -{ - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // Ignore set request if the CPU does not support APIC Base Address MSR - // - return; - } - - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - - ApicBaseMsr.Bits.ApicBase = (UINT32) (BaseAddress >> 12); - ApicBaseMsr.Bits.ApicBaseHi = (UINT32) (RShiftU64((UINT64) BaseAddress, 32)); - - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); -} - -/** - Read from a local APIC register. - - 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. - - @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. - It must be 16-byte aligned. - - @return 32-bit Value read from the register. -**/ -UINT32 -EFIAPI -ReadLocalApicReg ( - IN UINTN MmioOffset - ) -{ - ASSERT ((MmioOffset & 0xf) == 0); - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); - - return MmioRead32 (GetLocalApicBaseAddress() + MmioOffset); -} - -/** - Write to a local APIC register. - - This function writes to 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 write. - - if the register index is invalid or unsupported in current APIC mode, then ASSERT. - - @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. - It must be 16-byte aligned. - @param Value Value to be written to the register. -**/ -VOID -EFIAPI -WriteLocalApicReg ( - IN UINTN MmioOffset, - IN UINT32 Value - ) -{ - ASSERT ((MmioOffset & 0xf) == 0); - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); - - MmioWrite32 (GetLocalApicBaseAddress() + MmioOffset, Value); -} - -/** - Send an IPI by writing to ICR. - - This function returns after the IPI has been accepted by the target processor. - - @param IcrLow 32-bit value to be written to the low half of ICR. - @param ApicId APIC ID of the target processor if this IPI is targeted for a specific processor. -**/ -VOID -SendIpi ( - IN UINT32 IcrLow, - IN UINT32 ApicId - ) -{ - LOCAL_APIC_ICR_LOW IcrLowReg; - UINT32 IcrHigh; - BOOLEAN InterruptState; - - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); - ASSERT (ApicId <= 0xff); - - InterruptState = SaveAndDisableInterrupts (); - - // - // Save existing contents of ICR high 32 bits - // - IcrHigh = ReadLocalApicReg (XAPIC_ICR_HIGH_OFFSET); - - // - // Wait for DeliveryStatus clear in case a previous IPI - // is still being sent - // - do { - IcrLowReg.Uint32 = ReadLocalApicReg (XAPIC_ICR_LOW_OFFSET); - } while (IcrLowReg.Bits.DeliveryStatus != 0); - - // - // For xAPIC, the act of writing to the low doubleword of the ICR causes the IPI to be sent. - // - WriteLocalApicReg (XAPIC_ICR_HIGH_OFFSET, ApicId << 24); - WriteLocalApicReg (XAPIC_ICR_LOW_OFFSET, IcrLow); - - // - // Wait for DeliveryStatus clear again - // - do { - IcrLowReg.Uint32 = ReadLocalApicReg (XAPIC_ICR_LOW_OFFSET); - } while (IcrLowReg.Bits.DeliveryStatus != 0); - - // - // And restore old contents of ICR high - // - WriteLocalApicReg (XAPIC_ICR_HIGH_OFFSET, IcrHigh); - - SetInterruptState (InterruptState); - -} - -// -// Library API implementation functions -// - -/** - Get the current local APIC mode. - - If local APIC is disabled, then ASSERT. - - @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. - @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. -**/ -UINTN -EFIAPI -GetApicMode ( - VOID - ) -{ - DEBUG_CODE ( - { - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - // - // Check to see if the CPU supports the APIC Base Address MSR - // - if (LocalApicBaseAddressMsrSupported ()) { - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - // - // Local APIC should have been enabled - // - ASSERT (ApicBaseMsr.Bits.EN != 0); - ASSERT (ApicBaseMsr.Bits.EXTD == 0); - } - } - ); - return LOCAL_APIC_MODE_XAPIC; -} - -/** - Set the current local APIC mode. - - If the specified local APIC mode is not valid, then ASSERT. - If the specified local APIC mode can't be set as current, then ASSERT. - - @param ApicMode APIC mode to be set. - - @note This API must not be called from an interrupt handler or SMI handler. - It may result in unpredictable behavior. -**/ -VOID -EFIAPI -SetApicMode ( - IN UINTN ApicMode - ) -{ - ASSERT (ApicMode == LOCAL_APIC_MODE_XAPIC); - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); -} - -/** - Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. - - In xAPIC mode, the initial local APIC ID may be different from current APIC ID. - In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, - the 32-bit local APIC ID is returned as initial APIC ID. - - @return 32-bit initial local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetInitialApicId ( - VOID - ) -{ - UINT32 ApicId; - UINT32 MaxCpuIdIndex; - UINT32 RegEbx; - - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); - - // - // Get the max index of basic CPUID - // - AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); - - // - // If CPUID Leaf B is supported, - // And CPUID.0BH:EBX[15:0] reports a non-zero value, - // Then the initial 32-bit APIC ID = CPUID.0BH:EDX - // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24] - // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { - AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, &RegEbx, NULL, &ApicId); - if ((RegEbx & (BIT16 - 1)) != 0) { - return ApicId; - } - } - - AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL); - return RegEbx >> 24; -} - -/** - Get the local APIC ID of the executing processor. - - @return 32-bit local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetApicId ( - VOID - ) -{ - UINT32 ApicId; - - ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC); - - if ((ApicId = GetInitialApicId ()) < 0x100) { - // - // If the initial local APIC ID is less 0x100, read APIC ID from - // XAPIC_ID_OFFSET, otherwise return the initial local APIC ID. - // - ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET); - ApicId >>= 24; - } - return ApicId; -} - -/** - Get the value of the local APIC version register. - - @return the value of the local APIC version register. -**/ -UINT32 -EFIAPI -GetApicVersion ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_VERSION_OFFSET); -} - -/** - Send a Fixed IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId The local APIC ID of the target processor. - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpi ( - IN UINT32 ApicId, - IN UINT8 Vector - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; - IcrLow.Bits.Level = 1; - IcrLow.Bits.Vector = Vector; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send a Fixed IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpiAllExcludingSelf ( - IN UINT8 Vector - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - IcrLow.Bits.Vector = Vector; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send a SMI IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendSmiIpi ( - IN UINT32 ApicId - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send a SMI IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendSmiIpiAllExcludingSelf ( - VOID - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send an INIT IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendInitIpi ( - IN UINT32 ApicId - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send an INIT IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendInitIpiAllExcludingSelf ( - VOID - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param ApicId Specify the local APIC ID of the target processor. - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipi ( - IN UINT32 ApicId, - IN UINT32 StartupRoutine - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) == 0); - - SendInitIpi (ApicId); - MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 = 0; - IcrLow.Bits.Vector = (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); - MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipiAllExcludingSelf ( - IN UINT32 StartupRoutine - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) == 0); - - SendInitIpiAllExcludingSelf (); - MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 = 0; - IcrLow.Bits.Vector = (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); - MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, 0); -} - -/** - Initialize the state of the SoftwareEnable bit in the Local APIC - Spurious Interrupt Vector register. - - @param Enable If TRUE, then set SoftwareEnable to 1 - If FALSE, then set SoftwareEnable to 0. - -**/ -VOID -EFIAPI -InitializeLocalApicSoftwareEnable ( - IN BOOLEAN Enable - ) -{ - LOCAL_APIC_SVR Svr; - - // - // Set local APIC software-enabled bit. - // - Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); - if (Enable) { - if (Svr.Bits.SoftwareEnable == 0) { - Svr.Bits.SoftwareEnable = 1; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - } - } else { - if (Svr.Bits.SoftwareEnable == 1) { - Svr.Bits.SoftwareEnable = 0; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - } - } -} - -/** - Programming Virtual Wire Mode. - - This function programs the local APIC for virtual wire mode following - the example described in chapter A.3 of the MP 1.4 spec. - - IOxAPIC is not involved in this type of virtual wire mode. -**/ -VOID -EFIAPI -ProgramVirtualWireMode ( - VOID - ) -{ - LOCAL_APIC_SVR Svr; - LOCAL_APIC_LVT_LINT Lint; - - // - // Enable the APIC via SVR and set the spurious interrupt to use Int 00F. - // - Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); - Svr.Bits.SpuriousVector = 0xf; - Svr.Bits.SoftwareEnable = 1; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - - // - // Program the LINT0 vector entry as ExtInt. Not masked, edge, active high. - // - Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); - Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_EXTINT; - Lint.Bits.InputPinPolarity = 0; - Lint.Bits.TriggerMode = 0; - Lint.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, Lint.Uint32); - - // - // Program the LINT0 vector entry as NMI. Not masked, edge, active high. - // - Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); - Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI; - Lint.Bits.InputPinPolarity = 0; - Lint.Bits.TriggerMode = 0; - Lint.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, Lint.Uint32); -} - -/** - Disable LINT0 & LINT1 interrupts. - - This function sets the mask flag in the LVT LINT0 & LINT1 registers. -**/ -VOID -EFIAPI -DisableLvtInterrupts ( - VOID - ) -{ - LOCAL_APIC_LVT_LINT LvtLint; - - LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); - LvtLint.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, LvtLint.Uint32); - - LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); - LvtLint.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, LvtLint.Uint32); -} - -/** - Read the initial count value from the init-count register. - - @return The initial count value read from the init-count register. -**/ -UINT32 -EFIAPI -GetApicTimerInitCount ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET); -} - -/** - Read the current count value from the current-count register. - - @return The current count value read from the current-count register. -**/ -UINT32 -EFIAPI -GetApicTimerCurrentCount ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_TIMER_CURRENT_COUNT_OFFSET); -} - -/** - Initialize the local APIC timer. - - The local APIC timer is initialized and enabled. - - @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - If it is 0, then use the current divide value in the DCR. - @param InitCount The initial count value. - @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector The timer interrupt vector number. -**/ -VOID -EFIAPI -InitializeApicTimer ( - IN UINTN DivideValue, - IN UINT32 InitCount, - IN BOOLEAN PeriodicMode, - IN UINT8 Vector - ) -{ - LOCAL_APIC_DCR Dcr; - LOCAL_APIC_LVT_TIMER LvtTimer; - UINT32 Divisor; - - // - // Ensure local APIC is in software-enabled state. - // - InitializeLocalApicSoftwareEnable (TRUE); - - // - // Program init-count register. - // - WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); - - if (DivideValue != 0) { - ASSERT (DivideValue <= 128); - ASSERT (DivideValue == GetPowerOfTwo32((UINT32)DivideValue)); - Divisor = (UINT32)((HighBitSet32 ((UINT32)DivideValue) - 1) & 0x7); - - Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); - Dcr.Bits.DivideValue1 = (Divisor & 0x3); - Dcr.Bits.DivideValue2 = (Divisor >> 2); - WriteLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET, Dcr.Uint32); - } - - // - // Enable APIC timer interrupt with specified timer mode. - // - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - if (PeriodicMode) { - LvtTimer.Bits.TimerMode = 1; - } else { - LvtTimer.Bits.TimerMode = 0; - } - LvtTimer.Bits.Mask = 0; - LvtTimer.Bits.Vector = Vector; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Get the state of the local APIC timer. - - This function will ASSERT if the local APIC is not software enabled. - - @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector Return the timer interrupt vector number. -**/ -VOID -EFIAPI -GetApicTimerState ( - OUT UINTN *DivideValue OPTIONAL, - OUT BOOLEAN *PeriodicMode OPTIONAL, - OUT UINT8 *Vector OPTIONAL - ) -{ - UINT32 Divisor; - LOCAL_APIC_DCR Dcr; - LOCAL_APIC_LVT_TIMER LvtTimer; - - // - // Check the APIC Software Enable/Disable bit (bit 8) in Spurious-Interrupt - // Vector Register. - // This bit will be 1, if local APIC is software enabled. - // - ASSERT ((ReadLocalApicReg(XAPIC_SPURIOUS_VECTOR_OFFSET) & BIT8) != 0); - - if (DivideValue != NULL) { - Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); - Divisor = Dcr.Bits.DivideValue1 | (Dcr.Bits.DivideValue2 << 2); - Divisor = (Divisor + 1) & 0x7; - *DivideValue = ((UINTN)1) << Divisor; - } - - if (PeriodicMode != NULL || Vector != NULL) { - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - if (PeriodicMode != NULL) { - if (LvtTimer.Bits.TimerMode == 1) { - *PeriodicMode = TRUE; - } else { - *PeriodicMode = FALSE; - } - } - if (Vector != NULL) { - *Vector = (UINT8) LvtTimer.Bits.Vector; - } - } -} - -/** - Enable the local APIC timer interrupt. -**/ -VOID -EFIAPI -EnableApicTimerInterrupt ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - LvtTimer.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Disable the local APIC timer interrupt. -**/ -VOID -EFIAPI -DisableApicTimerInterrupt ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - LvtTimer.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Get the local APIC timer interrupt state. - - @retval TRUE The local APIC timer interrupt is enabled. - @retval FALSE The local APIC timer interrupt is disabled. -**/ -BOOLEAN -EFIAPI -GetApicTimerInterruptState ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - return (BOOLEAN)(LvtTimer.Bits.Mask == 0); -} - -/** - Send EOI to the local APIC. -**/ -VOID -EFIAPI -SendApicEoi ( - VOID - ) -{ - WriteLocalApicReg (XAPIC_EOI_OFFSET, 0); -} - -/** - Get the 32-bit address that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - @return 32-bit address used to send an MSI to the Local APIC. -**/ -UINT32 -EFIAPI -GetApicMsiAddress ( - VOID - ) -{ - LOCAL_APIC_MSI_ADDRESS MsiAddress; - - // - // Return address for an MSI interrupt to be delivered only to the APIC ID - // of the currently executing processor. - // - MsiAddress.Uint32 = 0; - MsiAddress.Bits.BaseAddress = 0xFEE; - MsiAddress.Bits.DestinationId = GetApicId (); - return MsiAddress.Uint32; -} - -/** - Get the 64-bit data value that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - If Vector is not in range 0x10..0xFE, then ASSERT(). - If DeliveryMode is not supported, then ASSERT(). - - @param Vector The 8-bit interrupt vector associated with the MSI. - Must be in the range 0x10..0xFE - @param DeliveryMode A 3-bit value that specifies how the recept of the MSI - is handled. The only supported values are: - 0: LOCAL_APIC_DELIVERY_MODE_FIXED - 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY - 2: LOCAL_APIC_DELIVERY_MODE_SMI - 4: LOCAL_APIC_DELIVERY_MODE_NMI - 5: LOCAL_APIC_DELIVERY_MODE_INIT - 7: LOCAL_APIC_DELIVERY_MODE_EXTINT - - @param LevelTriggered TRUE specifies a level triggered interrupt. - FALSE specifies an edge triggered interrupt. - @param AssertionLevel Ignored if LevelTriggered is FALSE. - TRUE specifies a level triggered interrupt that active - when the interrupt line is asserted. - FALSE specifies a level triggered interrupt that active - when the interrupt line is deasserted. - - @return 64-bit data value used to send an MSI to the Local APIC. -**/ -UINT64 -EFIAPI -GetApicMsiValue ( - IN UINT8 Vector, - IN UINTN DeliveryMode, - IN BOOLEAN LevelTriggered, - IN BOOLEAN AssertionLevel - ) -{ - LOCAL_APIC_MSI_DATA MsiData; - - ASSERT (Vector >= 0x10 && Vector <= 0xFE); - ASSERT (DeliveryMode < 8 && DeliveryMode != 6 && DeliveryMode != 3); - - MsiData.Uint64 = 0; - MsiData.Bits.Vector = Vector; - MsiData.Bits.DeliveryMode = (UINT32)DeliveryMode; - if (LevelTriggered) { - MsiData.Bits.TriggerMode = 1; - if (AssertionLevel) { - MsiData.Bits.Level = 1; - } - } - return MsiData.Uint64; -} - -/** - Get Package ID/Core ID/Thread ID of a processor. - - The algorithm assumes the target system has symmetry across physical - package boundaries with respect to the number of logical processors - per package, number of cores per package. - - @param[in] InitialApicId Initial APIC ID of the target logical processor. - @param[out] Package Returns the processor package ID. - @param[out] Core Returns the processor core ID. - @param[out] Thread Returns the processor thread ID. -**/ -VOID -EFIAPI -GetProcessorLocationByApicId ( - IN UINT32 InitialApicId, - OUT UINT32 *Package OPTIONAL, - OUT UINT32 *Core OPTIONAL, - OUT UINT32 *Thread OPTIONAL - ) -{ - BOOLEAN TopologyLeafSupported; - UINTN ThreadBits; - UINTN CoreBits; - CPUID_VERSION_INFO_EBX VersionInfoEbx; - CPUID_VERSION_INFO_EDX VersionInfoEdx; - CPUID_CACHE_PARAMS_EAX CacheParamsEax; - CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; - CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; - CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; - UINT32 MaxCpuIdIndex; - UINT32 SubIndex; - UINTN LevelType; - UINT32 MaxLogicProcessorsPerPackage; - UINT32 MaxCoresPerPackage; - - // - // Check if the processor is capable of supporting more than one logical processor. - // - AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); - if (VersionInfoEdx.Bits.HTT == 0) { - if (Thread != NULL) { - *Thread = 0; - } - if (Core != NULL) { - *Core = 0; - } - if (Package != NULL) { - *Package = 0; - } - return; - } - - ThreadBits = 0; - CoreBits = 0; - - // - // Assume three-level mapping of APIC ID: Package:Core:SMT. - // - TopologyLeafSupported = FALSE; - - // - // Get the max index of basic CPUID - // - AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); - - // - // If the extended topology enumeration leaf is available, it - // is the preferred mechanism for enumerating topology. - // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { - AsmCpuidEx( - CPUID_EXTENDED_TOPOLOGY, - 0, - &ExtendedTopologyEax.Uint32, - &ExtendedTopologyEbx.Uint32, - &ExtendedTopologyEcx.Uint32, - NULL - ); - // - // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for - // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not - // supported on that processor. - // - if (ExtendedTopologyEbx.Uint32 != 0) { - TopologyLeafSupported = TRUE; - - // - // Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract - // the SMT sub-field of x2APIC ID. - // - LevelType = ExtendedTopologyEcx.Bits.LevelType; - ASSERT(LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT); - ThreadBits = ExtendedTopologyEax.Bits.ApicIdShift; - - // - // Software must not assume any "level type" encoding - // value to be related to any sub-leaf index, except sub-leaf 0. - // - SubIndex = 1; - do { - AsmCpuidEx( - CPUID_EXTENDED_TOPOLOGY, - SubIndex, - &ExtendedTopologyEax.Uint32, - NULL, - &ExtendedTopologyEcx.Uint32, - NULL - ); - LevelType = ExtendedTopologyEcx.Bits.LevelType; - if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE) { - CoreBits = ExtendedTopologyEax.Bits.ApicIdShift - ThreadBits; - break; - } - SubIndex++; - } while (LevelType != CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID); - } - } - - if (!TopologyLeafSupported) { - AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); - MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; - if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { - AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); - MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; - } - else { - // - // Must be a single-core processor. - // - MaxCoresPerPackage = 1; - } - - ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); - CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } - - if (Thread != NULL) { - *Thread = InitialApicId & ((1 << ThreadBits) - 1); - } - if (Core != NULL) { - *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); - } - if (Package != NULL) { - *Package = (InitialApicId >> (ThreadBits + CoreBits)); - } -} diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf deleted file mode 100644 index 7dd2714af3..0000000000 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# The Local Apic library supports xAPIC mode only. -# -# Note: Local APIC library assumes local APIC is enabled. It does not handle cases -# where local APIC is disabled. -# -# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BaseXApicLib - MODULE_UNI_FILE = BaseXApicLib.uni - FILE_GUID = D87CA0A8-1AC2-439b-90F8-EF4A2AC88DAF - MODULE_TYPE = BASE - VERSION_STRING = 1.1 - LIBRARY_CLASS = LocalApicLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - BaseXApicLib.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - TimerLib - IoLib - PcdLib - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni deleted file mode 100644 index 49b05e6cec..0000000000 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file -// The Local Apic library supports xAPIC mode only. -// -// Note: Local APIC library assumes local APIC is enabled. It does not handle cases -// where local APIC is disabled. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Supports xAPIC mode only" - -#string STR_MODULE_DESCRIPTION #language en-US "Note: Local APIC library assumes local APIC is enabled. It does not handle cases where local APIC is disabled." - diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c deleted file mode 100644 index e690d2aa14..0000000000 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ /dev/null @@ -1,1188 +0,0 @@ -/** @file - Local APIC Library. - - This local APIC library instance supports x2APIC capable processors - which have xAPIC and x2APIC modes. - - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// -// Library internal functions -// - -/** - Determine if the CPU supports the Local APIC Base Address MSR. - - @retval TRUE The CPU supports the Local APIC Base Address MSR. - @retval FALSE The CPU does not support the Local APIC Base Address MSR. - -**/ -BOOLEAN -LocalApicBaseAddressMsrSupported ( - VOID - ) -{ - UINT32 RegEax; - UINTN FamilyId; - - AsmCpuid (1, &RegEax, NULL, NULL, NULL); - FamilyId = BitFieldRead32 (RegEax, 8, 11); - if (FamilyId == 0x04 || FamilyId == 0x05) { - // - // CPUs with a FamilyId of 0x04 or 0x05 do not support the - // Local APIC Base Address MSR - // - return FALSE; - } - return TRUE; -} - -/** - Retrieve the base address of local APIC. - - @return The base address of local APIC. - -**/ -UINTN -EFIAPI -GetLocalApicBaseAddress ( - VOID - ) -{ - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // If CPU does not support Local APIC Base Address MSR, then retrieve - // Local APIC Base Address from PCD - // - return PcdGet32 (PcdCpuLocalApicBaseAddress); - } - - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - - return (UINTN)(LShiftU64 ((UINT64) ApicBaseMsr.Bits.ApicBaseHi, 32)) + - (((UINTN)ApicBaseMsr.Bits.ApicBase) << 12); -} - -/** - Set the base address of local APIC. - - If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). - - @param[in] BaseAddress Local APIC base address to be set. - -**/ -VOID -EFIAPI -SetLocalApicBaseAddress ( - IN UINTN BaseAddress - ) -{ - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // Ignore set request of the CPU does not support APIC Base Address MSR - // - return; - } - - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - - ApicBaseMsr.Bits.ApicBase = (UINT32) (BaseAddress >> 12); - ApicBaseMsr.Bits.ApicBaseHi = (UINT32) (RShiftU64((UINT64) BaseAddress, 32)); - - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); -} - -/** - Read from a local APIC register. - - 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. - - @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. - It must be 16-byte aligned. - - @return 32-bit Value read from the register. -**/ -UINT32 -EFIAPI -ReadLocalApicReg ( - IN UINTN MmioOffset - ) -{ - UINT32 MsrIndex; - - ASSERT ((MmioOffset & 0xf) == 0); - - if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { - return MmioRead32 (GetLocalApicBaseAddress() + MmioOffset); - } else { - // - // DFR is not supported in x2APIC mode. - // - ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET); - // - // Note that in x2APIC mode, ICR is a 64-bit MSR that needs special treatment. It - // is not supported in this function for simplicity. - // - ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET); - - MsrIndex = (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS; - return AsmReadMsr32 (MsrIndex); - } -} - -/** - Write to a local APIC register. - - This function writes to 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 write. - - if the register index is invalid or unsupported in current APIC mode, then ASSERT. - - @param MmioOffset The MMIO offset of the local APIC register in xAPIC mode. - It must be 16-byte aligned. - @param Value Value to be written to the register. -**/ -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 { - // - // DFR is not supported in x2APIC mode. - // - ASSERT (MmioOffset != XAPIC_ICR_DFR_OFFSET); - // - // Note that in x2APIC mode, ICR is a 64-bit MSR that needs special treatment. It - // is not supported in this function for simplicity. - // - ASSERT (MmioOffset != XAPIC_ICR_HIGH_OFFSET); - ASSERT (MmioOffset != XAPIC_ICR_LOW_OFFSET); - - MsrIndex = (UINT32)(MmioOffset >> 4) + X2APIC_MSR_BASE_ADDRESS; - // - // The serializing semantics of WRMSR are relaxed when writing to the APIC registers. - // Use memory fence here to force the serializing semantics to be consisent with xAPIC mode. - // - MemoryFence (); - AsmWriteMsr32 (MsrIndex, Value); - } -} - -/** - Send an IPI by writing to ICR. - - This function returns after the IPI has been accepted by the target processor. - - @param IcrLow 32-bit value to be written to the low half of ICR. - @param ApicId APIC ID of the target processor if this IPI is targeted for a specific processor. -**/ -VOID -SendIpi ( - IN UINT32 IcrLow, - IN UINT32 ApicId - ) -{ - UINT64 MsrValue; - LOCAL_APIC_ICR_LOW IcrLowReg; - UINTN LocalApciBaseAddress; - UINT32 IcrHigh; - BOOLEAN InterruptState; - - // - // Legacy APIC or X2APIC? - // - if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { - ASSERT (ApicId <= 0xff); - - InterruptState = SaveAndDisableInterrupts (); - - // - // Get base address of this LAPIC - // - LocalApciBaseAddress = GetLocalApicBaseAddress(); - - // - // Save existing contents of ICR high 32 bits - // - IcrHigh = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET); - - // - // Wait for DeliveryStatus clear in case a previous IPI - // is still being sent - // - do { - IcrLowReg.Uint32 = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET); - } while (IcrLowReg.Bits.DeliveryStatus != 0); - - // - // For xAPIC, the act of writing to the low doubleword of the ICR causes the IPI to be sent. - // - MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET, ApicId << 24); - MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET, IcrLow); - - // - // Wait for DeliveryStatus clear again - // - do { - IcrLowReg.Uint32 = MmioRead32 (LocalApciBaseAddress + XAPIC_ICR_LOW_OFFSET); - } while (IcrLowReg.Bits.DeliveryStatus != 0); - - // - // And restore old contents of ICR high - // - MmioWrite32 (LocalApciBaseAddress + XAPIC_ICR_HIGH_OFFSET, IcrHigh); - - SetInterruptState (InterruptState); - - } else { - // - // For x2APIC, A single MSR write to the Interrupt Command Register is required for dispatching an - // interrupt in x2APIC mode. - // - MsrValue = LShiftU64 ((UINT64) ApicId, 32) | IcrLow; - AsmWriteMsr64 (X2APIC_MSR_ICR_ADDRESS, MsrValue); - } -} - -// -// Library API implementation functions -// - -/** - Get the current local APIC mode. - - If local APIC is disabled, then ASSERT. - - @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC. - @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC. -**/ -UINTN -EFIAPI -GetApicMode ( - VOID - ) -{ - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // If CPU does not support APIC Base Address MSR, then return XAPIC mode - // - return LOCAL_APIC_MODE_XAPIC; - } - - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - // - // Local APIC should have been enabled - // - ASSERT (ApicBaseMsr.Bits.EN != 0); - if (ApicBaseMsr.Bits.EXTD != 0) { - return LOCAL_APIC_MODE_X2APIC; - } else { - return LOCAL_APIC_MODE_XAPIC; - } -} - -/** - Set the current local APIC mode. - - If the specified local APIC mode is not valid, then ASSERT. - If the specified local APIC mode can't be set as current, then ASSERT. - - @param ApicMode APIC mode to be set. - - @note This API must not be called from an interrupt handler or SMI handler. - It may result in unpredictable behavior. -**/ -VOID -EFIAPI -SetApicMode ( - IN UINTN ApicMode - ) -{ - UINTN CurrentMode; - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - - if (!LocalApicBaseAddressMsrSupported ()) { - // - // Ignore set request if the CPU does not support APIC Base Address MSR - // - return; - } - - CurrentMode = GetApicMode (); - if (CurrentMode == LOCAL_APIC_MODE_XAPIC) { - switch (ApicMode) { - case LOCAL_APIC_MODE_XAPIC: - break; - case LOCAL_APIC_MODE_X2APIC: - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - ApicBaseMsr.Bits.EXTD = 1; - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); - break; - default: - ASSERT (FALSE); - } - } else { - switch (ApicMode) { - case LOCAL_APIC_MODE_XAPIC: - // - // Transition from x2APIC mode to xAPIC mode is a two-step process: - // x2APIC -> Local APIC disabled -> xAPIC - // - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - ApicBaseMsr.Bits.EXTD = 0; - ApicBaseMsr.Bits.EN = 0; - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); - ApicBaseMsr.Bits.EN = 1; - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); - break; - case LOCAL_APIC_MODE_X2APIC: - break; - default: - ASSERT (FALSE); - } - } -} - -/** - Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset. - - In xAPIC mode, the initial local APIC ID may be different from current APIC ID. - In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, - the 32-bit local APIC ID is returned as initial APIC ID. - - @return 32-bit initial local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetInitialApicId ( - VOID - ) -{ - UINT32 ApicId; - UINT32 MaxCpuIdIndex; - UINT32 RegEbx; - - if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { - // - // Get the max index of basic CPUID - // - AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); - // - // If CPUID Leaf B is supported, - // And CPUID.0BH:EBX[15:0] reports a non-zero value, - // Then the initial 32-bit APIC ID = CPUID.0BH:EDX - // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24] - // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { - AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, &RegEbx, NULL, &ApicId); - if ((RegEbx & (BIT16 - 1)) != 0) { - return ApicId; - } - } - AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL); - return RegEbx >> 24; - } else { - return GetApicId (); - } -} - -/** - Get the local APIC ID of the executing processor. - - @return 32-bit local APIC ID of the executing processor. -**/ -UINT32 -EFIAPI -GetApicId ( - VOID - ) -{ - UINT32 ApicId; - UINT32 InitApicId; - - ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET); - if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) { - ApicId = ((InitApicId = GetInitialApicId ()) < 0x100) ? (ApicId >> 24) : InitApicId; - } - - return ApicId; -} - -/** - Get the value of the local APIC version register. - - @return the value of the local APIC version register. -**/ -UINT32 -EFIAPI -GetApicVersion ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_VERSION_OFFSET); -} - -/** - Send a Fixed IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId The local APIC ID of the target processor. - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpi ( - IN UINT32 ApicId, - IN UINT8 Vector - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; - IcrLow.Bits.Level = 1; - IcrLow.Bits.Vector = Vector; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send a Fixed IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - @param Vector The vector number of the interrupt being sent. -**/ -VOID -EFIAPI -SendFixedIpiAllExcludingSelf ( - IN UINT8 Vector - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_FIXED; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - IcrLow.Bits.Vector = Vector; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send a SMI IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendSmiIpi ( - IN UINT32 ApicId - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send a SMI IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendSmiIpiAllExcludingSelf ( - VOID - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_SMI; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send an INIT IPI to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - @param ApicId Specify the local APIC ID of the target processor. -**/ -VOID -EFIAPI -SendInitIpi ( - IN UINT32 ApicId - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send an INIT IPI to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. -**/ -VOID -EFIAPI -SendInitIpiAllExcludingSelf ( - VOID - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - IcrLow.Uint32 = 0; - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_INIT; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); -} - -/** - Send an INIT-Start-up-Start-up IPI sequence to a specified target processor. - - This function returns after the IPI has been accepted by the target processor. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param ApicId Specify the local APIC ID of the target processor. - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipi ( - IN UINT32 ApicId, - IN UINT32 StartupRoutine - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) == 0); - - SendInitIpi (ApicId); - MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 = 0; - IcrLow.Bits.Vector = (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level = 1; - SendIpi (IcrLow.Uint32, ApicId); - MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, ApicId); -} - -/** - Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self. - - This function returns after the IPI has been accepted by the target processors. - - if StartupRoutine >= 1M, then ASSERT. - if StartupRoutine is not multiple of 4K, then ASSERT. - - @param StartupRoutine Points to a start-up routine which is below 1M physical - address and 4K aligned. -**/ -VOID -EFIAPI -SendInitSipiSipiAllExcludingSelf ( - IN UINT32 StartupRoutine - ) -{ - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) == 0); - - SendInitIpiAllExcludingSelf (); - MicroSecondDelay (PcdGet32(PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 = 0; - IcrLow.Bits.Vector = (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level = 1; - IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); - MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, 0); -} - -/** - Initialize the state of the SoftwareEnable bit in the Local APIC - Spurious Interrupt Vector register. - - @param Enable If TRUE, then set SoftwareEnable to 1 - If FALSE, then set SoftwareEnable to 0. - -**/ -VOID -EFIAPI -InitializeLocalApicSoftwareEnable ( - IN BOOLEAN Enable - ) -{ - LOCAL_APIC_SVR Svr; - - // - // Set local APIC software-enabled bit. - // - Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); - if (Enable) { - if (Svr.Bits.SoftwareEnable == 0) { - Svr.Bits.SoftwareEnable = 1; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - } - } else { - if (Svr.Bits.SoftwareEnable == 1) { - Svr.Bits.SoftwareEnable = 0; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - } - } -} - -/** - Programming Virtual Wire Mode. - - This function programs the local APIC for virtual wire mode following - the example described in chapter A.3 of the MP 1.4 spec. - - IOxAPIC is not involved in this type of virtual wire mode. -**/ -VOID -EFIAPI -ProgramVirtualWireMode ( - VOID - ) -{ - LOCAL_APIC_SVR Svr; - LOCAL_APIC_LVT_LINT Lint; - - // - // Enable the APIC via SVR and set the spurious interrupt to use Int 00F. - // - Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); - Svr.Bits.SpuriousVector = 0xf; - Svr.Bits.SoftwareEnable = 1; - WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); - - // - // Program the LINT0 vector entry as ExtInt. Not masked, edge, active high. - // - Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); - Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_EXTINT; - Lint.Bits.InputPinPolarity = 0; - Lint.Bits.TriggerMode = 0; - Lint.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, Lint.Uint32); - - // - // Program the LINT0 vector entry as NMI. Not masked, edge, active high. - // - Lint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); - Lint.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI; - Lint.Bits.InputPinPolarity = 0; - Lint.Bits.TriggerMode = 0; - Lint.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, Lint.Uint32); -} - -/** - Disable LINT0 & LINT1 interrupts. - - This function sets the mask flag in the LVT LINT0 & LINT1 registers. -**/ -VOID -EFIAPI -DisableLvtInterrupts ( - VOID - ) -{ - LOCAL_APIC_LVT_LINT LvtLint; - - LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); - LvtLint.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, LvtLint.Uint32); - - LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); - LvtLint.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET, LvtLint.Uint32); -} - -/** - Read the initial count value from the init-count register. - - @return The initial count value read from the init-count register. -**/ -UINT32 -EFIAPI -GetApicTimerInitCount ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET); -} - -/** - Read the current count value from the current-count register. - - @return The current count value read from the current-count register. -**/ -UINT32 -EFIAPI -GetApicTimerCurrentCount ( - VOID - ) -{ - return ReadLocalApicReg (XAPIC_TIMER_CURRENT_COUNT_OFFSET); -} - -/** - Initialize the local APIC timer. - - The local APIC timer is initialized and enabled. - - @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - If it is 0, then use the current divide value in the DCR. - @param InitCount The initial count value. - @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector The timer interrupt vector number. -**/ -VOID -EFIAPI -InitializeApicTimer ( - IN UINTN DivideValue, - IN UINT32 InitCount, - IN BOOLEAN PeriodicMode, - IN UINT8 Vector - ) -{ - LOCAL_APIC_DCR Dcr; - LOCAL_APIC_LVT_TIMER LvtTimer; - UINT32 Divisor; - - // - // Ensure local APIC is in software-enabled state. - // - InitializeLocalApicSoftwareEnable (TRUE); - - // - // Program init-count register. - // - WriteLocalApicReg (XAPIC_TIMER_INIT_COUNT_OFFSET, InitCount); - - if (DivideValue != 0) { - ASSERT (DivideValue <= 128); - ASSERT (DivideValue == GetPowerOfTwo32((UINT32)DivideValue)); - Divisor = (UINT32)((HighBitSet32 ((UINT32)DivideValue) - 1) & 0x7); - - Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); - Dcr.Bits.DivideValue1 = (Divisor & 0x3); - Dcr.Bits.DivideValue2 = (Divisor >> 2); - WriteLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET, Dcr.Uint32); - } - - // - // Enable APIC timer interrupt with specified timer mode. - // - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - if (PeriodicMode) { - LvtTimer.Bits.TimerMode = 1; - } else { - LvtTimer.Bits.TimerMode = 0; - } - LvtTimer.Bits.Mask = 0; - LvtTimer.Bits.Vector = Vector; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Get the state of the local APIC timer. - - This function will ASSERT if the local APIC is not software enabled. - - @param DivideValue Return the divide value for the DCR. It is one of 1,2,4,8,16,32,64,128. - @param PeriodicMode Return the timer mode. If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot. - @param Vector Return the timer interrupt vector number. -**/ -VOID -EFIAPI -GetApicTimerState ( - OUT UINTN *DivideValue OPTIONAL, - OUT BOOLEAN *PeriodicMode OPTIONAL, - OUT UINT8 *Vector OPTIONAL - ) -{ - UINT32 Divisor; - LOCAL_APIC_DCR Dcr; - LOCAL_APIC_LVT_TIMER LvtTimer; - - // - // Check the APIC Software Enable/Disable bit (bit 8) in Spurious-Interrupt - // Vector Register. - // This bit will be 1, if local APIC is software enabled. - // - ASSERT ((ReadLocalApicReg(XAPIC_SPURIOUS_VECTOR_OFFSET) & BIT8) != 0); - - if (DivideValue != NULL) { - Dcr.Uint32 = ReadLocalApicReg (XAPIC_TIMER_DIVIDE_CONFIGURATION_OFFSET); - Divisor = Dcr.Bits.DivideValue1 | (Dcr.Bits.DivideValue2 << 2); - Divisor = (Divisor + 1) & 0x7; - *DivideValue = ((UINTN)1) << Divisor; - } - - if (PeriodicMode != NULL || Vector != NULL) { - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - if (PeriodicMode != NULL) { - if (LvtTimer.Bits.TimerMode == 1) { - *PeriodicMode = TRUE; - } else { - *PeriodicMode = FALSE; - } - } - if (Vector != NULL) { - *Vector = (UINT8) LvtTimer.Bits.Vector; - } - } -} - -/** - Enable the local APIC timer interrupt. -**/ -VOID -EFIAPI -EnableApicTimerInterrupt ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - LvtTimer.Bits.Mask = 0; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Disable the local APIC timer interrupt. -**/ -VOID -EFIAPI -DisableApicTimerInterrupt ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - LvtTimer.Bits.Mask = 1; - WriteLocalApicReg (XAPIC_LVT_TIMER_OFFSET, LvtTimer.Uint32); -} - -/** - Get the local APIC timer interrupt state. - - @retval TRUE The local APIC timer interrupt is enabled. - @retval FALSE The local APIC timer interrupt is disabled. -**/ -BOOLEAN -EFIAPI -GetApicTimerInterruptState ( - VOID - ) -{ - LOCAL_APIC_LVT_TIMER LvtTimer; - - LvtTimer.Uint32 = ReadLocalApicReg (XAPIC_LVT_TIMER_OFFSET); - return (BOOLEAN)(LvtTimer.Bits.Mask == 0); -} - -/** - Send EOI to the local APIC. -**/ -VOID -EFIAPI -SendApicEoi ( - VOID - ) -{ - WriteLocalApicReg (XAPIC_EOI_OFFSET, 0); -} - -/** - Get the 32-bit address that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - @return 32-bit address used to send an MSI to the Local APIC. -**/ -UINT32 -EFIAPI -GetApicMsiAddress ( - VOID - ) -{ - LOCAL_APIC_MSI_ADDRESS MsiAddress; - - // - // Return address for an MSI interrupt to be delivered only to the APIC ID - // of the currently executing processor. - // - MsiAddress.Uint32 = 0; - MsiAddress.Bits.BaseAddress = 0xFEE; - MsiAddress.Bits.DestinationId = GetApicId (); - return MsiAddress.Uint32; -} - -/** - Get the 64-bit data value that a device should use to send a Message Signaled - Interrupt (MSI) to the Local APIC of the currently executing processor. - - If Vector is not in range 0x10..0xFE, then ASSERT(). - If DeliveryMode is not supported, then ASSERT(). - - @param Vector The 8-bit interrupt vector associated with the MSI. - Must be in the range 0x10..0xFE - @param DeliveryMode A 3-bit value that specifies how the recept of the MSI - is handled. The only supported values are: - 0: LOCAL_APIC_DELIVERY_MODE_FIXED - 1: LOCAL_APIC_DELIVERY_MODE_LOWEST_PRIORITY - 2: LOCAL_APIC_DELIVERY_MODE_SMI - 4: LOCAL_APIC_DELIVERY_MODE_NMI - 5: LOCAL_APIC_DELIVERY_MODE_INIT - 7: LOCAL_APIC_DELIVERY_MODE_EXTINT - - @param LevelTriggered TRUE specifies a level triggered interrupt. - FALSE specifies an edge triggered interrupt. - @param AssertionLevel Ignored if LevelTriggered is FALSE. - TRUE specifies a level triggered interrupt that active - when the interrupt line is asserted. - FALSE specifies a level triggered interrupt that active - when the interrupt line is deasserted. - - @return 64-bit data value used to send an MSI to the Local APIC. -**/ -UINT64 -EFIAPI -GetApicMsiValue ( - IN UINT8 Vector, - IN UINTN DeliveryMode, - IN BOOLEAN LevelTriggered, - IN BOOLEAN AssertionLevel - ) -{ - LOCAL_APIC_MSI_DATA MsiData; - - ASSERT (Vector >= 0x10 && Vector <= 0xFE); - ASSERT (DeliveryMode < 8 && DeliveryMode != 6 && DeliveryMode != 3); - - MsiData.Uint64 = 0; - MsiData.Bits.Vector = Vector; - MsiData.Bits.DeliveryMode = (UINT32)DeliveryMode; - if (LevelTriggered) { - MsiData.Bits.TriggerMode = 1; - if (AssertionLevel) { - MsiData.Bits.Level = 1; - } - } - return MsiData.Uint64; -} - -/** - Get Package ID/Core ID/Thread ID of a processor. - - The algorithm assumes the target system has symmetry across physical - package boundaries with respect to the number of logical processors - per package, number of cores per package. - - @param[in] InitialApicId Initial APIC ID of the target logical processor. - @param[out] Package Returns the processor package ID. - @param[out] Core Returns the processor core ID. - @param[out] Thread Returns the processor thread ID. -**/ -VOID -EFIAPI -GetProcessorLocationByApicId ( - IN UINT32 InitialApicId, - OUT UINT32 *Package OPTIONAL, - OUT UINT32 *Core OPTIONAL, - OUT UINT32 *Thread OPTIONAL - ) -{ - BOOLEAN TopologyLeafSupported; - UINTN ThreadBits; - UINTN CoreBits; - CPUID_VERSION_INFO_EBX VersionInfoEbx; - CPUID_VERSION_INFO_EDX VersionInfoEdx; - CPUID_CACHE_PARAMS_EAX CacheParamsEax; - CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; - CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; - CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; - UINT32 MaxCpuIdIndex; - UINT32 SubIndex; - UINTN LevelType; - UINT32 MaxLogicProcessorsPerPackage; - UINT32 MaxCoresPerPackage; - - // - // Check if the processor is capable of supporting more than one logical processor. - // - AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); - if (VersionInfoEdx.Bits.HTT == 0) { - if (Thread != NULL) { - *Thread = 0; - } - if (Core != NULL) { - *Core = 0; - } - if (Package != NULL) { - *Package = 0; - } - return; - } - - ThreadBits = 0; - CoreBits = 0; - - // - // Assume three-level mapping of APIC ID: Package:Core:SMT. - // - TopologyLeafSupported = FALSE; - - // - // Get the max index of basic CPUID - // - AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); - - // - // If the extended topology enumeration leaf is available, it - // is the preferred mechanism for enumerating topology. - // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { - AsmCpuidEx( - CPUID_EXTENDED_TOPOLOGY, - 0, - &ExtendedTopologyEax.Uint32, - &ExtendedTopologyEbx.Uint32, - &ExtendedTopologyEcx.Uint32, - NULL - ); - // - // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for - // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not - // supported on that processor. - // - if (ExtendedTopologyEbx.Uint32 != 0) { - TopologyLeafSupported = TRUE; - - // - // Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract - // the SMT sub-field of x2APIC ID. - // - LevelType = ExtendedTopologyEcx.Bits.LevelType; - ASSERT(LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT); - ThreadBits = ExtendedTopologyEax.Bits.ApicIdShift; - - // - // Software must not assume any "level type" encoding - // value to be related to any sub-leaf index, except sub-leaf 0. - // - SubIndex = 1; - do { - AsmCpuidEx( - CPUID_EXTENDED_TOPOLOGY, - SubIndex, - &ExtendedTopologyEax.Uint32, - NULL, - &ExtendedTopologyEcx.Uint32, - NULL - ); - LevelType = ExtendedTopologyEcx.Bits.LevelType; - if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE) { - CoreBits = ExtendedTopologyEax.Bits.ApicIdShift - ThreadBits; - break; - } - SubIndex++; - } while (LevelType != CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID); - } - } - - if (!TopologyLeafSupported) { - AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); - MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; - if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { - AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); - MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; - } - else { - // - // Must be a single-core processor. - // - MaxCoresPerPackage = 1; - } - - ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); - CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } - - if (Thread != NULL) { - *Thread = InitialApicId & ((1 << ThreadBits) - 1); - } - if (Core != NULL) { - *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); - } - if (Package != NULL) { - *Package = (InitialApicId >> (ThreadBits + CoreBits)); - } -} diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf deleted file mode 100644 index 53e186858f..0000000000 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# The Local Apic library supports x2APIC capable processors which have xAPIC and x2APIC modes. -# -# Note: Local APIC library assumes local APIC is enabled. It does not handle cases -# where local APIC is disabled. -# -# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BaseXApicX2ApicLib - MODULE_UNI_FILE = BaseXApicX2ApicLib.uni - FILE_GUID = 967B6E05-F10D-4c10-8BF7-365291CA143F - MODULE_TYPE = BASE - VERSION_STRING = 1.1 - LIBRARY_CLASS = LocalApicLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - BaseXApicX2ApicLib.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - TimerLib - IoLib - PcdLib - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni deleted file mode 100644 index 97f62273ba..0000000000 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file -// The Local Apic library supports x2APIC capable processors which have xAPIC and x2APIC modes. -// -// Note: Local APIC library assumes local APIC is enabled. It does not handle cases -// where local APIC is disabled. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Supports x2APIC capable processors that have xAPIC and x2APIC modes" - -#string STR_MODULE_DESCRIPTION #language en-US "Note: Local APIC library assumes local APIC is enabled. It does not handle cases where local APIC is disabled." - diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c deleted file mode 100644 index 178bfb50ab..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c +++ /dev/null @@ -1,127 +0,0 @@ -/** @file - AESNI feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Prepares for the data used by CPU feature detection and initialization. - - @param[in] NumberOfProcessors The number of CPUs in the platform. - - @return Pointer to a buffer of CPU related configuration data. - - @note This service could be called by BSP only. -**/ -VOID * -EFIAPI -AesniGetConfigData ( - IN UINTN NumberOfProcessors - ) -{ - UINT64 *ConfigData; - - ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors); - ASSERT (ConfigData != NULL); - return ConfigData; -} - -/** - Detects if AESNI feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE AESNI feature is supported. - @retval FALSE AESNI feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -AesniSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; - - if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { - MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; - MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); - return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1); - } - return FALSE; -} - -/** - Initializes AESNI feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the AESNI feature must be enabled. - If FALSE, then the AESNI feature must be disabled. - - @retval RETURN_SUCCESS AESNI feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -AesniInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; - - // - // SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index, - // Simply use MSR_SANDY_BRIDGE_FEATURE_CONFIG here - // - // The scope of the MSR_SANDY_BRIDGE_FEATURE_CONFIG is Core, only program MSR_FEATURE_CONFIG for thread 0 - // of each core. Otherwise, once a thread in the core disabled AES, the other thread will cause GP when - // programming it. - // - if (CpuInfo->ProcessorInfo.Location.Thread == 0) { - MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; - if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_SANDY_BRIDGE_FEATURE_CONFIG, - MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER, - Bits.AESConfiguration, - BIT1 | ((State) ? 0 : BIT0) - ); - } - } - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c deleted file mode 100644 index 47116355a8..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - C1E feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if C1E feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE C1E feature is supported. - @retval FALSE C1E feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -C1eSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel); -} - -/** - Initializes C1E feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the C1E feature must be enabled. - If FALSE, then the C1E feature must be disabled. - - @retval RETURN_SUCCESS C1E feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -C1eInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_NEHALEM_POWER_CTL, - MSR_NEHALEM_POWER_CTL_REGISTER, - Bits.C1EEnable, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c deleted file mode 100644 index 56e53561e9..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - Clock Modulation feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Clock Modulation feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Clock Modulation feature is supported. - @retval FALSE Clock Modulation feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -ClockModulationSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1); -} - -/** - Initializes Clock Modulation feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Clock Modulation feature must be enabled. - If FALSE, then the Clock Modulation feature must be disabled. - - @retval RETURN_SUCCESS Clock Modulation feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -ClockModulationInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, - MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, - Bits.OnDemandClockModulationDutyCycle, - PcdGet8 (PcdCpuClockModulationDutyCycle) - ); - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, - MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, - Bits.OnDemandClockModulationEnable, - (State) ? 1 : 0 - ); - } else { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_CLOCK_MODULATION, - MSR_IA32_CLOCK_MODULATION_REGISTER, - Bits.OnDemandClockModulationDutyCycle, - PcdGet8 (PcdCpuClockModulationDutyCycle) - ); - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_CLOCK_MODULATION, - MSR_IA32_CLOCK_MODULATION_REGISTER, - Bits.OnDemandClockModulationEnable, - (State) ? 1 : 0 - ); - } - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h deleted file mode 100644 index aa6d1122b1..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h +++ /dev/null @@ -1,867 +0,0 @@ -/** @file - CPU Common features library header file. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_COMMON_FEATURES_H_ -#define _CPU_COMMON_FEATURES_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/** - Prepares for the data used by CPU feature detection and initialization. - - @param[in] NumberOfProcessors The number of CPUs in the platform. - - @return Pointer to a buffer of CPU related configuration data. - - @note This service could be called by BSP only. -**/ -VOID * -EFIAPI -AesniGetConfigData ( - IN UINTN NumberOfProcessors - ); - -/** - Detects if AESNI feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE AESNI feature is supported. - @retval FALSE AESNI feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -AesniSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes AESNI feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the AESNI feature must be enabled. - If FALSE, then the AESNI feature must be disabled. - - @retval RETURN_SUCCESS AESNI feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -AesniInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Clock Modulation feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Clock Modulation feature is supported. - @retval FALSE Clock Modulation feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -ClockModulationSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Clock Modulation feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Clock Modulation feature must be enabled. - If FALSE, then the Clock Modulation feature must be disabled. - - @retval RETURN_SUCCESS Clock Modulation feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -ClockModulationInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Enhanced Intel SpeedStep feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Enhanced Intel SpeedStep feature is supported. - @retval FALSE Enhanced Intel SpeedStep feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -EistSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Enhanced Intel SpeedStep feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Enhanced Intel SpeedStep feature - must be enabled. - If FALSE, then the Enhanced Intel SpeedStep feature - must be disabled. - - @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -EistInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Execute Disable feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Execute Disable feature is supported. - @retval FALSE Execute Disable feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -ExecuteDisableSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Execute Disable feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Execute Disable feature must be enabled. - If FALSE, then the Execute Disable feature must be disabled. - - @retval RETURN_SUCCESS Execute Disable feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -ExecuteDisableInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Initializes Fast-Strings feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Fast-Strings feature must be enabled. - If FALSE, then the Fast-Strings feature must be disabled. - - @retval RETURN_SUCCESS Fast-Strings feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -FastStringsInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if MONITOR/MWAIT feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE MONITOR/MWAIT feature is supported. - @retval FALSE MONITOR/MWAIT feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -MonitorMwaitSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes MONITOR/MWAIT feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled. - If FALSE, then the MONITOR/MWAIT feature must be disabled. - - @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -MonitorMwaitInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if VMX feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE VMX feature is supported. - @retval FALSE VMX feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -VmxSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes VMX inside SMX feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the VMX inside SMX feature must be enabled. - If FALSE, then the VMX inside SMX feature must be disabled. - - @retval RETURN_SUCCESS VMX inside SMX feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -VmxInsideSmxInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Initializes SENTER feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the SENTER feature must be enabled. - If FALSE, then the SENTER feature must be disabled. - - @retval RETURN_SUCCESS SENTER feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -SenterInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Lock Feature Control Register feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Lock Feature Control Register feature is supported. - @retval FALSE Lock Feature Control Register feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -LockFeatureControlRegisterSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Lock Feature Control Register feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled. - If FALSE, then the Lock Feature Control Register feature must be disabled. - - @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -LockFeatureControlRegisterInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if SMX feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE SMX feature is supported. - @retval FALSE SMX feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -SmxSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes VMX outside SMX feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the VMX outside SMX feature must be enabled. - If FALSE, then the VMX outside SMX feature must be disabled. - - @retval RETURN_SUCCESS VMX outside SMX feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -VmxOutsideSmxInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if LimitCpuidMaxval feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE LimitCpuidMaxval feature is supported. - @retval FALSE LimitCpuidMaxval feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -LimitCpuidMaxvalSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes LimitCpuidMaxval feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled. - If FALSE, then the LimitCpuidMaxval feature must be disabled. - - @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -LimitCpuidMaxvalInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Machine Check Exception feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Machine Check Exception feature is supported. - @retval FALSE Machine Check Exception feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -MceSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Machine Check Exception feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Machine Check Exception feature must be enabled. - If FALSE, then the Machine Check Exception feature must be disabled. - - @retval RETURN_SUCCESS Machine Check Exception feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -MceInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Machine Check Architecture feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Machine Check Architecture feature is supported. - @retval FALSE Machine Check Architecture feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -McaSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Machine Check Architecture feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Machine Check Architecture feature must be enabled. - If FALSE, then the Machine Check Architecture feature must be disabled. - - @retval RETURN_SUCCESS Machine Check Architecture feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -McaInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if IA32_MCG_CTL feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE IA32_MCG_CTL feature is supported. - @retval FALSE IA32_MCG_CTL feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -McgCtlSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes IA32_MCG_CTL feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the IA32_MCG_CTL feature must be enabled. - If FALSE, then the IA32_MCG_CTL feature must be disabled. - - @retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -McgCtlInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if Pending Break feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Pending Break feature is supported. - @retval FALSE Pending Break feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -PendingBreakSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes Pending Break feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Pending Break feature must be enabled. - If FALSE, then the Pending Break feature must be disabled. - - @retval RETURN_SUCCESS Pending Break feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -PendingBreakInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if C1E feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE C1E feature is supported. - @retval FALSE C1E feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -C1eSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes C1E feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the C1E feature must be enabled. - If FALSE, then the C1E feature must be disabled. - - @retval RETURN_SUCCESS C1E feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -C1eInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Detects if X2Apci feature supported on current processor. - - Detect if X2Apci has been already enabled. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE X2Apci feature is supported. - @retval FALSE X2Apci feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -X2ApicSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ); - -/** - Initializes X2Apci feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the X2Apci feature must be enabled. - If FALSE, then the X2Apci feature must be disabled. - - @retval RETURN_SUCCESS X2Apci feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -X2ApicInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ); - -/** - Prepares for the data used by CPU feature detection and initialization. - - @param[in] NumberOfProcessors The number of CPUs in the platform. - - @return Pointer to a buffer of CPU related configuration data. - - @note This service could be called by BSP only. -**/ -VOID * -EFIAPI -FeatureControlGetConfigData ( - IN UINTN NumberOfProcessors - ); - -#endif diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c deleted file mode 100644 index 3390aa8f2a..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c +++ /dev/null @@ -1,227 +0,0 @@ -/** @file - This library registers CPU features defined in Intel(R) 64 and IA-32 - Architectures Software Developer's Manual. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Register CPU features. - - @retval RETURN_SUCCESS Register successfully -**/ -RETURN_STATUS -EFIAPI -CpuCommonFeaturesLibConstructor ( - VOID - ) -{ - RETURN_STATUS Status; - - if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) { - Status = RegisterCpuFeature ( - "AESNI", - AesniGetConfigData, - AesniSupport, - AesniInitialize, - CPU_FEATURE_AESNI, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) { - Status = RegisterCpuFeature ( - "MWAIT", - NULL, - MonitorMwaitSupport, - MonitorMwaitInitialize, - CPU_FEATURE_MWAIT, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) { - Status = RegisterCpuFeature ( - "ACPI", - NULL, - ClockModulationSupport, - ClockModulationInitialize, - CPU_FEATURE_ACPI, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) { - Status = RegisterCpuFeature ( - "EIST", - NULL, - EistSupport, - EistInitialize, - CPU_FEATURE_EIST, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_XD)) { - Status = RegisterCpuFeature ( - "Execute Disable", - NULL, - ExecuteDisableSupport, - ExecuteDisableInitialize, - CPU_FEATURE_XD, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) { - Status = RegisterCpuFeature ( - "FastStrings", - NULL, - NULL, - FastStringsInitialize, - CPU_FEATURE_FASTSTRINGS, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) { - Status = RegisterCpuFeature ( - "Lock Feature Control Register", - FeatureControlGetConfigData, - LockFeatureControlRegisterSupport, - LockFeatureControlRegisterInitialize, - CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) { - Status = RegisterCpuFeature ( - "SENTER", - FeatureControlGetConfigData, - VmxSupport, - SenterInitialize, - CPU_FEATURE_SENTER, - CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, - CPU_FEATURE_SMX | CPU_FEATURE_AFTER, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) { - Status = RegisterCpuFeature ( - "SMX", - FeatureControlGetConfigData, - SmxSupport, - VmxInsideSmxInitialize, - CPU_FEATURE_SMX, - CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) { - Status = RegisterCpuFeature ( - "VMX", - FeatureControlGetConfigData, - SmxSupport, - VmxOutsideSmxInitialize, - CPU_FEATURE_VMX, - CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) { - Status = RegisterCpuFeature ( - "Limit CpuId Maximum Value", - NULL, - LimitCpuidMaxvalSupport, - LimitCpuidMaxvalInitialize, - CPU_FEATURE_LIMIT_CPUID_MAX_VAL, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) { - Status = RegisterCpuFeature ( - "Machine Check Enable", - NULL, - MceSupport, - MceInitialize, - CPU_FEATURE_MCE, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) { - Status = RegisterCpuFeature ( - "Machine Check Architect", - NULL, - McaSupport, - McaInitialize, - CPU_FEATURE_MCA, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) { - Status = RegisterCpuFeature ( - "MCG_CTL", - NULL, - McgCtlSupport, - McgCtlInitialize, - CPU_FEATURE_MCG_CTL, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) { - Status = RegisterCpuFeature ( - "Pending Break", - NULL, - PendingBreakSupport, - PendingBreakInitialize, - CPU_FEATURE_PENDING_BREAK, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) { - Status = RegisterCpuFeature ( - "C1E", - NULL, - C1eSupport, - C1eInitialize, - CPU_FEATURE_C1E, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) { - Status = RegisterCpuFeature ( - "X2Apic", - NULL, - X2ApicSupport, - X2ApicInitialize, - CPU_FEATURE_X2APIC, - CPU_FEATURE_END - ); - ASSERT_EFI_ERROR (Status); - } - - return RETURN_SUCCESS; -} - - - diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf deleted file mode 100644 index e68936be25..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf +++ /dev/null @@ -1,68 +0,0 @@ -## @file -# NULL instance to register CPU features. -# -# This library registers CPU features defined in Intel(R) 64 and IA-32 -# Architectures Software Developer's Manual. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CpuCommonFeaturesLib - MODULE_UNI_FILE = CpuCommonFeaturesLib.uni - FILE_GUID = 6D69F79F-9535-4893-9DD7-93929898252C - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = NULL - - CONSTRUCTOR = CpuCommonFeaturesLibConstructor - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - CpuCommonFeaturesLib.c - CpuCommonFeatures.h - Aesni.c - C1e.c - ClockModulation.c - Eist.c - ExecuteDisable.c - FastStrings.c - FeatureControl.c - LimitCpuIdMaxval.c - MachineCheck.c - MonitorMwait.c - PendingBreak.c - X2Apic.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - PcdLib - DebugLib - RegisterCpuFeaturesLib - BaseMemoryLib - MemoryAllocationLib - LocalApicLib - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## SOMETIMES_CONSUMES - diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni b/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni deleted file mode 100644 index d1a90c32d4..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni +++ /dev/null @@ -1,25 +0,0 @@ -// /** @file -// Dxe Crc32 Guided Section Extract library. -// -// This library doesn't produce any library class. The constructor function uses -// ExtractGuidedSectionLib service to register CRC32 guided section handler -// that parses CRC32 encapsulation section and extracts raw data. -// -// It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value. -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Dxe Crc32 Guided Section Extract library." - -#string STR_MODULE_DESCRIPTION #language en-US "This library doesn't produce any library class. The constructor function uses ExtractGuidedSectionLib service to register CRC32 guided section handler that parses CRC32 encapsulation section and extracts raw data. It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value." - diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c deleted file mode 100644 index 2038171a14..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c +++ /dev/null @@ -1,81 +0,0 @@ -/** @file - Enhanced Intel SpeedStep feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Enhanced Intel SpeedStep feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Enhanced Intel SpeedStep feature is supported. - @retval FALSE Enhanced Intel SpeedStep feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -EistSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1); -} - -/** - Initializes Enhanced Intel SpeedStep feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Enhanced Intel SpeedStep feature - must be enabled. - If FALSE, then the Enhanced Intel SpeedStep feature - must be disabled. - - @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -EistInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_MISC_ENABLE, - MSR_IA32_MISC_ENABLE_REGISTER, - Bits.EIST, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c deleted file mode 100644 index 921656a1e8..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c +++ /dev/null @@ -1,91 +0,0 @@ -/** @file - Execute Disable feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Execute Disable feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Execute Disable feature is supported. - @retval FALSE Execute Disable feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -ExecuteDisableSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - UINT32 Eax; - CPUID_EXTENDED_CPU_SIG_EDX Edx; - - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); - if (Eax <= CPUID_EXTENDED_FUNCTION) { - // - // Extended CPUID functions are not supported on this processor. - // - return FALSE; - } - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); - return (Edx.Bits.NX != 0); -} - -/** - Initializes Execute Disable feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Execute Disable feature must be enabled. - If FALSE, then the Execute Disable feature must be disabled. - - @retval RETURN_SUCCESS Execute Disable feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -ExecuteDisableInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_EFER, - MSR_IA32_EFER_REGISTER, - Bits.NXE, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c deleted file mode 100644 index 029bcf87b3..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - Fast-Strings feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Initializes Fast-Strings feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Fast-Strings feature must be enabled. - If FALSE, then the Fast-Strings feature must be disabled. - - @retval RETURN_SUCCESS Fast-Strings feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -FastStringsInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_MISC_ENABLE, - MSR_IA32_MISC_ENABLE_REGISTER, - Bits.FastStrings, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c deleted file mode 100644 index 0b5c161f87..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c +++ /dev/null @@ -1,314 +0,0 @@ -/** @file - Features in MSR_IA32_FEATURE_CONTROL register. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Prepares for the data used by CPU feature detection and initialization. - - @param[in] NumberOfProcessors The number of CPUs in the platform. - - @return Pointer to a buffer of CPU related configuration data. - - @note This service could be called by BSP only. -**/ -VOID * -EFIAPI -FeatureControlGetConfigData ( - IN UINTN NumberOfProcessors - ) -{ - VOID *ConfigData; - - ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors); - ASSERT (ConfigData != NULL); - return ConfigData; -} - -/** - Detects if VMX feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE VMX feature is supported. - @retval FALSE VMX feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -VmxSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); - return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1); -} - -/** - Initializes VMX inside SMX feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the VMX inside SMX feature must be enabled. - If FALSE, then the VMX inside SMX feature must be disabled. - - @retval RETURN_SUCCESS VMX inside SMX feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -VmxInsideSmxInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_FEATURE_CONTROL, - MSR_IA32_FEATURE_CONTROL_REGISTER, - Bits.EnableVmxInsideSmx, - (State) ? 1 : 0 - ); - } - return RETURN_SUCCESS; -} - -/** - Initializes SENTER feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the SENTER feature must be enabled. - If FALSE, then the SENTER feature must be disabled. - - @retval RETURN_SUCCESS SENTER feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -SenterInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_FEATURE_CONTROL, - MSR_IA32_FEATURE_CONTROL_REGISTER, - Bits.SenterLocalFunctionEnables, - (State) ? 0x7F : 0 - ); - - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_FEATURE_CONTROL, - MSR_IA32_FEATURE_CONTROL_REGISTER, - Bits.SenterGlobalEnable, - (State) ? 1 : 0 - ); - } - return RETURN_SUCCESS; -} - -/** - Detects if Lock Feature Control Register feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Lock Feature Control Register feature is supported. - @retval FALSE Lock Feature Control Register feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -LockFeatureControlRegisterSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); - return TRUE; -} - -/** - Initializes Lock Feature Control Register feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled. - If FALSE, then the Lock Feature Control Register feature must be disabled. - - @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -LockFeatureControlRegisterInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_FEATURE_CONTROL, - MSR_IA32_FEATURE_CONTROL_REGISTER, - Bits.Lock, - 1 - ); - } - return RETURN_SUCCESS; -} - -/** - Detects if SMX feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE SMX feature is supported. - @retval FALSE SMX feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -SmxSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); - return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1); -} - -/** - Initializes VMX outside SMX feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the VMX outside SMX feature must be enabled. - If FALSE, then the VMX outside SMX feature must be disabled. - - @retval RETURN_SUCCESS VMX outside SMX feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -VmxOutsideSmxInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; - - ASSERT (ConfigData != NULL); - MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; - if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_FEATURE_CONTROL, - MSR_IA32_FEATURE_CONTROL_REGISTER, - Bits.EnableVmxOutsideSmx, - (State) ? 1 : 0 - ); - } - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c deleted file mode 100644 index 40cc9d5fe0..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c +++ /dev/null @@ -1,82 +0,0 @@ -/** @file - LimitCpuidMaxval Feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if LimitCpuidMaxval feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE LimitCpuidMaxval feature is supported. - @retval FALSE LimitCpuidMaxval feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -LimitCpuidMaxvalSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - UINT32 Eax; - - AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL); - return (Eax > 3); -} - -/** - Initializes LimitCpuidMaxval feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled. - If FALSE, then the LimitCpuidMaxval feature must be disabled. - - @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -LimitCpuidMaxvalInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_MISC_ENABLE, - MSR_IA32_MISC_ENABLE_REGISTER, - Bits.LimitCpuidMaxval, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c deleted file mode 100644 index 72f665d32e..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c +++ /dev/null @@ -1,231 +0,0 @@ -/** @file - Machine Check features. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Machine Check Exception feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Machine Check Exception feature is supported. - @retval FALSE Machine Check Exception feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -MceSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1); -} - -/** - Initializes Machine Check Exception feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Machine Check Exception feature must be enabled. - If FALSE, then the Machine Check Exception feature must be disabled. - - @retval RETURN_SUCCESS Machine Check Exception feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -MceInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - // - // Set MCE bit in CR4 - // - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - ControlRegister, - 4, - IA32_CR4, - Bits.MCE, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} - -/** - Detects if Machine Check Architecture feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Machine Check Architecture feature is supported. - @retval FALSE Machine Check Architecture feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -McaSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1); -} - -/** - Initializes Machine Check Architecture feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Machine Check Architecture feature must be enabled. - If FALSE, then the Machine Check Architecture feature must be disabled. - - @retval RETURN_SUCCESS Machine Check Architecture feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -McaInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - MSR_IA32_MCG_CAP_REGISTER McgCap; - UINT32 BankIndex; - - McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); - for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) { - CPU_REGISTER_TABLE_WRITE64 ( - ProcessorNumber, - Msr, - MSR_IA32_MC0_CTL + BankIndex * 4, - MAX_UINT64 - ); - } - - if (PcdGetBool (PcdIsPowerOnReset)) { - for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) { - CPU_REGISTER_TABLE_WRITE64 ( - ProcessorNumber, - Msr, - MSR_IA32_MC0_STATUS + BankIndex * 4, - 0 - ); - } - } - - return RETURN_SUCCESS; -} - -/** - Detects if IA32_MCG_CTL feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE IA32_MCG_CTL feature is supported. - @retval FALSE IA32_MCG_CTL feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -McgCtlSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - MSR_IA32_MCG_CAP_REGISTER McgCap; - - if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) { - return FALSE; - } - McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); - return (McgCap.Bits.MCG_CTL_P == 1); -} - -/** - Initializes IA32_MCG_CTL feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the IA32_MCG_CTL feature must be enabled. - If FALSE, then the IA32_MCG_CTL feature must be disabled. - - @retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -McgCtlInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE64 ( - ProcessorNumber, - Msr, - MSR_IA32_MCG_CTL, - (State)? MAX_UINT64 : 0 - ); - return RETURN_SUCCESS; -} - diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c deleted file mode 100644 index 1d43bd128a..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - MonitorMwait feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if MONITOR/MWAIT feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE MONITOR/MWAIT feature is supported. - @retval FALSE MONITOR/MWAIT feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -MonitorMwaitSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1); -} - -/** - Initializes MONITOR/MWAIT feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled. - If FALSE, then the MONITOR/MWAIT feature must be disabled. - - @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -MonitorMwaitInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_MISC_ENABLE, - MSR_IA32_MISC_ENABLE_REGISTER, - Bits.MONITOR, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c deleted file mode 100644 index 8cafba4f4a..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c +++ /dev/null @@ -1,90 +0,0 @@ -/** @file - Pending Break feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if Pending Break feature supported on current processor. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE Pending Break feature is supported. - @retval FALSE Pending Break feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -PendingBreakSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || - IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { - return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1); - } - return FALSE; -} - -/** - Initializes Pending Break feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the Pending Break feature must be enabled. - If FALSE, then the Pending Break feature must be disabled. - - @retval RETURN_SUCCESS Pending Break feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -PendingBreakInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - // - // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index, - // Simply use MSR_ATOM_IA32_MISC_ENABLE here - // - CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_ATOM_IA32_MISC_ENABLE, - MSR_ATOM_IA32_MISC_ENABLE_REGISTER, - Bits.FERR, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c deleted file mode 100644 index 9c2ad9ad31..0000000000 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c +++ /dev/null @@ -1,81 +0,0 @@ -/** @file - X2Apic feature. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuCommonFeatures.h" - -/** - Detects if X2Apci feature supported on current processor. - - Detect if X2Apci has been already enabled. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - - @retval TRUE X2Apci feature is supported. - @retval FALSE X2Apci feature is not supported. - - @note This service could be called by BSP/APs. -**/ -BOOLEAN -EFIAPI -X2ApicSupport ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData OPTIONAL - ) -{ - return (GetApicMode () == LOCAL_APIC_MODE_X2APIC); -} - -/** - Initializes X2Apci feature to specific state. - - @param[in] ProcessorNumber The index of the CPU executing this function. - @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION - structure for the CPU executing this function. - @param[in] ConfigData A pointer to the configuration buffer returned - by CPU_FEATURE_GET_CONFIG_DATA. NULL if - CPU_FEATURE_GET_CONFIG_DATA was not provided in - RegisterCpuFeature(). - @param[in] State If TRUE, then the X2Apci feature must be enabled. - If FALSE, then the X2Apci feature must be disabled. - - @retval RETURN_SUCCESS X2Apci feature is initialized. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -X2ApicInitialize ( - IN UINTN ProcessorNumber, - IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, - IN VOID *ConfigData, OPTIONAL - IN BOOLEAN State - ) -{ - PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD ( - ProcessorNumber, - Msr, - MSR_IA32_APIC_BASE, - MSR_IA32_APIC_BASE_REGISTER, - Bits.EXTD, - (State) ? 1 : 0 - ); - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c deleted file mode 100644 index 78ee182e8d..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c +++ /dev/null @@ -1,180 +0,0 @@ -/** @file - CPU Exception Handler Library common functions. - - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuExceptionCommon.h" - -// -// Error code flag indicating whether or not an error code will be -// pushed on the stack if an exception occurs. -// -// 1 means an error code will be pushed, otherwise 0 -// -CONST UINT32 mErrorCodeFlag = 0x00027d00; - -// -// Define the maximum message length -// -#define MAX_DEBUG_MESSAGE_LENGTH 0x100 - -CONST CHAR8 mExceptionReservedStr[] = "Reserved"; -CONST CHAR8 *mExceptionNameStr[] = { - "#DE - Divide Error", - "#DB - Debug", - "NMI Interrupt", - "#BP - Breakpoint", - "#OF - Overflow", - "#BR - BOUND Range Exceeded", - "#UD - Invalid Opcode", - "#NM - Device Not Available", - "#DF - Double Fault", - "Coprocessor Segment Overrun", - "#TS - Invalid TSS", - "#NP - Segment Not Present", - "#SS - Stack Fault Fault", - "#GP - General Protection", - "#PF - Page-Fault", - "Reserved", - "#MF - x87 FPU Floating-Point Error", - "#AC - Alignment Check", - "#MC - Machine-Check", - "#XM - SIMD floating-point", - "#VE - Virtualization" -}; - -#define EXCEPTION_KNOWN_NAME_NUM (sizeof (mExceptionNameStr) / sizeof (CHAR8 *)) - -/** - Get ASCII format string exception name by exception type. - - @param ExceptionType Exception type. - - @return ASCII format string exception name. -**/ -CONST CHAR8 * -GetExceptionNameStr ( - IN EFI_EXCEPTION_TYPE ExceptionType - ) -{ - if ((UINTN) ExceptionType < EXCEPTION_KNOWN_NAME_NUM) { - return mExceptionNameStr[ExceptionType]; - } else { - return mExceptionReservedStr; - } -} - -/** - Prints a message to the serial port. - - @param Format Format string for the message to print. - @param ... Variable argument list whose contents are accessed - based on the format string specified by Format. - -**/ -VOID -EFIAPI -InternalPrintMessage ( - IN CONST CHAR8 *Format, - ... - ) -{ - CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; - VA_LIST Marker; - - // - // Convert the message to an ASCII String - // - VA_START (Marker, Format); - AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); - VA_END (Marker); - - // - // Send the print string to a Serial Port - // - SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); -} - -/** - Find and display image base address and return image base and its entry point. - - @param CurrentEip Current instruction pointer. - -**/ -VOID -DumpModuleImageInfo ( - IN UINTN CurrentEip - ) -{ - EFI_STATUS Status; - UINTN Pe32Data; - VOID *PdbPointer; - VOID *EntryPoint; - - Pe32Data = PeCoffSerachImageBase (CurrentEip); - if (Pe32Data == 0) { - InternalPrintMessage ("!!!! Can't find image information. !!!!\n"); - } else { - // - // Find Image Base entry point - // - Status = PeCoffLoaderGetEntryPoint ((VOID *) Pe32Data, &EntryPoint); - if (EFI_ERROR (Status)) { - EntryPoint = NULL; - } - InternalPrintMessage ("!!!! Find image "); - PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data); - if (PdbPointer != NULL) { - InternalPrintMessage ("%a", PdbPointer); - } else { - InternalPrintMessage ("(No PDB) " ); - } - InternalPrintMessage ( - " (ImageBase=%016lp, EntryPoint=%016p) !!!!\n", - (VOID *) Pe32Data, - EntryPoint - ); - } -} - -/** - Read and save reserved vector information - - @param[in] VectorInfo Pointer to reserved vector list. - @param[out] ReservedVector Pointer to reserved vector data buffer. - @param[in] VectorCount Vector number to be updated. - - @return EFI_SUCCESS Read and save vector info successfully. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - -**/ -EFI_STATUS -ReadAndVerifyVectorInfo ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo, - OUT RESERVED_VECTORS_DATA *ReservedVector, - IN UINTN VectorCount - ) -{ - while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) { - if (VectorInfo->Attribute > EFI_VECTOR_HANDOFF_HOOK_AFTER) { - // - // If vector attrubute is invalid - // - return EFI_INVALID_PARAMETER; - } - if (VectorInfo->VectorNumber < VectorCount) { - ReservedVector[VectorInfo->VectorNumber].Attribute = VectorInfo->Attribute; - } - VectorInfo ++; - } - return EFI_SUCCESS; -} \ No newline at end of file diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h deleted file mode 100644 index 740a58828b..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ /dev/null @@ -1,292 +0,0 @@ -/** @file - Common header file for CPU Exception Handler Library. - - Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_EXCEPTION_COMMON_H_ -#define _CPU_EXCEPTION_COMMON_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CPU_EXCEPTION_NUM 32 -#define CPU_INTERRUPT_NUM 256 -#define HOOKAFTER_STUB_SIZE 16 - -// -// Exception Error Code of Page-Fault Exception -// -#define IA32_PF_EC_P BIT0 -#define IA32_PF_EC_WR BIT1 -#define IA32_PF_EC_US BIT2 -#define IA32_PF_EC_RSVD BIT3 -#define IA32_PF_EC_ID BIT4 -#define IA32_PF_EC_PK BIT5 -#define IA32_PF_EC_SGX BIT15 - -#include "ArchInterruptDefs.h" - -#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \ - { \ - 0xb21d9148, 0x9211, 0x4d8f, { 0xad, 0xd3, 0x66, 0xb1, 0x89, 0xc9, 0x2c, 0x83 } \ - } - -// -// Record exception handler information -// -typedef struct { - UINTN ExceptionStart; - UINTN ExceptionStubHeaderSize; - UINTN HookAfterStubHeaderStart; -} EXCEPTION_HANDLER_TEMPLATE_MAP; - -typedef struct { - UINTN IdtEntryCount; - SPIN_LOCK DisplayMessageSpinLock; - RESERVED_VECTORS_DATA *ReservedVectors; - EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; -} EXCEPTION_HANDLER_DATA; - -extern CONST UINT32 mErrorCodeFlag; -extern CONST UINTN mDoFarReturnFlag; - -/** - Return address map of exception handler template so that C code can generate - exception tables. - - @param AddressMap Pointer to a buffer where the address map is returned. -**/ -VOID -EFIAPI -AsmGetTemplateAddressMap ( - OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap - ); - -/** - Return address map of exception handler template so that C code can generate - exception tables. - - @param IdtEntry Pointer to IDT entry to be updated. - @param InterruptHandler IDT handler value. - -**/ -VOID -ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler - ); - -/** - Read IDT handler value from IDT entry. - - @param IdtEntry Pointer to IDT entry to be read. - -**/ -UINTN -ArchGetIdtHandler ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry - ); - -/** - Prints a message to the serial port. - - @param Format Format string for the message to print. - @param ... Variable argument list whose contents are accessed - based on the format string specified by Format. - -**/ -VOID -EFIAPI -InternalPrintMessage ( - IN CONST CHAR8 *Format, - ... - ); - -/** - Find and display image base address and return image base and its entry point. - - @param CurrentEip Current instruction pointer. - -**/ -VOID -DumpModuleImageInfo ( - IN UINTN CurrentEip - ); - -/** - Display CPU information. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -DumpImageAndCpuContent ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ); - -/** - Internal worker function to initialize exception handler. - - @param[in] VectorInfo Pointer to reserved vector list. - @param[in, out] ExceptionHandlerData Pointer to exception handler data. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -InitializeCpuExceptionHandlersWorker ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, - IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -/** - Registers a function to be called from the processor interrupt handler. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled - @param[in] ExceptionHandlerData Pointer to exception handler data. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -RegisterCpuInterruptHandlerWorker ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -/** - Internal worker function to update IDT entries accordling to vector attributes. - - @param[in] IdtTable Pointer to IDT table. - @param[in] TemplateMap Pointer to a buffer where the address map is - returned. - @param[in] ExceptionHandlerData Pointer to exception handler data. - -**/ -VOID -UpdateIdtTable ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtTable, - IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -/** - Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchSaveExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -/** - Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -/** - Fix up the vector number and function address in the vector code. - - @param[in] NewVectorAddr New vector handler address. - @param[in] VectorNum Index of vector. - @param[in] OldVectorAddr Old vector handler address. - -**/ -VOID -EFIAPI -AsmVectorNumFixup ( - IN VOID *NewVectorAddr, - IN UINT8 VectorNum, - IN VOID *OldVectorAddr - ); - -/** - Read and save reserved vector information - - @param[in] VectorInfo Pointer to reserved vector list. - @param[out] ReservedVector Pointer to reserved vector data buffer. - @param[in] VectorCount Vector number to be updated. - - @return EFI_SUCCESS Read and save vector info successfully. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - -**/ -EFI_STATUS -ReadAndVerifyVectorInfo ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo, - OUT RESERVED_VECTORS_DATA *ReservedVector, - IN UINTN VectorCount - ); - -/** - Get ASCII format string exception name by exception type. - - @param ExceptionType Exception type. - - @return ASCII format string exception name. -**/ -CONST CHAR8 * -GetExceptionNameStr ( - IN EFI_EXCEPTION_TYPE ExceptionType - ); - -/** - Internal worker function for common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -CommonExceptionHandlerWorker ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ); - -#endif - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf deleted file mode 100644 index f4a8d01c80..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# CPU Exception Handler library instance for DXE modules. -# -# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeCpuExceptionHandlerLib - MODULE_UNI_FILE = DxeCpuExceptionHandlerLib.uni - FILE_GUID = B6E9835A-EDCF-4748-98A8-27D3C722E02D - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.1 - LIBRARY_CLASS = CpuExceptionHandlerLib|DXE_CORE DXE_DRIVER UEFI_APPLICATION - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.Ia32] - Ia32/ExceptionHandlerAsm.asm - Ia32/ExceptionHandlerAsm.nasm - Ia32/ExceptionHandlerAsm.S - Ia32/ArchExceptionHandler.c - Ia32/ArchInterruptDefs.h - -[Sources.X64] - X64/ExceptionHandlerAsm.asm - X64/ExceptionHandlerAsm.nasm - X64/ExceptionHandlerAsm.S - X64/ArchExceptionHandler.c - X64/ArchInterruptDefs.h - -[Sources.common] - CpuExceptionCommon.h - CpuExceptionCommon.c - PeiDxeSmmCpuException.c - DxeException.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - SerialPortLib - PrintLib - SynchronizationLib - LocalApicLib - PeCoffGetEntryPointLib - MemoryAllocationLib - DebugLib diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni deleted file mode 100644 index ace4b6f287..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Exception Handler library instance for DXE modules. -// -// CPU Exception Handler library instance for DXE modules. -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for DXE modules." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for DXE modules." - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c deleted file mode 100644 index 31febec976..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c +++ /dev/null @@ -1,199 +0,0 @@ -/** @file - CPU exception handler library implemenation for DXE modules. - - Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include "CpuExceptionCommon.h" -#include -#include - -CONST UINTN mDoFarReturnFlag = 0; - -RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM]; -EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM]; -UINTN mEnabledInterruptNum = 0; - -EXCEPTION_HANDLER_DATA mExceptionHandlerData; - -/** - Common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -EFIAPI -CommonExceptionHandler ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData); -} - -/** - Initializes all CPU exceptions entries and provides the default exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuExceptionHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - mExceptionHandlerData.ReservedVectors = mReservedVectorsData; - mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable; - InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); - return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData); -} - -/** - Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized - with default interrupt/exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuInterruptHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - EFI_STATUS Status; - IA32_IDT_GATE_DESCRIPTOR *IdtTable; - IA32_DESCRIPTOR IdtDescriptor; - UINTN IdtEntryCount; - EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; - UINTN Index; - UINTN InterruptEntry; - UINT8 *InterruptEntryCode; - RESERVED_VECTORS_DATA *ReservedVectors; - EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; - - ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM); - ASSERT (ReservedVectors != NULL); - SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM, 0xff); - if (VectorInfo != NULL) { - Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, CPU_INTERRUPT_NUM); - if (EFI_ERROR (Status)) { - FreePool (ReservedVectors); - return EFI_INVALID_PARAMETER; - } - } - - ExternalInterruptHandler = AllocateZeroPool (sizeof (EFI_CPU_INTERRUPT_HANDLER) * CPU_INTERRUPT_NUM); - ASSERT (ExternalInterruptHandler != NULL); - - // - // Read IDT descriptor and calculate IDT size - // - AsmReadIdtr (&IdtDescriptor); - IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); - if (IdtEntryCount > CPU_INTERRUPT_NUM) { - IdtEntryCount = CPU_INTERRUPT_NUM; - } - // - // Create Interrupt Descriptor Table and Copy the old IDT table in - // - IdtTable = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM); - ASSERT (IdtTable != NULL); - CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount); - - AsmGetTemplateAddressMap (&TemplateMap); - ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE); - InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM); - ASSERT (InterruptEntryCode != NULL); - - InterruptEntry = (UINTN) InterruptEntryCode; - for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) { - CopyMem ( - (VOID *) InterruptEntry, - (VOID *) TemplateMap.ExceptionStart, - TemplateMap.ExceptionStubHeaderSize - ); - AsmVectorNumFixup ((VOID *) InterruptEntry, (UINT8) Index, (VOID *) TemplateMap.ExceptionStart); - InterruptEntry += TemplateMap.ExceptionStubHeaderSize; - } - - TemplateMap.ExceptionStart = (UINTN) InterruptEntryCode; - mExceptionHandlerData.IdtEntryCount = CPU_INTERRUPT_NUM; - mExceptionHandlerData.ReservedVectors = ReservedVectors; - mExceptionHandlerData.ExternalInterruptHandler = ExternalInterruptHandler; - InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); - - UpdateIdtTable (IdtTable, &TemplateMap, &mExceptionHandlerData); - - // - // Load Interrupt Descriptor Table - // - IdtDescriptor.Base = (UINTN) IdtTable; - IdtDescriptor.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM - 1); - AsmWriteIdtr ((IA32_DESCRIPTOR *) &IdtDescriptor); - - return EFI_SUCCESS; -} - -/** - Registers a function to be called from the processor interrupt handler. - - This function registers and enables the handler specified by InterruptHandler for a processor - interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the - handler for the processor interrupt or exception type specified by InterruptType is uninstalled. - The installed handler is called once for each processor interrupt or exception. - NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -EFIAPI -RegisterCpuInterruptHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData); -} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c deleted file mode 100644 index f2c39eb193..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c +++ /dev/null @@ -1,230 +0,0 @@ -/** @file - IA32 CPU Exception Handler functons. - - Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuExceptionCommon.h" - -/** - Return address map of exception handler template so that C code can generate - exception tables. - - @param IdtEntry Pointer to IDT entry to be updated. - @param InterruptHandler IDT handler value. - -**/ -VOID -ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler - ) -{ - IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; - IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); - IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; -} - -/** - Read IDT handler value from IDT entry. - - @param IdtEntry Pointer to IDT entry to be read. - -**/ -UINTN -ArchGetIdtHandler ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry - ) -{ - return (UINTN)IdtEntry->Bits.OffsetLow + (((UINTN)IdtEntry->Bits.OffsetHigh) << 16); -} - -/** - Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchSaveExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - IA32_EFLAGS32 Eflags; - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - // - // Save Exception context in global variable - // - ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags; - ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs; - ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextIa32->Eip; - ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextIa32->ExceptionData; - // - // Clear IF flag to avoid old IDT handler enable interrupt by IRET - // - Eflags.UintN = SystemContext.SystemContextIa32->Eflags; - Eflags.Bits.IF = 0; - SystemContext.SystemContextIa32->Eflags = Eflags.UintN; - // - // Modify the EIP in stack, then old IDT handler will return to the stub code - // - SystemContext.SystemContextIa32->Eip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode; -} - -/** - Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - SystemContext.SystemContextIa32->Eflags = ReservedVectors[ExceptionType].OldFlags; - SystemContext.SystemContextIa32->Cs = ReservedVectors[ExceptionType].OldCs; - SystemContext.SystemContextIa32->Eip = ReservedVectors[ExceptionType].OldIp; - SystemContext.SystemContextIa32->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; -} - -/** - Display processor context. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Processor context to be display. -**/ -VOID -EFIAPI -DumpCpuContext ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - InternalPrintMessage ( - "!!!! IA32 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n", - ExceptionType, - GetExceptionNameStr (ExceptionType), - GetApicId () - ); - if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) { - InternalPrintMessage ( - "ExceptionData - %08x", - SystemContext.SystemContextIa32->ExceptionData - ); - if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) { - InternalPrintMessage ( - " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_RSVD) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_US) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_WR) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_P) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_PK) != 0, - (SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_SGX) != 0 - ); - } - InternalPrintMessage ("\n"); - } - InternalPrintMessage ( - "EIP - %08x, CS - %08x, EFLAGS - %08x\n", - SystemContext.SystemContextIa32->Eip, - SystemContext.SystemContextIa32->Cs, - SystemContext.SystemContextIa32->Eflags - ); - InternalPrintMessage ( - "EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x\n", - SystemContext.SystemContextIa32->Eax, - SystemContext.SystemContextIa32->Ecx, - SystemContext.SystemContextIa32->Edx, - SystemContext.SystemContextIa32->Ebx - ); - InternalPrintMessage ( - "ESP - %08x, EBP - %08x, ESI - %08x, EDI - %08x\n", - SystemContext.SystemContextIa32->Esp, - SystemContext.SystemContextIa32->Ebp, - SystemContext.SystemContextIa32->Esi, - SystemContext.SystemContextIa32->Edi - ); - InternalPrintMessage ( - "DS - %08x, ES - %08x, FS - %08x, GS - %08x, SS - %08x\n", - SystemContext.SystemContextIa32->Ds, - SystemContext.SystemContextIa32->Es, - SystemContext.SystemContextIa32->Fs, - SystemContext.SystemContextIa32->Gs, - SystemContext.SystemContextIa32->Ss - ); - InternalPrintMessage ( - "CR0 - %08x, CR2 - %08x, CR3 - %08x, CR4 - %08x\n", - SystemContext.SystemContextIa32->Cr0, - SystemContext.SystemContextIa32->Cr2, - SystemContext.SystemContextIa32->Cr3, - SystemContext.SystemContextIa32->Cr4 - ); - InternalPrintMessage ( - "DR0 - %08x, DR1 - %08x, DR2 - %08x, DR3 - %08x\n", - SystemContext.SystemContextIa32->Dr0, - SystemContext.SystemContextIa32->Dr1, - SystemContext.SystemContextIa32->Dr2, - SystemContext.SystemContextIa32->Dr3 - ); - InternalPrintMessage ( - "DR6 - %08x, DR7 - %08x\n", - SystemContext.SystemContextIa32->Dr6, - SystemContext.SystemContextIa32->Dr7 - ); - InternalPrintMessage ( - "GDTR - %08x %08x, IDTR - %08x %08x\n", - SystemContext.SystemContextIa32->Gdtr[0], - SystemContext.SystemContextIa32->Gdtr[1], - SystemContext.SystemContextIa32->Idtr[0], - SystemContext.SystemContextIa32->Idtr[1] - ); - InternalPrintMessage ( - "LDTR - %08x, TR - %08x\n", - SystemContext.SystemContextIa32->Ldtr, - SystemContext.SystemContextIa32->Tr - ); - InternalPrintMessage ( - "FXSAVE_STATE - %08x\n", - &SystemContext.SystemContextIa32->FxSaveState - ); -} - -/** - Display CPU information. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -DumpImageAndCpuContent ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - DumpCpuContext (ExceptionType, SystemContext); - // - // Dump module image base and module entry point by EIP - // - DumpModuleImageInfo (SystemContext.SystemContextIa32->Eip); -} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h deleted file mode 100644 index a8d3556a80..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchInterruptDefs.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - Ia32 arch definition for CPU Exception Handler Library. - - Copyright (c) 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _ARCH_CPU_INTERRUPT_DEFS_H_ -#define _ARCH_CPU_INTERRUPT_DEFS_H_ - -typedef struct { - EFI_SYSTEM_CONTEXT_IA32 SystemContext; - BOOLEAN ExceptionDataFlag; - UINTN OldIdtHandler; -} EXCEPTION_HANDLER_CONTEXT; - -// -// Register Structure Definitions -// -typedef struct { - EFI_STATUS_CODE_DATA Header; - EFI_SYSTEM_CONTEXT_IA32 SystemContext; -} CPU_STATUS_CODE_TEMPLATE; - -typedef struct { - SPIN_LOCK SpinLock; - UINT32 ApicId; - UINT32 Attribute; - UINTN ExceptonHandler; - UINTN OldFlags; - UINTN OldCs; - UINTN OldIp; - UINTN ExceptionData; - UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; -} RESERVED_VECTORS_DATA; - -#endif diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S deleted file mode 100644 index c134257d9d..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S +++ /dev/null @@ -1,667 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* ExceptionHandlerAsm.S -#* -#* Abstract: -#* -#* IA32 CPU Exception Handler -# -#------------------------------------------------------------------------------ - - -#.MMX -#.XMM - -ASM_GLOBAL ASM_PFX(CommonExceptionHandler) -ASM_GLOBAL ASM_PFX(CommonInterruptEntry) -ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) - -#EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions -#EXTRN ASM_PFX(mDoFarReturnFlag):DWORD # Do far return flag - -.text - -# -# exception handler stub table -# -Exception0Handle: - .byte 0x6a # push #VectorNum - .byte 0 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception1Handle: - .byte 0x6a # push #VectorNum - .byte 1 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception2Handle: - .byte 0x6a # push #VectorNum - .byte 2 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception3Handle: - .byte 0x6a # push #VectorNum - .byte 3 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception4Handle: - .byte 0x6a # push #VectorNum - .byte 4 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception5Handle: - .byte 0x6a # push #VectorNum - .byte 5 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception6Handle: - .byte 0x6a # push #VectorNum - .byte 6 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception7Handle: - .byte 0x6a # push #VectorNum - .byte 7 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception8Handle: - .byte 0x6a # push #VectorNum - .byte 8 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception9Handle: - .byte 0x6a # push #VectorNum - .byte 9 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception10Handle: - .byte 0x6a # push #VectorNum - .byte 10 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception11Handle: - .byte 0x6a # push #VectorNum - .byte 11 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception12Handle: - .byte 0x6a # push #VectorNum - .byte 12 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception13Handle: - .byte 0x6a # push #VectorNum - .byte 13 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception14Handle: - .byte 0x6a # push #VectorNum - .byte 14 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception15Handle: - .byte 0x6a # push #VectorNum - .byte 15 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception16Handle: - .byte 0x6a # push #VectorNum - .byte 16 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception17Handle: - .byte 0x6a # push #VectorNum - .byte 17 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception18Handle: - .byte 0x6a # push #VectorNum - .byte 18 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception19Handle: - .byte 0x6a # push #VectorNum - .byte 19 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception20Handle: - .byte 0x6a # push #VectorNum - .byte 20 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception21Handle: - .byte 0x6a # push #VectorNum - .byte 21 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception22Handle: - .byte 0x6a # push #VectorNum - .byte 22 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception23Handle: - .byte 0x6a # push #VectorNum - .byte 23 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception24Handle: - .byte 0x6a # push #VectorNum - .byte 24 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception25Handle: - .byte 0x6a # push #VectorNum - .byte 25 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception26Handle: - .byte 0x6a # push #VectorNum - .byte 26 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception27Handle: - .byte 0x6a # push #VectorNum - .byte 27 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception28Handle: - .byte 0x6a # push #VectorNum - .byte 28 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception29Handle: - .byte 0x6a # push #VectorNum - .byte 29 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception30Handle: - .byte 0x6a # push #VectorNum - .byte 30 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax -Exception31Handle: - .byte 0x6a # push #VectorNum - .byte 31 - pushl %eax - .byte 0xB8 - .long ASM_PFX(CommonInterruptEntry) - jmp *%eax - -HookAfterStubBegin: - .byte 0x6a # push -VectorNum: - .byte 0 # 0 will be fixed - pushl %eax - .byte 0xB8 # movl ASM_PFX(HookAfterStubHeaderEnd), %eax - .long ASM_PFX(HookAfterStubHeaderEnd) - jmp *%eax -ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) -ASM_PFX(HookAfterStubHeaderEnd): - popl %eax - subl $8, %esp # reserve room for filling exception data later - pushl 8(%esp) - xchgl (%esp), %ecx # get vector number - bt %ecx, ASM_PFX(mErrorCodeFlag) - jnc NoErrorData - pushl (%esp) # addition push if exception data needed -NoErrorData: - xchg (%esp), %ecx # restore ecx - pushl %eax - -#---------------------------------------; -# CommonInterruptEntry ; -#---------------------------------------; -# The follow algorithm is used for the common interrupt routine. - -ASM_GLOBAL ASM_PFX(CommonInterruptEntry) -ASM_PFX(CommonInterruptEntry): - cli - popl %eax - # - # All interrupt handlers are invoked through interrupt gates, so - # IF flag automatically cleared at the entry point - # - - # - # Get vector number from top of stack - # - xchgl (%esp), %ecx - andl $0x0FF, %ecx # Vector number should be less than 256 - cmpl $32, %ecx # Intel reserved vector for exceptions? - jae NoErrorCode - bt %ecx, ASM_PFX(mErrorCodeFlag) - jc HasErrorCode - -NoErrorCode: - - # - # Stack: - # +---------------------+ - # + EFlags + - # +---------------------+ - # + CS + - # +---------------------+ - # + EIP + - # +---------------------+ - # + ECX + - # +---------------------+ <-- ESP - # - # Registers: - # ECX - Vector Number - # - - # - # Put Vector Number on stack - # - pushl %ecx - - # - # Put 0 (dummy) error code on stack, and restore ECX - # - xorl %ecx, %ecx # ECX = 0 - xchgl 4(%esp), %ecx - - jmp ErrorCodeAndVectorOnStack - -HasErrorCode: - - # - # Stack: - # +---------------------+ - # + EFlags + - # +---------------------+ - # + CS + - # +---------------------+ - # + EIP + - # +---------------------+ - # + Error Code + - # +---------------------+ - # + ECX + - # +---------------------+ <-- ESP - # - # Registers: - # ECX - Vector Number - # - - # - # Put Vector Number on stack and restore ECX - # - xchgl (%esp), %ecx - -ErrorCodeAndVectorOnStack: - pushl %ebp - movl %esp, %ebp - - # - # Stack: - # +---------------------+ - # + EFlags + - # +---------------------+ - # + CS + - # +---------------------+ - # + EIP + - # +---------------------+ - # + Error Code + - # +---------------------+ - # + Vector Number + - # +---------------------+ - # + EBP + - # +---------------------+ <-- EBP - # - - # - # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - # is 16-byte aligned - # - andl $0x0fffffff0, %esp - subl $12, %esp - - subl $8, %esp - pushl $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - pushl $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - -#; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pushl %eax - pushl %ecx - pushl %edx - pushl %ebx - leal 24(%ebp), %ecx - pushl %ecx # ESP - pushl (%ebp) # EBP - pushl %esi - pushl %edi - -#; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - movl %ss, %eax - pushl %eax - movzwl 16(%ebp), %eax - pushl %eax - movl %ds, %eax - pushl %eax - movl %es, %eax - pushl %eax - movl %fs, %eax - pushl %eax - movl %gs, %eax - pushl %eax - -#; UINT32 Eip; - movl 12(%ebp), %eax - pushl %eax - -#; UINT32 Gdtr[2], Idtr[2]; - subl $8, %esp - sidt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0x0FFFF, %eax - movl %eax, 4(%esp) - - subl $8, %esp - sgdt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0x0FFFF, %eax - movl %eax, 4(%esp) - -#; UINT32 Ldtr, Tr; - xorl %eax, %eax - str %ax - pushl %eax - sldt %ax - pushl %eax - -#; UINT32 EFlags; - movl 20(%ebp), %eax - pushl %eax - -#; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; -## insure FXSAVE/FXRSTOR is enabled in CR4... -## ... while we're at it, make sure DE is also enabled... - mov $1, %eax - pushl %ebx # temporarily save value of ebx on stack - cpuid # use CPUID to determine if FXSAVE/FXRESTOR - # and DE are supported - popl %ebx # retore value of ebx that was overwritten - # by CPUID - movl %cr4, %eax - pushl %eax # push cr4 firstly - testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support - jz L1 - orl $BIT9, %eax # Set CR4.OSFXSR -L1: - testl $BIT2, %edx # Test for Debugging Extensions support - jz L2 - orl $BIT3, %eax # Set CR4.DE -L2: - movl %eax, %cr4 - movl %cr3, %eax - pushl %eax - movl %cr2, %eax - pushl %eax - xorl %eax, %eax - pushl %eax - movl %cr0, %eax - pushl %eax - -#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - movl %dr7, %eax - pushl %eax - movl %dr6, %eax - pushl %eax - movl %dr3, %eax - pushl %eax - movl %dr2, %eax - pushl %eax - movl %dr1, %eax - pushl %eax - movl %dr0, %eax - pushl %eax - -#; FX_SAVE_STATE_IA32 FxSaveState; - subl $512, %esp - movl %esp, %edi - testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support. - # edx still contains result from CPUID above - jz L3 - .byte 0x0f, 0x0ae, 0x07 #fxsave [edi] -L3: - -#; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -#; UINT32 ExceptionData; - pushl 8(%ebp) - -#; Prepare parameter and call - movl %esp, %edx - pushl %edx - movl 4(%ebp), %edx - pushl %edx - - # - # Call External Exception Handler - # - call ASM_PFX(CommonExceptionHandler) - addl $8, %esp - - cli -#; UINT32 ExceptionData; - addl $4, %esp - -#; FX_SAVE_STATE_IA32 FxSaveState; - movl %esp, %esi - movl $1, %eax - cpuid # use CPUID to determine if FXSAVE/FXRESTOR - # are supported - testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support - jz L4 - .byte 0x0f, 0x0ae, 0x0e # fxrstor [esi] -L4: - addl $512, %esp - -#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -#; Skip restoration of DRx registers to support in-circuit emualators -#; or debuggers set breakpoint in interrupt/exception context - addl $24, %esp - -#; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - popl %eax - movl %eax, %cr0 - addl $4, %esp # not for Cr1 - popl %eax - movl %eax, %cr2 - popl %eax - movl %eax, %cr3 - popl %eax - movl %eax, %cr4 - -#; UINT32 EFlags; - popl 20(%ebp) - -#; UINT32 Ldtr, Tr; -#; UINT32 Gdtr[2], Idtr[2]; -#; Best not let anyone mess with these particular registers... - addl $24, %esp - -#; UINT32 Eip; - popl 12(%ebp) - -#; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -#; NOTE - modified segment registers could hang the debugger... We -#; could attempt to insulate ourselves against this possibility, -#; but that poses risks as well. -#; - popl %gs - popl %fs - popl %es - popl %ds - popl 16(%ebp) - popl %ss - -#; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - popl %edi - popl %esi - addl $4, %esp # not for ebp - addl $4, %esp # not for esp - popl %ebx - popl %edx - popl %ecx - popl %eax - - popl -8(%ebp) - popl -4(%ebp) - movl %ebp, %esp - popl %ebp - addl $8, %esp - cmpl $0, -16(%esp) # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn - cmpl $1, -20(%esp) # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - jz ErrorCode - jmp *-16(%esp) -ErrorCode: - subl $4, %esp - jmp *-12(%esp) - -DoReturn: - cmpl $0, ASM_PFX(mDoFarReturnFlag) - jz DoIret - pushl 8(%esp) # save EFLAGS - addl $16, %esp - pushl -8(%esp) # save CS in new location - pushl -8(%esp) # save EIP in new location - pushl -8(%esp) # save EFLAGS in new location - popfl # restore EFLAGS - lret # far return - -DoIret: - iretl - - -#---------------------------------------; -# _AsmGetTemplateAddressMap ; -#---------------------------------------; -# -# Protocol prototype -# AsmGetTemplateAddressMap ( -# EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap -# ); -# -# Routine Description: -# -# Return address map of interrupt handler template so that C code can generate -# interrupt table. -# -# Arguments: -# -# -# Returns: -# -# Nothing -# -# -# Input: [ebp][0] = Original ebp -# [ebp][4] = Return address -# -# Output: Nothing -# -# Destroys: Nothing -#-----------------------------------------------------------------------------; -#------------------------------------------------------------------------------------- -# AsmGetAddressMap (&AddressMap); -#------------------------------------------------------------------------------------- -ASM_GLOBAL ASM_PFX(AsmGetTemplateAddressMap) -ASM_PFX(AsmGetTemplateAddressMap): - - pushl %ebp - movl %esp,%ebp - pushal - - movl 0x8(%ebp), %ebx - movl $Exception0Handle, (%ebx) - movl $(Exception1Handle - Exception0Handle), 0x4(%ebx) - movl $(HookAfterStubBegin), 0x8(%ebx) - - popal - popl %ebp - ret -#------------------------------------------------------------------------------------- -# AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); -#------------------------------------------------------------------------------------- -ASM_GLOBAL ASM_PFX(AsmVectorNumFixup) -ASM_PFX(AsmVectorNumFixup): - movl 8(%esp), %eax - movl 4(%esp), %ecx - movb %al, (VectorNum - HookAfterStubBegin)(%ecx) - ret diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm deleted file mode 100644 index 126680ea47..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm +++ /dev/null @@ -1,467 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ExceptionHandlerAsm.Asm -; -; Abstract: -; -; IA32 CPU Exception Handler -; -; Notes: -; -;------------------------------------------------------------------------------ - - .686 - .model flat,C - -; -; CommonExceptionHandler() -; -CommonExceptionHandler PROTO C - -.data - -EXTRN mErrorCodeFlag:DWORD ; Error code flags for exceptions -EXTRN mDoFarReturnFlag:DWORD ; Do far return flag - -.code - -ALIGN 8 - -; -; exception handler stub table -; -AsmIdtVectorBegin: -REPEAT 32 - db 6ah ; push #VectorNum - db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum - push eax - mov eax, CommonInterruptEntry - jmp eax -ENDM -AsmIdtVectorEnd: - -HookAfterStubBegin: - db 6ah ; push -VectorNum: - db 0 ; 0 will be fixed - push eax - mov eax, HookAfterStubHeaderEnd - jmp eax -HookAfterStubHeaderEnd: - pop eax - sub esp, 8 ; reserve room for filling exception data later - push [esp + 8] - xchg ecx, [esp] ; get vector number - bt mErrorCodeFlag, ecx - jnc @F - push [esp] ; addition push if exception data needed -@@: - xchg ecx, [esp] ; restore ecx - push eax - -;----------------------------------------------------------------------------; -; CommonInterruptEntry ; -;----------------------------------------------------------------------------; -; The follow algorithm is used for the common interrupt routine. -; Entry from each interrupt with a push eax and eax=interrupt number -; Stack: -; +---------------------+ -; + EFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + EIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + EBP + -; +---------------------+ <-- EBP -CommonInterruptEntry PROC PUBLIC - cli - pop eax - ; - ; All interrupt handlers are invoked through interrupt gates, so - ; IF flag automatically cleared at the entry point - ; - - ; - ; Get vector number from top of stack - ; - xchg ecx, [esp] - and ecx, 0FFh ; Vector number should be less than 256 - cmp ecx, 32 ; Intel reserved vector for exceptions? - jae NoErrorCode - bt mErrorCodeFlag, ecx - jc HasErrorCode - -NoErrorCode: - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + ECX + - ; +---------------------+ <-- ESP - ; - ; Registers: - ; ECX - Vector Number - ; - - ; - ; Put Vector Number on stack - ; - push ecx - - ; - ; Put 0 (dummy) error code on stack, and restore ECX - ; - xor ecx, ecx ; ECX = 0 - xchg ecx, [esp+4] - - jmp ErrorCodeAndVectorOnStack - -HasErrorCode: - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + ECX + - ; +---------------------+ <-- ESP - ; - ; Registers: - ; ECX - Vector Number - ; - - ; - ; Put Vector Number on stack and restore ECX - ; - xchg ecx, [esp] - -ErrorCodeAndVectorOnStack: - push ebp - mov ebp, esp - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + Vector Number + - ; +---------------------+ - ; + EBP + - ; +---------------------+ <-- EBP - ; - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0fffffff0h - sub esp, 12 - - sub esp, 8 - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push eax - push ecx - push edx - push ebx - lea ecx, [ebp + 6 * 4] - push ecx ; ESP - push dword ptr [ebp] ; EBP - push esi - push edi - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - mov eax, ss - push eax - movzx eax, word ptr [ebp + 4 * 4] - push eax - mov eax, ds - push eax - mov eax, es - push eax - mov eax, fs - push eax - mov eax, gs - push eax - -;; UINT32 Eip; - mov eax, [ebp + 3 * 4] - push eax - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - xor eax, eax - str ax - push eax - sldt ax - push eax - -;; UINT32 EFlags; - mov eax, [ebp + 5 * 4] - push eax - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, 1 - push ebx ; temporarily save value of ebx on stack - cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE - ; are supported - pop ebx ; retore value of ebx that was overwritten by CPUID - mov eax, cr4 - push eax ; push cr4 firstly - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support - jz @F - or eax, BIT9 ; Set CR4.OSFXSR -@@: - test edx, BIT2 ; Test for Debugging Extensions support - jz @F - or eax, BIT3 ; Set CR4.DE -@@: - mov cr4, eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; - sub esp, 512 - mov edi, esp - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support. - ; edx still contains result from CPUID above - jz @F - db 0fh, 0aeh, 07h ;fxsave [edi] -@@: - -;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword ptr [ebp + 2 * 4] - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, dword ptr [ebp + 1 * 4] - push edx - - ; - ; Call External Exception Handler - ; - mov eax, CommonExceptionHandler - call eax - add esp, 8 - - cli -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - mov eax, 1 - cpuid ; use CPUID to determine if FXSAVE/FXRESTOR - ; are supported - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support - jz @F - db 0fh, 0aeh, 0eh ; fxrstor [esi] -@@: - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support in-circuit emualators -;; or debuggers set breakpoint in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov cr3, eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop dword ptr [ebp + 5 * 4] - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop dword ptr [ebp + 3 * 4] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop gs - pop fs - pop es - pop ds - pop dword ptr [ebp + 4 * 4] - pop ss - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop edi - pop esi - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop ebx - pop edx - pop ecx - pop eax - - pop dword ptr [ebp - 8] - pop dword ptr [ebp - 4] - mov esp, ebp - pop ebp - add esp, 8 - cmp dword ptr [esp - 16], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn - cmp dword ptr [esp - 20], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - jz ErrorCode - jmp dword ptr [esp - 16] -ErrorCode: - sub esp, 4 - jmp dword ptr [esp - 12] - -DoReturn: - cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET - jz DoIret - push [esp + 8] ; save EFLAGS - add esp, 16 - push [esp - 8] ; save CS in new location - push [esp - 8] ; save EIP in new location - push [esp - 8] ; save EFLAGS in new location - popfd ; restore EFLAGS - retf ; far return - -DoIret: - iretd - -CommonInterruptEntry ENDP - -;---------------------------------------; -; _AsmGetTemplateAddressMap ; -;----------------------------------------------------------------------------; -; -; Protocol prototype -; AsmGetTemplateAddressMap ( -; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap -; ); -; -; Routine Description: -; -; Return address map of interrupt handler template so that C code can generate -; interrupt table. -; -; Arguments: -; -; -; Returns: -; -; Nothing -; -; -; Input: [ebp][0] = Original ebp -; [ebp][4] = Return address -; -; Output: Nothing -; -; Destroys: Nothing -;-----------------------------------------------------------------------------; -AsmGetTemplateAddressMap proc near public - push ebp ; C prolog - mov ebp, esp - pushad - - mov ebx, dword ptr [ebp + 08h] - mov dword ptr [ebx], AsmIdtVectorBegin - mov dword ptr [ebx + 4h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 - mov dword ptr [ebx + 8h], HookAfterStubBegin - - popad - pop ebp - ret -AsmGetTemplateAddressMap ENDP - -;------------------------------------------------------------------------------------- -; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); -;------------------------------------------------------------------------------------- -AsmVectorNumFixup proc near public - mov eax, dword ptr [esp + 8] - mov ecx, [esp + 4] - mov [ecx + (VectorNum - HookAfterStubBegin)], al - ret -AsmVectorNumFixup ENDP -END diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm deleted file mode 100644 index 45d6474091..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm +++ /dev/null @@ -1,462 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ExceptionHandlerAsm.Asm -; -; Abstract: -; -; IA32 CPU Exception Handler -; -; Notes: -; -;------------------------------------------------------------------------------ - -; -; CommonExceptionHandler() -; -extern ASM_PFX(CommonExceptionHandler) - -SECTION .data - -extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions -extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag - -SECTION .text - -ALIGN 8 - -; -; exception handler stub table -; -AsmIdtVectorBegin: -%rep 32 - db 0x6a ; push #VectorNum - db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum - push eax - mov eax, ASM_PFX(CommonInterruptEntry) - jmp eax -%endrep -AsmIdtVectorEnd: - -HookAfterStubBegin: - db 0x6a ; push -VectorNum: - db 0 ; 0 will be fixed - push eax - mov eax, HookAfterStubHeaderEnd - jmp eax -HookAfterStubHeaderEnd: - pop eax - sub esp, 8 ; reserve room for filling exception data later - push dword [esp + 8] - xchg ecx, [esp] ; get vector number - bt [ASM_PFX(mErrorCodeFlag)], ecx - jnc .0 - push dword [esp] ; addition push if exception data needed -.0: - xchg ecx, [esp] ; restore ecx - push eax - -;----------------------------------------------------------------------------; -; CommonInterruptEntry ; -;----------------------------------------------------------------------------; -; The follow algorithm is used for the common interrupt routine. -; Entry from each interrupt with a push eax and eax=interrupt number -; Stack: -; +---------------------+ -; + EFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + EIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + EBP + -; +---------------------+ <-- EBP -global ASM_PFX(CommonInterruptEntry) -ASM_PFX(CommonInterruptEntry): - cli - pop eax - ; - ; All interrupt handlers are invoked through interrupt gates, so - ; IF flag automatically cleared at the entry point - ; - - ; - ; Get vector number from top of stack - ; - xchg ecx, [esp] - and ecx, 0xFF ; Vector number should be less than 256 - cmp ecx, 32 ; Intel reserved vector for exceptions? - jae NoErrorCode - bt [ASM_PFX(mErrorCodeFlag)], ecx - jc HasErrorCode - -NoErrorCode: - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + ECX + - ; +---------------------+ <-- ESP - ; - ; Registers: - ; ECX - Vector Number - ; - - ; - ; Put Vector Number on stack - ; - push ecx - - ; - ; Put 0 (dummy) error code on stack, and restore ECX - ; - xor ecx, ecx ; ECX = 0 - xchg ecx, [esp+4] - - jmp ErrorCodeAndVectorOnStack - -HasErrorCode: - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + ECX + - ; +---------------------+ <-- ESP - ; - ; Registers: - ; ECX - Vector Number - ; - - ; - ; Put Vector Number on stack and restore ECX - ; - xchg ecx, [esp] - -ErrorCodeAndVectorOnStack: - push ebp - mov ebp, esp - - ; - ; Stack: - ; +---------------------+ - ; + EFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + EIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + Vector Number + - ; +---------------------+ - ; + EBP + - ; +---------------------+ <-- EBP - ; - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0xfffffff0 - sub esp, 12 - - sub esp, 8 - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push eax - push ecx - push edx - push ebx - lea ecx, [ebp + 6 * 4] - push ecx ; ESP - push dword [ebp] ; EBP - push esi - push edi - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - mov eax, ss - push eax - movzx eax, word [ebp + 4 * 4] - push eax - mov eax, ds - push eax - mov eax, es - push eax - mov eax, fs - push eax - mov eax, gs - push eax - -;; UINT32 Eip; - mov eax, [ebp + 3 * 4] - push eax - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - xor eax, eax - str ax - push eax - sldt ax - push eax - -;; UINT32 EFlags; - mov eax, [ebp + 5 * 4] - push eax - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, 1 - push ebx ; temporarily save value of ebx on stack - cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE - ; are supported - pop ebx ; retore value of ebx that was overwritten by CPUID - mov eax, cr4 - push eax ; push cr4 firstly - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support - jz .1 - or eax, BIT9 ; Set CR4.OSFXSR -.1: - test edx, BIT2 ; Test for Debugging Extensions support - jz .2 - or eax, BIT3 ; Set CR4.DE -.2: - mov cr4, eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; - sub esp, 512 - mov edi, esp - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support. - ; edx still contains result from CPUID above - jz .3 - db 0xf, 0xae, 0x7 ;fxsave [edi] -.3: - -;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword [ebp + 2 * 4] - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, dword [ebp + 1 * 4] - push edx - - ; - ; Call External Exception Handler - ; - mov eax, ASM_PFX(CommonExceptionHandler) - call eax - add esp, 8 - - cli -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - mov eax, 1 - cpuid ; use CPUID to determine if FXSAVE/FXRESTOR - ; are supported - test edx, BIT24 ; Test for FXSAVE/FXRESTOR support - jz .4 - db 0xf, 0xae, 0xe ; fxrstor [esi] -.4: - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support in-circuit emualators -;; or debuggers set breakpoint in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov cr3, eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop dword [ebp + 5 * 4] - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop dword [ebp + 3 * 4] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop gs - pop fs - pop es - pop ds - pop dword [ebp + 4 * 4] - pop ss - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop edi - pop esi - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop ebx - pop edx - pop ecx - pop eax - - pop dword [ebp - 8] - pop dword [ebp - 4] - mov esp, ebp - pop ebp - add esp, 8 - cmp dword [esp - 16], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn - cmp dword [esp - 20], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - jz ErrorCode - jmp dword [esp - 16] -ErrorCode: - sub esp, 4 - jmp dword [esp - 12] - -DoReturn: - cmp dword [ASM_PFX(mDoFarReturnFlag)], 0 ; Check if need to do far return instead of IRET - jz DoIret - push dword [esp + 8] ; save EFLAGS - add esp, 16 - push dword [esp - 8] ; save CS in new location - push dword [esp - 8] ; save EIP in new location - push dword [esp - 8] ; save EFLAGS in new location - popfd ; restore EFLAGS - retf ; far return - -DoIret: - iretd - -;---------------------------------------; -; _AsmGetTemplateAddressMap ; -;----------------------------------------------------------------------------; -; -; Protocol prototype -; AsmGetTemplateAddressMap ( -; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap -; ); -; -; Routine Description: -; -; Return address map of interrupt handler template so that C code can generate -; interrupt table. -; -; Arguments: -; -; -; Returns: -; -; Nothing -; -; -; Input: [ebp][0] = Original ebp -; [ebp][4] = Return address -; -; Output: Nothing -; -; Destroys: Nothing -;-----------------------------------------------------------------------------; -global ASM_PFX(AsmGetTemplateAddressMap) -ASM_PFX(AsmGetTemplateAddressMap): - push ebp ; C prolog - mov ebp, esp - pushad - - mov ebx, dword [ebp + 0x8] - mov dword [ebx], AsmIdtVectorBegin - mov dword [ebx + 0x4], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 - mov dword [ebx + 0x8], HookAfterStubBegin - - popad - pop ebp - ret - -;------------------------------------------------------------------------------------- -; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmVectorNumFixup) -ASM_PFX(AsmVectorNumFixup): - mov eax, dword [esp + 8] - mov ecx, [esp + 4] - mov [ecx + (VectorNum - HookAfterStubBegin)], al - ret diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c deleted file mode 100644 index 8d8d16ecbd..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c +++ /dev/null @@ -1,180 +0,0 @@ -/** @file - CPU exception handler library implementation for PEIM module. - -Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include "CpuExceptionCommon.h" -#include -#include -#include - -CONST UINTN mDoFarReturnFlag = 0; - -EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID; - -/** - Get exception handler data pointer from GUIDed HOb. - - @return pointer to exception handler data. -**/ -EXCEPTION_HANDLER_DATA * -GetExceptionHandlerData ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - VOID *DataInHob; - EXCEPTION_HANDLER_DATA *ExceptionHandlerData; - - ExceptionHandlerData = NULL; - GuidHob = GetFirstGuidHob (&mCpuExceptrionHandlerLibHobGuid); - if (GuidHob != NULL) { - DataInHob = GET_GUID_HOB_DATA (GuidHob); - ExceptionHandlerData = (EXCEPTION_HANDLER_DATA *)(*(UINTN *)DataInHob); - } - ASSERT (ExceptionHandlerData != NULL); - return ExceptionHandlerData; -} - -/** - Common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -EFIAPI -CommonExceptionHandler ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - EXCEPTION_HANDLER_DATA *ExceptionHandlerData; - - ExceptionHandlerData = GetExceptionHandlerData (); - CommonExceptionHandlerWorker (ExceptionType, SystemContext, ExceptionHandlerData); -} - -/** - Initializes all CPU exceptions entries and provides the default exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - Note: Before invoking this API, caller must allocate memory for IDT table and load - IDTR by AsmWriteIdtr(). - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuExceptionHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - EFI_STATUS Status; - EXCEPTION_HANDLER_DATA *ExceptionHandlerData; - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM); - ASSERT (ReservedVectors != NULL); - - ExceptionHandlerData = AllocatePool (sizeof (EXCEPTION_HANDLER_DATA)); - ASSERT (ExceptionHandlerData != NULL); - ExceptionHandlerData->ReservedVectors = ReservedVectors; - ExceptionHandlerData->ExternalInterruptHandler = NULL; - InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); - - Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData); - if (EFI_ERROR (Status)) { - FreePool (ReservedVectors); - FreePool (ExceptionHandlerData); - return Status; - } - - // - // Build location of CPU MP DATA buffer in HOB - // - BuildGuidDataHob ( - &mCpuExceptrionHandlerLibHobGuid, - (VOID *)&ExceptionHandlerData, - sizeof(UINT64) - ); - - return EFI_SUCCESS; -} - -/** - Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized - with default interrupt/exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuInterruptHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Registers a function to be called from the processor interrupt handler. - - This function registers and enables the handler specified by InterruptHandler for a processor - interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the - handler for the processor interrupt or exception type specified by InterruptType is uninstalled. - The installed handler is called once for each processor interrupt or exception. - NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -EFIAPI -RegisterCpuInterruptHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return EFI_UNSUPPORTED; -} \ No newline at end of file diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf deleted file mode 100644 index 75443288a9..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# CPU Exception Handler library instance for PEI module. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiCpuExceptionHandlerLib - MODULE_UNI_FILE = PeiCpuExceptionHandlerLib.uni - FILE_GUID = 980DDA67-44A6-4897-99E6-275290B71F9E - MODULE_TYPE = PEIM - VERSION_STRING = 1.1 - LIBRARY_CLASS = CpuExceptionHandlerLib|PEI_CORE PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.Ia32] - Ia32/ExceptionHandlerAsm.asm - Ia32/ExceptionHandlerAsm.nasm - Ia32/ExceptionHandlerAsm.S - Ia32/ArchExceptionHandler.c - Ia32/ArchInterruptDefs.h - -[Sources.X64] - X64/ExceptionHandlerAsm.asm - X64/ExceptionHandlerAsm.nasm - X64/ExceptionHandlerAsm.S - X64/ArchExceptionHandler.c - X64/ArchInterruptDefs.h - -[Sources.common] - CpuExceptionCommon.h - CpuExceptionCommon.c - PeiCpuException.c - PeiDxeSmmCpuException.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - SerialPortLib - PrintLib - LocalApicLib - PeCoffGetEntryPointLib - HobLib - MemoryAllocationLib - SynchronizationLib diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni deleted file mode 100644 index a89537f7ff..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Exception Handler library instance for PEI module. -// -// CPU Exception Handler library instance for PEI module. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for PEI module." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for PEI module." - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c deleted file mode 100644 index 0facfde5dd..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ /dev/null @@ -1,294 +0,0 @@ -/** @file - CPU Exception Library provides PEI/DXE/SMM CPU common exception handler. - -Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuExceptionCommon.h" -#include - -/** - Internal worker function for common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -CommonExceptionHandlerWorker ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - EXCEPTION_HANDLER_CONTEXT *ExceptionHandlerContext; - RESERVED_VECTORS_DATA *ReservedVectors; - EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; - - ExceptionHandlerContext = (EXCEPTION_HANDLER_CONTEXT *) (UINTN) (SystemContext.SystemContextIa32); - ReservedVectors = ExceptionHandlerData->ReservedVectors; - ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler; - - switch (ReservedVectors[ExceptionType].Attribute) { - case EFI_VECTOR_HANDOFF_HOOK_BEFORE: - // - // Need to jmp to old IDT handler after this exception handler - // - ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE; - ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler; - break; - case EFI_VECTOR_HANDOFF_HOOK_AFTER: - while (TRUE) { - // - // If if anyone has gotten SPIN_LOCK for owner running hook after - // - if (AcquireSpinLockOrFail (&ReservedVectors[ExceptionType].SpinLock)) { - // - // Need to execute old IDT handler before running this exception handler - // - ReservedVectors[ExceptionType].ApicId = GetApicId (); - ArchSaveExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData); - ExceptionHandlerContext->ExceptionDataFlag = (mErrorCodeFlag & (1 << ExceptionType)) ? TRUE : FALSE; - ExceptionHandlerContext->OldIdtHandler = ReservedVectors[ExceptionType].ExceptonHandler; - return; - } - // - // If failed to acquire SPIN_LOCK, check if it was locked by processor itself - // - if (ReservedVectors[ExceptionType].ApicId == GetApicId ()) { - // - // Old IDT handler has been executed, then restore CPU exception content to - // run new exception handler. - // - ArchRestoreExceptionContext (ExceptionType, SystemContext, ExceptionHandlerData); - // - // Rlease spin lock for ApicId - // - ReleaseSpinLock (&ReservedVectors[ExceptionType].SpinLock); - break; - } - CpuPause (); - } - break; - case 0xffffffff: - break; - default: - // - // It should never reach here - // - CpuDeadLoop (); - break; - } - - if (ExternalInterruptHandler != NULL && - ExternalInterruptHandler[ExceptionType] != NULL) { - (ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContext); - } else if (ExceptionType < CPU_EXCEPTION_NUM) { - // - // Get Spinlock to display CPU information - // - while (!AcquireSpinLockOrFail (&ExceptionHandlerData->DisplayMessageSpinLock)) { - CpuPause (); - } - // - // Display ExceptionType, CPU information and Image information - // - DumpImageAndCpuContent (ExceptionType, SystemContext); - // - // Release Spinlock of output message - // - ReleaseSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); - // - // Enter a dead loop if needn't to execute old IDT handler further - // - if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE) { - CpuDeadLoop (); - } - } -} - -/** - Internal worker function to update IDT entries accordling to vector attributes. - - @param[in] IdtTable Pointer to IDT table. - @param[in] TemplateMap Pointer to a buffer where the address map is - returned. - @param[in] ExceptionHandlerData Pointer to exception handler data. - -**/ -VOID -UpdateIdtTable ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtTable, - IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - UINT16 CodeSegment; - UINTN Index; - UINTN InterruptHandler; - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - // - // Use current CS as the segment selector of interrupt gate in IDT - // - CodeSegment = AsmReadCs (); - - for (Index = 0; Index < ExceptionHandlerData->IdtEntryCount; Index ++) { - IdtTable[Index].Bits.Selector = CodeSegment; - // - // Check reserved vectors attributes - // - switch (ReservedVectors[Index].Attribute) { - case EFI_VECTOR_HANDOFF_DO_NOT_HOOK: - // - // Keep original IDT entry - // - continue; - case EFI_VECTOR_HANDOFF_HOOK_AFTER: - InitializeSpinLock (&ReservedVectors[Index].SpinLock); - CopyMem ( - (VOID *) ReservedVectors[Index].HookAfterStubHeaderCode, - (VOID *) TemplateMap->HookAfterStubHeaderStart, - TemplateMap->ExceptionStubHeaderSize - ); - AsmVectorNumFixup ( - (VOID *) ReservedVectors[Index].HookAfterStubHeaderCode, - (UINT8) Index, - (VOID *) TemplateMap->HookAfterStubHeaderStart - ); - // - // Go on the following code - // - case EFI_VECTOR_HANDOFF_HOOK_BEFORE: - // - // Save original IDT handler address - // - ReservedVectors[Index].ExceptonHandler = ArchGetIdtHandler (&IdtTable[Index]); - // - // Go on the following code - // - default: - // - // Update new IDT entry - // - InterruptHandler = TemplateMap->ExceptionStart + Index * TemplateMap->ExceptionStubHeaderSize; - ArchUpdateIdtEntry (&IdtTable[Index], InterruptHandler); - break; - } - } -} - -/** - Internal worker function to initialize exception handler. - - @param[in] VectorInfo Pointer to reserved vector list. - @param[in, out] ExceptionHandlerData Pointer to exception handler data. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -InitializeCpuExceptionHandlersWorker ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, - IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - EFI_STATUS Status; - IA32_DESCRIPTOR IdtDescriptor; - UINTN IdtEntryCount; - EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; - IA32_IDT_GATE_DESCRIPTOR *IdtTable; - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM, 0xff); - if (VectorInfo != NULL) { - Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, CPU_EXCEPTION_NUM); - if (EFI_ERROR (Status)) { - return EFI_INVALID_PARAMETER; - } - } - - // - // Read IDT descriptor and calculate IDT size - // - AsmReadIdtr (&IdtDescriptor); - IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); - if (IdtEntryCount > CPU_EXCEPTION_NUM) { - // - // CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at most - // - IdtEntryCount = CPU_EXCEPTION_NUM; - } - - IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base; - AsmGetTemplateAddressMap (&TemplateMap); - ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE); - - ExceptionHandlerData->IdtEntryCount = IdtEntryCount; - UpdateIdtTable (IdtTable, &TemplateMap, ExceptionHandlerData); - - return EFI_SUCCESS; -} - -/** - Registers a function to be called from the processor interrupt handler. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled - @param[in] ExceptionHandlerData Pointer to exception handler data. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -RegisterCpuInterruptHandlerWorker ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - UINTN EnabledInterruptNum; - RESERVED_VECTORS_DATA *ReservedVectors; - EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; - - EnabledInterruptNum = ExceptionHandlerData->IdtEntryCount; - ReservedVectors = ExceptionHandlerData->ReservedVectors; - ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler; - - if (InterruptType < 0 || InterruptType >= (EFI_EXCEPTION_TYPE)EnabledInterruptNum || - ReservedVectors[InterruptType].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) { - return EFI_UNSUPPORTED; - } - - if (InterruptHandler == NULL && ExternalInterruptHandler[InterruptType] == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (InterruptHandler != NULL && ExternalInterruptHandler[InterruptType] != NULL) { - return EFI_ALREADY_STARTED; - } - - ExternalInterruptHandler[InterruptType] = InterruptHandler; - return EFI_SUCCESS; -} - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c deleted file mode 100644 index af608bffb6..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ /dev/null @@ -1,179 +0,0 @@ -/** @file - CPU exception handler library implemenation for SEC/PEIM modules. - -Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include "CpuExceptionCommon.h" - -CONST UINTN mDoFarReturnFlag = 0; - -/** - Common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -EFIAPI -CommonExceptionHandler ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - // - // Display ExceptionType, CPU information and Image information - // - DumpImageAndCpuContent (ExceptionType, SystemContext); - - // - // Enter a dead loop. - // - CpuDeadLoop (); -} - -/** - Initializes all CPU exceptions entries and provides the default exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - Note: Before invoking this API, caller must allocate memory for IDT table and load - IDTR by AsmWriteIdtr(). - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuExceptionHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - EFI_STATUS Status; - RESERVED_VECTORS_DATA ReservedVectorData[CPU_EXCEPTION_NUM]; - IA32_DESCRIPTOR IdtDescriptor; - UINTN IdtEntryCount; - UINT16 CodeSegment; - EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; - IA32_IDT_GATE_DESCRIPTOR *IdtTable; - UINTN Index; - UINTN InterruptHandler; - - if (VectorInfo != NULL) { - SetMem ((VOID *) ReservedVectorData, sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM, 0xff); - Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectorData, CPU_EXCEPTION_NUM); - if (EFI_ERROR (Status)) { - return EFI_INVALID_PARAMETER; - } - } - // - // Read IDT descriptor and calculate IDT size - // - AsmReadIdtr (&IdtDescriptor); - IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR); - if (IdtEntryCount > CPU_EXCEPTION_NUM) { - // - // CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at most - // - IdtEntryCount = CPU_EXCEPTION_NUM; - } - // - // Use current CS as the segment selector of interrupt gate in IDT - // - CodeSegment = AsmReadCs (); - - AsmGetTemplateAddressMap (&TemplateMap); - IdtTable = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base; - for (Index = 0; Index < IdtEntryCount; Index ++) { - IdtTable[Index].Bits.Selector = CodeSegment; - // - // Check reserved vectors attributes if has, only EFI_VECTOR_HANDOFF_DO_NOT_HOOK - // supported in this instance - // - if (VectorInfo != NULL) { - if (ReservedVectorData[Index].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) { - continue; - } - } - // - // Update IDT entry - // - InterruptHandler = TemplateMap.ExceptionStart + Index * TemplateMap.ExceptionStubHeaderSize; - ArchUpdateIdtEntry (&IdtTable[Index], InterruptHandler); - } - return EFI_SUCCESS; -} - -/** - Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized - with default interrupt/exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuInterruptHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Registers a function to be called from the processor interrupt handler. - - This function registers and enables the handler specified by InterruptHandler for a processor - interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the - handler for the processor interrupt or exception type specified by InterruptType is uninstalled. - The installed handler is called once for each processor interrupt or exception. - NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -EFIAPI -RegisterCpuInterruptHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return EFI_UNSUPPORTED; -} \ No newline at end of file diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf deleted file mode 100644 index d70a99c100..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf +++ /dev/null @@ -1,59 +0,0 @@ -## @file -# CPU Exception Handler library instance for SEC/PEI modules. -# -# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SecPeiCpuExceptionHandlerLib - MODULE_UNI_FILE = SecPeiCpuExceptionHandlerLib.uni - FILE_GUID = CA4BBC99-DFC6-4234-B553-8B6586B7B113 - MODULE_TYPE = PEIM - VERSION_STRING = 1.1 - LIBRARY_CLASS = CpuExceptionHandlerLib|SEC PEI_CORE PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.Ia32] - Ia32/ExceptionHandlerAsm.asm - Ia32/ExceptionHandlerAsm.nasm - Ia32/ExceptionHandlerAsm.S - Ia32/ArchExceptionHandler.c - Ia32/ArchInterruptDefs.h - -[Sources.X64] - X64/ExceptionHandlerAsm.asm - X64/ExceptionHandlerAsm.nasm - X64/ExceptionHandlerAsm.S - X64/ArchExceptionHandler.c - X64/ArchInterruptDefs.h - -[Sources.common] - CpuExceptionCommon.h - CpuExceptionCommon.c - SecPeiCpuException.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - SerialPortLib - PrintLib - LocalApicLib - PeCoffGetEntryPointLib diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni deleted file mode 100644 index de8b846a67..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Exception Handler library instance for SEC/PEI modules. -// -// CPU Exception Handler library instance for SEC/PEI modules. -// -// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for SEC/PEI modules." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for SEC/PEI modules." - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf deleted file mode 100644 index 634ffcb21d..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# CPU Exception Handler library instance for SMM modules. -# -# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmCpuExceptionHandlerLib - MODULE_UNI_FILE = SmmCpuExceptionHandlerLib.uni - FILE_GUID = 8D2C439B-3981-42ff-9CE5-1B50ECA502D6 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.1 - LIBRARY_CLASS = CpuExceptionHandlerLib|DXE_SMM_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.Ia32] - Ia32/ExceptionHandlerAsm.asm - Ia32/ExceptionHandlerAsm.nasm - Ia32/ExceptionHandlerAsm.S - Ia32/ArchExceptionHandler.c - Ia32/ArchInterruptDefs.h - -[Sources.X64] - X64/ExceptionHandlerAsm.asm - X64/ExceptionHandlerAsm.nasm - X64/ExceptionHandlerAsm.S - X64/ArchExceptionHandler.c - X64/ArchInterruptDefs.h - -[Sources.common] - CpuExceptionCommon.h - CpuExceptionCommon.c - PeiDxeSmmCpuException.c - SmmException.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - SerialPortLib - PrintLib - SynchronizationLib - LocalApicLib - PeCoffGetEntryPointLib - DebugLib - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni deleted file mode 100644 index 3dfa69547b..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Exception Handler library instance for SMM modules. -// -// CPU Exception Handler library instance for SMM modules. -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for SMM modules." - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for SMM modules." - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c deleted file mode 100644 index 7414d3f773..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c +++ /dev/null @@ -1,128 +0,0 @@ -/** @file - CPU exception handler library implemenation for SMM modules. - - Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include "CpuExceptionCommon.h" - -CONST UINTN mDoFarReturnFlag = 1; - -// -// Spin lock for CPU information display -// -SPIN_LOCK mDisplayMessageSpinLock; - -RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM]; -EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM]; -EXCEPTION_HANDLER_DATA mExceptionHandlerData; -/** - Common exception handler. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -EFIAPI -CommonExceptionHandler ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData); -} - -/** - Initializes all CPU exceptions entries and provides the default exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized - with default exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuExceptionHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - mExceptionHandlerData.ReservedVectors = mReservedVectorsData; - mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable; - InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); - return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData); -} - -/** - Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. - - Caller should try to get an array of interrupt and/or exception vectors that are in use and need to - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. - If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. - If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. - - @param[in] VectorInfo Pointer to reserved vector list. - - @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized - with default interrupt/exception handlers. - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -InitializeCpuInterruptHandlers ( - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Registers a function to be called from the processor interrupt handler. - - This function registers and enables the handler specified by InterruptHandler for a processor - interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the - handler for the processor interrupt or exception type specified by InterruptType is uninstalled. - The installed handler is called once for each processor interrupt or exception. - NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. - - @param[in] InterruptType Defines which interrupt or exception to hook. - @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called - when a processor interrupt occurs. If this parameter is NULL, then the handler - will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was - previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not - previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, - or this function is not supported. -**/ -EFI_STATUS -EFIAPI -RegisterCpuInterruptHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData); -} \ No newline at end of file diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c deleted file mode 100644 index 65f0cff680..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ /dev/null @@ -1,262 +0,0 @@ -/** @file - x64 CPU Exception Handler. - - Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CpuExceptionCommon.h" - -/** - Return address map of exception handler template so that C code can generate - exception tables. - - @param IdtEntry Pointer to IDT entry to be updated. - @param InterruptHandler IDT handler value. -**/ -VOID -ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler - ) -{ - IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; - IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); - IdtEntry->Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32); - IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; -} - -/** - Read IDT handler value from IDT entry. - - @param IdtEntry Pointer to IDT entry to be read. - -**/ -UINTN -ArchGetIdtHandler ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry - ) -{ - return IdtEntry->Bits.OffsetLow + (((UINTN) IdtEntry->Bits.OffsetHigh) << 16) + - (((UINTN) IdtEntry->Bits.OffsetUpper) << 32); -} - -/** - Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchSaveExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - IA32_EFLAGS32 Eflags; - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - // - // Save Exception context in global variable - // - ReservedVectors[ExceptionType].OldSs = SystemContext.SystemContextX64->Ss; - ReservedVectors[ExceptionType].OldSp = SystemContext.SystemContextX64->Rsp; - ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextX64->Rflags; - ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextX64->Cs; - ReservedVectors[ExceptionType].OldIp = SystemContext.SystemContextX64->Rip; - ReservedVectors[ExceptionType].ExceptionData = SystemContext.SystemContextX64->ExceptionData; - // - // Clear IF flag to avoid old IDT handler enable interrupt by IRET - // - Eflags.UintN = SystemContext.SystemContextX64->Rflags; - Eflags.Bits.IF = 0; - SystemContext.SystemContextX64->Rflags = Eflags.UintN; - // - // Modify the EIP in stack, then old IDT handler will return to the stub code - // - SystemContext.SystemContextX64->Rip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode; -} - -/** - Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. - - @param[in] ExceptionType Exception type. - @param[in] SystemContext Pointer to EFI_SYSTEM_CONTEXT. - @param[in] ExceptionHandlerData Pointer to exception handler data. -**/ -VOID -ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData - ) -{ - RESERVED_VECTORS_DATA *ReservedVectors; - - ReservedVectors = ExceptionHandlerData->ReservedVectors; - SystemContext.SystemContextX64->Ss = ReservedVectors[ExceptionType].OldSs; - SystemContext.SystemContextX64->Rsp = ReservedVectors[ExceptionType].OldSp; - SystemContext.SystemContextX64->Rflags = ReservedVectors[ExceptionType].OldFlags; - SystemContext.SystemContextX64->Cs = ReservedVectors[ExceptionType].OldCs; - SystemContext.SystemContextX64->Rip = ReservedVectors[ExceptionType].OldIp; - SystemContext.SystemContextX64->ExceptionData = ReservedVectors[ExceptionType].ExceptionData; -} - -/** - Display CPU information. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -EFIAPI -DumpCpuContext ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - InternalPrintMessage ( - "!!!! X64 Exception Type - %02x(%a) CPU Apic ID - %08x !!!!\n", - ExceptionType, - GetExceptionNameStr (ExceptionType), - GetApicId () - ); - if ((mErrorCodeFlag & (1 << ExceptionType)) != 0) { - InternalPrintMessage ( - "ExceptionData - %016lx", - SystemContext.SystemContextX64->ExceptionData - ); - if (ExceptionType == EXCEPT_IA32_PAGE_FAULT) { - InternalPrintMessage ( - " I:%x R:%x U:%x W:%x P:%x PK:%x S:%x", - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_RSVD) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_US) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_WR) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_P) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_PK) != 0, - (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_SGX) != 0 - ); - } - InternalPrintMessage ("\n"); - } - InternalPrintMessage ( - "RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n", - SystemContext.SystemContextX64->Rip, - SystemContext.SystemContextX64->Cs, - SystemContext.SystemContextX64->Rflags - ); - InternalPrintMessage ( - "RAX - %016lx, RCX - %016lx, RDX - %016lx\n", - SystemContext.SystemContextX64->Rax, - SystemContext.SystemContextX64->Rcx, - SystemContext.SystemContextX64->Rdx - ); - InternalPrintMessage ( - "RBX - %016lx, RSP - %016lx, RBP - %016lx\n", - SystemContext.SystemContextX64->Rbx, - SystemContext.SystemContextX64->Rsp, - SystemContext.SystemContextX64->Rbp - ); - InternalPrintMessage ( - "RSI - %016lx, RDI - %016lx\n", - SystemContext.SystemContextX64->Rsi, - SystemContext.SystemContextX64->Rdi - ); - InternalPrintMessage ( - "R8 - %016lx, R9 - %016lx, R10 - %016lx\n", - SystemContext.SystemContextX64->R8, - SystemContext.SystemContextX64->R9, - SystemContext.SystemContextX64->R10 - ); - InternalPrintMessage ( - "R11 - %016lx, R12 - %016lx, R13 - %016lx\n", - SystemContext.SystemContextX64->R11, - SystemContext.SystemContextX64->R12, - SystemContext.SystemContextX64->R13 - ); - InternalPrintMessage ( - "R14 - %016lx, R15 - %016lx\n", - SystemContext.SystemContextX64->R14, - SystemContext.SystemContextX64->R15 - ); - InternalPrintMessage ( - "DS - %016lx, ES - %016lx, FS - %016lx\n", - SystemContext.SystemContextX64->Ds, - SystemContext.SystemContextX64->Es, - SystemContext.SystemContextX64->Fs - ); - InternalPrintMessage ( - "GS - %016lx, SS - %016lx\n", - SystemContext.SystemContextX64->Gs, - SystemContext.SystemContextX64->Ss - ); - InternalPrintMessage ( - "CR0 - %016lx, CR2 - %016lx, CR3 - %016lx\n", - SystemContext.SystemContextX64->Cr0, - SystemContext.SystemContextX64->Cr2, - SystemContext.SystemContextX64->Cr3 - ); - InternalPrintMessage ( - "CR4 - %016lx, CR8 - %016lx\n", - SystemContext.SystemContextX64->Cr4, - SystemContext.SystemContextX64->Cr8 - ); - InternalPrintMessage ( - "DR0 - %016lx, DR1 - %016lx, DR2 - %016lx\n", - SystemContext.SystemContextX64->Dr0, - SystemContext.SystemContextX64->Dr1, - SystemContext.SystemContextX64->Dr2 - ); - InternalPrintMessage ( - "DR3 - %016lx, DR6 - %016lx, DR7 - %016lx\n", - SystemContext.SystemContextX64->Dr3, - SystemContext.SystemContextX64->Dr6, - SystemContext.SystemContextX64->Dr7 - ); - InternalPrintMessage ( - "GDTR - %016lx %016lx, LDTR - %016lx\n", - SystemContext.SystemContextX64->Gdtr[0], - SystemContext.SystemContextX64->Gdtr[1], - SystemContext.SystemContextX64->Ldtr - ); - InternalPrintMessage ( - "IDTR - %016lx %016lx, TR - %016lx\n", - SystemContext.SystemContextX64->Idtr[0], - SystemContext.SystemContextX64->Idtr[1], - SystemContext.SystemContextX64->Tr - ); - InternalPrintMessage ( - "FXSAVE_STATE - %016lx\n", - &SystemContext.SystemContextX64->FxSaveState - ); -} - -/** - Display CPU information. - - @param ExceptionType Exception type. - @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. -**/ -VOID -DumpImageAndCpuContent ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - DumpCpuContext (ExceptionType, SystemContext); - // - // Dump module image base and module entry point by RIP - // - DumpModuleImageInfo (SystemContext.SystemContextX64->Rip); -} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h deleted file mode 100644 index 906480134a..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - X64 arch definition for CPU Exception Handler Library. - - Copyright (c) 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _ARCH_CPU_INTERRUPT_DEFS_H_ -#define _ARCH_CPU_INTERRUPT_DEFS_H_ - -typedef struct { - EFI_SYSTEM_CONTEXT_X64 SystemContext; - BOOLEAN ExceptionDataFlag; - UINTN OldIdtHandler; -} EXCEPTION_HANDLER_CONTEXT; - -// -// Register Structure Definitions -// -typedef struct { - EFI_STATUS_CODE_DATA Header; - EFI_SYSTEM_CONTEXT_X64 SystemContext; -} CPU_STATUS_CODE_TEMPLATE; - -typedef struct { - SPIN_LOCK SpinLock; - UINT32 ApicId; - UINT32 Attribute; - UINTN ExceptonHandler; - UINTN OldSs; - UINTN OldSp; - UINTN OldFlags; - UINTN OldCs; - UINTN OldIp; - UINTN ExceptionData; - UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; -} RESERVED_VECTORS_DATA; - -#endif diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S deleted file mode 100644 index edd363cdaa..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S +++ /dev/null @@ -1,434 +0,0 @@ -#------------------------------------------------------------------------------ ; -# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# ExceptionHandlerAsm.S -# -# Abstract: -# -# x64 CPU Exception Handler -# -# Notes: -# -#------------------------------------------------------------------------------ - - - -ASM_GLOBAL ASM_PFX(CommonExceptionHandler) - -#EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions -#EXTRN ASM_PFX(mDoFarReturnFlag):QWORD # Do far return flag -.text - -#ifdef __APPLE__ -# macros are different between GNU and Xcode as. -.macro IDT_MACRO - push $0 -#else -.macro IDT_MACRO arg - push \arg -#endif - .byte 0xe9 # jmp ASM_PFX(CommonInterruptEntry) - .long ASM_PFX(CommonInterruptEntry) - . - 4 -.endm - -AsmIdtVectorBegin: - IDT_MACRO $0 - IDT_MACRO $1 - IDT_MACRO $2 - IDT_MACRO $3 - IDT_MACRO $4 - IDT_MACRO $5 - IDT_MACRO $6 - IDT_MACRO $7 - IDT_MACRO $8 - IDT_MACRO $9 - IDT_MACRO $10 - IDT_MACRO $11 - IDT_MACRO $12 - IDT_MACRO $13 - IDT_MACRO $14 - IDT_MACRO $15 - IDT_MACRO $16 - IDT_MACRO $17 - IDT_MACRO $18 - IDT_MACRO $19 - IDT_MACRO $20 - IDT_MACRO $21 - IDT_MACRO $22 - IDT_MACRO $23 - IDT_MACRO $24 - IDT_MACRO $25 - IDT_MACRO $26 - IDT_MACRO $27 - IDT_MACRO $28 - IDT_MACRO $29 - IDT_MACRO $30 - IDT_MACRO $31 -AsmIdtVectorEnd: - -HookAfterStubHeaderBegin: - .byte 0x6a # push -PatchVectorNum: - .byte 0 # 0 will be fixed - .byte 0xe9 # jmp ASM_PFX(HookAfterStubHeaderEnd) -PatchFuncAddress: - .set HOOK_ADDRESS, ASM_PFX(HookAfterStubHeaderEnd) - . - 4 - .long HOOK_ADDRESS # will be fixed -ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd) -ASM_PFX(HookAfterStubHeaderEnd): - pushq %rax - movq %rsp, %rax - andl $0x0fffffff0, %esp # make sure 16-byte aligned for exception context - subq $0x18, %rsp # reserve room for filling exception data later - pushq %rcx - movq 8(%rax), %rcx - bt %ecx, ASM_PFX(mErrorCodeFlag)(%rip) - jnc NoErrorData - pushq (%rsp) # push additional rcx to make stack alignment -NoErrorData: - xchgq (%rsp), %rcx # restore rcx, save Exception Number in stack - movq (%rax), %rax # restore rax - -#---------------------------------------; -# CommonInterruptEntry ; -#---------------------------------------; -# The follow algorithm is used for the common interrupt routine. - -ASM_GLOBAL ASM_PFX(CommonInterruptEntry) -ASM_PFX(CommonInterruptEntry): - cli - # - # All interrupt handlers are invoked through interrupt gates, so - # IF flag automatically cleared at the entry point - # - # - # Calculate vector number - # - xchgq (%rsp), %rcx # get the return address of call, actually, it is the address of vector number. - andq $0x0FF, %rcx - cmp $32, %ecx # Intel reserved vector for exceptions? - jae NoErrorCode - pushq %rax - movl ASM_PFX(mErrorCodeFlag)(%rip), %eax - bt %ecx, %eax - popq %rax - jc CommonInterruptEntry_al_0000 - -NoErrorCode: - - # - # Push a dummy error code on the stack - # to maintain coherent stack map - # - pushq (%rsp) - movq $0, 8(%rsp) -CommonInterruptEntry_al_0000: - pushq %rbp - movq %rsp, %rbp - pushq $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - pushq $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - - # - # Stack: - # +---------------------+ <-- 16-byte aligned ensured by processor - # + Old SS + - # +---------------------+ - # + Old RSP + - # +---------------------+ - # + RFlags + - # +---------------------+ - # + CS + - # +---------------------+ - # + RIP + - # +---------------------+ - # + Error Code + - # +---------------------+ - # + RCX / Vector Number + - # +---------------------+ - # + RBP + - # +---------------------+ <-- RBP, 16-byte aligned - # - - - # - # Since here the stack pointer is 16-byte aligned, so - # EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - # is 16-byte aligned - # - -#; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -#; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pushq %r15 - pushq %r14 - pushq %r13 - pushq %r12 - pushq %r11 - pushq %r10 - pushq %r9 - pushq %r8 - pushq %rax - pushq 8(%rbp) # RCX - pushq %rdx - pushq %rbx - pushq 48(%rbp) # RSP - pushq (%rbp) # RBP - pushq %rsi - pushq %rdi - -#; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzwq 56(%rbp), %rax - pushq %rax # for ss - movzwq 32(%rbp), %rax - pushq %rax # for cs - mov %ds, %rax - pushq %rax - mov %es, %rax - pushq %rax - mov %fs, %rax - pushq %rax - mov %gs, %rax - pushq %rax - - movq %rcx, 8(%rbp) # save vector number - -#; UINT64 Rip; - pushq 24(%rbp) - -#; UINT64 Gdtr[2], Idtr[2]; - xorq %rax, %rax - pushq %rax - pushq %rax - sidt (%rsp) - xchgq 2(%rsp), %rax - xchgq (%rsp), %rax - xchgq 8(%rsp), %rax - - xorq %rax, %rax - pushq %rax - pushq %rax - sgdt (%rsp) - xchgq 2(%rsp), %rax - xchgq (%rsp), %rax - xchgq 8(%rsp), %rax - -#; UINT64 Ldtr, Tr; - xorq %rax, %rax - str %ax - pushq %rax - sldt %ax - pushq %rax - -#; UINT64 RFlags; - pushq 40(%rbp) - -#; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - movq %cr8, %rax - pushq %rax - movq %cr4, %rax - orq $0x208, %rax - movq %rax, %cr4 - pushq %rax - mov %cr3, %rax - pushq %rax - mov %cr2, %rax - pushq %rax - xorq %rax, %rax - pushq %rax - mov %cr0, %rax - pushq %rax - -#; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - movq %dr7, %rax - pushq %rax - movq %dr6, %rax - pushq %rax - movq %dr3, %rax - pushq %rax - movq %dr2, %rax - pushq %rax - movq %dr1, %rax - pushq %rax - movq %dr0, %rax - pushq %rax - -#; FX_SAVE_STATE_X64 FxSaveState; - subq $512, %rsp - movq %rsp, %rdi - .byte 0x0f, 0x0ae, 0x07 #fxsave [rdi] - -#; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -#; UINT32 ExceptionData; - pushq 16(%rbp) - -#; Prepare parameter and call - mov 8(%rbp), %rcx - mov %rsp, %rdx - # - # Per X64 calling convention, allocate maximum parameter stack space - # and make sure RSP is 16-byte aligned - # - subq $40, %rsp - call ASM_PFX(CommonExceptionHandler) - addq $40, %rsp - - cli -#; UINT64 ExceptionData; - addq $8, %rsp - -#; FX_SAVE_STATE_X64 FxSaveState; - - movq %rsp, %rsi - .byte 0x0f, 0x0ae, 0x0E # fxrstor [rsi] - addq $512, %rsp - -#; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -#; Skip restoration of DRx registers to support in-circuit emualators -#; or debuggers set breakpoint in interrupt/exception context - addq $48, %rsp - -#; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - popq %rax - movq %rax, %cr0 - addq $8, %rsp # not for Cr1 - popq %rax - movq %rax, %cr2 - popq %rax - movq %rax, %cr3 - popq %rax - movq %rax, %cr4 - popq %rax - movq %rax, %cr8 - -#; UINT64 RFlags; - popq 40(%rbp) - -#; UINT64 Ldtr, Tr; -#; UINT64 Gdtr[2], Idtr[2]; -#; Best not let anyone mess with these particular registers... - addq $48, %rsp - -#; UINT64 Rip; - popq 24(%rbp) - -#; UINT64 Gs, Fs, Es, Ds, Cs, Ss; - popq %rax - # mov %rax, %gs ; not for gs - popq %rax - # mov %rax, %fs ; not for fs - # (X64 will not use fs and gs, so we do not restore it) - popq %rax - mov %rax, %es - popq %rax - mov %rax, %ds - popq 32(%rbp) # for cs - popq 56(%rbp) # for ss - -#; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -#; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - popq %rdi - popq %rsi - addq $8, %rsp # not for rbp - popq 48(%rbp) # for rsp - popq %rbx - popq %rdx - popq %rcx - popq %rax - popq %r8 - popq %r9 - popq %r10 - popq %r11 - popq %r12 - popq %r13 - popq %r14 - popq %r15 - - movq %rbp, %rsp - popq %rbp - addq $16, %rsp - cmpq $0, -32(%rsp) # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - cmpb $1, -40(%rsp) - jz ErrorCode - jmp *-32(%rsp) -ErrorCode: - subq $8, %rsp - jmp *-24(%rsp) - -DoReturn: - pushq %rax - movq ASM_PFX(mDoFarReturnFlag)(%rip), %rax - cmpq $0, %rax # Check if need to do far return instead of IRET - popq %rax - jz DoIret - pushq %rax - movq %rsp, %rax # save old RSP to rax - movq 0x20(%rsp), %rsp - pushq 0x10(%rax) # save CS in new location - pushq 0x8(%rax) # save EIP in new location - pushq 0x18(%rax) # save EFLAGS in new location - movq (%rax), %rax # restore rax - popfq # restore EFLAGS - lretq # far return -DoIret: - iretq - - -#------------------------------------------------------------------------------------- -# AsmGetTemplateAddressMap (&AddressMap); -#------------------------------------------------------------------------------------- -# comments here for definition of address map -ASM_GLOBAL ASM_PFX(AsmGetTemplateAddressMap) -ASM_PFX(AsmGetTemplateAddressMap): - pushq %rbp - movq %rsp, %rbp - - leaq AsmIdtVectorBegin(%rip), %rax - movq %rax, (%rcx) - .set ENTRY_SIZE, ASM_PFX(HookAfterStubHeaderEnd) - HookAfterStubHeaderBegin - movq $(ENTRY_SIZE), 0x08(%rcx) - leaq HookAfterStubHeaderBegin(%rip), %rax - movq %rax, 0x10(%rcx) - - popq %rbp - ret - -#------------------------------------------------------------------------------------- -# VOID -# EFIAPI -# AsmVectorNumFixup ( -# IN VOID *NewVectorAddr, // RCX -# IN UINT8 VectorNum // RDX -# IN VOID *OldVectorAddr, // R8 -# ); -#------------------------------------------------------------------------------------- -ASM_GLOBAL ASM_PFX(AsmVectorNumFixup) -ASM_PFX(AsmVectorNumFixup): - pushq %rbp - movq %rsp, %rbp - -# Patch vector # - movb %dl, (PatchVectorNum - HookAfterStubHeaderBegin)(%rcx) - -# Patch Function address - subq %rcx, %r8 # Calculate the offset value - movl (PatchFuncAddress - HookAfterStubHeaderBegin)(%rcx), %eax - addq %r8, %rax - movl %eax, (PatchFuncAddress - HookAfterStubHeaderBegin)(%rcx) - - popq %rbp - ret - -#END - - diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm deleted file mode 100644 index 726c64a140..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm +++ /dev/null @@ -1,389 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ExceptionHandlerAsm.Asm -; -; Abstract: -; -; x64 CPU Exception Handler -; -; Notes: -; -;------------------------------------------------------------------------------ - -; -; CommonExceptionHandler() -; -externdef CommonExceptionHandler:near - -EXTRN mErrorCodeFlag:DWORD ; Error code flags for exceptions -EXTRN mDoFarReturnFlag:QWORD ; Do far return flag - -data SEGMENT - -.code - -ALIGN 8 - -AsmIdtVectorBegin: -REPEAT 32 - db 6ah ; push #VectorNum - db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum - push rax - mov rax, CommonInterruptEntry - jmp rax -ENDM -AsmIdtVectorEnd: - -HookAfterStubHeaderBegin: - db 6ah ; push -@VectorNum: - db 0 ; 0 will be fixed - push rax - mov rax, HookAfterStubHeaderEnd - jmp rax -HookAfterStubHeaderEnd: - mov rax, rsp - and sp, 0fff0h ; make sure 16-byte aligned for exception context - sub rsp, 18h ; reserve room for filling exception data later - push rcx - mov rcx, [rax + 8] - bt mErrorCodeFlag, ecx - jnc @F - push [rsp] ; push additional rcx to make stack alignment -@@: - xchg rcx, [rsp] ; restore rcx, save Exception Number in stack - push [rax] ; push rax into stack to keep code consistence - -;---------------------------------------; -; CommonInterruptEntry ; -;---------------------------------------; -; The follow algorithm is used for the common interrupt routine. -; Entry from each interrupt with a push eax and eax=interrupt number -; Stack frame would be as follows as specified in IA32 manuals: -; -; +---------------------+ <-- 16-byte aligned ensured by processor -; + Old SS + -; +---------------------+ -; + Old RSP + -; +---------------------+ -; + RFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + RIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + RBP + -; +---------------------+ <-- RBP, 16-byte aligned -; The follow algorithm is used for the common interrupt routine. -CommonInterruptEntry PROC PUBLIC - cli - pop rax - ; - ; All interrupt handlers are invoked through interrupt gates, so - ; IF flag automatically cleared at the entry point - ; - xchg rcx, [rsp] ; Save rcx into stack and save vector number into rcx - and rcx, 0FFh - cmp ecx, 32 ; Intel reserved vector for exceptions? - jae NoErrorCode - bt mErrorCodeFlag, ecx - jc @F - -NoErrorCode: - - ; - ; Push a dummy error code on the stack - ; to maintain coherent stack map - ; - push [rsp] - mov qword ptr [rsp + 8], 0 -@@: - push rbp - mov rbp, rsp - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - - ; - ; Stack: - ; +---------------------+ <-- 16-byte aligned ensured by processor - ; + Old SS + - ; +---------------------+ - ; + Old RSP + - ; +---------------------+ - ; + RFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + RIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + RCX / Vector Number + - ; +---------------------+ - ; + RBP + - ; +---------------------+ <-- RBP, 16-byte aligned - ; - - - ; - ; Since here the stack pointer is 16-byte aligned, so - ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - ; is 16-byte aligned - ; - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - push r15 - push r14 - push r13 - push r12 - push r11 - push r10 - push r9 - push r8 - push rax - push qword ptr [rbp + 8] ; RCX - push rdx - push rbx - push qword ptr [rbp + 48] ; RSP - push qword ptr [rbp] ; RBP - push rsi - push rdi - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzx rax, word ptr [rbp + 56] - push rax ; for ss - movzx rax, word ptr [rbp + 32] - push rax ; for cs - mov rax, ds - push rax - mov rax, es - push rax - mov rax, fs - push rax - mov rax, gs - push rax - - mov [rbp + 8], rcx ; save vector number - -;; UINT64 Rip; - push qword ptr [rbp + 24] - -;; UINT64 Gdtr[2], Idtr[2]; - xor rax, rax - push rax - push rax - sidt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] - - xor rax, rax - push rax - push rax - sgdt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] - -;; UINT64 Ldtr, Tr; - xor rax, rax - str ax - push rax - sldt ax - push rax - -;; UINT64 RFlags; - push qword ptr [rbp + 40] - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - mov rax, cr8 - push rax - mov rax, cr4 - or rax, 208h - mov cr4, rax - push rax - mov rax, cr3 - push rax - mov rax, cr2 - push rax - xor rax, rax - push rax - mov rax, cr0 - push rax - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov rax, dr7 - push rax - mov rax, dr6 - push rax - mov rax, dr3 - push rax - mov rax, dr2 - push rax - mov rax, dr1 - push rax - mov rax, dr0 - push rax - -;; FX_SAVE_STATE_X64 FxSaveState; - sub rsp, 512 - mov rdi, rsp - db 0fh, 0aeh, 07h ;fxsave [rdi] - -;; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push qword ptr [rbp + 16] - -;; Prepare parameter and call - mov rcx, [rbp + 8] - mov rdx, rsp - ; - ; Per X64 calling convention, allocate maximum parameter stack space - ; and make sure RSP is 16-byte aligned - ; - sub rsp, 4 * 8 + 8 - mov rax, CommonExceptionHandler - call rax - add rsp, 4 * 8 + 8 - - cli -;; UINT64 ExceptionData; - add rsp, 8 - -;; FX_SAVE_STATE_X64 FxSaveState; - - mov rsi, rsp - db 0fh, 0aeh, 0Eh ; fxrstor [rsi] - add rsp, 512 - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support in-circuit emualators -;; or debuggers set breakpoint in interrupt/exception context - add rsp, 8 * 6 - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - pop rax - mov cr0, rax - add rsp, 8 ; not for Cr1 - pop rax - mov cr2, rax - pop rax - mov cr3, rax - pop rax - mov cr4, rax - pop rax - mov cr8, rax - -;; UINT64 RFlags; - pop qword ptr [rbp + 40] - -;; UINT64 Ldtr, Tr; -;; UINT64 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add rsp, 48 - -;; UINT64 Rip; - pop qword ptr [rbp + 24] - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; - pop rax - ; mov gs, rax ; not for gs - pop rax - ; mov fs, rax ; not for fs - ; (X64 will not use fs and gs, so we do not restore it) - pop rax - mov es, rax - pop rax - mov ds, rax - pop qword ptr [rbp + 32] ; for cs - pop qword ptr [rbp + 56] ; for ss - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pop rdi - pop rsi - add rsp, 8 ; not for rbp - pop qword ptr [rbp + 48] ; for rsp - pop rbx - pop rdx - pop rcx - pop rax - pop r8 - pop r9 - pop r10 - pop r11 - pop r12 - pop r13 - pop r14 - pop r15 - - mov rsp, rbp - pop rbp - add rsp, 16 - cmp qword ptr [rsp - 32], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn - cmp qword ptr [rsp - 40], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - jz ErrorCode - jmp qword ptr [rsp - 32] -ErrorCode: - sub rsp, 8 - jmp qword ptr [rsp - 24] - -DoReturn: - cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET - jz DoIret - push rax - mov rax, rsp ; save old RSP to rax - mov rsp, [rsp + 20h] - push [rax + 10h] ; save CS in new location - push [rax + 8h] ; save EIP in new location - push [rax + 18h] ; save EFLAGS in new location - mov rax, [rax] ; restore rax - popfq ; restore EFLAGS - DB 48h ; prefix to composite "retq" with next "retf" - retf ; far return -DoIret: - iretq - -CommonInterruptEntry ENDP - -;------------------------------------------------------------------------------------- -; GetTemplateAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -; comments here for definition of address map -AsmGetTemplateAddressMap PROC - mov rax, offset AsmIdtVectorBegin - mov qword ptr [rcx], rax - mov qword ptr [rcx + 8h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 - mov rax, offset HookAfterStubHeaderBegin - mov qword ptr [rcx + 10h], rax - ret -AsmGetTemplateAddressMap ENDP - -;------------------------------------------------------------------------------------- -; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); -;------------------------------------------------------------------------------------- -AsmVectorNumFixup PROC - mov rax, rdx - mov [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al - ret -AsmVectorNumFixup ENDP - -END diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm deleted file mode 100644 index ba8993d84b..0000000000 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm +++ /dev/null @@ -1,387 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ExceptionHandlerAsm.Asm -; -; Abstract: -; -; x64 CPU Exception Handler -; -; Notes: -; -;------------------------------------------------------------------------------ - -; -; CommonExceptionHandler() -; - -extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions -extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag -extern ASM_PFX(CommonExceptionHandler) - -SECTION .data - -DEFAULT REL -SECTION .text - -ALIGN 8 - -AsmIdtVectorBegin: -%rep 32 - db 0x6a ; push #VectorNum - db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum - push rax - mov rax, ASM_PFX(CommonInterruptEntry) - jmp rax -%endrep -AsmIdtVectorEnd: - -HookAfterStubHeaderBegin: - db 0x6a ; push -@VectorNum: - db 0 ; 0 will be fixed - push rax - mov rax, HookAfterStubHeaderEnd - jmp rax -HookAfterStubHeaderEnd: - mov rax, rsp - and sp, 0xfff0 ; make sure 16-byte aligned for exception context - sub rsp, 0x18 ; reserve room for filling exception data later - push rcx - mov rcx, [rax + 8] - bt [ASM_PFX(mErrorCodeFlag)], ecx - jnc .0 - push qword [rsp] ; push additional rcx to make stack alignment -.0: - xchg rcx, [rsp] ; restore rcx, save Exception Number in stack - push qword [rax] ; push rax into stack to keep code consistence - -;---------------------------------------; -; CommonInterruptEntry ; -;---------------------------------------; -; The follow algorithm is used for the common interrupt routine. -; Entry from each interrupt with a push eax and eax=interrupt number -; Stack frame would be as follows as specified in IA32 manuals: -; -; +---------------------+ <-- 16-byte aligned ensured by processor -; + Old SS + -; +---------------------+ -; + Old RSP + -; +---------------------+ -; + RFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + RIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + RBP + -; +---------------------+ <-- RBP, 16-byte aligned -; The follow algorithm is used for the common interrupt routine. -global ASM_PFX(CommonInterruptEntry) -ASM_PFX(CommonInterruptEntry): - cli - pop rax - ; - ; All interrupt handlers are invoked through interrupt gates, so - ; IF flag automatically cleared at the entry point - ; - xchg rcx, [rsp] ; Save rcx into stack and save vector number into rcx - and rcx, 0xFF - cmp ecx, 32 ; Intel reserved vector for exceptions? - jae NoErrorCode - bt [ASM_PFX(mErrorCodeFlag)], ecx - jc HasErrorCode - -NoErrorCode: - - ; - ; Push a dummy error code on the stack - ; to maintain coherent stack map - ; - push qword [rsp] - mov qword [rsp + 8], 0 -HasErrorCode: - push rbp - mov rbp, rsp - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - - ; - ; Stack: - ; +---------------------+ <-- 16-byte aligned ensured by processor - ; + Old SS + - ; +---------------------+ - ; + Old RSP + - ; +---------------------+ - ; + RFlags + - ; +---------------------+ - ; + CS + - ; +---------------------+ - ; + RIP + - ; +---------------------+ - ; + Error Code + - ; +---------------------+ - ; + RCX / Vector Number + - ; +---------------------+ - ; + RBP + - ; +---------------------+ <-- RBP, 16-byte aligned - ; - - ; - ; Since here the stack pointer is 16-byte aligned, so - ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - ; is 16-byte aligned - ; - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - push r15 - push r14 - push r13 - push r12 - push r11 - push r10 - push r9 - push r8 - push rax - push qword [rbp + 8] ; RCX - push rdx - push rbx - push qword [rbp + 48] ; RSP - push qword [rbp] ; RBP - push rsi - push rdi - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzx rax, word [rbp + 56] - push rax ; for ss - movzx rax, word [rbp + 32] - push rax ; for cs - mov rax, ds - push rax - mov rax, es - push rax - mov rax, fs - push rax - mov rax, gs - push rax - - mov [rbp + 8], rcx ; save vector number - -;; UINT64 Rip; - push qword [rbp + 24] - -;; UINT64 Gdtr[2], Idtr[2]; - xor rax, rax - push rax - push rax - sidt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] - - xor rax, rax - push rax - push rax - sgdt [rsp] - xchg rax, [rsp + 2] - xchg rax, [rsp] - xchg rax, [rsp + 8] - -;; UINT64 Ldtr, Tr; - xor rax, rax - str ax - push rax - sldt ax - push rax - -;; UINT64 RFlags; - push qword [rbp + 40] - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - mov rax, cr8 - push rax - mov rax, cr4 - or rax, 0x208 - mov cr4, rax - push rax - mov rax, cr3 - push rax - mov rax, cr2 - push rax - xor rax, rax - push rax - mov rax, cr0 - push rax - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov rax, dr7 - push rax - mov rax, dr6 - push rax - mov rax, dr3 - push rax - mov rax, dr2 - push rax - mov rax, dr1 - push rax - mov rax, dr0 - push rax - -;; FX_SAVE_STATE_X64 FxSaveState; - sub rsp, 512 - mov rdi, rsp - db 0xf, 0xae, 0x7 ;fxsave [rdi] - -;; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push qword [rbp + 16] - -;; Prepare parameter and call - mov rcx, [rbp + 8] - mov rdx, rsp - ; - ; Per X64 calling convention, allocate maximum parameter stack space - ; and make sure RSP is 16-byte aligned - ; - sub rsp, 4 * 8 + 8 - mov rax, ASM_PFX(CommonExceptionHandler) - call rax - add rsp, 4 * 8 + 8 - - cli -;; UINT64 ExceptionData; - add rsp, 8 - -;; FX_SAVE_STATE_X64 FxSaveState; - - mov rsi, rsp - db 0xf, 0xae, 0xE ; fxrstor [rsi] - add rsp, 512 - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support in-circuit emualators -;; or debuggers set breakpoint in interrupt/exception context - add rsp, 8 * 6 - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - pop rax - mov cr0, rax - add rsp, 8 ; not for Cr1 - pop rax - mov cr2, rax - pop rax - mov cr3, rax - pop rax - mov cr4, rax - pop rax - mov cr8, rax - -;; UINT64 RFlags; - pop qword [rbp + 40] - -;; UINT64 Ldtr, Tr; -;; UINT64 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add rsp, 48 - -;; UINT64 Rip; - pop qword [rbp + 24] - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; - pop rax - ; mov gs, rax ; not for gs - pop rax - ; mov fs, rax ; not for fs - ; (X64 will not use fs and gs, so we do not restore it) - pop rax - mov es, rax - pop rax - mov ds, rax - pop qword [rbp + 32] ; for cs - pop qword [rbp + 56] ; for ss - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pop rdi - pop rsi - add rsp, 8 ; not for rbp - pop qword [rbp + 48] ; for rsp - pop rbx - pop rdx - pop rcx - pop rax - pop r8 - pop r9 - pop r10 - pop r11 - pop r12 - pop r13 - pop r14 - pop r15 - - mov rsp, rbp - pop rbp - add rsp, 16 - cmp qword [rsp - 32], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler - jz DoReturn - cmp qword [rsp - 40], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag - jz ErrorCode - jmp qword [rsp - 32] -ErrorCode: - sub rsp, 8 - jmp qword [rsp - 24] - -DoReturn: - cmp qword [ASM_PFX(mDoFarReturnFlag)], 0 ; Check if need to do far return instead of IRET - jz DoIret - push rax - mov rax, rsp ; save old RSP to rax - mov rsp, [rsp + 0x20] - push qword [rax + 0x10] ; save CS in new location - push qword [rax + 0x8] ; save EIP in new location - push qword [rax + 0x18] ; save EFLAGS in new location - mov rax, [rax] ; restore rax - popfq ; restore EFLAGS - DB 0x48 ; prefix to composite "retq" with next "retf" - retf ; far return -DoIret: - iretq - -;------------------------------------------------------------------------------------- -; GetTemplateAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -; comments here for definition of address map -global ASM_PFX(AsmGetTemplateAddressMap) -ASM_PFX(AsmGetTemplateAddressMap): - mov rax, AsmIdtVectorBegin - mov qword [rcx], rax - mov qword [rcx + 0x8], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 - mov rax, HookAfterStubHeaderBegin - mov qword [rcx + 0x10], rax - ret - -;------------------------------------------------------------------------------------- -; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmVectorNumFixup) -ASM_PFX(AsmVectorNumFixup): - mov rax, rdx - mov [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al - ret - diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf deleted file mode 100644 index 9751ba1f0d..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ /dev/null @@ -1,75 +0,0 @@ -## @file -# MP Initialize Library instance for DXE driver. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeMpInitLib - MODULE_UNI_FILE = DxeMpInitLib.uni - FILE_GUID = B88F7146-9834-4c55-BFAC-481CC0C33736 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.1 - LIBRARY_CLASS = MpInitLib|DXE_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.IA32] - Ia32/MpEqu.inc - Ia32/MpFuncs.nasm - -[Sources.X64] - X64/MpEqu.inc - X64/MpFuncs.nasm - -[Sources.common] - DxeMpLib.c - MpLib.c - MpLib.h - Microcode.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - LocalApicLib - MemoryAllocationLib - HobLib - MtrrLib - CpuLib - UefiCpuLib - UefiBootServicesTableLib - DebugAgentLib - -[Protocols] - gEfiTimerArchProtocolGuid ## SOMETIMES_CONSUMES - -[Guids] - gEfiEventExitBootServicesGuid ## CONSUMES ## Event - gEfiEventLegacyBootGuid ## CONSUMES ## Event - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOMETIMES_CONSUMES - diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni deleted file mode 100644 index 99d79974be..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// MP Initialize Library instance for DXE driver. -// -// MP Initialize Library instance for DXE driver. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "MP Initialize Library instance for DXE driver." - -#string STR_MODULE_DESCRIPTION #language en-US "MP Initialize Library instance for DXE driver." - diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c deleted file mode 100644 index b393244e05..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ /dev/null @@ -1,743 +0,0 @@ -/** @file - MP initialize support functions for DXE phase. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MpLib.h" - -#include -#include -#include - -#include - -#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) -#define AP_SAFE_STACK_SIZE 128 - -CPU_MP_DATA *mCpuMpData = NULL; -EFI_EVENT mCheckAllApsEvent = NULL; -EFI_EVENT mMpInitExitBootServicesEvent = NULL; -EFI_EVENT mLegacyBootEvent = NULL; -volatile BOOLEAN mStopCheckAllApsStatus = TRUE; -VOID *mReservedApLoopFunc = NULL; -UINTN mReservedTopOfApStack; -volatile UINT32 mNumberToFinish = 0; - -/** - Enable Debug Agent to support source debugging on AP function. - -**/ -VOID -EnableDebugAgent ( - VOID - ) -{ - // - // Initialize Debug Agent to support source level debug in DXE phase - // - InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_AP, NULL, NULL); -} - -/** - Get the pointer to CPU MP Data structure. - - @return The pointer to CPU MP Data structure. -**/ -CPU_MP_DATA * -GetCpuMpData ( - VOID - ) -{ - ASSERT (mCpuMpData != NULL); - return mCpuMpData; -} - -/** - Save the pointer to CPU MP Data structure. - - @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. -**/ -VOID -SaveCpuMpData ( - IN CPU_MP_DATA *CpuMpData - ) -{ - mCpuMpData = CpuMpData; -} - -/** - Allocate reset vector buffer. - - @param[in, out] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -AllocateResetVector ( - IN OUT CPU_MP_DATA *CpuMpData - ) -{ - EFI_STATUS Status; - UINTN ApResetVectorSize; - EFI_PHYSICAL_ADDRESS StartAddress; - - if (CpuMpData->SaveRestoreFlag) { - BackupAndPrepareWakeupBuffer (CpuMpData); - } else { - ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + - sizeof (MP_CPU_EXCHANGE_INFO); - - StartAddress = BASE_1MB; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (ApResetVectorSize), - &StartAddress - ); - ASSERT_EFI_ERROR (Status); - - CpuMpData->WakeupBuffer = (UINTN) StartAddress; - CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) - (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize); - // - // copy AP reset code in it - // - CopyMem ( - (VOID *) CpuMpData->WakeupBuffer, - (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress, - CpuMpData->AddressMap.RendezvousFunnelSize - ); - } -} - -/** - Free AP reset vector buffer. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -FreeResetVector ( - IN CPU_MP_DATA *CpuMpData - ) -{ - EFI_STATUS Status; - UINTN ApResetVectorSize; - - if (CpuMpData->SaveRestoreFlag) { - RestoreWakeupBuffer (CpuMpData); - } else { - ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + - sizeof (MP_CPU_EXCHANGE_INFO); - Status = gBS->FreePages( - (EFI_PHYSICAL_ADDRESS)CpuMpData->WakeupBuffer, - EFI_SIZE_TO_PAGES (ApResetVectorSize) - ); - ASSERT_EFI_ERROR (Status); - } -} - -/** - Checks APs status and updates APs status if needed. - -**/ -VOID -CheckAndUpdateApsStatus ( - VOID - ) -{ - UINTN ProcessorNumber; - EFI_STATUS Status; - CPU_MP_DATA *CpuMpData; - - CpuMpData = GetCpuMpData (); - - // - // First, check whether pending StartupAllAPs() exists. - // - if (CpuMpData->WaitEvent != NULL) { - - Status = CheckAllAPs (); - // - // If all APs finish for StartupAllAPs(), signal the WaitEvent for it. - // - if (Status != EFI_NOT_READY) { - Status = gBS->SignalEvent (CpuMpData->WaitEvent); - CpuMpData->WaitEvent = NULL; - } - } - - // - // Second, check whether pending StartupThisAPs() callings exist. - // - for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { - - if (CpuMpData->CpuData[ProcessorNumber].WaitEvent == NULL) { - continue; - } - - Status = CheckThisAP (ProcessorNumber); - - if (Status != EFI_NOT_READY) { - gBS->SignalEvent (CpuMpData->CpuData[ProcessorNumber].WaitEvent); - CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL; - } - } -} - -/** - Checks APs' status periodically. - - This function is triggered by timer periodically to check the - state of APs for StartupAllAPs() and StartupThisAP() executed - in non-blocking mode. - - @param[in] Event Event triggered. - @param[in] Context Parameter passed with the event. - -**/ -VOID -EFIAPI -CheckApsStatus ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - // - // If CheckApsStatus() is not stopped, otherwise return immediately. - // - if (!mStopCheckAllApsStatus) { - CheckAndUpdateApsStatus (); - } -} - -/** - Get Protected mode code segment from current GDT table. - - @return Protected mode code segment value. -**/ -UINT16 -GetProtectedModeCS ( - VOID - ) -{ - IA32_DESCRIPTOR GdtrDesc; - IA32_SEGMENT_DESCRIPTOR *GdtEntry; - UINTN GdtEntryCount; - UINT16 Index; - - Index = (UINT16) -1; - AsmReadGdtr (&GdtrDesc); - GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR); - GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base; - for (Index = 0; Index < GdtEntryCount; Index++) { - if (GdtEntry->Bits.L == 0) { - if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.L == 0) { - break; - } - } - GdtEntry++; - } - ASSERT (Index != -1); - return Index * 8; -} - -/** - Do sync on APs. - - @param[in, out] Buffer Pointer to private data buffer. -**/ -VOID -EFIAPI -RelocateApLoop ( - IN OUT VOID *Buffer - ) -{ - CPU_MP_DATA *CpuMpData; - BOOLEAN MwaitSupport; - ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; - UINTN ProcessorNumber; - - MpInitLibWhoAmI (&ProcessorNumber); - CpuMpData = GetCpuMpData (); - MwaitSupport = IsMwaitSupport (); - AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP) (UINTN) mReservedApLoopFunc; - AsmRelocateApLoopFunc ( - MwaitSupport, - CpuMpData->ApTargetCState, - CpuMpData->PmCodeSegment, - mReservedTopOfApStack - ProcessorNumber * AP_SAFE_STACK_SIZE, - (UINTN) &mNumberToFinish - ); - // - // It should never reach here - // - ASSERT (FALSE); -} - -/** - Callback function for ExitBootServices. - - @param[in] Event Event whose notification function is being invoked. - @param[in] Context The pointer to the notification function's context, - which is implementation-dependent. - -**/ -VOID -EFIAPI -MpInitChangeApLoopCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - CPU_MP_DATA *CpuMpData; - - CpuMpData = GetCpuMpData (); - CpuMpData->SaveRestoreFlag = TRUE; - CpuMpData->PmCodeSegment = GetProtectedModeCS (); - CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode); - mNumberToFinish = CpuMpData->CpuCount - 1; - WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL); - while (mNumberToFinish > 0) { - CpuPause (); - } - DEBUG ((DEBUG_INFO, "%a() done!\n", __FUNCTION__)); -} - -/** - Initialize global data for MP support. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -InitMpGlobalData ( - IN CPU_MP_DATA *CpuMpData - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - UINTN ApSafeBufferSize; - - SaveCpuMpData (CpuMpData); - - if (CpuMpData->CpuCount == 1) { - // - // If only BSP exists, return - // - return; - } - - // - // Avoid APs access invalid buffer data which allocated by BootServices, - // so we will allocate reserved data for AP loop code. We also need to - // allocate this buffer below 4GB due to APs may be transferred to 32bit - // protected mode on long mode DXE. - // Allocating it in advance since memory services are not available in - // Exit Boot Services callback function. - // - ApSafeBufferSize = CpuMpData->AddressMap.RelocateApLoopFuncSize; - ApSafeBufferSize += CpuMpData->CpuCount * AP_SAFE_STACK_SIZE; - - Address = BASE_4GB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (ApSafeBufferSize), - &Address - ); - ASSERT_EFI_ERROR (Status); - mReservedApLoopFunc = (VOID *) (UINTN) Address; - ASSERT (mReservedApLoopFunc != NULL); - mReservedTopOfApStack = (UINTN) Address + EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (ApSafeBufferSize)); - ASSERT ((mReservedTopOfApStack & (UINTN)(CPU_STACK_ALIGNMENT - 1)) == 0); - CopyMem ( - mReservedApLoopFunc, - CpuMpData->AddressMap.RelocateApLoopFuncAddress, - CpuMpData->AddressMap.RelocateApLoopFuncSize - ); - - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - CheckApsStatus, - NULL, - &mCheckAllApsEvent - ); - ASSERT_EFI_ERROR (Status); - - // - // Set timer to check all APs status. - // - Status = gBS->SetTimer ( - mCheckAllApsEvent, - TimerPeriodic, - AP_CHECK_INTERVAL - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->CreateEvent ( - EVT_SIGNAL_EXIT_BOOT_SERVICES, - TPL_CALLBACK, - MpInitChangeApLoopCallback, - NULL, - &mMpInitExitBootServicesEvent - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - MpInitChangeApLoopCallback, - NULL, - &gEfiEventLegacyBootGuid, - &mLegacyBootEvent - ); - ASSERT_EFI_ERROR (Status); -} - -/** - This service executes a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure, or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by MpInitLibStartupAllAPs() or - MPInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, - if all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - The buffer is allocated by MP Initialization - library, and it's the caller's responsibility to - free the buffer with FreePool() service. - In blocking mode, it is ready for consumption - when the call returns. In non-blocking mode, - it is ready when WaitEvent is signaled. The - list of failed CPU is terminated by - END_OF_CPU_LIST. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - all enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupAllAPs ( - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ) -{ - EFI_STATUS Status; - - // - // Temporarily stop checkAllApsStatus for avoid resource dead-lock. - // - mStopCheckAllApsStatus = TRUE; - - Status = StartupAllAPsWorker ( - Procedure, - SingleThread, - WaitEvent, - TimeoutInMicroseconds, - ProcedureArgument, - FailedCpuList - ); - - // - // Start checkAllApsStatus - // - mStopCheckAllApsStatus = FALSE; - - return Status; -} - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. - - @param[in] Procedure A pointer to the function to be run on the - designated AP of the system. See type - EFI_AP_PROCEDURE. - @param[in] ProcessorNumber The handle number of the AP. The range is - from 0 to the total number of logical - processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until this AP finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on this AP, - and go on executing immediately. If this AP - return from Procedure or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - this AP to finish this Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - this AP returns from Procedure, then Procedure - on the AP is terminated. The - AP is available for next function assigned - by MpInitLibStartupAllAPs() or - MpInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure on the - specified AP. - @param[out] Finished If NULL, this parameter is ignored. In - blocking mode, this parameter is ignored. - In non-blocking mode, if AP returns from - Procedure before the timeout expires, its - content is set to TRUE. Otherwise, the - value is set to FALSE. The caller can - determine if the AP returned from Procedure - by evaluating this value. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval EFI_SUCCESS In non-blocking mode, the function has been - dispatched to specified AP. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - the specified AP has finished. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupThisAP ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ) -{ - EFI_STATUS Status; - - // - // temporarily stop checkAllApsStatus for avoid resource dead-lock. - // - mStopCheckAllApsStatus = TRUE; - - Status = StartupThisAPWorker ( - Procedure, - ProcessorNumber, - WaitEvent, - TimeoutInMicroseconds, - ProcedureArgument, - Finished - ); - - mStopCheckAllApsStatus = FALSE; - - return Status; -} - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibSwitchBSP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ) -{ - EFI_STATUS Status; - EFI_TIMER_ARCH_PROTOCOL *Timer; - UINT64 TimerPeriod; - - TimerPeriod = 0; - // - // Locate Timer Arch Protocol - // - Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Timer); - if (EFI_ERROR (Status)) { - Timer = NULL; - } - - if (Timer != NULL) { - // - // Save current rate of DXE Timer - // - Timer->GetTimerPeriod (Timer, &TimerPeriod); - // - // Disable DXE Timer and drain pending interrupts - // - Timer->SetTimerPeriod (Timer, 0); - } - - Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP); - - if (Timer != NULL) { - // - // Enable and restore rate of DXE Timer - // - Timer->SetTimerPeriod (Timer, TimerPeriod); - } - - return Status; -} - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. This flag - corresponds to StatusFlag defined in - EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only - the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter - is ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed - prior to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibEnableDisableAP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ) -{ - EFI_STATUS Status; - BOOLEAN TempStopCheckState; - - TempStopCheckState = FALSE; - // - // temporarily stop checkAllAPsStatus for initialize parameters. - // - if (!mStopCheckAllApsStatus) { - mStopCheckAllApsStatus = TRUE; - TempStopCheckState = TRUE; - } - - Status = EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); - - if (TempStopCheckState) { - mStopCheckAllApsStatus = FALSE; - } - - return Status; -} diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc b/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc deleted file mode 100644 index 62762308e2..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc +++ /dev/null @@ -1,43 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpEqu.inc -; -; Abstract: -; -; This is the equates file for Multiple Processor support -; -;------------------------------------------------------------------------------- - -VacantFlag equ 00h -NotVacantFlag equ 0ffh - -CPU_SWITCH_STATE_IDLE equ 0 -CPU_SWITCH_STATE_STORED equ 1 -CPU_SWITCH_STATE_LOADED equ 2 - -LockLocation equ (RendezvousFunnelProcEnd - RendezvousFunnelProcStart) -StackStartAddressLocation equ LockLocation + 04h -StackSizeLocation equ LockLocation + 08h -ApProcedureLocation equ LockLocation + 0Ch -GdtrLocation equ LockLocation + 10h -IdtrLocation equ LockLocation + 16h -BufferStartLocation equ LockLocation + 1Ch -ModeOffsetLocation equ LockLocation + 20h -NumApsExecutingLocation equ LockLocation + 24h -CodeSegmentLocation equ LockLocation + 28h -DataSegmentLocation equ LockLocation + 2Ch -EnableExecuteDisableLocation equ LockLocation + 30h -Cr3Location equ LockLocation + 34h -InitFlagLocation equ LockLocation + 38h -CpuInfoLocation equ LockLocation + 3Ch - diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm deleted file mode 100644 index 52363e6e08..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm +++ /dev/null @@ -1,339 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.nasm -; -; Abstract: -; -; This is the assembly code for MP support -; -;------------------------------------------------------------------------------- - -%include "MpEqu.inc" -extern ASM_PFX(InitializeFloatingPointUnits) - -SECTION .text - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -global ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: -; At this point CS = 0x(vv00) and ip= 0x0. -BITS 16 - mov ebp, eax ; save BIST information - - mov ax, cs - mov ds, ax - mov es, ax - mov ss, ax - xor ax, ax - mov fs, ax - mov gs, ax - - mov si, BufferStartLocation - mov ebx, [si] - - mov si, ModeOffsetLocation - mov eax, [si] - mov si, CodeSegmentLocation - mov edx, [si] - mov di, ax - sub di, 02h - mov [di], dx - sub di, 04h - add eax, ebx - mov [di],eax - - mov si, DataSegmentLocation - mov edx, [si] - - mov si, GdtrLocation -o32 lgdt [cs:si] - - mov si, IdtrLocation -o32 lidt [cs:si] - - xor ax, ax - mov ds, ax - - mov eax, cr0 ; Get control register 0 - or eax, 000000003h ; Set PE bit (bit #0) & MP - mov cr0, eax - - jmp 0:strict dword 0 ; far jump to protected mode -BITS 32 -Flat32Start: ; protected mode entry point - mov ds, dx - mov es, dx - mov fs, dx - mov gs, dx - mov ss, dx - - mov esi, ebx - - mov edi, esi - add edi, EnableExecuteDisableLocation - cmp byte [edi], 0 - jz SkipEnableExecuteDisable - - ; - ; Enable IA32 PAE execute disable - ; - - mov ecx, 0xc0000080 - rdmsr - bts eax, 11 - wrmsr - - mov edi, esi - add edi, Cr3Location - mov eax, dword [edi] - mov cr3, eax - - mov eax, cr4 - bts eax, 5 - mov cr4, eax - - mov eax, cr0 - bts eax, 31 - mov cr0, eax - -SkipEnableExecuteDisable: - mov edi, esi - add edi, InitFlagLocation - cmp dword [edi], 1 ; 1 == ApInitConfig - jnz GetApicId - - ; AP init - mov edi, esi - add edi, LockLocation - mov eax, NotVacantFlag - -TestLock: - xchg [edi], eax - cmp eax, NotVacantFlag - jz TestLock - - mov ecx, esi - add ecx, NumApsExecutingLocation - inc dword [ecx] - mov ebx, [ecx] - -Releaselock: - mov eax, VacantFlag - xchg [edi], eax - - mov edi, esi - add edi, StackSizeLocation - mov eax, [edi] - mov ecx, ebx - inc ecx - mul ecx ; EAX = StackSize * (CpuNumber + 1) - mov edi, esi - add edi, StackStartAddressLocation - add eax, [edi] - mov esp, eax - jmp CProcedureInvoke - -GetApicId: - mov eax, 0 - cpuid - cmp eax, 0bh - jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY - - mov eax, 0bh - xor ecx, ecx - cpuid - test ebx, 0ffffh - jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero - - ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX - jmp GetProcessorNumber - -NoX2Apic: - ; Processor is not x2APIC capable, so get 8-bit APIC ID - mov eax, 1 - cpuid - shr ebx, 24 - mov edx, ebx - -GetProcessorNumber: - ; - ; Get processor number for this AP - ; Note that BSP may become an AP due to SwitchBsp() - ; - xor ebx, ebx - lea eax, [esi + CpuInfoLocation] - mov edi, [eax] - -GetNextProcNumber: - cmp [edi], edx ; APIC ID match? - jz ProgramStack - add edi, 20 - inc ebx - jmp GetNextProcNumber - -ProgramStack: - mov esp, [edi + 12] - -CProcedureInvoke: - push ebp ; push BIST data at top of AP stack - xor ebp, ebp ; clear ebp for call stack trace - push ebp - mov ebp, esp - - mov eax, ASM_PFX(InitializeFloatingPointUnits) - call eax ; Call assembly function to initialize FPU per UEFI spec - - push ebx ; Push NumApsExecuting - mov eax, esi - add eax, LockLocation - push eax ; push address of exchange info data buffer - - mov edi, esi - add edi, ApProcedureLocation - mov eax, [edi] - - call eax ; Invoke C function - - jmp $ ; Never reach here -RendezvousFunnelProcEnd: - -;------------------------------------------------------------------------------------- -; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmRelocateApLoop) -ASM_PFX(AsmRelocateApLoop): -AsmRelocateApLoopStart: - mov eax, esp - mov esp, [eax + 16] ; TopOfApStack - push dword [eax] ; push return address for stack trace - push ebp - mov ebp, esp - mov ebx, [eax + 8] ; ApTargetCState - mov ecx, [eax + 4] ; MwaitSupport - mov eax, [eax + 20] ; CountTofinish - lock dec dword [eax] ; (*CountTofinish)-- - cmp cl, 1 ; Check mwait-monitor support - jnz HltLoop -MwaitLoop: - mov eax, esp - xor ecx, ecx - xor edx, edx - monitor - mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4] - shl eax, 4 - mwait - jmp MwaitLoop -HltLoop: - cli - hlt - jmp HltLoop -AsmRelocateApLoopEnd: - -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - pushad - mov ebp,esp - - mov ebx, [ebp + 24h] - mov dword [ebx], RendezvousFunnelProcStart - mov dword [ebx + 4h], Flat32Start - RendezvousFunnelProcStart - mov dword [ebx + 8h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - mov dword [ebx + 0Ch], AsmRelocateApLoopStart - mov dword [ebx + 10h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart - - popad - ret - -;------------------------------------------------------------------------------------- -;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is -;about to become an AP. It switches it'stack with the current AP. -;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmExchangeRole) -ASM_PFX(AsmExchangeRole): - ; DO NOT call other functions in this function, since 2 CPU may use 1 stack - ; at the same time. If 1 CPU try to call a function, stack will be corrupted. - pushad - mov ebp,esp - - ; esi contains MyInfo pointer - mov esi, [ebp + 24h] - - ; edi contains OthersInfo pointer - mov edi, [ebp + 28h] - - ;Store EFLAGS, GDTR and IDTR register to stack - pushfd - mov eax, cr4 - push eax ; push cr4 firstly - mov eax, cr0 - push eax - - sgdt [esi + 8] - sidt [esi + 14] - - ; Store the its StackPointer - mov [esi + 4],esp - - ; update its switch state to STORED - mov byte [esi], CPU_SWITCH_STATE_STORED - -WaitForOtherStored: - ; wait until the other CPU finish storing its state - cmp byte [edi], CPU_SWITCH_STATE_STORED - jz OtherStored - pause - jmp WaitForOtherStored - -OtherStored: - ; Since another CPU already stored its state, load them - ; load GDTR value - lgdt [edi + 8] - - ; load IDTR value - lidt [edi + 14] - - ; load its future StackPointer - mov esp, [edi + 4] - - ; update the other CPU's switch state to LOADED - mov byte [edi], CPU_SWITCH_STATE_LOADED - -WaitForOtherLoaded: - ; wait until the other CPU finish loading new state, - ; otherwise the data in stack may corrupt - cmp byte [esi], CPU_SWITCH_STATE_LOADED - jz OtherLoaded - pause - jmp WaitForOtherLoaded - -OtherLoaded: - ; since the other CPU already get the data it want, leave this procedure - pop eax - mov cr0, eax - pop eax - mov cr4, eax - popfd - - popad - ret diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c deleted file mode 100644 index 982995be7d..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ /dev/null @@ -1,218 +0,0 @@ -/** @file - Implementation of loading microcode on processors. - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MpLib.h" - -/** - Get microcode update signature of currently loaded microcode update. - - @return Microcode signature. -**/ -UINT32 -GetCurrentMicrocodeSignature ( - VOID - ) -{ - MSR_IA32_BIOS_SIGN_ID_REGISTER BiosSignIdMsr; - - AsmWriteMsr64 (MSR_IA32_BIOS_SIGN_ID, 0); - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, NULL); - BiosSignIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_BIOS_SIGN_ID); - return BiosSignIdMsr.Bits.MicrocodeUpdateSignature; -} - -/** - Detect whether specified processor can find matching microcode patch and load it. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -MicrocodeDetect ( - IN CPU_MP_DATA *CpuMpData - ) -{ - UINT64 MicrocodePatchAddress; - UINT64 MicrocodePatchRegionSize; - UINT32 ExtendedTableLength; - UINT32 ExtendedTableCount; - CPU_MICROCODE_EXTENDED_TABLE *ExtendedTable; - CPU_MICROCODE_EXTENDED_TABLE_HEADER *ExtendedTableHeader; - CPU_MICROCODE_HEADER *MicrocodeEntryPoint; - UINTN MicrocodeEnd; - UINTN Index; - UINT8 PlatformId; - CPUID_VERSION_INFO_EAX Eax; - UINT32 CurrentRevision; - UINT32 LatestRevision; - UINTN TotalSize; - UINT32 CheckSum32; - BOOLEAN CorrectMicrocode; - VOID *MicrocodeData; - MSR_IA32_PLATFORM_ID_REGISTER PlatformIdMsr; - - MicrocodePatchAddress = PcdGet64 (PcdCpuMicrocodePatchAddress); - MicrocodePatchRegionSize = PcdGet64 (PcdCpuMicrocodePatchRegionSize); - if (MicrocodePatchRegionSize == 0) { - // - // There is no microcode patches - // - return; - } - - CurrentRevision = GetCurrentMicrocodeSignature (); - if (CurrentRevision != 0) { - // - // Skip loading microcode if it has been loaded successfully - // - return; - } - - ExtendedTableLength = 0; - // - // Here data of CPUID leafs have not been collected into context buffer, so - // GetProcessorCpuid() cannot be used here to retrieve sCPUID data. - // - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL); - - // - // The index of platform information resides in bits 50:52 of MSR IA32_PLATFORM_ID - // - PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); - PlatformId = (UINT8) PlatformIdMsr.Bits.PlatformId; - - LatestRevision = 0; - MicrocodeData = NULL; - MicrocodeEnd = (UINTN) (MicrocodePatchAddress + MicrocodePatchRegionSize); - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) MicrocodePatchAddress; - do { - // - // Check if the microcode is for the Cpu and the version is newer - // and the update can be processed on the platform - // - CorrectMicrocode = FALSE; - if (MicrocodeEntryPoint->HeaderVersion == 0x1) { - // - // It is the microcode header. It is not the padding data between microcode patches - // because the padding data should not include 0x00000001 and it should be the repeated - // byte format (like 0xXYXYXYXY....). - // - if (MicrocodeEntryPoint->ProcessorSignature.Uint32 == Eax.Uint32 && - MicrocodeEntryPoint->UpdateRevision > LatestRevision && - (MicrocodeEntryPoint->ProcessorFlags & (1 << PlatformId)) - ) { - if (MicrocodeEntryPoint->DataSize == 0) { - CheckSum32 = CalculateSum32 ((UINT32 *) MicrocodeEntryPoint, 2048); - } else { - CheckSum32 = CalculateSum32 ( - (UINT32 *) MicrocodeEntryPoint, - MicrocodeEntryPoint->DataSize + sizeof (CPU_MICROCODE_HEADER) - ); - } - if (CheckSum32 == 0) { - CorrectMicrocode = TRUE; - } - } else if ((MicrocodeEntryPoint->DataSize != 0) && - (MicrocodeEntryPoint->UpdateRevision > LatestRevision)) { - ExtendedTableLength = MicrocodeEntryPoint->TotalSize - (MicrocodeEntryPoint->DataSize + - sizeof (CPU_MICROCODE_HEADER)); - if (ExtendedTableLength != 0) { - // - // Extended Table exist, check if the CPU in support list - // - ExtendedTableHeader = (CPU_MICROCODE_EXTENDED_TABLE_HEADER *) ((UINT8 *) (MicrocodeEntryPoint) - + MicrocodeEntryPoint->DataSize + sizeof (CPU_MICROCODE_HEADER)); - // - // Calculate Extended Checksum - // - if ((ExtendedTableLength % 4) == 0) { - CheckSum32 = CalculateSum32 ((UINT32 *) ExtendedTableHeader, ExtendedTableLength); - if (CheckSum32 == 0) { - // - // Checksum correct - // - ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount; - ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *) (ExtendedTableHeader + 1); - for (Index = 0; Index < ExtendedTableCount; Index ++) { - CheckSum32 = CalculateSum32 ((UINT32 *) ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE)); - if (CheckSum32 == 0) { - // - // Verify Header - // - if ((ExtendedTable->ProcessorSignature.Uint32 == Eax.Uint32) && - (ExtendedTable->ProcessorFlag & (1 << PlatformId)) ) { - // - // Find one - // - CorrectMicrocode = TRUE; - break; - } - } - ExtendedTable ++; - } - } - } - } - } - } else { - // - // It is the padding data between the microcode patches for microcode patches alignment. - // Because the microcode patch is the multiple of 1-KByte, the padding data should not - // exist if the microcode patch alignment value is not larger than 1-KByte. So, the microcode - // alignment value should be larger than 1-KByte. We could skip SIZE_1KB padding data to - // find the next possible microcode patch header. - // - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + SIZE_1KB); - continue; - } - // - // Get the next patch. - // - if (MicrocodeEntryPoint->DataSize == 0) { - TotalSize = 2048; - } else { - TotalSize = MicrocodeEntryPoint->TotalSize; - } - - if (CorrectMicrocode) { - LatestRevision = MicrocodeEntryPoint->UpdateRevision; - MicrocodeData = (VOID *) ((UINTN) MicrocodeEntryPoint + sizeof (CPU_MICROCODE_HEADER)); - } - - MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (((UINTN) MicrocodeEntryPoint) + TotalSize); - } while (((UINTN) MicrocodeEntryPoint < MicrocodeEnd)); - - if (LatestRevision > CurrentRevision) { - // - // BIOS only authenticate updates that contain a numerically larger revision - // than the currently loaded revision, where Current Signature < New Update - // Revision. A processor with no loaded update is considered to have a - // revision equal to zero. - // - ASSERT (MicrocodeData != NULL); - AsmWriteMsr64 ( - MSR_IA32_BIOS_UPDT_TRIG, - (UINT64) (UINTN) MicrocodeData - ); - // - // Get and check new microcode signature - // - CurrentRevision = GetCurrentMicrocodeSignature (); - if (CurrentRevision != LatestRevision) { - AcquireSpinLock(&CpuMpData->MpLock); - DEBUG ((EFI_D_ERROR, "Updated microcode signature [0x%08x] does not match \ - loaded microcode signature [0x%08x]\n", CurrentRevision, LatestRevision)); - ReleaseSpinLock(&CpuMpData->MpLock); - } - } -} diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c deleted file mode 100644 index 03d6c2d89e..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ /dev/null @@ -1,2126 +0,0 @@ -/** @file - CPU MP Initialize Library common functions. - - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MpLib.h" - -EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID; - -/** - The function will check if BSP Execute Disable is enabled. - - DxeIpl may have enabled Execute Disable for BSP, APs need to - get the status and sync up the settings. - If BSP's CR0.Paging is not set, BSP execute Disble feature is - not working actually. - - @retval TRUE BSP Execute Disable is enabled. - @retval FALSE BSP Execute Disable is not enabled. -**/ -BOOLEAN -IsBspExecuteDisableEnabled ( - VOID - ) -{ - UINT32 Eax; - CPUID_EXTENDED_CPU_SIG_EDX Edx; - MSR_IA32_EFER_REGISTER EferMsr; - BOOLEAN Enabled; - IA32_CR0 Cr0; - - Enabled = FALSE; - Cr0.UintN = AsmReadCr0 (); - if (Cr0.Bits.PG != 0) { - // - // If CR0 Paging bit is set - // - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); - if (Eax >= CPUID_EXTENDED_CPU_SIG) { - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); - // - // CPUID 0x80000001 - // Bit 20: Execute Disable Bit available. - // - if (Edx.Bits.NX != 0) { - EferMsr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER); - // - // MSR 0xC0000080 - // Bit 11: Execute Disable Bit enable. - // - if (EferMsr.Bits.NXE != 0) { - Enabled = TRUE; - } - } - } - } - - return Enabled; -} - -/** - Worker function for SwitchBSP(). - - Worker function for SwitchBSP(), assigned to the AP which is intended - to become BSP. - - @param[in] Buffer Pointer to CPU MP Data -**/ -VOID -EFIAPI -FutureBSPProc ( - IN VOID *Buffer - ) -{ - CPU_MP_DATA *DataInHob; - - DataInHob = (CPU_MP_DATA *) Buffer; - AsmExchangeRole (&DataInHob->APInfo, &DataInHob->BSPInfo); -} - -/** - Get the Application Processors state. - - @param[in] CpuData The pointer to CPU_AP_DATA of specified AP - - @return The AP status -**/ -CPU_STATE -GetApState ( - IN CPU_AP_DATA *CpuData - ) -{ - return CpuData->State; -} - -/** - Set the Application Processors state. - - @param[in] CpuData The pointer to CPU_AP_DATA of specified AP - @param[in] State The AP status -**/ -VOID -SetApState ( - IN CPU_AP_DATA *CpuData, - IN CPU_STATE State - ) -{ - AcquireSpinLock (&CpuData->ApLock); - CpuData->State = State; - ReleaseSpinLock (&CpuData->ApLock); -} - -/** - Save BSP's local APIC timer setting. - - @param[in] CpuMpData Pointer to CPU MP Data -**/ -VOID -SaveLocalApicTimerSetting ( - IN CPU_MP_DATA *CpuMpData - ) -{ - // - // Record the current local APIC timer setting of BSP - // - GetApicTimerState ( - &CpuMpData->DivideValue, - &CpuMpData->PeriodicMode, - &CpuMpData->Vector - ); - CpuMpData->CurrentTimerCount = GetApicTimerCurrentCount (); - CpuMpData->TimerInterruptState = GetApicTimerInterruptState (); -} - -/** - Sync local APIC timer setting from BSP to AP. - - @param[in] CpuMpData Pointer to CPU MP Data -**/ -VOID -SyncLocalApicTimerSetting ( - IN CPU_MP_DATA *CpuMpData - ) -{ - // - // Sync local APIC timer setting from BSP to AP - // - InitializeApicTimer ( - CpuMpData->DivideValue, - CpuMpData->CurrentTimerCount, - CpuMpData->PeriodicMode, - CpuMpData->Vector - ); - // - // Disable AP's local APIC timer interrupt - // - DisableApicTimerInterrupt (); -} - -/** - Save the volatile registers required to be restored following INIT IPI. - - @param[out] VolatileRegisters Returns buffer saved the volatile resisters -**/ -VOID -SaveVolatileRegisters ( - OUT CPU_VOLATILE_REGISTERS *VolatileRegisters - ) -{ - CPUID_VERSION_INFO_EDX VersionInfoEdx; - - VolatileRegisters->Cr0 = AsmReadCr0 (); - VolatileRegisters->Cr3 = AsmReadCr3 (); - VolatileRegisters->Cr4 = AsmReadCr4 (); - - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); - if (VersionInfoEdx.Bits.DE != 0) { - // - // If processor supports Debugging Extensions feature - // by CPUID.[EAX=01H]:EDX.BIT2 - // - VolatileRegisters->Dr0 = AsmReadDr0 (); - VolatileRegisters->Dr1 = AsmReadDr1 (); - VolatileRegisters->Dr2 = AsmReadDr2 (); - VolatileRegisters->Dr3 = AsmReadDr3 (); - VolatileRegisters->Dr6 = AsmReadDr6 (); - VolatileRegisters->Dr7 = AsmReadDr7 (); - } -} - -/** - Restore the volatile registers following INIT IPI. - - @param[in] VolatileRegisters Pointer to volatile resisters - @param[in] IsRestoreDr TRUE: Restore DRx if supported - FALSE: Do not restore DRx -**/ -VOID -RestoreVolatileRegisters ( - IN CPU_VOLATILE_REGISTERS *VolatileRegisters, - IN BOOLEAN IsRestoreDr - ) -{ - CPUID_VERSION_INFO_EDX VersionInfoEdx; - - AsmWriteCr0 (VolatileRegisters->Cr0); - AsmWriteCr3 (VolatileRegisters->Cr3); - AsmWriteCr4 (VolatileRegisters->Cr4); - - if (IsRestoreDr) { - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); - if (VersionInfoEdx.Bits.DE != 0) { - // - // If processor supports Debugging Extensions feature - // by CPUID.[EAX=01H]:EDX.BIT2 - // - AsmWriteDr0 (VolatileRegisters->Dr0); - AsmWriteDr1 (VolatileRegisters->Dr1); - AsmWriteDr2 (VolatileRegisters->Dr2); - AsmWriteDr3 (VolatileRegisters->Dr3); - AsmWriteDr6 (VolatileRegisters->Dr6); - AsmWriteDr7 (VolatileRegisters->Dr7); - } - } -} - -/** - Detect whether Mwait-monitor feature is supported. - - @retval TRUE Mwait-monitor feature is supported. - @retval FALSE Mwait-monitor feature is not supported. -**/ -BOOLEAN -IsMwaitSupport ( - VOID - ) -{ - CPUID_VERSION_INFO_ECX VersionInfoEcx; - - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &VersionInfoEcx.Uint32, NULL); - return (VersionInfoEcx.Bits.MONITOR == 1) ? TRUE : FALSE; -} - -/** - Get AP loop mode. - - @param[out] MonitorFilterSize Returns the largest monitor-line size in bytes. - - @return The AP loop mode. -**/ -UINT8 -GetApLoopMode ( - OUT UINT32 *MonitorFilterSize - ) -{ - UINT8 ApLoopMode; - CPUID_MONITOR_MWAIT_EBX MonitorMwaitEbx; - - ASSERT (MonitorFilterSize != NULL); - - ApLoopMode = PcdGet8 (PcdCpuApLoopMode); - ASSERT (ApLoopMode >= ApInHltLoop && ApLoopMode <= ApInRunLoop); - if (ApLoopMode == ApInMwaitLoop) { - if (!IsMwaitSupport ()) { - // - // If processor does not support MONITOR/MWAIT feature, - // force AP in Hlt-loop mode - // - ApLoopMode = ApInHltLoop; - } - } - - if (ApLoopMode != ApInMwaitLoop) { - *MonitorFilterSize = sizeof (UINT32); - } else { - // - // CPUID.[EAX=05H]:EBX.BIT0-15: Largest monitor-line size in bytes - // CPUID.[EAX=05H].EDX: C-states supported using MWAIT - // - AsmCpuid (CPUID_MONITOR_MWAIT, NULL, &MonitorMwaitEbx.Uint32, NULL, NULL); - *MonitorFilterSize = MonitorMwaitEbx.Bits.LargestMonitorLineSize; - } - - return ApLoopMode; -} - -/** - Sort the APIC ID of all processors. - - This function sorts the APIC ID of all processors so that processor number is - assigned in the ascending order of APIC ID which eases MP debugging. - - @param[in] CpuMpData Pointer to PEI CPU MP Data -**/ -VOID -SortApicId ( - IN CPU_MP_DATA *CpuMpData - ) -{ - UINTN Index1; - UINTN Index2; - UINTN Index3; - UINT32 ApicId; - CPU_INFO_IN_HOB CpuInfo; - UINT32 ApCount; - CPU_INFO_IN_HOB *CpuInfoInHob; - - ApCount = CpuMpData->CpuCount - 1; - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - if (ApCount != 0) { - for (Index1 = 0; Index1 < ApCount; Index1++) { - Index3 = Index1; - // - // Sort key is the hardware default APIC ID - // - ApicId = CpuInfoInHob[Index1].ApicId; - for (Index2 = Index1 + 1; Index2 <= ApCount; Index2++) { - if (ApicId > CpuInfoInHob[Index2].ApicId) { - Index3 = Index2; - ApicId = CpuInfoInHob[Index2].ApicId; - } - } - if (Index3 != Index1) { - CopyMem (&CpuInfo, &CpuInfoInHob[Index3], sizeof (CPU_INFO_IN_HOB)); - CopyMem ( - &CpuInfoInHob[Index3], - &CpuInfoInHob[Index1], - sizeof (CPU_INFO_IN_HOB) - ); - CopyMem (&CpuInfoInHob[Index1], &CpuInfo, sizeof (CPU_INFO_IN_HOB)); - } - } - - // - // Get the processor number for the BSP - // - ApicId = GetInitialApicId (); - for (Index1 = 0; Index1 < CpuMpData->CpuCount; Index1++) { - if (CpuInfoInHob[Index1].ApicId == ApicId) { - CpuMpData->BspNumber = (UINT32) Index1; - break; - } - } - } -} - -/** - Enable x2APIC mode on APs. - - @param[in, out] Buffer Pointer to private data buffer. -**/ -VOID -EFIAPI -ApFuncEnableX2Apic ( - IN OUT VOID *Buffer - ) -{ - SetApicMode (LOCAL_APIC_MODE_X2APIC); -} - -/** - Do sync on APs. - - @param[in, out] Buffer Pointer to private data buffer. -**/ -VOID -EFIAPI -ApInitializeSync ( - IN OUT VOID *Buffer - ) -{ - CPU_MP_DATA *CpuMpData; - - CpuMpData = (CPU_MP_DATA *) Buffer; - // - // Load microcode on AP - // - MicrocodeDetect (CpuMpData); - // - // Sync BSP's MTRR table to AP - // - MtrrSetAllMtrrs (&CpuMpData->MtrrTable); -} - -/** - Find the current Processor number by APIC ID. - - @param[in] CpuMpData Pointer to PEI CPU MP Data - @param[out] ProcessorNumber Return the pocessor number found - - @retval EFI_SUCCESS ProcessorNumber is found and returned. - @retval EFI_NOT_FOUND ProcessorNumber is not found. -**/ -EFI_STATUS -GetProcessorNumber ( - IN CPU_MP_DATA *CpuMpData, - OUT UINTN *ProcessorNumber - ) -{ - UINTN TotalProcessorNumber; - UINTN Index; - CPU_INFO_IN_HOB *CpuInfoInHob; - - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - - TotalProcessorNumber = CpuMpData->CpuCount; - for (Index = 0; Index < TotalProcessorNumber; Index ++) { - if (CpuInfoInHob[Index].ApicId == GetApicId ()) { - *ProcessorNumber = Index; - return EFI_SUCCESS; - } - } - return EFI_NOT_FOUND; -} - -/** - This function will get CPU count in the system. - - @param[in] CpuMpData Pointer to PEI CPU MP Data - - @return CPU count detected -**/ -UINTN -CollectProcessorCount ( - IN CPU_MP_DATA *CpuMpData - ) -{ - // - // Send 1st broadcast IPI to APs to wakeup APs - // - CpuMpData->InitFlag = ApInitConfig; - CpuMpData->X2ApicEnable = FALSE; - WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL); - CpuMpData->InitFlag = ApInitDone; - ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); - // - // Wait for all APs finished the initialization - // - while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { - CpuPause (); - } - - if (CpuMpData->X2ApicEnable) { - DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n")); - // - // Wakeup all APs to enable x2APIC mode - // - WakeUpAP (CpuMpData, TRUE, 0, ApFuncEnableX2Apic, NULL); - // - // Wait for all known APs finished - // - while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { - CpuPause (); - } - // - // Enable x2APIC on BSP - // - SetApicMode (LOCAL_APIC_MODE_X2APIC); - } - DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ())); - // - // Sort BSP/Aps by CPU APIC ID in ascending order - // - SortApicId (CpuMpData); - - DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount)); - - return CpuMpData->CpuCount; -} - -/** - Initialize CPU AP Data when AP is wakeup at the first time. - - @param[in, out] CpuMpData Pointer to PEI CPU MP Data - @param[in] ProcessorNumber The handle number of processor - @param[in] BistData Processor BIST data - @param[in] ApTopOfStack Top of AP stack - -**/ -VOID -InitializeApData ( - IN OUT CPU_MP_DATA *CpuMpData, - IN UINTN ProcessorNumber, - IN UINT32 BistData, - IN UINT64 ApTopOfStack - ) -{ - CPU_INFO_IN_HOB *CpuInfoInHob; - - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId (); - CpuInfoInHob[ProcessorNumber].ApicId = GetApicId (); - CpuInfoInHob[ProcessorNumber].Health = BistData; - CpuInfoInHob[ProcessorNumber].ApTopOfStack = ApTopOfStack; - - CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; - CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ? TRUE : FALSE; - if (CpuInfoInHob[ProcessorNumber].InitialApicId >= 0xFF) { - // - // Set x2APIC mode if there are any logical processor reporting - // an Initial APIC ID of 255 or greater. - // - AcquireSpinLock(&CpuMpData->MpLock); - CpuMpData->X2ApicEnable = TRUE; - ReleaseSpinLock(&CpuMpData->MpLock); - } - - InitializeSpinLock(&CpuMpData->CpuData[ProcessorNumber].ApLock); - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); -} - -/** - This function will be called from AP reset code if BSP uses WakeUpAP. - - @param[in] ExchangeInfo Pointer to the MP exchange info buffer - @param[in] NumApsExecuting Number of current executing AP -**/ -VOID -EFIAPI -ApWakeupFunction ( - IN MP_CPU_EXCHANGE_INFO *ExchangeInfo, - IN UINTN NumApsExecuting - ) -{ - CPU_MP_DATA *CpuMpData; - UINTN ProcessorNumber; - EFI_AP_PROCEDURE Procedure; - VOID *Parameter; - UINT32 BistData; - volatile UINT32 *ApStartupSignalBuffer; - CPU_INFO_IN_HOB *CpuInfoInHob; - UINT64 ApTopOfStack; - - // - // AP finished assembly code and begin to execute C code - // - CpuMpData = ExchangeInfo->CpuMpData; - - // - // AP's local APIC settings will be lost after received INIT IPI - // We need to re-initialize them at here - // - ProgramVirtualWireMode (); - SyncLocalApicTimerSetting (CpuMpData); - - while (TRUE) { - if (CpuMpData->InitFlag == ApInitConfig) { - // - // Add CPU number - // - InterlockedIncrement ((UINT32 *) &CpuMpData->CpuCount); - ProcessorNumber = NumApsExecuting; - // - // This is first time AP wakeup, get BIST information from AP stack - // - ApTopOfStack = CpuMpData->Buffer + (ProcessorNumber + 1) * CpuMpData->CpuApStackSize; - BistData = *(UINT32 *) ((UINTN) ApTopOfStack - sizeof (UINTN)); - // - // Do some AP initialize sync - // - ApInitializeSync (CpuMpData); - // - // Sync BSP's Control registers to APs - // - RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE); - InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack); - ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; - } else { - // - // Execute AP function if AP is ready - // - GetProcessorNumber (CpuMpData, &ProcessorNumber); - // - // Clear AP start-up signal when AP waken up - // - ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; - InterlockedCompareExchange32 ( - (UINT32 *) ApStartupSignalBuffer, - WAKEUP_AP_SIGNAL, - 0 - ); - if (CpuMpData->ApLoopMode == ApInHltLoop) { - // - // Restore AP's volatile registers saved - // - RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, TRUE); - } - - if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateReady) { - Procedure = (EFI_AP_PROCEDURE)CpuMpData->CpuData[ProcessorNumber].ApFunction; - Parameter = (VOID *) CpuMpData->CpuData[ProcessorNumber].ApFunctionArgument; - if (Procedure != NULL) { - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateBusy); - // - // Enable source debugging on AP function - // - EnableDebugAgent (); - // - // Invoke AP function here - // - Procedure (Parameter); - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - if (CpuMpData->SwitchBspFlag) { - // - // Re-get the processor number due to BSP/AP maybe exchange in AP function - // - GetProcessorNumber (CpuMpData, &ProcessorNumber); - CpuMpData->CpuData[ProcessorNumber].ApFunction = 0; - CpuMpData->CpuData[ProcessorNumber].ApFunctionArgument = 0; - ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; - CpuInfoInHob[ProcessorNumber].ApTopOfStack = CpuInfoInHob[CpuMpData->NewBspNumber].ApTopOfStack; - } else { - // - // Re-get the CPU APICID and Initial APICID - // - CpuInfoInHob[ProcessorNumber].ApicId = GetApicId (); - CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId (); - } - } - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateFinished); - } - } - - // - // AP finished executing C code - // - InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount); - - // - // Place AP is specified loop mode - // - if (CpuMpData->ApLoopMode == ApInHltLoop) { - // - // Save AP volatile registers - // - SaveVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters); - // - // Place AP in HLT-loop - // - while (TRUE) { - DisableInterrupts (); - CpuSleep (); - CpuPause (); - } - } - while (TRUE) { - DisableInterrupts (); - if (CpuMpData->ApLoopMode == ApInMwaitLoop) { - // - // Place AP in MWAIT-loop - // - AsmMonitor ((UINTN) ApStartupSignalBuffer, 0, 0); - if (*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) { - // - // Check AP start-up signal again. - // If AP start-up signal is not set, place AP into - // the specified C-state - // - AsmMwait (CpuMpData->ApTargetCState << 4, 0); - } - } else if (CpuMpData->ApLoopMode == ApInRunLoop) { - // - // Place AP in Run-loop - // - CpuPause (); - } else { - ASSERT (FALSE); - } - - // - // If AP start-up signal is written, AP is waken up - // otherwise place AP in loop again - // - if (*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) { - break; - } - } - } -} - -/** - Wait for AP wakeup and write AP start-up signal till AP is waken up. - - @param[in] ApStartupSignalBuffer Pointer to AP wakeup signal -**/ -VOID -WaitApWakeup ( - IN volatile UINT32 *ApStartupSignalBuffer - ) -{ - // - // If AP is waken up, StartupApSignal should be cleared. - // Otherwise, write StartupApSignal again till AP waken up. - // - while (InterlockedCompareExchange32 ( - (UINT32 *) ApStartupSignalBuffer, - WAKEUP_AP_SIGNAL, - WAKEUP_AP_SIGNAL - ) != 0) { - CpuPause (); - } -} - -/** - This function will fill the exchange info structure. - - @param[in] CpuMpData Pointer to CPU MP Data - -**/ -VOID -FillExchangeInfoData ( - IN CPU_MP_DATA *CpuMpData - ) -{ - volatile MP_CPU_EXCHANGE_INFO *ExchangeInfo; - - ExchangeInfo = CpuMpData->MpCpuExchangeInfo; - ExchangeInfo->Lock = 0; - ExchangeInfo->StackStart = CpuMpData->Buffer; - ExchangeInfo->StackSize = CpuMpData->CpuApStackSize; - ExchangeInfo->BufferStart = CpuMpData->WakeupBuffer; - ExchangeInfo->ModeOffset = CpuMpData->AddressMap.ModeEntryOffset; - - ExchangeInfo->CodeSegment = AsmReadCs (); - ExchangeInfo->DataSegment = AsmReadDs (); - - ExchangeInfo->Cr3 = AsmReadCr3 (); - - ExchangeInfo->CFunction = (UINTN) ApWakeupFunction; - ExchangeInfo->NumApsExecuting = 0; - ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag; - ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - ExchangeInfo->CpuMpData = CpuMpData; - - ExchangeInfo->EnableExecuteDisable = IsBspExecuteDisableEnabled (); - - // - // Get the BSP's data of GDT and IDT - // - AsmReadGdtr ((IA32_DESCRIPTOR *) &ExchangeInfo->GdtrProfile); - AsmReadIdtr ((IA32_DESCRIPTOR *) &ExchangeInfo->IdtrProfile); -} - -/** - Helper function that waits until the finished AP count reaches the specified - limit, or the specified timeout elapses (whichever comes first). - - @param[in] CpuMpData Pointer to CPU MP Data. - @param[in] FinishedApLimit The number of finished APs to wait for. - @param[in] TimeLimit The number of microseconds to wait for. -**/ -VOID -TimedWaitForApFinish ( - IN CPU_MP_DATA *CpuMpData, - IN UINT32 FinishedApLimit, - IN UINT32 TimeLimit - ); - -/** - This function will be called by BSP to wakeup AP. - - @param[in] CpuMpData Pointer to CPU MP Data - @param[in] Broadcast TRUE: Send broadcast IPI to all APs - FALSE: Send IPI to AP by ApicId - @param[in] ProcessorNumber The handle number of specified processor - @param[in] Procedure The function to be invoked by AP - @param[in] ProcedureArgument The argument to be passed into AP function -**/ -VOID -WakeUpAP ( - IN CPU_MP_DATA *CpuMpData, - IN BOOLEAN Broadcast, - IN UINTN ProcessorNumber, - IN EFI_AP_PROCEDURE Procedure, OPTIONAL - IN VOID *ProcedureArgument OPTIONAL - ) -{ - volatile MP_CPU_EXCHANGE_INFO *ExchangeInfo; - UINTN Index; - CPU_AP_DATA *CpuData; - BOOLEAN ResetVectorRequired; - CPU_INFO_IN_HOB *CpuInfoInHob; - - CpuMpData->FinishedCount = 0; - ResetVectorRequired = FALSE; - - if (CpuMpData->ApLoopMode == ApInHltLoop || - CpuMpData->InitFlag != ApInitDone) { - ResetVectorRequired = TRUE; - AllocateResetVector (CpuMpData); - FillExchangeInfoData (CpuMpData); - SaveLocalApicTimerSetting (CpuMpData); - } else if (CpuMpData->ApLoopMode == ApInMwaitLoop) { - // - // Get AP target C-state each time when waking up AP, - // for it maybe updated by platform again - // - CpuMpData->ApTargetCState = PcdGet8 (PcdCpuApTargetCstate); - } - - ExchangeInfo = CpuMpData->MpCpuExchangeInfo; - - if (Broadcast) { - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { - if (Index != CpuMpData->BspNumber) { - CpuData = &CpuMpData->CpuData[Index]; - CpuData->ApFunction = (UINTN) Procedure; - CpuData->ApFunctionArgument = (UINTN) ProcedureArgument; - SetApState (CpuData, CpuStateReady); - if (CpuMpData->InitFlag != ApInitConfig) { - *(UINT32 *) CpuData->StartupApSignal = WAKEUP_AP_SIGNAL; - } - } - } - if (ResetVectorRequired) { - // - // Wakeup all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferStart); - } - if (CpuMpData->InitFlag == ApInitConfig) { - // - // Wait for all potential APs waken up in one specified period - // - TimedWaitForApFinish ( - CpuMpData, - PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, - PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) - ); - } else { - // - // Wait all APs waken up if this is not the 1st broadcast of SIPI - // - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { - CpuData = &CpuMpData->CpuData[Index]; - if (Index != CpuMpData->BspNumber) { - WaitApWakeup (CpuData->StartupApSignal); - } - } - } - } else { - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - CpuData->ApFunction = (UINTN) Procedure; - CpuData->ApFunctionArgument = (UINTN) ProcedureArgument; - SetApState (CpuData, CpuStateReady); - // - // Wakeup specified AP - // - ASSERT (CpuMpData->InitFlag != ApInitConfig); - *(UINT32 *) CpuData->StartupApSignal = WAKEUP_AP_SIGNAL; - if (ResetVectorRequired) { - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - SendInitSipiSipi ( - CpuInfoInHob[ProcessorNumber].ApicId, - (UINT32) ExchangeInfo->BufferStart - ); - } - // - // Wait specified AP waken up - // - WaitApWakeup (CpuData->StartupApSignal); - } - - if (ResetVectorRequired) { - FreeResetVector (CpuMpData); - } -} - -/** - Calculate timeout value and return the current performance counter value. - - Calculate the number of performance counter ticks required for a timeout. - If TimeoutInMicroseconds is 0, return value is also 0, which is recognized - as infinity. - - @param[in] TimeoutInMicroseconds Timeout value in microseconds. - @param[out] CurrentTime Returns the current value of the performance counter. - - @return Expected time stamp counter for timeout. - If TimeoutInMicroseconds is 0, return value is also 0, which is recognized - as infinity. - -**/ -UINT64 -CalculateTimeout ( - IN UINTN TimeoutInMicroseconds, - OUT UINT64 *CurrentTime - ) -{ - // - // Read the current value of the performance counter - // - *CurrentTime = GetPerformanceCounter (); - - // - // If TimeoutInMicroseconds is 0, return value is also 0, which is recognized - // as infinity. - // - if (TimeoutInMicroseconds == 0) { - return 0; - } - - // - // GetPerformanceCounterProperties () returns the timestamp counter's frequency - // in Hz. So multiply the return value with TimeoutInMicroseconds and then divide - // it by 1,000,000, to get the number of ticks for the timeout value. - // - return DivU64x32 ( - MultU64x64 ( - GetPerformanceCounterProperties (NULL, NULL), - TimeoutInMicroseconds - ), - 1000000 - ); -} - -/** - Checks whether timeout expires. - - Check whether the number of elapsed performance counter ticks required for - a timeout condition has been reached. - If Timeout is zero, which means infinity, return value is always FALSE. - - @param[in, out] PreviousTime On input, the value of the performance counter - when it was last read. - On output, the current value of the performance - counter - @param[in] TotalTime The total amount of elapsed time in performance - counter ticks. - @param[in] Timeout The number of performance counter ticks required - to reach a timeout condition. - - @retval TRUE A timeout condition has been reached. - @retval FALSE A timeout condition has not been reached. - -**/ -BOOLEAN -CheckTimeout ( - IN OUT UINT64 *PreviousTime, - IN UINT64 *TotalTime, - IN UINT64 Timeout - ) -{ - UINT64 Start; - UINT64 End; - UINT64 CurrentTime; - INT64 Delta; - INT64 Cycle; - - if (Timeout == 0) { - return FALSE; - } - GetPerformanceCounterProperties (&Start, &End); - Cycle = End - Start; - if (Cycle < 0) { - Cycle = -Cycle; - } - Cycle++; - CurrentTime = GetPerformanceCounter(); - Delta = (INT64) (CurrentTime - *PreviousTime); - if (Start > End) { - Delta = -Delta; - } - if (Delta < 0) { - Delta += Cycle; - } - *TotalTime += Delta; - *PreviousTime = CurrentTime; - if (*TotalTime > Timeout) { - return TRUE; - } - return FALSE; -} - -/** - Helper function that waits until the finished AP count reaches the specified - limit, or the specified timeout elapses (whichever comes first). - - @param[in] CpuMpData Pointer to CPU MP Data. - @param[in] FinishedApLimit The number of finished APs to wait for. - @param[in] TimeLimit The number of microseconds to wait for. -**/ -VOID -TimedWaitForApFinish ( - IN CPU_MP_DATA *CpuMpData, - IN UINT32 FinishedApLimit, - IN UINT32 TimeLimit - ) -{ - // - // CalculateTimeout() and CheckTimeout() consider a TimeLimit of 0 - // "infinity", so check for (TimeLimit == 0) explicitly. - // - if (TimeLimit == 0) { - return; - } - - CpuMpData->TotalTime = 0; - CpuMpData->ExpectedTime = CalculateTimeout ( - TimeLimit, - &CpuMpData->CurrentTime - ); - while (CpuMpData->FinishedCount < FinishedApLimit && - !CheckTimeout ( - &CpuMpData->CurrentTime, - &CpuMpData->TotalTime, - CpuMpData->ExpectedTime - )) { - CpuPause (); - } - - if (CpuMpData->FinishedCount >= FinishedApLimit) { - DEBUG (( - DEBUG_VERBOSE, - "%a: reached FinishedApLimit=%u in %Lu microseconds\n", - __FUNCTION__, - FinishedApLimit, - DivU64x64Remainder ( - MultU64x32 (CpuMpData->TotalTime, 1000000), - GetPerformanceCounterProperties (NULL, NULL), - NULL - ) - )); - } -} - -/** - Reset an AP to Idle state. - - Any task being executed by the AP will be aborted and the AP - will be waiting for a new task in Wait-For-SIPI state. - - @param[in] ProcessorNumber The handle number of processor. -**/ -VOID -ResetProcessorToIdleState ( - IN UINTN ProcessorNumber - ) -{ - CPU_MP_DATA *CpuMpData; - - CpuMpData = GetCpuMpData (); - - CpuMpData->InitFlag = ApInitReconfig; - WakeUpAP (CpuMpData, FALSE, ProcessorNumber, NULL, NULL); - while (CpuMpData->FinishedCount < 1) { - CpuPause (); - } - CpuMpData->InitFlag = ApInitDone; - - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); -} - -/** - Searches for the next waiting AP. - - Search for the next AP that is put in waiting state by single-threaded StartupAllAPs(). - - @param[out] NextProcessorNumber Pointer to the processor number of the next waiting AP. - - @retval EFI_SUCCESS The next waiting AP has been found. - @retval EFI_NOT_FOUND No waiting AP exists. - -**/ -EFI_STATUS -GetNextWaitingProcessorNumber ( - OUT UINTN *NextProcessorNumber - ) -{ - UINTN ProcessorNumber; - CPU_MP_DATA *CpuMpData; - - CpuMpData = GetCpuMpData (); - - for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { - if (CpuMpData->CpuData[ProcessorNumber].Waiting) { - *NextProcessorNumber = ProcessorNumber; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** Checks status of specified AP. - - This function checks whether the specified AP has finished the task assigned - by StartupThisAP(), and whether timeout expires. - - @param[in] ProcessorNumber The handle number of processor. - - @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs(). - @retval EFI_TIMEOUT The timeout expires. - @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired. -**/ -EFI_STATUS -CheckThisAP ( - IN UINTN ProcessorNumber - ) -{ - CPU_MP_DATA *CpuMpData; - CPU_AP_DATA *CpuData; - - CpuMpData = GetCpuMpData (); - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - - // - // Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task. - // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the - // value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value. - // - // - // If the AP finishes for StartupThisAP(), return EFI_SUCCESS. - // - if (GetApState(CpuData) == CpuStateFinished) { - if (CpuData->Finished != NULL) { - *(CpuData->Finished) = TRUE; - } - SetApState (CpuData, CpuStateIdle); - return EFI_SUCCESS; - } else { - // - // If timeout expires for StartupThisAP(), report timeout. - // - if (CheckTimeout (&CpuData->CurrentTime, &CpuData->TotalTime, CpuData->ExpectedTime)) { - if (CpuData->Finished != NULL) { - *(CpuData->Finished) = FALSE; - } - // - // Reset failed AP to idle state - // - ResetProcessorToIdleState (ProcessorNumber); - - return EFI_TIMEOUT; - } - } - return EFI_NOT_READY; -} - -/** - Checks status of all APs. - - This function checks whether all APs have finished task assigned by StartupAllAPs(), - and whether timeout expires. - - @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs(). - @retval EFI_TIMEOUT The timeout expires. - @retval EFI_NOT_READY APs have not finished task and timeout has not expired. -**/ -EFI_STATUS -CheckAllAPs ( - VOID - ) -{ - UINTN ProcessorNumber; - UINTN NextProcessorNumber; - UINTN ListIndex; - EFI_STATUS Status; - CPU_MP_DATA *CpuMpData; - CPU_AP_DATA *CpuData; - - CpuMpData = GetCpuMpData (); - - NextProcessorNumber = 0; - - // - // Go through all APs that are responsible for the StartupAllAPs(). - // - for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { - if (!CpuMpData->CpuData[ProcessorNumber].Waiting) { - continue; - } - - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - // - // Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task. - // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the - // value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value. - // - if (GetApState(CpuData) == CpuStateFinished) { - CpuMpData->RunningCount ++; - CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; - SetApState(CpuData, CpuStateIdle); - - // - // If in Single Thread mode, then search for the next waiting AP for execution. - // - if (CpuMpData->SingleThread) { - Status = GetNextWaitingProcessorNumber (&NextProcessorNumber); - - if (!EFI_ERROR (Status)) { - WakeUpAP ( - CpuMpData, - FALSE, - (UINT32) NextProcessorNumber, - CpuMpData->Procedure, - CpuMpData->ProcArguments - ); - } - } - } - } - - // - // If all APs finish, return EFI_SUCCESS. - // - if (CpuMpData->RunningCount == CpuMpData->StartCount) { - return EFI_SUCCESS; - } - - // - // If timeout expires, report timeout. - // - if (CheckTimeout ( - &CpuMpData->CurrentTime, - &CpuMpData->TotalTime, - CpuMpData->ExpectedTime) - ) { - // - // If FailedCpuList is not NULL, record all failed APs in it. - // - if (CpuMpData->FailedCpuList != NULL) { - *CpuMpData->FailedCpuList = - AllocatePool ((CpuMpData->StartCount - CpuMpData->FinishedCount + 1) * sizeof (UINTN)); - ASSERT (*CpuMpData->FailedCpuList != NULL); - } - ListIndex = 0; - - for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) { - // - // Check whether this processor is responsible for StartupAllAPs(). - // - if (CpuMpData->CpuData[ProcessorNumber].Waiting) { - // - // Reset failed APs to idle state - // - ResetProcessorToIdleState (ProcessorNumber); - CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; - if (CpuMpData->FailedCpuList != NULL) { - (*CpuMpData->FailedCpuList)[ListIndex++] = ProcessorNumber; - } - } - } - if (CpuMpData->FailedCpuList != NULL) { - (*CpuMpData->FailedCpuList)[ListIndex] = END_OF_CPU_LIST; - } - return EFI_TIMEOUT; - } - return EFI_NOT_READY; -} - -/** - MP Initialize Library initialization. - - This service will allocate AP reset vector and wakeup all APs to do APs - initialization. - - This service must be invoked before all other MP Initialize Library - service are invoked. - - @retval EFI_SUCCESS MP initialization succeeds. - @retval Others MP initialization fails. - -**/ -EFI_STATUS -EFIAPI -MpInitLibInitialize ( - VOID - ) -{ - CPU_MP_DATA *OldCpuMpData; - CPU_INFO_IN_HOB *CpuInfoInHob; - UINT32 MaxLogicalProcessorNumber; - UINT32 ApStackSize; - MP_ASSEMBLY_ADDRESS_MAP AddressMap; - UINTN BufferSize; - UINT32 MonitorFilterSize; - VOID *MpBuffer; - UINTN Buffer; - CPU_MP_DATA *CpuMpData; - UINT8 ApLoopMode; - UINT8 *MonitorBuffer; - UINTN Index; - UINTN ApResetVectorSize; - UINTN BackupBufferAddr; - - OldCpuMpData = GetCpuMpDataFromGuidedHob (); - if (OldCpuMpData == NULL) { - MaxLogicalProcessorNumber = PcdGet32(PcdCpuMaxLogicalProcessorNumber); - } else { - MaxLogicalProcessorNumber = OldCpuMpData->CpuCount; - } - ASSERT (MaxLogicalProcessorNumber != 0); - - AsmGetAddressMap (&AddressMap); - ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO); - ApStackSize = PcdGet32(PcdCpuApStackSize); - ApLoopMode = GetApLoopMode (&MonitorFilterSize); - - BufferSize = ApStackSize * MaxLogicalProcessorNumber; - BufferSize += MonitorFilterSize * MaxLogicalProcessorNumber; - BufferSize += sizeof (CPU_MP_DATA); - BufferSize += ApResetVectorSize; - BufferSize += (sizeof (CPU_AP_DATA) + sizeof (CPU_INFO_IN_HOB))* MaxLogicalProcessorNumber; - MpBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize)); - ASSERT (MpBuffer != NULL); - ZeroMem (MpBuffer, BufferSize); - Buffer = (UINTN) MpBuffer; - - MonitorBuffer = (UINT8 *) (Buffer + ApStackSize * MaxLogicalProcessorNumber); - BackupBufferAddr = (UINTN) MonitorBuffer + MonitorFilterSize * MaxLogicalProcessorNumber; - CpuMpData = (CPU_MP_DATA *) (BackupBufferAddr + ApResetVectorSize); - CpuMpData->Buffer = Buffer; - CpuMpData->CpuApStackSize = ApStackSize; - CpuMpData->BackupBuffer = BackupBufferAddr; - CpuMpData->BackupBufferSize = ApResetVectorSize; - CpuMpData->SaveRestoreFlag = FALSE; - CpuMpData->WakeupBuffer = (UINTN) -1; - CpuMpData->CpuCount = 1; - CpuMpData->BspNumber = 0; - CpuMpData->WaitEvent = NULL; - CpuMpData->SwitchBspFlag = FALSE; - CpuMpData->CpuData = (CPU_AP_DATA *) (CpuMpData + 1); - CpuMpData->CpuInfoInHob = (UINT64) (UINTN) (CpuMpData->CpuData + MaxLogicalProcessorNumber); - InitializeSpinLock(&CpuMpData->MpLock); - // - // Save BSP's Control registers to APs - // - SaveVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters); - // - // Set BSP basic information - // - InitializeApData (CpuMpData, 0, 0, CpuMpData->Buffer); - // - // Save assembly code information - // - CopyMem (&CpuMpData->AddressMap, &AddressMap, sizeof (MP_ASSEMBLY_ADDRESS_MAP)); - // - // Finally set AP loop mode - // - CpuMpData->ApLoopMode = ApLoopMode; - DEBUG ((DEBUG_INFO, "AP Loop Mode is %d\n", CpuMpData->ApLoopMode)); - // - // Set up APs wakeup signal buffer - // - for (Index = 0; Index < MaxLogicalProcessorNumber; Index++) { - CpuMpData->CpuData[Index].StartupApSignal = - (UINT32 *)(MonitorBuffer + MonitorFilterSize * Index); - } - // - // Load Microcode on BSP - // - MicrocodeDetect (CpuMpData); - // - // Store BSP's MTRR setting - // - MtrrGetAllMtrrs (&CpuMpData->MtrrTable); - - if (OldCpuMpData == NULL) { - if (MaxLogicalProcessorNumber > 1) { - // - // Wakeup all APs and calculate the processor count in system - // - CollectProcessorCount (CpuMpData); - } - } else { - // - // APs have been wakeup before, just get the CPU Information - // from HOB - // - CpuMpData->CpuCount = OldCpuMpData->CpuCount; - CpuMpData->BspNumber = OldCpuMpData->BspNumber; - CpuMpData->InitFlag = ApInitReconfig; - CpuMpData->CpuInfoInHob = OldCpuMpData->CpuInfoInHob; - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { - InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock); - if (CpuInfoInHob[Index].InitialApicId >= 255) { - CpuMpData->X2ApicEnable = TRUE; - } - CpuMpData->CpuData[Index].CpuHealthy = (CpuInfoInHob[Index].Health == 0)? TRUE:FALSE; - CpuMpData->CpuData[Index].ApFunction = 0; - CopyMem ( - &CpuMpData->CpuData[Index].VolatileRegisters, - &CpuMpData->CpuData[0].VolatileRegisters, - sizeof (CPU_VOLATILE_REGISTERS) - ); - } - if (MaxLogicalProcessorNumber > 1) { - // - // Wakeup APs to do some AP initialize sync - // - WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData); - // - // Wait for all APs finished initialization - // - while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { - CpuPause (); - } - CpuMpData->InitFlag = ApInitDone; - for (Index = 0; Index < CpuMpData->CpuCount; Index++) { - SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); - } - } - } - - // - // Initialize global data for MP support - // - InitMpGlobalData (CpuMpData); - - return EFI_SUCCESS; -} - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - @param[out] HealthData Return processor health data. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibGetProcessorInfo ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, - OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL - ) -{ - CPU_MP_DATA *CpuMpData; - UINTN CallerNumber; - CPU_INFO_IN_HOB *CpuInfoInHob; - - CpuMpData = GetCpuMpData (); - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_DEVICE_ERROR; - } - - if (ProcessorInfoBuffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (ProcessorNumber >= CpuMpData->CpuCount) { - return EFI_NOT_FOUND; - } - - ProcessorInfoBuffer->ProcessorId = (UINT64) CpuInfoInHob[ProcessorNumber].ApicId; - ProcessorInfoBuffer->StatusFlag = 0; - if (ProcessorNumber == CpuMpData->BspNumber) { - ProcessorInfoBuffer->StatusFlag |= PROCESSOR_AS_BSP_BIT; - } - if (CpuMpData->CpuData[ProcessorNumber].CpuHealthy) { - ProcessorInfoBuffer->StatusFlag |= PROCESSOR_HEALTH_STATUS_BIT; - } - if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateDisabled) { - ProcessorInfoBuffer->StatusFlag &= ~PROCESSOR_ENABLED_BIT; - } else { - ProcessorInfoBuffer->StatusFlag |= PROCESSOR_ENABLED_BIT; - } - - // - // Get processor location information - // - GetProcessorLocationByApicId ( - CpuInfoInHob[ProcessorNumber].ApicId, - &ProcessorInfoBuffer->Location.Package, - &ProcessorInfoBuffer->Location.Core, - &ProcessorInfoBuffer->Location.Thread - ); - - if (HealthData != NULL) { - HealthData->Uint32 = CpuInfoInHob[ProcessorNumber].Health; - } - - return EFI_SUCCESS; -} - -/** - Worker function to switch the requested AP to be the BSP from that point onward. - - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval others Failed to switch BSP. - -**/ -EFI_STATUS -SwitchBSPWorker ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ) -{ - CPU_MP_DATA *CpuMpData; - UINTN CallerNumber; - CPU_STATE State; - MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; - BOOLEAN OldInterruptState; - BOOLEAN OldTimerInterruptState; - - // - // Save and Disable Local APIC timer interrupt - // - OldTimerInterruptState = GetApicTimerInterruptState (); - DisableApicTimerInterrupt (); - // - // Before send both BSP and AP to a procedure to exchange their roles, - // interrupt must be disabled. This is because during the exchange role - // process, 2 CPU may use 1 stack. If interrupt happens, the stack will - // be corrupted, since interrupt return address will be pushed to stack - // by hardware. - // - OldInterruptState = SaveAndDisableInterrupts (); - - // - // Mask LINT0 & LINT1 for the old BSP - // - DisableLvtInterrupts (); - - CpuMpData = GetCpuMpData (); - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_SUCCESS; - } - - if (ProcessorNumber >= CpuMpData->CpuCount) { - return EFI_NOT_FOUND; - } - - // - // Check whether specified AP is disabled - // - State = GetApState (&CpuMpData->CpuData[ProcessorNumber]); - if (State == CpuStateDisabled) { - return EFI_INVALID_PARAMETER; - } - - // - // Check whether ProcessorNumber specifies the current BSP - // - if (ProcessorNumber == CpuMpData->BspNumber) { - return EFI_INVALID_PARAMETER; - } - - // - // Check whether specified AP is busy - // - if (State == CpuStateBusy) { - return EFI_NOT_READY; - } - - CpuMpData->BSPInfo.State = CPU_SWITCH_STATE_IDLE; - CpuMpData->APInfo.State = CPU_SWITCH_STATE_IDLE; - CpuMpData->SwitchBspFlag = TRUE; - CpuMpData->NewBspNumber = ProcessorNumber; - - // - // Clear the BSP bit of MSR_IA32_APIC_BASE - // - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - ApicBaseMsr.Bits.BSP = 0; - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); - - // - // Need to wakeUp AP (future BSP). - // - WakeUpAP (CpuMpData, FALSE, ProcessorNumber, FutureBSPProc, CpuMpData); - - AsmExchangeRole (&CpuMpData->BSPInfo, &CpuMpData->APInfo); - - // - // Set the BSP bit of MSR_IA32_APIC_BASE on new BSP - // - ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); - ApicBaseMsr.Bits.BSP = 1; - AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); - - // - // Wait for old BSP finished AP task - // - while (GetApState (&CpuMpData->CpuData[CallerNumber]) != CpuStateFinished) { - CpuPause (); - } - - CpuMpData->SwitchBspFlag = FALSE; - // - // Set old BSP enable state - // - if (!EnableOldBSP) { - SetApState (&CpuMpData->CpuData[CallerNumber], CpuStateDisabled); - } else { - SetApState (&CpuMpData->CpuData[CallerNumber], CpuStateIdle); - } - // - // Save new BSP number - // - CpuMpData->BspNumber = (UINT32) ProcessorNumber; - - // - // Restore interrupt state. - // - SetInterruptState (OldInterruptState); - - if (OldTimerInterruptState) { - EnableApicTimerInterrupt (); - } - - return EFI_SUCCESS; -} - -/** - Worker function to let the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of AP. - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval others Failed to Enable/Disable AP. - -**/ -EFI_STATUS -EnableDisableApWorker ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ) -{ - CPU_MP_DATA *CpuMpData; - UINTN CallerNumber; - - CpuMpData = GetCpuMpData (); - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_DEVICE_ERROR; - } - - if (ProcessorNumber == CpuMpData->BspNumber) { - return EFI_INVALID_PARAMETER; - } - - if (ProcessorNumber >= CpuMpData->CpuCount) { - return EFI_NOT_FOUND; - } - - if (!EnableAP) { - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateDisabled); - } else { - SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); - } - - if (HealthFlag != NULL) { - CpuMpData->CpuData[ProcessorNumber].CpuHealthy = - (BOOLEAN) ((*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT) != 0); - } - - return EFI_SUCCESS; -} - -/** - This return the handle number for the calling processor. This service may be - called from the BSP and APs. - - @param[out] ProcessorNumber Pointer to the handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibWhoAmI ( - OUT UINTN *ProcessorNumber - ) -{ - CPU_MP_DATA *CpuMpData; - - if (ProcessorNumber == NULL) { - return EFI_INVALID_PARAMETER; - } - - CpuMpData = GetCpuMpData (); - - return GetProcessorNumber (CpuMpData, ProcessorNumber); -} - -/** - Retrieves the number of logical processor in the platform and the number of - those logical processors that are enabled on this boot. This service may only - be called from the BSP. - - @param[out] NumberOfProcessors Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. - - @retval EFI_SUCCESS The number of logical processors and enabled - logical processors was retrieved. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors - is NULL. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibGetNumberOfProcessors ( - OUT UINTN *NumberOfProcessors, OPTIONAL - OUT UINTN *NumberOfEnabledProcessors OPTIONAL - ) -{ - CPU_MP_DATA *CpuMpData; - UINTN CallerNumber; - UINTN ProcessorNumber; - UINTN EnabledProcessorNumber; - UINTN Index; - - CpuMpData = GetCpuMpData (); - - if ((NumberOfProcessors == NULL) && (NumberOfEnabledProcessors == NULL)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_DEVICE_ERROR; - } - - ProcessorNumber = CpuMpData->CpuCount; - EnabledProcessorNumber = 0; - for (Index = 0; Index < ProcessorNumber; Index++) { - if (GetApState (&CpuMpData->CpuData[Index]) != CpuStateDisabled) { - EnabledProcessorNumber ++; - } - } - - if (NumberOfProcessors != NULL) { - *NumberOfProcessors = ProcessorNumber; - } - if (NumberOfEnabledProcessors != NULL) { - *NumberOfEnabledProcessors = EnabledProcessorNumber; - } - - return EFI_SUCCESS; -} - - -/** - Worker function to execute a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval others Failed to Startup all APs. - -**/ -EFI_STATUS -StartupAllAPsWorker ( - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ) -{ - EFI_STATUS Status; - CPU_MP_DATA *CpuMpData; - UINTN ProcessorCount; - UINTN ProcessorNumber; - UINTN CallerNumber; - CPU_AP_DATA *CpuData; - BOOLEAN HasEnabledAp; - CPU_STATE ApState; - - CpuMpData = GetCpuMpData (); - - if (FailedCpuList != NULL) { - *FailedCpuList = NULL; - } - - if (CpuMpData->CpuCount == 1) { - return EFI_NOT_STARTED; - } - - if (Procedure == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_DEVICE_ERROR; - } - - // - // Update AP state - // - CheckAndUpdateApsStatus (); - - ProcessorCount = CpuMpData->CpuCount; - HasEnabledAp = FALSE; - // - // Check whether all enabled APs are idle. - // If any enabled AP is not idle, return EFI_NOT_READY. - // - for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - if (ProcessorNumber != CpuMpData->BspNumber) { - ApState = GetApState (CpuData); - if (ApState != CpuStateDisabled) { - HasEnabledAp = TRUE; - if (ApState != CpuStateIdle) { - // - // If any enabled APs are busy, return EFI_NOT_READY. - // - return EFI_NOT_READY; - } - } - } - } - - if (!HasEnabledAp) { - // - // If no enabled AP exists, return EFI_NOT_STARTED. - // - return EFI_NOT_STARTED; - } - - CpuMpData->StartCount = 0; - for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - CpuData->Waiting = FALSE; - if (ProcessorNumber != CpuMpData->BspNumber) { - if (CpuData->State == CpuStateIdle) { - // - // Mark this processor as responsible for current calling. - // - CpuData->Waiting = TRUE; - CpuMpData->StartCount++; - } - } - } - - CpuMpData->Procedure = Procedure; - CpuMpData->ProcArguments = ProcedureArgument; - CpuMpData->SingleThread = SingleThread; - CpuMpData->FinishedCount = 0; - CpuMpData->RunningCount = 0; - CpuMpData->FailedCpuList = FailedCpuList; - CpuMpData->ExpectedTime = CalculateTimeout ( - TimeoutInMicroseconds, - &CpuMpData->CurrentTime - ); - CpuMpData->TotalTime = 0; - CpuMpData->WaitEvent = WaitEvent; - - if (!SingleThread) { - WakeUpAP (CpuMpData, TRUE, 0, Procedure, ProcedureArgument); - } else { - for (ProcessorNumber = 0; ProcessorNumber < ProcessorCount; ProcessorNumber++) { - if (ProcessorNumber == CallerNumber) { - continue; - } - if (CpuMpData->CpuData[ProcessorNumber].Waiting) { - WakeUpAP (CpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument); - break; - } - } - } - - Status = EFI_SUCCESS; - if (WaitEvent == NULL) { - do { - Status = CheckAllAPs (); - } while (Status == EFI_NOT_READY); - } - - return Status; -} - -/** - Worker function to let the caller get one enabled AP to execute a caller-provided - function. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. - @param[in] ProcessorNumber The handle number of the AP. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] Finished If AP returns from Procedure before the - timeout expires, its content is set to TRUE. - Otherwise, the value is set to FALSE. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval others Failed to Startup AP. - -**/ -EFI_STATUS -StartupThisAPWorker ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ) -{ - EFI_STATUS Status; - CPU_MP_DATA *CpuMpData; - CPU_AP_DATA *CpuData; - UINTN CallerNumber; - - CpuMpData = GetCpuMpData (); - - if (Finished != NULL) { - *Finished = FALSE; - } - - // - // Check whether caller processor is BSP - // - MpInitLibWhoAmI (&CallerNumber); - if (CallerNumber != CpuMpData->BspNumber) { - return EFI_DEVICE_ERROR; - } - - // - // Check whether processor with the handle specified by ProcessorNumber exists - // - if (ProcessorNumber >= CpuMpData->CpuCount) { - return EFI_NOT_FOUND; - } - - // - // Check whether specified processor is BSP - // - if (ProcessorNumber == CpuMpData->BspNumber) { - return EFI_INVALID_PARAMETER; - } - - // - // Check parameter Procedure - // - if (Procedure == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Update AP state - // - CheckAndUpdateApsStatus (); - - // - // Check whether specified AP is disabled - // - if (GetApState (&CpuMpData->CpuData[ProcessorNumber]) == CpuStateDisabled) { - return EFI_INVALID_PARAMETER; - } - - // - // If WaitEvent is not NULL, execute in non-blocking mode. - // BSP saves data for CheckAPsStatus(), and returns EFI_SUCCESS. - // CheckAPsStatus() will check completion and timeout periodically. - // - CpuData = &CpuMpData->CpuData[ProcessorNumber]; - CpuData->WaitEvent = WaitEvent; - CpuData->Finished = Finished; - CpuData->ExpectedTime = CalculateTimeout (TimeoutInMicroseconds, &CpuData->CurrentTime); - CpuData->TotalTime = 0; - - WakeUpAP (CpuMpData, FALSE, ProcessorNumber, Procedure, ProcedureArgument); - - // - // If WaitEvent is NULL, execute in blocking mode. - // BSP checks AP's state until it finishes or TimeoutInMicrosecsond expires. - // - Status = EFI_SUCCESS; - if (WaitEvent == NULL) { - do { - Status = CheckThisAP (ProcessorNumber); - } while (Status == EFI_NOT_READY); - } - - return Status; -} - -/** - Get pointer to CPU MP Data structure from GUIDed HOB. - - @return The pointer to CPU MP Data structure. -**/ -CPU_MP_DATA * -GetCpuMpDataFromGuidedHob ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - VOID *DataInHob; - CPU_MP_DATA *CpuMpData; - - CpuMpData = NULL; - GuidHob = GetFirstGuidHob (&mCpuInitMpLibHobGuid); - if (GuidHob != NULL) { - DataInHob = GET_GUID_HOB_DATA (GuidHob); - CpuMpData = (CPU_MP_DATA *) (*(UINTN *) DataInHob); - } - return CpuMpData; -} - -/** - Get available system memory below 1MB by specified size. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -BackupAndPrepareWakeupBuffer( - IN CPU_MP_DATA *CpuMpData - ) -{ - CopyMem ( - (VOID *) CpuMpData->BackupBuffer, - (VOID *) CpuMpData->WakeupBuffer, - CpuMpData->BackupBufferSize - ); - CopyMem ( - (VOID *) CpuMpData->WakeupBuffer, - (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress, - CpuMpData->AddressMap.RendezvousFunnelSize - ); -} - -/** - Restore wakeup buffer data. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -RestoreWakeupBuffer( - IN CPU_MP_DATA *CpuMpData - ) -{ - CopyMem ( - (VOID *) CpuMpData->WakeupBuffer, - (VOID *) CpuMpData->BackupBuffer, - CpuMpData->BackupBufferSize - ); -} diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h deleted file mode 100644 index 7a272d78ec..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ /dev/null @@ -1,594 +0,0 @@ -/** @file - Common header file for MP Initialize Library. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _MP_LIB_H_ -#define _MP_LIB_H_ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P') - -#define CPU_INIT_MP_LIB_HOB_GUID \ - { \ - 0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \ - } - -// -// The MP data for switch BSP -// -#define CPU_SWITCH_STATE_IDLE 0 -#define CPU_SWITCH_STATE_STORED 1 -#define CPU_SWITCH_STATE_LOADED 2 - -// -// CPU exchange information for switch BSP -// -typedef struct { - UINT8 State; // offset 0 - UINTN StackPointer; // offset 4 / 8 - IA32_DESCRIPTOR Gdtr; // offset 8 / 16 - IA32_DESCRIPTOR Idtr; // offset 14 / 26 -} CPU_EXCHANGE_ROLE_INFO; - -// -// AP loop state when APs are in idle state -// It's value is the same with PcdCpuApLoopMode -// -typedef enum { - ApInHltLoop = 1, - ApInMwaitLoop = 2, - ApInRunLoop = 3 -} AP_LOOP_MODE; - -// -// AP initialization state during APs wakeup -// -typedef enum { - ApInitConfig = 1, - ApInitReconfig = 2, - ApInitDone = 3 -} AP_INIT_STATE; - -// -// AP state -// -typedef enum { - CpuStateIdle, - CpuStateReady, - CpuStateBusy, - CpuStateFinished, - CpuStateDisabled -} CPU_STATE; - -// -// CPU volatile registers around INIT-SIPI-SIPI -// -typedef struct { - UINTN Cr0; - UINTN Cr3; - UINTN Cr4; - UINTN Dr0; - UINTN Dr1; - UINTN Dr2; - UINTN Dr3; - UINTN Dr6; - UINTN Dr7; -} CPU_VOLATILE_REGISTERS; - -// -// AP related data -// -typedef struct { - SPIN_LOCK ApLock; - volatile UINT32 *StartupApSignal; - volatile UINTN ApFunction; - volatile UINTN ApFunctionArgument; - BOOLEAN CpuHealthy; - volatile CPU_STATE State; - CPU_VOLATILE_REGISTERS VolatileRegisters; - BOOLEAN Waiting; - BOOLEAN *Finished; - UINT64 ExpectedTime; - UINT64 CurrentTime; - UINT64 TotalTime; - EFI_EVENT WaitEvent; -} CPU_AP_DATA; - -// -// Basic CPU information saved in Guided HOB. -// Because the contents will be shard between PEI and DXE, -// we need to make sure the each fields offset same in different -// architecture. -// -#pragma pack (1) -typedef struct { - UINT32 InitialApicId; - UINT32 ApicId; - UINT32 Health; - UINT64 ApTopOfStack; -} CPU_INFO_IN_HOB; -#pragma pack () - -// -// AP reset code information including code address and size, -// this structure will be shared be C code and assembly code. -// It is natural aligned by design. -// -typedef struct { - UINT8 *RendezvousFunnelAddress; - UINTN ModeEntryOffset; - UINTN RendezvousFunnelSize; - UINT8 *RelocateApLoopFuncAddress; - UINTN RelocateApLoopFuncSize; -} MP_ASSEMBLY_ADDRESS_MAP; - -typedef struct _CPU_MP_DATA CPU_MP_DATA; - -#pragma pack(1) - -// -// MP CPU exchange information for AP reset code -// This structure is required to be packed because fixed field offsets -// into this structure are used in assembly code in this module -// -typedef struct { - UINTN Lock; - UINTN StackStart; - UINTN StackSize; - UINTN CFunction; - IA32_DESCRIPTOR GdtrProfile; - IA32_DESCRIPTOR IdtrProfile; - UINTN BufferStart; - UINTN ModeOffset; - UINTN NumApsExecuting; - UINTN CodeSegment; - UINTN DataSegment; - UINTN EnableExecuteDisable; - UINTN Cr3; - UINTN InitFlag; - CPU_INFO_IN_HOB *CpuInfo; - CPU_MP_DATA *CpuMpData; -} MP_CPU_EXCHANGE_INFO; - -#pragma pack() - -// -// CPU MP Data save in memory -// -struct _CPU_MP_DATA { - UINT64 CpuInfoInHob; - UINT32 CpuCount; - UINT32 BspNumber; - // - // The above fields data will be passed from PEI to DXE - // Please make sure the fields offset same in the different - // architecture. - // - SPIN_LOCK MpLock; - UINTN Buffer; - UINTN CpuApStackSize; - MP_ASSEMBLY_ADDRESS_MAP AddressMap; - UINTN WakeupBuffer; - UINTN BackupBuffer; - UINTN BackupBufferSize; - BOOLEAN SaveRestoreFlag; - - volatile UINT32 StartCount; - volatile UINT32 FinishedCount; - volatile UINT32 RunningCount; - BOOLEAN SingleThread; - EFI_AP_PROCEDURE Procedure; - VOID *ProcArguments; - BOOLEAN *Finished; - UINT64 ExpectedTime; - UINT64 CurrentTime; - UINT64 TotalTime; - EFI_EVENT WaitEvent; - UINTN **FailedCpuList; - - AP_INIT_STATE InitFlag; - BOOLEAN X2ApicEnable; - BOOLEAN SwitchBspFlag; - UINTN NewBspNumber; - CPU_EXCHANGE_ROLE_INFO BSPInfo; - CPU_EXCHANGE_ROLE_INFO APInfo; - MTRR_SETTINGS MtrrTable; - UINT8 ApLoopMode; - UINT8 ApTargetCState; - UINT16 PmCodeSegment; - CPU_AP_DATA *CpuData; - volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo; - - UINT32 CurrentTimerCount; - UINTN DivideValue; - UINT8 Vector; - BOOLEAN PeriodicMode; - BOOLEAN TimerInterruptState; -}; - -extern EFI_GUID mCpuInitMpLibHobGuid; - -/** - Assembly code to place AP into safe loop mode. - - Place AP into targeted C-State if MONITOR is supported, otherwise - place AP into hlt state. - Place AP in protected mode if the current is long mode. Due to AP maybe - wakeup by some hardware event. It could avoid accessing page table that - may not available during booting to OS. - - @param[in] MwaitSupport TRUE indicates MONITOR is supported. - FALSE indicates MONITOR is not supported. - @param[in] ApTargetCState Target C-State value. - @param[in] PmCodeSegment Protected mode code segment value. -**/ -typedef -VOID -(EFIAPI * ASM_RELOCATE_AP_LOOP) ( - IN BOOLEAN MwaitSupport, - IN UINTN ApTargetCState, - IN UINTN PmCodeSegment, - IN UINTN TopOfApStack, - IN UINTN NumberToFinish - ); - -/** - Assembly code to get starting address and size of the rendezvous entry for APs. - Information for fixing a jump instruction in the code is also returned. - - @param[out] AddressMap Output buffer for address map information. -**/ -VOID -EFIAPI -AsmGetAddressMap ( - OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap - ); - -/** - This function is called by both the BSP and the AP which is to become the BSP to - Exchange execution context including stack between them. After return from this - function, the BSP becomes AP and the AP becomes the BSP. - - @param[in] MyInfo Pointer to buffer holding the exchanging information for the executing processor. - @param[in] OthersInfo Pointer to buffer holding the exchanging information for the peer. - -**/ -VOID -EFIAPI -AsmExchangeRole ( - IN CPU_EXCHANGE_ROLE_INFO *MyInfo, - IN CPU_EXCHANGE_ROLE_INFO *OthersInfo - ); - -/** - Get the pointer to CPU MP Data structure. - - @return The pointer to CPU MP Data structure. -**/ -CPU_MP_DATA * -GetCpuMpData ( - VOID - ); - -/** - Save the pointer to CPU MP Data structure. - - @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. -**/ -VOID -SaveCpuMpData ( - IN CPU_MP_DATA *CpuMpData - ); - -/** - Allocate reset vector buffer. - - @param[in, out] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -AllocateResetVector ( - IN OUT CPU_MP_DATA *CpuMpData - ); - -/** - Free AP reset vector buffer. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -FreeResetVector ( - IN CPU_MP_DATA *CpuMpData - ); - -/** - This function will be called by BSP to wakeup AP. - - @param[in] CpuMpData Pointer to CPU MP Data - @param[in] Broadcast TRUE: Send broadcast IPI to all APs - FALSE: Send IPI to AP by ApicId - @param[in] ProcessorNumber The handle number of specified processor - @param[in] Procedure The function to be invoked by AP - @param[in] ProcedureArgument The argument to be passed into AP function -**/ -VOID -WakeUpAP ( - IN CPU_MP_DATA *CpuMpData, - IN BOOLEAN Broadcast, - IN UINTN ProcessorNumber, - IN EFI_AP_PROCEDURE Procedure, OPTIONAL - IN VOID *ProcedureArgument OPTIONAL - ); - -/** - Initialize global data for MP support. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -InitMpGlobalData ( - IN CPU_MP_DATA *CpuMpData - ); - -/** - Worker function to execute a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval others Failed to Startup all APs. - -**/ -EFI_STATUS -StartupAllAPsWorker ( - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ); - -/** - Worker function to let the caller get one enabled AP to execute a caller-provided - function. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. - @param[in] ProcessorNumber The handle number of the AP. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] Finished If AP returns from Procedure before the - timeout expires, its content is set to TRUE. - Otherwise, the value is set to FALSE. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval others Failed to Startup AP. - -**/ -EFI_STATUS -StartupThisAPWorker ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ); - -/** - Worker function to switch the requested AP to be the BSP from that point onward. - - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval others Failed to switch BSP. - -**/ -EFI_STATUS -SwitchBSPWorker ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ); - -/** - Worker function to let the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of AP. - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval others Failed to Enable/Disable AP. - -**/ -EFI_STATUS -EnableDisableApWorker ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ); - -/** - Get pointer to CPU MP Data structure from GUIDed HOB. - - @return The pointer to CPU MP Data structure. -**/ -CPU_MP_DATA * -GetCpuMpDataFromGuidedHob ( - VOID - ); - -/** Checks status of specified AP. - - This function checks whether the specified AP has finished the task assigned - by StartupThisAP(), and whether timeout expires. - - @param[in] ProcessorNumber The handle number of processor. - - @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs(). - @retval EFI_TIMEOUT The timeout expires. - @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired. -**/ -EFI_STATUS -CheckThisAP ( - IN UINTN ProcessorNumber - ); - -/** - Checks status of all APs. - - This function checks whether all APs have finished task assigned by StartupAllAPs(), - and whether timeout expires. - - @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs(). - @retval EFI_TIMEOUT The timeout expires. - @retval EFI_NOT_READY APs have not finished task and timeout has not expired. -**/ -EFI_STATUS -CheckAllAPs ( - VOID - ); - -/** - Checks APs status and updates APs status if needed. - -**/ -VOID -CheckAndUpdateApsStatus ( - VOID - ); - -/** - Detect whether specified processor can find matching microcode patch and load it. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -MicrocodeDetect ( - IN CPU_MP_DATA *CpuMpData - ); - -/** - Detect whether Mwait-monitor feature is supported. - - @retval TRUE Mwait-monitor feature is supported. - @retval FALSE Mwait-monitor feature is not supported. -**/ -BOOLEAN -IsMwaitSupport ( - VOID - ); - -/** - Notify function on End Of PEI PPI. - - On S3 boot, this function will restore wakeup buffer data. - On normal boot, this function will flag wakeup buffer to be un-used type. - - @param[in] PeiServices The pointer to the PEI Services Table. - @param[in] NotifyDescriptor Address of the notification descriptor data structure. - @param[in] Ppi Address of the PPI that was installed. - - @retval EFI_SUCCESS When everything is OK. -**/ -EFI_STATUS -EFIAPI -CpuMpEndOfPeiCallback ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, - IN VOID *Ppi - ); - -/** - Get available system memory below 1MB by specified size. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -BackupAndPrepareWakeupBuffer( - IN CPU_MP_DATA *CpuMpData - ); - -/** - Restore wakeup buffer data. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -RestoreWakeupBuffer( - IN CPU_MP_DATA *CpuMpData - ); - -/** - Enable Debug Agent to support source debugging on AP function. - -**/ -VOID -EnableDebugAgent ( - VOID - ); - -#endif - diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf deleted file mode 100644 index 0c6873da79..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf +++ /dev/null @@ -1,70 +0,0 @@ -## @file -# MP Initialize Library instance for PEI driver. -# -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiMpInitLib - MODULE_UNI_FILE = PeiMpInitLib.uni - FILE_GUID = B00F6090-7739-4830-B906-E0032D388987 - MODULE_TYPE = PEIM - VERSION_STRING = 1.1 - LIBRARY_CLASS = MpInitLib|PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.IA32] - Ia32/MpEqu.inc - Ia32/MpFuncs.nasm - -[Sources.X64] - X64/MpEqu.inc - X64/MpFuncs.nasm - -[Sources.common] - PeiMpLib.c - MpLib.c - MpLib.h - Microcode.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - LocalApicLib - MemoryAllocationLib - HobLib - PeiServicesLib - MtrrLib - CpuLib - UefiCpuLib - SynchronizationLib - -[Ppis] - gEfiEndOfPeiSignalPpiGuid ## NOTIFY - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOMETIMES_CONSUMES - diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni deleted file mode 100644 index d16f306685..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// MP Initialize Library instance for PEI driver. -// -// MP Initialize Library instance for PEI driver. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "MP Initialize Library instance for PEI driver." - -#string STR_MODULE_DESCRIPTION #language en-US "MP Initialize Library instance for PEI driver." - diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c deleted file mode 100644 index fb1d48fad8..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c +++ /dev/null @@ -1,624 +0,0 @@ -/** @file - MP initialize support functions for PEI phase. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "MpLib.h" -#include -#include - -// -// Global PEI notify function descriptor on EndofPei event -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMpInitLibNotifyList = { - (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiEndOfPeiSignalPpiGuid, - CpuMpEndOfPeiCallback -}; - - -/** - Enable Debug Agent to support source debugging on AP function. - -**/ -VOID -EnableDebugAgent ( - VOID - ) -{ -} - -/** - Get pointer to CPU MP Data structure. - - @return The pointer to CPU MP Data structure. -**/ -CPU_MP_DATA * -GetCpuMpData ( - VOID - ) -{ - CPU_MP_DATA *CpuMpData; - - CpuMpData = GetCpuMpDataFromGuidedHob (); - ASSERT (CpuMpData != NULL); - return CpuMpData; -} - -/** - Save the pointer to CPU MP Data structure. - - @param[in] CpuMpData The pointer to CPU MP Data structure will be saved. -**/ -VOID -SaveCpuMpData ( - IN CPU_MP_DATA *CpuMpData - ) -{ - UINT64 Data64; - // - // Build location of CPU MP DATA buffer in HOB - // - Data64 = (UINT64) (UINTN) CpuMpData; - BuildGuidDataHob ( - &mCpuInitMpLibHobGuid, - (VOID *) &Data64, - sizeof (UINT64) - ); -} - -/** - Notify function on End Of PEI PPI. - - On S3 boot, this function will restore wakeup buffer data. - On normal boot, this function will flag wakeup buffer to be un-used type. - - @param[in] PeiServices The pointer to the PEI Services Table. - @param[in] NotifyDescriptor Address of the notification descriptor data structure. - @param[in] Ppi Address of the PPI that was installed. - - @retval EFI_SUCCESS When everything is OK. -**/ -EFI_STATUS -EFIAPI -CpuMpEndOfPeiCallback ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, - IN VOID *Ppi - ) -{ - EFI_STATUS Status; - EFI_BOOT_MODE BootMode; - CPU_MP_DATA *CpuMpData; - EFI_PEI_HOB_POINTERS Hob; - EFI_HOB_MEMORY_ALLOCATION *MemoryHob; - - DEBUG ((DEBUG_INFO, "PeiMpInitLib: CpuMpEndOfPeiCallback () invoked\n")); - - Status = PeiServicesGetBootMode (&BootMode); - ASSERT_EFI_ERROR (Status); - - CpuMpData = GetCpuMpData (); - if (BootMode != BOOT_ON_S3_RESUME) { - // - // Get the HOB list for processing - // - Hob.Raw = GetHobList (); - // - // Collect memory ranges - // - while (!END_OF_HOB_LIST (Hob)) { - if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) { - MemoryHob = Hob.MemoryAllocation; - if (MemoryHob->AllocDescriptor.MemoryBaseAddress == CpuMpData->WakeupBuffer) { - // - // Flag this HOB type to un-used - // - GET_HOB_TYPE (Hob) = EFI_HOB_TYPE_UNUSED; - break; - } - } - Hob.Raw = GET_NEXT_HOB (Hob); - } - } else { - CpuMpData->SaveRestoreFlag = TRUE; - RestoreWakeupBuffer (CpuMpData); - } - return EFI_SUCCESS; -} - -/** - Check if AP wakeup buffer is overlapped with existing allocated buffer. - - @param[in] WakeupBufferStart AP wakeup buffer start address. - @param[in] WakeupBufferEnd AP wakeup buffer end address. - - @retval TRUE There is overlap. - @retval FALSE There is no overlap. -**/ -BOOLEAN -CheckOverlapWithAllocatedBuffer ( - IN UINTN WakeupBufferStart, - IN UINTN WakeupBufferEnd - ) -{ - EFI_PEI_HOB_POINTERS Hob; - EFI_HOB_MEMORY_ALLOCATION *MemoryHob; - BOOLEAN Overlapped; - UINTN MemoryStart; - UINTN MemoryEnd; - - Overlapped = FALSE; - // - // Get the HOB list for processing - // - Hob.Raw = GetHobList (); - // - // Collect memory ranges - // - while (!END_OF_HOB_LIST (Hob)) { - if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) { - MemoryHob = Hob.MemoryAllocation; - MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress; - MemoryEnd = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress + - MemoryHob->AllocDescriptor.MemoryLength); - if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) { - Overlapped = TRUE; - break; - } - } - Hob.Raw = GET_NEXT_HOB (Hob); - } - return Overlapped; -} - -/** - Get available system memory below 1MB by specified size. - - @param[in] WakeupBufferSize Wakeup buffer size required - - @retval other Return wakeup buffer address below 1MB. - @retval -1 Cannot find free memory below 1MB. -**/ -UINTN -GetWakeupBuffer ( - IN UINTN WakeupBufferSize - ) -{ - EFI_PEI_HOB_POINTERS Hob; - UINTN WakeupBufferStart; - UINTN WakeupBufferEnd; - - WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1); - - // - // Get the HOB list for processing - // - Hob.Raw = GetHobList (); - - // - // Collect memory ranges - // - while (!END_OF_HOB_LIST (Hob)) { - if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if ((Hob.ResourceDescriptor->PhysicalStart < BASE_1MB) && - (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) && - ((Hob.ResourceDescriptor->ResourceAttribute & - (EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | - EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | - EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED - )) == 0) - ) { - // - // Need memory under 1MB to be collected here - // - WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength); - if (WakeupBufferEnd > BASE_1MB) { - // - // Wakeup buffer should be under 1MB - // - WakeupBufferEnd = BASE_1MB; - } - while (WakeupBufferEnd > WakeupBufferSize) { - // - // Wakeup buffer should be aligned on 4KB - // - WakeupBufferStart = (WakeupBufferEnd - WakeupBufferSize) & ~(SIZE_4KB - 1); - if (WakeupBufferStart < Hob.ResourceDescriptor->PhysicalStart) { - break; - } - if (CheckOverlapWithAllocatedBuffer (WakeupBufferStart, WakeupBufferEnd)) { - // - // If this range is overlapped with existing allocated buffer, skip it - // and find the next range - // - WakeupBufferEnd -= WakeupBufferSize; - continue; - } - DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n", - WakeupBufferStart, WakeupBufferSize)); - // - // Create a memory allocation HOB. - // - BuildMemoryAllocationHob ( - WakeupBufferStart, - WakeupBufferSize, - EfiBootServicesData - ); - return WakeupBufferStart; - } - } - } - // - // Find the next HOB - // - Hob.Raw = GET_NEXT_HOB (Hob); - } - - return (UINTN) -1; -} - -/** - Allocate reset vector buffer. - - @param[in, out] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -AllocateResetVector ( - IN OUT CPU_MP_DATA *CpuMpData - ) -{ - UINTN ApResetVectorSize; - - if (CpuMpData->WakeupBuffer == (UINTN) -1) { - ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize + - sizeof (MP_CPU_EXCHANGE_INFO); - - CpuMpData->WakeupBuffer = GetWakeupBuffer (ApResetVectorSize); - CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) - (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize); - BackupAndPrepareWakeupBuffer (CpuMpData); - } - - if (CpuMpData->SaveRestoreFlag) { - BackupAndPrepareWakeupBuffer (CpuMpData); - } -} - -/** - Free AP reset vector buffer. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -FreeResetVector ( - IN CPU_MP_DATA *CpuMpData - ) -{ - if (CpuMpData->SaveRestoreFlag) { - RestoreWakeupBuffer (CpuMpData); - } -} - -/** - Checks APs status and updates APs status if needed. - -**/ -VOID -CheckAndUpdateApsStatus ( - VOID - ) -{ -} - -/** - Initialize global data for MP support. - - @param[in] CpuMpData The pointer to CPU MP Data structure. -**/ -VOID -InitMpGlobalData ( - IN CPU_MP_DATA *CpuMpData - ) -{ - EFI_STATUS Status; - - SaveCpuMpData (CpuMpData); - - if (CpuMpData->CpuCount == 1) { - // - // If only BSP exists, return - // - return; - } - - // - // Register an event for EndOfPei - // - Status = PeiServicesNotifyPpi (&mMpInitLibNotifyList); - ASSERT_EFI_ERROR (Status); -} - -/** - This service executes a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. See type - EFI_AP_PROCEDURE. - @param[in] SingleThread If TRUE, then all the enabled APs execute - the function specified by Procedure one by - one, in ascending order of processor handle - number. If FALSE, then all the enabled APs - execute the function specified by Procedure - simultaneously. - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until all APs finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on all the enabled - APs, and go on executing immediately. If - all return from Procedure, or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - APs to return from Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - all APs return from Procedure, then Procedure - on the failed APs is terminated. All enabled - APs are available for next function assigned - by MpInitLibStartupAllAPs() or - MPInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure for - all APs. - @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, - if all APs finish successfully, then its - content is set to NULL. If not all APs - finish before timeout expires, then its - content is set to address of the buffer - holding handle numbers of the failed APs. - The buffer is allocated by MP Initialization - library, and it's the caller's responsibility to - free the buffer with FreePool() service. - In blocking mode, it is ready for consumption - when the call returns. In non-blocking mode, - it is ready when WaitEvent is signaled. The - list of failed CPU is terminated by - END_OF_CPU_LIST. - - @retval EFI_SUCCESS In blocking mode, all APs have finished before - the timeout expired. - @retval EFI_SUCCESS In non-blocking mode, function has been dispatched - to all enabled APs. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR Caller processor is AP. - @retval EFI_NOT_STARTED No enabled APs exist in the system. - @retval EFI_NOT_READY Any enabled APs are busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - all enabled APs have finished. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupAllAPs ( - IN EFI_AP_PROCEDURE Procedure, - IN BOOLEAN SingleThread, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT UINTN **FailedCpuList OPTIONAL - ) -{ - if (WaitEvent != NULL) { - return EFI_UNSUPPORTED; - } - - return StartupAllAPsWorker ( - Procedure, - SingleThread, - NULL, - TimeoutInMicroseconds, - ProcedureArgument, - FailedCpuList - ); -} - -/** - This service lets the caller get one enabled AP to execute a caller-provided - function. - - @param[in] Procedure A pointer to the function to be run on the - designated AP of the system. See type - EFI_AP_PROCEDURE. - @param[in] ProcessorNumber The handle number of the AP. The range is - from 0 to the total number of logical - processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] WaitEvent The event created by the caller with CreateEvent() - service. If it is NULL, then execute in - blocking mode. BSP waits until this AP finish - or TimeoutInMicroSeconds expires. If it's - not NULL, then execute in non-blocking mode. - BSP requests the function specified by - Procedure to be started on this AP, - and go on executing immediately. If this AP - return from Procedure or TimeoutInMicroSeconds - expires, this event is signaled. The BSP - can use the CheckEvent() or WaitForEvent() - services to check the state of event. Type - EFI_EVENT is defined in CreateEvent() in - the Unified Extensible Firmware Interface - Specification. - @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for - this AP to finish this Procedure, either for - blocking or non-blocking mode. Zero means - infinity. If the timeout expires before - this AP returns from Procedure, then Procedure - on the AP is terminated. The - AP is available for next function assigned - by MpInitLibStartupAllAPs() or - MpInitLibStartupThisAP(). - If the timeout expires in blocking mode, - BSP returns EFI_TIMEOUT. If the timeout - expires in non-blocking mode, WaitEvent - is signaled with SignalEvent(). - @param[in] ProcedureArgument The parameter passed into Procedure on the - specified AP. - @param[out] Finished If NULL, this parameter is ignored. In - blocking mode, this parameter is ignored. - In non-blocking mode, if AP returns from - Procedure before the timeout expires, its - content is set to TRUE. Otherwise, the - value is set to FALSE. The caller can - determine if the AP returned from Procedure - by evaluating this value. - - @retval EFI_SUCCESS In blocking mode, specified AP finished before - the timeout expires. - @retval EFI_SUCCESS In non-blocking mode, the function has been - dispatched to specified AP. - @retval EFI_UNSUPPORTED A non-blocking mode request was made after the - UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was - signaled. - @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not - supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_TIMEOUT In blocking mode, the timeout expired before - the specified AP has finished. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. - @retval EFI_INVALID_PARAMETER Procedure is NULL. - -**/ -EFI_STATUS -EFIAPI -MpInitLibStartupThisAP ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN ProcessorNumber, - IN EFI_EVENT WaitEvent OPTIONAL, - IN UINTN TimeoutInMicroseconds, - IN VOID *ProcedureArgument OPTIONAL, - OUT BOOLEAN *Finished OPTIONAL - ) -{ - if (WaitEvent != NULL) { - return EFI_UNSUPPORTED; - } - - return StartupThisAPWorker ( - Procedure, - ProcessorNumber, - NULL, - TimeoutInMicroseconds, - ProcedureArgument, - Finished - ); -} - -/** - This service switches the requested AP to be the BSP from that point onward. - This service changes the BSP for all purposes. This call can only be performed - by the current BSP. - - @param[in] ProcessorNumber The handle number of AP that is to become the new - BSP. The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an - enabled AP. Otherwise, it will be disabled. - - @retval EFI_SUCCESS BSP successfully switched. - @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to - this service returning. - @retval EFI_UNSUPPORTED Switching the BSP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or - a disabled AP. - @retval EFI_NOT_READY The specified AP is busy. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibSwitchBSP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableOldBSP - ) -{ - return SwitchBSPWorker (ProcessorNumber, EnableOldBSP); -} - -/** - This service lets the caller enable or disable an AP from this point onward. - This service may only be called from the BSP. - - @param[in] ProcessorNumber The handle number of AP. - The range is from 0 to the total number of - logical processors minus 1. The total number of - logical processors can be retrieved by - MpInitLibGetNumberOfProcessors(). - @param[in] EnableAP Specifies the new state for the processor for - enabled, FALSE for disabled. - @param[in] HealthFlag If not NULL, a pointer to a value that specifies - the new health status of the AP. This flag - corresponds to StatusFlag defined in - EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only - the PROCESSOR_HEALTH_STATUS_BIT is used. All other - bits are ignored. If it is NULL, this parameter - is ignored. - - @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. - @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed - prior to this service returning. - @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. - @retval EFI_DEVICE_ERROR The calling processor is an AP. - @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber - does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. - @retval EFI_NOT_READY MP Initialize Library is not initialized. - -**/ -EFI_STATUS -EFIAPI -MpInitLibEnableDisableAP ( - IN UINTN ProcessorNumber, - IN BOOLEAN EnableAP, - IN UINT32 *HealthFlag OPTIONAL - ) -{ - return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); -} - - diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc b/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc deleted file mode 100644 index a63cd23a40..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc +++ /dev/null @@ -1,43 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpEqu.inc -; -; Abstract: -; -; This is the equates file for Multiple Processor support -; -;------------------------------------------------------------------------------- - -VacantFlag equ 00h -NotVacantFlag equ 0ffh - -CPU_SWITCH_STATE_IDLE equ 0 -CPU_SWITCH_STATE_STORED equ 1 -CPU_SWITCH_STATE_LOADED equ 2 - -LockLocation equ (RendezvousFunnelProcEnd - RendezvousFunnelProcStart) -StackStartAddressLocation equ LockLocation + 08h -StackSizeLocation equ LockLocation + 10h -ApProcedureLocation equ LockLocation + 18h -GdtrLocation equ LockLocation + 20h -IdtrLocation equ LockLocation + 2Ah -BufferStartLocation equ LockLocation + 34h -ModeOffsetLocation equ LockLocation + 3Ch -NumApsExecutingLocation equ LockLocation + 44h -CodeSegmentLocation equ LockLocation + 4Ch -DataSegmentLocation equ LockLocation + 54h -EnableExecuteDisableLocation equ LockLocation + 5Ch -Cr3Location equ LockLocation + 64h -InitFlagLocation equ LockLocation + 6Ch -CpuInfoLocation equ LockLocation + 74h - diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm deleted file mode 100644 index fa54d01542..0000000000 --- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm +++ /dev/null @@ -1,398 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.nasm -; -; Abstract: -; -; This is the assembly code for MP support -; -;------------------------------------------------------------------------------- - -%include "MpEqu.inc" -extern ASM_PFX(InitializeFloatingPointUnits) - -DEFAULT REL - -SECTION .text - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -global ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: -; At this point CS = 0x(vv00) and ip= 0x0. -; Save BIST information to ebp firstly - -BITS 16 - mov ebp, eax ; Save BIST information - - mov ax, cs - mov ds, ax - mov es, ax - mov ss, ax - xor ax, ax - mov fs, ax - mov gs, ax - - mov si, BufferStartLocation - mov ebx, [si] - - mov di, ModeOffsetLocation - mov eax, [di] - mov di, CodeSegmentLocation - mov edx, [di] - mov di, ax - sub di, 02h - mov [di],dx ; Patch long mode CS - sub di, 04h - add eax, ebx - mov [di],eax ; Patch address - - mov si, GdtrLocation -o32 lgdt [cs:si] - - mov si, IdtrLocation -o32 lidt [cs:si] - - mov si, EnableExecuteDisableLocation - cmp byte [si], 0 - jz SkipEnableExecuteDisableBit - - ; - ; Enable execute disable bit - ; - mov ecx, 0c0000080h ; EFER MSR number - rdmsr ; Read EFER - bts eax, 11 ; Enable Execute Disable Bit - wrmsr ; Write EFER - -SkipEnableExecuteDisableBit: - - mov di, DataSegmentLocation - mov edi, [di] ; Save long mode DS in edi - - mov si, Cr3Location ; Save CR3 in ecx - mov ecx, [si] - - xor ax, ax - mov ds, ax ; Clear data segment - - mov eax, cr0 ; Get control register 0 - or eax, 000000003h ; Set PE bit (bit #0) & MP - mov cr0, eax - - mov eax, cr4 - bts eax, 5 - mov cr4, eax - - mov cr3, ecx ; Load CR3 - - mov ecx, 0c0000080h ; EFER MSR number - rdmsr ; Read EFER - bts eax, 8 ; Set LME=1 - wrmsr ; Write EFER - - mov eax, cr0 ; Read CR0 - bts eax, 31 ; Set PG=1 - mov cr0, eax ; Write CR0 - - jmp 0:strict dword 0 ; far jump to long mode -BITS 64 -LongModeStart: - mov eax, edi - mov ds, ax - mov es, ax - mov ss, ax - - mov esi, ebx - lea edi, [esi + InitFlagLocation] - cmp qword [edi], 1 ; ApInitConfig - jnz GetApicId - - ; AP init - mov edi, esi - add edi, LockLocation - mov rax, NotVacantFlag - -TestLock: - xchg qword [edi], rax - cmp rax, NotVacantFlag - jz TestLock - - lea ecx, [esi + NumApsExecutingLocation] - inc dword [ecx] - mov ebx, [ecx] - -Releaselock: - mov rax, VacantFlag - xchg qword [edi], rax - ; program stack - mov edi, esi - add edi, StackSizeLocation - mov eax, dword [edi] - mov ecx, ebx - inc ecx - mul ecx ; EAX = StackSize * (CpuNumber + 1) - mov edi, esi - add edi, StackStartAddressLocation - add rax, qword [edi] - mov rsp, rax - jmp CProcedureInvoke - -GetApicId: - mov eax, 0 - cpuid - cmp eax, 0bh - jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY - - mov eax, 0bh - xor ecx, ecx - cpuid - test ebx, 0ffffh - jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero - - ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX - jmp GetProcessorNumber - -NoX2Apic: - ; Processor is not x2APIC capable, so get 8-bit APIC ID - mov eax, 1 - cpuid - shr ebx, 24 - mov edx, ebx - -GetProcessorNumber: - ; - ; Get processor number for this AP - ; Note that BSP may become an AP due to SwitchBsp() - ; - xor ebx, ebx - lea eax, [esi + CpuInfoLocation] - mov edi, [eax] - -GetNextProcNumber: - cmp dword [edi], edx ; APIC ID match? - jz ProgramStack - add edi, 20 - inc ebx - jmp GetNextProcNumber - -ProgramStack: - mov rsp, qword [edi + 12] - -CProcedureInvoke: - push rbp ; Push BIST data at top of AP stack - xor rbp, rbp ; Clear ebp for call stack trace - push rbp - mov rbp, rsp - - mov rax, ASM_PFX(InitializeFloatingPointUnits) - sub rsp, 20h - call rax ; Call assembly function to initialize FPU per UEFI spec - add rsp, 20h - - mov edx, ebx ; edx is NumApsExecuting - mov ecx, esi - add ecx, LockLocation ; rcx is address of exchange info data buffer - - mov edi, esi - add edi, ApProcedureLocation - mov rax, qword [edi] - - sub rsp, 20h - call rax ; Invoke C function - add rsp, 20h - jmp $ ; Should never reach here - -RendezvousFunnelProcEnd: - -;------------------------------------------------------------------------------------- -; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmRelocateApLoop) -ASM_PFX(AsmRelocateApLoop): -AsmRelocateApLoopStart: - mov rax, [rsp + 40] ; CountTofinish - lock dec dword [rax] ; (*CountTofinish)-- - mov rsp, r9 - push rcx - push rdx - - lea rsi, [PmEntry] ; rsi <- The start address of transition code - - push r8 - push rsi - DB 0x48 - retf -BITS 32 -PmEntry: - mov eax, cr0 - btr eax, 31 ; Clear CR0.PG - mov cr0, eax ; Disable paging and caches - - mov ebx, edx ; Save EntryPoint to rbx, for rdmsr will overwrite rdx - mov ecx, 0xc0000080 - rdmsr - and ah, ~ 1 ; Clear LME - wrmsr - mov eax, cr4 - and al, ~ (1 << 5) ; Clear PAE - mov cr4, eax - - pop edx - add esp, 4 - pop ecx, - add esp, 4 - cmp cl, 1 ; Check mwait-monitor support - jnz HltLoop - mov ebx, edx ; Save C-State to ebx -MwaitLoop: - mov eax, esp ; Set Monitor Address - xor ecx, ecx ; ecx = 0 - xor edx, edx ; edx = 0 - monitor - mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4] - shl eax, 4 - mwait - jmp MwaitLoop -HltLoop: - cli - hlt - jmp HltLoop -BITS 64 -AsmRelocateApLoopEnd: - -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - mov rax, ASM_PFX(RendezvousFunnelProc) - mov qword [rcx], rax - mov qword [rcx + 8h], LongModeStart - RendezvousFunnelProcStart - mov qword [rcx + 10h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - mov rax, ASM_PFX(AsmRelocateApLoop) - mov qword [rcx + 18h], rax - mov qword [rcx + 20h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart - ret - -;------------------------------------------------------------------------------------- -;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is -;about to become an AP. It switches its stack with the current AP. -;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmExchangeRole) -ASM_PFX(AsmExchangeRole): - ; DO NOT call other functions in this function, since 2 CPU may use 1 stack - ; at the same time. If 1 CPU try to call a function, stack will be corrupted. - - push rax - push rbx - push rcx - push rdx - push rsi - push rdi - push rbp - push r8 - push r9 - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - - mov rax, cr0 - push rax - - mov rax, cr4 - push rax - - ; rsi contains MyInfo pointer - mov rsi, rcx - - ; rdi contains OthersInfo pointer - mov rdi, rdx - - ;Store EFLAGS, GDTR and IDTR regiter to stack - pushfq - sgdt [rsi + 16] - sidt [rsi + 26] - - ; Store the its StackPointer - mov [rsi + 8], rsp - - ; update its switch state to STORED - mov byte [rsi], CPU_SWITCH_STATE_STORED - -WaitForOtherStored: - ; wait until the other CPU finish storing its state - cmp byte [rdi], CPU_SWITCH_STATE_STORED - jz OtherStored - pause - jmp WaitForOtherStored - -OtherStored: - ; Since another CPU already stored its state, load them - ; load GDTR value - lgdt [rdi + 16] - - ; load IDTR value - lidt [rdi + 26] - - ; load its future StackPointer - mov rsp, [rdi + 8] - - ; update the other CPU's switch state to LOADED - mov byte [rdi], CPU_SWITCH_STATE_LOADED - -WaitForOtherLoaded: - ; wait until the other CPU finish loading new state, - ; otherwise the data in stack may corrupt - cmp byte [rsi], CPU_SWITCH_STATE_LOADED - jz OtherLoaded - pause - jmp WaitForOtherLoaded - -OtherLoaded: - ; since the other CPU already get the data it want, leave this procedure - popfq - - pop rax - mov cr4, rax - - pop rax - mov cr0, rax - - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - pop rbp - pop rdi - pop rsi - pop rdx - pop rcx - pop rbx - pop rax - - ret diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c deleted file mode 100644 index c38191a7ef..0000000000 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ /dev/null @@ -1,2441 +0,0 @@ -/** @file - MTRR setting library - - @par Note: - Most of services in this library instance are suggested to be invoked by BSP only, - except for MtrrSetAllMtrrs() which is used to sync BSP's MTRR setting to APs. - - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define OR_SEED 0x0101010101010101ull -#define CLEAR_SEED 0xFFFFFFFFFFFFFFFFull - -#define MTRR_LIB_ASSERT_ALIGNED(B, L) ASSERT ((B & ~(L - 1)) == B); -// -// Context to save and restore when MTRRs are programmed -// -typedef struct { - UINTN Cr4; - BOOLEAN InterruptState; -} MTRR_CONTEXT; - -typedef struct { - UINT64 BaseAddress; - UINT64 Length; - MTRR_MEMORY_CACHE_TYPE Type; -} MEMORY_RANGE; - -// -// This table defines the offset, base and length of the fixed MTRRs -// -CONST FIXED_MTRR mMtrrLibFixedMtrrTable[] = { - { - MSR_IA32_MTRR_FIX64K_00000, - 0, - SIZE_64KB - }, - { - MSR_IA32_MTRR_FIX16K_80000, - 0x80000, - SIZE_16KB - }, - { - MSR_IA32_MTRR_FIX16K_A0000, - 0xA0000, - SIZE_16KB - }, - { - MSR_IA32_MTRR_FIX4K_C0000, - 0xC0000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_C8000, - 0xC8000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_D0000, - 0xD0000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_D8000, - 0xD8000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_E0000, - 0xE0000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_E8000, - 0xE8000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_F0000, - 0xF0000, - SIZE_4KB - }, - { - MSR_IA32_MTRR_FIX4K_F8000, - 0xF8000, - SIZE_4KB - } -}; - -// -// Lookup table used to print MTRRs -// -GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mMtrrMemoryCacheTypeShortName[] = { - "UC", // CacheUncacheable - "WC", // CacheWriteCombining - "R*", // Invalid - "R*", // Invalid - "WT", // CacheWriteThrough - "WP", // CacheWriteProtected - "WB", // CacheWriteBack - "R*" // Invalid -}; - -/** - Worker function returns the variable MTRR count for the CPU. - - @return Variable MTRR count - -**/ -UINT32 -GetVariableMtrrCountWorker ( - VOID - ) -{ - MSR_IA32_MTRRCAP_REGISTER MtrrCap; - - MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); - ASSERT (MtrrCap.Bits.VCNT <= MTRR_NUMBER_OF_VARIABLE_MTRR); - return MtrrCap.Bits.VCNT; -} - -/** - Returns the variable MTRR count for the CPU. - - @return Variable MTRR count - -**/ -UINT32 -EFIAPI -GetVariableMtrrCount ( - VOID - ) -{ - if (!IsMtrrSupported ()) { - return 0; - } - return GetVariableMtrrCountWorker (); -} - -/** - Worker function returns the firmware usable variable MTRR count for the CPU. - - @return Firmware usable variable MTRR count - -**/ -UINT32 -GetFirmwareVariableMtrrCountWorker ( - VOID - ) -{ - UINT32 VariableMtrrCount; - UINT32 ReservedMtrrNumber; - - VariableMtrrCount = GetVariableMtrrCountWorker (); - ReservedMtrrNumber = PcdGet32 (PcdCpuNumberOfReservedVariableMtrrs); - if (VariableMtrrCount < ReservedMtrrNumber) { - return 0; - } - - return VariableMtrrCount - ReservedMtrrNumber; -} - -/** - Returns the firmware usable variable MTRR count for the CPU. - - @return Firmware usable variable MTRR count - -**/ -UINT32 -EFIAPI -GetFirmwareVariableMtrrCount ( - VOID - ) -{ - if (!IsMtrrSupported ()) { - return 0; - } - return GetFirmwareVariableMtrrCountWorker (); -} - -/** - Worker function returns the default MTRR cache type for the system. - - If MtrrSetting is not NULL, returns the default MTRR cache type from input - MTRR settings buffer. - If MtrrSetting is NULL, returns the default MTRR cache type from MSR. - - @param[in] MtrrSetting A buffer holding all MTRRs content. - - @return The default MTRR cache type. - -**/ -MTRR_MEMORY_CACHE_TYPE -MtrrGetDefaultMemoryTypeWorker ( - IN MTRR_SETTINGS *MtrrSetting - ) -{ - MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; - - if (MtrrSetting == NULL) { - DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - } else { - DefType.Uint64 = MtrrSetting->MtrrDefType; - } - - return (MTRR_MEMORY_CACHE_TYPE) DefType.Bits.Type; -} - - -/** - Returns the default MTRR cache type for the system. - - @return The default MTRR cache type. - -**/ -MTRR_MEMORY_CACHE_TYPE -EFIAPI -MtrrGetDefaultMemoryType ( - VOID - ) -{ - if (!IsMtrrSupported ()) { - return CacheUncacheable; - } - return MtrrGetDefaultMemoryTypeWorker (NULL); -} - -/** - Preparation before programming MTRR. - - This function will do some preparation for programming MTRRs: - disable cache, invalid cache and disable MTRR caching functionality - - @param[out] MtrrContext Pointer to context to save - -**/ -VOID -MtrrLibPreMtrrChange ( - OUT MTRR_CONTEXT *MtrrContext - ) -{ - MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; - // - // Disable interrupts and save current interrupt state - // - MtrrContext->InterruptState = SaveAndDisableInterrupts(); - - // - // Enter no fill cache mode, CD=1(Bit30), NW=0 (Bit29) - // - AsmDisableCache (); - - // - // Save original CR4 value and clear PGE flag (Bit 7) - // - MtrrContext->Cr4 = AsmReadCr4 (); - AsmWriteCr4 (MtrrContext->Cr4 & (~BIT7)); - - // - // Flush all TLBs - // - CpuFlushTlb (); - - // - // Disable MTRRs - // - DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - DefType.Bits.E = 0; - AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); -} - -/** - Cleaning up after programming MTRRs. - - This function will do some clean up after programming MTRRs: - Flush all TLBs, re-enable caching, restore CR4. - - @param[in] MtrrContext Pointer to context to restore - -**/ -VOID -MtrrLibPostMtrrChangeEnableCache ( - IN MTRR_CONTEXT *MtrrContext - ) -{ - // - // Flush all TLBs - // - CpuFlushTlb (); - - // - // Enable Normal Mode caching CD=NW=0, CD(Bit30), NW(Bit29) - // - AsmEnableCache (); - - // - // Restore original CR4 value - // - AsmWriteCr4 (MtrrContext->Cr4); - - // - // Restore original interrupt state - // - SetInterruptState (MtrrContext->InterruptState); -} - -/** - Cleaning up after programming MTRRs. - - This function will do some clean up after programming MTRRs: - enable MTRR caching functionality, and enable cache - - @param[in] MtrrContext Pointer to context to restore - -**/ -VOID -MtrrLibPostMtrrChange ( - IN MTRR_CONTEXT *MtrrContext - ) -{ - MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; - // - // Enable Cache MTRR - // - DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - DefType.Bits.E = 1; - DefType.Bits.FE = 1; - AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); - - MtrrLibPostMtrrChangeEnableCache (MtrrContext); -} - -/** - Worker function gets the content in fixed MTRRs - - @param[out] FixedSettings A buffer to hold fixed MTRRs content. - - @retval The pointer of FixedSettings - -**/ -MTRR_FIXED_SETTINGS* -MtrrGetFixedMtrrWorker ( - OUT MTRR_FIXED_SETTINGS *FixedSettings - ) -{ - UINT32 Index; - - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - FixedSettings->Mtrr[Index] = - AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr); - } - - return FixedSettings; -} - - -/** - This function gets the content in fixed MTRRs - - @param[out] FixedSettings A buffer to hold fixed MTRRs content. - - @retval The pointer of FixedSettings - -**/ -MTRR_FIXED_SETTINGS* -EFIAPI -MtrrGetFixedMtrr ( - OUT MTRR_FIXED_SETTINGS *FixedSettings - ) -{ - if (!IsMtrrSupported ()) { - return FixedSettings; - } - - return MtrrGetFixedMtrrWorker (FixedSettings); -} - - -/** - Worker function will get the raw value in variable MTRRs - - If MtrrSetting is not NULL, gets the variable MTRRs raw value from input - MTRR settings buffer. - If MtrrSetting is NULL, gets the variable MTRRs raw value from MTRRs. - - @param[in] MtrrSetting A buffer holding all MTRRs content. - @param[in] VariableMtrrCount Number of variable MTRRs. - @param[out] VariableSettings A buffer to hold variable MTRRs content. - - @return The VariableSettings input pointer - -**/ -MTRR_VARIABLE_SETTINGS* -MtrrGetVariableMtrrWorker ( - IN MTRR_SETTINGS *MtrrSetting, - IN UINT32 VariableMtrrCount, - OUT MTRR_VARIABLE_SETTINGS *VariableSettings - ) -{ - UINT32 Index; - - ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); - - for (Index = 0; Index < VariableMtrrCount; Index++) { - if (MtrrSetting == NULL) { - VariableSettings->Mtrr[Index].Base = - AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1)); - VariableSettings->Mtrr[Index].Mask = - AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1)); - } else { - VariableSettings->Mtrr[Index].Base = MtrrSetting->Variables.Mtrr[Index].Base; - VariableSettings->Mtrr[Index].Mask = MtrrSetting->Variables.Mtrr[Index].Mask; - } - } - - return VariableSettings; -} - -/** - This function will get the raw value in variable MTRRs - - @param[out] VariableSettings A buffer to hold variable MTRRs content. - - @return The VariableSettings input pointer - -**/ -MTRR_VARIABLE_SETTINGS* -EFIAPI -MtrrGetVariableMtrr ( - OUT MTRR_VARIABLE_SETTINGS *VariableSettings - ) -{ - if (!IsMtrrSupported ()) { - return VariableSettings; - } - - return MtrrGetVariableMtrrWorker ( - NULL, - GetVariableMtrrCountWorker (), - VariableSettings - ); -} - -/** - Programs fixed MTRRs registers. - - @param[in] Type The memory type to set. - @param[in, out] Base The base address of memory range. - @param[in, out] Length The length of memory range. - @param[in, out] LastMsrNum On input, the last index of the fixed MTRR MSR to program. - On return, the current index of the fixed MTRR MSR to program. - @param[out] ReturnClearMask The bits to clear in the fixed MTRR MSR. - @param[out] ReturnOrMask The bits to set in the fixed MTRR MSR. - - @retval RETURN_SUCCESS The cache type was updated successfully - @retval RETURN_UNSUPPORTED The requested range or cache type was invalid - for the fixed MTRRs. - -**/ -RETURN_STATUS -MtrrLibProgramFixedMtrr ( - IN MTRR_MEMORY_CACHE_TYPE Type, - IN OUT UINT64 *Base, - IN OUT UINT64 *Length, - IN OUT UINT32 *LastMsrNum, - OUT UINT64 *ReturnClearMask, - OUT UINT64 *ReturnOrMask - ) -{ - UINT32 MsrNum; - UINT32 LeftByteShift; - UINT32 RightByteShift; - UINT64 OrMask; - UINT64 ClearMask; - UINT64 SubLength; - - // - // Find the fixed MTRR index to be programmed - // - for (MsrNum = *LastMsrNum + 1; MsrNum < MTRR_NUMBER_OF_FIXED_MTRR; MsrNum++) { - if ((*Base >= mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) && - (*Base < - ( - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress + - (8 * mMtrrLibFixedMtrrTable[MsrNum].Length) - ) - ) - ) { - break; - } - } - - if (MsrNum == MTRR_NUMBER_OF_FIXED_MTRR) { - return RETURN_UNSUPPORTED; - } - - // - // Find the begin offset in fixed MTRR and calculate byte offset of left shift - // - LeftByteShift = ((UINT32)*Base - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) - / mMtrrLibFixedMtrrTable[MsrNum].Length; - - if (LeftByteShift >= 8) { - return RETURN_UNSUPPORTED; - } - - // - // Find the end offset in fixed MTRR and calculate byte offset of right shift - // - SubLength = mMtrrLibFixedMtrrTable[MsrNum].Length * (8 - LeftByteShift); - if (*Length >= SubLength) { - RightByteShift = 0; - } else { - RightByteShift = 8 - LeftByteShift - - (UINT32)(*Length) / mMtrrLibFixedMtrrTable[MsrNum].Length; - if ((LeftByteShift >= 8) || - (((UINT32)(*Length) % mMtrrLibFixedMtrrTable[MsrNum].Length) != 0) - ) { - return RETURN_UNSUPPORTED; - } - // - // Update SubLength by actual length - // - SubLength = *Length; - } - - ClearMask = CLEAR_SEED; - OrMask = MultU64x32 (OR_SEED, (UINT32) Type); - - if (LeftByteShift != 0) { - // - // Clear the low bits by LeftByteShift - // - ClearMask &= LShiftU64 (ClearMask, LeftByteShift * 8); - OrMask &= LShiftU64 (OrMask, LeftByteShift * 8); - } - - if (RightByteShift != 0) { - // - // Clear the high bits by RightByteShift - // - ClearMask &= RShiftU64 (ClearMask, RightByteShift * 8); - OrMask &= RShiftU64 (OrMask, RightByteShift * 8); - } - - *Length -= SubLength; - *Base += SubLength; - - *LastMsrNum = MsrNum; - *ReturnClearMask = ClearMask; - *ReturnOrMask = OrMask; - - return RETURN_SUCCESS; -} - - -/** - Worker function gets the attribute of variable MTRRs. - - This function shadows the content of variable MTRRs into an - internal array: VariableMtrr. - - @param[in] VariableSettings The variable MTRR values to shadow - @param[in] VariableMtrrCount The number of variable MTRRs - @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR - @param[in] MtrrValidAddressMask The valid address mask for MTRR - @param[out] VariableMtrr The array to shadow variable MTRRs content - - @return Number of MTRRs which has been used. - -**/ -UINT32 -MtrrGetMemoryAttributeInVariableMtrrWorker ( - IN MTRR_VARIABLE_SETTINGS *VariableSettings, - IN UINTN VariableMtrrCount, - IN UINT64 MtrrValidBitsMask, - IN UINT64 MtrrValidAddressMask, - OUT VARIABLE_MTRR *VariableMtrr - ) -{ - UINTN Index; - UINT32 UsedMtrr; - - ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * MTRR_NUMBER_OF_VARIABLE_MTRR); - for (Index = 0, UsedMtrr = 0; Index < VariableMtrrCount; Index++) { - if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *) &VariableSettings->Mtrr[Index].Mask)->Bits.V != 0) { - VariableMtrr[Index].Msr = (UINT32)Index; - VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base & MtrrValidAddressMask); - VariableMtrr[Index].Length = ((~(VariableSettings->Mtrr[Index].Mask & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1; - VariableMtrr[Index].Type = (VariableSettings->Mtrr[Index].Base & 0x0ff); - VariableMtrr[Index].Valid = TRUE; - VariableMtrr[Index].Used = TRUE; - UsedMtrr++; - } - } - return UsedMtrr; -} - - -/** - Gets the attribute of variable MTRRs. - - This function shadows the content of variable MTRRs into an - internal array: VariableMtrr. - - @param[in] MtrrValidBitsMask The mask for the valid bit of the MTRR - @param[in] MtrrValidAddressMask The valid address mask for MTRR - @param[out] VariableMtrr The array to shadow variable MTRRs content - - @return The return value of this parameter indicates the - number of MTRRs which has been used. - -**/ -UINT32 -EFIAPI -MtrrGetMemoryAttributeInVariableMtrr ( - IN UINT64 MtrrValidBitsMask, - IN UINT64 MtrrValidAddressMask, - OUT VARIABLE_MTRR *VariableMtrr - ) -{ - MTRR_VARIABLE_SETTINGS VariableSettings; - - if (!IsMtrrSupported ()) { - return 0; - } - - MtrrGetVariableMtrrWorker ( - NULL, - GetVariableMtrrCountWorker (), - &VariableSettings - ); - - return MtrrGetMemoryAttributeInVariableMtrrWorker ( - &VariableSettings, - GetFirmwareVariableMtrrCountWorker (), - MtrrValidBitsMask, - MtrrValidAddressMask, - VariableMtrr - ); -} - -/** - Return the least alignment of address. - - @param Address The address to return the alignment. - @param Alignment0 The alignment to return when Address is 0. - - @return The least alignment of the Address. -**/ -UINT64 -MtrrLibLeastAlignment ( - UINT64 Address, - UINT64 Alignment0 -) -{ - if (Address == 0) { - return Alignment0; - } - - return LShiftU64 (1, (UINTN) LowBitSet64 (Address)); -} - -/** - Return the number of required variable MTRRs to positively cover the - specified range. - - @param BaseAddress Base address of the range. - @param Length Length of the range. - @param Alignment0 Alignment of 0. - - @return The number of the required variable MTRRs. -**/ -UINT32 -MtrrLibGetPositiveMtrrNumber ( - IN UINT64 BaseAddress, - IN UINT64 Length, - IN UINT64 Alignment0 -) -{ - UINT64 SubLength; - UINT32 MtrrNumber; - BOOLEAN UseLeastAlignment; - - UseLeastAlignment = TRUE; - SubLength = 0; - - // - // Calculate the alignment of the base address. - // - for (MtrrNumber = 0; Length != 0; MtrrNumber++) { - if (UseLeastAlignment) { - SubLength = MtrrLibLeastAlignment (BaseAddress, Alignment0); - - if (SubLength > Length) { - // - // Set a flag when remaining length is too small - // so that MtrrLibLeastAlignment() is not called in following loops. - // - UseLeastAlignment = FALSE; - } - } - - if (!UseLeastAlignment) { - SubLength = GetPowerOfTwo64 (Length); - } - - BaseAddress += SubLength; - Length -= SubLength; - } - - return MtrrNumber; -} - -/** - Return whether the left MTRR type precedes the right MTRR type. - - The MTRR type precedence rules are: - 1. UC precedes any other type - 2. WT precedes WB - For further details, please refer the IA32 Software Developer's Manual, - Volume 3, Section "MTRR Precedences". - - @param Left The left MTRR type. - @param Right The right MTRR type. - - @retval TRUE Left precedes Right. - @retval FALSE Left doesn't precede Right. -**/ -BOOLEAN -MtrrLibTypeLeftPrecedeRight ( - IN MTRR_MEMORY_CACHE_TYPE Left, - IN MTRR_MEMORY_CACHE_TYPE Right -) -{ - return (BOOLEAN) (Left == CacheUncacheable || (Left == CacheWriteThrough && Right == CacheWriteBack)); -} - - -/** - Return whether the type of the specified range can precede the specified type. - - @param Ranges Memory range array holding memory type settings for all - the memory address. - @param RangeCount Count of memory ranges. - @param Type Type to check precedence. - @param SubBase Base address of the specified range. - @param SubLength Length of the specified range. - - @retval TRUE The type of the specified range can precede the Type. - @retval FALSE The type of the specified range cannot precede the Type. - So the subtraction is not applicable. -**/ -BOOLEAN -MtrrLibSubstractable ( - IN CONST MEMORY_RANGE *Ranges, - IN UINT32 RangeCount, - IN MTRR_MEMORY_CACHE_TYPE Type, - IN UINT64 SubBase, - IN UINT64 SubLength -) -{ - UINT32 Index; - UINT64 Length; - // WT > WB - // UC > * - for (Index = 0; Index < RangeCount; Index++) { - if (Ranges[Index].BaseAddress <= SubBase && SubBase < Ranges[Index].BaseAddress + Ranges[Index].Length) { - - if (Ranges[Index].BaseAddress + Ranges[Index].Length >= SubBase + SubLength) { - return MtrrLibTypeLeftPrecedeRight (Ranges[Index].Type, Type); - - } else { - if (!MtrrLibTypeLeftPrecedeRight (Ranges[Index].Type, Type)) { - return FALSE; - } - - Length = Ranges[Index].BaseAddress + Ranges[Index].Length - SubBase; - SubBase += Length; - SubLength -= Length; - } - } - } - - ASSERT (FALSE); - return FALSE; -} - -/** - Return the number of required variable MTRRs to cover the specified range. - - The routine considers subtraction in the both side of the range to find out - the most optimal solution (which uses the least MTRRs). - - @param Ranges Array holding memory type settings of all memory - address. - @param RangeCount Count of memory ranges. - @param VariableMtrr Array holding allocated variable MTRRs. - @param VariableMtrrCount Count of allocated variable MTRRs. - @param BaseAddress Base address of the specified range. - @param Length Length of the specified range. - @param Type MTRR type of the specified range. - @param Alignment0 Alignment of 0. - @param SubLeft Return the count of left subtraction. - @param SubRight Return the count of right subtraction. - - @return Number of required variable MTRRs. -**/ -UINT32 -MtrrLibGetMtrrNumber ( - IN CONST MEMORY_RANGE *Ranges, - IN UINT32 RangeCount, - IN CONST VARIABLE_MTRR *VariableMtrr, - IN UINT32 VariableMtrrCount, - IN UINT64 BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type, - IN UINT64 Alignment0, - OUT UINT32 *SubLeft, // subtractive from BaseAddress to get more aligned address, to save MTRR - OUT UINT32 *SubRight // subtractive from BaseAddress + Length, to save MTRR - ) -{ - UINT64 Alignment; - UINT32 LeastLeftMtrrNumber; - UINT32 MiddleMtrrNumber; - UINT32 LeastRightMtrrNumber; - UINT32 CurrentMtrrNumber; - UINT32 SubtractiveCount; - UINT32 SubtractiveMtrrNumber; - UINT32 LeastSubtractiveMtrrNumber; - UINT64 SubtractiveBaseAddress; - UINT64 SubtractiveLength; - UINT64 BaseAlignment; - UINT32 Index; - - *SubLeft = 0; - *SubRight = 0; - LeastSubtractiveMtrrNumber = 0; - BaseAlignment = 0; - - // - // Get the optimal left subtraction solution. - // - if (BaseAddress != 0) { - SubtractiveBaseAddress = 0; - SubtractiveLength = 0; - // - // Get the MTRR number needed without left subtraction. - // - LeastLeftMtrrNumber = MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); - - // - // Left subtraction bit by bit, to find the optimal left subtraction solution. - // - for (SubtractiveMtrrNumber = 0, SubtractiveCount = 1; BaseAddress != 0; SubtractiveCount++) { - Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); - - // - // Check whether the memory type of [BaseAddress - Alignment, BaseAddress) can override Type. - // IA32 Manual defines the following override rules: - // WT > WB - // UC > * (any) - // - if (!MtrrLibSubstractable (Ranges, RangeCount, Type, BaseAddress - Alignment, Alignment)) { - break; - } - - for (Index = 0; Index < VariableMtrrCount; Index++) { - if ((VariableMtrr[Index].BaseAddress == BaseAddress - Alignment) && - (VariableMtrr[Index].Length == Alignment)) { - break; - } - } - if (Index == VariableMtrrCount) { - // - // Increment SubtractiveMtrrNumber when [BaseAddress - Alignment, BaseAddress) is not be planed as a MTRR - // - SubtractiveMtrrNumber++; - } - - BaseAddress -= Alignment; - Length += Alignment; - - CurrentMtrrNumber = SubtractiveMtrrNumber + MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); - if (CurrentMtrrNumber <= LeastLeftMtrrNumber) { - LeastLeftMtrrNumber = CurrentMtrrNumber; - LeastSubtractiveMtrrNumber = SubtractiveMtrrNumber; - *SubLeft = SubtractiveCount; - SubtractiveBaseAddress = BaseAddress; - SubtractiveLength = Length; - } - } - - // - // If left subtraction is better, subtract BaseAddress to left, and enlarge Length - // - if (*SubLeft != 0) { - BaseAddress = SubtractiveBaseAddress; - Length = SubtractiveLength; - } - } - - // - // Increment BaseAddress greedily until (BaseAddress + Alignment) exceeds (BaseAddress + Length) - // - MiddleMtrrNumber = 0; - while (Length != 0) { - BaseAlignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); - if (BaseAlignment > Length) { - break; - } - BaseAddress += BaseAlignment; - Length -= BaseAlignment; - MiddleMtrrNumber++; - } - - - if (Length == 0) { - return LeastSubtractiveMtrrNumber + MiddleMtrrNumber; - } - - - // - // Get the optimal right subtraction solution. - // - - // - // Get the MTRR number needed without right subtraction. - // - LeastRightMtrrNumber = MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); - - for (SubtractiveCount = 1; Length < BaseAlignment; SubtractiveCount++) { - Alignment = MtrrLibLeastAlignment (BaseAddress + Length, Alignment0); - if (!MtrrLibSubstractable (Ranges, RangeCount, Type, BaseAddress + Length, Alignment)) { - break; - } - - Length += Alignment; - - // - // SubtractiveCount = Number of MTRRs used for subtraction - // - CurrentMtrrNumber = SubtractiveCount + MtrrLibGetPositiveMtrrNumber (BaseAddress, Length, Alignment0); - if (CurrentMtrrNumber <= LeastRightMtrrNumber) { - LeastRightMtrrNumber = CurrentMtrrNumber; - *SubRight = SubtractiveCount; - SubtractiveLength = Length; - } - } - - return LeastSubtractiveMtrrNumber + MiddleMtrrNumber + LeastRightMtrrNumber; -} - -/** - Initializes the valid bits mask and valid address mask for MTRRs. - - This function initializes the valid bits mask and valid address mask for MTRRs. - - @param[out] MtrrValidBitsMask The mask for the valid bit of the MTRR - @param[out] MtrrValidAddressMask The valid address mask for the MTRR - -**/ -VOID -MtrrLibInitializeMtrrMask ( - OUT UINT64 *MtrrValidBitsMask, - OUT UINT64 *MtrrValidAddressMask - ) -{ - UINT32 MaxExtendedFunction; - CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize; - - - AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NULL); - - if (MaxExtendedFunction >= CPUID_VIR_PHY_ADDRESS_SIZE) { - AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &VirPhyAddressSize.Uint32, NULL, NULL, NULL); - } else { - VirPhyAddressSize.Bits.PhysicalAddressBits = 36; - } - - *MtrrValidBitsMask = LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalAddressBits) - 1; - *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL; -} - - -/** - Determines the real attribute of a memory range. - - This function is to arbitrate the real attribute of the memory when - there are 2 MTRRs covers the same memory range. For further details, - please refer the IA32 Software Developer's Manual, Volume 3, - Section "MTRR Precedences". - - @param[in] MtrrType1 The first kind of Memory type - @param[in] MtrrType2 The second kind of memory type - -**/ -MTRR_MEMORY_CACHE_TYPE -MtrrLibPrecedence ( - IN MTRR_MEMORY_CACHE_TYPE MtrrType1, - IN MTRR_MEMORY_CACHE_TYPE MtrrType2 - ) -{ - if (MtrrType1 == MtrrType2) { - return MtrrType1; - } - - ASSERT ( - MtrrLibTypeLeftPrecedeRight (MtrrType1, MtrrType2) || - MtrrLibTypeLeftPrecedeRight (MtrrType2, MtrrType1) - ); - - if (MtrrLibTypeLeftPrecedeRight (MtrrType1, MtrrType2)) { - return MtrrType1; - } else { - return MtrrType2; - } -} - -/** - Worker function will get the memory cache type of the specific address. - - If MtrrSetting is not NULL, gets the memory cache type from input - MTRR settings buffer. - If MtrrSetting is NULL, gets the memory cache type from MTRRs. - - @param[in] MtrrSetting A buffer holding all MTRRs content. - @param[in] Address The specific address - - @return Memory cache type of the specific address - -**/ -MTRR_MEMORY_CACHE_TYPE -MtrrGetMemoryAttributeByAddressWorker ( - IN MTRR_SETTINGS *MtrrSetting, - IN PHYSICAL_ADDRESS Address - ) -{ - MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; - UINT64 FixedMtrr; - UINTN Index; - UINTN SubIndex; - MTRR_MEMORY_CACHE_TYPE MtrrType; - VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; - UINT64 MtrrValidBitsMask; - UINT64 MtrrValidAddressMask; - UINT32 VariableMtrrCount; - MTRR_VARIABLE_SETTINGS VariableSettings; - - // - // Check if MTRR is enabled, if not, return UC as attribute - // - if (MtrrSetting == NULL) { - DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - } else { - DefType.Uint64 = MtrrSetting->MtrrDefType; - } - - if (DefType.Bits.E == 0) { - return CacheUncacheable; - } - - // - // If address is less than 1M, then try to go through the fixed MTRR - // - if (Address < BASE_1MB) { - if (DefType.Bits.FE != 0) { - // - // Go through the fixed MTRR - // - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - if (Address >= mMtrrLibFixedMtrrTable[Index].BaseAddress && - Address < mMtrrLibFixedMtrrTable[Index].BaseAddress + - (mMtrrLibFixedMtrrTable[Index].Length * 8)) { - SubIndex = - ((UINTN) Address - mMtrrLibFixedMtrrTable[Index].BaseAddress) / - mMtrrLibFixedMtrrTable[Index].Length; - if (MtrrSetting == NULL) { - FixedMtrr = AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr); - } else { - FixedMtrr = MtrrSetting->Fixed.Mtrr[Index]; - } - return (MTRR_MEMORY_CACHE_TYPE) (RShiftU64 (FixedMtrr, SubIndex * 8) & 0xFF); - } - } - } - } - - VariableMtrrCount = GetVariableMtrrCountWorker (); - ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); - MtrrGetVariableMtrrWorker (MtrrSetting, VariableMtrrCount, &VariableSettings); - - MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); - MtrrGetMemoryAttributeInVariableMtrrWorker ( - &VariableSettings, - VariableMtrrCount, - MtrrValidBitsMask, - MtrrValidAddressMask, - VariableMtrr - ); - - // - // Go through the variable MTRR - // - MtrrType = CacheInvalid; - for (Index = 0; Index < VariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid) { - if (Address >= VariableMtrr[Index].BaseAddress && - Address < VariableMtrr[Index].BaseAddress + VariableMtrr[Index].Length) { - if (MtrrType == CacheInvalid) { - MtrrType = (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type; - } else { - MtrrType = MtrrLibPrecedence (MtrrType, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type); - } - } - } - } - - // - // If there is no MTRR which covers the Address, use the default MTRR type. - // - if (MtrrType == CacheInvalid) { - MtrrType = (MTRR_MEMORY_CACHE_TYPE) DefType.Bits.Type; - } - - return MtrrType; -} - - -/** - This function will get the memory cache type of the specific address. - - This function is mainly for debug purpose. - - @param[in] Address The specific address - - @return Memory cache type of the specific address - -**/ -MTRR_MEMORY_CACHE_TYPE -EFIAPI -MtrrGetMemoryAttribute ( - IN PHYSICAL_ADDRESS Address - ) -{ - if (!IsMtrrSupported ()) { - return CacheUncacheable; - } - - return MtrrGetMemoryAttributeByAddressWorker (NULL, Address); -} - -/** - Worker function prints all MTRRs for debugging. - - If MtrrSetting is not NULL, print MTRR settings from input MTRR - settings buffer. - If MtrrSetting is NULL, print MTRR settings from MTRRs. - - @param MtrrSetting A buffer holding all MTRRs content. -**/ -VOID -MtrrDebugPrintAllMtrrsWorker ( - IN MTRR_SETTINGS *MtrrSetting - ) -{ - DEBUG_CODE ( - MTRR_SETTINGS LocalMtrrs; - MTRR_SETTINGS *Mtrrs; - UINTN Index; - UINTN Index1; - UINTN VariableMtrrCount; - UINT64 Base; - UINT64 Limit; - UINT64 MtrrBase; - UINT64 MtrrLimit; - UINT64 RangeBase; - UINT64 RangeLimit; - UINT64 NoRangeBase; - UINT64 NoRangeLimit; - UINT32 RegEax; - UINTN MemoryType; - UINTN PreviousMemoryType; - BOOLEAN Found; - - if (!IsMtrrSupported ()) { - return; - } - - DEBUG((DEBUG_CACHE, "MTRR Settings\n")); - DEBUG((DEBUG_CACHE, "=============\n")); - - if (MtrrSetting != NULL) { - Mtrrs = MtrrSetting; - } else { - MtrrGetAllMtrrs (&LocalMtrrs); - Mtrrs = &LocalMtrrs; - } - - DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType)); - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - DEBUG((DEBUG_CACHE, "Fixed MTRR[%02d] : %016lx\n", Index, Mtrrs->Fixed.Mtrr[Index])); - } - - VariableMtrrCount = GetVariableMtrrCount (); - for (Index = 0; Index < VariableMtrrCount; Index++) { - DEBUG((DEBUG_CACHE, "Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n", - Index, - Mtrrs->Variables.Mtrr[Index].Base, - Mtrrs->Variables.Mtrr[Index].Mask - )); - } - DEBUG((DEBUG_CACHE, "\n")); - DEBUG((DEBUG_CACHE, "MTRR Ranges\n")); - DEBUG((DEBUG_CACHE, "====================================\n")); - - Base = 0; - PreviousMemoryType = MTRR_CACHE_INVALID_TYPE; - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - Base = mMtrrLibFixedMtrrTable[Index].BaseAddress; - for (Index1 = 0; Index1 < 8; Index1++) { - MemoryType = (UINTN)(RShiftU64 (Mtrrs->Fixed.Mtrr[Index], Index1 * 8) & 0xff); - if (MemoryType > CacheWriteBack) { - MemoryType = MTRR_CACHE_INVALID_TYPE; - } - if (MemoryType != PreviousMemoryType) { - if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) { - DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); - } - PreviousMemoryType = MemoryType; - DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base)); - } - Base += mMtrrLibFixedMtrrTable[Index].Length; - } - } - DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); - - VariableMtrrCount = GetVariableMtrrCount (); - - Limit = BIT36 - 1; - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - Limit = LShiftU64 (1, RegEax & 0xff) - 1; - } - Base = BASE_1MB; - PreviousMemoryType = MTRR_CACHE_INVALID_TYPE; - do { - MemoryType = MtrrGetMemoryAttributeByAddressWorker (Mtrrs, Base); - if (MemoryType > CacheWriteBack) { - MemoryType = MTRR_CACHE_INVALID_TYPE; - } - - if (MemoryType != PreviousMemoryType) { - if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) { - DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1)); - } - PreviousMemoryType = MemoryType; - DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base)); - } - - RangeBase = BASE_1MB; - NoRangeBase = BASE_1MB; - RangeLimit = Limit; - NoRangeLimit = Limit; - - for (Index = 0, Found = FALSE; Index < VariableMtrrCount; Index++) { - if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) { - // - // If mask is not valid, then do not display range - // - continue; - } - MtrrBase = (Mtrrs->Variables.Mtrr[Index].Base & (~(SIZE_4KB - 1))); - MtrrLimit = MtrrBase + ((~(Mtrrs->Variables.Mtrr[Index].Mask & (~(SIZE_4KB - 1)))) & Limit); - - if (Base >= MtrrBase && Base < MtrrLimit) { - Found = TRUE; - } - - if (Base >= MtrrBase && MtrrBase > RangeBase) { - RangeBase = MtrrBase; - } - if (Base > MtrrLimit && MtrrLimit > RangeBase) { - RangeBase = MtrrLimit + 1; - } - if (Base < MtrrBase && MtrrBase < RangeLimit) { - RangeLimit = MtrrBase - 1; - } - if (Base < MtrrLimit && MtrrLimit <= RangeLimit) { - RangeLimit = MtrrLimit; - } - - if (Base > MtrrLimit && NoRangeBase < MtrrLimit) { - NoRangeBase = MtrrLimit + 1; - } - if (Base < MtrrBase && NoRangeLimit > MtrrBase) { - NoRangeLimit = MtrrBase - 1; - } - } - - if (Found) { - Base = RangeLimit + 1; - } else { - Base = NoRangeLimit + 1; - } - } while (Base < Limit); - DEBUG((DEBUG_CACHE, "%016lx\n\n", Base - 1)); - ); -} - - -/** - This function prints all MTRRs for debugging. -**/ -VOID -EFIAPI -MtrrDebugPrintAllMtrrs ( - VOID - ) -{ - MtrrDebugPrintAllMtrrsWorker (NULL); -} - -/** - Update the Ranges array to change the specified range identified by - BaseAddress and Length to Type. - - @param Ranges Array holding memory type settings for all memory regions. - @param Capacity The maximum count of memory ranges the array can hold. - @param Count Return the new memory range count in the array. - @param BaseAddress The base address of the memory range to change type. - @param Length The length of the memory range to change type. - @param Type The new type of the specified memory range. - - @retval RETURN_SUCCESS The type of the specified memory range is - changed successfully. - @retval RETURN_OUT_OF_RESOURCES The new type set causes the count of memory - range exceeds capacity. -**/ -RETURN_STATUS -MtrrLibSetMemoryType ( - IN MEMORY_RANGE *Ranges, - IN UINT32 Capacity, - IN OUT UINT32 *Count, - IN UINT64 BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type - ) -{ - UINT32 Index; - UINT64 Limit; - UINT64 LengthLeft; - UINT64 LengthRight; - UINT32 StartIndex; - UINT32 EndIndex; - UINT32 DeltaCount; - - LengthRight = 0; - LengthLeft = 0; - Limit = BaseAddress + Length; - StartIndex = *Count; - EndIndex = *Count; - for (Index = 0; Index < *Count; Index++) { - if ((StartIndex == *Count) && - (Ranges[Index].BaseAddress <= BaseAddress) && - (BaseAddress < Ranges[Index].BaseAddress + Ranges[Index].Length)) { - StartIndex = Index; - LengthLeft = BaseAddress - Ranges[Index].BaseAddress; - } - - if ((EndIndex == *Count) && - (Ranges[Index].BaseAddress < Limit) && - (Limit <= Ranges[Index].BaseAddress + Ranges[Index].Length)) { - EndIndex = Index; - LengthRight = Ranges[Index].BaseAddress + Ranges[Index].Length - Limit; - break; - } - } - - ASSERT (StartIndex != *Count && EndIndex != *Count); - if (StartIndex == EndIndex && Ranges[StartIndex].Type == Type) { - return RETURN_SUCCESS; - } - - // - // The type change may cause merging with previous range or next range. - // Update the StartIndex, EndIndex, BaseAddress, Length so that following - // logic doesn't need to consider merging. - // - if (StartIndex != 0) { - if (LengthLeft == 0 && Ranges[StartIndex - 1].Type == Type) { - StartIndex--; - Length += Ranges[StartIndex].Length; - BaseAddress -= Ranges[StartIndex].Length; - } - } - if (EndIndex != (*Count) - 1) { - if (LengthRight == 0 && Ranges[EndIndex + 1].Type == Type) { - EndIndex++; - Length += Ranges[EndIndex].Length; - } - } - - // - // |- 0 -|- 1 -|- 2 -|- 3 -| StartIndex EndIndex DeltaCount Count (Count = 4) - // |++++++++++++++++++| 0 3 1=3-0-2 3 - // |+++++++| 0 1 -1=1-0-2 5 - // |+| 0 0 -2=0-0-2 6 - // |+++| 0 0 -1=0-0-2+1 5 - // - // - DeltaCount = EndIndex - StartIndex - 2; - if (LengthLeft == 0) { - DeltaCount++; - } - if (LengthRight == 0) { - DeltaCount++; - } - if (*Count - DeltaCount > Capacity) { - return RETURN_OUT_OF_RESOURCES; - } - - // - // Reserve (-DeltaCount) space - // - CopyMem (&Ranges[EndIndex + 1 - DeltaCount], &Ranges[EndIndex + 1], (*Count - EndIndex - 1) * sizeof (Ranges[0])); - *Count -= DeltaCount; - - if (LengthLeft != 0) { - Ranges[StartIndex].Length = LengthLeft; - StartIndex++; - } - if (LengthRight != 0) { - Ranges[EndIndex - DeltaCount].BaseAddress = BaseAddress + Length; - Ranges[EndIndex - DeltaCount].Length = LengthRight; - Ranges[EndIndex - DeltaCount].Type = Ranges[EndIndex].Type; - } - Ranges[StartIndex].BaseAddress = BaseAddress; - Ranges[StartIndex].Length = Length; - Ranges[StartIndex].Type = Type; - return RETURN_SUCCESS; -} - -/** - Allocate one or more variable MTRR to cover the range identified by - BaseAddress and Length. - - @param Ranges Memory range array holding the memory type - settings for all memory address. - @param RangeCount Count of memory ranges. - @param VariableMtrr Variable MTRR array. - @param VariableMtrrCapacity Capacity of variable MTRR array. - @param VariableMtrrCount Count of variable MTRR. - @param BaseAddress Base address of the memory range. - @param Length Length of the memory range. - @param Type MTRR type of the memory range. - @param Alignment0 Alignment of 0. - - @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. - @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. -**/ -RETURN_STATUS -MtrrLibSetMemoryAttributeInVariableMtrr ( - IN CONST MEMORY_RANGE *Ranges, - IN UINT32 RangeCount, - IN OUT VARIABLE_MTRR *VariableMtrr, - IN UINT32 VariableMtrrCapacity, - IN OUT UINT32 *VariableMtrrCount, - IN UINT64 BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type, - IN UINT64 Alignment0 - ); - -/** - Allocate one or more variable MTRR to cover the range identified by - BaseAddress and Length. - - The routine recursively calls MtrrLibSetMemoryAttributeInVariableMtrr() - to allocate variable MTRRs when the range contains several sub-ranges - with different attributes. - - @param Ranges Memory range array holding the memory type - settings for all memory address. - @param RangeCount Count of memory ranges. - @param VariableMtrr Variable MTRR array. - @param VariableMtrrCapacity Capacity of variable MTRR array. - @param VariableMtrrCount Count of variable MTRR. - @param BaseAddress Base address of the memory range. - @param Length Length of the memory range. - @param Type MTRR type of the range. - If it's CacheInvalid, the memory range may - contains several sub-ranges with different - attributes. - @param Alignment0 Alignment of 0. - - @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. - @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. -**/ -RETURN_STATUS -MtrrLibAddVariableMtrr ( - IN CONST MEMORY_RANGE *Ranges, - IN UINT32 RangeCount, - IN OUT VARIABLE_MTRR *VariableMtrr, - IN UINT32 VariableMtrrCapacity, - IN OUT UINT32 *VariableMtrrCount, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type, - IN UINT64 Alignment0 -) -{ - RETURN_STATUS Status; - UINT32 Index; - UINT64 SubLength; - - MTRR_LIB_ASSERT_ALIGNED (BaseAddress, Length); - if (Type == CacheInvalid) { - for (Index = 0; Index < RangeCount; Index++) { - if (Ranges[Index].BaseAddress <= BaseAddress && BaseAddress < Ranges[Index].BaseAddress + Ranges[Index].Length) { - - // - // Because the Length may not be aligned to BaseAddress, below code calls - // MtrrLibSetMemoryAttributeInVariableMtrr() instead of itself. - // MtrrLibSetMemoryAttributeInVariableMtrr() splits the range to several - // aligned ranges. - // - if (Ranges[Index].BaseAddress + Ranges[Index].Length >= BaseAddress + Length) { - return MtrrLibSetMemoryAttributeInVariableMtrr ( - Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress, Length, Ranges[Index].Type, Alignment0 - ); - } else { - SubLength = Ranges[Index].BaseAddress + Ranges[Index].Length - BaseAddress; - Status = MtrrLibSetMemoryAttributeInVariableMtrr ( - Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress, SubLength, Ranges[Index].Type, Alignment0 - ); - if (RETURN_ERROR (Status)) { - return Status; - } - BaseAddress += SubLength; - Length -= SubLength; - } - } - } - - // - // Because memory ranges cover all the memory addresses, it's impossible to be here. - // - ASSERT (FALSE); - return RETURN_DEVICE_ERROR; - } else { - for (Index = 0; Index < *VariableMtrrCount; Index++) { - if (VariableMtrr[Index].BaseAddress == BaseAddress && VariableMtrr[Index].Length == Length) { - ASSERT (VariableMtrr[Index].Type == Type); - break; - } - } - if (Index == *VariableMtrrCount) { - if (*VariableMtrrCount == VariableMtrrCapacity) { - return RETURN_OUT_OF_RESOURCES; - } - VariableMtrr[Index].BaseAddress = BaseAddress; - VariableMtrr[Index].Length = Length; - VariableMtrr[Index].Type = Type; - VariableMtrr[Index].Valid = TRUE; - VariableMtrr[Index].Used = TRUE; - (*VariableMtrrCount)++; - } - return RETURN_SUCCESS; - } -} - -/** - Allocate one or more variable MTRR to cover the range identified by - BaseAddress and Length. - - @param Ranges Memory range array holding the memory type - settings for all memory address. - @param RangeCount Count of memory ranges. - @param VariableMtrr Variable MTRR array. - @param VariableMtrrCapacity Capacity of variable MTRR array. - @param VariableMtrrCount Count of variable MTRR. - @param BaseAddress Base address of the memory range. - @param Length Length of the memory range. - @param Type MTRR type of the memory range. - @param Alignment0 Alignment of 0. - - @retval RETURN_SUCCESS Variable MTRRs are allocated successfully. - @retval RETURN_OUT_OF_RESOURCES Count of variable MTRRs exceeds capacity. -**/ -RETURN_STATUS -MtrrLibSetMemoryAttributeInVariableMtrr ( - IN CONST MEMORY_RANGE *Ranges, - IN UINT32 RangeCount, - IN OUT VARIABLE_MTRR *VariableMtrr, - IN UINT32 VariableMtrrCapacity, - IN OUT UINT32 *VariableMtrrCount, - IN UINT64 BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type, - IN UINT64 Alignment0 -) -{ - UINT64 Alignment; - UINT32 MtrrNumber; - UINT32 SubtractiveLeft; - UINT32 SubtractiveRight; - BOOLEAN UseLeastAlignment; - - Alignment = 0; - - MtrrNumber = MtrrLibGetMtrrNumber (Ranges, RangeCount, VariableMtrr, *VariableMtrrCount, - BaseAddress, Length, Type, Alignment0, &SubtractiveLeft, &SubtractiveRight); - - if (MtrrNumber + *VariableMtrrCount > VariableMtrrCapacity) { - return RETURN_OUT_OF_RESOURCES; - } - - while (SubtractiveLeft-- != 0) { - Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); - ASSERT (Alignment <= Length); - - MtrrLibAddVariableMtrr (Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress - Alignment, Alignment, CacheInvalid, Alignment0); - BaseAddress -= Alignment; - Length += Alignment; - } - - while (Length != 0) { - Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); - if (Alignment > Length) { - break; - } - MtrrLibAddVariableMtrr (NULL, 0, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress, Alignment, Type, Alignment0); - BaseAddress += Alignment; - Length -= Alignment; - } - - while (SubtractiveRight-- != 0) { - Alignment = MtrrLibLeastAlignment (BaseAddress + Length, Alignment0); - MtrrLibAddVariableMtrr (Ranges, RangeCount, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress + Length, Alignment, CacheInvalid, Alignment0); - Length += Alignment; - } - - UseLeastAlignment = TRUE; - while (Length != 0) { - if (UseLeastAlignment) { - Alignment = MtrrLibLeastAlignment (BaseAddress, Alignment0); - if (Alignment > Length) { - UseLeastAlignment = FALSE; - } - } - - if (!UseLeastAlignment) { - Alignment = GetPowerOfTwo64 (Length); - } - - MtrrLibAddVariableMtrr (NULL, 0, VariableMtrr, VariableMtrrCapacity, VariableMtrrCount, - BaseAddress, Alignment, Type, Alignment0); - BaseAddress += Alignment; - Length -= Alignment; - } - return RETURN_SUCCESS; -} - -/** - Return an array of memory ranges holding memory type settings for all memory - address. - - @param DefaultType The default memory type. - @param TotalLength The total length of the memory. - @param VariableMtrr The variable MTRR array. - @param VariableMtrrCount The count of variable MTRRs. - @param Ranges Return the memory range array holding memory type - settings for all memory address. - @param RangeCapacity The capacity of memory range array. - @param RangeCount Return the count of memory range. - - @retval RETURN_SUCCESS The memory range array is returned successfully. - @retval RETURN_OUT_OF_RESOURCES The count of memory ranges exceeds capacity. -**/ -RETURN_STATUS -MtrrLibGetMemoryTypes ( - IN MTRR_MEMORY_CACHE_TYPE DefaultType, - IN UINT64 TotalLength, - IN CONST VARIABLE_MTRR *VariableMtrr, - IN UINT32 VariableMtrrCount, - OUT MEMORY_RANGE *Ranges, - IN UINT32 RangeCapacity, - OUT UINT32 *RangeCount -) -{ - RETURN_STATUS Status; - UINTN Index; - - // - // WT > WB - // UC > * - // UC > * (except WB, UC) > WB - // - - // - // 0. Set whole range as DefaultType - // - *RangeCount = 1; - Ranges[0].BaseAddress = 0; - Ranges[0].Length = TotalLength; - Ranges[0].Type = DefaultType; - - // - // 1. Set WB - // - for (Index = 0; Index < VariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type == CacheWriteBack) { - Status = MtrrLibSetMemoryType ( - Ranges, RangeCapacity, RangeCount, - VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type - ); - if (RETURN_ERROR (Status)) { - return Status; - } - } - } - - // - // 2. Set other types than WB or UC - // - for (Index = 0; Index < VariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type != CacheWriteBack && VariableMtrr[Index].Type != CacheUncacheable) { - Status = MtrrLibSetMemoryType ( - Ranges, RangeCapacity, RangeCount, - VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type - ); - if (RETURN_ERROR (Status)) { - return Status; - } - } - } - - // - // 3. Set UC - // - for (Index = 0; Index < VariableMtrrCount; Index++) { - if (VariableMtrr[Index].Valid && VariableMtrr[Index].Type == CacheUncacheable) { - Status = MtrrLibSetMemoryType ( - Ranges, RangeCapacity, RangeCount, - VariableMtrr[Index].BaseAddress, VariableMtrr[Index].Length, (MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type - ); - if (RETURN_ERROR (Status)) { - return Status; - } - } - } - return RETURN_SUCCESS; -} - -/** - Worker function attempts to set the attributes for a memory range. - - If MtrrSetting is not NULL, set the attributes into the input MTRR - settings buffer. - If MtrrSetting is NULL, set the attributes into MTRRs registers. - - @param[in, out] MtrrSetting A buffer holding all MTRRs content. - @param[in] BaseAddress The physical address that is the start - address of a memory range. - @param[in] Length The size in bytes of the memory range. - @param[in] Type The MTRR type to set for the memory range. - - @retval RETURN_SUCCESS The attributes were set for the memory - range. - @retval RETURN_INVALID_PARAMETER Length is zero. - @retval RETURN_UNSUPPORTED The processor does not support one or - more bytes of the memory resource range - specified by BaseAddress and Length. - @retval RETURN_UNSUPPORTED The MTRR type is not support for the - memory resource range specified - by BaseAddress and Length. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to - modify the attributes of the memory - resource range. - -**/ -RETURN_STATUS -MtrrSetMemoryAttributeWorker ( - IN OUT MTRR_SETTINGS *MtrrSetting, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Type - ) -{ - RETURN_STATUS Status; - UINT32 Index; - UINT32 WorkingIndex; - // - // N variable MTRRs can maximumly separate (2N + 1) Ranges, plus 1 range for [0, 1M). - // - MEMORY_RANGE Ranges[MTRR_NUMBER_OF_VARIABLE_MTRR * 2 + 2]; - UINT32 RangeCount; - UINT64 MtrrValidBitsMask; - UINT64 MtrrValidAddressMask; - UINT64 Alignment0; - MTRR_CONTEXT MtrrContext; - BOOLEAN MtrrContextValid; - - MTRR_MEMORY_CACHE_TYPE DefaultType; - - UINT32 MsrIndex; - UINT64 ClearMask; - UINT64 OrMask; - UINT64 NewValue; - BOOLEAN FixedSettingsValid[MTRR_NUMBER_OF_FIXED_MTRR]; - BOOLEAN FixedSettingsModified[MTRR_NUMBER_OF_FIXED_MTRR]; - MTRR_FIXED_SETTINGS WorkingFixedSettings; - - UINT32 FirmwareVariableMtrrCount; - MTRR_VARIABLE_SETTINGS *VariableSettings; - MTRR_VARIABLE_SETTINGS OriginalVariableSettings; - UINT32 OriginalVariableMtrrCount; - VARIABLE_MTRR OriginalVariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; - UINT32 WorkingVariableMtrrCount; - VARIABLE_MTRR WorkingVariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR]; - BOOLEAN VariableSettingModified[MTRR_NUMBER_OF_VARIABLE_MTRR]; - UINTN FreeVariableMtrrCount; - - if (Length == 0) { - return RETURN_INVALID_PARAMETER; - } - - MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); - if (((BaseAddress & ~MtrrValidAddressMask) != 0) || (Length & ~MtrrValidAddressMask) != 0) { - return RETURN_UNSUPPORTED; - } - OriginalVariableMtrrCount = 0; - VariableSettings = NULL; - - ZeroMem (&WorkingFixedSettings, sizeof (WorkingFixedSettings)); - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - FixedSettingsValid[Index] = FALSE; - FixedSettingsModified[Index] = FALSE; - } - - // - // Check if Fixed MTRR - // - if (BaseAddress < BASE_1MB) { - MsrIndex = (UINT32)-1; - while ((BaseAddress < BASE_1MB) && (Length != 0)) { - Status = MtrrLibProgramFixedMtrr (Type, &BaseAddress, &Length, &MsrIndex, &ClearMask, &OrMask); - if (RETURN_ERROR (Status)) { - return Status; - } - if (MtrrSetting != NULL) { - MtrrSetting->Fixed.Mtrr[MsrIndex] = (MtrrSetting->Fixed.Mtrr[MsrIndex] & ~ClearMask) | OrMask; - ((MSR_IA32_MTRR_DEF_TYPE_REGISTER *) &MtrrSetting->MtrrDefType)->Bits.FE = 1; - } else { - if (!FixedSettingsValid[MsrIndex]) { - WorkingFixedSettings.Mtrr[MsrIndex] = AsmReadMsr64 (mMtrrLibFixedMtrrTable[MsrIndex].Msr); - FixedSettingsValid[MsrIndex] = TRUE; - } - NewValue = (WorkingFixedSettings.Mtrr[MsrIndex] & ~ClearMask) | OrMask; - if (WorkingFixedSettings.Mtrr[MsrIndex] != NewValue) { - WorkingFixedSettings.Mtrr[MsrIndex] = NewValue; - FixedSettingsModified[MsrIndex] = TRUE; - } - } - } - - if (Length == 0) { - // - // A Length of 0 can only make sense for fixed MTTR ranges. - // Since we just handled the fixed MTRRs, we can skip the - // variable MTRR section. - // - goto Done; - } - } - - // - // Read the default MTRR type - // - DefaultType = MtrrGetDefaultMemoryTypeWorker (MtrrSetting); - - // - // Read all variable MTRRs and convert to Ranges. - // - OriginalVariableMtrrCount = GetVariableMtrrCountWorker (); - if (MtrrSetting == NULL) { - ZeroMem (&OriginalVariableSettings, sizeof (OriginalVariableSettings)); - MtrrGetVariableMtrrWorker (NULL, OriginalVariableMtrrCount, &OriginalVariableSettings); - VariableSettings = &OriginalVariableSettings; - } else { - VariableSettings = &MtrrSetting->Variables; - } - MtrrGetMemoryAttributeInVariableMtrrWorker (VariableSettings, OriginalVariableMtrrCount, MtrrValidBitsMask, MtrrValidAddressMask, OriginalVariableMtrr); - - Status = MtrrLibGetMemoryTypes ( - DefaultType, MtrrValidBitsMask + 1, OriginalVariableMtrr, OriginalVariableMtrrCount, - Ranges, 2 * OriginalVariableMtrrCount + 1, &RangeCount - ); - ASSERT (Status == RETURN_SUCCESS); - - FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCountWorker (); - ASSERT (RangeCount <= 2 * FirmwareVariableMtrrCount + 1); - - // - // Force [0, 1M) to UC, so that it doesn't impact left subtraction algorithm. - // - Status = MtrrLibSetMemoryType (Ranges, 2 * FirmwareVariableMtrrCount + 2, &RangeCount, 0, SIZE_1MB, CacheUncacheable); - ASSERT (Status == RETURN_SUCCESS); - // - // Apply Type to [BaseAddress, BaseAddress + Length) - // - Status = MtrrLibSetMemoryType (Ranges, 2 * FirmwareVariableMtrrCount + 2, &RangeCount, BaseAddress, Length, Type); - if (RETURN_ERROR (Status)) { - return Status; - } - - Alignment0 = LShiftU64 (1, (UINTN) HighBitSet64 (MtrrValidBitsMask)); - WorkingVariableMtrrCount = 0; - ZeroMem (&WorkingVariableMtrr, sizeof (WorkingVariableMtrr)); - for (Index = 0; Index < RangeCount; Index++) { - if (Ranges[Index].Type != DefaultType) { - // - // Maximum allowed MTRR count is (FirmwareVariableMtrrCount + 1) - // Because potentially the range [0, 1MB) is not merged, but can be ignored because fixed MTRR covers that - // - Status = MtrrLibSetMemoryAttributeInVariableMtrr ( - Ranges, RangeCount, - WorkingVariableMtrr, FirmwareVariableMtrrCount + 1, &WorkingVariableMtrrCount, - Ranges[Index].BaseAddress, Ranges[Index].Length, - Ranges[Index].Type, Alignment0 - ); - if (RETURN_ERROR (Status)) { - return Status; - } - } - } - - // - // Remove the [0, 1MB) MTRR if it still exists (not merged with other range) - // - if (WorkingVariableMtrr[0].BaseAddress == 0 && WorkingVariableMtrr[0].Length == SIZE_1MB) { - ASSERT (WorkingVariableMtrr[0].Type == CacheUncacheable); - WorkingVariableMtrrCount--; - CopyMem (&WorkingVariableMtrr[0], &WorkingVariableMtrr[1], WorkingVariableMtrrCount * sizeof (VARIABLE_MTRR)); - } - - if (WorkingVariableMtrrCount > FirmwareVariableMtrrCount) { - return RETURN_OUT_OF_RESOURCES; - } - - for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { - VariableSettingModified[Index] = FALSE; - - if (!OriginalVariableMtrr[Index].Valid) { - continue; - } - for (WorkingIndex = 0; WorkingIndex < WorkingVariableMtrrCount; WorkingIndex++) { - if (OriginalVariableMtrr[Index].BaseAddress == WorkingVariableMtrr[WorkingIndex].BaseAddress && - OriginalVariableMtrr[Index].Length == WorkingVariableMtrr[WorkingIndex].Length && - OriginalVariableMtrr[Index].Type == WorkingVariableMtrr[WorkingIndex].Type) { - break; - } - } - - if (WorkingIndex == WorkingVariableMtrrCount) { - // - // Remove the one from OriginalVariableMtrr which is not in WorkingVariableMtrr - // - OriginalVariableMtrr[Index].Valid = FALSE; - VariableSettingModified[Index] = TRUE; - } else { - // - // Remove the one from WorkingVariableMtrr which is also in OriginalVariableMtrr - // - WorkingVariableMtrr[WorkingIndex].Valid = FALSE; - } - // - // The above two operations cause that valid MTRR only exists in either OriginalVariableMtrr or WorkingVariableMtrr. - // - } - - // - // Merge remaining MTRRs from WorkingVariableMtrr to OriginalVariableMtrr - // - for (FreeVariableMtrrCount = 0, WorkingIndex = 0, Index = 0; Index < OriginalVariableMtrrCount; Index++) { - if (!OriginalVariableMtrr[Index].Valid) { - for (; WorkingIndex < WorkingVariableMtrrCount; WorkingIndex++) { - if (WorkingVariableMtrr[WorkingIndex].Valid) { - break; - } - } - if (WorkingIndex == WorkingVariableMtrrCount) { - FreeVariableMtrrCount++; - } else { - CopyMem (&OriginalVariableMtrr[Index], &WorkingVariableMtrr[WorkingIndex], sizeof (VARIABLE_MTRR)); - VariableSettingModified[Index] = TRUE; - WorkingIndex++; - } - } - } - ASSERT (OriginalVariableMtrrCount - FreeVariableMtrrCount <= FirmwareVariableMtrrCount); - - // - // Move MTRRs after the FirmwraeVariableMtrrCount position to beginning - // - WorkingIndex = FirmwareVariableMtrrCount; - for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) { - if (!OriginalVariableMtrr[Index].Valid) { - // - // Found an empty MTRR in WorkingIndex position - // - for (; WorkingIndex < OriginalVariableMtrrCount; WorkingIndex++) { - if (OriginalVariableMtrr[WorkingIndex].Valid) { - break; - } - } - - if (WorkingIndex != OriginalVariableMtrrCount) { - CopyMem (&OriginalVariableMtrr[Index], &OriginalVariableMtrr[WorkingIndex], sizeof (VARIABLE_MTRR)); - VariableSettingModified[Index] = TRUE; - VariableSettingModified[WorkingIndex] = TRUE; - OriginalVariableMtrr[WorkingIndex].Valid = FALSE; - } - } - } - - // - // Convert OriginalVariableMtrr to VariableSettings - // NOTE: MTRR from FirmwareVariableMtrr to OriginalVariableMtrr need to update as well. - // - for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { - if (VariableSettingModified[Index]) { - if (OriginalVariableMtrr[Index].Valid) { - VariableSettings->Mtrr[Index].Base = (OriginalVariableMtrr[Index].BaseAddress & MtrrValidAddressMask) | (UINT8) OriginalVariableMtrr[Index].Type; - VariableSettings->Mtrr[Index].Mask = ((~(OriginalVariableMtrr[Index].Length - 1)) & MtrrValidAddressMask) | BIT11; - } else { - VariableSettings->Mtrr[Index].Base = 0; - VariableSettings->Mtrr[Index].Mask = 0; - } - } - } - -Done: - if (MtrrSetting != NULL) { - ((MSR_IA32_MTRR_DEF_TYPE_REGISTER *) &MtrrSetting->MtrrDefType)->Bits.E = 1; - return RETURN_SUCCESS; - } - - MtrrContextValid = FALSE; - // - // Write fixed MTRRs that have been modified - // - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - if (FixedSettingsModified[Index]) { - if (!MtrrContextValid) { - MtrrLibPreMtrrChange (&MtrrContext); - MtrrContextValid = TRUE; - } - AsmWriteMsr64 ( - mMtrrLibFixedMtrrTable[Index].Msr, - WorkingFixedSettings.Mtrr[Index] - ); - } - } - - // - // Write variable MTRRs - // When only fixed MTRRs were changed, below loop doesn't run - // because OriginalVariableMtrrCount equals to 0. - // - for (Index = 0; Index < OriginalVariableMtrrCount; Index++) { - if (VariableSettingModified[Index]) { - if (!MtrrContextValid) { - MtrrLibPreMtrrChange (&MtrrContext); - MtrrContextValid = TRUE; - } - AsmWriteMsr64 ( - MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), - VariableSettings->Mtrr[Index].Base - ); - AsmWriteMsr64 ( - MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), - VariableSettings->Mtrr[Index].Mask - ); - } - } - if (MtrrContextValid) { - MtrrLibPostMtrrChange (&MtrrContext); - } - - return RETURN_SUCCESS; -} - -/** - This function attempts to set the attributes for a memory range. - - @param[in] BaseAddress The physical address that is the start - address of a memory range. - @param[in] Length The size in bytes of the memory range. - @param[in] Attributes The bit mask of attributes to set for the - memory range. - - @retval RETURN_SUCCESS The attributes were set for the memory - range. - @retval RETURN_INVALID_PARAMETER Length is zero. - @retval RETURN_UNSUPPORTED The processor does not support one or - more bytes of the memory resource range - specified by BaseAddress and Length. - @retval RETURN_UNSUPPORTED The bit mask of attributes is not support - for the memory resource range specified - by BaseAddress and Length. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource - range specified by BaseAddress and Length - cannot be modified. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to - modify the attributes of the memory - resource range. - -**/ -RETURN_STATUS -EFIAPI -MtrrSetMemoryAttribute ( - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Attribute - ) -{ - RETURN_STATUS Status; - - if (!IsMtrrSupported ()) { - return RETURN_UNSUPPORTED; - } - - Status = MtrrSetMemoryAttributeWorker (NULL, BaseAddress, Length, Attribute); - DEBUG ((DEBUG_CACHE, "MtrrSetMemoryAttribute() %a: [%016lx, %016lx) - %r\n", - mMtrrMemoryCacheTypeShortName[Attribute], BaseAddress, BaseAddress + Length, Status)); - - if (!RETURN_ERROR (Status)) { - MtrrDebugPrintAllMtrrsWorker (NULL); - } - return Status; -} - -/** - This function attempts to set the attributes into MTRR setting buffer for a memory range. - - @param[in, out] MtrrSetting MTRR setting buffer to be set. - @param[in] BaseAddress The physical address that is the start address - of a memory range. - @param[in] Length The size in bytes of the memory range. - @param[in] Attribute The bit mask of attributes to set for the - memory range. - - @retval RETURN_SUCCESS The attributes were set for the memory range. - @retval RETURN_INVALID_PARAMETER Length is zero. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the - memory resource range specified by BaseAddress and Length. - @retval RETURN_UNSUPPORTED The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - -**/ -RETURN_STATUS -EFIAPI -MtrrSetMemoryAttributeInMtrrSettings ( - IN OUT MTRR_SETTINGS *MtrrSetting, - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN MTRR_MEMORY_CACHE_TYPE Attribute - ) -{ - RETURN_STATUS Status; - Status = MtrrSetMemoryAttributeWorker (MtrrSetting, BaseAddress, Length, Attribute); - DEBUG((DEBUG_CACHE, "MtrrSetMemoryAttributeMtrrSettings(%p) %a: [%016lx, %016lx) - %r\n", - MtrrSetting, mMtrrMemoryCacheTypeShortName[Attribute], BaseAddress, BaseAddress + Length, Status)); - - if (!RETURN_ERROR (Status)) { - MtrrDebugPrintAllMtrrsWorker (MtrrSetting); - } - - return Status; -} - -/** - Worker function setting variable MTRRs - - @param[in] VariableSettings A buffer to hold variable MTRRs content. - -**/ -VOID -MtrrSetVariableMtrrWorker ( - IN MTRR_VARIABLE_SETTINGS *VariableSettings - ) -{ - UINT32 Index; - UINT32 VariableMtrrCount; - - VariableMtrrCount = GetVariableMtrrCountWorker (); - ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR); - - for (Index = 0; Index < VariableMtrrCount; Index++) { - AsmWriteMsr64 ( - MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), - VariableSettings->Mtrr[Index].Base - ); - AsmWriteMsr64 ( - MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), - VariableSettings->Mtrr[Index].Mask - ); - } -} - - -/** - This function sets variable MTRRs - - @param[in] VariableSettings A buffer to hold variable MTRRs content. - - @return The pointer of VariableSettings - -**/ -MTRR_VARIABLE_SETTINGS* -EFIAPI -MtrrSetVariableMtrr ( - IN MTRR_VARIABLE_SETTINGS *VariableSettings - ) -{ - MTRR_CONTEXT MtrrContext; - - if (!IsMtrrSupported ()) { - return VariableSettings; - } - - MtrrLibPreMtrrChange (&MtrrContext); - MtrrSetVariableMtrrWorker (VariableSettings); - MtrrLibPostMtrrChange (&MtrrContext); - MtrrDebugPrintAllMtrrs (); - - return VariableSettings; -} - -/** - Worker function setting fixed MTRRs - - @param[in] FixedSettings A buffer to hold fixed MTRRs content. - -**/ -VOID -MtrrSetFixedMtrrWorker ( - IN MTRR_FIXED_SETTINGS *FixedSettings - ) -{ - UINT32 Index; - - for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) { - AsmWriteMsr64 ( - mMtrrLibFixedMtrrTable[Index].Msr, - FixedSettings->Mtrr[Index] - ); - } -} - - -/** - This function sets fixed MTRRs - - @param[in] FixedSettings A buffer to hold fixed MTRRs content. - - @retval The pointer of FixedSettings - -**/ -MTRR_FIXED_SETTINGS* -EFIAPI -MtrrSetFixedMtrr ( - IN MTRR_FIXED_SETTINGS *FixedSettings - ) -{ - MTRR_CONTEXT MtrrContext; - - if (!IsMtrrSupported ()) { - return FixedSettings; - } - - MtrrLibPreMtrrChange (&MtrrContext); - MtrrSetFixedMtrrWorker (FixedSettings); - MtrrLibPostMtrrChange (&MtrrContext); - MtrrDebugPrintAllMtrrs (); - - return FixedSettings; -} - - -/** - This function gets the content in all MTRRs (variable and fixed) - - @param[out] MtrrSetting A buffer to hold all MTRRs content. - - @retval the pointer of MtrrSetting - -**/ -MTRR_SETTINGS * -EFIAPI -MtrrGetAllMtrrs ( - OUT MTRR_SETTINGS *MtrrSetting - ) -{ - if (!IsMtrrSupported ()) { - return MtrrSetting; - } - - // - // Get fixed MTRRs - // - MtrrGetFixedMtrrWorker (&MtrrSetting->Fixed); - - // - // Get variable MTRRs - // - MtrrGetVariableMtrrWorker ( - NULL, - GetVariableMtrrCountWorker (), - &MtrrSetting->Variables - ); - - // - // Get MTRR_DEF_TYPE value - // - MtrrSetting->MtrrDefType = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); - - return MtrrSetting; -} - - -/** - This function sets all MTRRs (variable and fixed) - - @param[in] MtrrSetting A buffer holding all MTRRs content. - - @retval The pointer of MtrrSetting - -**/ -MTRR_SETTINGS * -EFIAPI -MtrrSetAllMtrrs ( - IN MTRR_SETTINGS *MtrrSetting - ) -{ - MTRR_CONTEXT MtrrContext; - - if (!IsMtrrSupported ()) { - return MtrrSetting; - } - - MtrrLibPreMtrrChange (&MtrrContext); - - // - // Set fixed MTRRs - // - MtrrSetFixedMtrrWorker (&MtrrSetting->Fixed); - - // - // Set variable MTRRs - // - MtrrSetVariableMtrrWorker (&MtrrSetting->Variables); - - // - // Set MTRR_DEF_TYPE value - // - AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, MtrrSetting->MtrrDefType); - - MtrrLibPostMtrrChangeEnableCache (&MtrrContext); - - return MtrrSetting; -} - - -/** - Checks if MTRR is supported. - - @retval TRUE MTRR is supported. - @retval FALSE MTRR is not supported. - -**/ -BOOLEAN -EFIAPI -IsMtrrSupported ( - VOID - ) -{ - CPUID_VERSION_INFO_EDX Edx; - MSR_IA32_MTRRCAP_REGISTER MtrrCap; - - // - // Check CPUID(1).EDX[12] for MTRR capability - // - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32); - if (Edx.Bits.MTRR == 0) { - return FALSE; - } - - // - // Check number of variable MTRRs and fixed MTRRs existence. - // If number of variable MTRRs is zero, or fixed MTRRs do not - // exist, return false. - // - MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP); - if ((MtrrCap.Bits.VCNT == 0) || (MtrrCap.Bits.FIX == 0)) { - return FALSE; - } - return TRUE; -} - diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf deleted file mode 100644 index 01a4d84da0..0000000000 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# MTRR library provides APIs for MTRR operation. -# -# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = MtrrLib - MODULE_UNI_FILE = MtrrLib.uni - FILE_GUID = 6826b408-f4f3-47ee-917f-af7047f9d937 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = MtrrLib - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - MtrrLib.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseMemoryLib - BaseLib - CpuLib - DebugLib - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs ## SOMETIMES_CONSUMES - diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni b/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni deleted file mode 100644 index 34753a089a..0000000000 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// MTRR library provides APIs for MTRR operation. -// -// MTRR library provides APIs for MTRR operation. -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "MTRR library provides APIs for MTRR operation" - -#string STR_MODULE_DESCRIPTION #language en-US "MTRR library provides APIs for MTRR operation." - diff --git a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c b/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c deleted file mode 100644 index ad3e9090c6..0000000000 --- a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.c +++ /dev/null @@ -1,90 +0,0 @@ -/** @file -Null instance of Platform Sec Lib. - -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include - -/** - A developer supplied function to perform platform specific operations. - - It's a developer supplied function to perform any operations appropriate to a - given platform. It's invoked just before passing control to PEI core by SEC - core. Platform developer may modify the SecCoreData passed to PEI Core. - It returns a platform specific PPI list that platform wishes to pass to PEI core. - The Generic SEC core module will merge this list to join the final list passed to - PEI core. - - @param SecCoreData The same parameter as passing to PEI core. It - could be overridden by this function. - - @return The platform specific PPI list to be passed to PEI core or - NULL if there is no need of such platform specific PPI list. - -**/ -EFI_PEI_PPI_DESCRIPTOR * -EFIAPI -SecPlatformMain ( - IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData - ) -{ - return NULL; -} - -/** - This interface conveys state information out of the Security (SEC) phase into PEI. - - @param PeiServices Pointer to the PEI Services Table. - @param StructureSize Pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord - ) -{ - return EFI_SUCCESS; -} - -/** - This interface disables temporary memory in SEC Phase. -**/ -VOID -EFIAPI -SecPlatformDisableTemporaryMemory ( - VOID - ) -{ -} - -/** - This function provides dummy function so that SecCore can pass build - validation. All real platform library instances need to implement the real - entry point in assembly. -**/ -VOID -EFIAPI -_ModuleEntryPoint ( - VOID - ) -{ - return; -} diff --git a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf b/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf deleted file mode 100644 index 3f8868adee..0000000000 --- a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf +++ /dev/null @@ -1,37 +0,0 @@ -## @file -# Library functions for PlatformSecLib. -# -# Null instance of Platform Sec Lib. -# -# Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformSecLibNull - MODULE_UNI_FILE = PlatformSecLibNull.uni - FILE_GUID = 6695974D-968C-420b-80B9-7870CD20118F - MODULE_TYPE = SEC - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformSecLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - PlatformSecLibNull.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec diff --git a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni b/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni deleted file mode 100644 index d7212f0351..0000000000 --- a/UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// Library functions for PlatformSecLib. -// -// Null instance of Platform Sec Library. -// -// Copyright (c) 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "Library functions for PlatformSecLib" - -#string STR_MODULE_DESCRIPTION #language en-US "Null instance of Platform Sec Library." diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c deleted file mode 100644 index 5e11b2b21c..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ /dev/null @@ -1,751 +0,0 @@ -/** @file - CPU Features Initialize functions. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "RegisterCpuFeatures.h" - -/** - Worker function to save PcdCpuFeaturesCapability. - - @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer -**/ -VOID -SetCapabilityPcd ( - IN UINT8 *SupportedFeatureMask - ) -{ - EFI_STATUS Status; - UINTN BitMaskSize; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability); - Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, SupportedFeatureMask); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to save PcdCpuFeaturesSetting. - - @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer -**/ -VOID -SetSettingPcd ( - IN UINT8 *SupportedFeatureMask - ) -{ - EFI_STATUS Status; - UINTN BitMaskSize; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSetting); - Status = PcdSetPtrS (PcdCpuFeaturesSetting, &BitMaskSize, SupportedFeatureMask); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to get PcdCpuFeaturesSupport. - - @return The pointer to CPU feature bits mask buffer. -**/ -UINT8 * -GetSupportPcds ( - VOID - ) -{ - UINTN BitMaskSize; - UINT8 *SupportBitMask; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - SupportBitMask = AllocateZeroPool (BitMaskSize); - ASSERT (SupportBitMask != NULL); - SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport); - - return SupportBitMask; -} - -/** - Worker function to get PcdCpuFeaturesUserConfiguration. - - @return The pointer to CPU feature bits mask buffer. -**/ -UINT8 * -GetConfigurationPcds ( - VOID - ) -{ - UINTN BitMaskSize; - UINT8 *SupportBitMask; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration); - SupportBitMask = AllocateZeroPool (BitMaskSize); - ASSERT (SupportBitMask != NULL); - SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration); - - return SupportBitMask; -} - -/** - Collects CPU type and feature information. - - @param[in, out] CpuInfo The pointer to CPU feature information -**/ -VOID -FillProcessorInfo ( - IN OUT REGISTER_CPU_FEATURE_INFORMATION *CpuInfo - ) -{ - CPUID_VERSION_INFO_EAX Eax; - CPUID_VERSION_INFO_ECX Ecx; - CPUID_VERSION_INFO_EDX Edx; - UINT32 DisplayedFamily; - UINT32 DisplayedModel; - - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, &Ecx.Uint32, &Edx.Uint32); - - DisplayedFamily = Eax.Bits.FamilyId; - if (Eax.Bits.FamilyId == 0x0F) { - DisplayedFamily |= (Eax.Bits.ExtendedFamilyId << 4); - } - - DisplayedModel = Eax.Bits.Model; - if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) { - DisplayedModel |= (Eax.Bits.ExtendedModelId << 4); - } - - CpuInfo->DisplayFamily = DisplayedFamily; - CpuInfo->DisplayModel = DisplayedModel; - CpuInfo->SteppingId = Eax.Bits.SteppingId; - CpuInfo->ProcessorType = Eax.Bits.ProcessorType; - CpuInfo->CpuIdVersionInfoEcx.Uint32 = Ecx.Uint32; - CpuInfo->CpuIdVersionInfoEdx.Uint32 = Edx.Uint32; -} - -/** - Prepares for private data used for CPU features. - - @param[in] NumberOfCpus Number of processor in system -**/ -VOID -CpuInitDataInitialize ( - IN UINTN NumberOfCpus - ) -{ - EFI_STATUS Status; - UINTN ProcessorNumber; - EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; - CPU_FEATURES_ENTRY *CpuFeature; - CPU_FEATURES_INIT_ORDER *InitOrder; - CPU_FEATURES_DATA *CpuFeaturesData; - LIST_ENTRY *Entry; - - CpuFeaturesData = GetCpuFeaturesData (); - CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus); - ASSERT (CpuFeaturesData->InitOrder != NULL); - CpuFeaturesData->BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - - // - // Collect CPU Features information - // - Entry = GetFirstNode (&CpuFeaturesData->FeatureList); - while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { - CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - ASSERT (CpuFeature->InitializeFunc != NULL); - if (CpuFeature->GetConfigDataFunc != NULL) { - CpuFeature->ConfigData = CpuFeature->GetConfigDataFunc (NumberOfCpus); - } - Entry = Entry->ForwardLink; - } - - for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { - InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; - InitOrder->FeaturesSupportedMask = AllocateZeroPool (CpuFeaturesData->BitMaskSize); - ASSERT (InitOrder->FeaturesSupportedMask != NULL); - InitializeListHead (&InitOrder->OrderList); - Status = GetProcessorInformation (ProcessorNumber, &ProcessorInfoBuffer); - ASSERT_EFI_ERROR (Status); - CopyMem ( - &InitOrder->CpuInfo.ProcessorInfo, - &ProcessorInfoBuffer, - sizeof (EFI_PROCESSOR_INFORMATION) - ); - } - // - // Get support and configuration PCDs - // - CpuFeaturesData->SupportPcds = GetSupportPcds (); - CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds (); -} - -/** - Worker function to do OR operation on CPU feature supported bits mask buffer. - - @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer - @param[in] OrFeatureBitMask The feature bit mask to do OR operation -**/ -VOID -SupportedMaskOr ( - IN UINT8 *SupportedFeatureMask, - IN UINT8 *OrFeatureBitMask - ) -{ - UINTN Index; - UINTN BitMaskSize; - UINT8 *Data1; - UINT8 *Data2; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - Data1 = SupportedFeatureMask; - Data2 = OrFeatureBitMask; - for (Index = 0; Index < BitMaskSize; Index++) { - *(Data1++) |= *(Data2++); - } -} - -/** - Worker function to do AND operation on CPU feature supported bits mask buffer. - - @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer - @param[in] AndFeatureBitMask The feature bit mask to do AND operation -**/ -VOID -SupportedMaskAnd ( - IN UINT8 *SupportedFeatureMask, - IN UINT8 *AndFeatureBitMask - ) -{ - UINTN Index; - UINTN BitMaskSize; - UINT8 *Data1; - UINT8 *Data2; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - Data1 = SupportedFeatureMask; - Data2 = AndFeatureBitMask; - for (Index = 0; Index < BitMaskSize; Index++) { - *(Data1++) &= *(Data2++); - } -} - -/** - Worker function to check if the compared CPU feature set in the CPU feature - supported bits mask buffer. - - @param[in] SupportedFeatureMask The pointer to CPU feature bits mask buffer - @param[in] ComparedFeatureBitMask The feature bit mask to be compared - - @retval TRUE The ComparedFeatureBitMask is set in CPU feature supported bits - mask buffer. - @retval FALSE The ComparedFeatureBitMask is not set in CPU feature supported bits - mask buffer. -**/ -BOOLEAN -IsBitMaskMatch ( - IN UINT8 *SupportedFeatureMask, - IN UINT8 *ComparedFeatureBitMask - ) -{ - UINTN Index; - UINTN BitMaskSize; - UINT8 *Data1; - UINT8 *Data2; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - - Data1 = SupportedFeatureMask; - Data2 = ComparedFeatureBitMask; - for (Index = 0; Index < BitMaskSize; Index++) { - if (((*(Data1++)) & (*(Data2++))) != 0) { - return TRUE; - } - } - return FALSE; -} - -/** - Collects processor data for calling processor. - - @param[in,out] Buffer The pointer to private data buffer. -**/ -VOID -EFIAPI -CollectProcessorData ( - IN OUT VOID *Buffer - ) -{ - UINTN ProcessorNumber; - CPU_FEATURES_ENTRY *CpuFeature; - REGISTER_CPU_FEATURE_INFORMATION *CpuInfo; - LIST_ENTRY *Entry; - CPU_FEATURES_DATA *CpuFeaturesData; - - CpuFeaturesData = GetCpuFeaturesData (); - ProcessorNumber = GetProcessorIndex (); - CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo; - // - // collect processor information - // - FillProcessorInfo (CpuInfo); - Entry = GetFirstNode (&CpuFeaturesData->FeatureList); - while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { - CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - if (IsBitMaskMatch (CpuFeaturesData->SupportPcds, CpuFeature->FeatureMask)) { - if (CpuFeature->SupportFunc == NULL) { - // - // If SupportFunc is NULL, then the feature is supported. - // - SupportedMaskOr ( - CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, - CpuFeature->FeatureMask - ); - } else if (CpuFeature->SupportFunc (ProcessorNumber, CpuInfo, CpuFeature->ConfigData)) { - SupportedMaskOr ( - CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask, - CpuFeature->FeatureMask - ); - } - } - Entry = Entry->ForwardLink; - } -} - -/** - Dump the contents of a CPU register table. - - @param[in] ProcessorNumber The index of the CPU to show the register table contents - - @note This service could be called by BSP only. -**/ -VOID -DumpRegisterTableOnProcessor ( - IN UINTN ProcessorNumber - ) -{ - CPU_FEATURES_DATA *CpuFeaturesData; - UINTN FeatureIndex; - CPU_REGISTER_TABLE *RegisterTable; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead; - UINT32 DebugPrintErrorLevel; - - DebugPrintErrorLevel = (ProcessorNumber == 0) ? DEBUG_INFO : DEBUG_VERBOSE; - CpuFeaturesData = GetCpuFeaturesData (); - // - // Debug information - // - RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; - DEBUG ((DebugPrintErrorLevel, "RegisterTable->TableLength = %d\n", RegisterTable->TableLength)); - - RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; - - for (FeatureIndex = 0; FeatureIndex < RegisterTable->TableLength; FeatureIndex++) { - RegisterTableEntry = &RegisterTableEntryHead[FeatureIndex]; - switch (RegisterTableEntry->RegisterType) { - case Msr: - DEBUG (( - DebugPrintErrorLevel, - "Processor: %d: MSR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", - ProcessorNumber, - RegisterTableEntry->Index, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitLength, - RegisterTableEntry->Value - )); - break; - case ControlRegister: - DEBUG (( - DebugPrintErrorLevel, - "Processor: %d: CR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", - ProcessorNumber, - RegisterTableEntry->Index, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitLength, - RegisterTableEntry->Value - )); - break; - case MemoryMapped: - DEBUG (( - DebugPrintErrorLevel, - "Processor: %d: MMIO: %lx, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", - ProcessorNumber, - RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32), - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitLength, - RegisterTableEntry->Value - )); - break; - case CacheControl: - DEBUG (( - DebugPrintErrorLevel, - "Processor: %d: CACHE: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n", - ProcessorNumber, - RegisterTableEntry->Index, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitLength, - RegisterTableEntry->Value - )); - break; - default: - break; - } - } -} - -/** - Analysis register CPU features on each processor and save CPU setting in CPU register table. - - @param[in] NumberOfCpus Number of processor in system - -**/ -VOID -AnalysisProcessorFeatures ( - IN UINTN NumberOfCpus - ) -{ - EFI_STATUS Status; - UINTN ProcessorNumber; - CPU_FEATURES_ENTRY *CpuFeature; - CPU_FEATURES_ENTRY *CpuFeatureInOrder; - CPU_FEATURES_INIT_ORDER *CpuInitOrder; - REGISTER_CPU_FEATURE_INFORMATION *CpuInfo; - LIST_ENTRY *Entry; - CPU_FEATURES_DATA *CpuFeaturesData; - - CpuFeaturesData = GetCpuFeaturesData (); - CpuFeaturesData->CapabilityPcds = AllocatePool (CpuFeaturesData->BitMaskSize); - ASSERT (CpuFeaturesData->CapabilityPcds != NULL); - SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF); - for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { - CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; - // - // Calculate the last capability on all processors - // - SupportedMaskAnd (CpuFeaturesData->CapabilityPcds, CpuInitOrder->FeaturesSupportedMask); - } - // - // Calculate the last setting - // - - CpuFeaturesData->SettingPcds = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds); - ASSERT (CpuFeaturesData->SettingPcds != NULL); - SupportedMaskAnd (CpuFeaturesData->SettingPcds, CpuFeaturesData->ConfigurationPcds); - - // - // Save PCDs and display CPU PCDs - // - SetCapabilityPcd (CpuFeaturesData->CapabilityPcds); - SetSettingPcd (CpuFeaturesData->SettingPcds); - - // - // Dump the last CPU feature list - // - DEBUG_CODE ( - DEBUG ((DEBUG_INFO, "Last CPU features list...\n")); - Entry = GetFirstNode (&CpuFeaturesData->FeatureList); - while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { - CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) { - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcds)) { - DEBUG ((DEBUG_INFO, "[Enable ] ")); - } else { - DEBUG ((DEBUG_INFO, "[Disable ] ")); - } - } else { - DEBUG ((DEBUG_INFO, "[Unsupport] ")); - } - DumpCpuFeature (CpuFeature); - Entry = Entry->ForwardLink; - } - DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n")); - DumpCpuFeatureMask (CpuFeaturesData->SupportPcds); - DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n")); - DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcds); - DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n")); - DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcds); - DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n")); - DumpCpuFeatureMask (CpuFeaturesData->SettingPcds); - ); - - for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) { - CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber]; - Entry = GetFirstNode (&CpuFeaturesData->FeatureList); - while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { - // - // Insert each feature into processor's order list - // - CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) { - CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), CpuFeature); - ASSERT (CpuFeatureInOrder != NULL); - InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Link); - } - Entry = Entry->ForwardLink; - } - // - // Go through ordered feature list to initialize CPU features - // - CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo; - Entry = GetFirstNode (&CpuInitOrder->OrderList); - while (!IsNull (&CpuInitOrder->OrderList, Entry)) { - CpuFeatureInOrder = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcds)) { - Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, TRUE); - } else { - Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, FALSE); - } - ASSERT_EFI_ERROR (Status); - Entry = Entry->ForwardLink; - } - // - // Dump the RegisterTable - // - DumpRegisterTableOnProcessor (ProcessorNumber); - } -} - -/** - Initialize the CPU registers from a register table. - - @param[in] ProcessorNumber The index of the CPU executing this function. - - @note This service could be called by BSP/APs. -**/ -VOID -ProgramProcessorRegister ( - IN UINTN ProcessorNumber - ) -{ - CPU_FEATURES_DATA *CpuFeaturesData; - CPU_REGISTER_TABLE *RegisterTable; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; - UINTN Index; - UINTN Value; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntryHead; - - CpuFeaturesData = GetCpuFeaturesData (); - RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; - - // - // Traverse Register Table of this logical processor - // - RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; - - for (Index = 0; Index < RegisterTable->TableLength; Index++) { - - RegisterTableEntry = &RegisterTableEntryHead[Index]; - - // - // Check the type of specified register - // - switch (RegisterTableEntry->RegisterType) { - // - // The specified register is Control Register - // - case ControlRegister: - switch (RegisterTableEntry->Index) { - case 0: - Value = AsmReadCr0 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - AsmWriteCr0 (Value); - break; - case 2: - Value = AsmReadCr2 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - AsmWriteCr2 (Value); - break; - case 3: - Value = AsmReadCr3 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - AsmWriteCr3 (Value); - break; - case 4: - Value = AsmReadCr4 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - AsmWriteCr4 (Value); - break; - case 8: - // - // Do we need to support CR8? - // - break; - default: - break; - } - break; - // - // The specified register is Model Specific Register - // - case Msr: - // - // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode - // - AcquireSpinLock (&CpuFeaturesData->MsrLock); - if (RegisterTableEntry->ValidBitLength >= 64) { - // - // If length is not less than 64 bits, then directly write without reading - // - AsmWriteMsr64 ( - RegisterTableEntry->Index, - RegisterTableEntry->Value - ); - } else { - // - // Set the bit section according to bit start and length - // - AsmMsrBitFieldWrite64 ( - RegisterTableEntry->Index, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - } - ReleaseSpinLock (&CpuFeaturesData->MsrLock); - break; - // - // MemoryMapped operations - // - case MemoryMapped: - AcquireSpinLock (&CpuFeaturesData->MemoryMappedLock); - MmioBitFieldWrite32 ( - (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)), - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINT32)RegisterTableEntry->Value - ); - ReleaseSpinLock (&CpuFeaturesData->MemoryMappedLock); - break; - // - // Enable or disable cache - // - case CacheControl: - // - // If value of the entry is 0, then disable cache. Otherwise, enable cache. - // - if (RegisterTableEntry->Value == 0) { - AsmDisableCache (); - } else { - AsmEnableCache (); - } - break; - - default: - break; - } - } -} - -/** - Programs registers for the calling processor. - - @param[in,out] Buffer The pointer to private data buffer. - -**/ -VOID -EFIAPI -SetProcessorRegister ( - IN OUT VOID *Buffer - ) -{ - UINTN ProcessorNumber; - - ProcessorNumber = GetProcessorIndex (); - ProgramProcessorRegister (ProcessorNumber); -} - -/** - Performs CPU features detection. - - This service will invoke MP service to check CPU features' - capabilities on BSP/APs. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuFeaturesDetect ( - VOID - ) -{ - UINTN NumberOfCpus; - UINTN NumberOfEnabledProcessors; - - GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors); - - CpuInitDataInitialize (NumberOfCpus); - - // - // Wakeup all APs for data collection. - // - StartupAPsWorker (CollectProcessorData); - - // - // Collect data on BSP - // - CollectProcessorData (NULL); - - AnalysisProcessorFeatures (NumberOfCpus); -} - -/** - Performs CPU features Initialization. - - This service will invoke MP service to perform CPU features - initialization on BSP/APs per user configuration. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuFeaturesInitialize ( - VOID - ) -{ - CPU_FEATURES_DATA *CpuFeaturesData; - UINTN OldBspNumber; - - CpuFeaturesData = GetCpuFeaturesData (); - - OldBspNumber = GetProcessorIndex(); - CpuFeaturesData->BspNumber = OldBspNumber; - // - // Wakeup all APs for programming. - // - StartupAPsWorker (SetProcessorRegister); - // - // Programming BSP - // - SetProcessorRegister (NULL); - // - // Switch to new BSP if required - // - if (CpuFeaturesData->BspNumber != OldBspNumber) { - SwitchNewBsp (CpuFeaturesData->BspNumber); - } -} diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c deleted file mode 100644 index 902a339529..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c +++ /dev/null @@ -1,266 +0,0 @@ -/** @file - CPU Register Table Library functions. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include - -#include "RegisterCpuFeatures.h" - -CPU_FEATURES_DATA mCpuFeaturesData = {0}; -EFI_MP_SERVICES_PROTOCOL *mCpuFeaturesMpServices = NULL; - -/** - Worker function to get CPU_FEATURES_DATA pointer. - - @return Pointer to CPU_FEATURES_DATA. -**/ -CPU_FEATURES_DATA * -GetCpuFeaturesData ( - VOID - ) -{ - return &mCpuFeaturesData; -} - -/** - Worker function to get EFI_MP_SERVICES_PROTOCOL pointer. - - @return Pointer to EFI_MP_SERVICES_PROTOCOL. -**/ -EFI_MP_SERVICES_PROTOCOL * -GetMpProtocol ( - VOID - ) -{ - EFI_STATUS Status; - - if (mCpuFeaturesMpServices == NULL) { - // - // Get MP Services Protocol - // - Status = gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&mCpuFeaturesMpServices - ); - ASSERT_EFI_ERROR (Status); - } - - ASSERT (mCpuFeaturesMpServices != NULL); - return mCpuFeaturesMpServices; -} - -/** - Worker function to return processor index. - - @return The processor index. -**/ -UINTN -GetProcessorIndex ( - VOID - ) -{ - EFI_STATUS Status; - UINTN ProcessorIndex; - EFI_MP_SERVICES_PROTOCOL *MpServices; - - MpServices = GetMpProtocol (); - Status = MpServices->WhoAmI(MpServices, &ProcessorIndex); - ASSERT_EFI_ERROR (Status); - return ProcessorIndex; -} - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @return Status of MpServices->GetProcessorInfo(). -**/ -EFI_STATUS -GetProcessorInformation ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - - MpServices = GetMpProtocol (); - Status = MpServices->GetProcessorInfo ( - MpServices, - ProcessorNumber, - ProcessorInfoBuffer - ); - return Status; -} - -/** - Worker function to execute a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. -**/ -VOID -StartupAPsWorker ( - IN EFI_AP_PROCEDURE Procedure - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - - MpServices = GetMpProtocol (); - // - // Wakeup all APs - // - Status = MpServices->StartupAllAPs ( - MpServices, - Procedure, - FALSE, - NULL, - 0, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to switch the requested AP to be the BSP from that point onward. - - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. -**/ -VOID -SwitchNewBsp ( - IN UINTN ProcessorNumber - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - - MpServices = GetMpProtocol (); - // - // Wakeup all APs - // - Status = MpServices->SwitchBSP ( - MpServices, - ProcessorNumber, - TRUE - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to retrieve the number of logical processor in the platform. - - @param[out] NumberOfCpus Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. -**/ -VOID -GetNumberOfProcessor ( - OUT UINTN *NumberOfCpus, - OUT UINTN *NumberOfEnabledProcessors - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - - MpServices = GetMpProtocol (); - - // - // Get the number of CPUs - // - Status = MpServices->GetNumberOfProcessors ( - MpServices, - NumberOfCpus, - NumberOfEnabledProcessors - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Allocates ACPI NVS memory to save ACPI_CPU_DATA. - - @return Pointer to allocated ACPI_CPU_DATA. -**/ -ACPI_CPU_DATA * -AllocateAcpiCpuData ( - VOID - ) -{ - // - // CpuS3DataDxe will do it. - // - ASSERT (FALSE); - return NULL; -} - -/** - Enlarges CPU register table for each processor. - - @param[in, out] RegisterTable Pointer processor's CPU register table -**/ -VOID -EnlargeRegisterTable ( - IN OUT CPU_REGISTER_TABLE *RegisterTable - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - UINTN AllocatePages; - - Address = BASE_4GB - 1; - AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - AllocatePages + 1, - &Address - ); - ASSERT_EFI_ERROR (Status); - - // - // If there are records existing in the register table, then copy its contents - // to new region and free the old one. - // - if (RegisterTable->AllocatedSize > 0) { - CopyMem ( - (VOID *) (UINTN) Address, - (VOID *) (UINTN) RegisterTable->RegisterTableEntry, - RegisterTable->AllocatedSize - ); - // - // RegisterTableEntry is allocated by gBS->AllocatePages() service. - // So, gBS->FreePages() service is used to free it. - // - gBS->FreePages ( - RegisterTable->RegisterTableEntry, - AllocatePages - ); - } - - // - // Adjust the allocated size and register table base address. - // - RegisterTable->AllocatedSize += EFI_PAGE_SIZE; - RegisterTable->RegisterTableEntry = Address; -} diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf deleted file mode 100644 index 62ac8a9635..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf +++ /dev/null @@ -1,62 +0,0 @@ -## @file -# Register CPU Features Library DXE instance. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeRegisterCpuFeaturesLib - MODULE_UNI_FILE = DxeRegisterCpuFeaturesLib.uni - FILE_GUID = ADE8F745-AA2E-49f6-8ED4-746B34867E52 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = RegisterCpuFeaturesLib|DXE_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.common] - DxeRegisterCpuFeaturesLib.c - RegisterCpuFeaturesLib.c - RegisterCpuFeatures.h - CpuFeaturesInitialize.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - PcdLib - LocalApicLib - BaseMemoryLib - MemoryAllocationLib - SynchronizationLib - UefiBootServicesTableLib - IoLib - -[Protocols] - gEfiMpServiceProtocolGuid ## CONSUMES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES - -[Depex] - gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c deleted file mode 100644 index 6804eddf65..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c +++ /dev/null @@ -1,390 +0,0 @@ -/** @file - CPU Register Table Library functions. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include "RegisterCpuFeatures.h" - -#define REGISTER_CPU_FEATURES_GUID \ - { \ - 0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \ - } - -EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID; - -/** - Worker function to get CPU_FEATURES_DATA pointer. - - @return Pointer to CPU_FEATURES_DATA. -**/ -CPU_FEATURES_DATA * -GetCpuFeaturesData ( - VOID - ) -{ - CPU_FEATURES_DATA *CpuInitData; - EFI_HOB_GUID_TYPE *GuidHob; - VOID *DataInHob; - UINT64 Data64; - - CpuInitData = NULL; - GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid); - if (GuidHob != NULL) { - DataInHob = GET_GUID_HOB_DATA (GuidHob); - CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob); - ASSERT (CpuInitData != NULL); - } else { - CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA)); - ASSERT (CpuInitData != NULL); - // - // Build location of CPU MP DATA buffer in HOB - // - Data64 = (UINT64) (UINTN) CpuInitData; - BuildGuidDataHob ( - &mRegisterCpuFeaturesHobGuid, - (VOID *) &Data64, - sizeof (UINT64) - ); - } - - return CpuInitData; -} - -/** - Worker function to get MP PPI service pointer. - - @return PEI PPI service pointer. -**/ -EFI_PEI_MP_SERVICES_PPI * -GetMpPpi ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - - // - // Get MP Services Protocol - // - Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, - 0, - NULL, - (VOID **)&CpuMpPpi - ); - ASSERT_EFI_ERROR (Status); - return CpuMpPpi; -} - -/** - Worker function to return processor index. - - @return The processor index. -**/ -UINTN -GetProcessorIndex ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - UINTN ProcessorIndex; - - CpuMpPpi = GetMpPpi (); - - Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex); - ASSERT_EFI_ERROR (Status); - return ProcessorIndex; -} - -/** - Worker function to MP-related information on the requested processor at the - instant this call is made. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @return Status of MpServices->GetProcessorInfo(). -**/ -EFI_STATUS -GetProcessorInformation ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ) -{ - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - EFI_STATUS Status; - - CpuMpPpi = GetMpPpi (); - Status = CpuMpPpi->GetProcessorInfo ( - GetPeiServicesTablePointer(), - CpuMpPpi, - ProcessorNumber, - ProcessorInfoBuffer - ); - return Status; -} - -/** - Worker function to execute a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. -**/ -VOID -StartupAPsWorker ( - IN EFI_AP_PROCEDURE Procedure - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - - // - // Get MP Services Protocol - // - Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, - 0, - NULL, - (VOID **)&CpuMpPpi - ); - ASSERT_EFI_ERROR (Status); - - // - // Wakeup all APs for data collection. - // - Status = CpuMpPpi->StartupAllAPs ( - GetPeiServicesTablePointer (), - CpuMpPpi, - Procedure, - FALSE, - 0, - NULL - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to switch the requested AP to be the BSP from that point onward. - - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. -**/ -VOID -SwitchNewBsp ( - IN UINTN ProcessorNumber - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - - // - // Get MP Services Protocol - // - Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, - 0, - NULL, - (VOID **)&CpuMpPpi - ); - ASSERT_EFI_ERROR (Status); - - // - // Wakeup all APs for data collection. - // - Status = CpuMpPpi->SwitchBSP ( - GetPeiServicesTablePointer (), - CpuMpPpi, - ProcessorNumber, - TRUE - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Worker function to retrieve the number of logical processor in the platform. - - @param[out] NumberOfCpus Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. -**/ -VOID -GetNumberOfProcessor ( - OUT UINTN *NumberOfCpus, - OUT UINTN *NumberOfEnabledProcessors - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - - // - // Get MP Services Protocol - // - Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, - 0, - NULL, - (VOID **)&CpuMpPpi - ); - ASSERT_EFI_ERROR (Status); - - // - // Get the number of CPUs - // - Status = CpuMpPpi->GetNumberOfProcessors ( - GetPeiServicesTablePointer (), - CpuMpPpi, - NumberOfCpus, - NumberOfEnabledProcessors - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Allocates ACPI NVS memory to save ACPI_CPU_DATA. - - @return Pointer to allocated ACPI_CPU_DATA. -**/ -ACPI_CPU_DATA * -AllocateAcpiCpuData ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; - UINTN NumberOfCpus; - UINTN NumberOfEnabledProcessors; - ACPI_CPU_DATA *AcpiCpuData; - EFI_PHYSICAL_ADDRESS Address; - UINTN TableSize; - CPU_REGISTER_TABLE *RegisterTable; - UINTN Index; - EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; - - Status = PeiServicesAllocatePages ( - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)), - &Address - ); - ASSERT_EFI_ERROR (Status); - AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address; - ASSERT (AcpiCpuData != NULL); - - // - // Get MP Services Protocol - // - Status = PeiServicesLocatePpi ( - &gEfiPeiMpServicesPpiGuid, - 0, - NULL, - (VOID **)&CpuMpPpi - ); - ASSERT_EFI_ERROR (Status); - - // - // Get the number of CPUs - // - Status = CpuMpPpi->GetNumberOfProcessors ( - GetPeiServicesTablePointer (), - CpuMpPpi, - &NumberOfCpus, - &NumberOfEnabledProcessors - ); - ASSERT_EFI_ERROR (Status); - AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; - - // - // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs - // - TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); - Status = PeiServicesAllocatePages ( - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (TableSize), - &Address - ); - ASSERT_EFI_ERROR (Status); - RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address; - - for (Index = 0; Index < NumberOfCpus; Index++) { - Status = CpuMpPpi->GetProcessorInfo ( - GetPeiServicesTablePointer (), - CpuMpPpi, - Index, - &ProcessorInfoBuffer - ); - ASSERT_EFI_ERROR (Status); - - RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; - RegisterTable[Index].TableLength = 0; - RegisterTable[Index].AllocatedSize = 0; - RegisterTable[Index].RegisterTableEntry = 0; - - RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; - RegisterTable[NumberOfCpus + Index].TableLength = 0; - RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; - RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; - } - AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; - AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); - - return AcpiCpuData; -} - -/** - Enlarges CPU register table for each processor. - - @param[in, out] RegisterTable Pointer processor's CPU register table -**/ -VOID -EnlargeRegisterTable ( - IN OUT CPU_REGISTER_TABLE *RegisterTable - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - UINTN AllocatePages; - - AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; - Status = PeiServicesAllocatePages ( - EfiACPIMemoryNVS, - AllocatePages + 1, - &Address - ); - ASSERT_EFI_ERROR (Status); - - // - // If there are records existing in the register table, then copy its contents - // to new region and free the old one. - // - if (RegisterTable->AllocatedSize > 0) { - CopyMem ( - (VOID *) (UINTN) Address, - (VOID *) (UINTN) RegisterTable->RegisterTableEntry, - RegisterTable->AllocatedSize - ); - } - - // - // Adjust the allocated size and register table base address. - // - RegisterTable->AllocatedSize += EFI_PAGE_SIZE; - RegisterTable->RegisterTableEntry = Address; -} diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf deleted file mode 100644 index 5e9ab2c304..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf +++ /dev/null @@ -1,64 +0,0 @@ -## @file -# Register CPU Features Library PEI instance. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiRegisterCpuFeaturesLib - MODULE_UNI_FILE = PeiRegisterCpuFeaturesLib.uni - FILE_GUID = D8855DB3-8348-41B5-BDA4-385351767D41 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = RegisterCpuFeaturesLib|PEIM - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.common] - PeiRegisterCpuFeaturesLib.c - RegisterCpuFeaturesLib.c - RegisterCpuFeatures.h - CpuFeaturesInitialize.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - PcdLib - LocalApicLib - BaseMemoryLib - MemoryAllocationLib - SynchronizationLib - HobLib - PeiServicesLib - PeiServicesTablePointerLib - IoLib - -[Ppis] - gEfiPeiMpServicesPpiGuid ## CONSUMES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES - -[Depex] - gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h deleted file mode 100644 index 7731f885b3..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h +++ /dev/null @@ -1,193 +0,0 @@ -/** @file - CPU Register Table Library definitions. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _REGISTER_CPU_FEATURES_H_ -#define _REGISTER_CPU_FEATURES_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S') - -#define CPU_FEATURE_NAME_SIZE 128 - -typedef struct { - REGISTER_CPU_FEATURE_INFORMATION CpuInfo; - UINT8 *FeaturesSupportedMask; - LIST_ENTRY OrderList; -} CPU_FEATURES_INIT_ORDER; - -typedef struct { - UINT32 Signature; - LIST_ENTRY Link; - UINT8 *FeatureMask; - CHAR8 *FeatureName; - CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc; - CPU_FEATURE_SUPPORT SupportFunc; - CPU_FEATURE_INITIALIZE InitializeFunc; - UINT8 *BeforeFeatureBitMask; - UINT8 *AfterFeatureBitMask; - VOID *ConfigData; - BOOLEAN BeforeAll; - BOOLEAN AfterAll; -} CPU_FEATURES_ENTRY; - -typedef struct { - UINTN FeaturesCount; - UINT32 BitMaskSize; - SPIN_LOCK MsrLock; - SPIN_LOCK MemoryMappedLock; - LIST_ENTRY FeatureList; - - CPU_FEATURES_INIT_ORDER *InitOrder; - UINT8 *SupportPcds; - UINT8 *CapabilityPcds; - UINT8 *ConfigurationPcds; - UINT8 *SettingPcds; - - CPU_REGISTER_TABLE *RegisterTable; - CPU_REGISTER_TABLE *PreSmmRegisterTable; - UINTN BspNumber; -} CPU_FEATURES_DATA; - -#define CPU_FEATURE_ENTRY_FROM_LINK(a) \ - CR ( \ - (a), \ - CPU_FEATURES_ENTRY, \ - Link, \ - CPU_FEATURE_ENTRY_SIGNATURE \ - ) - -/** - Worker function to get CPU_FEATURES_DATA pointer. - - @return Pointer to CPU_FEATURES_DATA. -**/ -CPU_FEATURES_DATA * -GetCpuFeaturesData ( - VOID - ); - -/** - Enlarges CPU register table for each processor. - - @param[in, out] RegisterTable Pointer processor's CPU register table -**/ -VOID -EnlargeRegisterTable ( - IN OUT CPU_REGISTER_TABLE *RegisterTable - ); - -/** - Allocates ACPI NVS memory to save ACPI_CPU_DATA. - - @return Pointer to allocated ACPI_CPU_DATA. -**/ -ACPI_CPU_DATA * -AllocateAcpiCpuData ( - VOID - ); - -/** - Worker function to return processor index. - - @return The processor index. -**/ -UINTN -GetProcessorIndex ( - VOID - ); - -/** - Gets detailed MP-related information on the requested processor at the - instant this call is made. - - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @return Status of MpServices->GetProcessorInfo(). -**/ -EFI_STATUS -GetProcessorInformation ( - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ); - -/** - Worker function to execute a caller provided function on all enabled APs. - - @param[in] Procedure A pointer to the function to be run on - enabled APs of the system. -**/ -VOID -StartupAPsWorker ( - IN EFI_AP_PROCEDURE Procedure - ); - -/** - Worker function to retrieve the number of logical processor in the platform. - - @param[out] NumberOfCpus Pointer to the total number of logical - processors in the system, including the BSP - and disabled APs. - @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical - processors that exist in system, including - the BSP. -**/ -VOID -GetNumberOfProcessor ( - OUT UINTN *NumberOfCpus, - OUT UINTN *NumberOfEnabledProcessors - ); - -/** - Worker function to switch the requested AP to be the BSP from that point onward. - - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. -**/ -VOID -SwitchNewBsp ( - IN UINTN ProcessorNumber - ); - -/** - Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask. - - @param[in] FeatureMask A pointer to the CPU feature bit mask. -**/ -VOID -DumpCpuFeatureMask ( - IN UINT8 *FeatureMask - ); - -/** - Dump CPU feature name or CPU feature bit mask. - - @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY -**/ -VOID -DumpCpuFeature ( - IN CPU_FEATURES_ENTRY *CpuFeature - ); - -#endif diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni deleted file mode 100644 index d928952551..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file -// CPU Register Table Library instance. -// -// CPU Register Table Library instance. -// -// Copyright (c) 2016, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "CPU Register Table Library instance" - -#string STR_MODULE_DESCRIPTION #language en-US "CPU Register Table Library instance." - diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c deleted file mode 100644 index 338f1a495c..0000000000 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c +++ /dev/null @@ -1,775 +0,0 @@ -/** @file - CPU Register Table Library functions. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "RegisterCpuFeatures.h" - -/** - Checks if two CPU feature bit masks are equal. - - @param[in] FirstFeatureMask The first input CPU feature bit mask - @param[in] SecondFeatureMask The second input CPU feature bit mask - - @retval TRUE Two CPU feature bit masks are equal. - @retval FALSE Two CPU feature bit masks are not equal. -**/ -BOOLEAN -IsCpuFeatureMatch ( - IN UINT8 *FirstFeatureMask, - IN UINT8 *SecondFeatureMask - ) -{ - UINT32 BitMaskSize; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - if (CompareMem (FirstFeatureMask, SecondFeatureMask, BitMaskSize) == 0) { - return TRUE; - } else { - return FALSE; - } -} - -/** - Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask. - - @param[in] FeatureMask A pointer to the CPU feature bit mask. -**/ -VOID -DumpCpuFeatureMask ( - IN UINT8 *FeatureMask - ) -{ - UINTN Index; - UINT8 *Data8; - UINT32 BitMaskSize; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - Data8 = (UINT8 *) FeatureMask; - for (Index = 0; Index < BitMaskSize; Index++) { - DEBUG ((DEBUG_INFO, " %02x ", *Data8++)); - } - DEBUG ((DEBUG_INFO, "\n")); -} - -/** - Dump CPU feature name or CPU feature bit mask. - - @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY -**/ -VOID -DumpCpuFeature ( - IN CPU_FEATURES_ENTRY *CpuFeature - ) -{ - - if (CpuFeature->FeatureName != NULL) { - DEBUG ((DEBUG_INFO, "FeatureName: %a\n", CpuFeature->FeatureName)); - } else { - DEBUG ((DEBUG_INFO, "FeatureMask = ")); - DumpCpuFeatureMask (CpuFeature->FeatureMask); - } -} - -/** - Determines if the feature bit mask is in dependent CPU feature bit mask buffer. - - @param[in] FeatureMask Pointer to CPU feature bit mask - @param[in] DependentBitMask Pointer to dependent CPU feature bit mask buffer - - @retval TRUE The feature bit mask is in dependent CPU feature bit mask buffer. - @retval FALSE The feature bit mask is not in dependent CPU feature bit mask buffer. -**/ -BOOLEAN -IsBitMaskMatchCheck ( - IN UINT8 *FeatureMask, - IN UINT8 *DependentBitMask - ) -{ - UINTN Index; - UINTN BitMaskSize; - UINT8 *Data1; - UINT8 *Data2; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - - Data1 = FeatureMask; - Data2 = DependentBitMask; - for (Index = 0; Index < BitMaskSize; Index++) { - if (((*(Data1++)) & (*(Data2++))) != 0) { - return TRUE; - } - } - return FALSE; -} - -/** - Checks and adjusts CPU features order per dependency relationship. - - @param[in] FeatureList Pointer to CPU feature list -**/ -VOID -CheckCpuFeaturesDependency ( - IN LIST_ENTRY *FeatureList - ) -{ - LIST_ENTRY *CurrentEntry; - CPU_FEATURES_ENTRY *CpuFeature; - LIST_ENTRY *CheckEntry; - CPU_FEATURES_ENTRY *CheckFeature; - BOOLEAN Swapped; - LIST_ENTRY *TempEntry; - - CurrentEntry = GetFirstNode (FeatureList); - while (!IsNull (FeatureList, CurrentEntry)) { - Swapped = FALSE; - CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (CurrentEntry); - if (CpuFeature->BeforeAll) { - // - // Check all features dispatched before this entry - // - CheckEntry = GetFirstNode (FeatureList); - while (CheckEntry != CurrentEntry) { - CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); - if (!CheckFeature->BeforeAll) { - // - // If this feature has no BeforeAll flag and is dispatched before CpuFeature, - // insert currentEntry before Checked feature - // - RemoveEntryList (CurrentEntry); - InsertTailList (CheckEntry, CurrentEntry); - Swapped = TRUE; - break; - } - CheckEntry = CheckEntry->ForwardLink; - } - if (Swapped) { - continue; - } - } - - if (CpuFeature->AfterAll) { - // - // Check all features dispatched after this entry - // - CheckEntry = GetNextNode (FeatureList, CurrentEntry); - while (!IsNull (FeatureList, CheckEntry)) { - CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); - if (!CheckFeature->AfterAll) { - // - // If this feature has no AfterAll flag and is dispatched after CpuFeature, - // insert currentEntry after Checked feature - // - TempEntry = GetNextNode (FeatureList, CurrentEntry); - RemoveEntryList (CurrentEntry); - InsertHeadList (CheckEntry, CurrentEntry); - CurrentEntry = TempEntry; - Swapped = TRUE; - break; - } - CheckEntry = CheckEntry->ForwardLink; - } - if (Swapped) { - continue; - } - } - - if (CpuFeature->BeforeFeatureBitMask != NULL) { - // - // Check all features dispatched before this entry - // - CheckEntry = GetFirstNode (FeatureList); - while (CheckEntry != CurrentEntry) { - CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); - if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->BeforeFeatureBitMask)) { - // - // If there is dependency, swap them - // - RemoveEntryList (CurrentEntry); - InsertTailList (CheckEntry, CurrentEntry); - Swapped = TRUE; - break; - } - CheckEntry = CheckEntry->ForwardLink; - } - if (Swapped) { - continue; - } - } - - if (CpuFeature->AfterFeatureBitMask != NULL) { - // - // Check all features dispatched after this entry - // - CheckEntry = GetNextNode (FeatureList, CurrentEntry); - while (!IsNull (FeatureList, CheckEntry)) { - CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry); - if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->AfterFeatureBitMask)) { - // - // If there is dependency, swap them - // - TempEntry = GetNextNode (FeatureList, CurrentEntry); - RemoveEntryList (CurrentEntry); - InsertHeadList (CheckEntry, CurrentEntry); - CurrentEntry = TempEntry; - Swapped = TRUE; - break; - } - CheckEntry = CheckEntry->ForwardLink; - } - if (Swapped) { - continue; - } - } - // - // No swap happened, check the next feature - // - CurrentEntry = CurrentEntry->ForwardLink; - } -} - -/** - Worker function to register CPU Feature. - - @param[in] CpuFeature Pointer to CPU feature entry - - @retval RETURN_SUCCESS The CPU feature was successfully registered. - @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register - the CPU feature. - @retval RETURN_UNSUPPORTED Registration of the CPU feature is not - supported due to a circular dependency between - BEFORE and AFTER features. -**/ -RETURN_STATUS -RegisterCpuFeatureWorker ( - IN CPU_FEATURES_ENTRY *CpuFeature - ) -{ - EFI_STATUS Status; - CPU_FEATURES_DATA *CpuFeaturesData; - CPU_FEATURES_ENTRY *CpuFeatureEntry; - LIST_ENTRY *Entry; - UINT32 BitMaskSize; - BOOLEAN FeatureExist; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - CpuFeaturesData = GetCpuFeaturesData (); - if (CpuFeaturesData->FeaturesCount == 0) { - InitializeListHead (&CpuFeaturesData->FeatureList); - InitializeSpinLock (&CpuFeaturesData->MsrLock); - InitializeSpinLock (&CpuFeaturesData->MemoryMappedLock); - CpuFeaturesData->BitMaskSize = BitMaskSize; - } - ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize); - - FeatureExist = FALSE; - CpuFeatureEntry = NULL; - Entry = GetFirstNode (&CpuFeaturesData->FeatureList); - while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) { - CpuFeatureEntry = CPU_FEATURE_ENTRY_FROM_LINK (Entry); - if (IsCpuFeatureMatch (CpuFeature->FeatureMask, CpuFeatureEntry->FeatureMask)) { - // - // If this feature already registered - // - FeatureExist = TRUE; - break; - } - Entry = Entry->ForwardLink; - } - - if (!FeatureExist) { - DEBUG ((DEBUG_INFO, "[NEW] ")); - DumpCpuFeature (CpuFeature); - InsertTailList (&CpuFeaturesData->FeatureList, &CpuFeature->Link); - CpuFeaturesData->FeaturesCount++; - } else { - DEBUG ((DEBUG_INFO, "[OVERRIDE] ")); - DumpCpuFeature (CpuFeature); - ASSERT (CpuFeatureEntry != NULL); - // - // Overwrite original parameters of CPU feature - // - if (CpuFeature->GetConfigDataFunc != NULL) { - CpuFeatureEntry->GetConfigDataFunc = CpuFeature->GetConfigDataFunc; - } - if (CpuFeature->SupportFunc != NULL) { - CpuFeatureEntry->SupportFunc = CpuFeature->SupportFunc; - } - if (CpuFeature->InitializeFunc != NULL) { - CpuFeatureEntry->InitializeFunc = CpuFeature->InitializeFunc; - } - if (CpuFeature->FeatureName != NULL) { - if (CpuFeatureEntry->FeatureName == NULL) { - CpuFeatureEntry->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE); - ASSERT (CpuFeatureEntry->FeatureName != NULL); - } - Status = AsciiStrCpyS (CpuFeatureEntry->FeatureName, CPU_FEATURE_NAME_SIZE, CpuFeature->FeatureName); - ASSERT_EFI_ERROR (Status); - FreePool (CpuFeature->FeatureName); - } - if (CpuFeature->BeforeFeatureBitMask != NULL) { - if (CpuFeatureEntry->BeforeFeatureBitMask != NULL) { - FreePool (CpuFeatureEntry->BeforeFeatureBitMask); - } - CpuFeatureEntry->BeforeFeatureBitMask = CpuFeature->BeforeFeatureBitMask; - } - if (CpuFeature->AfterFeatureBitMask != NULL) { - if (CpuFeatureEntry->AfterFeatureBitMask != NULL) { - FreePool (CpuFeatureEntry->AfterFeatureBitMask); - } - CpuFeatureEntry->AfterFeatureBitMask = CpuFeature->AfterFeatureBitMask; - } - CpuFeatureEntry->BeforeAll = CpuFeature->BeforeAll; - CpuFeatureEntry->AfterAll = CpuFeature->AfterAll; - - FreePool (CpuFeature->FeatureMask); - FreePool (CpuFeature); - } - // - // Verify CPU features dependency can change CPU feature order - // - CheckCpuFeaturesDependency (&CpuFeaturesData->FeatureList); - return RETURN_SUCCESS; -} - -/** - Sets CPU feature bit mask in CPU feature bit mask buffer. - - @param[in] FeaturesBitMask Pointer to CPU feature bit mask buffer - @param[in] Feature The bit number of the CPU feature - @param[in] BitMaskSize CPU feature bit mask buffer size -**/ -VOID -SetCpuFeaturesBitMask ( - IN UINT8 **FeaturesBitMask, - IN UINT32 Feature, - IN UINTN BitMaskSize - ) -{ - UINT8 *CpuFeaturesBitMask; - - ASSERT (FeaturesBitMask != NULL); - CpuFeaturesBitMask = *FeaturesBitMask; - if (CpuFeaturesBitMask == NULL) { - CpuFeaturesBitMask = AllocateZeroPool (BitMaskSize); - ASSERT (CpuFeaturesBitMask != NULL); - *FeaturesBitMask = CpuFeaturesBitMask; - } - - CpuFeaturesBitMask += (Feature / 8); - *CpuFeaturesBitMask |= (UINT8) (1 << (Feature % 8)); -} - -/** - Registers a CPU Feature. - - @param[in] FeatureName A Null-terminated Ascii string indicates CPU feature - name. - @param[in] GetConfigDataFunc CPU feature get configuration data function. This - is an optional parameter that may be NULL. If NULL, - then the most recently registered function for the - CPU feature is used. If no functions are registered - for a CPU feature, then the CPU configuration data - for the registered feature is NULL. - @param[in] SupportFunc CPU feature support function. This is an optional - parameter that may be NULL. If NULL, then the most - recently registered function for the CPU feature is - used. If no functions are registered for a CPU - feature, then the CPU feature is assumed to be - supported by all CPUs. - @param[in] InitializeFunc CPU feature initialize function. This is an optional - parameter that may be NULL. If NULL, then the most - recently registered function for the CPU feature is - used. If no functions are registered for a CPU - feature, then the CPU feature initialization is - skipped. - @param[in] ... Variable argument list of UINT32 CPU feature value. - Values with no modifiers are the features provided - by the registered functions. - Values with CPU_FEATURE_BEFORE modifier are features - that must be initialized after the features provided - by the registered functions are used. - Values with CPU_FEATURE_AFTER modifier are features - that must be initialized before the features provided - by the registered functions are used. - The last argument in this variable argument list must - always be CPU_FEATURE_END. - - @retval RETURN_SUCCESS The CPU feature was successfully registered. - @retval RETURN_OUT_OF_RESOURCES There are not enough resources to register - the CPU feature. - @retval RETURN_UNSUPPORTED Registration of the CPU feature is not - supported due to a circular dependency between - BEFORE and AFTER features. - - @note This service could be called by BSP only. -**/ -RETURN_STATUS -EFIAPI -RegisterCpuFeature ( - IN CHAR8 *FeatureName, OPTIONAL - IN CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc, OPTIONAL - IN CPU_FEATURE_SUPPORT SupportFunc, OPTIONAL - IN CPU_FEATURE_INITIALIZE InitializeFunc, OPTIONAL - ... - ) -{ - EFI_STATUS Status; - VA_LIST Marker; - UINT32 Feature; - UINTN BitMaskSize; - CPU_FEATURES_ENTRY *CpuFeature; - UINT8 *FeatureMask; - UINT8 *BeforeFeatureBitMask; - UINT8 *AfterFeatureBitMask; - BOOLEAN BeforeAll; - BOOLEAN AfterAll; - - FeatureMask = NULL; - BeforeFeatureBitMask = NULL; - AfterFeatureBitMask = NULL; - BeforeAll = FALSE; - AfterAll = FALSE; - - BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport); - - VA_START (Marker, InitializeFunc); - Feature = VA_ARG (Marker, UINT32); - while (Feature != CPU_FEATURE_END) { - ASSERT ((Feature & (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER)) - != (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER)); - ASSERT ((Feature & (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL)) - != (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL)); - if (Feature < CPU_FEATURE_BEFORE) { - BeforeAll = ((Feature & CPU_FEATURE_BEFORE_ALL) != 0) ? TRUE : FALSE; - AfterAll = ((Feature & CPU_FEATURE_AFTER_ALL) != 0) ? TRUE : FALSE; - Feature &= ~(CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL); - ASSERT (FeatureMask == NULL); - SetCpuFeaturesBitMask (&FeatureMask, Feature, BitMaskSize); - } else if ((Feature & CPU_FEATURE_BEFORE) != 0) { - SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATURE_BEFORE, BitMaskSize); - } else if ((Feature & CPU_FEATURE_AFTER) != 0) { - SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATURE_AFTER, BitMaskSize); - } - Feature = VA_ARG (Marker, UINT32); - } - VA_END (Marker); - - CpuFeature = AllocateZeroPool (sizeof (CPU_FEATURES_ENTRY)); - ASSERT (CpuFeature != NULL); - CpuFeature->Signature = CPU_FEATURE_ENTRY_SIGNATURE; - CpuFeature->FeatureMask = FeatureMask; - CpuFeature->BeforeFeatureBitMask = BeforeFeatureBitMask; - CpuFeature->AfterFeatureBitMask = AfterFeatureBitMask; - CpuFeature->BeforeAll = BeforeAll; - CpuFeature->AfterAll = AfterAll; - CpuFeature->GetConfigDataFunc = GetConfigDataFunc; - CpuFeature->SupportFunc = SupportFunc; - CpuFeature->InitializeFunc = InitializeFunc; - if (FeatureName != NULL) { - CpuFeature->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE); - ASSERT (CpuFeature->FeatureName != NULL); - Status = AsciiStrCpyS (CpuFeature->FeatureName, CPU_FEATURE_NAME_SIZE, FeatureName); - ASSERT_EFI_ERROR (Status); - } - - Status = RegisterCpuFeatureWorker (CpuFeature); - ASSERT_EFI_ERROR (Status); - - return RETURN_SUCCESS; -} - -/** - Add an entry in specified register table. - - This function adds an entry in specified register table, with given register type, - register index, bit section and value. - - @param[in] PreSmmFlag If TRUE, entry will be added into PreSmm register table - If FALSE, entry will be added into register table - @param[in] ProcessorNumber The index of the CPU to add a register table entry - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] ValidBitStart Start of the bit section - @param[in] ValidBitLength Length of the bit section - @param[in] Value Value to write -**/ -VOID -CpuRegisterTableWriteWorker ( - IN BOOLEAN PreSmmFlag, - IN UINTN ProcessorNumber, - IN REGISTER_TYPE RegisterType, - IN UINT64 Index, - IN UINT8 ValidBitStart, - IN UINT8 ValidBitLength, - IN UINT64 Value - ) -{ - EFI_STATUS Status; - CPU_FEATURES_DATA *CpuFeaturesData; - ACPI_CPU_DATA *AcpiCpuData; - CPU_REGISTER_TABLE *RegisterTable; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; - - CpuFeaturesData = GetCpuFeaturesData (); - if (CpuFeaturesData->RegisterTable == NULL) { - AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress); - if (AcpiCpuData == NULL) { - AcpiCpuData = AllocateAcpiCpuData (); - ASSERT (AcpiCpuData != NULL); - // - // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure - // - Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData); - ASSERT_EFI_ERROR (Status); - } - ASSERT (AcpiCpuData->RegisterTable != 0); - CpuFeaturesData->RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->RegisterTable; - CpuFeaturesData->PreSmmRegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->PreSmmInitRegisterTable; - } - - if (PreSmmFlag) { - RegisterTable = &CpuFeaturesData->PreSmmRegisterTable[ProcessorNumber]; - } else { - RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber]; - } - - if (RegisterTable->TableLength == RegisterTable->AllocatedSize / sizeof (CPU_REGISTER_TABLE_ENTRY)) { - EnlargeRegisterTable (RegisterTable); - } - - // - // Append entry in the register table. - // - RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; - RegisterTableEntry[RegisterTable->TableLength].RegisterType = RegisterType; - RegisterTableEntry[RegisterTable->TableLength].Index = (UINT32) Index; - RegisterTableEntry[RegisterTable->TableLength].HighIndex = (UINT32) RShiftU64 (Index, 32); - RegisterTableEntry[RegisterTable->TableLength].ValidBitStart = ValidBitStart; - RegisterTableEntry[RegisterTable->TableLength].ValidBitLength = ValidBitLength; - RegisterTableEntry[RegisterTable->TableLength].Value = Value; - - RegisterTable->TableLength++; -} - -/** - Adds an entry in specified register table. - - This function adds an entry in specified register table, with given register type, - register index, bit section and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] ValueMask Mask of bits in register to write - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -CpuRegisterTableWrite ( - IN UINTN ProcessorNumber, - IN REGISTER_TYPE RegisterType, - IN UINT64 Index, - IN UINT64 ValueMask, - IN UINT64 Value - ) -{ - UINT8 Start; - UINT8 End; - UINT8 Length; - - Start = (UINT8)LowBitSet64 (ValueMask); - End = (UINT8)HighBitSet64 (ValueMask); - Length = End - Start + 1; - CpuRegisterTableWriteWorker (FALSE, ProcessorNumber, RegisterType, Index, Start, Length, Value); -} - -/** - Adds an entry in specified Pre-SMM register table. - - This function adds an entry in specified register table, with given register type, - register index, bit section and value. - - @param[in] ProcessorNumber The index of the CPU to add a register table entry. - @param[in] RegisterType Type of the register to program - @param[in] Index Index of the register to program - @param[in] ValueMask Mask of bits in register to write - @param[in] Value Value to write - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -PreSmmCpuRegisterTableWrite ( - IN UINTN ProcessorNumber, - IN REGISTER_TYPE RegisterType, - IN UINT64 Index, - IN UINT64 ValueMask, - IN UINT64 Value - ) -{ - UINT8 Start; - UINT8 End; - UINT8 Length; - - Start = (UINT8)LowBitSet64 (ValueMask); - End = (UINT8)HighBitSet64 (ValueMask); - Length = End - Start + 1; - CpuRegisterTableWriteWorker (TRUE, ProcessorNumber, RegisterType, Index, Start, Length, Value); -} - -/** - Worker function to determine if a CPU feature is set in input CPU feature bit mask buffer. - - @param[in] CpuBitMask CPU feature bit mask buffer - @param[in] CpuBitMaskSize The size of CPU feature bit mask buffer - @param[in] Feature The bit number of the CPU feature - - @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. - -**/ -BOOLEAN -IsCpuFeatureSetInCpuPcd ( - IN UINT8 *CpuBitMask, - IN UINTN CpuBitMaskSize, - IN UINT32 Feature - ) -{ - if ((Feature >> 3) >= CpuBitMaskSize) { - return FALSE; - } - return ((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 0x07))) != 0); -} - -/** - Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask. - If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data - associated with that feature should be optimized away if compiler - optimizations are enabled. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesSupport - - @retval TRUE The CPU feature is set in PcdCpuFeaturesSupport. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesSupport. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureSupported ( - IN UINT32 Feature - ) -{ - return IsCpuFeatureSetInCpuPcd ( - (UINT8 *)PcdGetPtr (PcdCpuFeaturesSupport), - PcdGetSize (PcdCpuFeaturesSupport), - Feature - ); -} - -/** - Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesSetting - - @retval TRUE The CPU feature is set in PcdCpuFeaturesSetting. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesSetting. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureInSetting ( - IN UINT32 Feature - ) -{ - return IsCpuFeatureSetInCpuPcd ( - (UINT8 *)PcdGetPtr (PcdCpuFeaturesSetting), - PcdGetSize (PcdCpuFeaturesSetting), - Feature - ); -} - -/** - Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesCapability - - @retval TRUE The CPU feature is set in PcdCpuFeaturesCapability. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesCapability. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureCapability ( - IN UINT32 Feature - ) -{ - return IsCpuFeatureSetInCpuPcd ( - (UINT8 *)PcdGetPtr (PcdCpuFeaturesCapability), - PcdGetSize (PcdCpuFeaturesCapability), - Feature - ); - -} - -/** - Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask. - - @param[in] Feature The bit number of the CPU feature to check in the PCD - PcdCpuFeaturesUserConfiguration - - @retval TRUE The CPU feature is set in PcdCpuFeaturesUserConfiguration. - @retval FALSE The CPU feature is not set in PcdCpuFeaturesUserConfiguration. - - @note This service could be called by BSP only. -**/ -BOOLEAN -EFIAPI -IsCpuFeatureUserConfiguration ( - IN UINT32 Feature - ) -{ - return IsCpuFeatureSetInCpuPcd ( - (UINT8 *)PcdGetPtr (PcdCpuFeaturesUserConfiguration), - PcdGetSize (PcdCpuFeaturesUserConfiguration), - Feature - ); - -} - -/** - Switches to assigned BSP after CPU features initialization. - - @param[in] ProcessorNumber The index of the CPU executing this function. - - @note This service could be called by BSP only. -**/ -VOID -EFIAPI -SwitchBspAfterFeaturesInitialize ( - IN UINTN ProcessorNumber - ) -{ - CPU_FEATURES_DATA *CpuFeaturesData; - - CpuFeaturesData = GetCpuFeaturesData (); - CpuFeaturesData->BspNumber = ProcessorNumber; -} - diff --git a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c deleted file mode 100644 index 714b99eec4..0000000000 --- a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/IpfTimerLib.c +++ /dev/null @@ -1,216 +0,0 @@ -/** @file - Timer Library functions built upon ITC on IPF. - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include - - -/** - Performs a delay measured as number of ticks. - - An internal function to perform a delay measured as number of ticks. It's - invoked by MicroSecondDelay() and NanoSecondDelay(). - - @param Delay The number of ticks to delay. - -**/ -VOID -EFIAPI -InternalIpfDelay ( - IN INT64 Delay - ) -{ - INT64 Ticks; - - // - // The target timer count is calculated here - // - Ticks = (INT64)AsmReadItc () + Delay; - - // - // Wait until time out - // Delay > 2^63 could not be handled by this function - // Timer wrap-arounds are handled correctly by this function - // - while (Ticks - (INT64)AsmReadItc() >= 0); -} - -/** - Stalls the CPU for at least the given number of microseconds. - - Stalls the CPU for the number of microseconds specified by MicroSeconds. - - @param MicroSeconds The minimum number of microseconds to delay. - - @return The value of MicroSeconds inputted. - -**/ -UINTN -EFIAPI -MicroSecondDelay ( - IN UINTN MicroSeconds - ) -{ - InternalIpfDelay ( - GetPerformanceCounterProperties (NULL, NULL) * - MicroSeconds / - 1000000 - ); - return MicroSeconds; -} - -/** - Stalls the CPU for at least the given number of nanoseconds. - - Stalls the CPU for the number of nanoseconds specified by NanoSeconds. - - @param NanoSeconds The minimum number of nanoseconds to delay. - - @return The value of NanoSeconds inputted. - -**/ -UINTN -EFIAPI -NanoSecondDelay ( - IN UINTN NanoSeconds - ) -{ - InternalIpfDelay ( - GetPerformanceCounterProperties (NULL, NULL) * - NanoSeconds / - 1000000000 - ); - return NanoSeconds; -} - -/** - Retrieves the current value of a 64-bit free running performance counter. - - The counter can either count up by 1 or count down by 1. If the physical - performance counter counts by a larger increment, then the counter values - must be translated. The properties of the counter can be retrieved from - GetPerformanceCounterProperties(). - - @return The current value of the free running performance counter. - -**/ -UINT64 -EFIAPI -GetPerformanceCounter ( - VOID - ) -{ - return AsmReadItc (); -} - -/** - Retrieves the 64-bit frequency in Hz and the range of performance counter - values. - - If StartValue is not NULL, then the value that the performance counter starts - with immediately after is it rolls over is returned in StartValue. If - EndValue is not NULL, then the value that the performance counter end with - immediately before it rolls over is returned in EndValue. The 64-bit - frequency of the performance counter in Hz is always returned. If StartValue - is less than EndValue, then the performance counter counts up. If StartValue - is greater than EndValue, then the performance counter counts down. For - example, a 64-bit free running counter that counts up would have a StartValue - of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter - that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. - - @param StartValue The value the performance counter starts with when it - rolls over. - @param EndValue The value that the performance counter ends with before - it rolls over. - - @return The frequency in Hz. - -**/ -UINT64 -EFIAPI -GetPerformanceCounterProperties ( - OUT UINT64 *StartValue, OPTIONAL - OUT UINT64 *EndValue OPTIONAL - ) -{ - PAL_CALL_RETURN PalRet; - UINT64 BaseFrequence; - - if (StartValue != NULL) { - *StartValue = 0; - } - - if (EndValue != NULL) { - *EndValue = (UINT64)(-1); - } - - PalRet = PalCall (PAL_FREQ_BASE, 0, 0, 0); - if (PalRet.Status != 0) { - return 1000000; - } - BaseFrequence = PalRet.r9; - - PalRet = PalCall (PAL_FREQ_RATIOS, 0, 0, 0); - if (PalRet.Status != 0) { - return 1000000; - } - - return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11; -} - -/** - Converts elapsed ticks of performance counter to time in nanoseconds. - - This function converts the elapsed ticks of running performance counter to - time value in unit of nanoseconds. - - @param Ticks The number of elapsed ticks of running performance counter. - - @return The elapsed time in nanoseconds. - -**/ -UINT64 -EFIAPI -GetTimeInNanoSecond ( - IN UINT64 Ticks - ) -{ - UINT64 Frequency; - UINT64 NanoSeconds; - UINT64 Remainder; - INTN Shift; - - Frequency = GetPerformanceCounterProperties (NULL, NULL); - - // - // Ticks - // Time = --------- x 1,000,000,000 - // Frequency - // - NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u); - - // - // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit. - // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34, - // i.e. highest bit set in Remainder should <= 33. - // - Shift = MAX (0, HighBitSet64 (Remainder) - 33); - Remainder = RShiftU64 (Remainder, (UINTN) Shift); - Frequency = RShiftU64 (Frequency, (UINTN) Shift); - NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); - - return NanoSeconds; -} diff --git a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf deleted file mode 100644 index a25e94a61a..0000000000 --- a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf +++ /dev/null @@ -1,67 +0,0 @@ -## @file -# Instance of Timer Library only using CPU resources. -# -# Timer Library that only uses CPU resources to provide calibrated delays -# on IA-32, x64, and IPF. -# Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib -# in their initialization without any issues. They only have to be careful in -# the implementation of runtime services and SMI handlers. -# Because CPU Local APIC and ITC could be programmed by OS, it cannot be -# used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM -# drivers and runtime drivers. -# -# This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in -# that it uses the local APIC library so that it supports x2APIC mode. -# -# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SecPeiDxeTimerLibUefiCpu - MODULE_UNI_FILE = SecPeiDxeTimerLibUefiCpu.uni - FILE_GUID = 4FFF2014-2086-4ee6-9B58-886D1967861C - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib - - -# -# VALID_ARCHITECTURES = IA32 X64 IPF -# - -[Sources.Ia32, Sources.X64] - X86TimerLib.c - -[Sources.IPF] - IpfTimerLib.c - - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - -[LibraryClasses.IA32, LibraryClasses.X64] - PcdLib - DebugLib - LocalApicLib - -[LibraryClasses.IPF] - PalLib - - -[Pcd.IA32, Pcd.X64] - gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## SOMETIMES_CONSUMES - diff --git a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni deleted file mode 100644 index da9e4d8191..0000000000 --- a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.uni +++ /dev/null @@ -1,31 +0,0 @@ -// /** @file -// Instance of Timer Library only using CPU resources. -// -// Timer Library that only uses CPU resources to provide calibrated delays -// on IA-32, x64, and IPF. -// Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib -// in their initialization without any issues. They only have to be careful in -// the implementation of runtime services and SMI handlers. -// Because CPU Local APIC and ITC could be programmed by OS, it cannot be -// used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM -// drivers and runtime drivers. -// -// This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in -// that it uses the local APIC library so that it supports x2APIC mode. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php. -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Instance of Timer Library only using CPU resources" - -#string STR_MODULE_DESCRIPTION #language en-US "Timer Library that only uses CPU resources to provide calibrated delays on IA-32, x64, and IPF. Note: A driver of type DXE_RUNTIME_DRIVER and DXE_SMM_DRIVER can use this TimerLib in their initialization without any issues. They only have to be careful in the implementation of runtime services and SMI handlers. Because CPU Local APIC and ITC could be programmed by OS, it cannot be used by SMM drivers and runtime drivers, ACPI timer is recommended for SMM drivers and runtime drivers. This library differs with the SecPeiDxeTimerLibCpu library in the MdePkg in that it uses the local APIC library so that it supports x2APIC mode." - diff --git a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c b/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c deleted file mode 100644 index f703d7e477..0000000000 --- a/UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/X86TimerLib.c +++ /dev/null @@ -1,266 +0,0 @@ -/** @file - Timer Library functions built upon local APIC on IA32/x64. - - This library uses the local APIC library so that it supports x2APIC mode. - - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include - -/** - Internal function to return the frequency of the local APIC timer. - - @return The frequency of the timer in Hz. - -**/ -UINT32 -EFIAPI -InternalX86GetTimerFrequency ( - VOID - ) -{ - UINTN Divisor; - - GetApicTimerState (&Divisor, NULL, NULL); - return PcdGet32(PcdFSBClock) / (UINT32)Divisor; -} - -/** - Stalls the CPU for at least the given number of ticks. - - Stalls the CPU for at least the given number of ticks. It's invoked by - MicroSecondDelay() and NanoSecondDelay(). - - This function will ASSERT if the APIC timer intial count returned from - GetApicTimerInitCount() is zero. - - @param Delay A period of time to delay in ticks. - -**/ -VOID -EFIAPI -InternalX86Delay ( - IN UINT32 Delay - ) -{ - INT32 Ticks; - UINT32 Times; - UINT32 InitCount; - UINT32 StartTick; - - // - // In case Delay is too larger, separate it into several small delay slot. - // Devided Delay by half value of Init Count is to avoid Delay close to - // the Init Count, timeout maybe missing if the time consuming between 2 - // GetApicTimerCurrentCount() invoking is larger than the time gap between - // Delay and the Init Count. - // - InitCount = GetApicTimerInitCount (); - ASSERT (InitCount != 0); - Times = Delay / (InitCount / 2); - Delay = Delay % (InitCount / 2); - - // - // Get Start Tick and do delay - // - StartTick = GetApicTimerCurrentCount (); - do { - // - // Wait until time out by Delay value - // - do { - CpuPause (); - // - // Get Ticks from Start to Current. - // - Ticks = StartTick - GetApicTimerCurrentCount (); - // - // Ticks < 0 means Timer wrap-arounds happens. - // - if (Ticks < 0) { - Ticks += InitCount; - } - } while ((UINT32)Ticks < Delay); - - // - // Update StartTick and Delay for next delay slot - // - StartTick -= (StartTick > Delay) ? Delay : (Delay - InitCount); - Delay = InitCount / 2; - } while (Times-- > 0); -} - -/** - Stalls the CPU for at least the given number of microseconds. - - Stalls the CPU for the number of microseconds specified by MicroSeconds. - - @param MicroSeconds The minimum number of microseconds to delay. - - @return The value of MicroSeconds inputted. - -**/ -UINTN -EFIAPI -MicroSecondDelay ( - IN UINTN MicroSeconds - ) -{ - InternalX86Delay ( - (UINT32)DivU64x32 ( - MultU64x64 ( - InternalX86GetTimerFrequency (), - MicroSeconds - ), - 1000000u - ) - ); - return MicroSeconds; -} - -/** - Stalls the CPU for at least the given number of nanoseconds. - - Stalls the CPU for the number of nanoseconds specified by NanoSeconds. - - @param NanoSeconds The minimum number of nanoseconds to delay. - - @return The value of NanoSeconds inputted. - -**/ -UINTN -EFIAPI -NanoSecondDelay ( - IN UINTN NanoSeconds - ) -{ - InternalX86Delay ( - (UINT32)DivU64x32 ( - MultU64x64 ( - InternalX86GetTimerFrequency (), - NanoSeconds - ), - 1000000000u - ) - ); - return NanoSeconds; -} - -/** - Retrieves the current value of a 64-bit free running performance counter. - - The counter can either count up by 1 or count down by 1. If the physical - performance counter counts by a larger increment, then the counter values - must be translated. The properties of the counter can be retrieved from - GetPerformanceCounterProperties(). - - @return The current value of the free running performance counter. - -**/ -UINT64 -EFIAPI -GetPerformanceCounter ( - VOID - ) -{ - return (UINT64)GetApicTimerCurrentCount (); -} - -/** - Retrieves the 64-bit frequency in Hz and the range of performance counter - values. - - If StartValue is not NULL, then the value that the performance counter starts - with immediately after is it rolls over is returned in StartValue. If - EndValue is not NULL, then the value that the performance counter end with - immediately before it rolls over is returned in EndValue. The 64-bit - frequency of the performance counter in Hz is always returned. If StartValue - is less than EndValue, then the performance counter counts up. If StartValue - is greater than EndValue, then the performance counter counts down. For - example, a 64-bit free running counter that counts up would have a StartValue - of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter - that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. - - @param StartValue The value the performance counter starts with when it - rolls over. - @param EndValue The value that the performance counter ends with before - it rolls over. - - @return The frequency in Hz. - -**/ -UINT64 -EFIAPI -GetPerformanceCounterProperties ( - OUT UINT64 *StartValue, OPTIONAL - OUT UINT64 *EndValue OPTIONAL - ) -{ - if (StartValue != NULL) { - *StartValue = (UINT64)GetApicTimerInitCount (); - } - - if (EndValue != NULL) { - *EndValue = 0; - } - - return (UINT64) InternalX86GetTimerFrequency (); -} - -/** - Converts elapsed ticks of performance counter to time in nanoseconds. - - This function converts the elapsed ticks of running performance counter to - time value in unit of nanoseconds. - - @param Ticks The number of elapsed ticks of running performance counter. - - @return The elapsed time in nanoseconds. - -**/ -UINT64 -EFIAPI -GetTimeInNanoSecond ( - IN UINT64 Ticks - ) -{ - UINT64 Frequency; - UINT64 NanoSeconds; - UINT64 Remainder; - INTN Shift; - - Frequency = GetPerformanceCounterProperties (NULL, NULL); - - // - // Ticks - // Time = --------- x 1,000,000,000 - // Frequency - // - NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u); - - // - // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit. - // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34, - // i.e. highest bit set in Remainder should <= 33. - // - Shift = MAX (0, HighBitSet64 (Remainder) - 33); - Remainder = RShiftU64 (Remainder, (UINTN) Shift); - Frequency = RShiftU64 (Frequency, (UINTN) Shift); - NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); - - return NanoSeconds; -} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S deleted file mode 100644 index 4c0f8c8933..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.S +++ /dev/null @@ -1,278 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiEntry.S -# -# Abstract: -# -# Code template of the SMI handler for a particular processor -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerTemplate) -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerSize) -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerOffset) -ASM_GLOBAL ASM_PFX(gStmSmiCr3) -ASM_GLOBAL ASM_PFX(gStmSmiStack) -ASM_GLOBAL ASM_PFX(gStmSmbase) -ASM_GLOBAL ASM_PFX(gStmXdSupported) -ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) -ASM_GLOBAL ASM_PFX(gStmSmiHandlerIdtr) - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0xc0000080 -.equ MSR_EFER_XD, 0x800 - -# -# Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -# -.equ DSC_OFFSET, 0xfb00 -.equ DSC_GDTPTR, 0x48 -.equ DSC_GDTSIZ, 0x50 -.equ DSC_CS, 0x14 -.equ DSC_DS, 0x16 -.equ DSC_SS, 0x18 -.equ DSC_OTHERSEG, 0x1A - -.equ PROTECT_MODE_CS, 0x08 -.equ PROTECT_MODE_DS, 0x20 -.equ TSS_SEGMENT, 0x40 - - .text -ASM_PFX(gcStmSmiHandlerTemplate): - -_StmSmiEntryPoint: - .byte 0xbb # mov bx, imm16 - .word _StmGdtDesc - _StmSmiEntryPoint + 0x8000 - .byte 0x2e,0xa1 # mov ax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTSIZ - decl %eax - movl %eax, %cs:(%edi) # mov cs:[bx], ax - .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTPTR - movw %ax, %cs:2(%edi) - movw %ax, %bp # ebp = GDT base - .byte 0x66 - lgdt %cs:(%edi) -# Patch ProtectedMode Segment - .byte 0xb8 # mov ax, imm16 - .word PROTECT_MODE_CS # set AX for segment directly - movl %eax, %cs:-2(%edi) # mov cs:[bx - 2], ax -# Patch ProtectedMode entry - .byte 0x66, 0xbf # mov edi, SMBASE -ASM_PFX(gStmSmbase): .space 4 - .byte 0x67 - lea ((Start32bit - _StmSmiEntryPoint) + 0x8000)(%edi), %ax - movw %ax, %cs:-6(%edi) - movl %cr0, %ebx - .byte 0x66 - andl $0x9ffafff3, %ebx - .byte 0x66 - orl $0x23, %ebx - movl %ebx, %cr0 - .byte 0x66,0xea - .space 4 - .space 2 -_StmGdtDesc: .space 4 - .space 2 - -Start32bit: - movw $PROTECT_MODE_DS, %ax - movl %eax,%ds - movl %eax,%es - movl %eax,%fs - movl %eax,%gs - movl %eax,%ss - .byte 0xbc # mov esp, imm32 -ASM_PFX(gStmSmiStack): .space 4 - movl $ASM_PFX(gStmSmiHandlerIdtr), %eax - lidt (%eax) - jmp ProtFlatMode - -ProtFlatMode: - .byte 0xb8 # mov eax, imm32 -ASM_PFX(gStmSmiCr3): .space 4 - movl %eax, %cr3 -# -# Need to test for CR4 specific bit support -# - movl $1, %eax - cpuid # use CPUID to determine if specific CR4 bits are supported - xorl %eax, %eax # Clear EAX - testl $BIT2, %edx # Check for DE capabilities - jz L8 - orl $BIT3, %eax -L8: - testl $BIT6, %edx # Check for PAE capabilities - jz L9 - orl $BIT5, %eax -L9: - testl $BIT7, %edx # Check for MCE capabilities - jz L10 - orl $BIT6, %eax -L10: - testl $BIT24, %edx # Check for FXSR capabilities - jz L11 - orl $BIT9, %eax -L11: - testl $BIT25, %edx # Check for SSE capabilities - jz L12 - orl $BIT10, %eax -L12: # as cr4.PGE is not set here, refresh cr3 - movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. - - cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) - jz L5 -# Load TSS - movb $0x89, (TSS_SEGMENT + 5)(%ebp) # clear busy flag - movl $TSS_SEGMENT, %eax - ltrw %ax -L5: - -# enable NXE if supported - .byte 0xb0 # mov al, imm8 -ASM_PFX(gStmXdSupported): .byte 1 - cmpb $0, %al - jz SkipXd -# -# Check XD disable bit -# - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - pushl %edx # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr - jmp XdDone -SkipXd: - subl $4, %esp -XdDone: - - movl %cr0, %ebx - orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE - movl %ebx, %cr0 - leal DSC_OFFSET(%edi),%ebx - movw DSC_DS(%ebx),%ax - movl %eax, %ds - movw DSC_OTHERSEG(%ebx),%ax - movl %eax, %es - movl %eax, %fs - movl %eax, %gs - movw DSC_SS(%ebx),%ax - movl %eax, %ss - -CommonHandler: - movl 4(%esp), %ebx - - pushl %ebx - movl $ASM_PFX(CpuSmmDebugEntry), %eax - call *%eax - addl $4, %esp - - pushl %ebx - movl $ASM_PFX(SmiRendezvous), %eax - call *%eax - addl $4, %esp - - pushl %ebx - movl $ASM_PFX(CpuSmmDebugExit), %eax - call *%eax - addl $4, %esp - - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz L16 - popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr - -L16: - rsm - -_StmSmiHandler: -# -# Check XD disable bit -# - xorl %esi, %esi - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz StmXdDone - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L14 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L14: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone: - push %esi - - # below step is needed, because STM does not run above code. - # we have to run below code to set IDT/CR0/CR4 - movl $ASM_PFX(gStmSmiHandlerIdtr), %eax - lidt (%eax) - - movl %cr0, %eax - orl $0x80010023, %eax # enable paging + WP + NE + MP + PE - movl %eax, %cr0 -# -# Need to test for CR4 specific bit support -# - movl $1, %eax - cpuid # use CPUID to determine if specific CR4 bits are supported - movl %cr4, %eax # init EAX - testl $BIT2, %edx # Check for DE capabilities - jz L28 - orl $BIT3, %eax -L28: - testl $BIT6, %edx # Check for PAE capabilities - jz L29 - orl $BIT5, %eax -L29: - testl $BIT7, %edx # Check for MCE capabilities - jz L30 - orl $BIT6, %eax -L30: - testl $BIT24, %edx # Check for FXSR capabilities - jz L31 - orl $BIT9, %eax -L31: - testl $BIT25, %edx # Check for SSE capabilities - jz L32 - orl $BIT10, %eax -L32: # as cr4.PGE is not set here, refresh cr3 - movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. - # STM init finish - jmp CommonHandler - - -ASM_PFX(gcStmSmiHandlerSize) : .word . - _StmSmiEntryPoint -ASM_PFX(gcStmSmiHandlerOffset): .word _StmSmiHandler - _StmSmiEntryPoint - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm deleted file mode 100644 index 94888d5aec..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.asm +++ /dev/null @@ -1,285 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.asm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - - .686p - .model flat,C - .xmm - -MSR_IA32_MISC_ENABLE EQU 1A0h -MSR_EFER EQU 0c0000080h -MSR_EFER_XD EQU 0800h - -; -; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -; -DSC_OFFSET EQU 0fb00h -DSC_GDTPTR EQU 48h -DSC_GDTSIZ EQU 50h -DSC_CS EQU 14h -DSC_DS EQU 16h -DSC_SS EQU 18h -DSC_OTHERSEG EQU 1Ah - -PROTECT_MODE_CS EQU 08h -PROTECT_MODE_DS EQU 20h -TSS_SEGMENT EQU 40h - -SmiRendezvous PROTO C -CpuSmmDebugEntry PROTO C -CpuSmmDebugExit PROTO C - -EXTERNDEF gcStmSmiHandlerTemplate:BYTE -EXTERNDEF gcStmSmiHandlerSize:WORD -EXTERNDEF gcStmSmiHandlerOffset:WORD -EXTERNDEF gStmSmiCr3:DWORD -EXTERNDEF gStmSmiStack:DWORD -EXTERNDEF gStmSmbase:DWORD -EXTERNDEF gStmXdSupported:BYTE -EXTERNDEF FeaturePcdGet (PcdCpuSmmStackGuard):BYTE -EXTERNDEF gStmSmiHandlerIdtr:FWORD - - .code - -gcStmSmiHandlerTemplate LABEL BYTE - -_StmSmiEntryPoint: - DB 0bbh ; mov bx, imm16 - DW offset _StmGdtDesc - _StmSmiEntryPoint + 8000h - DB 2eh, 0a1h ; mov ax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTSIZ - dec eax - mov cs:[edi], eax ; mov cs:[bx], ax - DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTPTR - mov cs:[edi + 2], ax ; mov cs:[bx + 2], eax - mov bp, ax ; ebp = GDT base - DB 66h - lgdt fword ptr cs:[edi] ; lgdt fword ptr cs:[bx] -; Patch ProtectedMode Segment - DB 0b8h ; mov ax, imm16 - DW PROTECT_MODE_CS ; set AX for segment directly - mov cs:[edi - 2], eax ; mov cs:[bx - 2], ax -; Patch ProtectedMode entry - DB 66h, 0bfh ; mov edi, SMBASE -gStmSmbase DD ? - DB 67h - lea ax, [edi + (@32bit - _StmSmiEntryPoint) + 8000h] - mov cs:[edi - 6], ax ; mov cs:[bx - 6], eax - mov ebx, cr0 - DB 66h - and ebx, 9ffafff3h - DB 66h - or ebx, 23h - mov cr0, ebx - DB 66h, 0eah - DD ? - DW ? -_StmGdtDesc FWORD ? - -@32bit: - mov ax, PROTECT_MODE_DS - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - DB 0bch ; mov esp, imm32 -gStmSmiStack DD ? - mov eax, offset gStmSmiHandlerIdtr - lidt fword ptr [eax] - jmp ProtFlatMode - -ProtFlatMode: - DB 0b8h ; mov eax, imm32 -gStmSmiCr3 DD ? - mov cr3, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - xor eax, eax ; Clear EAX - test edx, BIT2 ; Check for DE capabilities - jz @f - or eax, BIT3 -@@: - test edx, BIT6 ; Check for PAE capabilities - jz @f - or eax, BIT5 -@@: - test edx, BIT7 ; Check for MCE capabilities - jz @f - or eax, BIT6 -@@: - test edx, BIT24 ; Check for FXSR capabilities - jz @f - or eax, BIT9 -@@: - test edx, BIT25 ; Check for SSE capabilities - jz @f - or eax, BIT10 -@@: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - - cmp FeaturePcdGet (PcdCpuSmmStackGuard), 0 - jz @F -; Load TSS - mov byte ptr [ebp + TSS_SEGMENT + 5], 89h ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax -@@: - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -gStmXdSupported DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - push edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 4 -@XdDone: - - mov ebx, cr0 - or ebx, 080010023h ; enable paging + WP + NE + MP + PE - mov cr0, ebx - lea ebx, [edi + DSC_OFFSET] - mov ax, [ebx + DSC_DS] - mov ds, eax - mov ax, [ebx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [ebx + DSC_SS] - mov ss, eax - -CommonHandler: - mov ebx, [esp + 4] ; CPU Index - push ebx - mov eax, CpuSmmDebugEntry - call eax - add esp, 4 - - push ebx - mov eax, SmiRendezvous - call eax - add esp, 4 - - push ebx - mov eax, CpuSmmDebugExit - call eax - add esp, 4 - - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @f - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -@@: - rsm - -_StmSmiHandler: -; -; Check XD disable bit -; - xor esi, esi - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @StmXdDone - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone: - push esi - - ; below step is needed, because STM does not run above code. - ; we have to run below code to set IDT/CR0/CR4 - mov eax, offset gStmSmiHandlerIdtr - lidt fword ptr [eax] - - - mov eax, cr0 - or eax, 80010023h ; enable paging + WP + NE + MP + PE - mov cr0, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - mov eax, cr4 ; init EAX - test edx, BIT2 ; Check for DE capabilities - jz @f - or eax, BIT3 -@@: - test edx, BIT6 ; Check for PAE capabilities - jz @f - or eax, BIT5 -@@: - test edx, BIT7 ; Check for MCE capabilities - jz @f - or eax, BIT6 -@@: - test edx, BIT24 ; Check for FXSR capabilities - jz @f - or eax, BIT9 -@@: - test edx, BIT25 ; Check for SSE capabilities - jz @f - or eax, BIT10 -@@: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - ; STM init finish - jmp CommonHandler - -gcStmSmiHandlerSize DW $ - _StmSmiEntryPoint -gcStmSmiHandlerOffset DW _StmSmiHandler - _StmSmiEntryPoint - - END diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm deleted file mode 100644 index b1c84a494f..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm +++ /dev/null @@ -1,271 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.nasm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -; -; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -; -%define DSC_OFFSET 0xfb00 -%define DSC_GDTPTR 0x48 -%define DSC_GDTSIZ 0x50 -%define DSC_CS 0x14 -%define DSC_DS 0x16 -%define DSC_SS 0x18 -%define DSC_OTHERSEG 0x1a - -%define PROTECT_MODE_CS 0x8 -%define PROTECT_MODE_DS 0x20 -%define TSS_SEGMENT 0x40 - -extern ASM_PFX(SmiRendezvous) -extern ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) -extern ASM_PFX(CpuSmmDebugEntry) -extern ASM_PFX(CpuSmmDebugExit) - -global ASM_PFX(gcStmSmiHandlerTemplate) -global ASM_PFX(gcStmSmiHandlerSize) -global ASM_PFX(gcStmSmiHandlerOffset) -global ASM_PFX(gStmSmiCr3) -global ASM_PFX(gStmSmiStack) -global ASM_PFX(gStmSmbase) -global ASM_PFX(gStmXdSupported) -extern ASM_PFX(gStmSmiHandlerIdtr) - - SECTION .text - -BITS 16 -ASM_PFX(gcStmSmiHandlerTemplate): -_StmSmiEntryPoint: - mov bx, _StmGdtDesc - _StmSmiEntryPoint + 0x8000 - mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] - dec ax - mov [cs:bx], ax - mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] - mov [cs:bx + 2], eax - mov ebp, eax ; ebp = GDT base -o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] - mov ax, PROTECT_MODE_CS - mov [cs:bx-0x2],ax - DB 0x66, 0xbf ; mov edi, SMBASE -ASM_PFX(gStmSmbase): DD 0 - lea eax, [edi + (@32bit - _StmSmiEntryPoint) + 0x8000] - mov [cs:bx-0x6],eax - mov ebx, cr0 - and ebx, 0x9ffafff3 - or ebx, 0x23 - mov cr0, ebx - jmp dword 0x0:0x0 -_StmGdtDesc: - DW 0 - DD 0 - -BITS 32 -@32bit: - mov ax, PROTECT_MODE_DS -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax - DB 0xbc ; mov esp, imm32 -ASM_PFX(gStmSmiStack): DD 0 - mov eax, ASM_PFX(gStmSmiHandlerIdtr) - lidt [eax] - jmp ProtFlatMode - -ProtFlatMode: - DB 0xb8 ; mov eax, imm32 -ASM_PFX(gStmSmiCr3): DD 0 - mov cr3, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - xor eax, eax ; Clear EAX - test edx, BIT2 ; Check for DE capabilities - jz .0 - or eax, BIT3 -.0: - test edx, BIT6 ; Check for PAE capabilities - jz .1 - or eax, BIT5 -.1: - test edx, BIT7 ; Check for MCE capabilities - jz .2 - or eax, BIT6 -.2: - test edx, BIT24 ; Check for FXSR capabilities - jz .3 - or eax, BIT9 -.3: - test edx, BIT25 ; Check for SSE capabilities - jz .4 - or eax, BIT10 -.4: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - - cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))], 0 - jz .6 -; Load TSS - mov byte [ebp + TSS_SEGMENT + 5], 0x89 ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax -.6: - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -ASM_PFX(gStmXdSupported): DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - push edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .5 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.5: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 4 -@XdDone: - - mov ebx, cr0 - or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, ebx - lea ebx, [edi + DSC_OFFSET] - mov ax, [ebx + DSC_DS] - mov ds, eax - mov ax, [ebx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [ebx + DSC_SS] - mov ss, eax - -CommonHandler: - mov ebx, [esp + 4] ; CPU Index - push ebx - mov eax, ASM_PFX(CpuSmmDebugEntry) - call eax - add esp, 4 - - push ebx - mov eax, ASM_PFX(SmiRendezvous) - call eax - add esp, 4 - - push ebx - mov eax, ASM_PFX(CpuSmmDebugExit) - call eax - add esp, 4 - - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz .7 - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .7 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.7: - rsm - - -_StmSmiHandler: -; -; Check XD disable bit -; - xor esi, esi - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz @StmXdDone - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .5 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.5: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone: - push esi - - ; below step is needed, because STM does not run above code. - ; we have to run below code to set IDT/CR0/CR4 - mov eax, ASM_PFX(gStmSmiHandlerIdtr) - lidt [eax] - - mov eax, cr0 - or eax, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - mov eax, cr4 ; init EAX - test edx, BIT2 ; Check for DE capabilities - jz .0 - or eax, BIT3 -.0: - test edx, BIT6 ; Check for PAE capabilities - jz .1 - or eax, BIT5 -.1: - test edx, BIT7 ; Check for MCE capabilities - jz .2 - or eax, BIT6 -.2: - test edx, BIT24 ; Check for FXSR capabilities - jz .3 - or eax, BIT9 -.3: - test edx, BIT25 ; Check for SSE capabilities - jz .4 - or eax, BIT10 -.4: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - ; STM init finish - jmp CommonHandler - -ASM_PFX(gcStmSmiHandlerSize) : DW $ - _StmSmiEntryPoint -ASM_PFX(gcStmSmiHandlerOffset) : DW _StmSmiHandler - _StmSmiEntryPoint - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S deleted file mode 100644 index 7d0057af80..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.S +++ /dev/null @@ -1,174 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiException.S -# -# Abstract: -# -# Exception handlers used in SM mode -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcStmPsd) - -ASM_GLOBAL ASM_PFX(SmmStmExceptionHandler) -ASM_GLOBAL ASM_PFX(SmmStmSetup) -ASM_GLOBAL ASM_PFX(SmmStmTeardown) - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0xc0000080 -.equ MSR_EFER_XD, 0x800 - -.equ CODE_SEL, 0x08 -.equ DATA_SEL, 0x20 -.equ TSS_SEL, 0x40 - - .data - -ASM_PFX(gcStmPsd): - .ascii "TXTPSSIG" - .word PSD_SIZE - .word 1 # Version - .long 0 # LocalApicId - .byte 0x5 # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - .byte 0 # BIOS to STM - .byte 0 # STM to BIOS - .byte 0 - .word CODE_SEL - .word DATA_SEL - .word DATA_SEL - .word DATA_SEL - .word TSS_SEL - .word 0 - .quad 0 # SmmCr3 - .long ASM_PFX(_OnStmSetup) - .long 0 - .long ASM_PFX(_OnStmTeardown) - .long 0 - .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint - .quad 0 # SmmSmiHandlerRsp - .quad 0 - .long 0 - .long 0x80010100 # RequiredStmSmmRevId - .long ASM_PFX(_OnException) - .long 0 - .quad 0 # ExceptionStack - .word DATA_SEL - .word 0x1F # ExceptionFilter - .long 0 - .quad 0 - .quad 0 # BiosHwResourceRequirementsPtr - .quad 0 # AcpiRsdp - .byte 0 # PhysicalAddressBits -.equ PSD_SIZE, . - ASM_PFX(gcStmPsd) - - .text - -#------------------------------------------------------------------------------ -# SMM Exception handlers -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(_OnException) -ASM_PFX(_OnException): - movl %esp, %ecx - pushl %ecx - call ASM_PFX(SmmStmExceptionHandler) - addl $4, %esp - - movl %eax, %ebx - movl $4, %eax - .byte 0xf, 0x1, 0xc1 # VMCALL - jmp . - -ASM_GLOBAL ASM_PFX(_OnStmSetup) -ASM_PFX(_OnStmSetup): -# -# Check XD disable bit -# - xorl %esi, %esi - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz StmXdDone1 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone1: - push %esi - - call ASM_PFX(SmmStmSetup) - - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz L14 - popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L14 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr -L14: - - rsm - -ASM_GLOBAL ASM_PFX(_OnStmTeardown) -ASM_PFX(_OnStmTeardown): -# -# Check XD disable bit -# - xorl %esi, %esi - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz StmXdDone2 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L15 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L15: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone2: - push %esi - - call ASM_PFX(SmmStmTeardown) - - movl $ASM_PFX(gStmXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz L16 - popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr -L16: - - rsm diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm deleted file mode 100644 index 7c04ad91f2..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.asm +++ /dev/null @@ -1,170 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.asm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - - .686p - .model flat,C - -EXTERNDEF gcStmPsd:BYTE - -EXTERNDEF SmmStmExceptionHandler:PROC -EXTERNDEF SmmStmSetup:PROC -EXTERNDEF SmmStmTeardown:PROC - -CODE_SEL = 08h -DATA_SEL = 20h -TSS_SEL = 40h - - .data - -gcStmPsd LABEL BYTE - DB 'TXTPSSIG' - DW PSD_SIZE - DW 1 ; Version - DD 0 ; LocalApicId - DB 05h ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - DB 0 ; BIOS to STM - DB 0 ; STM to BIOS - DB 0 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW TSS_SEL - DW 0 - DQ 0 ; SmmCr3 - DQ _OnStmSetup - DQ _OnStmTeardown - DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint - DQ 0 ; SmmSmiHandlerRsp - DQ 0 - DD 0 - DD 80010100h ; RequiredStmSmmRevId - DQ _OnException - DQ 0 ; ExceptionStack - DW DATA_SEL - DW 01Fh ; ExceptionFilter - DD 0 - DQ 0 - DQ 0 ; BiosHwResourceRequirementsPtr - DQ 0 ; AcpiRsdp - DB 0 ; PhysicalAddressBits -PSD_SIZE = $ - offset gcStmPsd - - .code -;------------------------------------------------------------------------------ -; SMM Exception handlers -;------------------------------------------------------------------------------ -_OnException PROC - mov ecx, esp - push ecx - call SmmStmExceptionHandler - add esp, 4 - - mov ebx, eax - mov eax, 4 - DB 0fh, 01h, 0c1h ; VMCALL - jmp $ -_OnException ENDP - -_OnStmSetup PROC -; -; Check XD disable bit -; - xor esi, esi - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @StmXdDone1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone1: - push esi - - call SmmStmSetup - - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @f - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr -@@: - - rsm -_OnStmSetup ENDP - -_OnStmTeardown PROC -; -; Check XD disable bit -; - xor esi, esi - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @StmXdDone2 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone2: - push esi - - call SmmStmTeardown - - mov eax, gStmXdSupported - mov al, [eax] - cmp al, 0 - jz @f - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr -@@: - - rsm -_OnStmTeardown ENDP - - END diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm deleted file mode 100644 index 0ce8501ba9..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm +++ /dev/null @@ -1,176 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.nasm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -global ASM_PFX(gcStmPsd) - -extern ASM_PFX(SmmStmExceptionHandler) -extern ASM_PFX(SmmStmSetup) -extern ASM_PFX(SmmStmTeardown) -extern ASM_PFX(gStmXdSupported) -extern ASM_PFX(gStmSmiHandlerIdtr) - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -CODE_SEL equ 0x08 -DATA_SEL equ 0x20 -TSS_SEL equ 0x40 - - SECTION .data - -ASM_PFX(gcStmPsd): - DB 'TXTPSSIG' - DW PSD_SIZE - DW 1 ; Version - DD 0 ; LocalApicId - DB 0x05 ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - DB 0 ; BIOS to STM - DB 0 ; STM to BIOS - DB 0 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW TSS_SEL - DW 0 - DQ 0 ; SmmCr3 - DD ASM_PFX(OnStmSetup) - DD 0 - DD ASM_PFX(OnStmTeardown) - DD 0 - DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint - DQ 0 ; SmmSmiHandlerRsp - DQ 0 - DD 0 - DD 0x80010100 ; RequiredStmSmmRevId - DD ASM_PFX(OnException) - DD 0 - DQ 0 ; ExceptionStack - DW DATA_SEL - DW 0x01F ; ExceptionFilter - DD 0 - DD 0 - DD 0 - DQ 0 ; BiosHwResourceRequirementsPtr - DQ 0 ; AcpiRsdp - DB 0 ; PhysicalAddressBits -PSD_SIZE equ $ - ASM_PFX(gcStmPsd) - - SECTION .text -;------------------------------------------------------------------------------ -; SMM Exception handlers -;------------------------------------------------------------------------------ -global ASM_PFX(OnException) -ASM_PFX(OnException): - mov ecx, esp - push ecx - call ASM_PFX(SmmStmExceptionHandler) - add esp, 4 - - mov ebx, eax - mov eax, 4 - DB 0x0f, 0x01, 0x0c1 ; VMCALL - jmp $ - -global ASM_PFX(OnStmSetup) -ASM_PFX(OnStmSetup): -; -; Check XD disable bit -; - xor esi, esi - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz @StmXdDone1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .51 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.51: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone1: - push esi - - call ASM_PFX(SmmStmSetup) - - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz .71 - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .71 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.71: - rsm - -global ASM_PFX(OnStmTeardown) -ASM_PFX(OnStmTeardown): -; -; Check XD disable bit -; - xor esi, esi - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz @StmXdDone2 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .52 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.52: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone2: - push esi - - call ASM_PFX(SmmStmTeardown) - - mov eax, ASM_PFX(gStmXdSupported) - mov al, [eax] - cmp al, 0 - jz .72 - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .72 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.72: - rsm - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c deleted file mode 100644 index 0154c7c0f8..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c +++ /dev/null @@ -1,83 +0,0 @@ -/** @file - SMM STM support functions - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "SmmStm.h" - -/// -/// Page Table Entry -/// -#define IA32_PG_P BIT0 -#define IA32_PG_RW BIT1 -#define IA32_PG_PS BIT7 - -/** - - Create 4G page table for STM. - 4M Non-PAE page table in IA32 version. - - @param PageTableBase The page table base in MSEG - -**/ -VOID -StmGen4GPageTable ( - IN UINTN PageTableBase - ) -{ - UINTN Index; - UINT32 *Pte; - UINT32 Address; - - Pte = (UINT32*)(UINTN)PageTableBase; - - Address = 0; - for (Index = 0; Index < SIZE_4KB / sizeof (*Pte); Index++) { - *Pte = Address | IA32_PG_PS | IA32_PG_RW | IA32_PG_P; - Pte++; - Address += SIZE_4MB; - } -} - -/** - This is SMM exception handle. - Consumed by STM when exception happen. - - @param Context STM protection exception stack frame - - @return the EBX value for STM reference. - EBX = 0: resume SMM guest using register state found on exception stack. - EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the - TXT.ERRORCODE register and subsequently reset the system via - TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as - follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC - EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. - -**/ -UINT32 -EFIAPI -SmmStmExceptionHandler ( - IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context - ) -{ - // TBD - SmmStmExceptionHandler, record information - DEBUG ((DEBUG_ERROR, "SmmStmExceptionHandler ...\n")); - // - // Skip this instruction and continue; - // - Context.Ia32StackFrame->Rip += Context.Ia32StackFrame->VmcsExitInstructionLength; - - return 0; -} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c deleted file mode 100644 index 079baa4ae1..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ /dev/null @@ -1,630 +0,0 @@ -/** @file -The CPU specific programming for PiSmmCpuDxeSmm module. - -Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// Machine Specific Registers (MSRs) -// -#define SMM_FEATURES_LIB_IA32_MTRR_CAP 0x0FE -#define SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A -#define SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE 0x1F2 -#define SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK 0x1F3 -#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE 0x0A0 -#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK 0x0A1 -#define EFI_MSR_SMRR_MASK 0xFFFFF000 -#define EFI_MSR_SMRR_PHYS_MASK_VALID BIT11 -#define SMM_FEATURES_LIB_SMM_FEATURE_CONTROL 0x4E0 - -// -// MSRs required for configuration of SMM Code Access Check -// -#define SMM_FEATURES_LIB_IA32_MCA_CAP 0x17D -#define SMM_CODE_ACCESS_CHK_BIT BIT58 - -/** - Internal worker function that is called to complete CPU initialization at the - end of SmmCpuFeaturesInitializeProcessor(). - -**/ -VOID -FinishSmmCpuFeaturesInitializeProcessor ( - VOID - ); - -// -// Set default value to assume SMRR is not supported -// -BOOLEAN mSmrrSupported = FALSE; - -// -// Set default value to assume MSR_SMM_FEATURE_CONTROL is not supported -// -BOOLEAN mSmmFeatureControlSupported = FALSE; - -// -// Set default value to assume IA-32 Architectural MSRs are used -// -UINT32 mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE; -UINT32 mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK; - -// -// Set default value to assume MTRRs need to be configured on each SMI -// -BOOLEAN mNeedConfigureMtrrs = TRUE; - -// -// Array for state of SMRR enable on all CPUs -// -BOOLEAN *mSmrrEnabled; - -/** - The constructor function - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - UINT32 RegEax; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - - // - // Retrieve CPU Family and Model - // - AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); - FamilyId = (RegEax >> 8) & 0xf; - ModelId = (RegEax >> 4) & 0xf; - if (FamilyId == 0x06 || FamilyId == 0x0f) { - ModelId = ModelId | ((RegEax >> 12) & 0xf0); - } - - // - // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability - // - if ((RegEdx & BIT12) != 0) { - // - // Check MTRR_CAP MSR bit 11 for SMRR support - // - if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) != 0) { - mSmrrSupported = TRUE; - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Family - // - // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then - // SMRR Physical Base and SMM Physical Mask MSRs are not available. - // - if (FamilyId == 0x06) { - if (ModelId == 0x1C || ModelId == 0x26 || ModelId == 0x27 || ModelId == 0x35 || ModelId == 0x36) { - mSmrrSupported = FALSE; - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family - // - // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2 - // Processor Family MSRs - // - if (FamilyId == 0x06) { - if (ModelId == 0x17 || ModelId == 0x0f) { - mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE; - mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK; - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 34.4.2 SMRAM Caching - // An IA-32 processor does not automatically write back and invalidate its - // caches before entering SMM or before exiting SMM. Because of this behavior, - // care must be taken in the placement of the SMRAM in system memory and in - // the caching of the SMRAM to prevent cache incoherence when switching back - // and forth between SMM and protected mode operation. - // - // An IA-32 processor is a processor that does not support the Intel 64 - // Architecture. Support for the Intel 64 Architecture can be detected from - // CPUID(CPUID_EXTENDED_CPU_SIG).EDX[29] - // - // If an IA-32 processor is detected, then set mNeedConfigureMtrrs to TRUE, - // so caches are flushed on SMI entry and SMI exit, the interrupted code - // MTRRs are saved/restored, and MTRRs for SMM are loaded. - // - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax >= CPUID_EXTENDED_CPU_SIG) { - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT29) != 0) { - mNeedConfigureMtrrs = FALSE; - } - } - - // - // Allocate array for state of SMRR enable on all CPUs - // - mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); - ASSERT (mSmrrEnabled != NULL); - - return EFI_SUCCESS; -} - -/** - Called during the very first SMI into System Management Mode to initialize - CPU features, including SMBASE, for the currently executing CPU. Since this - is the first SMI, the SMRAM Save State Map is at the default address of - SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executing - CPU is specified by CpuIndex and CpuIndex can be used to access information - about the currently executing CPU in the ProcessorInfo array and the - HotPlugCpuData data structure. - - @param[in] CpuIndex The index of the CPU to initialize. The value - must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU that - was elected as monarch during System Management - Mode initialization. - FALSE if the CpuIndex is not the index of the CPU - that was elected as monarch during System - Management Mode initialization. - @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMATION - structures. ProcessorInfo[CpuIndex] contains the - information for the currently executing CPU. - @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure that - contains the ApidId and SmBase arrays. -**/ -VOID -EFIAPI -SmmCpuFeaturesInitializeProcessor ( - IN UINTN CpuIndex, - IN BOOLEAN IsMonarch, - IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, - IN CPU_HOT_PLUG_DATA *CpuHotPlugData - ) -{ - SMRAM_SAVE_STATE_MAP *CpuState; - UINT64 FeatureControl; - UINT32 RegEax; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - - // - // Configure SMBASE. - // - CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); - CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family - // - // If Intel(R) Core(TM) Core(TM) 2 Processor Family MSRs are being used, then - // make sure SMRR Enable(BIT3) of MSR_FEATURE_CONTROL MSR(0x3A) is set before - // accessing SMRR base/mask MSRs. If Lock(BIT0) of MSR_FEATURE_CONTROL MSR(0x3A) - // is set, then the MSR is locked and can not be modified. - // - if (mSmrrSupported && mSmrrPhysBaseMsr == SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE) { - FeatureControl = AsmReadMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL); - if ((FeatureControl & BIT3) == 0) { - if ((FeatureControl & BIT0) == 0) { - AsmWriteMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL, FeatureControl | BIT3); - } else { - mSmrrSupported = FALSE; - } - } - } - - // - // If SMRR is supported, then program SMRR base/mask MSRs. - // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first normal SMI. - // The code that initializes SMM environment is running in normal mode - // from SMRAM region. If SMRR is enabled here, then the SMRAM region - // is protected and the normal mode code execution will fail. - // - if (mSmrrSupported) { - // - // SMRR size cannot be less than 4-KBytes - // SMRR size must be of length 2^n - // SMRR base alignment cannot be less than SMRR length - // - if ((CpuHotPlugData->SmrrSize < SIZE_4KB) || - (CpuHotPlugData->SmrrSize != GetPowerOfTwo32 (CpuHotPlugData->SmrrSize)) || - ((CpuHotPlugData->SmrrBase & ~(CpuHotPlugData->SmrrSize - 1)) != CpuHotPlugData->SmrrBase)) { - // - // Print message and halt if CPU is Monarch - // - if (IsMonarch) { - DEBUG ((DEBUG_ERROR, "SMM Base/Size does not meet alignment/size requirement!\n")); - CpuDeadLoop (); - } - } else { - AsmWriteMsr64 (mSmrrPhysBaseMsr, CpuHotPlugData->SmrrBase | MTRR_CACHE_WRITE_BACK); - AsmWriteMsr64 (mSmrrPhysMaskMsr, (~(CpuHotPlugData->SmrrSize - 1) & EFI_MSR_SMRR_MASK)); - mSmrrEnabled[CpuIndex] = FALSE; - } - } - - // - // Retrieve CPU Family and Model - // - AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); - FamilyId = (RegEax >> 8) & 0xf; - ModelId = (RegEax >> 4) & 0xf; - if (FamilyId == 0x06 || FamilyId == 0x0f) { - ModelId = ModelId | ((RegEax >> 12) & 0xf0); - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.10.1 MSRs in 4th Generation Intel(R) Core(TM) - // Processor Family. - // - // If CPU Family/Model is 06_3C, 06_45, or 06_46 then use 4th Generation - // Intel(R) Core(TM) Processor Family MSRs. - // - if (FamilyId == 0x06) { - if (ModelId == 0x3C || ModelId == 0x45 || ModelId == 0x46) { - // - // Check to see if the CPU supports the SMM Code Access Check feature - // Do not access this MSR unless the CPU supports the SmmRegFeatureControl - // - if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) != 0) { - mSmmFeatureControlSupported = TRUE; - } - } - } - - // - // Call internal worker function that completes the CPU initialization - // - FinishSmmCpuFeaturesInitializeProcessor (); -} - -/** - This function updates the SMRAM save state on the currently executing CPU - to resume execution at a specific address after an RSM instruction. This - function must evaluate the SMRAM save state to determine the execution mode - the RSM instruction resumes and update the resume execution address with - either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart - flag in the SMRAM save state must always be cleared. This function returns - the value of the instruction pointer from the SMRAM save state that was - replaced. If this function returns 0, then the SMRAM save state was not - modified. - - This function is called during the very first SMI on each CPU after - SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode - to signal that the SMBASE of each CPU has been updated before the default - SMBASE address is used for the first SMI to the next CPU. - - @param[in] CpuIndex The index of the CPU to hook. The value - must be between 0 and the NumberOfCpus - field in the System Management System Table - (SMST). - @param[in] CpuState Pointer to SMRAM Save State Map for the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to - 32-bit execution mode from 64-bit SMM. - @param[in] NewInstructionPointer Instruction pointer to use if resuming to - same execution mode as SMM. - - @retval 0 This function did modify the SMRAM save state. - @retval > 0 The original instruction pointer value from the SMRAM save state - before it was replaced. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesHookReturnFromSmm ( - IN UINTN CpuIndex, - IN SMRAM_SAVE_STATE_MAP *CpuState, - IN UINT64 NewInstructionPointer32, - IN UINT64 NewInstructionPointer - ) -{ - return 0; -} - -/** - Hook point in normal execution mode that allows the one CPU that was elected - as monarch during System Management Mode initialization to perform additional - initialization actions immediately after all of the CPUs have processed their - first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE - into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). -**/ -VOID -EFIAPI -SmmCpuFeaturesSmmRelocationComplete ( - VOID - ) -{ -} - -/** - Determines if MTRR registers must be configured to set SMRAM cache-ability - when executing in System Management Mode. - - @retval TRUE MTRR registers must be configured to set SMRAM cache-ability. - @retval FALSE MTRR registers do not need to be configured to set SMRAM - cache-ability. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesNeedConfigureMtrrs ( - VOID - ) -{ - return mNeedConfigureMtrrs; -} - -/** - Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesDisableSmrr ( - VOID - ) -{ - if (mSmrrSupported && mNeedConfigureMtrrs) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64(mSmrrPhysMaskMsr) & ~EFI_MSR_SMRR_PHYS_MASK_VALID); - } -} - -/** - Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesReenableSmrr ( - VOID - ) -{ - if (mSmrrSupported && mNeedConfigureMtrrs) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64(mSmrrPhysMaskMsr) | EFI_MSR_SMRR_PHYS_MASK_VALID); - } -} - -/** - Processor specific hook point each time a CPU enters System Management Mode. - - @param[in] CpuIndex The index of the CPU that has entered SMM. The value - must be between 0 and the NumberOfCpus field in the - System Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousEntry ( - IN UINTN CpuIndex - ) -{ - // - // If SMRR is supported and this is the first normal SMI, then enable SMRR - // - if (mSmrrSupported && !mSmrrEnabled[CpuIndex]) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI_MSR_SMRR_PHYS_MASK_VALID); - mSmrrEnabled[CpuIndex] = TRUE; - } -} - -/** - Processor specific hook point each time a CPU exits System Management Mode. - - @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must - be between 0 and the NumberOfCpus field in the System - Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousExit ( - IN UINTN CpuIndex - ) -{ -} - -/** - Check to see if an SMM register is supported by a specified CPU. - - @param[in] CpuIndex The index of the CPU to check for SMM register support. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to check for support. - - @retval TRUE The SMM register specified by RegName is supported by the CPU - specified by CpuIndex. - @retval FALSE The SMM register specified by RegName is not supported by the - CPU specified by CpuIndex. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesIsSmmRegisterSupported ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { - return TRUE; - } - return FALSE; -} - -/** - Returns the current value of the SMM register for the specified CPU. - If the SMM register is not supported, then 0 is returned. - - @param[in] CpuIndex The index of the CPU to read the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to read. - - @return The value of the SMM register specified by RegName from the CPU - specified by CpuIndex. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesGetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { - return AsmReadMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL); - } - return 0; -} - -/** - Sets the value of an SMM register on a specified CPU. - If the SMM register is not supported, then no action is performed. - - @param[in] CpuIndex The index of the CPU to write the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to write. - registers are read-only. - @param[in] Value The value to write to the SMM register. -**/ -VOID -EFIAPI -SmmCpuFeaturesSetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName, - IN UINT64 Value - ) -{ - if (mSmmFeatureControlSupported && RegName == SmmRegFeatureControl) { - AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value); - } -} - -/** - Read an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for reading the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to read the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to read. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read - from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support reading Register. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Writes an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for writing the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to write the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to write. - @param[in] Width The number of bytes to write to the CPU save state. - @param[in] Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written to Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support writing Register. -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesWriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** - This function is hook point called after the gEfiSmmReadyToLockProtocolGuid - notification is completely processed. -**/ -VOID -EFIAPI -SmmCpuFeaturesCompleteSmmReadyToLock ( - VOID - ) -{ -} - -/** - This API provides a method for a CPU to allocate a specific region for storing page tables. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the request, then NULL is - returned. - - This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer for page tables. - @retval NULL Fail to allocate a specific region for storing page tables, - Or there is no preference on where the page tables are allocated in SMRAM. - -**/ -VOID * -EFIAPI -SmmCpuFeaturesAllocatePageTableMemory ( - IN UINTN Pages - ) -{ - return NULL; -} - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf deleted file mode 100644 index 77908b0366..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# The CPU specific programming for PiSmmCpuDxeSmm module. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmCpuFeaturesLib - MODULE_UNI_FILE = SmmCpuFeaturesLib.uni - FILE_GUID = FC3DC10D-D271-422a-AFF3-CBCF70344431 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmmCpuFeaturesLib - CONSTRUCTOR = SmmCpuFeaturesLibConstructor - -[Sources] - SmmCpuFeaturesLib.c - SmmCpuFeaturesLibNoStm.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - PcdLib - MemoryAllocationLib - DebugLib - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni deleted file mode 100644 index 322aa8bb5a..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// The CPU specific programming for PiSmmCpuDxeSmm module. -// -// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "The CPU specific programming for PiSmmCpuDxeSmm module." - -#string STR_MODULE_DESCRIPTION #language en-US "The CPU specific programming for PiSmmCpuDxeSmm module." diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c deleted file mode 100644 index 5276856797..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c +++ /dev/null @@ -1,89 +0,0 @@ -/** @file -The CPU specific programming for PiSmmCpuDxeSmm module when STM support -is not included. - -Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -/** - Internal worker function that is called to complete CPU initialization at the - end of SmmCpuFeaturesInitializeProcessor(). - -**/ -VOID -FinishSmmCpuFeaturesInitializeProcessor ( - VOID - ) -{ -} - -/** - Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is - returned, then a custom SMI handler is not provided by this library, - and the default SMI handler must be used. - - @retval 0 Use the default SMI handler. - @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() - The caller is required to allocate enough SMRAM for each CPU to - support the size of the custom SMI handler. -**/ -UINTN -EFIAPI -SmmCpuFeaturesGetSmiHandlerSize ( - VOID - ) -{ - return 0; -} - -/** - Install a custom SMI handler for the CPU specified by CpuIndex. This function - is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater - than zero and is called by the CPU that was elected as monarch during System - Management Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -SmmCpuFeaturesInstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ) -{ -} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf deleted file mode 100644 index db8dcdcff4..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ /dev/null @@ -1,88 +0,0 @@ -## @file -# The CPU specific programming for PiSmmCpuDxeSmm module when STM support -# is included. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmCpuFeaturesLibStm - MODULE_UNI_FILE = SmmCpuFeaturesLib.uni - FILE_GUID = 374DE830-81C5-4CC8-B2AB-28F0AB73710B - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmmCpuFeaturesLib - CONSTRUCTOR = SmmCpuFeaturesLibStmConstructor - -[Sources] - SmmCpuFeaturesLib.c - SmmStm.c - SmmStm.h - -[Sources.Ia32] - Ia32/SmmStmSupport.c - - Ia32/SmiEntry.asm - Ia32/SmiException.asm - - Ia32/SmiEntry.nasm - Ia32/SmiException.nasm - - Ia32/SmiEntry.S - Ia32/SmiException.S - -[Sources.X64] - X64/SmmStmSupport.c - - X64/SmiEntry.asm - X64/SmiException.asm - - X64/SmiEntry.nasm - X64/SmiException.nasm - - X64/SmiEntry.S - X64/SmiException.S - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - PcdLib - HobLib - MemoryAllocationLib - DebugLib - UefiBootServicesTableLib - SmmServicesTableLib - TpmMeasurementLib - -[Protocols] - gEfiMpServiceProtocolGuid ## CONSUMES - gEfiSmmEndOfDxeProtocolGuid ## CONSUMES - gEfiSmMonitorInitProtocolGuid ## PRODUCES - -[Guids] - gMsegSmramGuid ## SOMETIMES_CONSUMES ## HOB - gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuMsegSize ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStmExceptionStackSize ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES - -[Depex] - gEfiMpServiceProtocolGuid diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c deleted file mode 100644 index 03937dcbe2..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c +++ /dev/null @@ -1,1299 +0,0 @@ -/** @file - SMM STM support functions - - Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "SmmStm.h" - -#define TXT_EVTYPE_BASE 0x400 -#define TXT_EVTYPE_STM_HASH (TXT_EVTYPE_BASE + 14) - -#define RDWR_ACCS 3 -#define FULL_ACCS 7 - -/** - The constructor function - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -EFI_HANDLE mStmSmmCpuHandle = NULL; - -BOOLEAN mLockLoadMonitor = FALSE; - -// -// Template of STM_RSC_END structure for copying. -// -GLOBAL_REMOVE_IF_UNREFERENCED STM_RSC_END mRscEndNode = { - {END_OF_RESOURCES, sizeof (STM_RSC_END)}, -}; - -GLOBAL_REMOVE_IF_UNREFERENCED UINT8 *mStmResourcesPtr = NULL; -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceTotalSize = 0x0; -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeUsed = 0x0; -GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeAvailable = 0x0; - -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mStmState = 0; - -// -// System Configuration Table pointing to STM Configuration Table -// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_SM_MONITOR_INIT_PROTOCOL mSmMonitorInitProtocol = { - LoadMonitor, - AddPiResource, - DeletePiResource, - GetPiResource, - GetMonitorState, -}; - - - - -#define CPUID1_EDX_XD_SUPPORT 0x100000 - -// -// External global variables associated with SMI Handler Template -// -extern CONST TXT_PROCESSOR_SMM_DESCRIPTOR gcStmPsd; -extern UINT32 gStmSmbase; -extern volatile UINT32 gStmSmiStack; -extern UINT32 gStmSmiCr3; -extern volatile UINT8 gcStmSmiHandlerTemplate[]; -extern CONST UINT16 gcStmSmiHandlerSize; -extern UINT16 gcStmSmiHandlerOffset; -extern BOOLEAN gStmXdSupported; - -// -// Variables used by SMI Handler -// -IA32_DESCRIPTOR gStmSmiHandlerIdtr; - -// -// MP Services Protocol -// -EFI_MP_SERVICES_PROTOCOL *mSmmCpuFeaturesLibMpService = NULL; - -// -// MSEG Base and Length in SMRAM -// -UINTN mMsegBase = 0; -UINTN mMsegSize = 0; - -BOOLEAN mStmConfigurationTableInitialized = FALSE; - - -/** - The constructor function - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibStmConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - CPUID_VERSION_INFO_ECX RegEcx; - EFI_HOB_GUID_TYPE *GuidHob; - EFI_SMRAM_DESCRIPTOR *SmramDescriptor; - - // - // Call the common constructor function - // - Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable); - ASSERT_EFI_ERROR (Status); - - // - // Lookup the MP Services Protocol - // - Status = gBS->LocateProtocol ( - &gEfiMpServiceProtocolGuid, - NULL, - (VOID **)&mSmmCpuFeaturesLibMpService - ); - ASSERT_EFI_ERROR (Status); - - // - // If CPU supports VMX, then determine SMRAM range for MSEG. - // - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &RegEcx.Uint32, NULL); - if (RegEcx.Bits.VMX == 1) { - GuidHob = GetFirstGuidHob (&gMsegSmramGuid); - if (GuidHob != NULL) { - // - // Retrieve MSEG location from MSEG SRAM HOB - // - SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); - if (SmramDescriptor->PhysicalSize > 0) { - mMsegBase = (UINTN)SmramDescriptor->CpuStart; - mMsegSize = (UINTN)SmramDescriptor->PhysicalSize; - } - } else if (PcdGet32 (PcdCpuMsegSize) > 0) { - // - // Allocate MSEG from SMRAM memory - // - mMsegBase = (UINTN)AllocatePages (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuMsegSize))); - if (mMsegBase > 0) { - mMsegSize = ALIGN_VALUE (PcdGet32 (PcdCpuMsegSize), EFI_PAGE_SIZE); - } else { - DEBUG ((DEBUG_ERROR, "Not enough SMRAM resource to allocate MSEG size %08x\n", PcdGet32 (PcdCpuMsegSize))); - } - } - if (mMsegBase > 0) { - DEBUG ((DEBUG_INFO, "MsegBase: 0x%08x, MsegSize: 0x%08x\n", mMsegBase, mMsegSize)); - } - } - - return EFI_SUCCESS; -} - -/** - Internal worker function that is called to complete CPU initialization at the - end of SmmCpuFeaturesInitializeProcessor(). - -**/ -VOID -FinishSmmCpuFeaturesInitializeProcessor ( - VOID - ) -{ - MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; - - // - // Set MSEG Base Address in SMM Monitor Control MSR. - // - if (mMsegBase > 0) { - SmmMonitorCtl.Uint64 = 0; - SmmMonitorCtl.Bits.MsegBase = (UINT32)mMsegBase >> 12; - SmmMonitorCtl.Bits.Valid = 1; - AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, SmmMonitorCtl.Uint64); - } -} - -/** - Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is - returned, then a custom SMI handler is not provided by this library, - and the default SMI handler must be used. - - @retval 0 Use the default SMI handler. - @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() - The caller is required to allocate enough SMRAM for each CPU to - support the size of the custom SMI handler. -**/ -UINTN -EFIAPI -SmmCpuFeaturesGetSmiHandlerSize ( - VOID - ) -{ - return gcStmSmiHandlerSize; -} - -/** - Install a custom SMI handler for the CPU specified by CpuIndex. This function - is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater - than zero and is called by the CPU that was elected as monarch during System - Management Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -SmmCpuFeaturesInstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ) -{ - EFI_STATUS Status; - TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; - VOID *Hob; - UINT32 RegEax; - UINT32 RegEdx; - EFI_PROCESSOR_INFORMATION ProcessorInfo; - - CopyMem ((VOID *)((UINTN)SmBase + TXT_SMM_PSD_OFFSET), &gcStmPsd, sizeof (gcStmPsd)); - Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + TXT_SMM_PSD_OFFSET); - Psd->SmmGdtPtr = GdtBase; - Psd->SmmGdtSize = (UINT32)GdtSize; - - // - // Initialize values in template before copy - // - gStmSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); - gStmSmiCr3 = Cr3; - gStmSmbase = SmBase; - gStmSmiHandlerIdtr.Base = IdtBase; - gStmSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1); - - if (gStmXdSupported) { - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax <= CPUID_EXTENDED_FUNCTION) { - // - // Extended CPUID functions are not supported on this processor. - // - gStmXdSupported = FALSE; - } - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & CPUID1_EDX_XD_SUPPORT) == 0) { - // - // Execute Disable Bit feature is not supported on this processor. - // - gStmXdSupported = FALSE; - } - } - - // - // Set the value at the top of the CPU stack to the CPU Index - // - *(UINTN*)(UINTN)gStmSmiStack = CpuIndex; - - // - // Copy template to CPU specific SMI handler location - // - CopyMem ( - (VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET), - (VOID*)gcStmSmiHandlerTemplate, - gcStmSmiHandlerSize - ); - - Psd->SmmSmiHandlerRip = SmBase + SMM_HANDLER_OFFSET + gcStmSmiHandlerOffset; - Psd->SmmSmiHandlerRsp = (UINTN)SmiStack + StackSize - sizeof(UINTN); - Psd->SmmCr3 = Cr3; - - DEBUG((DEBUG_ERROR, "CpuSmmStmExceptionStackSize - %x\n", PcdGet32(PcdCpuSmmStmExceptionStackSize))); - DEBUG((DEBUG_ERROR, "Pages - %x\n", EFI_SIZE_TO_PAGES(PcdGet32(PcdCpuSmmStmExceptionStackSize)))); - Psd->StmProtectionExceptionHandler.SpeRsp = (UINT64)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStmExceptionStackSize))); - Psd->StmProtectionExceptionHandler.SpeRsp += EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStmExceptionStackSize))); - - Psd->BiosHwResourceRequirementsPtr = (UINT64)(UINTN)GetStmResource (); - - // - // Get the APIC ID for the CPU specified by CpuIndex - // - Status = mSmmCpuFeaturesLibMpService->GetProcessorInfo ( - mSmmCpuFeaturesLibMpService, - CpuIndex, - &ProcessorInfo - ); - ASSERT_EFI_ERROR (Status); - - Psd->LocalApicId = (UINT32)ProcessorInfo.ProcessorId; - Psd->AcpiRsdp = 0; - - Hob = GetFirstHob (EFI_HOB_TYPE_CPU); - if (Hob != NULL) { - Psd->PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; - } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - Psd->PhysicalAddressBits = (UINT8) RegEax; - } else { - Psd->PhysicalAddressBits = 36; - } - } - - if (!mStmConfigurationTableInitialized) { - StmSmmConfigurationTableInit (); - mStmConfigurationTableInitialized = TRUE; - } -} - -/** - SMM End Of Dxe event notification handler. - - STM support need patch AcpiRsdp in TXT_PROCESSOR_SMM_DESCRIPTOR. - - @param[in] Protocol Points to the protocol's unique identifier. - @param[in] Interface Points to the interface instance. - @param[in] Handle The handle on which the interface was installed. - - @retval EFI_SUCCESS Notification handler runs successfully. -**/ -EFI_STATUS -EFIAPI -SmmEndOfDxeEventNotify ( - IN CONST EFI_GUID *Protocol, - IN VOID *Interface, - IN EFI_HANDLE Handle - ) -{ - VOID *Rsdp; - UINTN Index; - TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; - - DEBUG ((DEBUG_INFO, "SmmEndOfDxeEventNotify\n")); - - // - // found ACPI table RSD_PTR from system table - // - Rsdp = NULL; - for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { - if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi20TableGuid)) { - // - // A match was found. - // - Rsdp = gST->ConfigurationTable[Index].VendorTable; - break; - } - } - if (Rsdp == NULL) { - for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { - if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi10TableGuid)) { - // - // A match was found. - // - Rsdp = gST->ConfigurationTable[Index].VendorTable; - break; - } - } - } - - for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { - Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)((UINTN)gSmst->CpuSaveState[Index] - SMRAM_SAVE_STATE_MAP_OFFSET + TXT_SMM_PSD_OFFSET); - DEBUG ((DEBUG_INFO, "Index=%d Psd=%p Rsdp=%p\n", Index, Psd, Rsdp)); - Psd->AcpiRsdp = (UINT64)(UINTN)Rsdp; - } - - mLockLoadMonitor = TRUE; - - return EFI_SUCCESS; -} - -/** - This function initializes the STM configuration table. -**/ -VOID -StmSmmConfigurationTableInit ( - VOID - ) -{ - EFI_STATUS Status; - VOID *Registration; - - Status = gSmst->SmmInstallProtocolInterface ( - &mStmSmmCpuHandle, - &gEfiSmMonitorInitProtocolGuid, - EFI_NATIVE_INTERFACE, - &mSmMonitorInitProtocol - ); - ASSERT_EFI_ERROR (Status); - - // - // - // Register SMM End of DXE Event - // - Status = gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, - SmmEndOfDxeEventNotify, - &Registration - ); - ASSERT_EFI_ERROR (Status); -} - -/** - - Get STM state. - - @return STM state - -**/ -EFI_SM_MONITOR_STATE -EFIAPI -GetMonitorState ( - VOID - ) -{ - return mStmState; -} - -/** - - Handle single Resource to see if it can be merged into Record. - - @param Resource A pointer to resource node to be added - @param Record A pointer to record node to be merged - - @retval TRUE resource handled - @retval FALSE resource is not handled - -**/ -BOOLEAN -HandleSingleResource ( - IN STM_RSC *Resource, - IN STM_RSC *Record - ) -{ - UINT64 ResourceLo; - UINT64 ResourceHi; - UINT64 RecordLo; - UINT64 RecordHi; - - ResourceLo = 0; - ResourceHi = 0; - RecordLo = 0; - RecordHi = 0; - - // - // Calling code is responsible for making sure that - // Resource->Header.RscType == (*Record)->Header.RscType - // thus we use just one of them as switch variable. - // - switch (Resource->Header.RscType) { - case MEM_RANGE: - case MMIO_RANGE: - ResourceLo = Resource->Mem.Base; - ResourceHi = Resource->Mem.Base + Resource->Mem.Length; - RecordLo = Record->Mem.Base; - RecordHi = Record->Mem.Base + Record->Mem.Length; - if (Resource->Mem.RWXAttributes != Record->Mem.RWXAttributes) { - if ((ResourceLo == RecordLo) && (ResourceHi == RecordHi)) { - Record->Mem.RWXAttributes = Resource->Mem.RWXAttributes | Record->Mem.RWXAttributes; - return TRUE; - } else { - return FALSE; - } - } - break; - case IO_RANGE: - case TRAPPED_IO_RANGE: - ResourceLo = (UINT64) Resource->Io.Base; - ResourceHi = (UINT64) Resource->Io.Base + (UINT64) Resource->Io.Length; - RecordLo = (UINT64) Record->Io.Base; - RecordHi = (UINT64) Record->Io.Base + (UINT64) Record->Io.Length; - break; - case PCI_CFG_RANGE: - if ((Resource->PciCfg.OriginatingBusNumber != Record->PciCfg.OriginatingBusNumber) || - (Resource->PciCfg.LastNodeIndex != Record->PciCfg.LastNodeIndex)) { - return FALSE; - } - if (CompareMem (Resource->PciCfg.PciDevicePath, Record->PciCfg.PciDevicePath, sizeof(STM_PCI_DEVICE_PATH_NODE) * (Resource->PciCfg.LastNodeIndex + 1)) != 0) { - return FALSE; - } - ResourceLo = (UINT64) Resource->PciCfg.Base; - ResourceHi = (UINT64) Resource->PciCfg.Base + (UINT64) Resource->PciCfg.Length; - RecordLo = (UINT64) Record->PciCfg.Base; - RecordHi = (UINT64) Record->PciCfg.Base + (UINT64) Record->PciCfg.Length; - if (Resource->PciCfg.RWAttributes != Record->PciCfg.RWAttributes) { - if ((ResourceLo == RecordLo) && (ResourceHi == RecordHi)) { - Record->PciCfg.RWAttributes = Resource->PciCfg.RWAttributes | Record->PciCfg.RWAttributes; - return TRUE; - } else { - return FALSE; - } - } - break; - case MACHINE_SPECIFIC_REG: - // - // Special case - merge MSR masks in place. - // - if (Resource->Msr.MsrIndex != Record->Msr.MsrIndex) { - return FALSE; - } - Record->Msr.ReadMask |= Resource->Msr.ReadMask; - Record->Msr.WriteMask |= Resource->Msr.WriteMask; - return TRUE; - default: - return FALSE; - } - // - // If resources are disjoint - // - if ((ResourceHi < RecordLo) || (ResourceLo > RecordHi)) { - return FALSE; - } - - // - // If resource is consumed by record. - // - if ((ResourceLo >= RecordLo) && (ResourceHi <= RecordHi)) { - return TRUE; - } - // - // Resources are overlapping. - // Resource and record are merged. - // - ResourceLo = (ResourceLo < RecordLo) ? ResourceLo : RecordLo; - ResourceHi = (ResourceHi > RecordHi) ? ResourceHi : RecordHi; - - switch (Resource->Header.RscType) { - case MEM_RANGE: - case MMIO_RANGE: - Record->Mem.Base = ResourceLo; - Record->Mem.Length = ResourceHi - ResourceLo; - break; - case IO_RANGE: - case TRAPPED_IO_RANGE: - Record->Io.Base = (UINT16) ResourceLo; - Record->Io.Length = (UINT16) (ResourceHi - ResourceLo); - break; - case PCI_CFG_RANGE: - Record->PciCfg.Base = (UINT16) ResourceLo; - Record->PciCfg.Length = (UINT16) (ResourceHi - ResourceLo); - break; - default: - return FALSE; - } - - return TRUE; -} - -/** - - Add resource node. - - @param Resource A pointer to resource node to be added - -**/ -VOID -AddSingleResource ( - IN STM_RSC *Resource - ) -{ - STM_RSC *Record; - - Record = (STM_RSC *)mStmResourcesPtr; - - while (TRUE) { - if (Record->Header.RscType == END_OF_RESOURCES) { - break; - } - // - // Go to next record if resource and record types don't match. - // - if (Resource->Header.RscType != Record->Header.RscType) { - Record = (STM_RSC *)((UINTN)Record + Record->Header.Length); - continue; - } - // - // Record is handled inside of procedure - don't adjust. - // - if (HandleSingleResource (Resource, Record)) { - return ; - } - Record = (STM_RSC *)((UINTN)Record + Record->Header.Length); - } - - // - // Add resource to the end of area. - // - CopyMem ( - mStmResourcesPtr + mStmResourceSizeUsed - sizeof(mRscEndNode), - Resource, - Resource->Header.Length - ); - CopyMem ( - mStmResourcesPtr + mStmResourceSizeUsed - sizeof(mRscEndNode) + Resource->Header.Length, - &mRscEndNode, - sizeof(mRscEndNode) - ); - mStmResourceSizeUsed += Resource->Header.Length; - mStmResourceSizeAvailable = mStmResourceTotalSize - mStmResourceSizeUsed; - - return ; -} - -/** - - Add resource list. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - -**/ -VOID -AddResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ) -{ - UINT32 Count; - UINTN Index; - STM_RSC *Resource; - - if (NumEntries == 0) { - Count = 0xFFFFFFFF; - } else { - Count = NumEntries; - } - - Resource = ResourceList; - - for (Index = 0; Index < Count; Index++) { - if (Resource->Header.RscType == END_OF_RESOURCES) { - return ; - } - AddSingleResource (Resource); - Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); - } - return ; -} - -/** - - Validate resource list. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval TRUE resource valid - @retval FALSE resource invalid - -**/ -BOOLEAN -ValidateResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ) -{ - UINT32 Count; - UINTN Index; - STM_RSC *Resource; - UINTN SubIndex; - - // - // If NumEntries == 0 make it very big. Scan will be terminated by - // END_OF_RESOURCES. - // - if (NumEntries == 0) { - Count = 0xFFFFFFFF; - } else { - Count = NumEntries; - } - - // - // Start from beginning of resource list. - // - Resource = ResourceList; - - for (Index = 0; Index < Count; Index++) { - DEBUG ((DEBUG_ERROR, "ValidateResource (%d) - RscType(%x)\n", Index, Resource->Header.RscType)); - // - // Validate resource. - // - switch (Resource->Header.RscType) { - case END_OF_RESOURCES: - if (Resource->Header.Length != sizeof (STM_RSC_END)) { - return FALSE; - } - // - // If we are passed actual number of resources to add, - // END_OF_RESOURCES structure between them is considered an - // error. If NumEntries == 0 END_OF_RESOURCES is a termination. - // - if (NumEntries != 0) { - return FALSE; - } else { - // - // If NumEntries == 0 and list reached end - return success. - // - return TRUE; - } - break; - - case MEM_RANGE: - case MMIO_RANGE: - if (Resource->Header.Length != sizeof (STM_RSC_MEM_DESC)) { - return FALSE; - } - - if (Resource->Mem.RWXAttributes > FULL_ACCS) { - return FALSE; - } - break; - - case IO_RANGE: - case TRAPPED_IO_RANGE: - if (Resource->Header.Length != sizeof (STM_RSC_IO_DESC)) { - return FALSE; - } - - if ((Resource->Io.Base + Resource->Io.Length) > 0xFFFF) { - return FALSE; - } - break; - - case PCI_CFG_RANGE: - DEBUG ((DEBUG_ERROR, "ValidateResource - PCI (0x%02x, 0x%08x, 0x%02x, 0x%02x)\n", Resource->PciCfg.OriginatingBusNumber, Resource->PciCfg.LastNodeIndex, Resource->PciCfg.PciDevicePath[0].PciDevice, Resource->PciCfg.PciDevicePath[0].PciFunction)); - if (Resource->Header.Length != sizeof (STM_RSC_PCI_CFG_DESC) + (sizeof(STM_PCI_DEVICE_PATH_NODE) * Resource->PciCfg.LastNodeIndex)) { - return FALSE; - } - for (SubIndex = 0; SubIndex <= Resource->PciCfg.LastNodeIndex; SubIndex++) { - if ((Resource->PciCfg.PciDevicePath[SubIndex].PciDevice > 0x1F) || (Resource->PciCfg.PciDevicePath[SubIndex].PciFunction > 7)) { - return FALSE; - } - } - if ((Resource->PciCfg.Base + Resource->PciCfg.Length) > 0x1000) { - return FALSE; - } - break; - - case MACHINE_SPECIFIC_REG: - if (Resource->Header.Length != sizeof (STM_RSC_MSR_DESC)) { - return FALSE; - } - break; - - default : - DEBUG ((DEBUG_ERROR, "ValidateResource - Unknown RscType(%x)\n", Resource->Header.RscType)); - return FALSE; - } - Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); - } - return TRUE; -} - -/** - - Get resource list. - EndResource is excluded. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval TRUE resource valid - @retval FALSE resource invalid - -**/ -UINTN -GetResourceSize ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ) -{ - UINT32 Count; - UINTN Index; - STM_RSC *Resource; - - Resource = ResourceList; - - // - // If NumEntries == 0 make it very big. Scan will be terminated by - // END_OF_RESOURCES. - // - if (NumEntries == 0) { - Count = 0xFFFFFFFF; - } else { - Count = NumEntries; - } - - // - // Start from beginning of resource list. - // - Resource = ResourceList; - - for (Index = 0; Index < Count; Index++) { - if (Resource->Header.RscType == END_OF_RESOURCES) { - break; - } - Resource = (STM_RSC *)((UINTN)Resource + Resource->Header.Length); - } - - return (UINTN)Resource - (UINTN)ResourceList; -} - -/** - - Add resources in list to database. Allocate new memory areas as needed. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are added - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. - -**/ -EFI_STATUS -EFIAPI -AddPiResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ) -{ - EFI_STATUS Status; - UINTN ResourceSize; - EFI_PHYSICAL_ADDRESS NewResource; - UINTN NewResourceSize; - - DEBUG ((DEBUG_INFO, "AddPiResource - Enter\n")); - - if (!ValidateResource (ResourceList, NumEntries)) { - return EFI_INVALID_PARAMETER; - } - - ResourceSize = GetResourceSize (ResourceList, NumEntries); - DEBUG ((DEBUG_INFO, "ResourceSize - 0x%08x\n", ResourceSize)); - if (ResourceSize == 0) { - return EFI_INVALID_PARAMETER; - } - - if (mStmResourcesPtr == NULL) { - // - // First time allocation - // - NewResourceSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (ResourceSize + sizeof(mRscEndNode))); - DEBUG ((DEBUG_INFO, "Allocate - 0x%08x\n", NewResourceSize)); - Status = gSmst->SmmAllocatePages ( - AllocateAnyPages, - EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES (NewResourceSize), - &NewResource - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Copy EndResource for intialization - // - mStmResourcesPtr = (UINT8 *)(UINTN)NewResource; - mStmResourceTotalSize = NewResourceSize; - CopyMem (mStmResourcesPtr, &mRscEndNode, sizeof(mRscEndNode)); - mStmResourceSizeUsed = sizeof(mRscEndNode); - mStmResourceSizeAvailable = mStmResourceTotalSize - sizeof(mRscEndNode); - - // - // Let SmmCore change resource ptr - // - NotifyStmResourceChange (mStmResourcesPtr); - } else if (mStmResourceSizeAvailable < ResourceSize) { - // - // Need enlarge - // - NewResourceSize = mStmResourceTotalSize + (ResourceSize - mStmResourceSizeAvailable); - NewResourceSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (NewResourceSize)); - DEBUG ((DEBUG_INFO, "ReAllocate - 0x%08x\n", NewResourceSize)); - Status = gSmst->SmmAllocatePages ( - AllocateAnyPages, - EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES (NewResourceSize), - &NewResource - ); - if (EFI_ERROR (Status)) { - return Status; - } - CopyMem ((VOID *)(UINTN)NewResource, mStmResourcesPtr, mStmResourceSizeUsed); - mStmResourceSizeAvailable = NewResourceSize - mStmResourceSizeUsed; - - gSmst->SmmFreePages ( - (EFI_PHYSICAL_ADDRESS)(UINTN)mStmResourcesPtr, - EFI_SIZE_TO_PAGES (mStmResourceTotalSize) - ); - - mStmResourceTotalSize = NewResourceSize; - mStmResourcesPtr = (UINT8 *)(UINTN)NewResource; - - // - // Let SmmCore change resource ptr - // - NotifyStmResourceChange (mStmResourcesPtr); - } - - // - // Check duplication - // - AddResource (ResourceList, NumEntries); - - return EFI_SUCCESS; -} - -/** - - Delete resources in list to database. - - @param ResourceList A pointer to resource list to be deleted - NULL means delete all resources. - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are deleted - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - -**/ -EFI_STATUS -EFIAPI -DeletePiResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ) -{ - if (ResourceList != NULL) { - // TBD - ASSERT (FALSE); - return EFI_UNSUPPORTED; - } - // - // Delete all - // - CopyMem (mStmResourcesPtr, &mRscEndNode, sizeof(mRscEndNode)); - mStmResourceSizeUsed = sizeof(mRscEndNode); - mStmResourceSizeAvailable = mStmResourceTotalSize - sizeof(mRscEndNode); - return EFI_SUCCESS; -} - -/** - - Get BIOS resources. - - @param ResourceList A pointer to resource list to be filled - @param ResourceSize On input it means size of resource list input. - On output it means size of resource list filled, - or the size of resource list to be filled if size of too small. - - @retval EFI_SUCCESS If resources are returned. - @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. - -**/ -EFI_STATUS -EFIAPI -GetPiResource ( - OUT STM_RSC *ResourceList, - IN OUT UINT32 *ResourceSize - ) -{ - if (*ResourceSize < mStmResourceSizeUsed) { - *ResourceSize = (UINT32)mStmResourceSizeUsed; - return EFI_BUFFER_TOO_SMALL; - } - - CopyMem (ResourceList, mStmResourcesPtr, mStmResourceSizeUsed); - *ResourceSize = (UINT32)mStmResourceSizeUsed; - return EFI_SUCCESS; -} - -/** - - Set valid bit for MSEG MSR. - - @param Buffer Ap function buffer. (not used) - -**/ -VOID -EFIAPI -EnableMsegMsr ( - IN VOID *Buffer - ) -{ - MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; - - SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); - SmmMonitorCtl.Bits.Valid = 1; - AsmWriteMsr64 (MSR_IA32_SMM_MONITOR_CTL, SmmMonitorCtl.Uint64); -} - -/** - - Get 4K page aligned VMCS size. - - @return 4K page aligned VMCS size - -**/ -UINT32 -GetVmcsSize ( - VOID - ) -{ - MSR_IA32_VMX_BASIC_REGISTER VmxBasic; - - // - // Read VMCS size and and align to 4KB - // - VmxBasic.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_BASIC); - return ALIGN_VALUE (VmxBasic.Bits.VmcsSize, SIZE_4KB); -} - -/** - - Check STM image size. - - @param StmImage STM image - @param StmImageSize STM image size - - @retval TRUE check pass - @retval FALSE check fail -**/ -BOOLEAN -StmCheckStmImage ( - IN EFI_PHYSICAL_ADDRESS StmImage, - IN UINTN StmImageSize - ) -{ - UINTN MinMsegSize; - STM_HEADER *StmHeader; - IA32_VMX_MISC_REGISTER VmxMiscMsr; - - // - // Check to see if STM image is compatible with CPU - // - StmHeader = (STM_HEADER *)(UINTN)StmImage; - VmxMiscMsr.Uint64 = AsmReadMsr64 (MSR_IA32_VMX_MISC); - if (StmHeader->HwStmHdr.MsegHeaderRevision != VmxMiscMsr.Bits.MsegRevisionIdentifier) { - DEBUG ((DEBUG_ERROR, "STM Image not compatible with CPU\n")); - DEBUG ((DEBUG_ERROR, " StmHeader->HwStmHdr.MsegHeaderRevision = %08x\n", StmHeader->HwStmHdr.MsegHeaderRevision)); - DEBUG ((DEBUG_ERROR, " VmxMiscMsr.Bits.MsegRevisionIdentifier = %08x\n", VmxMiscMsr.Bits.MsegRevisionIdentifier)); - return FALSE; - } - - // - // Get Minimal required Mseg size - // - MinMsegSize = (EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (StmHeader->SwStmHdr.StaticImageSize)) + - StmHeader->SwStmHdr.AdditionalDynamicMemorySize + - (StmHeader->SwStmHdr.PerProcDynamicMemorySize + GetVmcsSize () * 2) * gSmst->NumberOfCpus); - if (MinMsegSize < StmImageSize) { - MinMsegSize = StmImageSize; - } - - if (StmHeader->HwStmHdr.Cr3Offset >= StmHeader->SwStmHdr.StaticImageSize) { - // - // We will create page table, just in case that SINIT does not create it. - // - if (MinMsegSize < StmHeader->HwStmHdr.Cr3Offset + EFI_PAGES_TO_SIZE(6)) { - MinMsegSize = StmHeader->HwStmHdr.Cr3Offset + EFI_PAGES_TO_SIZE(6); - } - } - - // - // Check if it exceeds MSEG size - // - if (MinMsegSize > mMsegSize) { - DEBUG ((DEBUG_ERROR, "MSEG too small. Min MSEG Size = %08x Current MSEG Size = %08x\n", MinMsegSize, mMsegSize)); - DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.StaticImageSize = %08x\n", StmHeader->SwStmHdr.StaticImageSize)); - DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.AdditionalDynamicMemorySize = %08x\n", StmHeader->SwStmHdr.AdditionalDynamicMemorySize)); - DEBUG ((DEBUG_ERROR, " StmHeader->SwStmHdr.PerProcDynamicMemorySize = %08x\n", StmHeader->SwStmHdr.PerProcDynamicMemorySize)); - DEBUG ((DEBUG_ERROR, " VMCS Size = %08x\n", GetVmcsSize ())); - DEBUG ((DEBUG_ERROR, " Max CPUs = %08x\n", gSmst->NumberOfCpus)); - DEBUG ((DEBUG_ERROR, " StmHeader->HwStmHdr.Cr3Offset = %08x\n", StmHeader->HwStmHdr.Cr3Offset)); - return FALSE; - } - - return TRUE; -} - -/** - - Load STM image to MSEG. - - @param StmImage STM image - @param StmImageSize STM image size - -**/ -VOID -StmLoadStmImage ( - IN EFI_PHYSICAL_ADDRESS StmImage, - IN UINTN StmImageSize - ) -{ - MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; - UINT32 MsegBase; - STM_HEADER *StmHeader; - - // - // Get MSEG base address from MSR_IA32_SMM_MONITOR_CTL - // - SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); - MsegBase = SmmMonitorCtl.Bits.MsegBase << 12; - - // - // Zero all of MSEG base address - // - ZeroMem ((VOID *)(UINTN)MsegBase, mMsegSize); - - // - // Copy STM Image into MSEG - // - CopyMem ((VOID *)(UINTN)MsegBase, (VOID *)(UINTN)StmImage, StmImageSize); - - // - // STM Header is at the beginning of the STM Image - // - StmHeader = (STM_HEADER *)(UINTN)StmImage; - - StmGen4GPageTable ((UINTN)MsegBase + StmHeader->HwStmHdr.Cr3Offset); -} - -/** - - Load STM image to MSEG. - - @param StmImage STM image - @param StmImageSize STM image size - - @retval EFI_SUCCESS Load STM to MSEG successfully - @retval EFI_ALREADY_STARTED STM image is already loaded to MSEG - @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image - @retval EFI_UNSUPPORTED MSEG is not enabled - -**/ -EFI_STATUS -EFIAPI -LoadMonitor ( - IN EFI_PHYSICAL_ADDRESS StmImage, - IN UINTN StmImageSize - ) -{ - MSR_IA32_SMM_MONITOR_CTL_REGISTER SmmMonitorCtl; - - if (mLockLoadMonitor) { - return EFI_ACCESS_DENIED; - } - - SmmMonitorCtl.Uint64 = AsmReadMsr64 (MSR_IA32_SMM_MONITOR_CTL); - if (SmmMonitorCtl.Bits.MsegBase == 0) { - return EFI_UNSUPPORTED; - } - - if (!StmCheckStmImage (StmImage, StmImageSize)) { - return EFI_BUFFER_TOO_SMALL; - } - - // Record STM_HASH to PCR 0, just in case it is NOT TXT launch, we still need provide the evidence. - TpmMeasureAndLogData( - 0, // PcrIndex - TXT_EVTYPE_STM_HASH, // EventType - NULL, // EventLog - 0, // LogLen - (VOID *)(UINTN)StmImage, // HashData - StmImageSize // HashDataLen - ); - - StmLoadStmImage (StmImage, StmImageSize); - - mStmState |= EFI_SM_MONITOR_STATE_ENABLED; - - return EFI_SUCCESS; -} - -/** - This function return BIOS STM resource. - Produced by SmmStm. - Comsumed by SmmMpService when Init. - - @return BIOS STM resource - -**/ -VOID * -GetStmResource( - VOID - ) -{ - return mStmResourcesPtr; -} - -/** - This function notify STM resource change. - - @param StmResource BIOS STM resource - -**/ -VOID -NotifyStmResourceChange ( - VOID *StmResource - ) -{ - UINTN Index; - TXT_PROCESSOR_SMM_DESCRIPTOR *Psd; - - for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { - Psd = (TXT_PROCESSOR_SMM_DESCRIPTOR *)((UINTN)gSmst->CpuSaveState[Index] - SMRAM_SAVE_STATE_MAP_OFFSET + TXT_SMM_PSD_OFFSET); - Psd->BiosHwResourceRequirementsPtr = (UINT64)(UINTN)StmResource; - } - return ; -} - - -/** - This is STM setup BIOS callback. -**/ -VOID -EFIAPI -SmmStmSetup ( - VOID - ) -{ - mStmState |= EFI_SM_MONITOR_STATE_ACTIVATED; -} - -/** - This is STM teardown BIOS callback. -**/ -VOID -EFIAPI -SmmStmTeardown ( - VOID - ) -{ - mStmState &= ~EFI_SM_MONITOR_STATE_ACTIVATED; -} - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h deleted file mode 100644 index 92a4dc00eb..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.h +++ /dev/null @@ -1,176 +0,0 @@ -/** @file - SMM STM support - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_STM_H_ -#define _SMM_STM_H_ - -#include - -/** - - Create 4G page table for STM. - 2M PAE page table in X64 version. - - @param PageTableBase The page table base in MSEG - -**/ -VOID -StmGen4GPageTable ( - IN UINTN PageTableBase - ); - -/** - This is SMM exception handle. - Consumed by STM when exception happen. - - @param Context STM protection exception stack frame - - @return the EBX value for STM reference. - EBX = 0: resume SMM guest using register state found on exception stack. - EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the - TXT.ERRORCODE register and subsequently reset the system via - TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as - follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC - EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. - -**/ -UINT32 -EFIAPI -SmmStmExceptionHandler ( - IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context - ); - - -/** - - Get STM state. - - @return STM state - -**/ -EFI_SM_MONITOR_STATE -EFIAPI -GetMonitorState ( - VOID - ); - -/** - - Load STM image to MSEG. - - @param StmImage STM image - @param StmImageSize STM image size - - @retval EFI_SUCCESS Load STM to MSEG successfully - @retval EFI_BUFFER_TOO_SMALL MSEG is smaller than minimal requirement of STM image - -**/ -EFI_STATUS -EFIAPI -LoadMonitor ( - IN EFI_PHYSICAL_ADDRESS StmImage, - IN UINTN StmImageSize - ); - -/** - - Add resources in list to database. Allocate new memory areas as needed. - - @param ResourceList A pointer to resource list to be added - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are added - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - @retval EFI_OUT_OF_RESOURCES If nested procedure returned it and we cannot allocate more areas. - -**/ -EFI_STATUS -EFIAPI -AddPiResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ); - -/** - - Delete resources in list to database. - - @param ResourceList A pointer to resource list to be deleted - NULL means delete all resources. - @param NumEntries Optional number of entries. - If 0, list must be terminated by END_OF_RESOURCES. - - @retval EFI_SUCCESS If resources are deleted - @retval EFI_INVALID_PARAMETER If nested procedure detected resource failer - -**/ -EFI_STATUS -EFIAPI -DeletePiResource ( - IN STM_RSC *ResourceList, - IN UINT32 NumEntries OPTIONAL - ); - -/** - - Get BIOS resources. - - @param ResourceList A pointer to resource list to be filled - @param ResourceSize On input it means size of resource list input. - On output it means size of resource list filled, - or the size of resource list to be filled if size of too small. - - @retval EFI_SUCCESS If resources are returned. - @retval EFI_BUFFER_TOO_SMALL If resource list buffer is too small to hold the whole resources. - -**/ -EFI_STATUS -EFIAPI -GetPiResource ( - OUT STM_RSC *ResourceList, - IN OUT UINT32 *ResourceSize - ); - -/** - This functin initialize STM configuration table. -**/ -VOID -StmSmmConfigurationTableInit ( - VOID - ); - -/** - This function notify STM resource change. - - @param StmResource BIOS STM resource - -**/ -VOID -NotifyStmResourceChange ( - IN VOID *StmResource - ); - -/** - This function return BIOS STM resource. - - @return BIOS STM resource - -**/ -VOID * -GetStmResource ( - VOID - ); - -#endif diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S deleted file mode 100644 index 1f9f91ce10..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.S +++ /dev/null @@ -1,282 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiEntry.S -# -# Abstract: -# -# Code template of the SMI handler for a particular processor -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerTemplate) -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerSize) -ASM_GLOBAL ASM_PFX(gcStmSmiHandlerOffset) -ASM_GLOBAL ASM_PFX(gStmSmiCr3) -ASM_GLOBAL ASM_PFX(gStmSmiStack) -ASM_GLOBAL ASM_PFX(gStmSmbase) -ASM_GLOBAL ASM_PFX(gStmXdSupported) -ASM_GLOBAL ASM_PFX(gStmSmiHandlerIdtr) - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0xc0000080 -.equ MSR_EFER_XD, 0x800 - -# -# Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -# -.equ DSC_OFFSET, 0xfb00 -.equ DSC_GDTPTR, 0x48 -.equ DSC_GDTSIZ, 0x50 -.equ DSC_CS, 0x14 -.equ DSC_DS, 0x16 -.equ DSC_SS, 0x18 -.equ DSC_OTHERSEG, 0x1a -# -# Constants relating to CPU State Save Area -# -.equ SSM_DR6, 0xffd0 -.equ SSM_DR7, 0xffc8 - -.equ PROTECT_MODE_CS, 0x08 -.equ PROTECT_MODE_DS, 0x20 -.equ LONG_MODE_CS, 0x38 -.equ TSS_SEGMENT, 0x40 -.equ GDT_SIZE, 0x50 - - .text - -ASM_PFX(gcStmSmiHandlerTemplate): - -_StmSmiEntryPoint: - # - # The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- - # bit addressing mode. And that coincidence has been used in the following - # "64-bit like" 16-bit code. Be aware that once RDI is referenced as a - # base address register, it is actually BX that is referenced. - # - .byte 0xbb # mov bx, imm16 - .word _StmGdtDesc - _StmSmiEntryPoint + 0x8000 - # - # fix GDT descriptor - # - .byte 0x2e,0xa1 # mov ax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTSIZ - .byte 0x48 # dec ax - .byte 0x2e - movl %eax, (%rdi) # mov cs:[bx], ax - .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTPTR - .byte 0x2e - movw %ax, 2(%rdi) - .byte 0x66,0x2e - lgdt (%rdi) - # - # Patch ProtectedMode Segment - # - .byte 0xb8 - .word PROTECT_MODE_CS - .byte 0x2e - movl %eax, -2(%rdi) - # - # Patch ProtectedMode entry - # - .byte 0x66, 0xbf # mov edi, SMBASE -ASM_PFX(gStmSmbase): .space 4 - lea ((ProtectedMode - _StmSmiEntryPoint) + 0x8000)(%edi), %ax - .byte 0x2e - movw %ax, -6(%rdi) - # - # Switch into ProtectedMode - # - movq %cr0, %rbx - .byte 0x66 - andl $0x9ffafff3, %ebx - .byte 0x66 - orl $0x00000023, %ebx - - movq %rbx, %cr0 - .byte 0x66, 0xea - .space 6 - -_StmGdtDesc: .space 6 - -ProtectedMode: - movw $PROTECT_MODE_DS, %ax - movl %eax, %ds - movl %eax, %es - movl %eax, %fs - movl %eax, %gs - movl %eax, %ss - .byte 0xbc # mov esp, imm32 -ASM_PFX(gStmSmiStack): .space 4 - jmp ProtFlatMode - -ProtFlatMode: - .byte 0xb8 -ASM_PFX(gStmSmiCr3): .space 4 - movq %rax, %cr3 - movl $0x668,%eax # as cr4.PGE is not set here, refresh cr3 - movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. -# Load TSS - subl $8, %esp # reserve room in stack - sgdt (%rsp) - movl 2(%rsp), %eax # eax = GDT base - addl $8, %esp - movb $0x89, %dl - movb %dl, (TSS_SEGMENT + 5)(%rax) # clear busy flag - movl $TSS_SEGMENT, %eax - ltr %ax - -# enable NXE if supported - .byte 0xb0 # mov al, imm8 -ASM_PFX(gStmXdSupported): .byte 1 - cmpb $0, %al - jz SkipXd -# -# Check XD disable bit -# - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - subl $4, %esp - pushq %rdx # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr - jmp XdDone -SkipXd: - subl $8, %esp -XdDone: - - # - # Switch to LongMode - # - pushq $LONG_MODE_CS # push cs hardcore here - call Base # push return address for retf later -Base: - addl $(LongMode - Base), (%rsp) # offset for far retf, seg is the 1st arg - - movl $MSR_EFER, %ecx - rdmsr - orb $1,%ah # enable LME - wrmsr - movq %cr0, %rbx - orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE - movq %rbx, %cr0 - retf -LongMode: # long mode (64-bit code) starts here - movabsq $ASM_PFX(gStmSmiHandlerIdtr), %rax - lidt (%rax) - lea (DSC_OFFSET)(%rdi), %ebx - movw DSC_DS(%rbx), %ax - movl %eax,%ds - movw DSC_OTHERSEG(%rbx), %ax - movl %eax,%es - movl %eax,%fs - movl %eax,%gs - movw DSC_SS(%rbx), %ax - movl %eax,%ss - -CommonHandler: - movq 8(%rsp), %rbx - # Save FP registers - - subq $0x200, %rsp - .byte 0x48 # FXSAVE64 - fxsave (%rsp) - - addq $-0x20, %rsp - - movq %rbx, %rcx - movabsq $ASM_PFX(CpuSmmDebugEntry), %rax - call *%rax - - movq %rbx, %rcx - movabsq $ASM_PFX(SmiRendezvous), %rax - call *%rax - - movq %rbx, %rcx - movabsq $ASM_PFX(CpuSmmDebugExit), %rax - call *%rax - - addq $0x20, %rsp - - # - # Restore FP registers - # - .byte 0x48 # FXRSTOR64 - fxrstor (%rsp) - - addq $0x200, %rsp - - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz L16 - popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr - -L16: - rsm - -_StmSmiHandler: -# -# Check XD disable bit -# - xorq %r8, %r8 - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz StmXdDone - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L14 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L14: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone: - pushq %r8 - - # below step is needed, because STM does not run above code. - # we have to run below code to set IDT/CR0/CR4 - movabsq $ASM_PFX(gStmSmiHandlerIdtr), %rax - lidt (%rax) - - movq %cr0, %rax - orl $0x80010023, %eax - movq %rax, %cr0 - movq %cr4, %rax - movl $0x668, %eax # as cr4.PGE is not set here, refresh cr3 - movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. - # STM init finish - jmp CommonHandler - -ASM_PFX(gcStmSmiHandlerSize) : .word . - _StmSmiEntryPoint -ASM_PFX(gcStmSmiHandlerOffset): .word _StmSmiHandler - _StmSmiEntryPoint diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm deleted file mode 100644 index ad51e07079..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.asm +++ /dev/null @@ -1,281 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.asm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -; -; Variables referenced by C code -; -EXTERNDEF SmiRendezvous:PROC -EXTERNDEF CpuSmmDebugEntry:PROC -EXTERNDEF CpuSmmDebugExit:PROC -EXTERNDEF gcStmSmiHandlerTemplate:BYTE -EXTERNDEF gcStmSmiHandlerSize:WORD -EXTERNDEF gcStmSmiHandlerOffset:WORD -EXTERNDEF gStmSmiCr3:DWORD -EXTERNDEF gStmSmiStack:DWORD -EXTERNDEF gStmSmbase:DWORD -EXTERNDEF gStmXdSupported:BYTE -EXTERNDEF gStmSmiHandlerIdtr:FWORD - -MSR_IA32_MISC_ENABLE EQU 1A0h -MSR_EFER EQU 0c0000080h -MSR_EFER_XD EQU 0800h - -; -; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -; -DSC_OFFSET EQU 0fb00h -DSC_GDTPTR EQU 48h -DSC_GDTSIZ EQU 50h -DSC_CS EQU 14h -DSC_DS EQU 16h -DSC_SS EQU 18h -DSC_OTHERSEG EQU 1ah -; -; Constants relating to CPU State Save Area -; -SSM_DR6 EQU 0ffd0h -SSM_DR7 EQU 0ffc8h - -PROTECT_MODE_CS EQU 08h -PROTECT_MODE_DS EQU 20h -LONG_MODE_CS EQU 38h -TSS_SEGMENT EQU 40h -GDT_SIZE EQU 50h - - .code - -gcStmSmiHandlerTemplate LABEL BYTE - -_StmSmiEntryPoint: - ; - ; The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- - ; bit addressing mode. And that coincidence has been used in the following - ; "64-bit like" 16-bit code. Be aware that once RDI is referenced as a - ; base address register, it is actually BX that is referenced. - ; - DB 0bbh ; mov bx, imm16 - DW offset _StmGdtDesc - _StmSmiEntryPoint + 8000h ; bx = GdtDesc offset -; fix GDT descriptor - DB 2eh, 0a1h ; mov ax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTSIZ - DB 48h ; dec ax - DB 2eh - mov [rdi], eax ; mov cs:[bx], ax - DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTPTR - DB 2eh - mov [rdi + 2], ax ; mov cs:[bx + 2], eax - DB 66h, 2eh - lgdt fword ptr [rdi] ; lgdt fword ptr cs:[bx] -; Patch ProtectedMode Segment - DB 0b8h ; mov ax, imm16 - DW PROTECT_MODE_CS ; set AX for segment directly - DB 2eh - mov [rdi - 2], eax ; mov cs:[bx - 2], ax -; Patch ProtectedMode entry - DB 66h, 0bfh ; mov edi, SMBASE -gStmSmbase DD ? - lea ax, [edi + (@ProtectedMode - _StmSmiEntryPoint) + 8000h] - DB 2eh - mov [rdi - 6], ax ; mov cs:[bx - 6], eax -; Switch into @ProtectedMode - mov rbx, cr0 - DB 66h - and ebx, 9ffafff3h - DB 66h - or ebx, 00000023h - - mov cr0, rbx - DB 66h, 0eah - DD ? - DW ? - -_StmGdtDesc FWORD ? -@ProtectedMode: - mov ax, PROTECT_MODE_DS - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - DB 0bch ; mov esp, imm32 -gStmSmiStack DD ? - jmp ProtFlatMode - -ProtFlatMode: - DB 0b8h ; mov eax, offset gStmSmiCr3 -gStmSmiCr3 DD ? - mov cr3, rax - mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. -; Load TSS - sub esp, 8 ; reserve room in stack - sgdt fword ptr [rsp] - mov eax, [rsp + 2] ; eax = GDT base - add esp, 8 - mov dl, 89h - mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -gStmXdSupported DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - sub esp, 4 - push rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 8 -@XdDone: - -; Switch into @LongMode - push LONG_MODE_CS ; push cs hardcore here - call Base ; push return address for retf later -Base: - add dword ptr [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg - - mov ecx, MSR_EFER - rdmsr - or ah, 1 ; enable LME - wrmsr - mov rbx, cr0 - or ebx, 080010023h ; enable paging + WP + NE + MP + PE - mov cr0, rbx - retf -@LongMode: ; long mode (64-bit code) starts here - mov rax, offset gStmSmiHandlerIdtr - lidt fword ptr [rax] - lea ebx, [rdi + DSC_OFFSET] - mov ax, [rbx + DSC_DS] - mov ds, eax - mov ax, [rbx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [rbx + DSC_SS] - mov ss, eax - -CommonHandler: - mov rbx, [rsp + 0x08] ; rbx <- CpuIndex - - ; - ; Save FP registers - ; - sub rsp, 200h - DB 48h ; FXSAVE64 - fxsave [rsp] - - add rsp, -20h - - mov rcx, rbx - mov rax, CpuSmmDebugEntry - call rax - - mov rcx, rbx - mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous - call rax - - mov rcx, rbx - mov rax, CpuSmmDebugExit - call rax - - add rsp, 20h - - ; - ; Restore FP registers - ; - DB 48h ; FXRSTOR64 - fxrstor [rsp] - - add rsp, 200h - - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @f - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -@@: - rsm - -_StmSmiHandler: -; -; Check XD disable bit -; - xor r8, r8 - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone: - push r8 - - ; below step is needed, because STM does not run above code. - ; we have to run below code to set IDT/CR0/CR4 - mov rax, offset gStmSmiHandlerIdtr - lidt fword ptr [rax] - - mov rax, cr0 - or eax, 80010023h ; enable paging + WP + NE + MP + PE - mov cr0, rax - mov rax, cr4 - mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. - ; STM init finish - jmp CommonHandler - -gcStmSmiHandlerSize DW $ - _StmSmiEntryPoint -gcStmSmiHandlerOffset DW _StmSmiHandler - _StmSmiEntryPoint - - END diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm deleted file mode 100644 index c801591fc7..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm +++ /dev/null @@ -1,263 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.nasm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -; -; Variables referrenced by C code -; - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -; -; Constants relating to TXT_PROCESSOR_SMM_DESCRIPTOR -; -%define DSC_OFFSET 0xfb00 -%define DSC_GDTPTR 0x48 -%define DSC_GDTSIZ 0x50 -%define DSC_CS 0x14 -%define DSC_DS 0x16 -%define DSC_SS 0x18 -%define DSC_OTHERSEG 0x1a -; -; Constants relating to CPU State Save Area -; -%define SSM_DR6 0xffd0 -%define SSM_DR7 0xffc8 - -%define PROTECT_MODE_CS 0x8 -%define PROTECT_MODE_DS 0x20 -%define LONG_MODE_CS 0x38 -%define TSS_SEGMENT 0x40 -%define GDT_SIZE 0x50 - -extern ASM_PFX(SmiRendezvous) -extern ASM_PFX(gStmSmiHandlerIdtr) -extern ASM_PFX(CpuSmmDebugEntry) -extern ASM_PFX(CpuSmmDebugExit) - -global ASM_PFX(gStmSmbase) -global ASM_PFX(gStmXdSupported) -global ASM_PFX(gStmSmiStack) -global ASM_PFX(gStmSmiCr3) -global ASM_PFX(gcStmSmiHandlerTemplate) -global ASM_PFX(gcStmSmiHandlerSize) -global ASM_PFX(gcStmSmiHandlerOffset) - - DEFAULT REL - SECTION .text - -BITS 16 -ASM_PFX(gcStmSmiHandlerTemplate): -_StmSmiEntryPoint: - mov bx, _StmGdtDesc - _StmSmiEntryPoint + 0x8000 - mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] - dec ax - mov [cs:bx], ax - mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] - mov [cs:bx + 2], eax -o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] - mov ax, PROTECT_MODE_CS - mov [cs:bx-0x2],ax - DB 0x66, 0xbf ; mov edi, SMBASE -ASM_PFX(gStmSmbase): DD 0 - lea eax, [edi + (@ProtectedMode - _StmSmiEntryPoint) + 0x8000] - mov [cs:bx-0x6],eax - mov ebx, cr0 - and ebx, 0x9ffafff3 - or ebx, 0x23 - mov cr0, ebx - jmp dword 0x0:0x0 -_StmGdtDesc: - DW 0 - DD 0 - -BITS 32 -@ProtectedMode: - mov ax, PROTECT_MODE_DS -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax - DB 0xbc ; mov esp, imm32 -ASM_PFX(gStmSmiStack): DD 0 - jmp ProtFlatMode - -BITS 64 -ProtFlatMode: - DB 0xb8 ; mov eax, offset gStmSmiCr3 -ASM_PFX(gStmSmiCr3): DD 0 - mov cr3, rax - mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. -; Load TSS - sub esp, 8 ; reserve room in stack - sgdt [rsp] - mov eax, [rsp + 2] ; eax = GDT base - add esp, 8 - mov dl, 0x89 - mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax - -; enable NXE if supported - DB 0xb0 ; mov al, imm8 -ASM_PFX(gStmXdSupported): DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - sub esp, 4 - push rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .0 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.0: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 8 -@XdDone: - -; Switch into @LongMode - push LONG_MODE_CS ; push cs hardcore here - call Base ; push return address for retf later -Base: - add dword [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg - - mov ecx, MSR_EFER - rdmsr - or ah, 1 ; enable LME - wrmsr - mov rbx, cr0 - or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, rbx - retf -@LongMode: ; long mode (64-bit code) starts here - mov rax, ASM_PFX(gStmSmiHandlerIdtr) - lidt [rax] - lea ebx, [rdi + DSC_OFFSET] - mov ax, [rbx + DSC_DS] - mov ds, eax - mov ax, [rbx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [rbx + DSC_SS] - mov ss, eax - -CommonHandler: - mov rbx, [rsp + 0x08] ; rbx <- CpuIndex - - ; - ; Save FP registers - ; - sub rsp, 0x200 - DB 0x48 ; FXSAVE64 - fxsave [rsp] - - add rsp, -0x20 - - mov rcx, rbx - mov rax, CpuSmmDebugEntry - call rax - - mov rcx, rbx - mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous - call rax - - mov rcx, rbx - mov rax, CpuSmmDebugExit - call rax - - add rsp, 0x20 - - ; - ; Restore FP registers - ; - DB 0x48 ; FXRSTOR64 - fxrstor [rsp] - - add rsp, 0x200 - - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz .1 - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.1: - rsm - -_StmSmiHandler: -; -; Check XD disable bit -; - xor r8, r8 - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .0 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.0: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone: - push r8 - - ; below step is needed, because STM does not run above code. - ; we have to run below code to set IDT/CR0/CR4 - - mov rax, ASM_PFX(gStmSmiHandlerIdtr) - lidt [rax] - - mov rax, cr0 - or eax, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, rax - mov rax, cr4 - mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. - ; STM init finish - jmp CommonHandler - -ASM_PFX(gcStmSmiHandlerSize) : DW $ - _StmSmiEntryPoint -ASM_PFX(gcStmSmiHandlerOffset) : DW _StmSmiHandler - _StmSmiEntryPoint diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S deleted file mode 100644 index 4d0cd9ac6f..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.S +++ /dev/null @@ -1,178 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiException.S -# -# Abstract: -# -# Exception handlers used in SM mode -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcStmPsd) - -ASM_GLOBAL ASM_PFX(SmmStmExceptionHandler) -ASM_GLOBAL ASM_PFX(SmmStmSetup) -ASM_GLOBAL ASM_PFX(SmmStmTeardown) - -.equ CODE_SEL, 0x38 -.equ DATA_SEL, 0x20 -.equ TR_SEL, 0x40 - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0x0c0000080 -.equ MSR_EFER_XD, 0x0800 - - .data - -# -# This structure serves as a template for all processors. -# -ASM_PFX(gcStmPsd): - .ascii "TXTPSSIG" - .word PSD_SIZE - .word 1 # Version - .long 0 # LocalApicId - .byte 0xF # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - .byte 0 # BIOS to STM - .byte 0 # STM to BIOS - .byte 0 - .word CODE_SEL - .word DATA_SEL - .word DATA_SEL - .word DATA_SEL - .word TR_SEL - .word 0 - .quad 0 # SmmCr3 - .quad ASM_PFX(_OnStmSetup) - .quad ASM_PFX(_OnStmTeardown) - .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint - .quad 0 # SmmSmiHandlerRsp - .quad 0 - .long 0 - .long 0x80010100 # RequiredStmSmmRevId - .quad ASM_PFX(_OnException) - .quad 0 # ExceptionStack - .word DATA_SEL - .word 0x1F # ExceptionFilter - .long 0 - .quad 0 - .quad 0 # BiosHwResourceRequirementsPtr - .quad 0 # AcpiRsdp - .byte 0 # PhysicalAddressBits -.equ PSD_SIZE, . - ASM_PFX(gcStmPsd) - - .text -#------------------------------------------------------------------------------ -# SMM Exception handlers -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(_OnException) -ASM_PFX(_OnException): - movq %rsp, %rcx - subq $0x28, %rsp - call ASM_PFX(SmmStmExceptionHandler) - addq $0x28, %rsp - movl %eax, %ebx - movl $4, %eax - .byte 0xf, 0x1, 0xc1 # VMCALL - jmp . - -ASM_GLOBAL ASM_PFX(_OnStmSetup) -ASM_PFX(_OnStmSetup): -# -# Check XD disable bit -# - xorq %r8, %r8 - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz StmXdDone1 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone1: - pushq %r8 - - subq $0x20, %rsp - call ASM_PFX(SmmStmSetup) - addq 0x20, %rsp - - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz L14 - popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L14 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr -L14: - - rsm - -ASM_GLOBAL ASM_PFX(_OnStmTeardown) -ASM_PFX(_OnStmTeardown): -# -# Check XD disable bit -# - xorq %r8, %r8 - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz StmXdDone2 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L15 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L15: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -StmXdDone2: - pushq %r8 - - subq $0x20, %rsp - call ASM_PFX(SmmStmTeardown) - addq $0x20, %rsp - - movabsq $ASM_PFX(gStmXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz L16 - popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr -L16: - - rsm - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm deleted file mode 100644 index 33e9860160..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.asm +++ /dev/null @@ -1,178 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.asm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -EXTERNDEF gcStmPsd:BYTE - -EXTERNDEF SmmStmExceptionHandler:PROC -EXTERNDEF SmmStmSetup:PROC -EXTERNDEF SmmStmTeardown:PROC -EXTERNDEF gStmXdSupported:BYTE - -CODE_SEL EQU 38h -DATA_SEL EQU 20h -TR_SEL EQU 40h - -MSR_IA32_MISC_ENABLE EQU 1A0h -MSR_EFER EQU 0c0000080h -MSR_EFER_XD EQU 0800h - - .data - -; -; This structure serves as a template for all processors. -; -gcStmPsd LABEL BYTE - DB 'TXTPSSIG' - DW PSD_SIZE - DW 1 ; Version - DD 0 ; LocalApicId - DB 0Fh ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - DB 0 ; BIOS to STM - DB 0 ; STM to BIOS - DB 0 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW TR_SEL - DW 0 - DQ 0 ; SmmCr3 - DQ _OnStmSetup - DQ _OnStmTeardown - DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint - DQ 0 ; SmmSmiHandlerRsp - DQ 0 - DD 0 - DD 80010100h ; RequiredStmSmmRevId - DQ _OnException - DQ 0 ; ExceptionStack - DW DATA_SEL - DW 01Fh ; ExceptionFilter - DD 0 - DQ 0 - DQ 0 ; BiosHwResourceRequirementsPtr - DQ 0 ; AcpiRsdp - DB 0 ; PhysicalAddressBits -PSD_SIZE = $ - offset gcStmPsd - - .code -;------------------------------------------------------------------------------ -; SMM Exception handlers -;------------------------------------------------------------------------------ -_OnException PROC - mov rcx, rsp - add rsp, -28h - call SmmStmExceptionHandler - add rsp, 28h - mov ebx, eax - mov eax, 4 - DB 0fh, 01h, 0c1h ; VMCALL - jmp $ -_OnException ENDP - -_OnStmSetup PROC -; -; Check XD disable bit -; - xor r8, r8 - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone1: - push r8 - - add rsp, -20h - call SmmStmSetup - add rsp, 20h - - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @f - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr -@@: - - rsm -_OnStmSetup ENDP - -_OnStmTeardown PROC -; -; Check XD disable bit -; - xor r8, r8 - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone2 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone2: - push r8 - - add rsp, -20h - call SmmStmTeardown - add rsp, 20h - - mov rax, offset ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @f - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr -@@: - - rsm -_OnStmTeardown ENDP - - END diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm deleted file mode 100644 index fe1bf3f165..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm +++ /dev/null @@ -1,179 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.nasm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -global ASM_PFX(gcStmPsd) - -extern ASM_PFX(SmmStmExceptionHandler) -extern ASM_PFX(SmmStmSetup) -extern ASM_PFX(SmmStmTeardown) -extern ASM_PFX(gStmXdSupported) -extern ASM_PFX(gStmSmiHandlerIdtr) - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -CODE_SEL equ 0x38 -DATA_SEL equ 0x20 -TR_SEL equ 0x40 - - SECTION .data - -; -; This structure serves as a template for all processors. -; -ASM_PFX(gcStmPsd): - DB 'TXTPSSIG' - DW PSD_SIZE - DW 1 ; Version - DD 0 ; LocalApicId - DB 0x0F ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr - DB 0 ; BIOS to STM - DB 0 ; STM to BIOS - DB 0 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW TR_SEL - DW 0 - DQ 0 ; SmmCr3 - DQ ASM_PFX(OnStmSetup) - DQ ASM_PFX(OnStmTeardown) - DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint - DQ 0 ; SmmSmiHandlerRsp - DQ 0 - DD 0 - DD 0x80010100 ; RequiredStmSmmRevId - DQ ASM_PFX(OnException) - DQ 0 ; ExceptionStack - DW DATA_SEL - DW 0x01F ; ExceptionFilter - DD 0 - DQ 0 - DQ 0 ; BiosHwResourceRequirementsPtr - DQ 0 ; AcpiRsdp - DB 0 ; PhysicalAddressBits -PSD_SIZE equ $ - ASM_PFX(gcStmPsd) - - DEFAULT REL - SECTION .text -;------------------------------------------------------------------------------ -; SMM Exception handlers -;------------------------------------------------------------------------------ -global ASM_PFX(OnException) -ASM_PFX(OnException): - mov rcx, rsp - add rsp, -0x28 - call ASM_PFX(SmmStmExceptionHandler) - add rsp, 0x28 - mov ebx, eax - mov eax, 4 - DB 0x0f, 0x01, 0x0c1 ; VMCALL - jmp $ - -global ASM_PFX(OnStmSetup) -ASM_PFX(OnStmSetup): -; -; Check XD disable bit -; - xor r8, r8 - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .01 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.01: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone1: - push r8 - - add rsp, -0x20 - call ASM_PFX(SmmStmSetup) - add rsp, 0x20 - - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz .11 - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .11 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.11: - rsm - -global ASM_PFX(OnStmTeardown) -ASM_PFX(OnStmTeardown): -; -; Check XD disable bit -; - xor r8, r8 - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz @StmXdDone2 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .02 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.02: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr -@StmXdDone2: - push r8 - - add rsp, -0x20 - call ASM_PFX(SmmStmTeardown) - add rsp, 0x20 - - mov rax, ASM_PFX(gStmXdSupported) - mov al, [rax] - cmp al, 0 - jz .12 - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .12 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.12: - rsm - diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c deleted file mode 100644 index 6681234783..0000000000 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - SMM STM support functions - - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "SmmStm.h" - -/// -/// Page Table Entry -/// -#define IA32_PG_P BIT0 -#define IA32_PG_RW BIT1 -#define IA32_PG_PS BIT7 - -/** - - Create 4G page table for STM. - 2M PAE page table in X64 version. - - @param PageTableBase The page table base in MSEG - -**/ -VOID -StmGen4GPageTable ( - IN UINTN PageTableBase - ) -{ - UINTN Index; - UINTN SubIndex; - UINT64 *Pde; - UINT64 *Pte; - UINT64 *Pml4; - - Pml4 = (UINT64*)(UINTN)PageTableBase; - PageTableBase += SIZE_4KB; - *Pml4 = PageTableBase | IA32_PG_RW | IA32_PG_P; - - Pde = (UINT64*)(UINTN)PageTableBase; - PageTableBase += SIZE_4KB; - Pte = (UINT64 *)(UINTN)PageTableBase; - - for (Index = 0; Index < 4; Index++) { - *Pde = PageTableBase | IA32_PG_RW | IA32_PG_P; - Pde++; - PageTableBase += SIZE_4KB; - - for (SubIndex = 0; SubIndex < SIZE_4KB / sizeof (*Pte); SubIndex++) { - *Pte = (((Index << 9) + SubIndex) << 21) | IA32_PG_PS | IA32_PG_RW | IA32_PG_P; - Pte++; - } - } -} - -/** - This is SMM exception handle. - Consumed by STM when exception happen. - - @param Context STM protection exception stack frame - - @return the EBX value for STM reference. - EBX = 0: resume SMM guest using register state found on exception stack. - EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the - TXT.ERRORCODE register and subsequently reset the system via - TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as - follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC - EBX = 0x10 to 0xFFFFFFFF - reserved, do not use. - -**/ -UINT32 -EFIAPI -SmmStmExceptionHandler ( - IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context - ) -{ - // TBD - SmmStmExceptionHandler, record information - DEBUG ((DEBUG_ERROR, "SmmStmExceptionHandler ...\n")); - // - // Skip this instruction and continue; - // - Context.X64StackFrame->Rip += Context.X64StackFrame->VmcsExitInstructionLength; - - return 0; -} diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c deleted file mode 100644 index efb61fa6f8..0000000000 --- a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c +++ /dev/null @@ -1,108 +0,0 @@ -/** @file -SMM CPU Platform Hook NULL library instance. - -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include -#include - -/** - Checks if platform produces a valid SMI. - - This function checks if platform produces a valid SMI. This function is - called at SMM entry to detect if this is a spurious SMI. This function - must be implemented in an MP safe way because it is called by multiple CPU - threads. - - @retval TRUE There is a valid SMI - @retval FALSE There is no valid SMI - -**/ -BOOLEAN -EFIAPI -PlatformValidSmi ( - VOID - ) -{ - return TRUE; -} - -/** - Clears platform top level SMI status bit. - - This function clears platform top level SMI status bit. - - @retval TRUE The platform top level SMI status is cleared. - @retval FALSE The platform top level SMI status cannot be cleared. - -**/ -BOOLEAN -EFIAPI -ClearTopLevelSmiStatus ( - VOID - ) -{ - return TRUE; -} - -/** - Performs platform specific way of SMM BSP election. - - This function performs platform specific way of SMM BSP election. - - @param IsBsp Output parameter. TRUE: the CPU this function executes - on is elected to be the SMM BSP. FALSE: the CPU this - function executes on is to be SMM AP. - - @retval EFI_SUCCESS The function executes successfully. - @retval EFI_NOT_READY The function does not determine whether this CPU should be - BSP or AP. This may occur if hardware init sequence to - enable the determination is yet to be done, or the function - chooses not to do BSP election and will let SMM CPU driver to - use its default BSP election process. - @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU should be - BSP or AP due to hardware error. - -**/ -EFI_STATUS -EFIAPI -PlatformSmmBspElection ( - OUT BOOLEAN *IsBsp - ) -{ - return EFI_NOT_READY; -} - -/** - Get platform page table attribute. - - This function gets page table attribute of platform. - - @param Address Input parameter. Obtain the page table entries attribute on this address. - @param PageSize Output parameter. The size of the page. - @param NumOfPages Output parameter. Number of page. - @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc). - - @retval EFI_SUCCESS The platform page table attribute from the address is determined. - @retval EFI_UNSUPPORTED The platform does not support getting page table attribute for the address. - -**/ -EFI_STATUS -EFIAPI -GetPlatformPageTableAttribute ( - IN UINT64 Address, - IN OUT SMM_PAGE_SIZE_TYPE *PageSize, - IN OUT UINTN *NumOfPages, - IN OUT UINTN *PageAttribute - ) -{ - return EFI_UNSUPPORTED; -} diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf deleted file mode 100644 index 4dea5fb4e1..0000000000 --- a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# SMM CPU Platform Hook NULL library instance. -# -# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -################################################################################ -# -# Defines Section - statements that will be processed to create a Makefile. -# -################################################################################ -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmCpuPlatformHookLibNull - MODULE_UNI_FILE = SmmCpuPlatformHookLibNull.uni - FILE_GUID = D6494E1B-E06F-4ab5-B64D-48B25AA9EB33 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmmCpuPlatformHookLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - SmmCpuPlatformHookLibNull.c - -[Packages] - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec diff --git a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni b/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni deleted file mode 100644 index 46de9f3494..0000000000 --- a/UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// SMM CPU Platform Hook NULL library instance. -// -// Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "SMM CPU Platform Hook NULL library instance" - -#string STR_MODULE_DESCRIPTION #language en-US "SMM CPU Platform Hook NULL library instance." diff --git a/UefiCpuPkg/License.txt b/UefiCpuPkg/License.txt deleted file mode 100644 index be68999be6..0000000000 --- a/UefiCpuPkg/License.txt +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2012, Intel Corporation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c deleted file mode 100644 index aaeaa06729..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.c +++ /dev/null @@ -1,425 +0,0 @@ -/** @file -PiSmmCommunication PEI Driver. - -Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PiSmmCommunicationPrivate.h" - -/** - the whole picture is below: - - +----------------------------------+ - | ACPI_VARIABLE_HOB | - | SmramDescriptor | <- DRAM - | CpuStart |--- - +----------------------------------+ | - | - +----------------------------------+<-- - | SMM_S3_RESUME_STATE | - | Signature | <- SMRAM - | Smst |--- - +----------------------------------+ | - | - +----------------------------------+<-- - | EFI_SMM_SYSTEM_TABLE2 | - | NumberOfTableEntries | <- SMRAM - | SmmConfigurationTable |--- - +----------------------------------+ | - | - +----------------------------------+<-- - | EFI_SMM_COMMUNICATION_CONTEXT | - | SwSmiNumber | <- SMRAM - | BufferPtrAddress |---------------- - +----------------------------------+ | - | - +----------------------------------+ | - | EFI_SMM_COMMUNICATION_ACPI_TABLE | | - | SwSmiNumber | <- AcpiTable | - | BufferPtrAddress |--- | - +----------------------------------+ | | - | | - +----------------------------------+<--------------- - | Communication Buffer Pointer | <- AcpiNvs - +----------------------------------+--- - | - +----------------------------------+<-- - | EFI_SMM_COMMUNICATE_HEADER | - | HeaderGuid | <- DRAM - | MessageLength | - +----------------------------------+ - -**/ - -#if defined (MDE_CPU_IA32) -typedef struct { - EFI_TABLE_HEADER Hdr; - UINT64 SmmFirmwareVendor; - UINT64 SmmFirmwareRevision; - UINT64 SmmInstallConfigurationTable; - UINT64 SmmIoMemRead; - UINT64 SmmIoMemWrite; - UINT64 SmmIoIoRead; - UINT64 SmmIoIoWrite; - UINT64 SmmAllocatePool; - UINT64 SmmFreePool; - UINT64 SmmAllocatePages; - UINT64 SmmFreePages; - UINT64 SmmStartupThisAp; - UINT64 CurrentlyExecutingCpu; - UINT64 NumberOfCpus; - UINT64 CpuSaveStateSize; - UINT64 CpuSaveState; - UINT64 NumberOfTableEntries; - UINT64 SmmConfigurationTable; -} EFI_SMM_SYSTEM_TABLE2_64; - -typedef struct { - EFI_GUID VendorGuid; - UINT64 VendorTable; -} EFI_CONFIGURATION_TABLE64; -#endif - -#if defined (MDE_CPU_X64) -typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64; -typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64; -#endif - -/** - Communicates with a registered handler. - - This function provides a service to send and receive messages from a registered UEFI service. - - @param[in] This The EFI_PEI_SMM_COMMUNICATION_PPI instance. - @param[in, out] CommBuffer A pointer to the buffer to convey into SMRAM. - @param[in, out] CommSize The size of the data buffer being passed in.On exit, the size of data - being returned. Zero if the handler does not wish to reply with any data. - - @retval EFI_SUCCESS The message was successfully posted. - @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. - @retval EFI_NOT_STARTED The service is NOT started. -**/ -EFI_STATUS -EFIAPI -Communicate ( - IN CONST EFI_PEI_SMM_COMMUNICATION_PPI *This, - IN OUT VOID *CommBuffer, - IN OUT UINTN *CommSize - ); - -EFI_PEI_SMM_COMMUNICATION_PPI mSmmCommunicationPpi = { Communicate }; - -EFI_PEI_PPI_DESCRIPTOR mPpiList = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiSmmCommunicationPpiGuid, - &mSmmCommunicationPpi -}; - -/** - Get SMM communication context. - - @return SMM communication context. -**/ -EFI_SMM_COMMUNICATION_CONTEXT * -GetCommunicationContext ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; - - GuidHob = GetFirstGuidHob (&gEfiPeiSmmCommunicationPpiGuid); - ASSERT (GuidHob != NULL); - - SmmCommunicationContext = (EFI_SMM_COMMUNICATION_CONTEXT *)GET_GUID_HOB_DATA (GuidHob); - - return SmmCommunicationContext; -} - -/** - Set SMM communication context. - - @param SmmCommunicationContext SMM communication context. -**/ -VOID -SetCommunicationContext ( - IN EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext - ) -{ - EFI_PEI_HOB_POINTERS Hob; - UINTN BufferSize; - - BufferSize = sizeof (*SmmCommunicationContext); - Hob.Raw = BuildGuidHob ( - &gEfiPeiSmmCommunicationPpiGuid, - BufferSize - ); - ASSERT (Hob.Raw); - - CopyMem ((VOID *)Hob.Raw, SmmCommunicationContext, sizeof(*SmmCommunicationContext)); -} - -/** - Get VendorTable by VendorGuid in Smst. - - @param Signature Signature of SMM_S3_RESUME_STATE - @param Smst SMM system table - @param VendorGuid vendor guid - - @return vendor table. -**/ -VOID * -InternalSmstGetVendorTableByGuid ( - IN UINT64 Signature, - IN EFI_SMM_SYSTEM_TABLE2 *Smst, - IN EFI_GUID *VendorGuid - ) -{ - EFI_CONFIGURATION_TABLE *SmmConfigurationTable; - UINTN NumberOfTableEntries; - UINTN Index; - EFI_SMM_SYSTEM_TABLE2_64 *Smst64; - EFI_CONFIGURATION_TABLE64 *SmmConfigurationTable64; - - if ((sizeof(UINTN) == sizeof(UINT32)) && (Signature == SMM_S3_RESUME_SMM_64)) { - // - // 32 PEI + 64 DXE - // - Smst64 = (EFI_SMM_SYSTEM_TABLE2_64 *)Smst; - DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmConfigurationTable: %x\n", Smst64->SmmConfigurationTable)); - DEBUG ((EFI_D_INFO, "InitCommunicationContext - NumberOfTableEntries: %x\n", Smst64->NumberOfTableEntries)); - SmmConfigurationTable64 = (EFI_CONFIGURATION_TABLE64 *)(UINTN)Smst64->SmmConfigurationTable; - NumberOfTableEntries = (UINTN)Smst64->NumberOfTableEntries; - for (Index = 0; Index < NumberOfTableEntries; Index++) { - if (CompareGuid (&SmmConfigurationTable64[Index].VendorGuid, VendorGuid)) { - return (VOID *)(UINTN)SmmConfigurationTable64[Index].VendorTable; - } - } - return NULL; - } else { - DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmConfigurationTable: %x\n", Smst->SmmConfigurationTable)); - DEBUG ((EFI_D_INFO, "InitCommunicationContext - NumberOfTableEntries: %x\n", Smst->NumberOfTableEntries)); - SmmConfigurationTable = Smst->SmmConfigurationTable; - NumberOfTableEntries = Smst->NumberOfTableEntries; - for (Index = 0; Index < NumberOfTableEntries; Index++) { - if (CompareGuid (&SmmConfigurationTable[Index].VendorGuid, VendorGuid)) { - return (VOID *)SmmConfigurationTable[Index].VendorTable; - } - } - return NULL; - } -} - -/** - Init SMM communication context. -**/ -VOID -InitCommunicationContext ( - VOID - ) -{ - EFI_SMRAM_DESCRIPTOR *SmramDescriptor; - SMM_S3_RESUME_STATE *SmmS3ResumeState; - VOID *GuidHob; - EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; - - GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); - ASSERT (GuidHob != NULL); - SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); - SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; - - DEBUG ((EFI_D_INFO, "InitCommunicationContext - SmmS3ResumeState: %x\n", SmmS3ResumeState)); - DEBUG ((EFI_D_INFO, "InitCommunicationContext - Smst: %x\n", SmmS3ResumeState->Smst)); - - SmmCommunicationContext = (EFI_SMM_COMMUNICATION_CONTEXT *)InternalSmstGetVendorTableByGuid ( - SmmS3ResumeState->Signature, - (EFI_SMM_SYSTEM_TABLE2 *)(UINTN)SmmS3ResumeState->Smst, - &gEfiPeiSmmCommunicationPpiGuid - ); - ASSERT (SmmCommunicationContext != NULL); - - SetCommunicationContext (SmmCommunicationContext); - - return ; -} - -/** - Communicates with a registered handler. - - This function provides a service to send and receive messages from a registered UEFI service. - - @param[in] This The EFI_PEI_SMM_COMMUNICATION_PPI instance. - @param[in, out] CommBuffer A pointer to the buffer to convey into SMRAM. - @param[in, out] CommSize The size of the data buffer being passed in.On exit, the size of data - being returned. Zero if the handler does not wish to reply with any data. - - @retval EFI_SUCCESS The message was successfully posted. - @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. - @retval EFI_NOT_STARTED The service is NOT started. -**/ -EFI_STATUS -EFIAPI -Communicate ( - IN CONST EFI_PEI_SMM_COMMUNICATION_PPI *This, - IN OUT VOID *CommBuffer, - IN OUT UINTN *CommSize - ) -{ - EFI_STATUS Status; - PEI_SMM_CONTROL_PPI *SmmControl; - PEI_SMM_ACCESS_PPI *SmmAccess; - UINT8 SmiCommand; - UINTN Size; - EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext; - - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei Communicate Enter\n")); - - if (CommBuffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Get needed resource - // - Status = PeiServicesLocatePpi ( - &gPeiSmmControlPpiGuid, - 0, - NULL, - (VOID **)&SmmControl - ); - if (EFI_ERROR (Status)) { - return EFI_NOT_STARTED; - } - - Status = PeiServicesLocatePpi ( - &gPeiSmmAccessPpiGuid, - 0, - NULL, - (VOID **)&SmmAccess - ); - if (EFI_ERROR (Status)) { - return EFI_NOT_STARTED; - } - - // - // Check SMRAM locked, it should be done after SMRAM lock. - // - if (!SmmAccess->LockState) { - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei LockState - %x\n", (UINTN)SmmAccess->LockState)); - return EFI_NOT_STARTED; - } - - SmmCommunicationContext = GetCommunicationContext (); - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei BufferPtrAddress - 0x%016lx, BufferPtr: 0x%016lx\n", SmmCommunicationContext->BufferPtrAddress, *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress)); - - // - // No need to check if BufferPtr is 0, because it is in PEI phase. - // - *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer; - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei CommBuffer - %x\n", (UINTN)CommBuffer)); - - // - // Send command - // - SmiCommand = (UINT8)SmmCommunicationContext->SwSmiNumber; - Size = sizeof(SmiCommand); - Status = SmmControl->Trigger ( - (EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), - SmmControl, - (INT8 *)&SmiCommand, - &Size, - FALSE, - 0 - ); - ASSERT_EFI_ERROR (Status); - - // - // Setting BufferPtr to 0 means this transaction is done. - // - *(EFI_PHYSICAL_ADDRESS *)(UINTN)SmmCommunicationContext->BufferPtrAddress = 0; - - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei Communicate Exit\n")); - - return EFI_SUCCESS; -} - -/** - Entry Point for PI SMM communication PEIM. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Pointer to PEI Services table. - - @retval EFI_SUCEESS - @return Others Some error occurs. -**/ -EFI_STATUS -EFIAPI -PiSmmCommunicationPeiEntryPoint ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - PEI_SMM_ACCESS_PPI *SmmAccess; - EFI_BOOT_MODE BootMode; - UINTN Index; - - BootMode = GetBootModeHob (); - if (BootMode != BOOT_ON_S3_RESUME) { - return EFI_UNSUPPORTED; - } - - Status = PeiServicesLocatePpi ( - &gPeiSmmAccessPpiGuid, - 0, - NULL, - (VOID **)&SmmAccess - ); - if (EFI_ERROR (Status)) { - return EFI_NOT_STARTED; - } - - // - // Check SMRAM locked, it should be done before SMRAM lock. - // - if (SmmAccess->LockState) { - DEBUG ((EFI_D_INFO, "PiSmmCommunicationPei LockState - %x\n", (UINTN)SmmAccess->LockState)); - return EFI_ACCESS_DENIED; - } - - // - // Open all SMRAM - // - for (Index = 0; !EFI_ERROR (Status); Index++) { - Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); - } - - InitCommunicationContext (); - - PeiServicesInstallPpi (&mPpiList); - - return RETURN_SUCCESS; -} diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf deleted file mode 100644 index 5cb596c564..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf +++ /dev/null @@ -1,70 +0,0 @@ -## @file -# PI SMM Communication PEIM which produces PEI SMM Communication PPI. -# -# This PEIM retrieves the SMM communication context and produces PEI SMM -# Communication PPIin the S3 boot mode. -# -# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PiSmmCommunicationPei - MODULE_UNI_FILE = PiSmmCommunicationPei.uni - FILE_GUID = 1C8B7F78-1699-40e6-AF33-9B995D16B043 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = PiSmmCommunicationPeiEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - PiSmmCommunicationPei.c - PiSmmCommunicationPrivate.h - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - PeimEntryPoint - PeiServicesTablePointerLib - PeiServicesLib - BaseLib - BaseMemoryLib - HobLib - DebugLib - -[Guids] - gEfiAcpiVariableGuid ## CONSUMES ## HOB - -[Ppis] - ## PRODUCES - ## UNDEFINED # HOB # SMM Configuration Table - gEfiPeiSmmCommunicationPpiGuid - gPeiSmmAccessPpiGuid ## CONSUMES - gPeiSmmControlPpiGuid ## CONSUMES - -# [BootMode] -# S3_RESUME ## CONSUMES - -[Depex] - gPeiSmmAccessPpiGuid AND - gPeiSmmControlPpiGuid AND - gEfiPeiMasterBootModePpiGuid - -[UserExtensions.TianoCore."ExtraFiles"] - PiSmmCommunicationPeiExtra.uni diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni deleted file mode 100644 index 697bb2b3d9..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// PI SMM Communication PEIM which produces PEI SMM Communication PPI. -// -// This PEIM retrieves the SMM communication context and produces PEI SMM -// Communication PPIin the S3 boot mode. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "PI SMM Communication PEIM that produces PEI SMM Communication PPI" - -#string STR_MODULE_DESCRIPTION #language en-US "This PEIM retrieves the SMM communication context and produces PEI SMM Communication PPI in the S3 boot mode." diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni deleted file mode 100644 index 62e3f97928..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPeiExtra.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// PiSmmCommunicationPei Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"SMM Communication PEI Module" diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h deleted file mode 100644 index 3dd5ac6e38..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPrivate.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file -PiSmmCommunication private data structure - -Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_COMMUNICATION_PRIVATE_H_ -#define _SMM_COMMUNICATION_PRIVATE_H_ - -#pragma pack(push, 1) - -#define SMM_COMMUNICATION_SIGNATURE SIGNATURE_32 ('S','M','M','C') - -typedef struct { - UINT32 Signature; - UINT32 SwSmiNumber; - EFI_PHYSICAL_ADDRESS BufferPtrAddress; -} EFI_SMM_COMMUNICATION_CONTEXT; - -#pragma pack(pop) - -#endif diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c deleted file mode 100644 index 077eacce88..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.c +++ /dev/null @@ -1,269 +0,0 @@ -/** @file -PiSmmCommunication SMM Driver. - -Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PiSmmCommunicationPrivate.h" - -EFI_SMM_COMMUNICATION_CONTEXT mSmmCommunicationContext = { - SMM_COMMUNICATION_SIGNATURE -}; - -EFI_SMM_COMMUNICATION_ACPI_TABLE mSmmCommunicationAcpiTable = { - { - { - EFI_ACPI_4_0_UEFI_ACPI_DATA_TABLE_SIGNATURE, - sizeof (EFI_SMM_COMMUNICATION_ACPI_TABLE), - 0x1, // Revision - 0x0, // Checksum - {0x0}, // OemId[6] - 0x0, // OemTableId - 0x0, // OemRevision - 0x0, // CreatorId - 0x0 // CreatorRevision - }, - {0x0}, // Identifier - OFFSET_OF (EFI_SMM_COMMUNICATION_ACPI_TABLE, SwSmiNumber) // DataOffset - }, - 0x0, // SwSmiNumber - 0x0 // BufferPtrAddress -}; - -/** - Set SMM communication context. -**/ -VOID -SetCommunicationContext ( - VOID - ) -{ - EFI_STATUS Status; - - Status = gSmst->SmmInstallConfigurationTable ( - gSmst, - &gEfiPeiSmmCommunicationPpiGuid, - &mSmmCommunicationContext, - sizeof(mSmmCommunicationContext) - ); - ASSERT_EFI_ERROR (Status); -} - -/** - Dispatch function for a Software SMI handler. - - @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). - @param Context Points to an optional handler context which was specified when the - handler was registered. - @param CommBuffer A pointer to a collection of data in memory that will - be conveyed from a non-SMM environment into an SMM environment. - @param CommBufferSize The size of the CommBuffer. - - @retval EFI_SUCCESS Command is handled successfully. - -**/ -EFI_STATUS -EFIAPI -PiSmmCommunicationHandler ( - IN EFI_HANDLE DispatchHandle, - IN CONST VOID *Context OPTIONAL, - IN OUT VOID *CommBuffer OPTIONAL, - IN OUT UINTN *CommBufferSize OPTIONAL - ) -{ - UINTN CommSize; - EFI_STATUS Status; - EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader; - EFI_PHYSICAL_ADDRESS *BufferPtrAddress; - - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Enter\n")); - - BufferPtrAddress = (EFI_PHYSICAL_ADDRESS *)(UINTN)mSmmCommunicationContext.BufferPtrAddress; - CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)(UINTN)*BufferPtrAddress; - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateHeader - %x\n", CommunicateHeader)); - if (CommunicateHeader == NULL) { - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler is NULL, needn't to call dispatch function\n")); - Status = EFI_SUCCESS; - } else { - if (!SmmIsBufferOutsideSmmValid ((UINTN)CommunicateHeader, OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))) { - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateHeader invalid - 0x%x\n", CommunicateHeader)); - Status = EFI_SUCCESS; - goto Done; - } - - CommSize = (UINTN)CommunicateHeader->MessageLength; - if (!SmmIsBufferOutsideSmmValid ((UINTN)&CommunicateHeader->Data[0], CommSize)) { - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler CommunicateData invalid - 0x%x\n", &CommunicateHeader->Data[0])); - Status = EFI_SUCCESS; - goto Done; - } - - // - // Call dispatch function - // - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Data - %x\n", &CommunicateHeader->Data[0])); - Status = gSmst->SmiManage ( - &CommunicateHeader->HeaderGuid, - NULL, - &CommunicateHeader->Data[0], - &CommSize - ); - } - -Done: - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler %r\n", Status)); - DEBUG ((EFI_D_INFO, "PiSmmCommunicationHandler Exit\n")); - - return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_INTERRUPT_PENDING; -} - -/** - Allocate EfiACPIMemoryNVS below 4G memory address. - - This function allocates EfiACPIMemoryNVS below 4G memory address. - - @param Size Size of memory to allocate. - - @return Allocated address for output. - -**/ -VOID* -AllocateAcpiNvsMemoryBelow4G ( - IN UINTN Size - ) -{ - UINTN Pages; - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - VOID* Buffer; - - Pages = EFI_SIZE_TO_PAGES (Size); - Address = 0xffffffff; - - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - Pages, - &Address - ); - ASSERT_EFI_ERROR (Status); - - Buffer = (VOID *) (UINTN) Address; - ZeroMem (Buffer, Size); - - return Buffer; -} - -/** - Entry Point for PI SMM communication SMM driver. - - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable A Pointer to the EFI System Table. - - @retval EFI_SUCEESS - @return Others Some error occurs. -**/ -EFI_STATUS -EFIAPI -PiSmmCommunicationSmmEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_SMM_SW_DISPATCH2_PROTOCOL *SmmSwDispatch2; - EFI_SMM_SW_REGISTER_CONTEXT SmmSwDispatchContext; - EFI_HANDLE DispatchHandle; - EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; - UINTN TableKey; - UINT64 OemTableId; - EFI_PHYSICAL_ADDRESS *BufferPtrAddress; - - CopyMem ( - mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemId, - PcdGetPtr (PcdAcpiDefaultOemId), - sizeof (mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemId) - ); - OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId); - CopyMem (&mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemTableId, &OemTableId, sizeof (UINT64)); - mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); - mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId); - mSmmCommunicationAcpiTable.UefiAcpiDataTable.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision); - - // - // Register software SMI handler - // - Status = gSmst->SmmLocateProtocol ( - &gEfiSmmSwDispatch2ProtocolGuid, - NULL, - (VOID **)&SmmSwDispatch2 - ); - ASSERT_EFI_ERROR (Status); - - SmmSwDispatchContext.SwSmiInputValue = (UINTN)-1; - Status = SmmSwDispatch2->Register ( - SmmSwDispatch2, - PiSmmCommunicationHandler, - &SmmSwDispatchContext, - &DispatchHandle - ); - ASSERT_EFI_ERROR (Status); - - DEBUG ((EFI_D_INFO, "SmmCommunication SwSmi: %x\n", (UINTN)SmmSwDispatchContext.SwSmiInputValue)); - - // - // Set ACPI table - // - Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); - ASSERT_EFI_ERROR (Status); - - mSmmCommunicationAcpiTable.SwSmiNumber = (UINT32)SmmSwDispatchContext.SwSmiInputValue; - BufferPtrAddress = AllocateAcpiNvsMemoryBelow4G (sizeof(EFI_PHYSICAL_ADDRESS)); - ASSERT (BufferPtrAddress != NULL); - DEBUG ((EFI_D_INFO, "SmmCommunication BufferPtrAddress: 0x%016lx, BufferPtr: 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)BufferPtrAddress, *BufferPtrAddress)); - mSmmCommunicationAcpiTable.BufferPtrAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)BufferPtrAddress; - CopyMem (&mSmmCommunicationAcpiTable.UefiAcpiDataTable.Identifier, &gEfiSmmCommunicationProtocolGuid, sizeof(gEfiSmmCommunicationProtocolGuid)); - - Status = AcpiTableProtocol->InstallAcpiTable ( - AcpiTableProtocol, - &mSmmCommunicationAcpiTable, - sizeof(mSmmCommunicationAcpiTable), - &TableKey - ); - ASSERT_EFI_ERROR (Status); - - // - // Save context - // - mSmmCommunicationContext.SwSmiNumber = (UINT32)SmmSwDispatchContext.SwSmiInputValue; - mSmmCommunicationContext.BufferPtrAddress = mSmmCommunicationAcpiTable.BufferPtrAddress; - SetCommunicationContext (); - - return Status; -} diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf deleted file mode 100644 index 9b03837cf3..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf +++ /dev/null @@ -1,82 +0,0 @@ -## @file -# PI SMM Communication SMM driver that installs the SMM Communication ACPI Table. -# -# This SMM driver installs the SMM Communication ACPI Table defined in the UEFI spec -# which provides a mechanism that can be used in the OS present environment by -# non-firmware agents for inter-mode communication with SMM agents. It also saves -# SMM communication context for use by SMM Communication PEIM in the S3 boot mode. -# -# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PiSmmCommunicationSmm - MODULE_UNI_FILE = PiSmmCommunicationSmm.uni - FILE_GUID = E21F35A8-42FF-4050-82D6-93F7CDFA7073 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x0001000A - ENTRY_POINT = PiSmmCommunicationSmmEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - PiSmmCommunicationSmm.c - PiSmmCommunicationPrivate.h - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - SmmServicesTableLib - BaseLib - BaseMemoryLib - HobLib - DebugLib - SmmMemLib - PcdLib - -[Guids] - gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## SystemTable - -[Ppis] - gEfiPeiSmmCommunicationPpiGuid ## UNDEFINED # SMM Configuration Table - -[Protocols] - gEfiSmmSwDispatch2ProtocolGuid ## CONSUMES - gEfiSmmCommunicationProtocolGuid ## UNDEFINED # SMM Communication ACPI Table GUID - gEfiAcpiTableProtocolGuid ## CONSUMES - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES - -[Depex] - gEfiSmmSwDispatch2ProtocolGuid AND - gEfiAcpiTableProtocolGuid - -[UserExtensions.TianoCore."ExtraFiles"] - PiSmmCommunicationSmmExtra.uni diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni deleted file mode 100644 index 55df3905df..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file -// PI SMM Communication SMM driver that installs the SMM Communication ACPI Table. -// -// This SMM driver installs the SMM Communication ACPI Table defined in the UEFI spec -// which provides a mechanism that can be used in the OS present environment by -// non-firmware agents for inter-mode communication with SMM agents. It also saves -// SMM communication context for use by SMM Communication PEIM in the S3 boot mode. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "PI SMM Communication SMM driver that installs the SMM Communication ACPI Table" - -#string STR_MODULE_DESCRIPTION #language en-US "This SMM driver installs the SMM Communication ACPI Table defined in the UEFI Specification, which provides a mechanism that can be used in the OS-present environment by non-firmware agents for inter-mode communication with SMM agents. It also saves an SMM communication context for use by SMM Communication PEIM in the S3 boot mode." diff --git a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni b/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni deleted file mode 100644 index 34e7731fb5..0000000000 --- a/UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmmExtra.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// PiSmmCommunicationSmm Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"SMM Communication ACPI Table DXE Driver" diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c deleted file mode 100644 index 9404501498..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ /dev/null @@ -1,945 +0,0 @@ -/** @file -Code for Processor S3 restoration - -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -typedef struct { - UINTN Lock; - VOID *StackStart; - UINTN StackSize; - VOID *ApFunction; - IA32_DESCRIPTOR GdtrProfile; - IA32_DESCRIPTOR IdtrProfile; - UINT32 BufferStart; - UINT32 Cr3; -} MP_CPU_EXCHANGE_INFO; - -typedef struct { - UINT8 *RendezvousFunnelAddress; - UINTN PModeEntryOffset; - UINTN FlatJumpOffset; - UINTN Size; - UINTN LModeEntryOffset; - UINTN LongJumpOffset; -} MP_ASSEMBLY_ADDRESS_MAP; - -// -// Spin lock used to serialize MemoryMapped operation -// -SPIN_LOCK *mMemoryMappedLock = NULL; - -/** - Get starting address and size of the rendezvous entry for APs. - Information for fixing a jump instruction in the code is also returned. - - @param AddressMap Output buffer for address map information. -**/ -VOID * -EFIAPI -AsmGetAddressMap ( - MP_ASSEMBLY_ADDRESS_MAP *AddressMap - ); - -#define LEGACY_REGION_SIZE (2 * 0x1000) -#define LEGACY_REGION_BASE (0xA0000 - LEGACY_REGION_SIZE) - -ACPI_CPU_DATA mAcpiCpuData; -volatile UINT32 mNumberToFinish; -MP_CPU_EXCHANGE_INFO *mExchangeInfo; -BOOLEAN mRestoreSmmConfigurationInS3 = FALSE; -VOID *mGdtForAp = NULL; -VOID *mIdtForAp = NULL; -VOID *mMachineCheckHandlerForAp = NULL; -MP_MSR_LOCK *mMsrSpinLocks = NULL; -UINTN mMsrSpinLockCount; -UINTN mMsrCount = 0; - -// -// S3 boot flag -// -BOOLEAN mSmmS3Flag = FALSE; - -// -// Pointer to structure used during S3 Resume -// -SMM_S3_RESUME_STATE *mSmmS3ResumeState = NULL; - -BOOLEAN mAcpiS3Enable = TRUE; - -UINT8 *mApHltLoopCode = NULL; -UINT8 mApHltLoopCodeTemplate[] = { - 0x8B, 0x44, 0x24, 0x04, // mov eax, dword ptr [esp+4] - 0xF0, 0xFF, 0x08, // lock dec dword ptr [eax] - 0xFA, // cli - 0xF4, // hlt - 0xEB, 0xFC // jmp $-2 - }; - -/** - Get MSR spin lock by MSR index. - - @param MsrIndex MSR index value. - - @return Pointer to MSR spin lock. - -**/ -SPIN_LOCK * -GetMsrSpinLockByIndex ( - IN UINT32 MsrIndex - ) -{ - UINTN Index; - for (Index = 0; Index < mMsrCount; Index++) { - if (MsrIndex == mMsrSpinLocks[Index].MsrIndex) { - return mMsrSpinLocks[Index].SpinLock; - } - } - return NULL; -} - -/** - Initialize MSR spin lock by MSR index. - - @param MsrIndex MSR index value. - -**/ -VOID -InitMsrSpinLockByIndex ( - IN UINT32 MsrIndex - ) -{ - UINTN MsrSpinLockCount; - UINTN NewMsrSpinLockCount; - UINTN Index; - UINTN AddedSize; - - if (mMsrSpinLocks == NULL) { - MsrSpinLockCount = mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter; - mMsrSpinLocks = (MP_MSR_LOCK *) AllocatePool (sizeof (MP_MSR_LOCK) * MsrSpinLockCount); - ASSERT (mMsrSpinLocks != NULL); - for (Index = 0; Index < MsrSpinLockCount; Index++) { - mMsrSpinLocks[Index].SpinLock = - (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreMsr.Msr + Index * mSemaphoreSize); - mMsrSpinLocks[Index].MsrIndex = (UINT32)-1; - } - mMsrSpinLockCount = MsrSpinLockCount; - mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter = 0; - } - if (GetMsrSpinLockByIndex (MsrIndex) == NULL) { - // - // Initialize spin lock for MSR programming - // - mMsrSpinLocks[mMsrCount].MsrIndex = MsrIndex; - InitializeSpinLock (mMsrSpinLocks[mMsrCount].SpinLock); - mMsrCount ++; - if (mMsrCount == mMsrSpinLockCount) { - // - // If MSR spin lock buffer is full, enlarge it - // - AddedSize = SIZE_4KB; - mSmmCpuSemaphores.SemaphoreMsr.Msr = - AllocatePages (EFI_SIZE_TO_PAGES(AddedSize)); - ASSERT (mSmmCpuSemaphores.SemaphoreMsr.Msr != NULL); - NewMsrSpinLockCount = mMsrSpinLockCount + AddedSize / mSemaphoreSize; - mMsrSpinLocks = ReallocatePool ( - sizeof (MP_MSR_LOCK) * mMsrSpinLockCount, - sizeof (MP_MSR_LOCK) * NewMsrSpinLockCount, - mMsrSpinLocks - ); - ASSERT (mMsrSpinLocks != NULL); - mMsrSpinLockCount = NewMsrSpinLockCount; - for (Index = mMsrCount; Index < mMsrSpinLockCount; Index++) { - mMsrSpinLocks[Index].SpinLock = - (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreMsr.Msr + - (Index - mMsrCount) * mSemaphoreSize); - mMsrSpinLocks[Index].MsrIndex = (UINT32)-1; - } - } - } -} - -/** - Sync up the MTRR values for all processors. - - @param MtrrTable Table holding fixed/variable MTRR values to be loaded. -**/ -VOID -EFIAPI -LoadMtrrData ( - EFI_PHYSICAL_ADDRESS MtrrTable - ) -/*++ - -Routine Description: - - Sync up the MTRR values for all processors. - -Arguments: - -Returns: - None - ---*/ -{ - MTRR_SETTINGS *MtrrSettings; - - MtrrSettings = (MTRR_SETTINGS *) (UINTN) MtrrTable; - MtrrSetAllMtrrs (MtrrSettings); -} - -/** - Programs registers for the calling processor. - - This function programs registers for the calling processor. - - @param RegisterTable Pointer to register table of the running processor. - -**/ -VOID -SetProcessorRegister ( - IN CPU_REGISTER_TABLE *RegisterTable - ) -{ - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; - UINTN Index; - UINTN Value; - SPIN_LOCK *MsrSpinLock; - - // - // Traverse Register Table of this logical processor - // - RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry; - for (Index = 0; Index < RegisterTable->TableLength; Index++, RegisterTableEntry++) { - // - // Check the type of specified register - // - switch (RegisterTableEntry->RegisterType) { - // - // The specified register is Control Register - // - case ControlRegister: - switch (RegisterTableEntry->Index) { - case 0: - Value = AsmReadCr0 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINTN) RegisterTableEntry->Value - ); - AsmWriteCr0 (Value); - break; - case 2: - Value = AsmReadCr2 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINTN) RegisterTableEntry->Value - ); - AsmWriteCr2 (Value); - break; - case 3: - Value = AsmReadCr3 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINTN) RegisterTableEntry->Value - ); - AsmWriteCr3 (Value); - break; - case 4: - Value = AsmReadCr4 (); - Value = (UINTN) BitFieldWrite64 ( - Value, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINTN) RegisterTableEntry->Value - ); - AsmWriteCr4 (Value); - break; - default: - break; - } - break; - // - // The specified register is Model Specific Register - // - case Msr: - // - // If this function is called to restore register setting after INIT signal, - // there is no need to restore MSRs in register table. - // - if (RegisterTableEntry->ValidBitLength >= 64) { - // - // If length is not less than 64 bits, then directly write without reading - // - AsmWriteMsr64 ( - RegisterTableEntry->Index, - RegisterTableEntry->Value - ); - } else { - // - // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode - // to make sure MSR read/write operation is atomic. - // - MsrSpinLock = GetMsrSpinLockByIndex (RegisterTableEntry->Index); - AcquireSpinLock (MsrSpinLock); - // - // Set the bit section according to bit start and length - // - AsmMsrBitFieldWrite64 ( - RegisterTableEntry->Index, - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - RegisterTableEntry->Value - ); - ReleaseSpinLock (MsrSpinLock); - } - break; - // - // MemoryMapped operations - // - case MemoryMapped: - AcquireSpinLock (mMemoryMappedLock); - MmioBitFieldWrite32 ( - (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)), - RegisterTableEntry->ValidBitStart, - RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1, - (UINT32)RegisterTableEntry->Value - ); - ReleaseSpinLock (mMemoryMappedLock); - break; - // - // Enable or disable cache - // - case CacheControl: - // - // If value of the entry is 0, then disable cache. Otherwise, enable cache. - // - if (RegisterTableEntry->Value == 0) { - AsmDisableCache (); - } else { - AsmEnableCache (); - } - break; - - default: - break; - } - } -} - -/** - AP initialization before SMBASE relocation in the S3 boot path. -**/ -VOID -EarlyMPRendezvousProcedure ( - VOID - ) -{ - CPU_REGISTER_TABLE *RegisterTableList; - UINT32 InitApicId; - UINTN Index; - - LoadMtrrData (mAcpiCpuData.MtrrTable); - - // - // Find processor number for this CPU. - // - RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.PreSmmInitRegisterTable; - InitApicId = GetInitialApicId (); - for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { - if (RegisterTableList[Index].InitialApicId == InitApicId) { - SetProcessorRegister (&RegisterTableList[Index]); - break; - } - } - - // - // Count down the number with lock mechanism. - // - InterlockedDecrement (&mNumberToFinish); -} - -/** - AP initialization after SMBASE relocation in the S3 boot path. -**/ -VOID -MPRendezvousProcedure ( - VOID - ) -{ - CPU_REGISTER_TABLE *RegisterTableList; - UINT32 InitApicId; - UINTN Index; - UINTN TopOfStack; - UINT8 Stack[128]; - - ProgramVirtualWireMode (); - DisableLvtInterrupts (); - - RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.RegisterTable; - InitApicId = GetInitialApicId (); - for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { - if (RegisterTableList[Index].InitialApicId == InitApicId) { - SetProcessorRegister (&RegisterTableList[Index]); - break; - } - } - - // - // Place AP into the safe code, count down the number with lock mechanism in the safe code. - // - TopOfStack = (UINTN) Stack + sizeof (Stack); - TopOfStack &= ~(UINTN) (CPU_STACK_ALIGNMENT - 1); - CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate)); - TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish); -} - -/** - Prepares startup vector for APs. - - This function prepares startup vector for APs. - - @param WorkingBuffer The address of the work buffer. -**/ -VOID -PrepareApStartupVector ( - EFI_PHYSICAL_ADDRESS WorkingBuffer - ) -{ - EFI_PHYSICAL_ADDRESS StartupVector; - MP_ASSEMBLY_ADDRESS_MAP AddressMap; - - // - // Get the address map of startup code for AP, - // including code size, and offset of long jump instructions to redirect. - // - ZeroMem (&AddressMap, sizeof (AddressMap)); - AsmGetAddressMap (&AddressMap); - - StartupVector = WorkingBuffer; - - // - // Copy AP startup code to startup vector, and then redirect the long jump - // instructions for mode switching. - // - CopyMem ((VOID *) (UINTN) StartupVector, AddressMap.RendezvousFunnelAddress, AddressMap.Size); - *(UINT32 *) (UINTN) (StartupVector + AddressMap.FlatJumpOffset + 3) = (UINT32) (StartupVector + AddressMap.PModeEntryOffset); - if (AddressMap.LongJumpOffset != 0) { - *(UINT32 *) (UINTN) (StartupVector + AddressMap.LongJumpOffset + 2) = (UINT32) (StartupVector + AddressMap.LModeEntryOffset); - } - - // - // Get the start address of exchange data between BSP and AP. - // - mExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN) (StartupVector + AddressMap.Size); - ZeroMem ((VOID *) mExchangeInfo, sizeof (MP_CPU_EXCHANGE_INFO)); - - CopyMem ((VOID *) (UINTN) &mExchangeInfo->GdtrProfile, (VOID *) (UINTN) mAcpiCpuData.GdtrProfile, sizeof (IA32_DESCRIPTOR)); - CopyMem ((VOID *) (UINTN) &mExchangeInfo->IdtrProfile, (VOID *) (UINTN) mAcpiCpuData.IdtrProfile, sizeof (IA32_DESCRIPTOR)); - - // - // Copy AP's GDT, IDT and Machine Check handler from SMRAM to ACPI NVS memory - // - CopyMem ((VOID *) mExchangeInfo->GdtrProfile.Base, mGdtForAp, mExchangeInfo->GdtrProfile.Limit + 1); - CopyMem ((VOID *) mExchangeInfo->IdtrProfile.Base, mIdtForAp, mExchangeInfo->IdtrProfile.Limit + 1); - CopyMem ((VOID *)(UINTN) mAcpiCpuData.ApMachineCheckHandlerBase, mMachineCheckHandlerForAp, mAcpiCpuData.ApMachineCheckHandlerSize); - - mExchangeInfo->StackStart = (VOID *) (UINTN) mAcpiCpuData.StackAddress; - mExchangeInfo->StackSize = mAcpiCpuData.StackSize; - mExchangeInfo->BufferStart = (UINT32) StartupVector; - mExchangeInfo->Cr3 = (UINT32) (AsmReadCr3 ()); -} - -/** - The function is invoked before SMBASE relocation in S3 path to restores CPU status. - - The function is invoked before SMBASE relocation in S3 path. It does first time microcode load - and restores MTRRs for both BSP and APs. - -**/ -VOID -EarlyInitializeCpu ( - VOID - ) -{ - CPU_REGISTER_TABLE *RegisterTableList; - UINT32 InitApicId; - UINTN Index; - - LoadMtrrData (mAcpiCpuData.MtrrTable); - - // - // Find processor number for this CPU. - // - RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.PreSmmInitRegisterTable; - InitApicId = GetInitialApicId (); - for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { - if (RegisterTableList[Index].InitialApicId == InitApicId) { - SetProcessorRegister (&RegisterTableList[Index]); - break; - } - } - - ProgramVirtualWireMode (); - - PrepareApStartupVector (mAcpiCpuData.StartupVector); - - mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; - mExchangeInfo->ApFunction = (VOID *) (UINTN) EarlyMPRendezvousProcedure; - - // - // Send INIT IPI - SIPI to all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); - - while (mNumberToFinish > 0) { - CpuPause (); - } -} - -/** - The function is invoked after SMBASE relocation in S3 path to restores CPU status. - - The function is invoked after SMBASE relocation in S3 path. It restores configuration according to - data saved by normal boot path for both BSP and APs. - -**/ -VOID -InitializeCpu ( - VOID - ) -{ - CPU_REGISTER_TABLE *RegisterTableList; - UINT32 InitApicId; - UINTN Index; - - RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.RegisterTable; - InitApicId = GetInitialApicId (); - for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) { - if (RegisterTableList[Index].InitialApicId == InitApicId) { - SetProcessorRegister (&RegisterTableList[Index]); - break; - } - } - - mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1; - // - // StackStart was updated when APs were waken up in EarlyInitializeCpu. - // Re-initialize StackAddress to original beginning address. - // - mExchangeInfo->StackStart = (VOID *) (UINTN) mAcpiCpuData.StackAddress; - mExchangeInfo->ApFunction = (VOID *) (UINTN) MPRendezvousProcedure; - - // - // Send INIT IPI - SIPI to all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); - - while (mNumberToFinish > 0) { - CpuPause (); - } -} - -/** - Restore SMM Configuration in S3 boot path. - -**/ -VOID -RestoreSmmConfigurationInS3 ( - VOID - ) -{ - if (!mAcpiS3Enable) { - return; - } - - // - // Restore SMM Configuration in S3 boot path. - // - if (mRestoreSmmConfigurationInS3) { - // - // Need make sure gSmst is correct because below function may use them. - // - gSmst->SmmStartupThisAp = gSmmCpuPrivate->SmmCoreEntryContext.SmmStartupThisAp; - gSmst->CurrentlyExecutingCpu = gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu; - gSmst->NumberOfCpus = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - gSmst->CpuSaveStateSize = gSmmCpuPrivate->SmmCoreEntryContext.CpuSaveStateSize; - gSmst->CpuSaveState = gSmmCpuPrivate->SmmCoreEntryContext.CpuSaveState; - - // - // Configure SMM Code Access Check feature if available. - // - ConfigSmmCodeAccessCheck (); - - SmmCpuFeaturesCompleteSmmReadyToLock (); - - mRestoreSmmConfigurationInS3 = FALSE; - } -} - -/** - Perform SMM initialization for all processors in the S3 boot path. - - For a native platform, MP initialization in the S3 boot path is also performed in this function. -**/ -VOID -EFIAPI -SmmRestoreCpu ( - VOID - ) -{ - SMM_S3_RESUME_STATE *SmmS3ResumeState; - IA32_DESCRIPTOR Ia32Idtr; - IA32_DESCRIPTOR X64Idtr; - IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER]; - EFI_STATUS Status; - - DEBUG ((EFI_D_INFO, "SmmRestoreCpu()\n")); - - mSmmS3Flag = TRUE; - - InitializeSpinLock (mMemoryMappedLock); - - // - // See if there is enough context to resume PEI Phase - // - if (mSmmS3ResumeState == NULL) { - DEBUG ((EFI_D_ERROR, "No context to return to PEI Phase\n")); - CpuDeadLoop (); - } - - SmmS3ResumeState = mSmmS3ResumeState; - ASSERT (SmmS3ResumeState != NULL); - - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { - // - // Save the IA32 IDT Descriptor - // - AsmReadIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); - - // - // Setup X64 IDT table - // - ZeroMem (IdtEntryTable, sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32); - X64Idtr.Base = (UINTN) IdtEntryTable; - X64Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32 - 1); - AsmWriteIdtr ((IA32_DESCRIPTOR *) &X64Idtr); - - // - // Setup the default exception handler - // - Status = InitializeCpuExceptionHandlers (NULL); - ASSERT_EFI_ERROR (Status); - - // - // Initialize Debug Agent to support source level debug - // - InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL); - } - - // - // Skip initialization if mAcpiCpuData is not valid - // - if (mAcpiCpuData.NumberOfCpus > 0) { - // - // First time microcode load and restore MTRRs - // - EarlyInitializeCpu (); - } - - // - // Restore SMBASE for BSP and all APs - // - SmmRelocateBases (); - - // - // Skip initialization if mAcpiCpuData is not valid - // - if (mAcpiCpuData.NumberOfCpus > 0) { - // - // Restore MSRs for BSP and all APs - // - InitializeCpu (); - } - - // - // Set a flag to restore SMM configuration in S3 path. - // - mRestoreSmmConfigurationInS3 = TRUE; - - DEBUG (( EFI_D_INFO, "SMM S3 Return CS = %x\n", SmmS3ResumeState->ReturnCs)); - DEBUG (( EFI_D_INFO, "SMM S3 Return Entry Point = %x\n", SmmS3ResumeState->ReturnEntryPoint)); - DEBUG (( EFI_D_INFO, "SMM S3 Return Context1 = %x\n", SmmS3ResumeState->ReturnContext1)); - DEBUG (( EFI_D_INFO, "SMM S3 Return Context2 = %x\n", SmmS3ResumeState->ReturnContext2)); - DEBUG (( EFI_D_INFO, "SMM S3 Return Stack Pointer = %x\n", SmmS3ResumeState->ReturnStackPointer)); - - // - // If SMM is in 32-bit mode, then use SwitchStack() to resume PEI Phase - // - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) { - DEBUG ((EFI_D_INFO, "Call SwitchStack() to return to S3 Resume in PEI Phase\n")); - - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->ReturnEntryPoint, - (VOID *)(UINTN)SmmS3ResumeState->ReturnContext1, - (VOID *)(UINTN)SmmS3ResumeState->ReturnContext2, - (VOID *)(UINTN)SmmS3ResumeState->ReturnStackPointer - ); - } - - // - // If SMM is in 64-bit mode, then use AsmDisablePaging64() to resume PEI Phase - // - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { - DEBUG ((EFI_D_INFO, "Call AsmDisablePaging64() to return to S3 Resume in PEI Phase\n")); - // - // Disable interrupt of Debug timer, since new IDT table is for IA32 and will not work in long mode. - // - SaveAndSetDebugTimerInterrupt (FALSE); - // - // Restore IA32 IDT table - // - AsmWriteIdtr ((IA32_DESCRIPTOR *) &Ia32Idtr); - AsmDisablePaging64 ( - SmmS3ResumeState->ReturnCs, - (UINT32)SmmS3ResumeState->ReturnEntryPoint, - (UINT32)SmmS3ResumeState->ReturnContext1, - (UINT32)SmmS3ResumeState->ReturnContext2, - (UINT32)SmmS3ResumeState->ReturnStackPointer - ); - } - - // - // Can not resume PEI Phase - // - DEBUG ((EFI_D_ERROR, "No context to return to PEI Phase\n")); - CpuDeadLoop (); -} - -/** - Initialize SMM S3 resume state structure used during S3 Resume. - - @param[in] Cr3 The base address of the page tables to use in SMM. - -**/ -VOID -InitSmmS3ResumeState ( - IN UINT32 Cr3 - ) -{ - VOID *GuidHob; - EFI_SMRAM_DESCRIPTOR *SmramDescriptor; - SMM_S3_RESUME_STATE *SmmS3ResumeState; - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - - if (!mAcpiS3Enable) { - return; - } - - GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); - if (GuidHob != NULL) { - SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); - - DEBUG ((EFI_D_INFO, "SMM S3 SMRAM Structure = %x\n", SmramDescriptor)); - DEBUG ((EFI_D_INFO, "SMM S3 Structure = %x\n", SmramDescriptor->CpuStart)); - - SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; - ZeroMem (SmmS3ResumeState, sizeof (SMM_S3_RESUME_STATE)); - - mSmmS3ResumeState = SmmS3ResumeState; - SmmS3ResumeState->Smst = (EFI_PHYSICAL_ADDRESS)(UINTN)gSmst; - - SmmS3ResumeState->SmmS3ResumeEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)SmmRestoreCpu; - - SmmS3ResumeState->SmmS3StackSize = SIZE_32KB; - SmmS3ResumeState->SmmS3StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)SmmS3ResumeState->SmmS3StackSize)); - if (SmmS3ResumeState->SmmS3StackBase == 0) { - SmmS3ResumeState->SmmS3StackSize = 0; - } - - SmmS3ResumeState->SmmS3Cr0 = gSmmCr0; - SmmS3ResumeState->SmmS3Cr3 = Cr3; - SmmS3ResumeState->SmmS3Cr4 = gSmmCr4; - - if (sizeof (UINTN) == sizeof (UINT64)) { - SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_64; - } - if (sizeof (UINTN) == sizeof (UINT32)) { - SmmS3ResumeState->Signature = SMM_S3_RESUME_SMM_32; - } - } - - // - // Patch SmmS3ResumeState->SmmS3Cr3 - // - InitSmmS3Cr3 (); - - // - // Allocate safe memory in ACPI NVS for AP to execute hlt loop in - // protected mode on S3 path - // - Address = BASE_4GB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiACPIMemoryNVS, - EFI_SIZE_TO_PAGES (sizeof (mApHltLoopCodeTemplate)), - &Address - ); - ASSERT_EFI_ERROR (Status); - mApHltLoopCode = (UINT8 *) (UINTN) Address; -} - -/** - Copy register table from ACPI NVS memory into SMRAM. - - @param[in] DestinationRegisterTableList Points to destination register table. - @param[in] SourceRegisterTableList Points to source register table. - @param[in] NumberOfCpus Number of CPUs. - -**/ -VOID -CopyRegisterTable ( - IN CPU_REGISTER_TABLE *DestinationRegisterTableList, - IN CPU_REGISTER_TABLE *SourceRegisterTableList, - IN UINT32 NumberOfCpus - ) -{ - UINTN Index; - UINTN Index1; - CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry; - - CopyMem (DestinationRegisterTableList, SourceRegisterTableList, NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); - for (Index = 0; Index < NumberOfCpus; Index++) { - if (DestinationRegisterTableList[Index].AllocatedSize != 0) { - RegisterTableEntry = AllocateCopyPool ( - DestinationRegisterTableList[Index].AllocatedSize, - (VOID *)(UINTN)SourceRegisterTableList[Index].RegisterTableEntry - ); - ASSERT (RegisterTableEntry != NULL); - DestinationRegisterTableList[Index].RegisterTableEntry = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTableEntry; - // - // Go though all MSRs in register table to initialize MSR spin lock - // - for (Index1 = 0; Index1 < DestinationRegisterTableList[Index].TableLength; Index1++, RegisterTableEntry++) { - if ((RegisterTableEntry->RegisterType == Msr) && (RegisterTableEntry->ValidBitLength < 64)) { - // - // Initialize MSR spin lock only for those MSRs need bit field writing - // - InitMsrSpinLockByIndex (RegisterTableEntry->Index); - } - } - } - } -} - -/** - Get ACPI CPU data. - -**/ -VOID -GetAcpiCpuData ( - VOID - ) -{ - ACPI_CPU_DATA *AcpiCpuData; - IA32_DESCRIPTOR *Gdtr; - IA32_DESCRIPTOR *Idtr; - - if (!mAcpiS3Enable) { - return; - } - - // - // Prevent use of mAcpiCpuData by initialize NumberOfCpus to 0 - // - mAcpiCpuData.NumberOfCpus = 0; - - // - // If PcdCpuS3DataAddress was never set, then do not copy CPU S3 Data into SMRAM - // - AcpiCpuData = (ACPI_CPU_DATA *)(UINTN)PcdGet64 (PcdCpuS3DataAddress); - if (AcpiCpuData == 0) { - return; - } - - // - // For a native platform, copy the CPU S3 data into SMRAM for use on CPU S3 Resume. - // - CopyMem (&mAcpiCpuData, AcpiCpuData, sizeof (mAcpiCpuData)); - - mAcpiCpuData.MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (MTRR_SETTINGS)); - ASSERT (mAcpiCpuData.MtrrTable != 0); - - CopyMem ((VOID *)(UINTN)mAcpiCpuData.MtrrTable, (VOID *)(UINTN)AcpiCpuData->MtrrTable, sizeof (MTRR_SETTINGS)); - - mAcpiCpuData.GdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (IA32_DESCRIPTOR)); - ASSERT (mAcpiCpuData.GdtrProfile != 0); - - CopyMem ((VOID *)(UINTN)mAcpiCpuData.GdtrProfile, (VOID *)(UINTN)AcpiCpuData->GdtrProfile, sizeof (IA32_DESCRIPTOR)); - - mAcpiCpuData.IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (sizeof (IA32_DESCRIPTOR)); - ASSERT (mAcpiCpuData.IdtrProfile != 0); - - CopyMem ((VOID *)(UINTN)mAcpiCpuData.IdtrProfile, (VOID *)(UINTN)AcpiCpuData->IdtrProfile, sizeof (IA32_DESCRIPTOR)); - - mAcpiCpuData.PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); - ASSERT (mAcpiCpuData.PreSmmInitRegisterTable != 0); - - CopyRegisterTable ( - (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.PreSmmInitRegisterTable, - (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->PreSmmInitRegisterTable, - mAcpiCpuData.NumberOfCpus - ); - - mAcpiCpuData.RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE)); - ASSERT (mAcpiCpuData.RegisterTable != 0); - - CopyRegisterTable ( - (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.RegisterTable, - (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->RegisterTable, - mAcpiCpuData.NumberOfCpus - ); - - // - // Copy AP's GDT, IDT and Machine Check handler into SMRAM. - // - Gdtr = (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.GdtrProfile; - Idtr = (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.IdtrProfile; - - mGdtForAp = AllocatePool ((Gdtr->Limit + 1) + (Idtr->Limit + 1) + mAcpiCpuData.ApMachineCheckHandlerSize); - ASSERT (mGdtForAp != NULL); - mIdtForAp = (VOID *) ((UINTN)mGdtForAp + (Gdtr->Limit + 1)); - mMachineCheckHandlerForAp = (VOID *) ((UINTN)mIdtForAp + (Idtr->Limit + 1)); - - CopyMem (mGdtForAp, (VOID *)Gdtr->Base, Gdtr->Limit + 1); - CopyMem (mIdtForAp, (VOID *)Idtr->Base, Idtr->Limit + 1); - CopyMem (mMachineCheckHandlerForAp, (VOID *)(UINTN)mAcpiCpuData.ApMachineCheckHandlerBase, mAcpiCpuData.ApMachineCheckHandlerSize); -} - -/** - Get ACPI S3 enable flag. - -**/ -VOID -GetAcpiS3EnableFlag ( - VOID - ) -{ - mAcpiS3Enable = PcdGetBool (PcdAcpiS3Enable); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c deleted file mode 100644 index 29f3a58939..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c +++ /dev/null @@ -1,372 +0,0 @@ -/** @file -Implementation of SMM CPU Services Protocol. - -Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -// -// SMM CPU Service Protocol instance -// -EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService = { - SmmGetProcessorInfo, - SmmSwitchBsp, - SmmAddProcessor, - SmmRemoveProcessor, - SmmWhoAmI, - SmmRegisterExceptionHandler -}; - -/** - Gets processor information on the requested processor at the instant this call is made. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - -**/ -EFI_STATUS -EFIAPI -SmmGetProcessorInfo ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ) -{ - // - // Check parameter - // - if (ProcessorNumber >= mMaxNumberOfCpus || ProcessorInfoBuffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { - return EFI_NOT_FOUND; - } - - // - // Fill in processor information - // - CopyMem (ProcessorInfoBuffer, &gSmmCpuPrivate->ProcessorInfo[ProcessorNumber], sizeof (EFI_PROCESSOR_INFORMATION)); - return EFI_SUCCESS; -} - -/** - This service switches the requested AP to be the BSP since the next SMI. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. - - @retval EFI_SUCCESS BSP will be switched in next SMI. - @retval EFI_UNSUPPORTED Switching the BSP or a processor to be hot-removed is not supported. - @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. -**/ -EFI_STATUS -EFIAPI -SmmSwitchBsp ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ) -{ - // - // Check parameter - // - if (ProcessorNumber >= mMaxNumberOfCpus) { - return EFI_INVALID_PARAMETER; - } - - if (gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { - return EFI_NOT_FOUND; - } - - if (gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone || - gSmst->CurrentlyExecutingCpu == ProcessorNumber) { - return EFI_UNSUPPORTED; - } - - // - // Setting of the BSP for next SMI is pending until all SMI handlers are finished - // - gSmmCpuPrivate->Operation[ProcessorNumber] = SmmCpuSwitchBsp; - return EFI_SUCCESS; -} - -/** - Notify that a processor was hot-added. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorId Local APIC ID of the hot-added processor. - @param[out] ProcessorNumber The handle number of the hot-added processor. - - @retval EFI_SUCCESS The hot-addition of the specified processors was successfully notified. - @retval EFI_UNSUPPORTED Hot addition of processor is not supported. - @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. - @retval EFI_ALREADY_STARTED The processor is already online in the system. -**/ -EFI_STATUS -EFIAPI -SmmAddProcessor ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINT64 ProcessorId, - OUT UINTN *ProcessorNumber - ) -{ - UINTN Index; - - if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { - return EFI_UNSUPPORTED; - } - - // - // Check parameter - // - if (ProcessorNumber == NULL || ProcessorId == INVALID_APIC_ID) { - return EFI_INVALID_PARAMETER; - } - - // - // Check if the processor already exists - // - - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ProcessorId) { - return EFI_ALREADY_STARTED; - } - } - - // - // Check CPU hot plug data. The CPU RAS handler should have created the mapping - // of the APIC ID to SMBASE. - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (mCpuHotPlugData.ApicId[Index] == ProcessorId && - gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == INVALID_APIC_ID) { - gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = ProcessorId; - gSmmCpuPrivate->ProcessorInfo[Index].StatusFlag = 0; - GetProcessorLocationByApicId ( - (UINT32)ProcessorId, - &gSmmCpuPrivate->ProcessorInfo[Index].Location.Package, - &gSmmCpuPrivate->ProcessorInfo[Index].Location.Core, - &gSmmCpuPrivate->ProcessorInfo[Index].Location.Thread - ); - - *ProcessorNumber = Index; - gSmmCpuPrivate->Operation[Index] = SmmCpuAdd; - return EFI_SUCCESS; - } - } - - return EFI_INVALID_PARAMETER; -} - -/** - Notify that a processor was hot-removed. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of the hot-added processor. - - @retval EFI_SUCCESS The hot-removal of the specified processors was successfully notified. - @retval EFI_UNSUPPORTED Hot removal of processor is not supported. - @retval EFI_UNSUPPORTED Hot removal of BSP is not supported. - @retval EFI_UNSUPPORTED Hot removal of a processor with pending hot-plug operation is not supported. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. -**/ -EFI_STATUS -EFIAPI -SmmRemoveProcessor ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ) -{ - if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { - return EFI_UNSUPPORTED; - } - - // - // Check parameter - // - if (ProcessorNumber >= mMaxNumberOfCpus || - gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId == INVALID_APIC_ID) { - return EFI_INVALID_PARAMETER; - } - - // - // Can't remove BSP - // - if (ProcessorNumber == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { - return EFI_UNSUPPORTED; - } - - if (gSmmCpuPrivate->Operation[ProcessorNumber] != SmmCpuNone) { - return EFI_UNSUPPORTED; - } - - gSmmCpuPrivate->ProcessorInfo[ProcessorNumber].ProcessorId = INVALID_APIC_ID; - mCpuHotPlugData.ApicId[ProcessorNumber] = INVALID_APIC_ID; - - // - // Removal of the processor from the CPU list is pending until all SMI handlers are finished - // - gSmmCpuPrivate->Operation[ProcessorNumber] = SmmCpuRemove; - return EFI_SUCCESS; -} - -/** - This return the handle number for the calling processor. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[out] ProcessorNumber The handle number of currently executing processor. - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - -**/ -EFI_STATUS -EFIAPI -SmmWhoAmI ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - OUT UINTN *ProcessorNumber - ) -{ - UINTN Index; - UINT64 ApicId; - - // - // Check parameter - // - if (ProcessorNumber == NULL) { - return EFI_INVALID_PARAMETER; - } - - ApicId = GetApicId (); - - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ApicId) { - *ProcessorNumber = Index; - return EFI_SUCCESS; - } - } - // - // This should not happen - // - ASSERT (FALSE); - return EFI_NOT_FOUND; -} - -/** - Update the SMM CPU list per the pending operation. - - This function is called after return from SMI handlers. -**/ -VOID -SmmCpuUpdate ( - VOID - ) -{ - UINTN Index; - - // - // Handle pending BSP switch operations - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->Operation[Index] == SmmCpuSwitchBsp) { - gSmmCpuPrivate->Operation[Index] = SmmCpuNone; - mSmmMpSyncData->SwitchBsp = TRUE; - mSmmMpSyncData->CandidateBsp[Index] = TRUE; - } - } - - // - // Handle pending hot-add operations - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->Operation[Index] == SmmCpuAdd) { - gSmmCpuPrivate->Operation[Index] = SmmCpuNone; - mNumberOfCpus++; - } - } - - // - // Handle pending hot-remove operations - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->Operation[Index] == SmmCpuRemove) { - gSmmCpuPrivate->Operation[Index] = SmmCpuNone; - mNumberOfCpus--; - } - } -} - -/** - Register exception handler. - - @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. - @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and - the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL - of the UEFI 2.0 specification. - @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER - that is called when a processor interrupt occurs. - If this parameter is NULL, then the handler will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. - -**/ -EFI_STATUS -EFIAPI -SmmRegisterExceptionHandler ( - IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ) -{ - return RegisterCpuInterruptHandler (ExceptionType, InterruptHandler); -} - -/** - Initialize SMM CPU Services. - - It installs EFI SMM CPU Services Protocol. - - @param ImageHandle The firmware allocated handle for the EFI image. - - @retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully. -**/ -EFI_STATUS -InitializeSmmCpuServices ( - IN EFI_HANDLE Handle - ) -{ - EFI_STATUS Status; - - Status = gSmst->SmmInstallProtocolInterface ( - &Handle, - &gEfiSmmCpuServiceProtocolGuid, - EFI_NATIVE_INTERFACE, - &mSmmCpuService - ); - ASSERT_EFI_ERROR (Status); - return Status; -} - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h deleted file mode 100644 index 9fe3f45b02..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.h +++ /dev/null @@ -1,181 +0,0 @@ -/** @file -Include file for SMM CPU Services protocol implementation. - -Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_SERVICE_H_ -#define _CPU_SERVICE_H_ - -typedef enum { - SmmCpuNone, - SmmCpuAdd, - SmmCpuRemove, - SmmCpuSwitchBsp -} SMM_CPU_OPERATION; - -// -// SMM CPU Service Protocol function prototypes. -// - -/** - Gets processor information on the requested processor at the instant this call is made. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of processor. - @param[out] ProcessorInfoBuffer A pointer to the buffer where information for - the requested processor is deposited. - - @retval EFI_SUCCESS Processor information was returned. - @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. - @retval EFI_NOT_FOUND The processor with the handle specified by - ProcessorNumber does not exist in the platform. - -**/ -EFI_STATUS -EFIAPI -SmmGetProcessorInfo ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber, - OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer - ); - -/** - This service switches the requested AP to be the BSP since the next SMI. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of AP that is to become the new BSP. - - @retval EFI_SUCCESS BSP will be switched in next SMI. - @retval EFI_UNSUPPORTED Switching the BSP or a processor to be hot-removed is not supported. - @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. -**/ -EFI_STATUS -EFIAPI -SmmSwitchBsp ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ); - -/** - Notify that a processor was hot-added. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorId Local APIC ID of the hot-added processor. - @param[out] ProcessorNumber The handle number of the hot-added processor. - - @retval EFI_SUCCESS The hot-addition of the specified processors was successfully notified. - @retval EFI_UNSUPPORTED Hot addition of processor is not supported. - @retval EFI_NOT_FOUND The processor with the handle specified by ProcessorNumber does not exist. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. - @retval EFI_ALREADY_STARTED The processor is already online in the system. -**/ -EFI_STATUS -EFIAPI -SmmAddProcessor ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINT64 ProcessorId, - OUT UINTN *ProcessorNumber - ); - -/** - Notify that a processor was hot-removed. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[in] ProcessorNumber The handle number of the hot-added processor. - - @retval EFI_SUCCESS The hot-removal of the specified processors was successfully notified. - @retval EFI_UNSUPPORTED Hot removal of processor is not supported. - @retval EFI_UNSUPPORTED Hot removal of BSP is not supported. - @retval EFI_UNSUPPORTED Hot removal of a processor with pending hot-plug operation is not supported. - @retval EFI_INVALID_PARAMETER ProcessorNumber is invalid. -**/ -EFI_STATUS -EFIAPI -SmmRemoveProcessor ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN UINTN ProcessorNumber - ); - -/** - This return the handle number for the calling processor. - - @param[in] This A pointer to the EFI_SMM_CPU_SERVICE_PROTOCOL instance. - @param[out] ProcessorNumber The handle number of currently executing processor. - - @retval EFI_SUCCESS The current processor handle number was returned - in ProcessorNumber. - @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. - -**/ -EFI_STATUS -EFIAPI -SmmWhoAmI ( - IN CONST EFI_SMM_CPU_SERVICE_PROTOCOL *This, - OUT UINTN *ProcessorNumber - ); - -/** - Register exception handler. - - @param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance. - @param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and - the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL - of the UEFI 2.0 specification. - @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER - that is called when a processor interrupt occurs. - If this parameter is NULL, then the handler will be uninstalled. - - @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported. - -**/ -EFI_STATUS -EFIAPI -SmmRegisterExceptionHandler ( - IN EFI_SMM_CPU_SERVICE_PROTOCOL *This, - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler - ); - -// -// Internal function prototypes -// - -/** - Update the SMM CPU list per the pending operation. - - This function is called after return from SMI handlers. -**/ -VOID -SmmCpuUpdate ( - VOID - ); - -/** - Initialize SMM CPU Services. - - It installs EFI SMM CPU Services Protocol. - - @param ImageHandle The firmware allocated handle for the EFI image. - - @retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully. -**/ -EFI_STATUS -InitializeSmmCpuServices ( - IN EFI_HANDLE Handle - ); - -#endif diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S deleted file mode 100644 index 75aa312a6e..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.S +++ /dev/null @@ -1,165 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# MpFuncs.S -# -# Abstract: -# -# This is the assembly code for Multi-processor S3 support -# -#------------------------------------------------------------------------------ - -.equ VacantFlag, 0x0 -.equ NotVacantFlag, 0xff - -.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart -.equ StackStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x04 -.equ StackSize, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08 -.equ RendezvousProc, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x0C -.equ GdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10 -.equ IdtrProfile, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16 -.equ BufferStart, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C - -#------------------------------------------------------------------------------------- -#RendezvousFunnelProc procedure follows. All APs execute their procedure. This -#procedure serializes all the AP processors through an Init sequence. It must be -#noted that APs arrive here very raw...ie: real mode, no stack. -#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -#IS IN MACHINE CODE. -#------------------------------------------------------------------------------------- -#RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -ASM_GLOBAL ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: - -# At this point CS = 0x(vv00) and ip= 0x0. - - .byte 0x8c,0xc8 # mov ax, cs - .byte 0x8e,0xd8 # mov ds, ax - .byte 0x8e,0xc0 # mov es, ax - .byte 0x8e,0xd0 # mov ss, ax - .byte 0x33,0xc0 # xor ax, ax - .byte 0x8e,0xe0 # mov fs, ax - .byte 0x8e,0xe8 # mov gs, ax - -flat32Start: - - .byte 0xBE - .word BufferStart - .byte 0x66,0x8B,0x14 # mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer - - .byte 0xBE - .word GdtrProfile - .byte 0x66 # db 66h - .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si] - - .byte 0xBE - .word IdtrProfile - .byte 0x66 # db 66h - .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si] - - .byte 0x33,0xC0 # xor ax, ax - .byte 0x8E,0xD8 # mov ds, ax - - .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0 - .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0) - .byte 0xF,0x22,0xC0 # mov cr0, eax - -FLAT32_JUMP: - - .byte 0x66,0x67,0xEA # far jump - .long 0x0 # 32-bit offset - .word 0x20 # 16-bit selector - -PMODE_ENTRY: # protected mode entry point - - movw $0x8,%ax - .byte 0x66 - movw %ax,%ds - .byte 0x66 - movw %ax,%es - .byte 0x66 - movw %ax,%fs - .byte 0x66 - movw %ax,%gs - .byte 0x66 - movw %ax,%ss # Flat mode setup. - - movl %edx,%esi - - movl %esi,%edi - addl $LockLocation, %edi - movb $NotVacantFlag, %al -TestLock: - xchgb (%edi), %al - cmpb $NotVacantFlag, %al - jz TestLock - -ProgramStack: - - movl %esi,%edi - addl $StackSize, %edi - movl (%edi),%eax - movl %esi,%edi - addl $StackStart, %edi - addl (%edi),%eax - movl %eax,%esp - movl %eax,(%edi) - -Releaselock: - - movb $VacantFlag, %al - movl %esi,%edi - addl $LockLocation, %edi - xchgb (%edi), %al - - # - # Call assembly function to initialize FPU. - # - lea ASM_PFX(InitializeFloatingPointUnits), %ebx - call *%ebx - # - # Call C Function - # - movl %esi,%edi - addl $RendezvousProc, %edi - movl (%edi),%eax - - testl %eax,%eax - jz GoToSleep - call *%eax # Call C function - -GoToSleep: - cli - hlt - jmp GoToSleep - -RendezvousFunnelProcEnd: -#------------------------------------------------------------------------------------- -# AsmGetAddressMap (&AddressMap); -#------------------------------------------------------------------------------------- -ASM_GLOBAL ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - - pushal - movl %esp,%ebp - - movl 0x24(%ebp), %ebx - movl $RendezvousFunnelProcStart, (%ebx) - movl $(PMODE_ENTRY - RendezvousFunnelProcStart), 0x4(%ebx) - movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx) - movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x0c(%ebx) - - popal - ret diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm deleted file mode 100644 index 70e24a8270..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.asm +++ /dev/null @@ -1,168 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.asm -; -; Abstract: -; -; This is the assembly code for Multi-processor S3 support -; -;------------------------------------------------------------------------------- - -.686p -.model flat,C -.code - -EXTERN InitializeFloatingPointUnits:PROC - -VacantFlag Equ 00h -NotVacantFlag Equ 0ffh - -LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart -StackStart equ LockLocation + 4h -StackSize equ LockLocation + 8h -RendezvousProc equ LockLocation + 0Ch -GdtrProfile equ LockLocation + 10h -IdtrProfile equ LockLocation + 16h -BufferStart equ LockLocation + 1Ch - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -RendezvousFunnelProc PROC near C PUBLIC -RendezvousFunnelProcStart:: - -; At this point CS = 0x(vv00) and ip= 0x0. - - db 8ch, 0c8h ; mov ax, cs - db 8eh, 0d8h ; mov ds, ax - db 8eh, 0c0h ; mov es, ax - db 8eh, 0d0h ; mov ss, ax - db 33h, 0c0h ; xor ax, ax - db 8eh, 0e0h ; mov fs, ax - db 8eh, 0e8h ; mov gs, ax - -flat32Start:: - - db 0BEh - dw BufferStart ; mov si, BufferStart - db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer - - db 0BEh - dw GdtrProfile ; mov si, GdtrProfile - db 66h ; db 66h - db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si] - - db 0BEh - dw IdtrProfile ; mov si, IdtrProfile - db 66h ; db 66h - db 2Eh, 0Fh, 01h, 1Ch ; lidt fword ptr cs:[si] - - db 33h, 0C0h ; xor ax, ax - db 8Eh, 0D8h ; mov ds, ax - - db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0 - db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0) - db 0Fh, 22h, 0C0h ; mov cr0, eax - -FLAT32_JUMP:: - - db 66h, 67h, 0EAh ; far jump - dd 0h ; 32-bit offset - dw 20h ; 16-bit selector - -PMODE_ENTRY:: ; protected mode entry point - - mov ax, 8h - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax ; Flat mode setup. - - mov esi, edx - - mov edi, esi - add edi, LockLocation - mov al, NotVacantFlag -TestLock:: - xchg byte ptr [edi], al - cmp al, NotVacantFlag - jz TestLock - -ProgramStack:: - - mov edi, esi - add edi, StackSize - mov eax, dword ptr [edi] - mov edi, esi - add edi, StackStart - add eax, dword ptr [edi] - mov esp, eax - mov dword ptr [edi], eax - -Releaselock:: - - mov al, VacantFlag - mov edi, esi - add edi, LockLocation - xchg byte ptr [edi], al - - ; - ; Call assembly function to initialize FPU. - ; - mov ebx, InitializeFloatingPointUnits - call ebx - ; - ; Call C Function - ; - mov edi, esi - add edi, RendezvousProc - mov eax, dword ptr [edi] - - test eax, eax - jz GoToSleep - call eax ; Call C function - -GoToSleep:: - cli - hlt - jmp $-2 - -RendezvousFunnelProc ENDP -RendezvousFunnelProcEnd:: -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -AsmGetAddressMap PROC near C PUBLIC - - pushad - mov ebp,esp - - mov ebx, dword ptr [ebp+24h] - mov dword ptr [ebx], RendezvousFunnelProcStart - mov dword ptr [ebx+4h], PMODE_ENTRY - RendezvousFunnelProcStart - mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart - mov dword ptr [ebx+0ch], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - - popad - ret - -AsmGetAddressMap ENDP - -END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm deleted file mode 100644 index f7cdcce9a7..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm +++ /dev/null @@ -1,159 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.nasm -; -; Abstract: -; -; This is the assembly code for Multi-processor S3 support -; -;------------------------------------------------------------------------------- - -SECTION .text - -extern ASM_PFX(InitializeFloatingPointUnits) - -%define VacantFlag 0x0 -%define NotVacantFlag 0xff - -%define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart -%define StackStart LockLocation + 0x4 -%define StackSize LockLocation + 0x8 -%define RendezvousProc LockLocation + 0xC -%define GdtrProfile LockLocation + 0x10 -%define IdtrProfile LockLocation + 0x16 -%define BufferStart LockLocation + 0x1C - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -BITS 16 -global ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: - -; At this point CS = 0x(vv00) and ip= 0x0. - - mov ax, cs - mov ds, ax - mov es, ax - mov ss, ax - xor ax, ax - mov fs, ax - mov gs, ax - -flat32Start: - - mov si, BufferStart - mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer - - mov si, GdtrProfile -o32 lgdt [cs:si] - - mov si, IdtrProfile -o32 lidt [cs:si] - - xor ax, ax - mov ds, ax - - mov eax, cr0 ; Get control register 0 - or eax, 0x000000001 ; Set PE bit (bit #0) - mov cr0, eax - -FLAT32_JUMP: - -a32 jmp dword 0x20:0x0 - -BITS 32 -PMODE_ENTRY: ; protected mode entry point - - mov ax, 0x8 -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax ; Flat mode setup. - - mov esi, edx - - mov edi, esi - add edi, LockLocation - mov al, NotVacantFlag -TestLock: - xchg byte [edi], al - cmp al, NotVacantFlag - jz TestLock - -ProgramStack: - - mov edi, esi - add edi, StackSize - mov eax, dword [edi] - mov edi, esi - add edi, StackStart - add eax, dword [edi] - mov esp, eax - mov dword [edi], eax - -Releaselock: - - mov al, VacantFlag - mov edi, esi - add edi, LockLocation - xchg byte [edi], al - - ; - ; Call assembly function to initialize FPU. - ; - mov ebx, ASM_PFX(InitializeFloatingPointUnits) - call ebx - ; - ; Call C Function - ; - mov edi, esi - add edi, RendezvousProc - mov eax, dword [edi] - - test eax, eax - jz GoToSleep - call eax ; Call C function - -GoToSleep: - cli - hlt - jmp $-2 - -RendezvousFunnelProcEnd: -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -global ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - - pushad - mov ebp,esp - - mov ebx, dword [ebp+0x24] - mov dword [ebx], RendezvousFunnelProcStart - mov dword [ebx+0x4], PMODE_ENTRY - RendezvousFunnelProcStart - mov dword [ebx+0x8], FLAT32_JUMP - RendezvousFunnelProcStart - mov dword [ebx+0xc], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - - popad - ret - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c deleted file mode 100644 index 32ce5958c5..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c +++ /dev/null @@ -1,232 +0,0 @@ -/** @file -Page table manipulation functions for IA-32 processors - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -/** - Create PageTable for SMM use. - - @return PageTable Address - -**/ -UINT32 -SmmInitPageTable ( - VOID - ) -{ - UINTN PageFaultHandlerHookAddress; - IA32_IDT_GATE_DESCRIPTOR *IdtEntry; - EFI_STATUS Status; - - // - // Initialize spin lock - // - InitializeSpinLock (mPFLock); - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - // - // Set own Page Fault entry instead of the default one, because SMM Profile - // feature depends on IRET instruction to do Single Step - // - PageFaultHandlerHookAddress = (UINTN)PageFaultIdtHandlerSmmProfile; - IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) gcSmiIdtr.Base; - IdtEntry += EXCEPT_IA32_PAGE_FAULT; - IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress; - IdtEntry->Bits.Reserved_0 = 0; - IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; - IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16); - } else { - // - // Register SMM Page Fault Handler - // - Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT, SmiPFHandler); - ASSERT_EFI_ERROR (Status); - } - - // - // Additional SMM IDT initialization for SMM stack guard - // - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - InitializeIDTSmmStackGuard (); - } - return Gen4GPageTable (TRUE); -} - -/** - Page Fault handler for SMM use. - -**/ -VOID -SmiDefaultPFHandler ( - VOID - ) -{ - CpuDeadLoop (); -} - -/** - ThePage Fault handler wrapper for SMM use. - - @param InterruptType Defines the type of interrupt or exception that - occurred on the processor.This parameter is processor architecture specific. - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. -**/ -VOID -EFIAPI -SmiPFHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - UINTN PFAddress; - UINTN GuardPageAddress; - UINTN CpuIndex; - - ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT); - - AcquireSpinLock (mPFLock); - - PFAddress = AsmReadCr2 (); - - // - // If a page fault occurs in SMRAM range, it might be in a SMM stack guard page, - // or SMM page protection violation. - // - if ((PFAddress >= mCpuHotPlugData.SmrrBase) && - (PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))) { - DumpCpuContext (InterruptType, SystemContext); - CpuIndex = GetCpuIndex (); - GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize); - if ((FeaturePcdGet (PcdCpuSmmStackGuard)) && - (PFAddress >= GuardPageAddress) && - (PFAddress < (GuardPageAddress + EFI_PAGE_SIZE))) { - DEBUG ((DEBUG_ERROR, "SMM stack overflow!\n")); - } else { - if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) { - DEBUG ((DEBUG_ERROR, "SMM exception at execution (0x%x)\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp); - ); - } else { - DEBUG ((DEBUG_ERROR, "SMM exception at access (0x%x)\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); - ); - } - } - CpuDeadLoop (); - } - - // - // If a page fault occurs in SMM range - // - if ((PFAddress < mCpuHotPlugData.SmrrBase) || - (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { - DumpCpuContext (InterruptType, SystemContext); - if ((SystemContext.SystemContextIa32->ExceptionData & IA32_PF_EC_ID) != 0) { - DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%x) out of SMM range after SMM is locked!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextIa32->Esp); - ); - CpuDeadLoop (); - } - if (IsSmmCommBufferForbiddenAddress (PFAddress)) { - DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%x)!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextIa32->Eip); - ); - CpuDeadLoop (); - } - } - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - SmmProfilePFHandler ( - SystemContext.SystemContextIa32->Eip, - SystemContext.SystemContextIa32->ExceptionData - ); - } else { - DumpCpuContext (InterruptType, SystemContext); - SmiDefaultPFHandler (); - } - - ReleaseSpinLock (mPFLock); -} - -/** - This function sets memory attribute for page table. -**/ -VOID -SetPageTableAttributes ( - VOID - ) -{ - UINTN Index2; - UINTN Index3; - UINT64 *L1PageTable; - UINT64 *L2PageTable; - UINT64 *L3PageTable; - BOOLEAN IsSplitted; - BOOLEAN PageTableSplitted; - - DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n")); - - // - // Disable write protection, because we need mark page table to be write protected. - // We need *write* page table memory, to mark itself to be *read only*. - // - AsmWriteCr0 (AsmReadCr0() & ~CR0_WP); - - do { - DEBUG ((DEBUG_INFO, "Start...\n")); - PageTableSplitted = FALSE; - - L3PageTable = (UINT64 *)GetPageTableBase (); - - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L3PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - - for (Index3 = 0; Index3 < 4; Index3++) { - L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L2PageTable == NULL) { - continue; - } - - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - - for (Index2 = 0; Index2 < SIZE_4KB/sizeof(UINT64); Index2++) { - if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { - // 2M - continue; - } - L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L1PageTable == NULL) { - continue; - } - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - } - } - } while (PageTableSplitted); - - // - // Enable write protection, after page table updated. - // - AsmWriteCr0 (AsmReadCr0() | CR0_WP); - - return ; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c deleted file mode 100644 index 02a866b430..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c +++ /dev/null @@ -1,48 +0,0 @@ -/** @file -Semaphore mechanism to indicate to the BSP that an AP has exited SMM -after SMBASE relocation. - -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -UINTN mSmmRelocationOriginalAddress; -volatile BOOLEAN *mRebasedFlag; - -/** - Hook return address of SMM Save State so that semaphore code - can be executed immediately after AP exits SMM to indicate to - the BSP that an AP has exited SMM after SMBASE relocation. - - @param[in] CpuIndex The processor index. - @param[in] RebasedFlag A pointer to a flag that is set to TRUE - immediately after AP exits SMM. - -**/ -VOID -SemaphoreHook ( - IN UINTN CpuIndex, - IN volatile BOOLEAN *RebasedFlag - ) -{ - SMRAM_SAVE_STATE_MAP *CpuState; - - mRebasedFlag = RebasedFlag; - - CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); - mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm ( - CpuIndex, - CpuState, - (UINT64)(UINTN)&SmmRelocationSemaphoreComplete, - (UINT64)(UINTN)&SmmRelocationSemaphoreComplete - ); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S deleted file mode 100644 index 62f1697efa..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S +++ /dev/null @@ -1,214 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiEntry.S -# -# Abstract: -# -# Code template of the SMI handler for a particular processor -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcSmiHandlerTemplate) -ASM_GLOBAL ASM_PFX(gcSmiHandlerSize) -ASM_GLOBAL ASM_PFX(gSmiCr3) -ASM_GLOBAL ASM_PFX(gSmiStack) -ASM_GLOBAL ASM_PFX(gSmbase) -ASM_GLOBAL ASM_PFX(mXdSupported) -ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) -ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr) - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0xc0000080 -.equ MSR_EFER_XD, 0x800 - -# -# Constants relating to PROCESSOR_SMM_DESCRIPTOR -# -.equ DSC_OFFSET, 0xfb00 -.equ DSC_GDTPTR, 0x30 -.equ DSC_GDTSIZ, 0x38 -.equ DSC_CS, 14 -.equ DSC_DS, 16 -.equ DSC_SS, 18 -.equ DSC_OTHERSEG, 20 - -.equ PROTECT_MODE_CS, 0x08 -.equ PROTECT_MODE_DS, 0x20 -.equ TSS_SEGMENT, 0x40 - - .text - -ASM_PFX(gcSmiHandlerTemplate): - -_SmiEntryPoint: - .byte 0xbb # mov bx, imm16 - .word _GdtDesc - _SmiEntryPoint + 0x8000 - .byte 0x2e,0xa1 # mov ax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTSIZ - decl %eax - movl %eax, %cs:(%edi) # mov cs:[bx], ax - .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTPTR - movw %ax, %cs:2(%edi) - movw %ax, %bp # ebp = GDT base - .byte 0x66 - lgdt %cs:(%edi) -# Patch ProtectedMode Segment - .byte 0xb8 # mov ax, imm16 - .word PROTECT_MODE_CS # set AX for segment directly - movl %eax, %cs:-2(%edi) # mov cs:[bx - 2], ax -# Patch ProtectedMode entry - .byte 0x66, 0xbf # mov edi, SMBASE -ASM_PFX(gSmbase): .space 4 - .byte 0x67 - lea ((Start32bit - _SmiEntryPoint) + 0x8000)(%edi), %ax - movw %ax, %cs:-6(%edi) - movl %cr0, %ebx - .byte 0x66 - andl $0x9ffafff3, %ebx - .byte 0x66 - orl $0x23, %ebx - movl %ebx, %cr0 - .byte 0x66,0xea - .space 4 - .space 2 -_GdtDesc: .space 4 - .space 2 - -Start32bit: - movw $PROTECT_MODE_DS, %ax - movl %eax,%ds - movl %eax,%es - movl %eax,%fs - movl %eax,%gs - movl %eax,%ss - .byte 0xbc # mov esp, imm32 -ASM_PFX(gSmiStack): .space 4 - movl $ASM_PFX(gSmiHandlerIdtr), %eax - lidt (%eax) - jmp ProtFlatMode - -ProtFlatMode: - .byte 0xb8 # mov eax, imm32 -ASM_PFX(gSmiCr3): .space 4 - movl %eax, %cr3 -# -# Need to test for CR4 specific bit support -# - movl $1, %eax - cpuid # use CPUID to determine if specific CR4 bits are supported - xorl %eax, %eax # Clear EAX - testl $BIT2, %edx # Check for DE capabilities - jz L8 - orl $BIT3, %eax -L8: - testl $BIT6, %edx # Check for PAE capabilities - jz L9 - orl $BIT5, %eax -L9: - testl $BIT7, %edx # Check for MCE capabilities - jz L10 - orl $BIT6, %eax -L10: - testl $BIT24, %edx # Check for FXSR capabilities - jz L11 - orl $BIT9, %eax -L11: - testl $BIT25, %edx # Check for SSE capabilities - jz L12 - orl $BIT10, %eax -L12: # as cr4.PGE is not set here, refresh cr3 - movl %eax, %cr4 # in PreModifyMtrrs() to flush TLB. - - cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) - jz L5 -# Load TSS - movb $0x89, (TSS_SEGMENT + 5)(%ebp) # clear busy flag - movl $TSS_SEGMENT, %eax - ltrw %ax -L5: - -# enable NXE if supported - .byte 0xb0 # mov al, imm8 -ASM_PFX(mXdSupported): .byte 1 - cmpb $0, %al - jz SkipNxe -# -# Check XD disable bit -# - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - pushl %edx # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr -SkipNxe: - subl $4, %esp -NxeDone: - - movl %cr0, %ebx - orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE - movl %ebx, %cr0 - leal DSC_OFFSET(%edi),%ebx - movw DSC_DS(%ebx),%ax - movl %eax, %ds - movw DSC_OTHERSEG(%ebx),%ax - movl %eax, %es - movl %eax, %fs - movl %eax, %gs - movw DSC_SS(%ebx),%ax - movl %eax, %ss - -# jmp _SmiHandler # instruction is not needed - -_SmiHandler: - movl 4(%esp), %ebx - - pushl %ebx - movl $ASM_PFX(CpuSmmDebugEntry), %eax - call *%eax - addl $4, %esp - - pushl %ebx - movl $ASM_PFX(SmiRendezvous), %eax - call *%eax - addl $4, %esp - - pushl %ebx - movl $ASM_PFX(CpuSmmDebugExit), %eax - call *%eax - addl $4, %esp - - movl $ASM_PFX(mXdSupported), %eax - movb (%eax), %al - cmpb $0, %al - jz L16 - popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr - -L16: - rsm - -ASM_PFX(gcSmiHandlerSize): .word . - _SmiEntryPoint diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm deleted file mode 100644 index 8296f36d26..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm +++ /dev/null @@ -1,223 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.asm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - - .686p - .model flat,C - .xmm - -MSR_IA32_MISC_ENABLE EQU 1A0h -MSR_EFER EQU 0c0000080h -MSR_EFER_XD EQU 0800h - -; -; Constants relating to PROCESSOR_SMM_DESCRIPTOR -; -DSC_OFFSET EQU 0fb00h -DSC_GDTPTR EQU 30h -DSC_GDTSIZ EQU 38h -DSC_CS EQU 14 -DSC_DS EQU 16 -DSC_SS EQU 18 -DSC_OTHERSEG EQU 20 - -PROTECT_MODE_CS EQU 08h -PROTECT_MODE_DS EQU 20h -TSS_SEGMENT EQU 40h - -SmiRendezvous PROTO C -CpuSmmDebugEntry PROTO C -CpuSmmDebugExit PROTO C - -EXTERNDEF gcSmiHandlerTemplate:BYTE -EXTERNDEF gcSmiHandlerSize:WORD -EXTERNDEF gSmiCr3:DWORD -EXTERNDEF gSmiStack:DWORD -EXTERNDEF gSmbase:DWORD -EXTERNDEF mXdSupported:BYTE -EXTERNDEF FeaturePcdGet (PcdCpuSmmStackGuard):BYTE -EXTERNDEF gSmiHandlerIdtr:FWORD - - .code - -gcSmiHandlerTemplate LABEL BYTE - -_SmiEntryPoint: - DB 0bbh ; mov bx, imm16 - DW offset _GdtDesc - _SmiEntryPoint + 8000h - DB 2eh, 0a1h ; mov ax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTSIZ - dec eax - mov cs:[edi], eax ; mov cs:[bx], ax - DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTPTR - mov cs:[edi + 2], ax ; mov cs:[bx + 2], eax - mov bp, ax ; ebp = GDT base - DB 66h - lgdt fword ptr cs:[edi] ; lgdt fword ptr cs:[bx] -; Patch ProtectedMode Segment - DB 0b8h ; mov ax, imm16 - DW PROTECT_MODE_CS ; set AX for segment directly - mov cs:[edi - 2], eax ; mov cs:[bx - 2], ax -; Patch ProtectedMode entry - DB 66h, 0bfh ; mov edi, SMBASE -gSmbase DD ? - DB 67h - lea ax, [edi + (@32bit - _SmiEntryPoint) + 8000h] - mov cs:[edi - 6], ax ; mov cs:[bx - 6], eax - mov ebx, cr0 - DB 66h - and ebx, 9ffafff3h - DB 66h - or ebx, 23h - mov cr0, ebx - DB 66h, 0eah - DD ? - DW ? -_GdtDesc FWORD ? - -@32bit: - mov ax, PROTECT_MODE_DS - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - DB 0bch ; mov esp, imm32 -gSmiStack DD ? - mov eax, offset gSmiHandlerIdtr - lidt fword ptr [eax] - jmp ProtFlatMode - -ProtFlatMode: - DB 0b8h ; mov eax, imm32 -gSmiCr3 DD ? - mov cr3, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - xor eax, eax ; Clear EAX - test edx, BIT2 ; Check for DE capabilities - jz @f - or eax, BIT3 -@@: - test edx, BIT6 ; Check for PAE capabilities - jz @f - or eax, BIT5 -@@: - test edx, BIT7 ; Check for MCE capabilities - jz @f - or eax, BIT6 -@@: - test edx, BIT24 ; Check for FXSR capabilities - jz @f - or eax, BIT9 -@@: - test edx, BIT25 ; Check for SSE capabilities - jz @f - or eax, BIT10 -@@: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - - cmp FeaturePcdGet (PcdCpuSmmStackGuard), 0 - jz @F -; Load TSS - mov byte ptr [ebp + TSS_SEGMENT + 5], 89h ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax -@@: - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -mXdSupported DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - push edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 4 -@XdDone: - - mov ebx, cr0 - or ebx, 080010023h ; enable paging + WP + NE + MP + PE - mov cr0, ebx - lea ebx, [edi + DSC_OFFSET] - mov ax, [ebx + DSC_DS] - mov ds, eax - mov ax, [ebx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [ebx + DSC_SS] - mov ss, eax - -; jmp _SmiHandler ; instruction is not needed - -_SmiHandler PROC - mov ebx, [esp + 4] ; CPU Index - push ebx - mov eax, CpuSmmDebugEntry - call eax - add esp, 4 - - push ebx - mov eax, SmiRendezvous - call eax - add esp, 4 - - push ebx - mov eax, CpuSmmDebugExit - call eax - add esp, 4 - - mov eax, offset mXdSupported - mov al, [eax] - cmp al, 0 - jz @f - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -@@: - rsm -_SmiHandler ENDP - -gcSmiHandlerSize DW $ - _SmiEntryPoint - - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm deleted file mode 100644 index 4d2383ff97..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm +++ /dev/null @@ -1,209 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.nasm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -; -; Constants relating to PROCESSOR_SMM_DESCRIPTOR -; -%define DSC_OFFSET 0xfb00 -%define DSC_GDTPTR 0x30 -%define DSC_GDTSIZ 0x38 -%define DSC_CS 14 -%define DSC_DS 16 -%define DSC_SS 18 -%define DSC_OTHERSEG 20 - -%define PROTECT_MODE_CS 0x8 -%define PROTECT_MODE_DS 0x20 -%define TSS_SEGMENT 0x40 - -extern ASM_PFX(SmiRendezvous) -extern ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard)) -extern ASM_PFX(CpuSmmDebugEntry) -extern ASM_PFX(CpuSmmDebugExit) - -global ASM_PFX(gcSmiHandlerTemplate) -global ASM_PFX(gcSmiHandlerSize) -global ASM_PFX(gSmiCr3) -global ASM_PFX(gSmiStack) -global ASM_PFX(gSmbase) -global ASM_PFX(mXdSupported) -extern ASM_PFX(gSmiHandlerIdtr) - - SECTION .text - -BITS 16 -ASM_PFX(gcSmiHandlerTemplate): -_SmiEntryPoint: - mov bx, _GdtDesc - _SmiEntryPoint + 0x8000 - mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] - dec ax - mov [cs:bx], ax - mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] - mov [cs:bx + 2], eax - mov ebp, eax ; ebp = GDT base -o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] - mov ax, PROTECT_MODE_CS - mov [cs:bx-0x2],ax - DB 0x66, 0xbf ; mov edi, SMBASE -ASM_PFX(gSmbase): DD 0 - lea eax, [edi + (@32bit - _SmiEntryPoint) + 0x8000] - mov [cs:bx-0x6],eax - mov ebx, cr0 - and ebx, 0x9ffafff3 - or ebx, 0x23 - mov cr0, ebx - jmp dword 0x0:0x0 -_GdtDesc: - DW 0 - DD 0 - -BITS 32 -@32bit: - mov ax, PROTECT_MODE_DS -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax - DB 0xbc ; mov esp, imm32 -ASM_PFX(gSmiStack): DD 0 - mov eax, ASM_PFX(gSmiHandlerIdtr) - lidt [eax] - jmp ProtFlatMode - -ProtFlatMode: - DB 0xb8 ; mov eax, imm32 -ASM_PFX(gSmiCr3): DD 0 - mov cr3, eax -; -; Need to test for CR4 specific bit support -; - mov eax, 1 - cpuid ; use CPUID to determine if specific CR4 bits are supported - xor eax, eax ; Clear EAX - test edx, BIT2 ; Check for DE capabilities - jz .0 - or eax, BIT3 -.0: - test edx, BIT6 ; Check for PAE capabilities - jz .1 - or eax, BIT5 -.1: - test edx, BIT7 ; Check for MCE capabilities - jz .2 - or eax, BIT6 -.2: - test edx, BIT24 ; Check for FXSR capabilities - jz .3 - or eax, BIT9 -.3: - test edx, BIT25 ; Check for SSE capabilities - jz .4 - or eax, BIT10 -.4: ; as cr4.PGE is not set here, refresh cr3 - mov cr4, eax ; in PreModifyMtrrs() to flush TLB. - - cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))], 0 - jz .6 -; Load TSS - mov byte [ebp + TSS_SEGMENT + 5], 0x89 ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax -.6: - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -ASM_PFX(mXdSupported): DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - push edx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .5 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.5: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 4 -@XdDone: - - mov ebx, cr0 - or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, ebx - lea ebx, [edi + DSC_OFFSET] - mov ax, [ebx + DSC_DS] - mov ds, eax - mov ax, [ebx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [ebx + DSC_SS] - mov ss, eax - -; jmp _SmiHandler ; instruction is not needed - -global ASM_PFX(SmiHandler) -ASM_PFX(SmiHandler): - mov ebx, [esp + 4] ; CPU Index - push ebx - mov eax, ASM_PFX(CpuSmmDebugEntry) - call eax - add esp, 4 - - push ebx - mov eax, ASM_PFX(SmiRendezvous) - call eax - add esp, 4 - - push ebx - mov eax, ASM_PFX(CpuSmmDebugExit) - call eax - add esp, 4 - - mov eax, ASM_PFX(mXdSupported) - mov al, [eax] - cmp al, 0 - jz .7 - pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .7 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.7: - rsm - -ASM_PFX(gcSmiHandlerSize): DW $ - _SmiEntryPoint - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S deleted file mode 100644 index 4600c7c36e..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S +++ /dev/null @@ -1,696 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiException.S -# -# Abstract: -# -# Exception handlers used in SM mode -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(SmiPFHandler) -ASM_GLOBAL ASM_PFX(PageFaultStubFunction) -ASM_GLOBAL ASM_PFX(gcSmiIdtr) -ASM_GLOBAL ASM_PFX(gcSmiGdtr) -ASM_GLOBAL ASM_PFX(gTaskGateDescriptor) -ASM_GLOBAL ASM_PFX(gcPsd) -ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) - - .data - -NullSeg: .quad 0 # reserved by architecture -CodeSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -ProtModeCodeSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -ProtModeSsSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x93 - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -DataSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x93 - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -CodeSeg16: - .word -1 - .word 0 - .byte 0 - .byte 0x9b - .byte 0x8f - .byte 0 -DataSeg16: - .word -1 - .word 0 - .byte 0 - .byte 0x93 - .byte 0x8f - .byte 0 -CodeSeg64: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xaf # LimitHigh - .byte 0 # BaseHigh -.equ GDT_SIZE, .- NullSeg - -TssSeg: - .word TSS_DESC_SIZE -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x89 - .byte 0x00 # LimitHigh - .byte 0 # BaseHigh -ExceptionTssSeg: - .word TSS_DESC_SIZE - 1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x89 - .byte 0x00 # LimitHigh - .byte 0 # BaseHigh - -.equ CODE_SEL, CodeSeg32 - NullSeg -.equ DATA_SEL, DataSeg32 - NullSeg -.equ TSS_SEL, TssSeg - NullSeg -.equ EXCEPTION_TSS_SEL, ExceptionTssSeg - NullSeg - -# IA32 TSS fields -.equ TSS_ESP0, 4 -.equ TSS_SS0, 8 -.equ TSS_ESP1, 12 -.equ TSS_SS1, 16 -.equ TSS_ESP2, 20 -.equ TSS_SS2, 24 -.equ TSS_CR3, 28 -.equ TSS_EIP, 32 -.equ TSS_EFLAGS, 36 -.equ TSS_EAX, 40 -.equ TSS_ECX, 44 -.equ TSS_EDX, 48 -.equ TSS_EBX, 52 -.equ TSS_ESP, 56 -.equ TSS_EBP, 60 -.equ TSS_ESI, 64 -.equ TSS_EDI, 68 -.equ TSS_ES, 72 -.equ TSS_CS, 76 -.equ TSS_SS, 80 -.equ TSS_DS, 84 -.equ TSS_FS, 88 -.equ TSS_GS, 92 -.equ TSS_LDT, 96 - -# Create 2 TSS segments just after GDT -TssDescriptor: - .word 0 # PreviousTaskLink - .word 0 # Reserved - .long 0 # ESP0 - .word 0 # SS0 - .word 0 # Reserved - .long 0 # ESP1 - .word 0 # SS1 - .word 0 # Reserved - .long 0 # ESP2 - .word 0 # SS2 - .word 0 # Reserved - .long 0 # CR3 - .long 0 # EIP - .long 0 # EFLAGS - .long 0 # EAX - .long 0 # ECX - .long 0 # EDX - .long 0 # EBX - .long 0 # ESP - .long 0 # EBP - .long 0 # ESI - .long 0 # EDI - .word 0 # ES - .word 0 # Reserved - .word 0 # CS - .word 0 # Reserved - .word 0 # SS - .word 0 # Reserved - .word 0 # DS - .word 0 # Reserved - .word 0 # FS - .word 0 # Reserved - .word 0 # GS - .word 0 # Reserved - .word 0 # LDT Selector - .word 0 # Reserved - .word 0 # T - .word 0 # I/O Map Base -.equ TSS_DESC_SIZE, . - TssDescriptor - -ExceptionTssDescriptor: - .word 0 # PreviousTaskLink - .word 0 # Reserved - .long 0 # ESP0 - .word 0 # SS0 - .word 0 # Reserved - .long 0 # ESP1 - .word 0 # SS1 - .word 0 # Reserved - .long 0 # ESP2 - .word 0 # SS2 - .word 0 # Reserved - .long 0 # CR3 - .long PFHandlerEntry # EIP - .long 00000002 # EFLAGS - .long 0 # EAX - .long 0 # ECX - .long 0 # EDX - .long 0 # EBX - .long 0 # ESP - .long 0 # EBP - .long 0 # ESI - .long 0 # EDI - .word DATA_SEL # ES - .word 0 # Reserved - .word CODE_SEL # CS - .word 0 # Reserved - .word DATA_SEL # SS - .word 0 # Reserved - .word DATA_SEL # DS - .word 0 # Reserved - .word DATA_SEL # FS - .word 0 # Reserved - .word DATA_SEL # GS - .word 0 # Reserved - .word 0 # LDT Selector - .word 0 # Reserved - .word 0 # T - .word 0 # I/O Map Base - -ASM_PFX(gcPsd): - .ascii "PSDSIG " - .word PSD_SIZE - .word 2 - .word 1 << 2 - .word CODE_SEL - .word DATA_SEL - .word DATA_SEL - .word DATA_SEL - .word 0 - .long 0 - .long 0 - .long 0 - .long 0 - .quad 0 - .long NullSeg - .long 0 - .long GDT_SIZE - .long 0 - .space 24, 0 - .long 0 - .long 0 -.equ PSD_SIZE, . - ASM_PFX(gcPsd) - -ASM_PFX(gcSmiGdtr): .word GDT_SIZE - 1 - .long NullSeg - -ASM_PFX(gcSmiIdtr): .word 0 - .long 0 - -ASM_PFX(gTaskGateDescriptor): - .word 0 # Reserved - .word EXCEPTION_TSS_SEL # TSS Segment selector - .byte 0 # Reserved - .byte 0x85 # Task Gate, present, DPL = 0 - .word 0 # Reserved - - .text - -#------------------------------------------------------------------------------ -# PageFaultIdtHandlerSmmProfile is the entry point for all exceptions -# -# Stack: -#+---------------------+ -#+ EFlags + -#+---------------------+ -#+ CS + -#+---------------------+ -#+ EIP + -#+---------------------+ -#+ Error Code + -#+---------------------+ -#+ Vector Number + -#+---------------------+ -#+ EBP + -#+---------------------+ <-- EBP -# -# RSP set to odd multiple of 8 means ErrCode PRESENT -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(PageFaultIdtHandlerSmmProfile) -ASM_PFX(PageFaultIdtHandlerSmmProfile): - pushl $0x0e # Page Fault - pushl %ebp - movl %esp, %ebp - - - # - # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - # is 16-byte aligned - # - andl $0xfffffff0, %esp - subl $12, %esp - -## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pushl %eax - pushl %ecx - pushl %edx - pushl %ebx - leal (6*4)(%ebp), %ecx - pushl %ecx # ESP - pushl (%ebp) # EBP - pushl %esi - pushl %edi - -## UINT32 Gs, Fs, Es, Ds, Cs, Ss; - movl %ss, %eax - pushl %eax - movzwl (4*4)(%ebp), %eax - pushl %eax - movl %ds, %eax - pushl %eax - movl %es, %eax - pushl %eax - movl %fs, %eax - pushl %eax - movl %gs, %eax - pushl %eax - -## UINT32 Eip; - movl (3*4)(%ebp), %eax - pushl %eax - -## UINT32 Gdtr[2], Idtr[2]; - subl $8, %esp - sidt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0xffff, %eax - movl %eax, 4(%esp) - - subl $8, %esp - sgdt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0xffff, %eax - movl %eax, 4(%esp) - -## UINT32 Ldtr, Tr; - xorl %eax, %eax - strw %ax - pushl %eax - sldtw %ax - pushl %eax - -## UINT32 EFlags; - movl (5*4)(%ebp), %eax - pushl %eax - -## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - movl %cr4, %eax - orl $0x208, %eax - movl %eax, %cr4 - pushl %eax - movl %cr3, %eax - pushl %eax - movl %cr2, %eax - pushl %eax - xorl %eax, %eax - pushl %eax - movl %cr0, %eax - pushl %eax - -## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - movl %dr7, %eax - pushl %eax - movl %dr6, %eax - pushl %eax - movl %dr3, %eax - pushl %eax - movl %dr2, %eax - pushl %eax - movl %dr1, %eax - pushl %eax - movl %dr0, %eax - pushl %eax - -## FX_SAVE_STATE_IA32 FxSaveState; - subl $512, %esp - movl %esp, %edi - .byte 0x0f, 0xae, 0x07 #fxsave [edi] - -# UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -## UINT32 ExceptionData; - pushl (2*4)(%ebp) - -## call into exception handler - -## Prepare parameter and call - movl %esp, %edx - pushl %edx - movl (1*4)(%ebp), %edx - pushl %edx - - # - # Call External Exception Handler - # - movl $ASM_PFX(SmiPFHandler), %eax - call *%eax - addl $8, %esp - jmp L4 - -L4: -## UINT32 ExceptionData; - addl $4, %esp - -## FX_SAVE_STATE_IA32 FxSaveState; - movl %esp, %esi - .byte 0xf, 0xae, 0xe # fxrstor [esi] - addl $512, %esp - -## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -## Skip restoration of DRx registers to support debuggers -## that set breakpoints in interrupt/exception context - addl $4*6, %esp - -## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - popl %eax - movl %eax, %cr0 - addl $4, %esp # not for Cr1 - popl %eax - movl %eax, %cr2 - popl %eax - movl %eax, %cr3 - popl %eax - movl %eax, %cr4 - -## UINT32 EFlags; - popl (5*4)(%ebp) - -## UINT32 Ldtr, Tr; -## UINT32 Gdtr[2], Idtr[2]; -## Best not let anyone mess with these particular registers... - addl $24, %esp - -## UINT32 Eip; - popl (3*4)(%ebp) - -## UINT32 Gs, Fs, Es, Ds, Cs, Ss; -## NOTE - modified segment registers could hang the debugger... We -## could attempt to insulate ourselves against this possibility, -## but that poses risks as well. -## - popl %gs - popl %fs - popl %es - popl %ds - popl (4*4)(%ebp) - popl %ss - -## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - popl %edi - popl %esi - addl $4, %esp # not for ebp - addl $4, %esp # not for esp - popl %ebx - popl %edx - popl %ecx - popl %eax - - movl %ebp, %esp - popl %ebp - -# Enable TF bit after page fault handler runs - btsl $8, 16(%esp) # EFLAGS - - addl $8, %esp # skip INT# & ErrCode -Return: - iret -# -# Page Fault Exception Handler entry when SMM Stack Guard is enabled -# Executiot starts here after a task switch -# -PFHandlerEntry: -# -# Get this processor's TSS -# - subl $8, %esp - sgdt 2(%esp) - movl 4(%esp), %eax # GDT base - addl $8, %esp - movl (TSS_SEL+2)(%eax), %ecx - shll $8, %ecx - movb (TSS_SEL+7)(%eax), %cl - rorl $8, %ecx # ecx = TSS base - - movl %esp, %ebp - - # - # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - # is 16-byte aligned - # - andl $0xfffffff0, %esp - subl $12, %esp - -## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pushl TSS_EAX(%ecx) - pushl TSS_ECX(%ecx) - pushl TSS_EDX(%ecx) - pushl TSS_EBX(%ecx) - pushl TSS_ESP(%ecx) - pushl TSS_EBP(%ecx) - pushl TSS_ESI(%ecx) - pushl TSS_EDI(%ecx) - -## UINT32 Gs, Fs, Es, Ds, Cs, Ss; - movzwl TSS_SS(%ecx), %eax - pushl %eax - movzwl TSS_CS(%ecx), %eax - pushl %eax - movzwl TSS_DS(%ecx), %eax - pushl %eax - movzwl TSS_ES(%ecx), %eax - pushl %eax - movzwl TSS_FS(%ecx), %eax - pushl %eax - movzwl TSS_GS(%ecx), %eax - pushl %eax - -## UINT32 Eip; - pushl TSS_EIP(%ecx) - -## UINT32 Gdtr[2], Idtr[2]; - subl $8, %esp - sidt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0xFFFF, %eax - movl %eax, 4(%esp) - - subl $8, %esp - sgdt (%esp) - movl 2(%esp), %eax - xchgl (%esp), %eax - andl $0xFFFF, %eax - movl %eax, 4(%esp) - -## UINT32 Ldtr, Tr; - movl $TSS_SEL, %eax - pushl %eax - movzwl TSS_LDT(%ecx), %eax - pushl %eax - -## UINT32 EFlags; - pushl TSS_EFLAGS(%ecx) - -## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - movl %cr4, %eax - orl $0x208, %eax - movl %eax, %cr4 - pushl %eax - movl %cr3, %eax - pushl %eax - movl %cr2, %eax - pushl %eax - xorl %eax, %eax - pushl %eax - movl %cr0, %eax - pushl %eax - -## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - movl %dr7, %eax - pushl %eax - movl %dr6, %eax - pushl %eax - movl %dr3, %eax - pushl %eax - movl %dr2, %eax - pushl %eax - movl %dr1, %eax - pushl %eax - movl %dr0, %eax - pushl %eax - -## FX_SAVE_STATE_IA32 FxSaveState; -## Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) -## when executing fxsave/fxrstor instruction - clts - subl $512, %esp - movl %esp, %edi - .byte 0x0f, 0xae, 0x07 #fxsave [edi] - -# UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -## UINT32 ExceptionData; - pushl (%ebp) - -## call into exception handler - movl %ecx, %ebx - movl $ASM_PFX(SmiPFHandler), %eax - -## Prepare parameter and call - movl %esp, %edx - pushl %edx - movl $14, %edx - pushl %edx - - # - # Call External Exception Handler - # - call *%eax - addl $8, %esp - - movl %ebx, %ecx -## UINT32 ExceptionData; - addl $4, %esp - -## FX_SAVE_STATE_IA32 FxSaveState; - movl %esp, %esi - .byte 0xf, 0xae, 0xe # fxrstor [esi] - addl $512, %esp - -## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -## Skip restoration of DRx registers to support debuggers -## that set breakpoints in interrupt/exception context - addl $4*6, %esp - -## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - popl %eax - movl %eax, %cr0 - addl $4, %esp # not for Cr1 - popl %eax - movl %eax, %cr2 - popl %eax - movl %eax, TSS_CR3(%ecx) - popl %eax - movl %eax, %cr4 - -## UINT32 EFlags; - popl TSS_EFLAGS(%ecx) - -## UINT32 Ldtr, Tr; -## UINT32 Gdtr[2], Idtr[2]; -## Best not let anyone mess with these particular registers... - addl $24, %esp - -## UINT32 Eip; - popl TSS_EIP(%ecx) - -## UINT32 Gs, Fs, Es, Ds, Cs, Ss; -## NOTE - modified segment registers could hang the debugger... We -## could attempt to insulate ourselves against this possibility, -## but that poses risks as well. -## - popl %eax - movw %ax, TSS_GS(%ecx) - popl %eax - movw %ax, TSS_FS(%ecx) - popl %eax - movw %ax, TSS_ES(%ecx) - popl %eax - movw %ax, TSS_DS(%ecx) - popl %eax - movw %ax, TSS_CS(%ecx) - popl %eax - movw %ax, TSS_SS(%ecx) - -## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - popl TSS_EDI(%ecx) - popl TSS_ESI(%ecx) - addl $4, %esp # not for ebp - addl $4, %esp # not for esp - popl TSS_EBX(%ecx) - popl TSS_EDX(%ecx) - popl TSS_ECX(%ecx) - popl TSS_EAX(%ecx) - - movl %ebp, %esp - -# Set single step DB# if SMM profile is enabled and page fault exception happens - cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) - jz Done2 -# Create return context for iret in stub function - movl TSS_ESP(%ecx), %eax # Get old stack pointer - movl TSS_EIP(%ecx), %ebx - movl %ebx, -0xc(%eax) # create EIP in old stack - movzwl TSS_CS(%ecx), %ebx - movl %ebx, -0x8(%eax) # create CS in old stack - movl TSS_EFLAGS(%ecx), %ebx - btsl $8,%ebx - movl %ebx, -0x4(%eax) # create eflags in old stack - movl TSS_ESP(%ecx), %eax # Get old stack pointer - subl $12, %eax # minus 12 byte - movl %eax, TSS_ESP(%ecx) # Set new stack pointer - -# Replace the EIP of interrupted task with stub function - movl $ASM_PFX(PageFaultStubFunction), %eax - movl %eax, TSS_EIP(%ecx) -# Jump to the iret so next page fault handler as a task will start again after iret. - -Done2: - - addl $4, %esp # skip ErrCode - - jmp Return - -ASM_PFX(PageFaultStubFunction): -# -# we need clean TS bit in CR0 to execute -# x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. -# - clts - iret diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm deleted file mode 100644 index 80a44b861f..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm +++ /dev/null @@ -1,713 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.asm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - - .686p - .model flat,C - -EXTERNDEF SmiPFHandler:PROC -EXTERNDEF PageFaultStubFunction:PROC -EXTERNDEF gcSmiIdtr:FWORD -EXTERNDEF gcSmiGdtr:FWORD -EXTERNDEF gTaskGateDescriptor:QWORD -EXTERNDEF gcPsd:BYTE -EXTERNDEF FeaturePcdGet (PcdCpuSmmProfileEnable):BYTE - - - .data - -NullSeg DQ 0 ; reserved by architecture -CodeSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -ProtModeCodeSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -ProtModeSsSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 93h - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -DataSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 93h - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -CodeSeg16 LABEL QWORD - DW -1 - DW 0 - DB 0 - DB 9bh - DB 8fh - DB 0 -DataSeg16 LABEL QWORD - DW -1 - DW 0 - DB 0 - DB 93h - DB 8fh - DB 0 -CodeSeg64 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0afh ; LimitHigh - DB 0 ; BaseHigh -GDT_SIZE = $ - offset NullSeg - -TssSeg LABEL QWORD - DW TSS_DESC_SIZE - 1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 89h - DB 00h ; LimitHigh - DB 0 ; BaseHigh -ExceptionTssSeg LABEL QWORD - DW TSS_DESC_SIZE - 1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 89h - DB 00h ; LimitHigh - DB 0 ; BaseHigh - -CODE_SEL = offset CodeSeg32 - offset NullSeg -DATA_SEL = offset DataSeg32 - offset NullSeg -TSS_SEL = offset TssSeg - offset NullSeg -EXCEPTION_TSS_SEL = offset ExceptionTssSeg - offset NullSeg - -IA32_TSS STRUC - DW ? - DW ? - ESP0 DD ? - SS0 DW ? - DW ? - ESP1 DD ? - SS1 DW ? - DW ? - ESP2 DD ? - SS2 DW ? - DW ? - _CR3 DD ? - EIP DD ? - EFLAGS DD ? - _EAX DD ? - _ECX DD ? - _EDX DD ? - _EBX DD ? - _ESP DD ? - _EBP DD ? - _ESI DD ? - _EDI DD ? - _ES DW ? - DW ? - _CS DW ? - DW ? - _SS DW ? - DW ? - _DS DW ? - DW ? - _FS DW ? - DW ? - _GS DW ? - DW ? - LDT DW ? - DW ? - DW ? - DW ? -IA32_TSS ENDS - -; Create 2 TSS segments just after GDT -TssDescriptor LABEL BYTE - DW 0 ; PreviousTaskLink - DW 0 ; Reserved - DD 0 ; ESP0 - DW 0 ; SS0 - DW 0 ; Reserved - DD 0 ; ESP1 - DW 0 ; SS1 - DW 0 ; Reserved - DD 0 ; ESP2 - DW 0 ; SS2 - DW 0 ; Reserved - DD 0 ; CR3 - DD 0 ; EIP - DD 0 ; EFLAGS - DD 0 ; EAX - DD 0 ; ECX - DD 0 ; EDX - DD 0 ; EBX - DD 0 ; ESP - DD 0 ; EBP - DD 0 ; ESI - DD 0 ; EDI - DW 0 ; ES - DW 0 ; Reserved - DW 0 ; CS - DW 0 ; Reserved - DW 0 ; SS - DW 0 ; Reserved - DW 0 ; DS - DW 0 ; Reserved - DW 0 ; FS - DW 0 ; Reserved - DW 0 ; GS - DW 0 ; Reserved - DW 0 ; LDT Selector - DW 0 ; Reserved - DW 0 ; T - DW 0 ; I/O Map Base -TSS_DESC_SIZE = $ - offset TssDescriptor - -ExceptionTssDescriptor LABEL BYTE - DW 0 ; PreviousTaskLink - DW 0 ; Reserved - DD 0 ; ESP0 - DW 0 ; SS0 - DW 0 ; Reserved - DD 0 ; ESP1 - DW 0 ; SS1 - DW 0 ; Reserved - DD 0 ; ESP2 - DW 0 ; SS2 - DW 0 ; Reserved - DD 0 ; CR3 - DD offset PFHandlerEntry ; EIP - DD 00000002 ; EFLAGS - DD 0 ; EAX - DD 0 ; ECX - DD 0 ; EDX - DD 0 ; EBX - DD 0 ; ESP - DD 0 ; EBP - DD 0 ; ESI - DD 0 ; EDI - DW DATA_SEL ; ES - DW 0 ; Reserved - DW CODE_SEL ; CS - DW 0 ; Reserved - DW DATA_SEL ; SS - DW 0 ; Reserved - DW DATA_SEL ; DS - DW 0 ; Reserved - DW DATA_SEL ; FS - DW 0 ; Reserved - DW DATA_SEL ; GS - DW 0 ; Reserved - DW 0 ; LDT Selector - DW 0 ; Reserved - DW 0 ; T - DW 0 ; I/O Map Base - -gcPsd LABEL BYTE - DB 'PSDSIG ' - DW PSD_SIZE - DW 2 - DW 1 SHL 2 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW 0 - DQ 0 - DQ 0 - DQ 0 - DQ offset NullSeg - DD GDT_SIZE - DD 0 - DB 24 dup (0) - DQ 0 -PSD_SIZE = $ - offset gcPsd - -gcSmiGdtr LABEL FWORD - DW GDT_SIZE - 1 - DD offset NullSeg - -gcSmiIdtr LABEL FWORD - DW 0 - DD 0 - -gTaskGateDescriptor LABEL QWORD - DW 0 ; Reserved - DW EXCEPTION_TSS_SEL ; TSS Segment selector - DB 0 ; Reserved - DB 85h ; Task Gate, present, DPL = 0 - DW 0 ; Reserved - - - .code -;------------------------------------------------------------------------------ -; PageFaultIdtHandlerSmmProfile is the entry point page fault only -; -; -; Stack: -; +---------------------+ -; + EFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + EIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + EBP + -; +---------------------+ <-- EBP -; -; -;------------------------------------------------------------------------------ -PageFaultIdtHandlerSmmProfile PROC - push 0eh ; Page Fault - - push ebp - mov ebp, esp - - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0fffffff0h - sub esp, 12 - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push eax - push ecx - push edx - push ebx - lea ecx, [ebp + 6 * 4] - push ecx ; ESP - push dword ptr [ebp] ; EBP - push esi - push edi - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - mov eax, ss - push eax - movzx eax, word ptr [ebp + 4 * 4] - push eax - mov eax, ds - push eax - mov eax, es - push eax - mov eax, fs - push eax - mov eax, gs - push eax - -;; UINT32 Eip; - mov eax, [ebp + 3 * 4] - push eax - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - xor eax, eax - str ax - push eax - sldt ax - push eax - -;; UINT32 EFlags; - mov eax, [ebp + 5 * 4] - push eax - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, cr4 - or eax, 208h - mov cr4, eax - push eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; - sub esp, 512 - mov edi, esp - db 0fh, 0aeh, 07h ;fxsave [edi] - -; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword ptr [ebp + 2 * 4] - -;; call into exception handler - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, dword ptr [ebp + 1 * 4] - push edx - - ; - ; Call External Exception Handler - ; - mov eax, SmiPFHandler - call eax - add esp, 8 - -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - db 0fh, 0aeh, 0eh ; fxrstor [esi] - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoint in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov cr3, eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop dword ptr [ebp + 5 * 4] - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop dword ptr [ebp + 3 * 4] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop gs - pop fs - pop es - pop ds - pop dword ptr [ebp + 4 * 4] - pop ss - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop edi - pop esi - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop ebx - pop edx - pop ecx - pop eax - - mov esp, ebp - pop ebp - -; Enable TF bit after page fault handler runs - bts dword ptr [esp + 16], 8 ; EFLAGS - - add esp, 8 ; skip INT# & ErrCode -Return: - iretd -; -; Page Fault Exception Handler entry when SMM Stack Guard is enabled -; Executiot starts here after a task switch -; -PFHandlerEntry:: -; -; Get this processor's TSS -; - sub esp, 8 - sgdt [esp + 2] - mov eax, [esp + 4] ; GDT base - add esp, 8 - mov ecx, [eax + TSS_SEL + 2] - shl ecx, 8 - mov cl, [eax + TSS_SEL + 7] - ror ecx, 8 ; ecx = TSS base - - mov ebp, esp - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0fffffff0h - sub esp, 12 - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push (IA32_TSS ptr [ecx])._EAX - push (IA32_TSS ptr [ecx])._ECX - push (IA32_TSS ptr [ecx])._EDX - push (IA32_TSS ptr [ecx])._EBX - push (IA32_TSS ptr [ecx])._ESP - push (IA32_TSS ptr [ecx])._EBP - push (IA32_TSS ptr [ecx])._ESI - push (IA32_TSS ptr [ecx])._EDI - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - movzx eax, (IA32_TSS ptr [ecx])._SS - push eax - movzx eax, (IA32_TSS ptr [ecx])._CS - push eax - movzx eax, (IA32_TSS ptr [ecx])._DS - push eax - movzx eax, (IA32_TSS ptr [ecx])._ES - push eax - movzx eax, (IA32_TSS ptr [ecx])._FS - push eax - movzx eax, (IA32_TSS ptr [ecx])._GS - push eax - -;; UINT32 Eip; - push (IA32_TSS ptr [ecx]).EIP - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0FFFFh - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - mov eax, TSS_SEL - push eax - movzx eax, (IA32_TSS ptr [ecx]).LDT - push eax - -;; UINT32 EFlags; - push (IA32_TSS ptr [ecx]).EFLAGS - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, cr4 - or eax, 208h - mov cr4, eax - push eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; -;; Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) -;; when executing fxsave/fxrstor instruction - clts - sub esp, 512 - mov edi, esp - db 0fh, 0aeh, 07h ;fxsave [edi] - -; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword ptr [ebp] - -;; call into exception handler - mov ebx, ecx - mov eax, SmiPFHandler - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, 14 - push edx - - ; - ; Call External Exception Handler - ; - call eax - add esp, 8 - - mov ecx, ebx -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - db 0fh, 0aeh, 0eh ; fxrstor [esi] - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoints in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov (IA32_TSS ptr [ecx])._CR3, eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop (IA32_TSS ptr [ecx]).EFLAGS - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop (IA32_TSS ptr [ecx]).EIP - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop eax - mov (IA32_TSS ptr [ecx])._GS, ax - pop eax - mov (IA32_TSS ptr [ecx])._FS, ax - pop eax - mov (IA32_TSS ptr [ecx])._ES, ax - pop eax - mov (IA32_TSS ptr [ecx])._DS, ax - pop eax - mov (IA32_TSS ptr [ecx])._CS, ax - pop eax - mov (IA32_TSS ptr [ecx])._SS, ax - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop (IA32_TSS ptr [ecx])._EDI - pop (IA32_TSS ptr [ecx])._ESI - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop (IA32_TSS ptr [ecx])._EBX - pop (IA32_TSS ptr [ecx])._EDX - pop (IA32_TSS ptr [ecx])._ECX - pop (IA32_TSS ptr [ecx])._EAX - - mov esp, ebp - -; Set single step DB# if SMM profile is enabled and page fault exception happens - cmp FeaturePcdGet (PcdCpuSmmProfileEnable), 0 - jz @Done2 - -; Create return context for iretd in stub function - mov eax, (IA32_TSS ptr [ecx])._ESP ; Get old stack pointer - mov ebx, (IA32_TSS ptr [ecx]).EIP - mov [eax - 0ch], ebx ; create EIP in old stack - movzx ebx, (IA32_TSS ptr [ecx])._CS - mov [eax - 08h], ebx ; create CS in old stack - mov ebx, (IA32_TSS ptr [ecx]).EFLAGS - bts ebx, 8 - mov [eax - 04h], ebx ; create eflags in old stack - mov eax, (IA32_TSS ptr [ecx])._ESP ; Get old stack pointer - sub eax, 0ch ; minus 12 byte - mov (IA32_TSS ptr [ecx])._ESP, eax ; Set new stack pointer -; Replace the EIP of interrupted task with stub function - mov eax, PageFaultStubFunction - mov (IA32_TSS ptr [ecx]).EIP, eax -; Jump to the iretd so next page fault handler as a task will start again after iretd. -@Done2: - add esp, 4 ; skip ErrCode - - jmp Return -PageFaultIdtHandlerSmmProfile ENDP - -PageFaultStubFunction PROC -; -; we need clean TS bit in CR0 to execute -; x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. -; - clts - iretd -PageFaultStubFunction ENDP - - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm deleted file mode 100644 index 7c80a6ae91..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm +++ /dev/null @@ -1,708 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.nasm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -extern ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable)) -extern ASM_PFX(SmiPFHandler) - -global ASM_PFX(gcSmiIdtr) -global ASM_PFX(gcSmiGdtr) -global ASM_PFX(gTaskGateDescriptor) -global ASM_PFX(gcPsd) - - SECTION .data - -NullSeg: DQ 0 ; reserved by architecture -CodeSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -ProtModeCodeSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -ProtModeSsSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x93 - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -DataSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x93 - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -CodeSeg16: - DW -1 - DW 0 - DB 0 - DB 0x9b - DB 0x8f - DB 0 -DataSeg16: - DW -1 - DW 0 - DB 0 - DB 0x93 - DB 0x8f - DB 0 -CodeSeg64: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xaf ; LimitHigh - DB 0 ; BaseHigh -GDT_SIZE equ $ - NullSeg - -TssSeg: - DW TSS_DESC_SIZE ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x89 - DB 0x80 ; LimitHigh - DB 0 ; BaseHigh -ExceptionTssSeg: - DW TSS_DESC_SIZE ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x89 - DB 0x80 ; LimitHigh - DB 0 ; BaseHigh - -CODE_SEL equ CodeSeg32 - NullSeg -DATA_SEL equ DataSeg32 - NullSeg -TSS_SEL equ TssSeg - NullSeg -EXCEPTION_TSS_SEL equ ExceptionTssSeg - NullSeg - -struc IA32_TSS - resw 1 - resw 1 - .ESP0: resd 1 - .SS0: resw 1 - resw 1 - .ESP1: resd 1 - .SS1: resw 1 - resw 1 - .ESP2: resd 1 - .SS2: resw 1 - resw 1 - ._CR3: resd 1 - .EIP: resd 1 - .EFLAGS: resd 1 - ._EAX: resd 1 - ._ECX: resd 1 - ._EDX: resd 1 - ._EBX: resd 1 - ._ESP: resd 1 - ._EBP: resd 1 - ._ESI: resd 1 - ._EDI: resd 1 - ._ES: resw 1 - resw 1 - ._CS: resw 1 - resw 1 - ._SS: resw 1 - resw 1 - ._DS: resw 1 - resw 1 - ._FS: resw 1 - resw 1 - ._GS: resw 1 - resw 1 - .LDT: resw 1 - resw 1 - resw 1 - resw 1 -endstruc - -; Create 2 TSS segments just after GDT -TssDescriptor: - DW 0 ; PreviousTaskLink - DW 0 ; Reserved - DD 0 ; ESP0 - DW 0 ; SS0 - DW 0 ; Reserved - DD 0 ; ESP1 - DW 0 ; SS1 - DW 0 ; Reserved - DD 0 ; ESP2 - DW 0 ; SS2 - DW 0 ; Reserved - DD 0 ; CR3 - DD 0 ; EIP - DD 0 ; EFLAGS - DD 0 ; EAX - DD 0 ; ECX - DD 0 ; EDX - DD 0 ; EBX - DD 0 ; ESP - DD 0 ; EBP - DD 0 ; ESI - DD 0 ; EDI - DW 0 ; ES - DW 0 ; Reserved - DW 0 ; CS - DW 0 ; Reserved - DW 0 ; SS - DW 0 ; Reserved - DW 0 ; DS - DW 0 ; Reserved - DW 0 ; FS - DW 0 ; Reserved - DW 0 ; GS - DW 0 ; Reserved - DW 0 ; LDT Selector - DW 0 ; Reserved - DW 0 ; T - DW 0 ; I/O Map Base -TSS_DESC_SIZE equ $ - TssDescriptor - -ExceptionTssDescriptor: - DW 0 ; PreviousTaskLink - DW 0 ; Reserved - DD 0 ; ESP0 - DW 0 ; SS0 - DW 0 ; Reserved - DD 0 ; ESP1 - DW 0 ; SS1 - DW 0 ; Reserved - DD 0 ; ESP2 - DW 0 ; SS2 - DW 0 ; Reserved - DD 0 ; CR3 - DD PFHandlerEntry ; EIP - DD 00000002 ; EFLAGS - DD 0 ; EAX - DD 0 ; ECX - DD 0 ; EDX - DD 0 ; EBX - DD 0 ; ESP - DD 0 ; EBP - DD 0 ; ESI - DD 0 ; EDI - DW DATA_SEL ; ES - DW 0 ; Reserved - DW CODE_SEL ; CS - DW 0 ; Reserved - DW DATA_SEL ; SS - DW 0 ; Reserved - DW DATA_SEL ; DS - DW 0 ; Reserved - DW DATA_SEL ; FS - DW 0 ; Reserved - DW DATA_SEL ; GS - DW 0 ; Reserved - DW 0 ; LDT Selector - DW 0 ; Reserved - DW 0 ; T - DW 0 ; I/O Map Base - -ASM_PFX(gcPsd): - DB 'PSDSIG ' - DW PSD_SIZE - DW 2 - DW 1 << 2 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW 0 - DQ 0 - DQ 0 - DQ 0 - DD 0 - DD NullSeg - DD GDT_SIZE - DD 0 - times 24 DB 0 - DD 0 - DD 0 -PSD_SIZE equ $ - ASM_PFX(gcPsd) - -ASM_PFX(gcSmiGdtr): - DW GDT_SIZE - 1 - DD NullSeg - -ASM_PFX(gcSmiIdtr): - DW 0 - DD 0 - -ASM_PFX(gTaskGateDescriptor): - DW 0 ; Reserved - DW EXCEPTION_TSS_SEL ; TSS Segment selector - DB 0 ; Reserved - DB 0x85 ; Task Gate, present, DPL = 0 - DW 0 ; Reserved - - SECTION .text -;------------------------------------------------------------------------------ -; PageFaultIdtHandlerSmmProfile is the entry point page fault only -; -; -; Stack: -; +---------------------+ -; + EFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + EIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + EBP + -; +---------------------+ <-- EBP -; -; -;------------------------------------------------------------------------------ -global ASM_PFX(PageFaultIdtHandlerSmmProfile) -ASM_PFX(PageFaultIdtHandlerSmmProfile): - push 0xe ; Page Fault - - push ebp - mov ebp, esp - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0xfffffff0 - sub esp, 12 - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push eax - push ecx - push edx - push ebx - lea ecx, [ebp + 6 * 4] - push ecx ; ESP - push dword [ebp] ; EBP - push esi - push edi - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - mov eax, ss - push eax - movzx eax, word [ebp + 4 * 4] - push eax - mov eax, ds - push eax - mov eax, es - push eax - mov eax, fs - push eax - mov eax, gs - push eax - -;; UINT32 Eip; - mov eax, [ebp + 3 * 4] - push eax - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - xor eax, eax - str ax - push eax - sldt ax - push eax - -;; UINT32 EFlags; - mov eax, [ebp + 5 * 4] - push eax - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, cr4 - or eax, 0x208 - mov cr4, eax - push eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; - sub esp, 512 - mov edi, esp - db 0xf, 0xae, 0x7 ;fxsave [edi] - -; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword [ebp + 2 * 4] - -;; call into exception handler - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, dword [ebp + 1 * 4] - push edx - - ; - ; Call External Exception Handler - ; - mov eax, ASM_PFX(SmiPFHandler) - call eax - add esp, 8 - -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - db 0xf, 0xae, 0xe ; fxrstor [esi] - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoint in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov cr3, eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop dword [ebp + 5 * 4] - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop dword [ebp + 3 * 4] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop gs - pop fs - pop es - pop ds - pop dword [ebp + 4 * 4] - pop ss - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop edi - pop esi - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop ebx - pop edx - pop ecx - pop eax - - mov esp, ebp - pop ebp - -; Enable TF bit after page fault handler runs - bts dword [esp + 16], 8 ; EFLAGS - - add esp, 8 ; skip INT# & ErrCode -Return: - iretd -; -; Page Fault Exception Handler entry when SMM Stack Guard is enabled -; Executiot starts here after a task switch -; -PFHandlerEntry: -; -; Get this processor's TSS -; - sub esp, 8 - sgdt [esp + 2] - mov eax, [esp + 4] ; GDT base - add esp, 8 - mov ecx, [eax + TSS_SEL + 2] - shl ecx, 8 - mov cl, [eax + TSS_SEL + 7] - ror ecx, 8 ; ecx = TSS base - - mov ebp, esp - - ; - ; Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 - ; is 16-byte aligned - ; - and esp, 0xfffffff0 - sub esp, 12 - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - push dword [ecx + IA32_TSS._EAX] - push dword [ecx + IA32_TSS._ECX] - push dword [ecx + IA32_TSS._EDX] - push dword [ecx + IA32_TSS._EBX] - push dword [ecx + IA32_TSS._ESP] - push dword [ecx + IA32_TSS._EBP] - push dword [ecx + IA32_TSS._ESI] - push dword [ecx + IA32_TSS._EDI] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; - movzx eax, word [ecx + IA32_TSS._SS] - push eax - movzx eax, word [ecx + IA32_TSS._CS] - push eax - movzx eax, word [ecx + IA32_TSS._DS] - push eax - movzx eax, word [ecx + IA32_TSS._ES] - push eax - movzx eax, word [ecx + IA32_TSS._FS] - push eax - movzx eax, word [ecx + IA32_TSS._GS] - push eax - -;; UINT32 Eip; - push dword [ecx + IA32_TSS.EIP] - -;; UINT32 Gdtr[2], Idtr[2]; - sub esp, 8 - sidt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - - sub esp, 8 - sgdt [esp] - mov eax, [esp + 2] - xchg eax, [esp] - and eax, 0xFFFF - mov [esp+4], eax - -;; UINT32 Ldtr, Tr; - mov eax, TSS_SEL - push eax - movzx eax, word [ecx + IA32_TSS.LDT] - push eax - -;; UINT32 EFlags; - push dword [ecx + IA32_TSS.EFLAGS] - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - mov eax, cr4 - or eax, 0x208 - mov cr4, eax - push eax - mov eax, cr3 - push eax - mov eax, cr2 - push eax - xor eax, eax - push eax - mov eax, cr0 - push eax - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov eax, dr7 - push eax - mov eax, dr6 - push eax - mov eax, dr3 - push eax - mov eax, dr2 - push eax - mov eax, dr1 - push eax - mov eax, dr0 - push eax - -;; FX_SAVE_STATE_IA32 FxSaveState; -;; Clear TS bit in CR0 to avoid Device Not Available Exception (#NM) -;; when executing fxsave/fxrstor instruction - clts - sub esp, 512 - mov edi, esp - db 0xf, 0xae, 0x7 ;fxsave [edi] - -; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push dword [ebp] - -;; call into exception handler - mov ebx, ecx - mov eax, ASM_PFX(SmiPFHandler) - -;; Prepare parameter and call - mov edx, esp - push edx - mov edx, 14 - push edx - - ; - ; Call External Exception Handler - ; - call eax - add esp, 8 - - mov ecx, ebx -;; UINT32 ExceptionData; - add esp, 4 - -;; FX_SAVE_STATE_IA32 FxSaveState; - mov esi, esp - db 0xf, 0xae, 0xe ; fxrstor [esi] - add esp, 512 - -;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoints in interrupt/exception context - add esp, 4 * 6 - -;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; - pop eax - mov cr0, eax - add esp, 4 ; not for Cr1 - pop eax - mov cr2, eax - pop eax - mov dword [ecx + IA32_TSS._CR3], eax - pop eax - mov cr4, eax - -;; UINT32 EFlags; - pop dword [ecx + IA32_TSS.EFLAGS] - -;; UINT32 Ldtr, Tr; -;; UINT32 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add esp, 24 - -;; UINT32 Eip; - pop dword [ecx + IA32_TSS.EIP] - -;; UINT32 Gs, Fs, Es, Ds, Cs, Ss; -;; NOTE - modified segment registers could hang the debugger... We -;; could attempt to insulate ourselves against this possibility, -;; but that poses risks as well. -;; - pop eax -o16 mov [ecx + IA32_TSS._GS], ax - pop eax -o16 mov [ecx + IA32_TSS._FS], ax - pop eax -o16 mov [ecx + IA32_TSS._ES], ax - pop eax -o16 mov [ecx + IA32_TSS._DS], ax - pop eax -o16 mov [ecx + IA32_TSS._CS], ax - pop eax -o16 mov [ecx + IA32_TSS._SS], ax - -;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; - pop dword [ecx + IA32_TSS._EDI] - pop dword [ecx + IA32_TSS._ESI] - add esp, 4 ; not for ebp - add esp, 4 ; not for esp - pop dword [ecx + IA32_TSS._EBX] - pop dword [ecx + IA32_TSS._EDX] - pop dword [ecx + IA32_TSS._ECX] - pop dword [ecx + IA32_TSS._EAX] - - mov esp, ebp - -; Set single step DB# if SMM profile is enabled and page fault exception happens - cmp byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable))], 0 - jz @Done2 - -; Create return context for iretd in stub function - mov eax, dword [ecx + IA32_TSS._ESP] ; Get old stack pointer - mov ebx, dword [ecx + IA32_TSS.EIP] - mov [eax - 0xc], ebx ; create EIP in old stack - movzx ebx, word [ecx + IA32_TSS._CS] - mov [eax - 0x8], ebx ; create CS in old stack - mov ebx, dword [ecx + IA32_TSS.EFLAGS] - bts ebx, 8 - mov [eax - 0x4], ebx ; create eflags in old stack - mov eax, dword [ecx + IA32_TSS._ESP] ; Get old stack pointer - sub eax, 0xc ; minus 12 byte - mov dword [ecx + IA32_TSS._ESP], eax ; Set new stack pointer -; Replace the EIP of interrupted task with stub function - mov eax, ASM_PFX(PageFaultStubFunction) - mov dword [ecx + IA32_TSS.EIP], eax -; Jump to the iretd so next page fault handler as a task will start again after iretd. -@Done2: - add esp, 4 ; skip ErrCode - - jmp Return - -global ASM_PFX(PageFaultStubFunction) -ASM_PFX(PageFaultStubFunction): -; -; we need clean TS bit in CR0 to execute -; x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instructions. -; - clts - iretd - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c deleted file mode 100644 index 3c68c97024..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c +++ /dev/null @@ -1,209 +0,0 @@ -/** @file - SMM CPU misc functions for Ia32 arch specific. - -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -extern UINT64 gTaskGateDescriptor; - -EFI_PHYSICAL_ADDRESS mGdtBuffer; -UINTN mGdtBufferSize; - -/** - Initialize IDT for SMM Stack Guard. - -**/ -VOID -EFIAPI -InitializeIDTSmmStackGuard ( - VOID - ) -{ - IA32_IDT_GATE_DESCRIPTOR *IdtGate; - - // - // If SMM Stack Guard feature is enabled, the Page Fault Exception entry in IDT - // is a Task Gate Descriptor so that when a Page Fault Exception occurs, - // the processors can use a known good stack in case stack is ran out. - // - IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base; - IdtGate += EXCEPT_IA32_PAGE_FAULT; - IdtGate->Uint64 = gTaskGateDescriptor; -} - -/** - Initialize Gdt for all processors. - - @param[in] Cr3 CR3 value. - @param[out] GdtStepSize The step size for GDT table. - - @return GdtBase for processor 0. - GdtBase for processor X is: GdtBase + (GdtStepSize * X) -**/ -VOID * -InitGdt ( - IN UINTN Cr3, - OUT UINTN *GdtStepSize - ) -{ - UINTN Index; - IA32_SEGMENT_DESCRIPTOR *GdtDescriptor; - UINTN TssBase; - UINTN GdtTssTableSize; - UINT8 *GdtTssTables; - UINTN GdtTableStepSize; - - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - // - // For IA32 SMM, if SMM Stack Guard feature is enabled, we use 2 TSS. - // in this case, we allocate separate GDT/TSS for each CPUs to avoid TSS load contention - // on each SMI entry. - // - - // - // Enlarge GDT to contain 2 TSS descriptors - // - gcSmiGdtr.Limit += (UINT16)(2 * sizeof (IA32_SEGMENT_DESCRIPTOR)); - - GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE * 2 + 7) & ~7; // 8 bytes aligned - mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); - ASSERT (GdtTssTables != NULL); - mGdtBuffer = (UINTN)GdtTssTables; - GdtTableStepSize = GdtTssTableSize; - - for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { - CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE * 2); - // - // Fixup TSS descriptors - // - TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1); - GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2; - GdtDescriptor->Bits.BaseLow = (UINT16)TssBase; - GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16); - GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24); - - TssBase += TSS_SIZE; - GdtDescriptor++; - GdtDescriptor->Bits.BaseLow = (UINT16)TssBase; - GdtDescriptor->Bits.BaseMid = (UINT8)(TssBase >> 16); - GdtDescriptor->Bits.BaseHigh = (UINT8)(TssBase >> 24); - // - // Fixup TSS segments - // - // ESP as known good stack - // - *(UINTN *)(TssBase + TSS_IA32_ESP_OFFSET) = mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize; - *(UINT32 *)(TssBase + TSS_IA32_CR3_OFFSET) = Cr3; - } - } else { - // - // Just use original table, AllocatePage and copy them here to make sure GDTs are covered in page memory. - // - GdtTssTableSize = gcSmiGdtr.Limit + 1; - mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); - ASSERT (GdtTssTables != NULL); - mGdtBuffer = (UINTN)GdtTssTables; - GdtTableStepSize = GdtTssTableSize; - - for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { - CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1); - } - } - - *GdtStepSize = GdtTableStepSize; - return GdtTssTables; -} - -/** - This function sets GDT/IDT buffer to be RO and XP. -**/ -VOID -PatchGdtIdtMap ( - VOID - ) -{ - EFI_PHYSICAL_ADDRESS BaseAddress; - UINTN Size; - - // - // GDT - // - DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n")); - - BaseAddress = mGdtBuffer; - Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB); - if (!FeaturePcdGet (PcdCpuSmmStackGuard)) { - // - // Do not set RO for IA32 when stack guard feature is enabled. - // Stack Guard need use task switch to switch stack. - // It need write GDT and TSS. - // - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_RO - ); - } - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_XP - ); - - // - // IDT - // - DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n")); - - BaseAddress = gcSmiIdtr.Base; - Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_RO - ); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_XP - ); -} - -/** - Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. - - @param[in] ApHltLoopCode The address of the safe hlt-loop function. - @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. - @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. - -**/ -VOID -TransferApToSafeState ( - IN UINTN ApHltLoopCode, - IN UINTN TopOfStack, - IN UINTN NumberToFinishAddress - ) -{ - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)ApHltLoopCode, - (VOID *)NumberToFinishAddress, - NULL, - (VOID *)TopOfStack - ); - // - // It should never reach here - // - ASSERT (FALSE); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S deleted file mode 100644 index e8db33a45a..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.S +++ /dev/null @@ -1,84 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmmInit.S -# -# Abstract: -# -# Functions for relocating SMBASE's for all processors -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gSmmCr0) -ASM_GLOBAL ASM_PFX(gSmmCr3) -ASM_GLOBAL ASM_PFX(gSmmCr4) -ASM_GLOBAL ASM_PFX(gcSmmInitTemplate) -ASM_GLOBAL ASM_PFX(gcSmmInitSize) -ASM_GLOBAL ASM_PFX(gSmmJmpAddr) -ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete) -ASM_GLOBAL ASM_PFX(gSmmInitStack) -ASM_GLOBAL ASM_PFX(gcSmiInitGdtr) - -.equ PROTECT_MODE_CS, 0x08 -.equ PROTECT_MODE_DS, 0x20 - - .text - -ASM_PFX(gcSmiInitGdtr): - .word 0 - .quad 0 - -SmmStartup: - .byte 0x66,0xb8 -ASM_PFX(gSmmCr3): .space 4 - movl %eax, %cr3 - .byte 0x67,0x66 - lgdt %cs:(ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp) - .byte 0x66,0xb8 -ASM_PFX(gSmmCr4): .space 4 - movl %eax, %cr4 - .byte 0x66,0xb8 -ASM_PFX(gSmmCr0): .space 4 - .byte 0xbf, PROTECT_MODE_DS, 0 # mov di, PROTECT_MODE_DS - movl %eax, %cr0 - .byte 0x66,0xea # jmp far [ptr48] -ASM_PFX(gSmmJmpAddr): .long Start32bit - .word PROTECT_MODE_CS -Start32bit: - movl %edi,%ds - movl %edi,%es - movl %edi,%fs - movl %edi,%gs - movl %edi,%ss - .byte 0xbc # mov esp, imm32 -ASM_PFX(gSmmInitStack): .space 4 - call ASM_PFX(SmmInitHandler) - rsm - -ASM_PFX(gcSmmInitTemplate): - -_SmmInitTemplate: - .byte 0x66 - movl $SmmStartup, %ebp - .byte 0x66, 0x81, 0xed, 0, 0, 3, 0 # sub ebp, 0x30000 - jmp *%bp # jmp ebp actually - -ASM_PFX(gcSmmInitSize): .word . - ASM_PFX(gcSmmInitTemplate) - - -ASM_PFX(SmmRelocationSemaphoreComplete): - pushl %eax - movl ASM_PFX(mRebasedFlag), %eax - movb $1, (%eax) - popl %eax - jmp *ASM_PFX(mSmmRelocationOriginalAddress) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm deleted file mode 100644 index 9ba2aebe69..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.asm +++ /dev/null @@ -1,94 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmmInit.Asm -; -; Abstract: -; -; Functions for relocating SMBASE's for all processors -; -;------------------------------------------------------------------------------- - - .686p - .xmm - .model flat,C - -SmmInitHandler PROTO C - -EXTERNDEF C gSmmCr0:DWORD -EXTERNDEF C gSmmCr3:DWORD -EXTERNDEF C gSmmCr4:DWORD -EXTERNDEF C gcSmmInitTemplate:BYTE -EXTERNDEF C gcSmmInitSize:WORD -EXTERNDEF C gSmmJmpAddr:QWORD -EXTERNDEF C mRebasedFlag:PTR BYTE -EXTERNDEF C mSmmRelocationOriginalAddress:DWORD -EXTERNDEF C gSmmInitStack:DWORD -EXTERNDEF C gcSmiInitGdtr:FWORD - -PROTECT_MODE_CS EQU 08h -PROTECT_MODE_DS EQU 20h - - .code - -gcSmiInitGdtr LABEL FWORD - DW 0 - DQ 0 - -SmmStartup PROC - DB 66h, 0b8h -gSmmCr3 DD ? - mov cr3, eax - DB 67h, 66h - lgdt fword ptr cs:[ebp + (offset gcSmiInitGdtr - SmmStartup)] - DB 66h, 0b8h -gSmmCr4 DD ? - mov cr4, eax - DB 66h, 0b8h -gSmmCr0 DD ? - DB 0bfh, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS - mov cr0, eax - DB 66h, 0eah ; jmp far [ptr48] -gSmmJmpAddr LABEL QWORD - DD @32bit - DW PROTECT_MODE_CS -@32bit: - mov ds, edi - mov es, edi - mov fs, edi - mov gs, edi - mov ss, edi - DB 0bch ; mov esp, imm32 -gSmmInitStack DD ? - call SmmInitHandler - rsm -SmmStartup ENDP - -gcSmmInitTemplate LABEL BYTE - -_SmmInitTemplate PROC - DB 66h - mov ebp, SmmStartup - DB 66h, 81h, 0edh, 00h, 00h, 03h, 00 ; sub ebp, 30000h - jmp bp ; jmp ebp actually -_SmmInitTemplate ENDP - -gcSmmInitSize DW $ - gcSmmInitTemplate - -SmmRelocationSemaphoreComplete PROC - push eax - mov eax, mRebasedFlag - mov byte ptr [eax], 1 - pop eax - jmp [mSmmRelocationOriginalAddress] -SmmRelocationSemaphoreComplete ENDP - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm deleted file mode 100644 index d9df3626c7..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm +++ /dev/null @@ -1,87 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmmInit.nasm -; -; Abstract: -; -; Functions for relocating SMBASE's for all processors -; -;------------------------------------------------------------------------------- - -extern ASM_PFX(SmmInitHandler) -extern ASM_PFX(mRebasedFlag) -extern ASM_PFX(mSmmRelocationOriginalAddress) - -global ASM_PFX(gSmmCr3) -global ASM_PFX(gSmmCr4) -global ASM_PFX(gSmmCr0) -global ASM_PFX(gSmmJmpAddr) -global ASM_PFX(gSmmInitStack) -global ASM_PFX(gcSmiInitGdtr) -global ASM_PFX(gcSmmInitSize) -global ASM_PFX(gcSmmInitTemplate) - -%define PROTECT_MODE_CS 0x8 -%define PROTECT_MODE_DS 0x20 - - SECTION .text - -ASM_PFX(gcSmiInitGdtr): - DW 0 - DQ 0 - -global ASM_PFX(SmmStartup) -ASM_PFX(SmmStartup): - DB 0x66, 0xb8 -ASM_PFX(gSmmCr3): DD 0 - mov cr3, eax - DB 0x67, 0x66 - lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] - DB 0x66, 0xb8 -ASM_PFX(gSmmCr4): DD 0 - mov cr4, eax - DB 0x66, 0xb8 -ASM_PFX(gSmmCr0): DD 0 - DB 0xbf, PROTECT_MODE_DS, 0 ; mov di, PROTECT_MODE_DS - mov cr0, eax - DB 0x66, 0xea ; jmp far [ptr48] -ASM_PFX(gSmmJmpAddr): - DD @32bit - DW PROTECT_MODE_CS -@32bit: - mov ds, edi - mov es, edi - mov fs, edi - mov gs, edi - mov ss, edi - DB 0xbc ; mov esp, imm32 -ASM_PFX(gSmmInitStack): DD 0 - call ASM_PFX(SmmInitHandler) - rsm - -BITS 16 -ASM_PFX(gcSmmInitTemplate): - mov ebp, ASM_PFX(SmmStartup) - sub ebp, 0x30000 - jmp ebp - -ASM_PFX(gcSmmInitSize): DW $ - ASM_PFX(gcSmmInitTemplate) - -BITS 32 -global ASM_PFX(SmmRelocationSemaphoreComplete) -ASM_PFX(SmmRelocationSemaphoreComplete): - push eax - mov eax, [ASM_PFX(mRebasedFlag)] - mov byte [eax], 1 - pop eax - jmp [ASM_PFX(mSmmRelocationOriginalAddress)] diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c deleted file mode 100644 index 724cd92c9c..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.c +++ /dev/null @@ -1,80 +0,0 @@ -/** @file -IA-32 processor specific functions to enable SMM profile. - -Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" -#include "SmmProfileInternal.h" - -/** - Create SMM page table for S3 path. - -**/ -VOID -InitSmmS3Cr3 ( - VOID - ) -{ - mSmmS3ResumeState->SmmS3Cr3 = Gen4GPageTable (TRUE); - - return ; -} - -/** - Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. - 32-bit firmware does not need it. - -**/ -VOID -InitPagesForPFHandler ( - VOID - ) -{ -} - -/** - Update page table to map the memory correctly in order to make the instruction - which caused page fault execute successfully. And it also save the original page - table to be restored in single-step exception. 32-bit firmware does not need it. - - @param PageTable PageTable Address. - @param PFAddress The memory address which caused page fault exception. - @param CpuIndex The index of the processor. - @param ErrorCode The Error code of exception. - @param IsValidPFAddress The flag indicates if SMM profile data need be added. - -**/ -VOID -RestorePageTableAbove4G ( - UINT64 *PageTable, - UINT64 PFAddress, - UINTN CpuIndex, - UINTN ErrorCode, - BOOLEAN *IsValidPFAddress - ) -{ -} - -/** - Clear TF in FLAGS. - - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. - -**/ -VOID -ClearTrapFlag ( - IN OUT EFI_SYSTEM_CONTEXT SystemContext - ) -{ - SystemContext.SystemContextIa32->Eflags &= (UINTN) ~BIT8; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h deleted file mode 100644 index 3e15bffc60..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h +++ /dev/null @@ -1,97 +0,0 @@ -/** @file -IA-32 processor specific header file to enable SMM profile. - -Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_PROFILE_ARCH_H_ -#define _SMM_PROFILE_ARCH_H_ - -#pragma pack (1) - -typedef struct _MSR_DS_AREA_STRUCT { - UINT32 BTSBufferBase; - UINT32 BTSIndex; - UINT32 BTSAbsoluteMaximum; - UINT32 BTSInterruptThreshold; - UINT32 PEBSBufferBase; - UINT32 PEBSIndex; - UINT32 PEBSAbsoluteMaximum; - UINT32 PEBSInterruptThreshold; - UINT32 PEBSCounterReset[4]; - UINT32 Reserved; -} MSR_DS_AREA_STRUCT; - -typedef struct _BRANCH_TRACE_RECORD { - UINT32 LastBranchFrom; - UINT32 LastBranchTo; - UINT32 Rsvd0 : 4; - UINT32 BranchPredicted : 1; - UINT32 Rsvd1 : 27; -} BRANCH_TRACE_RECORD; - -typedef struct _PEBS_RECORD { - UINT32 Eflags; - UINT32 LinearIP; - UINT32 Eax; - UINT32 Ebx; - UINT32 Ecx; - UINT32 Edx; - UINT32 Esi; - UINT32 Edi; - UINT32 Ebp; - UINT32 Esp; -} PEBS_RECORD; - -#pragma pack () - -#define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB) - -/** - Update page table to map the memory correctly in order to make the instruction - which caused page fault execute successfully. And it also save the original page - table to be restored in single-step exception. 32-bit firmware does not need it. - - @param PageTable PageTable Address. - @param PFAddress The memory address which caused page fault exception. - @param CpuIndex The index of the processor. - @param ErrorCode The Error code of exception. - @param IsValidPFAddress The flag indicates if SMM profile data need be added. - -**/ -VOID -RestorePageTableAbove4G ( - UINT64 *PageTable, - UINT64 PFAddress, - UINTN CpuIndex, - UINTN ErrorCode, - BOOLEAN *IsValidPFAddress - ); - -/** - Create SMM page table for S3 path. - -**/ -VOID -InitSmmS3Cr3 ( - VOID - ); - -/** - Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. - -**/ -VOID -InitPagesForPFHandler ( - VOID - ); - -#endif // _SMM_PROFILE_ARCH_H_ diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c deleted file mode 100644 index a1d16b4570..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ /dev/null @@ -1,1390 +0,0 @@ -/** @file -SMM MP service implementation - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -// -// Slots for all MTRR( FIXED MTRR + VARIABLE MTRR + MTRR_LIB_IA32_MTRR_DEF_TYPE) -// -MTRR_SETTINGS gSmiMtrrs; -UINT64 gPhyMask; -SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData = NULL; -UINTN mSmmMpSyncDataSize; -SMM_CPU_SEMAPHORES mSmmCpuSemaphores; -UINTN mSemaphoreSize; -SPIN_LOCK *mPFLock = NULL; -SMM_CPU_SYNC_MODE mCpuSmmSyncMode; - -/** - Performs an atomic compare exchange operation to get semaphore. - The compare exchange operation must be performed using - MP safe mechanisms. - - @param Sem IN: 32-bit unsigned integer - OUT: original integer - 1 - @return Original integer - 1 - -**/ -UINT32 -WaitForSemaphore ( - IN OUT volatile UINT32 *Sem - ) -{ - UINT32 Value; - - do { - Value = *Sem; - } while (Value == 0 || - InterlockedCompareExchange32 ( - (UINT32*)Sem, - Value, - Value - 1 - ) != Value); - return Value - 1; -} - - -/** - Performs an atomic compare exchange operation to release semaphore. - The compare exchange operation must be performed using - MP safe mechanisms. - - @param Sem IN: 32-bit unsigned integer - OUT: original integer + 1 - @return Original integer + 1 - -**/ -UINT32 -ReleaseSemaphore ( - IN OUT volatile UINT32 *Sem - ) -{ - UINT32 Value; - - do { - Value = *Sem; - } while (Value + 1 != 0 && - InterlockedCompareExchange32 ( - (UINT32*)Sem, - Value, - Value + 1 - ) != Value); - return Value + 1; -} - -/** - Performs an atomic compare exchange operation to lock semaphore. - The compare exchange operation must be performed using - MP safe mechanisms. - - @param Sem IN: 32-bit unsigned integer - OUT: -1 - @return Original integer - -**/ -UINT32 -LockdownSemaphore ( - IN OUT volatile UINT32 *Sem - ) -{ - UINT32 Value; - - do { - Value = *Sem; - } while (InterlockedCompareExchange32 ( - (UINT32*)Sem, - Value, (UINT32)-1 - ) != Value); - return Value; -} - -/** - Wait all APs to performs an atomic compare exchange operation to release semaphore. - - @param NumberOfAPs AP number - -**/ -VOID -WaitForAllAPs ( - IN UINTN NumberOfAPs - ) -{ - UINTN BspIndex; - - BspIndex = mSmmMpSyncData->BspIndex; - while (NumberOfAPs-- > 0) { - WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - } -} - -/** - Performs an atomic compare exchange operation to release semaphore - for each AP. - -**/ -VOID -ReleaseAllAPs ( - VOID - ) -{ - UINTN Index; - UINTN BspIndex; - - BspIndex = mSmmMpSyncData->BspIndex; - for (Index = mMaxNumberOfCpus; Index-- > 0;) { - if (Index != BspIndex && *(mSmmMpSyncData->CpuData[Index].Present)) { - ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run); - } - } -} - -/** - Checks if all CPUs (with certain exceptions) have checked in for this SMI run - - @param Exceptions CPU Arrival exception flags. - - @retval TRUE if all CPUs the have checked in. - @retval FALSE if at least one Normal AP hasn't checked in. - -**/ -BOOLEAN -AllCpusInSmmWithExceptions ( - SMM_CPU_ARRIVAL_EXCEPTIONS Exceptions - ) -{ - UINTN Index; - SMM_CPU_DATA_BLOCK *CpuData; - EFI_PROCESSOR_INFORMATION *ProcessorInfo; - - ASSERT (*mSmmMpSyncData->Counter <= mNumberOfCpus); - - if (*mSmmMpSyncData->Counter == mNumberOfCpus) { - return TRUE; - } - - CpuData = mSmmMpSyncData->CpuData; - ProcessorInfo = gSmmCpuPrivate->ProcessorInfo; - for (Index = mMaxNumberOfCpus; Index-- > 0;) { - if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { - if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmDelayed) != 0) { - continue; - } - if (((Exceptions & ARRIVAL_EXCEPTION_BLOCKED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmBlocked) != 0) { - continue; - } - if (((Exceptions & ARRIVAL_EXCEPTION_SMI_DISABLED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmEnable) != 0) { - continue; - } - return FALSE; - } - } - - - return TRUE; -} - - -/** - Given timeout constraint, wait for all APs to arrive, and insure when this function returns, no AP will execute normal mode code before - entering SMM, except SMI disabled APs. - -**/ -VOID -SmmWaitForApArrival ( - VOID - ) -{ - UINT64 Timer; - UINTN Index; - - ASSERT (*mSmmMpSyncData->Counter <= mNumberOfCpus); - - // - // Platform implementor should choose a timeout value appropriately: - // - The timeout value should balance the SMM time constrains and the likelihood that delayed CPUs are excluded in the SMM run. Note - // the SMI Handlers must ALWAYS take into account the cases that not all APs are available in an SMI run. - // - The timeout value must, in the case of 2nd timeout, be at least long enough to give time for all APs to receive the SMI IPI - // and either enter SMM or buffer the SMI, to insure there is no CPU running normal mode code when SMI handling starts. This will - // be TRUE even if a blocked CPU is brought out of the blocked state by a normal mode CPU (before the normal mode CPU received the - // SMI IPI), because with a buffered SMI, and CPU will enter SMM immediately after it is brought out of the blocked state. - // - The timeout value must be longer than longest possible IO operation in the system - // - - // - // Sync with APs 1st timeout - // - for (Timer = StartSyncTimer (); - !IsSyncTimerTimeout (Timer) && - !AllCpusInSmmWithExceptions (ARRIVAL_EXCEPTION_BLOCKED | ARRIVAL_EXCEPTION_SMI_DISABLED ); - ) { - CpuPause (); - } - - // - // Not all APs have arrived, so we need 2nd round of timeout. IPIs should be sent to ALL none present APs, - // because: - // a) Delayed AP may have just come out of the delayed state. Blocked AP may have just been brought out of blocked state by some AP running - // normal mode code. These APs need to be guaranteed to have an SMI pending to insure that once they are out of delayed / blocked state, they - // enter SMI immediately without executing instructions in normal mode. Note traditional flow requires there are no APs doing normal mode - // work while SMI handling is on-going. - // b) As a consequence of SMI IPI sending, (spurious) SMI may occur after this SMM run. - // c) ** NOTE **: Use SMI disabling feature VERY CAREFULLY (if at all) for traditional flow, because a processor in SMI-disabled state - // will execute normal mode code, which breaks the traditional SMI handlers' assumption that no APs are doing normal - // mode work while SMI handling is on-going. - // d) We don't add code to check SMI disabling status to skip sending IPI to SMI disabled APs, because: - // - In traditional flow, SMI disabling is discouraged. - // - In relaxed flow, CheckApArrival() will check SMI disabling status before calling this function. - // In both cases, adding SMI-disabling checking code increases overhead. - // - if (*mSmmMpSyncData->Counter < mNumberOfCpus) { - // - // Send SMI IPIs to bring outside processors in - // - for (Index = mMaxNumberOfCpus; Index-- > 0;) { - if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { - SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId); - } - } - - // - // Sync with APs 2nd timeout. - // - for (Timer = StartSyncTimer (); - !IsSyncTimerTimeout (Timer) && - !AllCpusInSmmWithExceptions (ARRIVAL_EXCEPTION_BLOCKED | ARRIVAL_EXCEPTION_SMI_DISABLED ); - ) { - CpuPause (); - } - } - - return; -} - - -/** - Replace OS MTRR's with SMI MTRR's. - - @param CpuIndex Processor Index - -**/ -VOID -ReplaceOSMtrrs ( - IN UINTN CpuIndex - ) -{ - SmmCpuFeaturesDisableSmrr (); - - // - // Replace all MTRRs registers - // - MtrrSetAllMtrrs (&gSmiMtrrs); -} - -/** - SMI handler for BSP. - - @param CpuIndex BSP processor Index - @param SyncMode SMM MP sync mode - -**/ -VOID -BSPHandler ( - IN UINTN CpuIndex, - IN SMM_CPU_SYNC_MODE SyncMode - ) -{ - UINTN Index; - MTRR_SETTINGS Mtrrs; - UINTN ApCount; - BOOLEAN ClearTopLevelSmiResult; - UINTN PresentCount; - - ASSERT (CpuIndex == mSmmMpSyncData->BspIndex); - ApCount = 0; - - // - // Flag BSP's presence - // - *mSmmMpSyncData->InsideSmm = TRUE; - - // - // Initialize Debug Agent to start source level debug in BSP handler - // - InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL); - - // - // Mark this processor's presence - // - *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; - - // - // Clear platform top level SMI status bit before calling SMI handlers. If - // we cleared it after SMI handlers are run, we would miss the SMI that - // occurs after SMI handlers are done and before SMI status bit is cleared. - // - ClearTopLevelSmiResult = ClearTopLevelSmiStatus(); - ASSERT (ClearTopLevelSmiResult == TRUE); - - // - // Set running processor index - // - gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu = CpuIndex; - - // - // If Traditional Sync Mode or need to configure MTRRs: gather all available APs. - // - if (SyncMode == SmmCpuSyncModeTradition || SmmCpuFeaturesNeedConfigureMtrrs()) { - - // - // Wait for APs to arrive - // - SmmWaitForApArrival(); - - // - // Lock the counter down and retrieve the number of APs - // - *mSmmMpSyncData->AllCpusInSync = TRUE; - ApCount = LockdownSemaphore (mSmmMpSyncData->Counter) - 1; - - // - // Wait for all APs to get ready for programming MTRRs - // - WaitForAllAPs (ApCount); - - if (SmmCpuFeaturesNeedConfigureMtrrs()) { - // - // Signal all APs it's time for backup MTRRs - // - ReleaseAllAPs (); - - // - // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at - // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been set - // to a large enough value to avoid this situation. - // Note: For HT capable CPUs, threads within a core share the same set of MTRRs. - // We do the backup first and then set MTRR to avoid race condition for threads - // in the same core. - // - MtrrGetAllMtrrs(&Mtrrs); - - // - // Wait for all APs to complete their MTRR saving - // - WaitForAllAPs (ApCount); - - // - // Let all processors program SMM MTRRs together - // - ReleaseAllAPs (); - - // - // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at - // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been set - // to a large enough value to avoid this situation. - // - ReplaceOSMtrrs (CpuIndex); - - // - // Wait for all APs to complete their MTRR programming - // - WaitForAllAPs (ApCount); - } - } - - // - // The BUSY lock is initialized to Acquired state - // - AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy); - - // - // Perform the pre tasks - // - PerformPreTasks (); - - // - // Invoke SMM Foundation EntryPoint with the processor information context. - // - gSmmCpuPrivate->SmmCoreEntry (&gSmmCpuPrivate->SmmCoreEntryContext); - - // - // Make sure all APs have completed their pending none-block tasks - // - for (Index = mMaxNumberOfCpus; Index-- > 0;) { - if (Index != CpuIndex && *(mSmmMpSyncData->CpuData[Index].Present)) { - AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy); - ReleaseSpinLock (mSmmMpSyncData->CpuData[Index].Busy); - } - } - - // - // Perform the remaining tasks - // - PerformRemainingTasks (); - - // - // If Relaxed-AP Sync Mode: gather all available APs after BSP SMM handlers are done, and - // make those APs to exit SMI synchronously. APs which arrive later will be excluded and - // will run through freely. - // - if (SyncMode != SmmCpuSyncModeTradition && !SmmCpuFeaturesNeedConfigureMtrrs()) { - - // - // Lock the counter down and retrieve the number of APs - // - *mSmmMpSyncData->AllCpusInSync = TRUE; - ApCount = LockdownSemaphore (mSmmMpSyncData->Counter) - 1; - // - // Make sure all APs have their Present flag set - // - while (TRUE) { - PresentCount = 0; - for (Index = mMaxNumberOfCpus; Index-- > 0;) { - if (*(mSmmMpSyncData->CpuData[Index].Present)) { - PresentCount ++; - } - } - if (PresentCount > ApCount) { - break; - } - } - } - - // - // Notify all APs to exit - // - *mSmmMpSyncData->InsideSmm = FALSE; - ReleaseAllAPs (); - - // - // Wait for all APs to complete their pending tasks - // - WaitForAllAPs (ApCount); - - if (SmmCpuFeaturesNeedConfigureMtrrs()) { - // - // Signal APs to restore MTRRs - // - ReleaseAllAPs (); - - // - // Restore OS MTRRs - // - SmmCpuFeaturesReenableSmrr (); - MtrrSetAllMtrrs(&Mtrrs); - - // - // Wait for all APs to complete MTRR programming - // - WaitForAllAPs (ApCount); - } - - // - // Stop source level debug in BSP handler, the code below will not be - // debugged. - // - InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); - - // - // Signal APs to Reset states/semaphore for this processor - // - ReleaseAllAPs (); - - // - // Perform pending operations for hot-plug - // - SmmCpuUpdate (); - - // - // Clear the Present flag of BSP - // - *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; - - // - // Gather APs to exit SMM synchronously. Note the Present flag is cleared by now but - // WaitForAllAps does not depend on the Present flag. - // - WaitForAllAPs (ApCount); - - // - // Reset BspIndex to -1, meaning BSP has not been elected. - // - if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { - mSmmMpSyncData->BspIndex = (UINT32)-1; - } - - // - // Allow APs to check in from this point on - // - *mSmmMpSyncData->Counter = 0; - *mSmmMpSyncData->AllCpusInSync = FALSE; -} - -/** - SMI handler for AP. - - @param CpuIndex AP processor Index. - @param ValidSmi Indicates that current SMI is a valid SMI or not. - @param SyncMode SMM MP sync mode. - -**/ -VOID -APHandler ( - IN UINTN CpuIndex, - IN BOOLEAN ValidSmi, - IN SMM_CPU_SYNC_MODE SyncMode - ) -{ - UINT64 Timer; - UINTN BspIndex; - MTRR_SETTINGS Mtrrs; - - // - // Timeout BSP - // - for (Timer = StartSyncTimer (); - !IsSyncTimerTimeout (Timer) && - !(*mSmmMpSyncData->InsideSmm); - ) { - CpuPause (); - } - - if (!(*mSmmMpSyncData->InsideSmm)) { - // - // BSP timeout in the first round - // - if (mSmmMpSyncData->BspIndex != -1) { - // - // BSP Index is known - // - BspIndex = mSmmMpSyncData->BspIndex; - ASSERT (CpuIndex != BspIndex); - - // - // Send SMI IPI to bring BSP in - // - SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[BspIndex].ProcessorId); - - // - // Now clock BSP for the 2nd time - // - for (Timer = StartSyncTimer (); - !IsSyncTimerTimeout (Timer) && - !(*mSmmMpSyncData->InsideSmm); - ) { - CpuPause (); - } - - if (!(*mSmmMpSyncData->InsideSmm)) { - // - // Give up since BSP is unable to enter SMM - // and signal the completion of this AP - WaitForSemaphore (mSmmMpSyncData->Counter); - return; - } - } else { - // - // Don't know BSP index. Give up without sending IPI to BSP. - // - WaitForSemaphore (mSmmMpSyncData->Counter); - return; - } - } - - // - // BSP is available - // - BspIndex = mSmmMpSyncData->BspIndex; - ASSERT (CpuIndex != BspIndex); - - // - // Mark this processor's presence - // - *(mSmmMpSyncData->CpuData[CpuIndex].Present) = TRUE; - - if (SyncMode == SmmCpuSyncModeTradition || SmmCpuFeaturesNeedConfigureMtrrs()) { - // - // Notify BSP of arrival at this point - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - } - - if (SmmCpuFeaturesNeedConfigureMtrrs()) { - // - // Wait for the signal from BSP to backup MTRRs - // - WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - // - // Backup OS MTRRs - // - MtrrGetAllMtrrs(&Mtrrs); - - // - // Signal BSP the completion of this AP - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - - // - // Wait for BSP's signal to program MTRRs - // - WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - // - // Replace OS MTRRs with SMI MTRRs - // - ReplaceOSMtrrs (CpuIndex); - - // - // Signal BSP the completion of this AP - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - } - - while (TRUE) { - // - // Wait for something to happen - // - WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - // - // Check if BSP wants to exit SMM - // - if (!(*mSmmMpSyncData->InsideSmm)) { - break; - } - - // - // BUSY should be acquired by SmmStartupThisAp() - // - ASSERT ( - !AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy) - ); - - // - // Invoke the scheduled procedure - // - (*mSmmMpSyncData->CpuData[CpuIndex].Procedure) ( - (VOID*)mSmmMpSyncData->CpuData[CpuIndex].Parameter - ); - - // - // Release BUSY - // - ReleaseSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - } - - if (SmmCpuFeaturesNeedConfigureMtrrs()) { - // - // Notify BSP the readiness of this AP to program MTRRs - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - - // - // Wait for the signal from BSP to program MTRRs - // - WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - // - // Restore OS MTRRs - // - SmmCpuFeaturesReenableSmrr (); - MtrrSetAllMtrrs(&Mtrrs); - } - - // - // Notify BSP the readiness of this AP to Reset states/semaphore for this processor - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - - // - // Wait for the signal from BSP to Reset states/semaphore for this processor - // - WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - // - // Reset states/semaphore for this processor - // - *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; - - // - // Notify BSP the readiness of this AP to exit SMM - // - ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run); - -} - -/** - Create 4G PageTable in SMRAM. - - @param[in] Is32BitPageTable Whether the page table is 32-bit PAE - @return PageTable Address - -**/ -UINT32 -Gen4GPageTable ( - IN BOOLEAN Is32BitPageTable - ) -{ - VOID *PageTable; - UINTN Index; - UINT64 *Pte; - UINTN PagesNeeded; - UINTN Low2MBoundary; - UINTN High2MBoundary; - UINTN Pages; - UINTN GuardPage; - UINT64 *Pdpte; - UINTN PageIndex; - UINTN PageAddress; - - Low2MBoundary = 0; - High2MBoundary = 0; - PagesNeeded = 0; - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - // - // Add one more page for known good stack, then find the lower 2MB aligned address. - // - Low2MBoundary = (mSmmStackArrayBase + EFI_PAGE_SIZE) & ~(SIZE_2MB-1); - // - // Add two more pages for known good stack and stack guard page, - // then find the lower 2MB aligned address. - // - High2MBoundary = (mSmmStackArrayEnd - mSmmStackSize + EFI_PAGE_SIZE * 2) & ~(SIZE_2MB-1); - PagesNeeded = ((High2MBoundary - Low2MBoundary) / SIZE_2MB) + 1; - } - // - // Allocate the page table - // - PageTable = AllocatePageTableMemory (5 + PagesNeeded); - ASSERT (PageTable != NULL); - - PageTable = (VOID *)((UINTN)PageTable); - Pte = (UINT64*)PageTable; - - // - // Zero out all page table entries first - // - ZeroMem (Pte, EFI_PAGES_TO_SIZE (1)); - - // - // Set Page Directory Pointers - // - for (Index = 0; Index < 4; Index++) { - Pte[Index] = ((UINTN)PageTable + EFI_PAGE_SIZE * (Index + 1)) | mAddressEncMask | - (Is32BitPageTable ? IA32_PAE_PDPTE_ATTRIBUTE_BITS : PAGE_ATTRIBUTE_BITS); - } - Pte += EFI_PAGE_SIZE / sizeof (*Pte); - - // - // Fill in Page Directory Entries - // - for (Index = 0; Index < EFI_PAGE_SIZE * 4 / sizeof (*Pte); Index++) { - Pte[Index] = (Index << 21) | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; - } - - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - Pages = (UINTN)PageTable + EFI_PAGES_TO_SIZE (5); - GuardPage = mSmmStackArrayBase + EFI_PAGE_SIZE; - Pdpte = (UINT64*)PageTable; - for (PageIndex = Low2MBoundary; PageIndex <= High2MBoundary; PageIndex += SIZE_2MB) { - Pte = (UINT64*)(UINTN)(Pdpte[BitFieldRead32 ((UINT32)PageIndex, 30, 31)] & ~mAddressEncMask & ~(EFI_PAGE_SIZE - 1)); - Pte[BitFieldRead32 ((UINT32)PageIndex, 21, 29)] = (UINT64)Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - // - // Fill in Page Table Entries - // - Pte = (UINT64*)Pages; - PageAddress = PageIndex; - for (Index = 0; Index < EFI_PAGE_SIZE / sizeof (*Pte); Index++) { - if (PageAddress == GuardPage) { - // - // Mark the guard page as non-present - // - Pte[Index] = PageAddress | mAddressEncMask; - GuardPage += mSmmStackSize; - if (GuardPage > mSmmStackArrayEnd) { - GuardPage = 0; - } - } else { - Pte[Index] = PageAddress | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - } - PageAddress+= EFI_PAGE_SIZE; - } - Pages += EFI_PAGE_SIZE; - } - } - - return (UINT32)(UINTN)PageTable; -} - -/** - Schedule a procedure to run on the specified CPU. - - @param[in] Procedure The address of the procedure to run - @param[in] CpuIndex Target CPU Index - @param[in, out] ProcArguments The parameter to pass to the procedure - @param[in] BlockingMode Startup AP in blocking mode or not - - @retval EFI_INVALID_PARAMETER CpuNumber not valid - @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy - @retval EFI_SUCCESS The procedure has been successfully scheduled - -**/ -EFI_STATUS -InternalSmmStartupThisAp ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN CpuIndex, - IN OUT VOID *ProcArguments OPTIONAL, - IN BOOLEAN BlockingMode - ) -{ - if (CpuIndex >= gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus) { - DEBUG((DEBUG_ERROR, "CpuIndex(%d) >= gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus(%d)\n", CpuIndex, gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus)); - return EFI_INVALID_PARAMETER; - } - if (CpuIndex == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { - DEBUG((DEBUG_ERROR, "CpuIndex(%d) == gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu\n", CpuIndex)); - return EFI_INVALID_PARAMETER; - } - if (!(*(mSmmMpSyncData->CpuData[CpuIndex].Present))) { - if (mSmmMpSyncData->EffectiveSyncMode == SmmCpuSyncModeTradition) { - DEBUG((DEBUG_ERROR, "!mSmmMpSyncData->CpuData[%d].Present\n", CpuIndex)); - } - return EFI_INVALID_PARAMETER; - } - if (gSmmCpuPrivate->Operation[CpuIndex] == SmmCpuRemove) { - if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { - DEBUG((DEBUG_ERROR, "gSmmCpuPrivate->Operation[%d] == SmmCpuRemove\n", CpuIndex)); - } - return EFI_INVALID_PARAMETER; - } - - if (BlockingMode) { - AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - } else { - if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy)) { - DEBUG((DEBUG_ERROR, "mSmmMpSyncData->CpuData[%d].Busy\n", CpuIndex)); - return EFI_INVALID_PARAMETER; - } - } - - mSmmMpSyncData->CpuData[CpuIndex].Procedure = Procedure; - mSmmMpSyncData->CpuData[CpuIndex].Parameter = ProcArguments; - ReleaseSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run); - - if (BlockingMode) { - AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - ReleaseSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - } - return EFI_SUCCESS; -} - -/** - Schedule a procedure to run on the specified CPU in blocking mode. - - @param[in] Procedure The address of the procedure to run - @param[in] CpuIndex Target CPU Index - @param[in, out] ProcArguments The parameter to pass to the procedure - - @retval EFI_INVALID_PARAMETER CpuNumber not valid - @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy - @retval EFI_SUCCESS The procedure has been successfully scheduled - -**/ -EFI_STATUS -EFIAPI -SmmBlockingStartupThisAp ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN CpuIndex, - IN OUT VOID *ProcArguments OPTIONAL - ) -{ - return InternalSmmStartupThisAp(Procedure, CpuIndex, ProcArguments, TRUE); -} - -/** - Schedule a procedure to run on the specified CPU. - - @param Procedure The address of the procedure to run - @param CpuIndex Target CPU Index - @param ProcArguments The parameter to pass to the procedure - - @retval EFI_INVALID_PARAMETER CpuNumber not valid - @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy - @retval EFI_SUCCESS The procedure has been successfully scheduled - -**/ -EFI_STATUS -EFIAPI -SmmStartupThisAp ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN CpuIndex, - IN OUT VOID *ProcArguments OPTIONAL - ) -{ - return InternalSmmStartupThisAp(Procedure, CpuIndex, ProcArguments, FeaturePcdGet (PcdCpuSmmBlockStartupThisAp)); -} - -/** - This function sets DR6 & DR7 according to SMM save state, before running SMM C code. - They are useful when you want to enable hardware breakpoints in SMM without entry SMM mode. - - NOTE: It might not be appreciated in runtime since it might - conflict with OS debugging facilities. Turn them off in RELEASE. - - @param CpuIndex CPU Index - -**/ -VOID -EFIAPI -CpuSmmDebugEntry ( - IN UINTN CpuIndex - ) -{ - SMRAM_SAVE_STATE_MAP *CpuSaveState; - - if (FeaturePcdGet (PcdCpuSmmDebug)) { - ASSERT(CpuIndex < mMaxNumberOfCpus); - CpuSaveState = (SMRAM_SAVE_STATE_MAP *)gSmmCpuPrivate->CpuSaveState[CpuIndex]; - if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { - AsmWriteDr6 (CpuSaveState->x86._DR6); - AsmWriteDr7 (CpuSaveState->x86._DR7); - } else { - AsmWriteDr6 ((UINTN)CpuSaveState->x64._DR6); - AsmWriteDr7 ((UINTN)CpuSaveState->x64._DR7); - } - } -} - -/** - This function restores DR6 & DR7 to SMM save state. - - NOTE: It might not be appreciated in runtime since it might - conflict with OS debugging facilities. Turn them off in RELEASE. - - @param CpuIndex CPU Index - -**/ -VOID -EFIAPI -CpuSmmDebugExit ( - IN UINTN CpuIndex - ) -{ - SMRAM_SAVE_STATE_MAP *CpuSaveState; - - if (FeaturePcdGet (PcdCpuSmmDebug)) { - ASSERT(CpuIndex < mMaxNumberOfCpus); - CpuSaveState = (SMRAM_SAVE_STATE_MAP *)gSmmCpuPrivate->CpuSaveState[CpuIndex]; - if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { - CpuSaveState->x86._DR7 = (UINT32)AsmReadDr7 (); - CpuSaveState->x86._DR6 = (UINT32)AsmReadDr6 (); - } else { - CpuSaveState->x64._DR7 = AsmReadDr7 (); - CpuSaveState->x64._DR6 = AsmReadDr6 (); - } - } -} - -/** - C function for SMI entry, each processor comes here upon SMI trigger. - - @param CpuIndex CPU Index - -**/ -VOID -EFIAPI -SmiRendezvous ( - IN UINTN CpuIndex - ) -{ - EFI_STATUS Status; - BOOLEAN ValidSmi; - BOOLEAN IsBsp; - BOOLEAN BspInProgress; - UINTN Index; - UINTN Cr2; - - ASSERT(CpuIndex < mMaxNumberOfCpus); - - // - // Save Cr2 because Page Fault exception in SMM may override its value - // - Cr2 = AsmReadCr2 (); - - // - // Perform CPU specific entry hooks - // - SmmCpuFeaturesRendezvousEntry (CpuIndex); - - // - // Determine if this is a valid SMI - // - ValidSmi = PlatformValidSmi(); - - // - // Determine if BSP has been already in progress. Note this must be checked after - // ValidSmi because BSP may clear a valid SMI source after checking in. - // - BspInProgress = *mSmmMpSyncData->InsideSmm; - - if (!BspInProgress && !ValidSmi) { - // - // If we reach here, it means when we sampled the ValidSmi flag, SMI status had not - // been cleared by BSP in a new SMI run (so we have a truly invalid SMI), or SMI - // status had been cleared by BSP and an existing SMI run has almost ended. (Note - // we sampled ValidSmi flag BEFORE judging BSP-in-progress status.) In both cases, there - // is nothing we need to do. - // - goto Exit; - } else { - // - // Signal presence of this processor - // - if (ReleaseSemaphore (mSmmMpSyncData->Counter) == 0) { - // - // BSP has already ended the synchronization, so QUIT!!! - // - - // - // Wait for BSP's signal to finish SMI - // - while (*mSmmMpSyncData->AllCpusInSync) { - CpuPause (); - } - goto Exit; - } else { - - // - // The BUSY lock is initialized to Released state. - // This needs to be done early enough to be ready for BSP's SmmStartupThisAp() call. - // E.g., with Relaxed AP flow, SmmStartupThisAp() may be called immediately - // after AP's present flag is detected. - // - InitializeSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - } - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - ActivateSmmProfile (CpuIndex); - } - - if (BspInProgress) { - // - // BSP has been elected. Follow AP path, regardless of ValidSmi flag - // as BSP may have cleared the SMI status - // - APHandler (CpuIndex, ValidSmi, mSmmMpSyncData->EffectiveSyncMode); - } else { - // - // We have a valid SMI - // - - // - // Elect BSP - // - IsBsp = FALSE; - if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { - if (!mSmmMpSyncData->SwitchBsp || mSmmMpSyncData->CandidateBsp[CpuIndex]) { - // - // Call platform hook to do BSP election - // - Status = PlatformSmmBspElection (&IsBsp); - if (EFI_SUCCESS == Status) { - // - // Platform hook determines successfully - // - if (IsBsp) { - mSmmMpSyncData->BspIndex = (UINT32)CpuIndex; - } - } else { - // - // Platform hook fails to determine, use default BSP election method - // - InterlockedCompareExchange32 ( - (UINT32*)&mSmmMpSyncData->BspIndex, - (UINT32)-1, - (UINT32)CpuIndex - ); - } - } - } - - // - // "mSmmMpSyncData->BspIndex == CpuIndex" means this is the BSP - // - if (mSmmMpSyncData->BspIndex == CpuIndex) { - - // - // Clear last request for SwitchBsp. - // - if (mSmmMpSyncData->SwitchBsp) { - mSmmMpSyncData->SwitchBsp = FALSE; - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - mSmmMpSyncData->CandidateBsp[Index] = FALSE; - } - } - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - SmmProfileRecordSmiNum (); - } - - // - // BSP Handler is always called with a ValidSmi == TRUE - // - BSPHandler (CpuIndex, mSmmMpSyncData->EffectiveSyncMode); - } else { - APHandler (CpuIndex, ValidSmi, mSmmMpSyncData->EffectiveSyncMode); - } - } - - ASSERT (*mSmmMpSyncData->CpuData[CpuIndex].Run == 0); - - // - // Wait for BSP's signal to exit SMI - // - while (*mSmmMpSyncData->AllCpusInSync) { - CpuPause (); - } - } - -Exit: - SmmCpuFeaturesRendezvousExit (CpuIndex); - // - // Restore Cr2 - // - AsmWriteCr2 (Cr2); -} - -/** - Allocate buffer for all semaphores and spin locks. - -**/ -VOID -InitializeSmmCpuSemaphores ( - VOID - ) -{ - UINTN ProcessorCount; - UINTN TotalSize; - UINTN GlobalSemaphoresSize; - UINTN CpuSemaphoresSize; - UINTN MsrSemahporeSize; - UINTN SemaphoreSize; - UINTN Pages; - UINTN *SemaphoreBlock; - UINTN SemaphoreAddr; - - SemaphoreSize = GetSpinLockProperties (); - ProcessorCount = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - GlobalSemaphoresSize = (sizeof (SMM_CPU_SEMAPHORE_GLOBAL) / sizeof (VOID *)) * SemaphoreSize; - CpuSemaphoresSize = (sizeof (SMM_CPU_SEMAPHORE_CPU) / sizeof (VOID *)) * ProcessorCount * SemaphoreSize; - MsrSemahporeSize = MSR_SPIN_LOCK_INIT_NUM * SemaphoreSize; - TotalSize = GlobalSemaphoresSize + CpuSemaphoresSize + MsrSemahporeSize; - DEBUG((EFI_D_INFO, "One Semaphore Size = 0x%x\n", SemaphoreSize)); - DEBUG((EFI_D_INFO, "Total Semaphores Size = 0x%x\n", TotalSize)); - Pages = EFI_SIZE_TO_PAGES (TotalSize); - SemaphoreBlock = AllocatePages (Pages); - ASSERT (SemaphoreBlock != NULL); - ZeroMem (SemaphoreBlock, TotalSize); - - SemaphoreAddr = (UINTN)SemaphoreBlock; - mSmmCpuSemaphores.SemaphoreGlobal.Counter = (UINT32 *)SemaphoreAddr; - SemaphoreAddr += SemaphoreSize; - mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm = (BOOLEAN *)SemaphoreAddr; - SemaphoreAddr += SemaphoreSize; - mSmmCpuSemaphores.SemaphoreGlobal.AllCpusInSync = (BOOLEAN *)SemaphoreAddr; - SemaphoreAddr += SemaphoreSize; - mSmmCpuSemaphores.SemaphoreGlobal.PFLock = (SPIN_LOCK *)SemaphoreAddr; - SemaphoreAddr += SemaphoreSize; - mSmmCpuSemaphores.SemaphoreGlobal.CodeAccessCheckLock - = (SPIN_LOCK *)SemaphoreAddr; - SemaphoreAddr += SemaphoreSize; - mSmmCpuSemaphores.SemaphoreGlobal.MemoryMappedLock - = (SPIN_LOCK *)SemaphoreAddr; - - SemaphoreAddr = (UINTN)SemaphoreBlock + GlobalSemaphoresSize; - mSmmCpuSemaphores.SemaphoreCpu.Busy = (SPIN_LOCK *)SemaphoreAddr; - SemaphoreAddr += ProcessorCount * SemaphoreSize; - mSmmCpuSemaphores.SemaphoreCpu.Run = (UINT32 *)SemaphoreAddr; - SemaphoreAddr += ProcessorCount * SemaphoreSize; - mSmmCpuSemaphores.SemaphoreCpu.Present = (BOOLEAN *)SemaphoreAddr; - - SemaphoreAddr = (UINTN)SemaphoreBlock + GlobalSemaphoresSize + CpuSemaphoresSize; - mSmmCpuSemaphores.SemaphoreMsr.Msr = (SPIN_LOCK *)SemaphoreAddr; - mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter = - ((UINTN)SemaphoreBlock + Pages * SIZE_4KB - SemaphoreAddr) / SemaphoreSize; - ASSERT (mSmmCpuSemaphores.SemaphoreMsr.AvailableCounter >= MSR_SPIN_LOCK_INIT_NUM); - - mPFLock = mSmmCpuSemaphores.SemaphoreGlobal.PFLock; - mConfigSmmCodeAccessCheckLock = mSmmCpuSemaphores.SemaphoreGlobal.CodeAccessCheckLock; - mMemoryMappedLock = mSmmCpuSemaphores.SemaphoreGlobal.MemoryMappedLock; - - mSemaphoreSize = SemaphoreSize; -} - -/** - Initialize un-cacheable data. - -**/ -VOID -EFIAPI -InitializeMpSyncData ( - VOID - ) -{ - UINTN CpuIndex; - - if (mSmmMpSyncData != NULL) { - // - // mSmmMpSyncDataSize includes one structure of SMM_DISPATCHER_MP_SYNC_DATA, one - // CpuData array of SMM_CPU_DATA_BLOCK and one CandidateBsp array of BOOLEAN. - // - ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize); - mSmmMpSyncData->CpuData = (SMM_CPU_DATA_BLOCK *)((UINT8 *)mSmmMpSyncData + sizeof (SMM_DISPATCHER_MP_SYNC_DATA)); - mSmmMpSyncData->CandidateBsp = (BOOLEAN *)(mSmmMpSyncData->CpuData + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus); - if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) { - // - // Enable BSP election by setting BspIndex to -1 - // - mSmmMpSyncData->BspIndex = (UINT32)-1; - } - mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode; - - mSmmMpSyncData->Counter = mSmmCpuSemaphores.SemaphoreGlobal.Counter; - mSmmMpSyncData->InsideSmm = mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm; - mSmmMpSyncData->AllCpusInSync = mSmmCpuSemaphores.SemaphoreGlobal.AllCpusInSync; - ASSERT (mSmmMpSyncData->Counter != NULL && mSmmMpSyncData->InsideSmm != NULL && - mSmmMpSyncData->AllCpusInSync != NULL); - *mSmmMpSyncData->Counter = 0; - *mSmmMpSyncData->InsideSmm = FALSE; - *mSmmMpSyncData->AllCpusInSync = FALSE; - - for (CpuIndex = 0; CpuIndex < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex ++) { - mSmmMpSyncData->CpuData[CpuIndex].Busy = - (SPIN_LOCK *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Busy + mSemaphoreSize * CpuIndex); - mSmmMpSyncData->CpuData[CpuIndex].Run = - (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + mSemaphoreSize * CpuIndex); - mSmmMpSyncData->CpuData[CpuIndex].Present = - (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + mSemaphoreSize * CpuIndex); - *(mSmmMpSyncData->CpuData[CpuIndex].Busy) = 0; - *(mSmmMpSyncData->CpuData[CpuIndex].Run) = 0; - *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE; - } - } -} - -/** - Initialize global data for MP synchronization. - - @param Stacks Base address of SMI stack buffer for all processors. - @param StackSize Stack size for each processor in SMM. - -**/ -UINT32 -InitializeMpServiceData ( - IN VOID *Stacks, - IN UINTN StackSize - ) -{ - UINT32 Cr3; - UINTN Index; - UINT8 *GdtTssTables; - UINTN GdtTableStepSize; - - // - // Allocate memory for all locks and semaphores - // - InitializeSmmCpuSemaphores (); - - // - // Initialize mSmmMpSyncData - // - mSmmMpSyncDataSize = sizeof (SMM_DISPATCHER_MP_SYNC_DATA) + - (sizeof (SMM_CPU_DATA_BLOCK) + sizeof (BOOLEAN)) * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - mSmmMpSyncData = (SMM_DISPATCHER_MP_SYNC_DATA*) AllocatePages (EFI_SIZE_TO_PAGES (mSmmMpSyncDataSize)); - ASSERT (mSmmMpSyncData != NULL); - mCpuSmmSyncMode = (SMM_CPU_SYNC_MODE)PcdGet8 (PcdCpuSmmSyncMode); - InitializeMpSyncData (); - - // - // Initialize physical address mask - // NOTE: Physical memory above virtual address limit is not supported !!! - // - AsmCpuid (0x80000008, (UINT32*)&Index, NULL, NULL, NULL); - gPhyMask = LShiftU64 (1, (UINT8)Index) - 1; - gPhyMask &= (1ull << 48) - EFI_PAGE_SIZE; - - // - // Create page tables - // - Cr3 = SmmInitPageTable (); - - GdtTssTables = InitGdt (Cr3, &GdtTableStepSize); - - // - // Install SMI handler for each CPU - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - InstallSmiHandler ( - Index, - (UINT32)mCpuHotPlugData.SmBase[Index], - (VOID*)((UINTN)Stacks + (StackSize * Index)), - StackSize, - (UINTN)(GdtTssTables + GdtTableStepSize * Index), - gcSmiGdtr.Limit + 1, - gcSmiIdtr.Base, - gcSmiIdtr.Limit + 1, - Cr3 - ); - } - - // - // Record current MTRR settings - // - ZeroMem (&gSmiMtrrs, sizeof (gSmiMtrrs)); - MtrrGetAllMtrrs (&gSmiMtrrs); - - return Cr3; -} - -/** - - Register the SMM Foundation entry point. - - @param This Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance - @param SmmEntryPoint SMM Foundation EntryPoint - - @retval EFI_SUCCESS Successfully to register SMM foundation entry point - -**/ -EFI_STATUS -EFIAPI -RegisterSmmEntry ( - IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This, - IN EFI_SMM_ENTRY_POINT SmmEntryPoint - ) -{ - // - // Record SMM Foundation EntryPoint, later invoke it on SMI entry vector. - // - gSmmCpuPrivate->SmmCoreEntry = SmmEntryPoint; - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c deleted file mode 100755 index 2cb0bbcff6..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ /dev/null @@ -1,1340 +0,0 @@ -/** @file -Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -// -// SMM CPU Private Data structure that contains SMM Configuration Protocol -// along its supporting fields. -// -SMM_CPU_PRIVATE_DATA mSmmCpuPrivateData = { - SMM_CPU_PRIVATE_DATA_SIGNATURE, // Signature - NULL, // SmmCpuHandle - NULL, // Pointer to ProcessorInfo array - NULL, // Pointer to Operation array - NULL, // Pointer to CpuSaveStateSize array - NULL, // Pointer to CpuSaveState array - { {0} }, // SmmReservedSmramRegion - { - SmmStartupThisAp, // SmmCoreEntryContext.SmmStartupThisAp - 0, // SmmCoreEntryContext.CurrentlyExecutingCpu - 0, // SmmCoreEntryContext.NumberOfCpus - NULL, // SmmCoreEntryContext.CpuSaveStateSize - NULL // SmmCoreEntryContext.CpuSaveState - }, - NULL, // SmmCoreEntry - { - mSmmCpuPrivateData.SmmReservedSmramRegion, // SmmConfiguration.SmramReservedRegions - RegisterSmmEntry // SmmConfiguration.RegisterSmmEntry - }, -}; - -CPU_HOT_PLUG_DATA mCpuHotPlugData = { - CPU_HOT_PLUG_DATA_REVISION_1, // Revision - 0, // Array Length of SmBase and APIC ID - NULL, // Pointer to APIC ID array - NULL, // Pointer to SMBASE array - 0, // Reserved - 0, // SmrrBase - 0 // SmrrSize -}; - -// -// Global pointer used to access mSmmCpuPrivateData from outside and inside SMM -// -SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate = &mSmmCpuPrivateData; - -// -// SMM Relocation variables -// -volatile BOOLEAN *mRebased; -volatile BOOLEAN mIsBsp; - -/// -/// Handle for the SMM CPU Protocol -/// -EFI_HANDLE mSmmCpuHandle = NULL; - -/// -/// SMM CPU Protocol instance -/// -EFI_SMM_CPU_PROTOCOL mSmmCpu = { - SmmReadSaveState, - SmmWriteSaveState -}; - -EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER]; - -// -// SMM stack information -// -UINTN mSmmStackArrayBase; -UINTN mSmmStackArrayEnd; -UINTN mSmmStackSize; - -UINTN mMaxNumberOfCpus = 1; -UINTN mNumberOfCpus = 1; - -// -// SMM ready to lock flag -// -BOOLEAN mSmmReadyToLock = FALSE; - -// -// Global used to cache PCD for SMM Code Access Check enable -// -BOOLEAN mSmmCodeAccessCheckEnable = FALSE; - -// -// Global copy of the PcdPteMemoryEncryptionAddressOrMask -// -UINT64 mAddressEncMask = 0; - -// -// Spin lock used to serialize setting of SMM Code Access Check feature -// -SPIN_LOCK *mConfigSmmCodeAccessCheckLock = NULL; - -// -// Saved SMM ranges information -// -EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; -UINTN mSmmCpuSmramRangeCount; - -/** - Initialize IDT to setup exception handlers for SMM. - -**/ -VOID -InitializeSmmIdt ( - VOID - ) -{ - EFI_STATUS Status; - BOOLEAN InterruptState; - IA32_DESCRIPTOR DxeIdtr; - - // - // There are 32 (not 255) entries in it since only processor - // generated exceptions will be handled. - // - gcSmiIdtr.Limit = (sizeof(IA32_IDT_GATE_DESCRIPTOR) * 32) - 1; - // - // Allocate page aligned IDT, because it might be set as read only. - // - gcSmiIdtr.Base = (UINTN)AllocateCodePages (EFI_SIZE_TO_PAGES(gcSmiIdtr.Limit + 1)); - ASSERT (gcSmiIdtr.Base != 0); - ZeroMem ((VOID *)gcSmiIdtr.Base, gcSmiIdtr.Limit + 1); - - // - // Disable Interrupt and save DXE IDT table - // - InterruptState = SaveAndDisableInterrupts (); - AsmReadIdtr (&DxeIdtr); - // - // Load SMM temporary IDT table - // - AsmWriteIdtr (&gcSmiIdtr); - // - // Setup SMM default exception handlers, SMM IDT table - // will be updated and saved in gcSmiIdtr - // - Status = InitializeCpuExceptionHandlers (NULL); - ASSERT_EFI_ERROR (Status); - // - // Restore DXE IDT table and CPU interrupt - // - AsmWriteIdtr ((IA32_DESCRIPTOR *) &DxeIdtr); - SetInterruptState (InterruptState); -} - -/** - Search module name by input IP address and output it. - - @param CallerIpAddress Caller instruction pointer. - -**/ -VOID -DumpModuleInfoByIp ( - IN UINTN CallerIpAddress - ) -{ - UINTN Pe32Data; - VOID *PdbPointer; - - // - // Find Image Base - // - Pe32Data = PeCoffSerachImageBase (CallerIpAddress); - if (Pe32Data != 0) { - DEBUG ((DEBUG_ERROR, "It is invoked from the instruction before IP(0x%p)", (VOID *) CallerIpAddress)); - PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *) Pe32Data); - if (PdbPointer != NULL) { - DEBUG ((DEBUG_ERROR, " in module (%a)\n", PdbPointer)); - } - } -} - -/** - Read information from the CPU save state. - - @param This EFI_SMM_CPU_PROTOCOL instance - @param Width The number of bytes to read from the CPU save state. - @param Register Specifies the CPU register to read form the save state. - @param CpuIndex Specifies the zero-based index of the CPU save state. - @param Buffer Upon return, this holds the CPU register value read from the save state. - - @retval EFI_SUCCESS The register was read from Save State - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor - @retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -EFI_STATUS -EFIAPI -SmmReadSaveState ( - IN CONST EFI_SMM_CPU_PROTOCOL *This, - IN UINTN Width, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN CpuIndex, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - - // - // Retrieve pointer to the specified CPU's SMM Save State buffer - // - if ((CpuIndex >= gSmst->NumberOfCpus) || (Buffer == NULL)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check for special EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID) { - // - // The pseudo-register only supports the 64-bit size specified by Width. - // - if (Width != sizeof (UINT64)) { - return EFI_INVALID_PARAMETER; - } - // - // If the processor is in SMM at the time the SMI occurred, - // the pseudo register value for EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID is returned in Buffer. - // Otherwise, EFI_NOT_FOUND is returned. - // - if (*(mSmmMpSyncData->CpuData[CpuIndex].Present)) { - *(UINT64 *)Buffer = gSmmCpuPrivate->ProcessorInfo[CpuIndex].ProcessorId; - return EFI_SUCCESS; - } else { - return EFI_NOT_FOUND; - } - } - - if (!(*(mSmmMpSyncData->CpuData[CpuIndex].Present))) { - return EFI_INVALID_PARAMETER; - } - - Status = SmmCpuFeaturesReadSaveStateRegister (CpuIndex, Register, Width, Buffer); - if (Status == EFI_UNSUPPORTED) { - Status = ReadSaveStateRegister (CpuIndex, Register, Width, Buffer); - } - return Status; -} - -/** - Write data to the CPU save state. - - @param This EFI_SMM_CPU_PROTOCOL instance - @param Width The number of bytes to read from the CPU save state. - @param Register Specifies the CPU register to write to the save state. - @param CpuIndex Specifies the zero-based index of the CPU save state - @param Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written from Save State - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor - @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct - -**/ -EFI_STATUS -EFIAPI -SmmWriteSaveState ( - IN CONST EFI_SMM_CPU_PROTOCOL *This, - IN UINTN Width, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN CpuIndex, - IN CONST VOID *Buffer - ) -{ - EFI_STATUS Status; - - // - // Retrieve pointer to the specified CPU's SMM Save State buffer - // - if ((CpuIndex >= gSmst->NumberOfCpus) || (Buffer == NULL)) { - return EFI_INVALID_PARAMETER; - } - - // - // Writes to EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID are ignored - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID) { - return EFI_SUCCESS; - } - - if (!mSmmMpSyncData->CpuData[CpuIndex].Present) { - return EFI_INVALID_PARAMETER; - } - - Status = SmmCpuFeaturesWriteSaveStateRegister (CpuIndex, Register, Width, Buffer); - if (Status == EFI_UNSUPPORTED) { - Status = WriteSaveStateRegister (CpuIndex, Register, Width, Buffer); - } - return Status; -} - - -/** - C function for SMI handler. To change all processor's SMMBase Register. - -**/ -VOID -EFIAPI -SmmInitHandler ( - VOID - ) -{ - UINT32 ApicId; - UINTN Index; - - // - // Update SMM IDT entries' code segment and load IDT - // - AsmWriteIdtr (&gcSmiIdtr); - ApicId = GetApicId (); - - ASSERT (mNumberOfCpus <= mMaxNumberOfCpus); - - for (Index = 0; Index < mNumberOfCpus; Index++) { - if (ApicId == (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId) { - // - // Initialize SMM specific features on the currently executing CPU - // - SmmCpuFeaturesInitializeProcessor ( - Index, - mIsBsp, - gSmmCpuPrivate->ProcessorInfo, - &mCpuHotPlugData - ); - - if (!mSmmS3Flag) { - // - // Check XD and BTS features on each processor on normal boot - // - CheckFeatureSupported (); - } - - if (mIsBsp) { - // - // BSP rebase is already done above. - // Initialize private data during S3 resume - // - InitializeMpSyncData (); - } - - // - // Hook return after RSM to set SMM re-based flag - // - SemaphoreHook (Index, &mRebased[Index]); - - return; - } - } - ASSERT (FALSE); -} - -/** - Relocate SmmBases for each processor. - - Execute on first boot and all S3 resumes - -**/ -VOID -EFIAPI -SmmRelocateBases ( - VOID - ) -{ - UINT8 BakBuf[BACK_BUF_SIZE]; - SMRAM_SAVE_STATE_MAP BakBuf2; - SMRAM_SAVE_STATE_MAP *CpuStatePtr; - UINT8 *U8Ptr; - UINT32 ApicId; - UINTN Index; - UINTN BspIndex; - - // - // Make sure the reserved size is large enough for procedure SmmInitTemplate. - // - ASSERT (sizeof (BakBuf) >= gcSmmInitSize); - - // - // Patch ASM code template with current CR0, CR3, and CR4 values - // - gSmmCr0 = (UINT32)AsmReadCr0 (); - gSmmCr3 = (UINT32)AsmReadCr3 (); - gSmmCr4 = (UINT32)AsmReadCr4 (); - - // - // Patch GDTR for SMM base relocation - // - gcSmiInitGdtr.Base = gcSmiGdtr.Base; - gcSmiInitGdtr.Limit = gcSmiGdtr.Limit; - - U8Ptr = (UINT8*)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET); - CpuStatePtr = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); - - // - // Backup original contents at address 0x38000 - // - CopyMem (BakBuf, U8Ptr, sizeof (BakBuf)); - CopyMem (&BakBuf2, CpuStatePtr, sizeof (BakBuf2)); - - // - // Load image for relocation - // - CopyMem (U8Ptr, gcSmmInitTemplate, gcSmmInitSize); - - // - // Retrieve the local APIC ID of current processor - // - ApicId = GetApicId (); - - // - // Relocate SM bases for all APs - // This is APs' 1st SMI - rebase will be done here, and APs' default SMI handler will be overridden by gcSmmInitTemplate - // - mIsBsp = FALSE; - BspIndex = (UINTN)-1; - for (Index = 0; Index < mNumberOfCpus; Index++) { - mRebased[Index] = FALSE; - if (ApicId != (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId) { - SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId); - // - // Wait for this AP to finish its 1st SMI - // - while (!mRebased[Index]); - } else { - // - // BSP will be Relocated later - // - BspIndex = Index; - } - } - - // - // Relocate BSP's SMM base - // - ASSERT (BspIndex != (UINTN)-1); - mIsBsp = TRUE; - SendSmiIpi (ApicId); - // - // Wait for the BSP to finish its 1st SMI - // - while (!mRebased[BspIndex]); - - // - // Restore contents at address 0x38000 - // - CopyMem (CpuStatePtr, &BakBuf2, sizeof (BakBuf2)); - CopyMem (U8Ptr, BakBuf, sizeof (BakBuf)); -} - -/** - SMM Ready To Lock event notification handler. - - The CPU S3 data is copied to SMRAM for security and mSmmReadyToLock is set to - perform additional lock actions that must be performed from SMM on the next SMI. - - @param[in] Protocol Points to the protocol's unique identifier. - @param[in] Interface Points to the interface instance. - @param[in] Handle The handle on which the interface was installed. - - @retval EFI_SUCCESS Notification handler runs successfully. - **/ -EFI_STATUS -EFIAPI -SmmReadyToLockEventNotify ( - IN CONST EFI_GUID *Protocol, - IN VOID *Interface, - IN EFI_HANDLE Handle - ) -{ - GetAcpiCpuData (); - - // - // Cache a copy of UEFI memory map before we start profiling feature. - // - GetUefiMemoryMap (); - - // - // Set SMM ready to lock flag and return - // - mSmmReadyToLock = TRUE; - return EFI_SUCCESS; -} - -/** - The module Entry Point of the CPU SMM driver. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval Other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -PiCpuSmmEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - UINTN NumberOfEnabledProcessors; - UINTN Index; - VOID *Buffer; - UINTN BufferPages; - UINTN TileCodeSize; - UINTN TileDataSize; - UINTN TileSize; - UINT8 *Stacks; - VOID *Registration; - UINT32 RegEax; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - UINT32 Cr3; - - // - // Initialize Debug Agent to support source level debug in SMM code - // - InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, NULL, NULL); - - // - // Report the start of CPU SMM initialization. - // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_SMM_INIT - ); - - // - // Fix segment address of the long-mode-switch jump - // - if (sizeof (UINTN) == sizeof (UINT64)) { - gSmmJmpAddr.Segment = LONG_MODE_CODE_SEGMENT; - } - - // - // Find out SMRR Base and SMRR Size - // - FindSmramInfo (&mCpuHotPlugData.SmrrBase, &mCpuHotPlugData.SmrrSize); - - // - // Get MP Services Protocol - // - Status = SystemTable->BootServices->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpServices); - ASSERT_EFI_ERROR (Status); - - // - // Use MP Services Protocol to retrieve the number of processors and number of enabled processors - // - Status = MpServices->GetNumberOfProcessors (MpServices, &mNumberOfCpus, &NumberOfEnabledProcessors); - ASSERT_EFI_ERROR (Status); - ASSERT (mNumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); - - // - // If support CPU hot plug, PcdCpuSmmEnableBspElection should be set to TRUE. - // A constant BSP index makes no sense because it may be hot removed. - // - DEBUG_CODE ( - if (FeaturePcdGet (PcdCpuHotPlugSupport)) { - - ASSERT (FeaturePcdGet (PcdCpuSmmEnableBspElection)); - } - ); - - // - // Save the PcdCpuSmmCodeAccessCheckEnable value into a global variable. - // - mSmmCodeAccessCheckEnable = PcdGetBool (PcdCpuSmmCodeAccessCheckEnable); - DEBUG ((EFI_D_INFO, "PcdCpuSmmCodeAccessCheckEnable = %d\n", mSmmCodeAccessCheckEnable)); - - // - // Save the PcdPteMemoryEncryptionAddressOrMask value into a global variable. - // Make sure AddressEncMask is contained to smallest supported address field. - // - mAddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; - DEBUG ((EFI_D_INFO, "mAddressEncMask = 0x%lx\n", mAddressEncMask)); - - // - // If support CPU hot plug, we need to allocate resources for possibly hot-added processors - // - if (FeaturePcdGet (PcdCpuHotPlugSupport)) { - mMaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); - } else { - mMaxNumberOfCpus = mNumberOfCpus; - } - gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus = mMaxNumberOfCpus; - - // - // The CPU save state and code for the SMI entry point are tiled within an SMRAM - // allocated buffer. The minimum size of this buffer for a uniprocessor system - // is 32 KB, because the entry point is SMBASE + 32KB, and CPU save state area - // just below SMBASE + 64KB. If more than one CPU is present in the platform, - // then the SMI entry point and the CPU save state areas can be tiles to minimize - // the total amount SMRAM required for all the CPUs. The tile size can be computed - // by adding the // CPU save state size, any extra CPU specific context, and - // the size of code that must be placed at the SMI entry point to transfer - // control to a C function in the native SMM execution mode. This size is - // rounded up to the nearest power of 2 to give the tile size for a each CPU. - // The total amount of memory required is the maximum number of CPUs that - // platform supports times the tile size. The picture below shows the tiling, - // where m is the number of tiles that fit in 32KB. - // - // +-----------------------------+ <-- 2^n offset from Base of allocated buffer - // | CPU m+1 Save State | - // +-----------------------------+ - // | CPU m+1 Extra Data | - // +-----------------------------+ - // | Padding | - // +-----------------------------+ - // | CPU 2m SMI Entry | - // +#############################+ <-- Base of allocated buffer + 64 KB - // | CPU m-1 Save State | - // +-----------------------------+ - // | CPU m-1 Extra Data | - // +-----------------------------+ - // | Padding | - // +-----------------------------+ - // | CPU 2m-1 SMI Entry | - // +=============================+ <-- 2^n offset from Base of allocated buffer - // | . . . . . . . . . . . . | - // +=============================+ <-- 2^n offset from Base of allocated buffer - // | CPU 2 Save State | - // +-----------------------------+ - // | CPU 2 Extra Data | - // +-----------------------------+ - // | Padding | - // +-----------------------------+ - // | CPU m+1 SMI Entry | - // +=============================+ <-- Base of allocated buffer + 32 KB - // | CPU 1 Save State | - // +-----------------------------+ - // | CPU 1 Extra Data | - // +-----------------------------+ - // | Padding | - // +-----------------------------+ - // | CPU m SMI Entry | - // +#############################+ <-- Base of allocated buffer + 32 KB == CPU 0 SMBASE + 64 KB - // | CPU 0 Save State | - // +-----------------------------+ - // | CPU 0 Extra Data | - // +-----------------------------+ - // | Padding | - // +-----------------------------+ - // | CPU m-1 SMI Entry | - // +=============================+ <-- 2^n offset from Base of allocated buffer - // | . . . . . . . . . . . . | - // +=============================+ <-- 2^n offset from Base of allocated buffer - // | Padding | - // +-----------------------------+ - // | CPU 1 SMI Entry | - // +=============================+ <-- 2^n offset from Base of allocated buffer - // | Padding | - // +-----------------------------+ - // | CPU 0 SMI Entry | - // +#############################+ <-- Base of allocated buffer == CPU 0 SMBASE + 32 KB - // - - // - // Retrieve CPU Family - // - AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, NULL); - FamilyId = (RegEax >> 8) & 0xf; - ModelId = (RegEax >> 4) & 0xf; - if (FamilyId == 0x06 || FamilyId == 0x0f) { - ModelId = ModelId | ((RegEax >> 12) & 0xf0); - } - - RegEdx = 0; - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax >= CPUID_EXTENDED_CPU_SIG) { - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - } - // - // Determine the mode of the CPU at the time an SMI occurs - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 34.4.1.1 - // - mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT; - if ((RegEdx & BIT29) != 0) { - mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; - } - if (FamilyId == 0x06) { - if (ModelId == 0x17 || ModelId == 0x0f || ModelId == 0x1c) { - mSmmSaveStateRegisterLma = EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; - } - } - - // - // Compute tile size of buffer required to hold the CPU SMRAM Save State Map, extra CPU - // specific context start starts at SMBASE + SMM_PSD_OFFSET, and the SMI entry point. - // This size is rounded up to nearest power of 2. - // - TileCodeSize = GetSmiHandlerSize (); - TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB); - TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP); - TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB); - TileSize = TileDataSize + TileCodeSize - 1; - TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize); - DEBUG ((EFI_D_INFO, "SMRAM TileSize = 0x%08x (0x%08x, 0x%08x)\n", TileSize, TileCodeSize, TileDataSize)); - - // - // If the TileSize is larger than space available for the SMI Handler of - // CPU[i], the extra CPU specific context of CPU[i+1], and the SMRAM Save - // State Map of CPU[i+1], then ASSERT(). If this ASSERT() is triggered, then - // the SMI Handler size must be reduced or the size of the extra CPU specific - // context must be reduced. - // - ASSERT (TileSize <= (SMRAM_SAVE_STATE_MAP_OFFSET + sizeof (SMRAM_SAVE_STATE_MAP) - SMM_HANDLER_OFFSET)); - - // - // Allocate buffer for all of the tiles. - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 34.11 SMBASE Relocation - // For Pentium and Intel486 processors, the SMBASE values must be - // aligned on a 32-KByte boundary or the processor will enter shutdown - // state during the execution of a RSM instruction. - // - // Intel486 processors: FamilyId is 4 - // Pentium processors : FamilyId is 5 - // - BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1)); - if ((FamilyId == 4) || (FamilyId == 5)) { - Buffer = AllocateAlignedCodePages (BufferPages, SIZE_32KB); - } else { - Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); - } - ASSERT (Buffer != NULL); - DEBUG ((EFI_D_INFO, "SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE(BufferPages))); - - // - // Allocate buffer for pointers to array in SMM_CPU_PRIVATE_DATA. - // - gSmmCpuPrivate->ProcessorInfo = (EFI_PROCESSOR_INFORMATION *)AllocatePool (sizeof (EFI_PROCESSOR_INFORMATION) * mMaxNumberOfCpus); - ASSERT (gSmmCpuPrivate->ProcessorInfo != NULL); - - gSmmCpuPrivate->Operation = (SMM_CPU_OPERATION *)AllocatePool (sizeof (SMM_CPU_OPERATION) * mMaxNumberOfCpus); - ASSERT (gSmmCpuPrivate->Operation != NULL); - - gSmmCpuPrivate->CpuSaveStateSize = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); - ASSERT (gSmmCpuPrivate->CpuSaveStateSize != NULL); - - gSmmCpuPrivate->CpuSaveState = (VOID **)AllocatePool (sizeof (VOID *) * mMaxNumberOfCpus); - ASSERT (gSmmCpuPrivate->CpuSaveState != NULL); - - mSmmCpuPrivateData.SmmCoreEntryContext.CpuSaveStateSize = gSmmCpuPrivate->CpuSaveStateSize; - mSmmCpuPrivateData.SmmCoreEntryContext.CpuSaveState = gSmmCpuPrivate->CpuSaveState; - - // - // Allocate buffer for pointers to array in CPU_HOT_PLUG_DATA. - // - mCpuHotPlugData.ApicId = (UINT64 *)AllocatePool (sizeof (UINT64) * mMaxNumberOfCpus); - ASSERT (mCpuHotPlugData.ApicId != NULL); - mCpuHotPlugData.SmBase = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); - ASSERT (mCpuHotPlugData.SmBase != NULL); - mCpuHotPlugData.ArrayLength = (UINT32)mMaxNumberOfCpus; - - // - // Retrieve APIC ID of each enabled processor from the MP Services protocol. - // Also compute the SMBASE address, CPU Save State address, and CPU Save state - // size for each CPU in the platform - // - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - mCpuHotPlugData.SmBase[Index] = (UINTN)Buffer + Index * TileSize - SMM_HANDLER_OFFSET; - gSmmCpuPrivate->CpuSaveStateSize[Index] = sizeof(SMRAM_SAVE_STATE_MAP); - gSmmCpuPrivate->CpuSaveState[Index] = (VOID *)(mCpuHotPlugData.SmBase[Index] + SMRAM_SAVE_STATE_MAP_OFFSET); - gSmmCpuPrivate->Operation[Index] = SmmCpuNone; - - if (Index < mNumberOfCpus) { - Status = MpServices->GetProcessorInfo (MpServices, Index, &gSmmCpuPrivate->ProcessorInfo[Index]); - ASSERT_EFI_ERROR (Status); - mCpuHotPlugData.ApicId[Index] = gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId; - - DEBUG ((EFI_D_INFO, "CPU[%03x] APIC ID=%04x SMBASE=%08x SaveState=%08x Size=%08x\n", - Index, - (UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId, - mCpuHotPlugData.SmBase[Index], - gSmmCpuPrivate->CpuSaveState[Index], - gSmmCpuPrivate->CpuSaveStateSize[Index] - )); - } else { - gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId = INVALID_APIC_ID; - mCpuHotPlugData.ApicId[Index] = INVALID_APIC_ID; - } - } - - // - // Allocate SMI stacks for all processors. - // - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - // - // 2 more pages is allocated for each processor. - // one is guard page and the other is known good stack. - // - // +-------------------------------------------+-----+-------------------------------------------+ - // | Known Good Stack | Guard Page | SMM Stack | ... | Known Good Stack | Guard Page | SMM Stack | - // +-------------------------------------------+-----+-------------------------------------------+ - // | | | | - // |<-------------- Processor 0 -------------->| |<-------------- Processor n -------------->| - // - mSmmStackSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStackSize)) + 2); - Stacks = (UINT8 *) AllocatePages (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmStackSize)) + 2)); - ASSERT (Stacks != NULL); - mSmmStackArrayBase = (UINTN)Stacks; - mSmmStackArrayEnd = mSmmStackArrayBase + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * mSmmStackSize - 1; - } else { - mSmmStackSize = PcdGet32 (PcdCpuSmmStackSize); - Stacks = (UINT8 *) AllocatePages (EFI_SIZE_TO_PAGES (gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus * mSmmStackSize)); - ASSERT (Stacks != NULL); - } - - // - // Set SMI stack for SMM base relocation - // - gSmmInitStack = (UINTN) (Stacks + mSmmStackSize - sizeof (UINTN)); - - // - // Initialize IDT - // - InitializeSmmIdt (); - - // - // Relocate SMM Base addresses to the ones allocated from SMRAM - // - mRebased = (BOOLEAN *)AllocateZeroPool (sizeof (BOOLEAN) * mMaxNumberOfCpus); - ASSERT (mRebased != NULL); - SmmRelocateBases (); - - // - // Call hook for BSP to perform extra actions in normal mode after all - // SMM base addresses have been relocated on all CPUs - // - SmmCpuFeaturesSmmRelocationComplete (); - - DEBUG ((DEBUG_INFO, "mXdSupported - 0x%x\n", mXdSupported)); - - // - // SMM Time initialization - // - InitializeSmmTimer (); - - // - // Initialize MP globals - // - Cr3 = InitializeMpServiceData (Stacks, mSmmStackSize); - - // - // Fill in SMM Reserved Regions - // - gSmmCpuPrivate->SmmReservedSmramRegion[0].SmramReservedStart = 0; - gSmmCpuPrivate->SmmReservedSmramRegion[0].SmramReservedSize = 0; - - // - // Install the SMM Configuration Protocol onto a new handle on the handle database. - // The entire SMM Configuration Protocol is allocated from SMRAM, so only a pointer - // to an SMRAM address will be present in the handle database - // - Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces ( - &gSmmCpuPrivate->SmmCpuHandle, - &gEfiSmmConfigurationProtocolGuid, &gSmmCpuPrivate->SmmConfiguration, - NULL - ); - ASSERT_EFI_ERROR (Status); - - // - // Install the SMM CPU Protocol into SMM protocol database - // - Status = gSmst->SmmInstallProtocolInterface ( - &mSmmCpuHandle, - &gEfiSmmCpuProtocolGuid, - EFI_NATIVE_INTERFACE, - &mSmmCpu - ); - ASSERT_EFI_ERROR (Status); - - // - // Expose address of CPU Hot Plug Data structure if CPU hot plug is supported. - // - if (FeaturePcdGet (PcdCpuHotPlugSupport)) { - Status = PcdSet64S (PcdCpuHotPlugDataAddress, (UINT64)(UINTN)&mCpuHotPlugData); - ASSERT_EFI_ERROR (Status); - } - - // - // Initialize SMM CPU Services Support - // - Status = InitializeSmmCpuServices (mSmmCpuHandle); - ASSERT_EFI_ERROR (Status); - - // - // register SMM Ready To Lock Protocol notification - // - Status = gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, - SmmReadyToLockEventNotify, - &Registration - ); - ASSERT_EFI_ERROR (Status); - - // - // Initialize SMM Profile feature - // - InitSmmProfile (Cr3); - - GetAcpiS3EnableFlag (); - InitSmmS3ResumeState (Cr3); - - DEBUG ((EFI_D_INFO, "SMM CPU Module exit from SMRAM with EFI_SUCCESS\n")); - - return EFI_SUCCESS; -} - -/** - - Find out SMRAM information including SMRR base and SMRR size. - - @param SmrrBase SMRR base - @param SmrrSize SMRR size - -**/ -VOID -FindSmramInfo ( - OUT UINT32 *SmrrBase, - OUT UINT32 *SmrrSize - ) -{ - EFI_STATUS Status; - UINTN Size; - EFI_SMM_ACCESS2_PROTOCOL *SmmAccess; - EFI_SMRAM_DESCRIPTOR *CurrentSmramRange; - UINTN Index; - UINT64 MaxSize; - BOOLEAN Found; - - // - // Get SMM Access Protocol - // - Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess); - ASSERT_EFI_ERROR (Status); - - // - // Get SMRAM information - // - Size = 0; - Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - - mSmmCpuSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size); - ASSERT (mSmmCpuSmramRanges != NULL); - - Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmmCpuSmramRanges); - ASSERT_EFI_ERROR (Status); - - mSmmCpuSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR); - - // - // Find the largest SMRAM range between 1MB and 4GB that is at least 256K - 4K in size - // - CurrentSmramRange = NULL; - for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < mSmmCpuSmramRangeCount; Index++) { - // - // Skip any SMRAM region that is already allocated, needs testing, or needs ECC initialization - // - if ((mSmmCpuSmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) { - continue; - } - - if (mSmmCpuSmramRanges[Index].CpuStart >= BASE_1MB) { - if ((mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) <= SMRR_MAX_ADDRESS) { - if (mSmmCpuSmramRanges[Index].PhysicalSize >= MaxSize) { - MaxSize = mSmmCpuSmramRanges[Index].PhysicalSize; - CurrentSmramRange = &mSmmCpuSmramRanges[Index]; - } - } - } - } - - ASSERT (CurrentSmramRange != NULL); - - *SmrrBase = (UINT32)CurrentSmramRange->CpuStart; - *SmrrSize = (UINT32)CurrentSmramRange->PhysicalSize; - - do { - Found = FALSE; - for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { - if (mSmmCpuSmramRanges[Index].CpuStart < *SmrrBase && - *SmrrBase == (mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize)) { - *SmrrBase = (UINT32)mSmmCpuSmramRanges[Index].CpuStart; - *SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize); - Found = TRUE; - } else if ((*SmrrBase + *SmrrSize) == mSmmCpuSmramRanges[Index].CpuStart && mSmmCpuSmramRanges[Index].PhysicalSize > 0) { - *SmrrSize = (UINT32)(*SmrrSize + mSmmCpuSmramRanges[Index].PhysicalSize); - Found = TRUE; - } - } - } while (Found); - - DEBUG ((EFI_D_INFO, "SMRR Base: 0x%x, SMRR Size: 0x%x\n", *SmrrBase, *SmrrSize)); -} - -/** -Configure SMM Code Access Check feature on an AP. -SMM Feature Control MSR will be locked after configuration. - -@param[in,out] Buffer Pointer to private data buffer. -**/ -VOID -EFIAPI -ConfigSmmCodeAccessCheckOnCurrentProcessor ( - IN OUT VOID *Buffer - ) -{ - UINTN CpuIndex; - UINT64 SmmFeatureControlMsr; - UINT64 NewSmmFeatureControlMsr; - - // - // Retrieve the CPU Index from the context passed in - // - CpuIndex = *(UINTN *)Buffer; - - // - // Get the current SMM Feature Control MSR value - // - SmmFeatureControlMsr = SmmCpuFeaturesGetSmmRegister (CpuIndex, SmmRegFeatureControl); - - // - // Compute the new SMM Feature Control MSR value - // - NewSmmFeatureControlMsr = SmmFeatureControlMsr; - if (mSmmCodeAccessCheckEnable) { - NewSmmFeatureControlMsr |= SMM_CODE_CHK_EN_BIT; - if (FeaturePcdGet (PcdCpuSmmFeatureControlMsrLock)) { - NewSmmFeatureControlMsr |= SMM_FEATURE_CONTROL_LOCK_BIT; - } - } - - // - // Only set the SMM Feature Control MSR value if the new value is different than the current value - // - if (NewSmmFeatureControlMsr != SmmFeatureControlMsr) { - SmmCpuFeaturesSetSmmRegister (CpuIndex, SmmRegFeatureControl, NewSmmFeatureControlMsr); - } - - // - // Release the spin lock user to serialize the updates to the SMM Feature Control MSR - // - ReleaseSpinLock (mConfigSmmCodeAccessCheckLock); -} - -/** -Configure SMM Code Access Check feature for all processors. -SMM Feature Control MSR will be locked after configuration. -**/ -VOID -ConfigSmmCodeAccessCheck ( - VOID - ) -{ - UINTN Index; - EFI_STATUS Status; - - // - // Check to see if the Feature Control MSR is supported on this CPU - // - Index = gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu; - if (!SmmCpuFeaturesIsSmmRegisterSupported (Index, SmmRegFeatureControl)) { - mSmmCodeAccessCheckEnable = FALSE; - return; - } - - // - // Check to see if the CPU supports the SMM Code Access Check feature - // Do not access this MSR unless the CPU supports the SmmRegFeatureControl - // - if ((AsmReadMsr64 (EFI_MSR_SMM_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) == 0) { - mSmmCodeAccessCheckEnable = FALSE; - return; - } - - // - // Initialize the lock used to serialize the MSR programming in BSP and all APs - // - InitializeSpinLock (mConfigSmmCodeAccessCheckLock); - - // - // Acquire Config SMM Code Access Check spin lock. The BSP will release the - // spin lock when it is done executing ConfigSmmCodeAccessCheckOnCurrentProcessor(). - // - AcquireSpinLock (mConfigSmmCodeAccessCheckLock); - - // - // Enable SMM Code Access Check feature on the BSP. - // - ConfigSmmCodeAccessCheckOnCurrentProcessor (&Index); - - // - // Enable SMM Code Access Check feature for the APs. - // - for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { - if (Index != gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) { - - // - // Acquire Config SMM Code Access Check spin lock. The AP will release the - // spin lock when it is done executing ConfigSmmCodeAccessCheckOnCurrentProcessor(). - // - AcquireSpinLock (mConfigSmmCodeAccessCheckLock); - - // - // Call SmmStartupThisAp() to enable SMM Code Access Check on an AP. - // - Status = gSmst->SmmStartupThisAp (ConfigSmmCodeAccessCheckOnCurrentProcessor, Index, &Index); - ASSERT_EFI_ERROR (Status); - - // - // Wait for the AP to release the Config SMM Code Access Check spin lock. - // - while (!AcquireSpinLockOrFail (mConfigSmmCodeAccessCheckLock)) { - CpuPause (); - } - - // - // Release the Config SMM Code Access Check spin lock. - // - ReleaseSpinLock (mConfigSmmCodeAccessCheckLock); - } - } -} - -/** - This API provides a way to allocate memory for page table. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the request, then NULL is - returned. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -VOID * -AllocatePageTableMemory ( - IN UINTN Pages - ) -{ - VOID *Buffer; - - Buffer = SmmCpuFeaturesAllocatePageTableMemory (Pages); - if (Buffer != NULL) { - return Buffer; - } - return AllocatePages (Pages); -} - -/** - Allocate pages for code. - - @param[in] Pages Number of pages to be allocated. - - @return Allocated memory. -**/ -VOID * -AllocateCodePages ( - IN UINTN Pages - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Memory; - - if (Pages == 0) { - return NULL; - } - - Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, Pages, &Memory); - if (EFI_ERROR (Status)) { - return NULL; - } - return (VOID *) (UINTN) Memory; -} - -/** - Allocate aligned pages for code. - - @param[in] Pages Number of pages to be allocated. - @param[in] Alignment The requested alignment of the allocation. - Must be a power of two. - If Alignment is zero, then byte alignment is used. - - @return Allocated memory. -**/ -VOID * -AllocateAlignedCodePages ( - IN UINTN Pages, - IN UINTN Alignment - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Memory; - UINTN AlignedMemory; - UINTN AlignmentMask; - UINTN UnalignedPages; - UINTN RealPages; - - // - // Alignment must be a power of two or zero. - // - ASSERT ((Alignment & (Alignment - 1)) == 0); - - if (Pages == 0) { - return NULL; - } - if (Alignment > EFI_PAGE_SIZE) { - // - // Calculate the total number of pages since alignment is larger than page size. - // - AlignmentMask = Alignment - 1; - RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment); - // - // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. - // - ASSERT (RealPages > Pages); - - Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, RealPages, &Memory); - if (EFI_ERROR (Status)) { - return NULL; - } - AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask; - UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory); - if (UnalignedPages > 0) { - // - // Free first unaligned page(s). - // - Status = gSmst->SmmFreePages (Memory, UnalignedPages); - ASSERT_EFI_ERROR (Status); - } - Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages); - UnalignedPages = RealPages - Pages - UnalignedPages; - if (UnalignedPages > 0) { - // - // Free last unaligned page(s). - // - Status = gSmst->SmmFreePages (Memory, UnalignedPages); - ASSERT_EFI_ERROR (Status); - } - } else { - // - // Do not over-allocate pages in this case. - // - Status = gSmst->SmmAllocatePages (AllocateAnyPages, EfiRuntimeServicesCode, Pages, &Memory); - if (EFI_ERROR (Status)) { - return NULL; - } - AlignedMemory = (UINTN) Memory; - } - return (VOID *) AlignedMemory; -} - -/** - Perform the remaining tasks. - -**/ -VOID -PerformRemainingTasks ( - VOID - ) -{ - if (mSmmReadyToLock) { - // - // Start SMM Profile feature - // - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - SmmProfileStart (); - } - // - // Create a mix of 2MB and 4KB page table. Update some memory ranges absent and execute-disable. - // - InitPaging (); - - // - // Mark critical region to be read-only in page table - // - SetMemMapAttributes (); - - // - // For outside SMRAM, we only map SMM communication buffer or MMIO. - // - SetUefiMemMapAttributes (); - - // - // Set page table itself to be read-only - // - SetPageTableAttributes (); - - // - // Configure SMM Code Access Check feature if available. - // - ConfigSmmCodeAccessCheck (); - - SmmCpuFeaturesCompleteSmmReadyToLock (); - - // - // Clean SMM ready to lock flag - // - mSmmReadyToLock = FALSE; - } -} - -/** - Perform the pre tasks. - -**/ -VOID -PerformPreTasks ( - VOID - ) -{ - RestoreSmmConfigurationInS3 (); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h deleted file mode 100644 index dbce9ec520..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ /dev/null @@ -1,1070 +0,0 @@ -/** @file -Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CPU_PISMMCPUDXESMM_H_ -#define _CPU_PISMMCPUDXESMM_H_ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "CpuService.h" -#include "SmmProfile.h" - -// -// MSRs required for configuration of SMM Code Access Check -// -#define EFI_MSR_SMM_MCA_CAP 0x17D -#define SMM_CODE_ACCESS_CHK_BIT BIT58 - -#define SMM_FEATURE_CONTROL_LOCK_BIT BIT0 -#define SMM_CODE_CHK_EN_BIT BIT2 - -/// -/// Page Table Entry -/// -#define IA32_PG_P BIT0 -#define IA32_PG_RW BIT1 -#define IA32_PG_U BIT2 -#define IA32_PG_WT BIT3 -#define IA32_PG_CD BIT4 -#define IA32_PG_A BIT5 -#define IA32_PG_D BIT6 -#define IA32_PG_PS BIT7 -#define IA32_PG_PAT_2M BIT12 -#define IA32_PG_PAT_4K IA32_PG_PS -#define IA32_PG_PMNT BIT62 -#define IA32_PG_NX BIT63 - -#define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P) -// -// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE -// X64 PAE PDPTE does not have such restriction -// -#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) - -#define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS) - -#define PAGING_4K_MASK 0xFFF -#define PAGING_2M_MASK 0x1FFFFF -#define PAGING_1G_MASK 0x3FFFFFFF - -#define PAGING_PAE_INDEX_MASK 0x1FF - -#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull -#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull -#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull - -#define SMRR_MAX_ADDRESS BASE_4GB - -typedef enum { - PageNone, - Page4K, - Page2M, - Page1G, -} PAGE_ATTRIBUTE; - -typedef struct { - PAGE_ATTRIBUTE Attribute; - UINT64 Length; - UINT64 AddressMask; -} PAGE_ATTRIBUTE_TABLE; - -// -// Size of Task-State Segment defined in IA32 Manual -// -#define TSS_SIZE 104 -#define TSS_X64_IST1_OFFSET 36 -#define TSS_IA32_CR3_OFFSET 28 -#define TSS_IA32_ESP_OFFSET 56 - -#define CR0_WP BIT16 - -// -// Code select value -// -#define PROTECT_MODE_CODE_SEGMENT 0x08 -#define LONG_MODE_CODE_SEGMENT 0x38 - -// -// The size 0x20 must be bigger than -// the size of template code of SmmInit. Currently, -// the size of SmmInit requires the 0x16 Bytes buffer -// at least. -// -#define BACK_BUF_SIZE 0x20 - -#define EXCEPTION_VECTOR_NUMBER 0x20 - -#define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL - -typedef UINT32 SMM_CPU_ARRIVAL_EXCEPTIONS; -#define ARRIVAL_EXCEPTION_BLOCKED 0x1 -#define ARRIVAL_EXCEPTION_DELAYED 0x2 -#define ARRIVAL_EXCEPTION_SMI_DISABLED 0x4 - -// -// Private structure for the SMM CPU module that is stored in DXE Runtime memory -// Contains the SMM Configuration Protocols that is produced. -// Contains a mix of DXE and SMM contents. All the fields must be used properly. -// -#define SMM_CPU_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('s', 'c', 'p', 'u') - -typedef struct { - UINTN Signature; - - EFI_HANDLE SmmCpuHandle; - - EFI_PROCESSOR_INFORMATION *ProcessorInfo; - SMM_CPU_OPERATION *Operation; - UINTN *CpuSaveStateSize; - VOID **CpuSaveState; - - EFI_SMM_RESERVED_SMRAM_REGION SmmReservedSmramRegion[1]; - EFI_SMM_ENTRY_CONTEXT SmmCoreEntryContext; - EFI_SMM_ENTRY_POINT SmmCoreEntry; - - EFI_SMM_CONFIGURATION_PROTOCOL SmmConfiguration; -} SMM_CPU_PRIVATE_DATA; - -extern SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate; -extern CPU_HOT_PLUG_DATA mCpuHotPlugData; -extern UINTN mMaxNumberOfCpus; -extern UINTN mNumberOfCpus; -extern EFI_SMM_CPU_PROTOCOL mSmmCpu; - -/// -/// The mode of the CPU at the time an SMI occurs -/// -extern UINT8 mSmmSaveStateRegisterLma; - -// -// SMM CPU Protocol function prototypes. -// - -/** - Read information from the CPU save state. - - @param This EFI_SMM_CPU_PROTOCOL instance - @param Width The number of bytes to read from the CPU save state. - @param Register Specifies the CPU register to read form the save state. - @param CpuIndex Specifies the zero-based index of the CPU save state - @param Buffer Upon return, this holds the CPU register value read from the save state. - - @retval EFI_SUCCESS The register was read from Save State - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor - @retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -EFI_STATUS -EFIAPI -SmmReadSaveState ( - IN CONST EFI_SMM_CPU_PROTOCOL *This, - IN UINTN Width, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN CpuIndex, - OUT VOID *Buffer - ); - -/** - Write data to the CPU save state. - - @param This EFI_SMM_CPU_PROTOCOL instance - @param Width The number of bytes to read from the CPU save state. - @param Register Specifies the CPU register to write to the save state. - @param CpuIndex Specifies the zero-based index of the CPU save state - @param Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written from Save State - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor - @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct - -**/ -EFI_STATUS -EFIAPI -SmmWriteSaveState ( - IN CONST EFI_SMM_CPU_PROTOCOL *This, - IN UINTN Width, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN CpuIndex, - IN CONST VOID *Buffer - ); - -/** -Read a CPU Save State register on the target processor. - -This function abstracts the differences that whether the CPU Save State register is in the -IA32 CPU Save State Map or X64 CPU Save State Map. - -This function supports reading a CPU Save State register in SMBase relocation handler. - -@param[in] CpuIndex Specifies the zero-based index of the CPU save state. -@param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. -@param[in] Width The number of bytes to read from the CPU save state. -@param[out] Buffer Upon return, this holds the CPU register value read from the save state. - -@retval EFI_SUCCESS The register was read from Save State. -@retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. -@retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -EFI_STATUS -EFIAPI -ReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ); - -/** -Write value to a CPU Save State register on the target processor. - -This function abstracts the differences that whether the CPU Save State register is in the -IA32 CPU Save State Map or X64 CPU Save State Map. - -This function supports writing a CPU Save State register in SMBase relocation handler. - -@param[in] CpuIndex Specifies the zero-based index of the CPU save state. -@param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. -@param[in] Width The number of bytes to read from the CPU save state. -@param[in] Buffer Upon entry, this holds the new CPU register value. - -@retval EFI_SUCCESS The register was written to Save State. -@retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. -@retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct. - -**/ -EFI_STATUS -EFIAPI -WriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ); - -// -// -// -typedef struct { - UINT32 Offset; - UINT16 Segment; - UINT16 Reserved; -} IA32_FAR_ADDRESS; - -extern IA32_FAR_ADDRESS gSmmJmpAddr; - -extern CONST UINT8 gcSmmInitTemplate[]; -extern CONST UINT16 gcSmmInitSize; -extern UINT32 gSmmCr0; -extern UINT32 gSmmCr3; -extern UINT32 gSmmCr4; -extern UINTN gSmmInitStack; - -/** - Semaphore operation for all processor relocate SMMBase. -**/ -VOID -EFIAPI -SmmRelocationSemaphoreComplete ( - VOID - ); - -/// -/// The type of SMM CPU Information -/// -typedef struct { - SPIN_LOCK *Busy; - volatile EFI_AP_PROCEDURE Procedure; - volatile VOID *Parameter; - volatile UINT32 *Run; - volatile BOOLEAN *Present; -} SMM_CPU_DATA_BLOCK; - -typedef enum { - SmmCpuSyncModeTradition, - SmmCpuSyncModeRelaxedAp, - SmmCpuSyncModeMax -} SMM_CPU_SYNC_MODE; - -typedef struct { - // - // Pointer to an array. The array should be located immediately after this structure - // so that UC cache-ability can be set together. - // - SMM_CPU_DATA_BLOCK *CpuData; - volatile UINT32 *Counter; - volatile UINT32 BspIndex; - volatile BOOLEAN *InsideSmm; - volatile BOOLEAN *AllCpusInSync; - volatile SMM_CPU_SYNC_MODE EffectiveSyncMode; - volatile BOOLEAN SwitchBsp; - volatile BOOLEAN *CandidateBsp; -} SMM_DISPATCHER_MP_SYNC_DATA; - -#define MSR_SPIN_LOCK_INIT_NUM 15 - -typedef struct { - SPIN_LOCK *SpinLock; - UINT32 MsrIndex; -} MP_MSR_LOCK; - -#define SMM_PSD_OFFSET 0xfb00 - -/// -/// All global semaphores' pointer -/// -typedef struct { - volatile UINT32 *Counter; - volatile BOOLEAN *InsideSmm; - volatile BOOLEAN *AllCpusInSync; - SPIN_LOCK *PFLock; - SPIN_LOCK *CodeAccessCheckLock; - SPIN_LOCK *MemoryMappedLock; -} SMM_CPU_SEMAPHORE_GLOBAL; - -/// -/// All semaphores for each processor -/// -typedef struct { - SPIN_LOCK *Busy; - volatile UINT32 *Run; - volatile BOOLEAN *Present; -} SMM_CPU_SEMAPHORE_CPU; - -/// -/// All MSRs semaphores' pointer and counter -/// -typedef struct { - SPIN_LOCK *Msr; - UINTN AvailableCounter; -} SMM_CPU_SEMAPHORE_MSR; - -/// -/// All semaphores' information -/// -typedef struct { - SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal; - SMM_CPU_SEMAPHORE_CPU SemaphoreCpu; - SMM_CPU_SEMAPHORE_MSR SemaphoreMsr; -} SMM_CPU_SEMAPHORES; - -extern IA32_DESCRIPTOR gcSmiGdtr; -extern EFI_PHYSICAL_ADDRESS mGdtBuffer; -extern UINTN mGdtBufferSize; -extern IA32_DESCRIPTOR gcSmiIdtr; -extern VOID *gcSmiIdtrPtr; -extern UINT64 gPhyMask; -extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData; -extern UINTN mSmmStackArrayBase; -extern UINTN mSmmStackArrayEnd; -extern UINTN mSmmStackSize; -extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService; -extern IA32_DESCRIPTOR gcSmiInitGdtr; -extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores; -extern UINTN mSemaphoreSize; -extern SPIN_LOCK *mPFLock; -extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock; -extern SPIN_LOCK *mMemoryMappedLock; -extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; -extern UINTN mSmmCpuSmramRangeCount; - -// -// Copy of the PcdPteMemoryEncryptionAddressOrMask -// -extern UINT64 mAddressEncMask; - -/** - Create 4G PageTable in SMRAM. - - @param[in] Is32BitPageTable Whether the page table is 32-bit PAE - @return PageTable Address - -**/ -UINT32 -Gen4GPageTable ( - IN BOOLEAN Is32BitPageTable - ); - - -/** - Initialize global data for MP synchronization. - - @param Stacks Base address of SMI stack buffer for all processors. - @param StackSize Stack size for each processor in SMM. - -**/ -UINT32 -InitializeMpServiceData ( - IN VOID *Stacks, - IN UINTN StackSize - ); - -/** - Initialize Timer for SMM AP Sync. - -**/ -VOID -InitializeSmmTimer ( - VOID - ); - -/** - Start Timer for SMM AP Sync. - -**/ -UINT64 -EFIAPI -StartSyncTimer ( - VOID - ); - -/** - Check if the SMM AP Sync timer is timeout. - - @param Timer The start timer from the begin. - -**/ -BOOLEAN -EFIAPI -IsSyncTimerTimeout ( - IN UINT64 Timer - ); - -/** - Initialize IDT for SMM Stack Guard. - -**/ -VOID -EFIAPI -InitializeIDTSmmStackGuard ( - VOID - ); - -/** - Initialize Gdt for all processors. - - @param[in] Cr3 CR3 value. - @param[out] GdtStepSize The step size for GDT table. - - @return GdtBase for processor 0. - GdtBase for processor X is: GdtBase + (GdtStepSize * X) -**/ -VOID * -InitGdt ( - IN UINTN Cr3, - OUT UINTN *GdtStepSize - ); - -/** - This function sets GDT/IDT buffer to be RO and XP. -**/ -VOID -PatchGdtIdtMap ( - VOID - ); - -/** - - Register the SMM Foundation entry point. - - @param This Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance - @param SmmEntryPoint SMM Foundation EntryPoint - - @retval EFI_SUCCESS Successfully to register SMM foundation entry point - -**/ -EFI_STATUS -EFIAPI -RegisterSmmEntry ( - IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This, - IN EFI_SMM_ENTRY_POINT SmmEntryPoint - ); - -/** - Create PageTable for SMM use. - - @return PageTable Address - -**/ -UINT32 -SmmInitPageTable ( - VOID - ); - -/** - Schedule a procedure to run on the specified CPU. - - @param Procedure The address of the procedure to run - @param CpuIndex Target CPU number - @param ProcArguments The parameter to pass to the procedure - - @retval EFI_INVALID_PARAMETER CpuNumber not valid - @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy - @retval EFI_SUCCESS - The procedure has been successfully scheduled - -**/ -EFI_STATUS -EFIAPI -SmmStartupThisAp ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN CpuIndex, - IN OUT VOID *ProcArguments OPTIONAL - ); - -/** - Schedule a procedure to run on the specified CPU in a blocking fashion. - - @param Procedure The address of the procedure to run - @param CpuIndex Target CPU Index - @param ProcArguments The parameter to pass to the procedure - - @retval EFI_INVALID_PARAMETER CpuNumber not valid - @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM - @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy - @retval EFI_SUCCESS The procedure has been successfully scheduled - -**/ -EFI_STATUS -EFIAPI -SmmBlockingStartupThisAp ( - IN EFI_AP_PROCEDURE Procedure, - IN UINTN CpuIndex, - IN OUT VOID *ProcArguments OPTIONAL - ); - -/** - This function sets the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to set for the memory region. - - @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmSetMemoryAttributes ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ); - -/** - This function clears the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to clear for the memory region. - - @retval EFI_SUCCESS The attributes were cleared for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmClearMemoryAttributes ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ); - -/** - Initialize MP synchronization data. - -**/ -VOID -EFIAPI -InitializeMpSyncData ( - VOID - ); - -/** - - Find out SMRAM information including SMRR base and SMRR size. - - @param SmrrBase SMRR base - @param SmrrSize SMRR size - -**/ -VOID -FindSmramInfo ( - OUT UINT32 *SmrrBase, - OUT UINT32 *SmrrSize - ); - -/** - Relocate SmmBases for each processor. - - Execute on first boot and all S3 resumes - -**/ -VOID -EFIAPI -SmmRelocateBases ( - VOID - ); - -/** - Page Fault handler for SMM use. - - @param InterruptType Defines the type of interrupt or exception that - occurred on the processor.This parameter is processor architecture specific. - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. -**/ -VOID -EFIAPI -SmiPFHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_SYSTEM_CONTEXT SystemContext - ); - -/** - Perform the remaining tasks. - -**/ -VOID -PerformRemainingTasks ( - VOID - ); - -/** - Perform the pre tasks. - -**/ -VOID -PerformPreTasks ( - VOID - ); - -/** - Initialize MSR spin lock by MSR index. - - @param MsrIndex MSR index value. - -**/ -VOID -InitMsrSpinLockByIndex ( - IN UINT32 MsrIndex - ); - -/** - Hook return address of SMM Save State so that semaphore code - can be executed immediately after AP exits SMM to indicate to - the BSP that an AP has exited SMM after SMBASE relocation. - - @param[in] CpuIndex The processor index. - @param[in] RebasedFlag A pointer to a flag that is set to TRUE - immediately after AP exits SMM. - -**/ -VOID -SemaphoreHook ( - IN UINTN CpuIndex, - IN volatile BOOLEAN *RebasedFlag - ); - -/** -Configure SMM Code Access Check feature for all processors. -SMM Feature Control MSR will be locked after configuration. -**/ -VOID -ConfigSmmCodeAccessCheck ( - VOID - ); - -/** - Hook the code executed immediately after an RSM instruction on the currently - executing CPU. The mode of code executed immediately after RSM must be - detected, and the appropriate hook must be selected. Always clear the auto - HALT restart flag if it is set. - - @param[in] CpuIndex The processor index for the currently - executing CPU. - @param[in] CpuState Pointer to SMRAM Save State Map for the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to - 32-bit mode from 64-bit SMM. - @param[in] NewInstructionPointer Instruction pointer to use if resuming to - same mode as SMM. - - @retval The value of the original instruction pointer before it was hooked. - -**/ -UINT64 -EFIAPI -HookReturnFromSmm ( - IN UINTN CpuIndex, - SMRAM_SAVE_STATE_MAP *CpuState, - UINT64 NewInstructionPointer32, - UINT64 NewInstructionPointer - ); - -/** - Get the size of the SMI Handler in bytes. - - @retval The size, in bytes, of the SMI Handler. - -**/ -UINTN -EFIAPI -GetSmiHandlerSize ( - VOID - ); - -/** - Install the SMI handler for the CPU specified by CpuIndex. This function - is called by the CPU that was elected as monarch during System Management - Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -InstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ); - -/** - Search module name by input IP address and output it. - - @param CallerIpAddress Caller instruction pointer. - -**/ -VOID -DumpModuleInfoByIp ( - IN UINTN CallerIpAddress - ); - -/** - This function sets memory attribute according to MemoryAttributesTable. -**/ -VOID -SetMemMapAttributes ( - VOID - ); - -/** - This function sets UEFI memory attribute according to UEFI memory map. -**/ -VOID -SetUefiMemMapAttributes ( - VOID - ); - -/** - Return if the Address is forbidden as SMM communication buffer. - - @param[in] Address the address to be checked - - @return TRUE The address is forbidden as SMM communication buffer. - @return FALSE The address is allowed as SMM communication buffer. -**/ -BOOLEAN -IsSmmCommBufferForbiddenAddress ( - IN UINT64 Address - ); - -/** - This function caches the UEFI memory map information. -**/ -VOID -GetUefiMemoryMap ( - VOID - ); - -/** - This function sets memory attribute for page table. -**/ -VOID -SetPageTableAttributes ( - VOID - ); - -/** - Return page table base. - - @return page table base. -**/ -UINTN -GetPageTableBase ( - VOID - ); - -/** - This function sets the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to set for the memory region. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - - @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmSetMemoryAttributesEx ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - OUT BOOLEAN *IsSplitted OPTIONAL - ); - -/** - This function clears the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to clear for the memory region. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - - @retval EFI_SUCCESS The attributes were cleared for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmClearMemoryAttributesEx ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - OUT BOOLEAN *IsSplitted OPTIONAL - ); - -/** - This API provides a way to allocate memory for page table. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the request, then NULL is - returned. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -VOID * -AllocatePageTableMemory ( - IN UINTN Pages - ); - -/** - Allocate pages for code. - - @param[in] Pages Number of pages to be allocated. - - @return Allocated memory. -**/ -VOID * -AllocateCodePages ( - IN UINTN Pages - ); - -/** - Allocate aligned pages for code. - - @param[in] Pages Number of pages to be allocated. - @param[in] Alignment The requested alignment of the allocation. - Must be a power of two. - If Alignment is zero, then byte alignment is used. - - @return Allocated memory. -**/ -VOID * -AllocateAlignedCodePages ( - IN UINTN Pages, - IN UINTN Alignment - ); - - -// -// S3 related global variable and function prototype. -// - -extern BOOLEAN mSmmS3Flag; - -/** - Initialize SMM S3 resume state structure used during S3 Resume. - - @param[in] Cr3 The base address of the page tables to use in SMM. - -**/ -VOID -InitSmmS3ResumeState ( - IN UINT32 Cr3 - ); - -/** - Get ACPI CPU data. - -**/ -VOID -GetAcpiCpuData ( - VOID - ); - -/** - Restore SMM Configuration in S3 boot path. - -**/ -VOID -RestoreSmmConfigurationInS3 ( - VOID - ); - -/** - Get ACPI S3 enable flag. - -**/ -VOID -GetAcpiS3EnableFlag ( - VOID - ); - -/** - Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. - - @param[in] ApHltLoopCode The address of the safe hlt-loop function. - @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. - @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. - -**/ -VOID -TransferApToSafeState ( - IN UINTN ApHltLoopCode, - IN UINTN TopOfStack, - IN UINTN NumberToFinishAddress - ); - -#endif diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf deleted file mode 100644 index 099792e6ce..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf +++ /dev/null @@ -1,167 +0,0 @@ -## @file -# CPU SMM driver. -# -# This SMM driver performs SMM initialization, deploy SMM Entry Vector, -# provides CPU specific services in SMM. -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PiSmmCpuDxeSmm - MODULE_UNI_FILE = PiSmmCpuDxeSmm.uni - FILE_GUID = A3FF0EF5-0C28-42f5-B544-8C7DE1E80014 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x0001000A - ENTRY_POINT = PiCpuSmmEntry - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - PiSmmCpuDxeSmm.c - PiSmmCpuDxeSmm.h - MpService.c - SyncTimer.c - CpuS3.c - CpuService.c - CpuService.h - SmmProfile.c - SmmProfile.h - SmmProfileInternal.h - SmramSaveState.c - SmmCpuMemoryManagement.c - -[Sources.Ia32] - Ia32/Semaphore.c - Ia32/PageTbl.c - Ia32/SmmFuncsArch.c - Ia32/SmmProfileArch.c - Ia32/SmmProfileArch.h - Ia32/SmmInit.asm - Ia32/SmiEntry.asm - Ia32/SmiException.asm - Ia32/MpFuncs.asm - - Ia32/SmmInit.nasm - Ia32/SmiEntry.nasm - Ia32/SmiException.nasm - Ia32/MpFuncs.nasm - - Ia32/SmmInit.S - Ia32/SmiEntry.S - Ia32/SmiException.S - Ia32/MpFuncs.S - -[Sources.X64] - X64/Semaphore.c - X64/PageTbl.c - X64/SmmFuncsArch.c - X64/SmmProfileArch.c - X64/SmmProfileArch.h - X64/SmmInit.asm - X64/SmiEntry.asm - X64/SmiException.asm - X64/MpFuncs.asm - - X64/SmmInit.nasm - X64/SmiEntry.nasm - X64/SmiException.nasm - X64/MpFuncs.nasm - - X64/SmmInit.S - X64/SmiEntry.S - X64/SmiException.S - X64/MpFuncs.S - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - UefiRuntimeServicesTableLib - CacheMaintenanceLib - PcdLib - DebugLib - BaseLib - SynchronizationLib - BaseMemoryLib - MtrrLib - IoLib - TimerLib - SmmServicesTableLib - MemoryAllocationLib - DebugAgentLib - HobLib - PciLib - LocalApicLib - UefiCpuLib - SmmCpuPlatformHookLib - CpuExceptionHandlerLib - UefiLib - DxeServicesTableLib - CpuLib - ReportStatusCodeLib - SmmCpuFeaturesLib - PeCoffGetEntryPointLib - -[Protocols] - gEfiSmmAccess2ProtocolGuid ## CONSUMES - gEfiMpServiceProtocolGuid ## CONSUMES - gEfiSmmConfigurationProtocolGuid ## PRODUCES - gEfiSmmCpuProtocolGuid ## PRODUCES - gEfiSmmReadyToLockProtocolGuid ## NOTIFY - gEfiSmmCpuServiceProtocolGuid ## PRODUCES - -[Guids] - gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot. - gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"SmmProfileData" - gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEdkiiPiSmmMemoryAttributesTableGuid ## CONSUMES ## SystemTable - -[FeaturePcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileEnable ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock ## CONSUMES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## SOMETIMES_CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## SOMETIMES_PRODUCES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode ## CONSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStaticPageTable ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES - -[Depex] - gEfiMpServiceProtocolGuid - -[UserExtensions.TianoCore."ExtraFiles"] - PiSmmCpuDxeSmmExtra.uni diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni deleted file mode 100644 index 98eae1d697..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// CPU SMM driver. -// -// This SMM driver performs SMM initialization, deploy SMM Entry Vector, -// provides CPU specific services in SMM. -// -// Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "CPU SMM driver" - -#string STR_MODULE_DESCRIPTION #language en-US "This SMM driver performs SMM initialization, deploys SMM Entry Vector, and provides CPU-specific services in SMM." diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni deleted file mode 100644 index d0a8d54006..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmmExtra.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// PiSmmCpuDxeSmm Localized Strings and Content -// -// Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"Processor SMM Initialization DXE Driver" diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c deleted file mode 100644 index a535389c26..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ /dev/null @@ -1,1103 +0,0 @@ -/** @file - -Copyright (c) 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \ - ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size))) - -#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \ - ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size))) - -EFI_MEMORY_DESCRIPTOR *mUefiMemoryMap; -UINTN mUefiMemoryMapSize; -UINTN mUefiDescriptorSize; - -PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = { - {Page4K, SIZE_4KB, PAGING_4K_ADDRESS_MASK_64}, - {Page2M, SIZE_2MB, PAGING_2M_ADDRESS_MASK_64}, - {Page1G, SIZE_1GB, PAGING_1G_ADDRESS_MASK_64}, -}; - -/** - Return page table base. - - @return page table base. -**/ -UINTN -GetPageTableBase ( - VOID - ) -{ - return (AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64); -} - -/** - Return length according to page attributes. - - @param[in] PageAttributes The page attribute of the page entry. - - @return The length of page entry. -**/ -UINTN -PageAttributeToLength ( - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINTN Index; - for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { - if (PageAttribute == mPageAttributeTable[Index].Attribute) { - return (UINTN)mPageAttributeTable[Index].Length; - } - } - return 0; -} - -/** - Return address mask according to page attributes. - - @param[in] PageAttributes The page attribute of the page entry. - - @return The address mask of page entry. -**/ -UINTN -PageAttributeToMask ( - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINTN Index; - for (Index = 0; Index < sizeof(mPageAttributeTable)/sizeof(mPageAttributeTable[0]); Index++) { - if (PageAttribute == mPageAttributeTable[Index].Attribute) { - return (UINTN)mPageAttributeTable[Index].AddressMask; - } - } - return 0; -} - -/** - Return page table entry to match the address. - - @param[in] Address The address to be checked. - @param[out] PageAttributes The page attribute of the page entry. - - @return The page entry. -**/ -VOID * -GetPageTableEntry ( - IN PHYSICAL_ADDRESS Address, - OUT PAGE_ATTRIBUTE *PageAttribute - ) -{ - UINTN Index1; - UINTN Index2; - UINTN Index3; - UINTN Index4; - UINT64 *L1PageTable; - UINT64 *L2PageTable; - UINT64 *L3PageTable; - UINT64 *L4PageTable; - - Index4 = ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK; - Index3 = ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK; - Index2 = ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK; - Index1 = ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK; - - if (sizeof(UINTN) == sizeof(UINT64)) { - L4PageTable = (UINT64 *)GetPageTableBase (); - if (L4PageTable[Index4] == 0) { - *PageAttribute = PageNone; - return NULL; - } - - L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - } else { - L3PageTable = (UINT64 *)GetPageTableBase (); - } - if (L3PageTable[Index3] == 0) { - *PageAttribute = PageNone; - return NULL; - } - if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { - // 1G - *PageAttribute = Page1G; - return &L3PageTable[Index3]; - } - - L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L2PageTable[Index2] == 0) { - *PageAttribute = PageNone; - return NULL; - } - if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { - // 2M - *PageAttribute = Page2M; - return &L2PageTable[Index2]; - } - - // 4k - L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if ((L1PageTable[Index1] == 0) && (Address != 0)) { - *PageAttribute = PageNone; - return NULL; - } - *PageAttribute = Page4K; - return &L1PageTable[Index1]; -} - -/** - Return memory attributes of page entry. - - @param[in] PageEntry The page entry. - - @return Memory attributes of page entry. -**/ -UINT64 -GetAttributesFromPageEntry ( - IN UINT64 *PageEntry - ) -{ - UINT64 Attributes; - Attributes = 0; - if ((*PageEntry & IA32_PG_P) == 0) { - Attributes |= EFI_MEMORY_RP; - } - if ((*PageEntry & IA32_PG_RW) == 0) { - Attributes |= EFI_MEMORY_RO; - } - if ((*PageEntry & IA32_PG_NX) != 0) { - Attributes |= EFI_MEMORY_XP; - } - return Attributes; -} - -/** - Modify memory attributes of page entry. - - @param[in] PageEntry The page entry. - @param[in] Attributes The bit mask of attributes to modify for the memory region. - @param[in] IsSet TRUE means to set attributes. FALSE means to clear attributes. - @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. -**/ -VOID -ConvertPageEntryAttribute ( - IN UINT64 *PageEntry, - IN UINT64 Attributes, - IN BOOLEAN IsSet, - OUT BOOLEAN *IsModified - ) -{ - UINT64 CurrentPageEntry; - UINT64 NewPageEntry; - - CurrentPageEntry = *PageEntry; - NewPageEntry = CurrentPageEntry; - if ((Attributes & EFI_MEMORY_RP) != 0) { - if (IsSet) { - NewPageEntry &= ~(UINT64)IA32_PG_P; - } else { - NewPageEntry |= IA32_PG_P; - } - } - if ((Attributes & EFI_MEMORY_RO) != 0) { - if (IsSet) { - NewPageEntry &= ~(UINT64)IA32_PG_RW; - } else { - NewPageEntry |= IA32_PG_RW; - } - } - if ((Attributes & EFI_MEMORY_XP) != 0) { - if (mXdSupported) { - if (IsSet) { - NewPageEntry |= IA32_PG_NX; - } else { - NewPageEntry &= ~IA32_PG_NX; - } - } - } - *PageEntry = NewPageEntry; - if (CurrentPageEntry != NewPageEntry) { - *IsModified = TRUE; - DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry)); - DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry)); - } else { - *IsModified = FALSE; - } -} - -/** - This function returns if there is need to split page entry. - - @param[in] BaseAddress The base address to be checked. - @param[in] Length The length to be checked. - @param[in] PageEntry The page entry to be checked. - @param[in] PageAttribute The page attribute of the page entry. - - @retval SplitAttributes on if there is need to split page entry. -**/ -PAGE_ATTRIBUTE -NeedSplitPage ( - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 *PageEntry, - IN PAGE_ATTRIBUTE PageAttribute - ) -{ - UINT64 PageEntryLength; - - PageEntryLength = PageAttributeToLength (PageAttribute); - - if (((BaseAddress & (PageEntryLength - 1)) == 0) && (Length >= PageEntryLength)) { - return PageNone; - } - - if (((BaseAddress & PAGING_2M_MASK) != 0) || (Length < SIZE_2MB)) { - return Page4K; - } - - return Page2M; -} - -/** - This function splits one page entry to small page entries. - - @param[in] PageEntry The page entry to be splitted. - @param[in] PageAttribute The page attribute of the page entry. - @param[in] SplitAttribute How to split the page entry. - - @retval RETURN_SUCCESS The page entry is splitted. - @retval RETURN_UNSUPPORTED The page entry does not support to be splitted. - @retval RETURN_OUT_OF_RESOURCES No resource to split page entry. -**/ -RETURN_STATUS -SplitPage ( - IN UINT64 *PageEntry, - IN PAGE_ATTRIBUTE PageAttribute, - IN PAGE_ATTRIBUTE SplitAttribute - ) -{ - UINT64 BaseAddress; - UINT64 *NewPageEntry; - UINTN Index; - - ASSERT (PageAttribute == Page2M || PageAttribute == Page1G); - - if (PageAttribute == Page2M) { - // - // Split 2M to 4K - // - ASSERT (SplitAttribute == Page4K); - if (SplitAttribute == Page4K) { - NewPageEntry = AllocatePageTableMemory (1); - DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry)); - if (NewPageEntry == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - BaseAddress = *PageEntry & PAGING_2M_ADDRESS_MASK_64; - for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { - NewPageEntry[Index] = (BaseAddress + SIZE_4KB * Index) | mAddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); - } - (*PageEntry) = (UINT64)(UINTN)NewPageEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - return RETURN_SUCCESS; - } else { - return RETURN_UNSUPPORTED; - } - } else if (PageAttribute == Page1G) { - // - // Split 1G to 2M - // No need support 1G->4K directly, we should use 1G->2M, then 2M->4K to get more compact page table. - // - ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K); - if ((SplitAttribute == Page2M || SplitAttribute == Page4K)) { - NewPageEntry = AllocatePageTableMemory (1); - DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry)); - if (NewPageEntry == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - BaseAddress = *PageEntry & PAGING_1G_ADDRESS_MASK_64; - for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { - NewPageEntry[Index] = (BaseAddress + SIZE_2MB * Index) | mAddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS); - } - (*PageEntry) = (UINT64)(UINTN)NewPageEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - return RETURN_SUCCESS; - } else { - return RETURN_UNSUPPORTED; - } - } else { - return RETURN_UNSUPPORTED; - } -} - -/** - This function modifies the page attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - Caller should make sure BaseAddress and Length is at page boundary. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to modify for the memory region. - @param[in] IsSet TRUE means to set attributes. FALSE means to clear attributes. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - @param[out] IsModified TRUE means page table modified. FALSE means page table not modified. - - @retval RETURN_SUCCESS The attributes were modified for the memory region. - @retval RETURN_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval RETURN_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval RETURN_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval RETURN_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. -**/ -RETURN_STATUS -EFIAPI -ConvertMemoryPageAttributes ( - IN PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - IN BOOLEAN IsSet, - OUT BOOLEAN *IsSplitted, OPTIONAL - OUT BOOLEAN *IsModified OPTIONAL - ) -{ - UINT64 *PageEntry; - PAGE_ATTRIBUTE PageAttribute; - UINTN PageEntryLength; - PAGE_ATTRIBUTE SplitAttribute; - RETURN_STATUS Status; - BOOLEAN IsEntryModified; - - ASSERT (Attributes != 0); - ASSERT ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) == 0); - - ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); - ASSERT ((Length & (SIZE_4KB - 1)) == 0); - - if (Length == 0) { - return RETURN_INVALID_PARAMETER; - } - -// DEBUG ((DEBUG_ERROR, "ConvertMemoryPageAttributes(%x) - %016lx, %016lx, %02lx\n", IsSet, BaseAddress, Length, Attributes)); - - if (IsSplitted != NULL) { - *IsSplitted = FALSE; - } - if (IsModified != NULL) { - *IsModified = FALSE; - } - - // - // Below logic is to check 2M/4K page to make sure we donot waist memory. - // - while (Length != 0) { - PageEntry = GetPageTableEntry (BaseAddress, &PageAttribute); - if (PageEntry == NULL) { - return RETURN_UNSUPPORTED; - } - PageEntryLength = PageAttributeToLength (PageAttribute); - SplitAttribute = NeedSplitPage (BaseAddress, Length, PageEntry, PageAttribute); - if (SplitAttribute == PageNone) { - ConvertPageEntryAttribute (PageEntry, Attributes, IsSet, &IsEntryModified); - if (IsEntryModified) { - if (IsModified != NULL) { - *IsModified = TRUE; - } - } - // - // Convert success, move to next - // - BaseAddress += PageEntryLength; - Length -= PageEntryLength; - } else { - Status = SplitPage (PageEntry, PageAttribute, SplitAttribute); - if (RETURN_ERROR (Status)) { - return RETURN_UNSUPPORTED; - } - if (IsSplitted != NULL) { - *IsSplitted = TRUE; - } - if (IsModified != NULL) { - *IsModified = TRUE; - } - // - // Just split current page - // Convert success in next around - // - } - } - - return RETURN_SUCCESS; -} - -/** - FlushTlb on current processor. - - @param[in,out] Buffer Pointer to private data buffer. -**/ -VOID -EFIAPI -FlushTlbOnCurrentProcessor ( - IN OUT VOID *Buffer - ) -{ - CpuFlushTlb (); -} - -/** - FlushTlb for all processors. -**/ -VOID -FlushTlbForAll ( - VOID - ) -{ - UINTN Index; - - FlushTlbOnCurrentProcessor (NULL); - - for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { - if (Index != gSmst->CurrentlyExecutingCpu) { - // Force to start up AP in blocking mode, - SmmBlockingStartupThisAp (FlushTlbOnCurrentProcessor, Index, NULL); - // Do not check return status, because AP might not be present in some corner cases. - } - } -} - -/** - This function sets the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to set for the memory region. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - - @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmSetMemoryAttributesEx ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - OUT BOOLEAN *IsSplitted OPTIONAL - ) -{ - EFI_STATUS Status; - BOOLEAN IsModified; - - Status = ConvertMemoryPageAttributes (BaseAddress, Length, Attributes, TRUE, IsSplitted, &IsModified); - if (!EFI_ERROR(Status)) { - if (IsModified) { - // - // Flush TLB as last step - // - FlushTlbForAll(); - } - } - - return Status; -} - -/** - This function clears the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to clear for the memory region. - @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted. - - @retval EFI_SUCCESS The attributes were cleared for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmClearMemoryAttributesEx ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes, - OUT BOOLEAN *IsSplitted OPTIONAL - ) -{ - EFI_STATUS Status; - BOOLEAN IsModified; - - Status = ConvertMemoryPageAttributes (BaseAddress, Length, Attributes, FALSE, IsSplitted, &IsModified); - if (!EFI_ERROR(Status)) { - if (IsModified) { - // - // Flush TLB as last step - // - FlushTlbForAll(); - } - } - - return Status; -} - -/** - This function sets the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to set for the memory region. - - @retval EFI_SUCCESS The attributes were set for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmSetMemoryAttributes ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ) -{ - return SmmSetMemoryAttributesEx (BaseAddress, Length, Attributes, NULL); -} - -/** - This function clears the attributes for the memory region specified by BaseAddress and - Length from their current attributes to the attributes specified by Attributes. - - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - @param[in] Attributes The bit mask of attributes to clear for the memory region. - - @retval EFI_SUCCESS The attributes were cleared for the memory region. - @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by - BaseAddress and Length cannot be modified. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combination of attributes that - cannot be set together. - @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of - the memory resource range. - @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory - resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource - range specified by BaseAddress and Length. - -**/ -EFI_STATUS -EFIAPI -SmmClearMemoryAttributes ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN UINT64 Attributes - ) -{ - return SmmClearMemoryAttributesEx (BaseAddress, Length, Attributes, NULL); -} - - - -/** - Retrieves a pointer to the system configuration table from the SMM System Table - based on a specified GUID. - - @param[in] TableGuid The pointer to table's GUID type. - @param[out] Table The pointer to the table associated with TableGuid in the EFI System Table. - - @retval EFI_SUCCESS A configuration table matching TableGuid was found. - @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. - -**/ -EFI_STATUS -EFIAPI -SmmGetSystemConfigurationTable ( - IN EFI_GUID *TableGuid, - OUT VOID **Table - ) -{ - UINTN Index; - - ASSERT (TableGuid != NULL); - ASSERT (Table != NULL); - - *Table = NULL; - for (Index = 0; Index < gSmst->NumberOfTableEntries; Index++) { - if (CompareGuid (TableGuid, &(gSmst->SmmConfigurationTable[Index].VendorGuid))) { - *Table = gSmst->SmmConfigurationTable[Index].VendorTable; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** - This function sets SMM save state buffer to be RW and XP. -**/ -VOID -PatchSmmSaveStateMap ( - VOID - ) -{ - UINTN Index; - UINTN TileCodeSize; - UINTN TileDataSize; - UINTN TileSize; - - TileCodeSize = GetSmiHandlerSize (); - TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB); - TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP); - TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB); - TileSize = TileDataSize + TileCodeSize - 1; - TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize); - - DEBUG ((DEBUG_INFO, "PatchSmmSaveStateMap:\n")); - for (Index = 0; Index < mMaxNumberOfCpus - 1; Index++) { - // - // Code - // - SmmSetMemoryAttributes ( - mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET, - TileCodeSize, - EFI_MEMORY_RO - ); - SmmClearMemoryAttributes ( - mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET, - TileCodeSize, - EFI_MEMORY_XP - ); - - // - // Data - // - SmmClearMemoryAttributes ( - mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET + TileCodeSize, - TileSize - TileCodeSize, - EFI_MEMORY_RO - ); - SmmSetMemoryAttributes ( - mCpuHotPlugData.SmBase[Index] + SMM_HANDLER_OFFSET + TileCodeSize, - TileSize - TileCodeSize, - EFI_MEMORY_XP - ); - } - - // - // Code - // - SmmSetMemoryAttributes ( - mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET, - TileCodeSize, - EFI_MEMORY_RO - ); - SmmClearMemoryAttributes ( - mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET, - TileCodeSize, - EFI_MEMORY_XP - ); - - // - // Data - // - SmmClearMemoryAttributes ( - mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET + TileCodeSize, - SIZE_32KB - TileCodeSize, - EFI_MEMORY_RO - ); - SmmSetMemoryAttributes ( - mCpuHotPlugData.SmBase[mMaxNumberOfCpus - 1] + SMM_HANDLER_OFFSET + TileCodeSize, - SIZE_32KB - TileCodeSize, - EFI_MEMORY_XP - ); -} - -/** - This function sets memory attribute according to MemoryAttributesTable. -**/ -VOID -SetMemMapAttributes ( - VOID - ) -{ - EFI_MEMORY_DESCRIPTOR *MemoryMap; - EFI_MEMORY_DESCRIPTOR *MemoryMapStart; - UINTN MemoryMapEntryCount; - UINTN DescriptorSize; - UINTN Index; - EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable; - - SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable); - if (MemoryAttributesTable == NULL) { - DEBUG ((DEBUG_INFO, "MemoryAttributesTable - NULL\n")); - return ; - } - - DEBUG ((DEBUG_INFO, "MemoryAttributesTable:\n")); - DEBUG ((DEBUG_INFO, " Version - 0x%08x\n", MemoryAttributesTable->Version)); - DEBUG ((DEBUG_INFO, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries)); - DEBUG ((DEBUG_INFO, " DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize)); - - MemoryMapEntryCount = MemoryAttributesTable->NumberOfEntries; - DescriptorSize = MemoryAttributesTable->DescriptorSize; - MemoryMapStart = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1); - MemoryMap = MemoryMapStart; - for (Index = 0; Index < MemoryMapEntryCount; Index++) { - DEBUG ((DEBUG_INFO, "Entry (0x%x)\n", MemoryMap)); - DEBUG ((DEBUG_INFO, " Type - 0x%x\n", MemoryMap->Type)); - DEBUG ((DEBUG_INFO, " PhysicalStart - 0x%016lx\n", MemoryMap->PhysicalStart)); - DEBUG ((DEBUG_INFO, " VirtualStart - 0x%016lx\n", MemoryMap->VirtualStart)); - DEBUG ((DEBUG_INFO, " NumberOfPages - 0x%016lx\n", MemoryMap->NumberOfPages)); - DEBUG ((DEBUG_INFO, " Attribute - 0x%016lx\n", MemoryMap->Attribute)); - MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize); - } - - MemoryMap = MemoryMapStart; - for (Index = 0; Index < MemoryMapEntryCount; Index++) { - DEBUG ((DEBUG_VERBOSE, "SetAttribute: Memory Entry - 0x%lx, 0x%x\n", MemoryMap->PhysicalStart, MemoryMap->NumberOfPages)); - switch (MemoryMap->Type) { - case EfiRuntimeServicesCode: - SmmSetMemoryAttributes ( - MemoryMap->PhysicalStart, - EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), - EFI_MEMORY_RO - ); - break; - case EfiRuntimeServicesData: - SmmSetMemoryAttributes ( - MemoryMap->PhysicalStart, - EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), - EFI_MEMORY_XP - ); - break; - default: - SmmSetMemoryAttributes ( - MemoryMap->PhysicalStart, - EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), - EFI_MEMORY_XP - ); - break; - } - MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize); - } - - PatchSmmSaveStateMap (); - PatchGdtIdtMap (); - - return ; -} - -/** - Sort memory map entries based upon PhysicalStart, from low to high. - - @param MemoryMap A pointer to the buffer in which firmware places - the current memory map. - @param MemoryMapSize Size, in bytes, of the MemoryMap buffer. - @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. -**/ -STATIC -VOID -SortMemoryMap ( - IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, - IN UINTN MemoryMapSize, - IN UINTN DescriptorSize - ) -{ - EFI_MEMORY_DESCRIPTOR *MemoryMapEntry; - EFI_MEMORY_DESCRIPTOR *NextMemoryMapEntry; - EFI_MEMORY_DESCRIPTOR *MemoryMapEnd; - EFI_MEMORY_DESCRIPTOR TempMemoryMap; - - MemoryMapEntry = MemoryMap; - NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize); - while (MemoryMapEntry < MemoryMapEnd) { - while (NextMemoryMapEntry < MemoryMapEnd) { - if (MemoryMapEntry->PhysicalStart > NextMemoryMapEntry->PhysicalStart) { - CopyMem (&TempMemoryMap, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); - CopyMem (MemoryMapEntry, NextMemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); - CopyMem (NextMemoryMapEntry, &TempMemoryMap, sizeof(EFI_MEMORY_DESCRIPTOR)); - } - - NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); - } - - MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - } -} - -/** - Return if a UEFI memory page should be marked as not present in SMM page table. - If the memory map entries type is - EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, - EfiUnusableMemory, EfiACPIReclaimMemory, return TRUE. - Or return FALSE. - - @param[in] MemoryMap A pointer to the memory descriptor. - - @return TRUE The memory described will be marked as not present in SMM page table. - @return FALSE The memory described will not be marked as not present in SMM page table. -**/ -BOOLEAN -IsUefiPageNotPresent ( - IN EFI_MEMORY_DESCRIPTOR *MemoryMap - ) -{ - switch (MemoryMap->Type) { - case EfiLoaderCode: - case EfiLoaderData: - case EfiBootServicesCode: - case EfiBootServicesData: - case EfiConventionalMemory: - case EfiUnusableMemory: - case EfiACPIReclaimMemory: - return TRUE; - default: - return FALSE; - } -} - -/** - Merge continous memory map entries whose type is - EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, - EfiUnusableMemory, EfiACPIReclaimMemory, because the memory described by - these entries will be set as NOT present in SMM page table. - - @param[in, out] MemoryMap A pointer to the buffer in which firmware places - the current memory map. - @param[in, out] MemoryMapSize A pointer to the size, in bytes, of the - MemoryMap buffer. On input, this is the size of - the current memory map. On output, - it is the size of new memory map after merge. - @param[in] DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. -**/ -STATIC -VOID -MergeMemoryMapForNotPresentEntry ( - IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, - IN OUT UINTN *MemoryMapSize, - IN UINTN DescriptorSize - ) -{ - EFI_MEMORY_DESCRIPTOR *MemoryMapEntry; - EFI_MEMORY_DESCRIPTOR *MemoryMapEnd; - UINT64 MemoryBlockLength; - EFI_MEMORY_DESCRIPTOR *NewMemoryMapEntry; - EFI_MEMORY_DESCRIPTOR *NextMemoryMapEntry; - - MemoryMapEntry = MemoryMap; - NewMemoryMapEntry = MemoryMap; - MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + *MemoryMapSize); - while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) { - CopyMem (NewMemoryMapEntry, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR)); - NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - - do { - MemoryBlockLength = (UINT64) (EFI_PAGES_TO_SIZE((UINTN)MemoryMapEntry->NumberOfPages)); - if (((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) && - IsUefiPageNotPresent(MemoryMapEntry) && IsUefiPageNotPresent(NextMemoryMapEntry) && - ((MemoryMapEntry->PhysicalStart + MemoryBlockLength) == NextMemoryMapEntry->PhysicalStart)) { - MemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages; - if (NewMemoryMapEntry != MemoryMapEntry) { - NewMemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages; - } - - NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); - continue; - } else { - MemoryMapEntry = PREVIOUS_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize); - break; - } - } while (TRUE); - - MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - NewMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NewMemoryMapEntry, DescriptorSize); - } - - *MemoryMapSize = (UINTN)NewMemoryMapEntry - (UINTN)MemoryMap; - - return ; -} - -/** - This function caches the UEFI memory map information. -**/ -VOID -GetUefiMemoryMap ( - VOID - ) -{ - EFI_STATUS Status; - UINTN MapKey; - UINT32 DescriptorVersion; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN UefiMemoryMapSize; - - DEBUG ((DEBUG_INFO, "GetUefiMemoryMap\n")); - - UefiMemoryMapSize = 0; - MemoryMap = NULL; - Status = gBS->GetMemoryMap ( - &UefiMemoryMapSize, - MemoryMap, - &MapKey, - &mUefiDescriptorSize, - &DescriptorVersion - ); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - - do { - Status = gBS->AllocatePool (EfiBootServicesData, UefiMemoryMapSize, (VOID **)&MemoryMap); - ASSERT (MemoryMap != NULL); - if (MemoryMap == NULL) { - return ; - } - - Status = gBS->GetMemoryMap ( - &UefiMemoryMapSize, - MemoryMap, - &MapKey, - &mUefiDescriptorSize, - &DescriptorVersion - ); - if (EFI_ERROR (Status)) { - gBS->FreePool (MemoryMap); - MemoryMap = NULL; - } - } while (Status == EFI_BUFFER_TOO_SMALL); - - if (MemoryMap == NULL) { - return ; - } - - SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize); - MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize); - - mUefiMemoryMapSize = UefiMemoryMapSize; - mUefiMemoryMap = AllocateCopyPool (UefiMemoryMapSize, MemoryMap); - ASSERT (mUefiMemoryMap != NULL); - - gBS->FreePool (MemoryMap); -} - -/** - This function sets UEFI memory attribute according to UEFI memory map. - - The normal memory region is marked as not present, such as - EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, - EfiUnusableMemory, EfiACPIReclaimMemory. -**/ -VOID -SetUefiMemMapAttributes ( - VOID - ) -{ - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN MemoryMapEntryCount; - UINTN Index; - - DEBUG ((DEBUG_INFO, "SetUefiMemMapAttributes\n")); - - if (mUefiMemoryMap == NULL) { - DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n")); - return ; - } - - MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; - MemoryMap = mUefiMemoryMap; - for (Index = 0; Index < MemoryMapEntryCount; Index++) { - if (IsUefiPageNotPresent(MemoryMap)) { - DEBUG ((DEBUG_INFO, "UefiMemory protection: 0x%lx - 0x%lx\n", MemoryMap->PhysicalStart, MemoryMap->PhysicalStart + (UINT64)EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages))); - SmmSetMemoryAttributes ( - MemoryMap->PhysicalStart, - EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages), - EFI_MEMORY_RP - ); - } - MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize); - } - - // - // Do free mUefiMemoryMap, it will be checked in IsSmmCommBufferForbiddenAddress(). - // -} - -/** - Return if the Address is forbidden as SMM communication buffer. - - @param[in] Address the address to be checked - - @return TRUE The address is forbidden as SMM communication buffer. - @return FALSE The address is allowed as SMM communication buffer. -**/ -BOOLEAN -IsSmmCommBufferForbiddenAddress ( - IN UINT64 Address - ) -{ - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN MemoryMapEntryCount; - UINTN Index; - - if (mUefiMemoryMap == NULL) { - return FALSE; - } - - MemoryMap = mUefiMemoryMap; - MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize; - for (Index = 0; Index < MemoryMapEntryCount; Index++) { - if (IsUefiPageNotPresent (MemoryMap)) { - if ((Address >= MemoryMap->PhysicalStart) && - (Address < MemoryMap->PhysicalStart + EFI_PAGES_TO_SIZE((UINTN)MemoryMap->NumberOfPages)) ) { - return TRUE; - } - } - MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize); - } - return FALSE; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c deleted file mode 100644 index 2713b19dd2..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ /dev/null @@ -1,1440 +0,0 @@ -/** @file -Enable SMM profile. - -Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" -#include "SmmProfileInternal.h" - -UINT32 mSmmProfileCr3; - -SMM_PROFILE_HEADER *mSmmProfileBase; -MSR_DS_AREA_STRUCT *mMsrDsAreaBase; -// -// The buffer to store SMM profile data. -// -UINTN mSmmProfileSize; - -// -// The buffer to enable branch trace store. -// -UINTN mMsrDsAreaSize = SMM_PROFILE_DTS_SIZE; - -// -// The flag indicates if execute-disable is enabled on processor. -// -BOOLEAN mXdEnabled = FALSE; - -// -// The flag indicates if BTS is supported by processor. -// -BOOLEAN mBtsSupported = TRUE; - -// -// The flag indicates if SMM profile starts to record data. -// -BOOLEAN mSmmProfileStart = FALSE; - -// -// Record the page fault exception count for one instruction execution. -// -UINTN *mPFEntryCount; - -UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; -UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT]; - -MSR_DS_AREA_STRUCT **mMsrDsArea; -BRANCH_TRACE_RECORD **mMsrBTSRecord; -UINTN mBTSRecordNumber; -PEBS_RECORD **mMsrPEBSRecord; - -// -// These memory ranges are always present, they does not generate the access type of page fault exception, -// but they possibly generate instruction fetch type of page fault exception. -// -MEMORY_PROTECTION_RANGE *mProtectionMemRange = NULL; -UINTN mProtectionMemRangeCount = 0; - -// -// Some predefined memory ranges. -// -MEMORY_PROTECTION_RANGE mProtectionMemRangeTemplate[] = { - // - // SMRAM range (to be fixed in runtime). - // It is always present and instruction fetches are allowed. - // - {{0x00000000, 0x00000000},TRUE,FALSE}, - - // - // SMM profile data range( to be fixed in runtime). - // It is always present and instruction fetches are not allowed. - // - {{0x00000000, 0x00000000},TRUE,TRUE}, - - // - // SMRAM ranges not covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz (to be fixed in runtime). - // It is always present and instruction fetches are allowed. - // {{0x00000000, 0x00000000},TRUE,FALSE}, - // - - // - // Future extended range could be added here. - // - - // - // PCI MMIO ranges (to be added in runtime). - // They are always present and instruction fetches are not allowed. - // -}; - -// -// These memory ranges are mapped by 4KB-page instead of 2MB-page. -// -MEMORY_RANGE *mSplitMemRange = NULL; -UINTN mSplitMemRangeCount = 0; - -// -// SMI command port. -// -UINT32 mSmiCommandPort; - -/** - Disable branch trace store. - -**/ -VOID -DisableBTS ( - VOID - ) -{ - AsmMsrAnd64 (MSR_DEBUG_CTL, ~((UINT64)(MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR))); -} - -/** - Enable branch trace store. - -**/ -VOID -EnableBTS ( - VOID - ) -{ - AsmMsrOr64 (MSR_DEBUG_CTL, (MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR)); -} - -/** - Get CPU Index from APIC ID. - -**/ -UINTN -GetCpuIndex ( - VOID - ) -{ - UINTN Index; - UINT32 ApicId; - - ApicId = GetApicId (); - - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - if (gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId == ApicId) { - return Index; - } - } - ASSERT (FALSE); - return 0; -} - -/** - Get the source of IP after execute-disable exception is triggered. - - @param CpuIndex The index of CPU. - @param DestinationIP The destination address. - -**/ -UINT64 -GetSourceFromDestinationOnBts ( - UINTN CpuIndex, - UINT64 DestinationIP - ) -{ - BRANCH_TRACE_RECORD *CurrentBTSRecord; - UINTN Index; - BOOLEAN FirstMatch; - - FirstMatch = FALSE; - - CurrentBTSRecord = (BRANCH_TRACE_RECORD *)mMsrDsArea[CpuIndex]->BTSIndex; - for (Index = 0; Index < mBTSRecordNumber; Index++) { - if ((UINTN)CurrentBTSRecord < (UINTN)mMsrBTSRecord[CpuIndex]) { - // - // Underflow - // - CurrentBTSRecord = (BRANCH_TRACE_RECORD *)((UINTN)mMsrDsArea[CpuIndex]->BTSAbsoluteMaximum - 1); - CurrentBTSRecord --; - } - if (CurrentBTSRecord->LastBranchTo == DestinationIP) { - // - // Good! find 1st one, then find 2nd one. - // - if (!FirstMatch) { - // - // The first one is DEBUG exception - // - FirstMatch = TRUE; - } else { - // - // Good find proper one. - // - return CurrentBTSRecord->LastBranchFrom; - } - } - CurrentBTSRecord--; - } - - return 0; -} - -/** - SMM profile specific INT 1 (single-step) exception handler. - - @param InterruptType Defines the type of interrupt or exception that - occurred on the processor.This parameter is processor architecture specific. - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. -**/ -VOID -EFIAPI -DebugExceptionHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - UINTN CpuIndex; - UINTN PFEntry; - - if (!mSmmProfileStart) { - return; - } - CpuIndex = GetCpuIndex (); - - // - // Clear last PF entries - // - for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) { - *mLastPFEntryPointer[CpuIndex][PFEntry] = mLastPFEntryValue[CpuIndex][PFEntry]; - } - - // - // Reset page fault exception count for next page fault. - // - mPFEntryCount[CpuIndex] = 0; - - // - // Flush TLB - // - CpuFlushTlb (); - - // - // Clear TF in EFLAGS - // - ClearTrapFlag (SystemContext); -} - -/** - Check if the input address is in SMM ranges. - - @param[in] Address The input address. - - @retval TRUE The input address is in SMM. - @retval FALSE The input address is not in SMM. -**/ -BOOLEAN -IsInSmmRanges ( - IN EFI_PHYSICAL_ADDRESS Address - ) -{ - UINTN Index; - - if ((Address < mCpuHotPlugData.SmrrBase) || (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { - return TRUE; - } - for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { - if (Address >= mSmmCpuSmramRanges[Index].CpuStart && - Address < mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) { - return TRUE; - } - } - return FALSE; -} - -/** - Check if the memory address will be mapped by 4KB-page. - - @param Address The address of Memory. - @param Nx The flag indicates if the memory is execute-disable. - -**/ -BOOLEAN -IsAddressValid ( - IN EFI_PHYSICAL_ADDRESS Address, - IN BOOLEAN *Nx - ) -{ - UINTN Index; - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - // - // Check configuration - // - for (Index = 0; Index < mProtectionMemRangeCount; Index++) { - if ((Address >= mProtectionMemRange[Index].Range.Base) && (Address < mProtectionMemRange[Index].Range.Top)) { - *Nx = mProtectionMemRange[Index].Nx; - return mProtectionMemRange[Index].Present; - } - } - *Nx = TRUE; - return FALSE; - - } else { - *Nx = TRUE; - if (IsInSmmRanges (Address)) { - *Nx = FALSE; - } - return TRUE; - } -} - -/** - Check if the memory address will be mapped by 4KB-page. - - @param Address The address of Memory. - -**/ -BOOLEAN -IsAddressSplit ( - IN EFI_PHYSICAL_ADDRESS Address - ) -{ - UINTN Index; - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - // - // Check configuration - // - for (Index = 0; Index < mSplitMemRangeCount; Index++) { - if ((Address >= mSplitMemRange[Index].Base) && (Address < mSplitMemRange[Index].Top)) { - return TRUE; - } - } - } else { - if (Address < mCpuHotPlugData.SmrrBase) { - if ((mCpuHotPlugData.SmrrBase - Address) < BASE_2MB) { - return TRUE; - } - } else if (Address > (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) { - if ((Address - (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize - BASE_2MB)) < BASE_2MB) { - return TRUE; - } - } - } - // - // Return default - // - return FALSE; -} - -/** - Initialize the protected memory ranges and the 4KB-page mapped memory ranges. - -**/ -VOID -InitProtectedMemRange ( - VOID - ) -{ - UINTN Index; - UINTN NumberOfDescriptors; - UINTN NumberOfAddedDescriptors; - UINTN NumberOfProtectRange; - UINTN NumberOfSpliteRange; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; - UINTN TotalSize; - EFI_PHYSICAL_ADDRESS ProtectBaseAddress; - EFI_PHYSICAL_ADDRESS ProtectEndAddress; - EFI_PHYSICAL_ADDRESS Top2MBAlignedAddress; - EFI_PHYSICAL_ADDRESS Base2MBAlignedAddress; - UINT64 High4KBPageSize; - UINT64 Low4KBPageSize; - - NumberOfDescriptors = 0; - NumberOfAddedDescriptors = mSmmCpuSmramRangeCount; - NumberOfSpliteRange = 0; - MemorySpaceMap = NULL; - - // - // Get MMIO ranges from GCD and add them into protected memory ranges. - // - gDS->GetMemorySpaceMap ( - &NumberOfDescriptors, - &MemorySpaceMap - ); - for (Index = 0; Index < NumberOfDescriptors; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) { - NumberOfAddedDescriptors++; - } - } - - if (NumberOfAddedDescriptors != 0) { - TotalSize = NumberOfAddedDescriptors * sizeof (MEMORY_PROTECTION_RANGE) + sizeof (mProtectionMemRangeTemplate); - mProtectionMemRange = (MEMORY_PROTECTION_RANGE *) AllocateZeroPool (TotalSize); - ASSERT (mProtectionMemRange != NULL); - mProtectionMemRangeCount = TotalSize / sizeof (MEMORY_PROTECTION_RANGE); - - // - // Copy existing ranges. - // - CopyMem (mProtectionMemRange, mProtectionMemRangeTemplate, sizeof (mProtectionMemRangeTemplate)); - - // - // Create split ranges which come from protected ranges. - // - TotalSize = (TotalSize / sizeof (MEMORY_PROTECTION_RANGE)) * sizeof (MEMORY_RANGE); - mSplitMemRange = (MEMORY_RANGE *) AllocateZeroPool (TotalSize); - ASSERT (mSplitMemRange != NULL); - - // - // Create SMM ranges which are set to present and execution-enable. - // - NumberOfProtectRange = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE); - for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) { - if (mSmmCpuSmramRanges[Index].CpuStart >= mProtectionMemRange[0].Range.Base && - mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize < mProtectionMemRange[0].Range.Top) { - // - // If the address have been already covered by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz - // - break; - } - mProtectionMemRange[NumberOfProtectRange].Range.Base = mSmmCpuSmramRanges[Index].CpuStart; - mProtectionMemRange[NumberOfProtectRange].Range.Top = mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize; - mProtectionMemRange[NumberOfProtectRange].Present = TRUE; - mProtectionMemRange[NumberOfProtectRange].Nx = FALSE; - NumberOfProtectRange++; - } - - // - // Create MMIO ranges which are set to present and execution-disable. - // - for (Index = 0; Index < NumberOfDescriptors; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) { - continue; - } - mProtectionMemRange[NumberOfProtectRange].Range.Base = MemorySpaceMap[Index].BaseAddress; - mProtectionMemRange[NumberOfProtectRange].Range.Top = MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length; - mProtectionMemRange[NumberOfProtectRange].Present = TRUE; - mProtectionMemRange[NumberOfProtectRange].Nx = TRUE; - NumberOfProtectRange++; - } - - // - // Check and updated actual protected memory ranges count - // - ASSERT (NumberOfProtectRange <= mProtectionMemRangeCount); - mProtectionMemRangeCount = NumberOfProtectRange; - } - - // - // According to protected ranges, create the ranges which will be mapped by 2KB page. - // - NumberOfSpliteRange = 0; - NumberOfProtectRange = mProtectionMemRangeCount; - for (Index = 0; Index < NumberOfProtectRange; Index++) { - // - // If MMIO base address is not 2MB alignment, make 2MB alignment for create 4KB page in page table. - // - ProtectBaseAddress = mProtectionMemRange[Index].Range.Base; - ProtectEndAddress = mProtectionMemRange[Index].Range.Top; - if (((ProtectBaseAddress & (SIZE_2MB - 1)) != 0) || ((ProtectEndAddress & (SIZE_2MB - 1)) != 0)) { - // - // Check if it is possible to create 4KB-page for not 2MB-aligned range and to create 2MB-page for 2MB-aligned range. - // A mix of 4KB and 2MB page could save SMRAM space. - // - Top2MBAlignedAddress = ProtectEndAddress & ~(SIZE_2MB - 1); - Base2MBAlignedAddress = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); - if ((Top2MBAlignedAddress > Base2MBAlignedAddress) && - ((Top2MBAlignedAddress - Base2MBAlignedAddress) >= SIZE_2MB)) { - // - // There is an range which could be mapped by 2MB-page. - // - High4KBPageSize = ((ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectEndAddress & ~(SIZE_2MB - 1)); - Low4KBPageSize = ((ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1)) - (ProtectBaseAddress & ~(SIZE_2MB - 1)); - if (High4KBPageSize != 0) { - // - // Add not 2MB-aligned range to be mapped by 4KB-page. - // - mSplitMemRange[NumberOfSpliteRange].Base = ProtectEndAddress & ~(SIZE_2MB - 1); - mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); - NumberOfSpliteRange++; - } - if (Low4KBPageSize != 0) { - // - // Add not 2MB-aligned range to be mapped by 4KB-page. - // - mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1); - mSplitMemRange[NumberOfSpliteRange].Top = (ProtectBaseAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); - NumberOfSpliteRange++; - } - } else { - // - // The range could only be mapped by 4KB-page. - // - mSplitMemRange[NumberOfSpliteRange].Base = ProtectBaseAddress & ~(SIZE_2MB - 1); - mSplitMemRange[NumberOfSpliteRange].Top = (ProtectEndAddress + SIZE_2MB - 1) & ~(SIZE_2MB - 1); - NumberOfSpliteRange++; - } - } - } - - mSplitMemRangeCount = NumberOfSpliteRange; - - DEBUG ((EFI_D_INFO, "SMM Profile Memory Ranges:\n")); - for (Index = 0; Index < mProtectionMemRangeCount; Index++) { - DEBUG ((EFI_D_INFO, "mProtectionMemRange[%d].Base = %lx\n", Index, mProtectionMemRange[Index].Range.Base)); - DEBUG ((EFI_D_INFO, "mProtectionMemRange[%d].Top = %lx\n", Index, mProtectionMemRange[Index].Range.Top)); - } - for (Index = 0; Index < mSplitMemRangeCount; Index++) { - DEBUG ((EFI_D_INFO, "mSplitMemRange[%d].Base = %lx\n", Index, mSplitMemRange[Index].Base)); - DEBUG ((EFI_D_INFO, "mSplitMemRange[%d].Top = %lx\n", Index, mSplitMemRange[Index].Top)); - } -} - -/** - Update page table according to protected memory ranges and the 4KB-page mapped memory ranges. - -**/ -VOID -InitPaging ( - VOID - ) -{ - UINT64 *Pml4; - UINT64 *Pde; - UINT64 *Pte; - UINT64 *Pt; - UINTN Address; - UINTN Level1; - UINTN Level2; - UINTN Level3; - UINTN Level4; - UINTN NumberOfPdpEntries; - UINTN NumberOfPml4Entries; - UINTN SizeOfMemorySpace; - BOOLEAN Nx; - - if (sizeof (UINTN) == sizeof (UINT64)) { - Pml4 = (UINT64*)(UINTN)mSmmProfileCr3; - SizeOfMemorySpace = HighBitSet64 (gPhyMask) + 1; - // - // Calculate the table entries of PML4E and PDPTE. - // - if (SizeOfMemorySpace <= 39 ) { - NumberOfPml4Entries = 1; - NumberOfPdpEntries = (UINT32)LShiftU64 (1, (SizeOfMemorySpace - 30)); - } else { - NumberOfPml4Entries = (UINT32)LShiftU64 (1, (SizeOfMemorySpace - 39)); - NumberOfPdpEntries = 512; - } - } else { - NumberOfPml4Entries = 1; - NumberOfPdpEntries = 4; - } - - // - // Go through page table and change 2MB-page into 4KB-page. - // - for (Level1 = 0; Level1 < NumberOfPml4Entries; Level1++) { - if (sizeof (UINTN) == sizeof (UINT64)) { - if ((Pml4[Level1] & IA32_PG_P) == 0) { - // - // If Pml4 entry does not exist, skip it - // - continue; - } - Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - } else { - Pde = (UINT64*)(UINTN)mSmmProfileCr3; - } - for (Level2 = 0; Level2 < NumberOfPdpEntries; Level2++, Pde++) { - if ((*Pde & IA32_PG_P) == 0) { - // - // If PDE entry does not exist, skip it - // - continue; - } - if ((*Pde & IA32_PG_PS) != 0) { - // - // This is 1G entry, skip it - // - continue; - } - Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - if (Pte == 0) { - continue; - } - for (Level3 = 0; Level3 < SIZE_4KB / sizeof (*Pte); Level3++, Pte++) { - if ((*Pte & IA32_PG_P) == 0) { - // - // If PTE entry does not exist, skip it - // - continue; - } - Address = (((Level2 << 9) + Level3) << 21); - - // - // If it is 2M page, check IsAddressSplit() - // - if (((*Pte & IA32_PG_PS) != 0) && IsAddressSplit (Address)) { - // - // Based on current page table, create 4KB page table for split area. - // - ASSERT (Address == (*Pte & PHYSICAL_ADDRESS_MASK)); - - Pt = AllocatePageTableMemory (1); - ASSERT (Pt != NULL); - - // Split it - for (Level4 = 0; Level4 < SIZE_4KB / sizeof(*Pt); Level4++) { - Pt[Level4] = Address + ((Level4 << 12) | mAddressEncMask | PAGE_ATTRIBUTE_BITS); - } // end for PT - *Pte = (UINT64)(UINTN)Pt | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - } // end if IsAddressSplit - } // end for PTE - } // end for PDE - } - - // - // Go through page table and set several page table entries to absent or execute-disable. - // - DEBUG ((EFI_D_INFO, "Patch page table start ...\n")); - for (Level1 = 0; Level1 < NumberOfPml4Entries; Level1++) { - if (sizeof (UINTN) == sizeof (UINT64)) { - if ((Pml4[Level1] & IA32_PG_P) == 0) { - // - // If Pml4 entry does not exist, skip it - // - continue; - } - Pde = (UINT64 *)(UINTN)(Pml4[Level1] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - } else { - Pde = (UINT64*)(UINTN)mSmmProfileCr3; - } - for (Level2 = 0; Level2 < NumberOfPdpEntries; Level2++, Pde++) { - if ((*Pde & IA32_PG_P) == 0) { - // - // If PDE entry does not exist, skip it - // - continue; - } - if ((*Pde & IA32_PG_PS) != 0) { - // - // This is 1G entry, set NX bit and skip it - // - if (mXdSupported) { - *Pde = *Pde | IA32_PG_NX; - } - continue; - } - Pte = (UINT64 *)(UINTN)(*Pde & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - if (Pte == 0) { - continue; - } - for (Level3 = 0; Level3 < SIZE_4KB / sizeof (*Pte); Level3++, Pte++) { - if ((*Pte & IA32_PG_P) == 0) { - // - // If PTE entry does not exist, skip it - // - continue; - } - Address = (((Level2 << 9) + Level3) << 21); - - if ((*Pte & IA32_PG_PS) != 0) { - // 2MB page - - if (!IsAddressValid (Address, &Nx)) { - // - // Patch to remove Present flag and RW flag - // - *Pte = *Pte & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); - } - if (Nx && mXdSupported) { - *Pte = *Pte | IA32_PG_NX; - } - } else { - // 4KB page - Pt = (UINT64 *)(UINTN)(*Pte & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - if (Pt == 0) { - continue; - } - for (Level4 = 0; Level4 < SIZE_4KB / sizeof(*Pt); Level4++, Pt++) { - if (!IsAddressValid (Address, &Nx)) { - *Pt = *Pt & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); - } - if (Nx && mXdSupported) { - *Pt = *Pt | IA32_PG_NX; - } - Address += SIZE_4KB; - } // end for PT - } // end if PS - } // end for PTE - } // end for PDE - } - - // - // Flush TLB - // - CpuFlushTlb (); - DEBUG ((EFI_D_INFO, "Patch page table done!\n")); - // - // Set execute-disable flag - // - mXdEnabled = TRUE; - - return ; -} - -/** - To find FADT in ACPI tables. - - @param AcpiTableGuid The GUID used to find ACPI table in UEFI ConfigurationTable. - - @return FADT table pointer. -**/ -EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE * -FindAcpiFadtTableByAcpiGuid ( - IN EFI_GUID *AcpiTableGuid - ) -{ - EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; - EFI_ACPI_DESCRIPTION_HEADER *Rsdt; - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; - UINTN Index; - UINT32 Data32; - Rsdp = NULL; - Rsdt = NULL; - Fadt = NULL; - // - // found ACPI table RSD_PTR from system table - // - for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { - if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), AcpiTableGuid)) { - // - // A match was found. - // - Rsdp = gST->ConfigurationTable[Index].VendorTable; - break; - } - } - - if (Rsdp == NULL) { - return NULL; - } - - Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress; - if (Rsdt == NULL || Rsdt->Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { - return NULL; - } - - for (Index = sizeof (EFI_ACPI_DESCRIPTION_HEADER); Index < Rsdt->Length; Index = Index + sizeof (UINT32)) { - - Data32 = *(UINT32 *) ((UINT8 *) Rsdt + Index); - Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) (UINT32 *) (UINTN) Data32; - if (Fadt->Header.Signature == EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { - break; - } - } - - if (Fadt == NULL || Fadt->Header.Signature != EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { - return NULL; - } - - return Fadt; -} - -/** - To find FADT in ACPI tables. - - @return FADT table pointer. -**/ -EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE * -FindAcpiFadtTable ( - VOID - ) -{ - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; - - Fadt = FindAcpiFadtTableByAcpiGuid (&gEfiAcpi20TableGuid); - if (Fadt != NULL) { - return Fadt; - } - - return FindAcpiFadtTableByAcpiGuid (&gEfiAcpi10TableGuid); -} - -/** - To get system port address of the SMI Command Port in FADT table. - -**/ -VOID -GetSmiCommandPort ( - VOID - ) -{ - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; - - Fadt = FindAcpiFadtTable (); - ASSERT (Fadt != NULL); - - mSmiCommandPort = Fadt->SmiCmd; - DEBUG ((EFI_D_INFO, "mSmiCommandPort = %x\n", mSmiCommandPort)); -} - -/** - Updates page table to make some memory ranges (like system memory) absent - and make some memory ranges (like MMIO) present and execute disable. It also - update 2MB-page to 4KB-page for some memory ranges. - -**/ -VOID -SmmProfileStart ( - VOID - ) -{ - // - // The flag indicates SMM profile starts to work. - // - mSmmProfileStart = TRUE; -} - -/** - Initialize SMM profile in SmmReadyToLock protocol callback function. - - @param Protocol Points to the protocol's unique identifier. - @param Interface Points to the interface instance. - @param Handle The handle on which the interface was installed. - - @retval EFI_SUCCESS SmmReadyToLock protocol callback runs successfully. -**/ -EFI_STATUS -EFIAPI -InitSmmProfileCallBack ( - IN CONST EFI_GUID *Protocol, - IN VOID *Interface, - IN EFI_HANDLE Handle - ) -{ - // - // Save to variable so that SMM profile data can be found. - // - gRT->SetVariable ( - SMM_PROFILE_NAME, - &gEfiCallerIdGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof(mSmmProfileBase), - &mSmmProfileBase - ); - - // - // Get Software SMI from FADT - // - GetSmiCommandPort (); - - // - // Initialize protected memory range for patching page table later. - // - InitProtectedMemRange (); - - return EFI_SUCCESS; -} - -/** - Initialize SMM profile data structures. - -**/ -VOID -InitSmmProfileInternal ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Base; - VOID *Registration; - UINTN Index; - UINTN MsrDsAreaSizePerCpu; - UINTN TotalSize; - - mPFEntryCount = (UINTN *)AllocateZeroPool (sizeof (UINTN) * mMaxNumberOfCpus); - ASSERT (mPFEntryCount != NULL); - mLastPFEntryValue = (UINT64 (*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool ( - sizeof (mLastPFEntryValue[0]) * mMaxNumberOfCpus); - ASSERT (mLastPFEntryValue != NULL); - mLastPFEntryPointer = (UINT64 *(*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool ( - sizeof (mLastPFEntryPointer[0]) * mMaxNumberOfCpus); - ASSERT (mLastPFEntryPointer != NULL); - - // - // Allocate memory for SmmProfile below 4GB. - // The base address - // - mSmmProfileSize = PcdGet32 (PcdCpuSmmProfileSize); - ASSERT ((mSmmProfileSize & 0xFFF) == 0); - - if (mBtsSupported) { - TotalSize = mSmmProfileSize + mMsrDsAreaSize; - } else { - TotalSize = mSmmProfileSize; - } - - Base = 0xFFFFFFFF; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (TotalSize), - &Base - ); - ASSERT_EFI_ERROR (Status); - ZeroMem ((VOID *)(UINTN)Base, TotalSize); - mSmmProfileBase = (SMM_PROFILE_HEADER *)(UINTN)Base; - - // - // Initialize SMM profile data header. - // - mSmmProfileBase->HeaderSize = sizeof (SMM_PROFILE_HEADER); - mSmmProfileBase->MaxDataEntries = (UINT64)((mSmmProfileSize - sizeof(SMM_PROFILE_HEADER)) / sizeof (SMM_PROFILE_ENTRY)); - mSmmProfileBase->MaxDataSize = MultU64x64 (mSmmProfileBase->MaxDataEntries, sizeof(SMM_PROFILE_ENTRY)); - mSmmProfileBase->CurDataEntries = 0; - mSmmProfileBase->CurDataSize = 0; - mSmmProfileBase->TsegStart = mCpuHotPlugData.SmrrBase; - mSmmProfileBase->TsegSize = mCpuHotPlugData.SmrrSize; - mSmmProfileBase->NumSmis = 0; - mSmmProfileBase->NumCpus = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - - if (mBtsSupported) { - mMsrDsArea = (MSR_DS_AREA_STRUCT **)AllocateZeroPool (sizeof (MSR_DS_AREA_STRUCT *) * mMaxNumberOfCpus); - ASSERT (mMsrDsArea != NULL); - mMsrBTSRecord = (BRANCH_TRACE_RECORD **)AllocateZeroPool (sizeof (BRANCH_TRACE_RECORD *) * mMaxNumberOfCpus); - ASSERT (mMsrBTSRecord != NULL); - mMsrPEBSRecord = (PEBS_RECORD **)AllocateZeroPool (sizeof (PEBS_RECORD *) * mMaxNumberOfCpus); - ASSERT (mMsrPEBSRecord != NULL); - - mMsrDsAreaBase = (MSR_DS_AREA_STRUCT *)((UINTN)Base + mSmmProfileSize); - MsrDsAreaSizePerCpu = mMsrDsAreaSize / mMaxNumberOfCpus; - mBTSRecordNumber = (MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER - sizeof(MSR_DS_AREA_STRUCT)) / sizeof(BRANCH_TRACE_RECORD); - for (Index = 0; Index < mMaxNumberOfCpus; Index++) { - mMsrDsArea[Index] = (MSR_DS_AREA_STRUCT *)((UINTN)mMsrDsAreaBase + MsrDsAreaSizePerCpu * Index); - mMsrBTSRecord[Index] = (BRANCH_TRACE_RECORD *)((UINTN)mMsrDsArea[Index] + sizeof(MSR_DS_AREA_STRUCT)); - mMsrPEBSRecord[Index] = (PEBS_RECORD *)((UINTN)mMsrDsArea[Index] + MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER); - - mMsrDsArea[Index]->BTSBufferBase = (UINTN)mMsrBTSRecord[Index]; - mMsrDsArea[Index]->BTSIndex = mMsrDsArea[Index]->BTSBufferBase; - mMsrDsArea[Index]->BTSAbsoluteMaximum = mMsrDsArea[Index]->BTSBufferBase + mBTSRecordNumber * sizeof(BRANCH_TRACE_RECORD) + 1; - mMsrDsArea[Index]->BTSInterruptThreshold = mMsrDsArea[Index]->BTSAbsoluteMaximum + 1; - - mMsrDsArea[Index]->PEBSBufferBase = (UINTN)mMsrPEBSRecord[Index]; - mMsrDsArea[Index]->PEBSIndex = mMsrDsArea[Index]->PEBSBufferBase; - mMsrDsArea[Index]->PEBSAbsoluteMaximum = mMsrDsArea[Index]->PEBSBufferBase + PEBS_RECORD_NUMBER * sizeof(PEBS_RECORD) + 1; - mMsrDsArea[Index]->PEBSInterruptThreshold = mMsrDsArea[Index]->PEBSAbsoluteMaximum + 1; - } - } - - mProtectionMemRange = mProtectionMemRangeTemplate; - mProtectionMemRangeCount = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE); - - // - // Update TSeg entry. - // - mProtectionMemRange[0].Range.Base = mCpuHotPlugData.SmrrBase; - mProtectionMemRange[0].Range.Top = mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize; - - // - // Update SMM profile entry. - // - mProtectionMemRange[1].Range.Base = (EFI_PHYSICAL_ADDRESS)(UINTN)mSmmProfileBase; - mProtectionMemRange[1].Range.Top = (EFI_PHYSICAL_ADDRESS)(UINTN)mSmmProfileBase + TotalSize; - - // - // Allocate memory reserved for creating 4KB pages. - // - InitPagesForPFHandler (); - - // - // Start SMM profile when SmmReadyToLock protocol is installed. - // - Status = gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, - InitSmmProfileCallBack, - &Registration - ); - ASSERT_EFI_ERROR (Status); - - return ; -} - -/** - Check if XD feature is supported by a processor. - -**/ -VOID -CheckFeatureSupported ( - VOID - ) -{ - UINT32 RegEax; - UINT32 RegEdx; - MSR_IA32_MISC_ENABLE_REGISTER MiscEnableMsr; - - if (mXdSupported) { - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax <= CPUID_EXTENDED_FUNCTION) { - // - // Extended CPUID functions are not supported on this processor. - // - mXdSupported = FALSE; - } - - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & CPUID1_EDX_XD_SUPPORT) == 0) { - // - // Execute Disable Bit feature is not supported on this processor. - // - mXdSupported = FALSE; - } - } - - if (mBtsSupported) { - AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & CPUID1_EDX_BTS_AVAILABLE) != 0) { - // - // Per IA32 manuals: - // When CPUID.1:EDX[21] is set, the following BTS facilities are available: - // 1. The BTS_UNAVAILABLE flag in the IA32_MISC_ENABLE MSR indicates the - // availability of the BTS facilities, including the ability to set the BTS and - // BTINT bits in the MSR_DEBUGCTLA MSR. - // 2. The IA32_DS_AREA MSR can be programmed to point to the DS save area. - // - MiscEnableMsr.Uint64 = AsmReadMsr64 (MSR_IA32_MISC_ENABLE); - if (MiscEnableMsr.Bits.BTS == 1) { - // - // BTS facilities is not supported if MSR_IA32_MISC_ENABLE.BTS bit is set. - // - mBtsSupported = FALSE; - } - } - } -} - -/** - Enable single step. - -**/ -VOID -ActivateSingleStepDB ( - VOID - ) -{ - UINTN Dr6; - - Dr6 = AsmReadDr6 (); - if ((Dr6 & DR6_SINGLE_STEP) != 0) { - return; - } - Dr6 |= DR6_SINGLE_STEP; - AsmWriteDr6 (Dr6); -} - -/** - Enable last branch. - -**/ -VOID -ActivateLBR ( - VOID - ) -{ - UINT64 DebugCtl; - - DebugCtl = AsmReadMsr64 (MSR_DEBUG_CTL); - if ((DebugCtl & MSR_DEBUG_CTL_LBR) != 0) { - return ; - } - DebugCtl |= MSR_DEBUG_CTL_LBR; - AsmWriteMsr64 (MSR_DEBUG_CTL, DebugCtl); -} - -/** - Enable branch trace store. - - @param CpuIndex The index of the processor. - -**/ -VOID -ActivateBTS ( - IN UINTN CpuIndex - ) -{ - UINT64 DebugCtl; - - DebugCtl = AsmReadMsr64 (MSR_DEBUG_CTL); - if ((DebugCtl & MSR_DEBUG_CTL_BTS) != 0) { - return ; - } - - AsmWriteMsr64 (MSR_DS_AREA, (UINT64)(UINTN)mMsrDsArea[CpuIndex]); - DebugCtl |= (UINT64)(MSR_DEBUG_CTL_BTS | MSR_DEBUG_CTL_TR); - DebugCtl &= ~((UINT64)MSR_DEBUG_CTL_BTINT); - AsmWriteMsr64 (MSR_DEBUG_CTL, DebugCtl); -} - -/** - Increase SMI number in each SMI entry. - -**/ -VOID -SmmProfileRecordSmiNum ( - VOID - ) -{ - if (mSmmProfileStart) { - mSmmProfileBase->NumSmis++; - } -} - -/** - Initialize processor environment for SMM profile. - - @param CpuIndex The index of the processor. - -**/ -VOID -ActivateSmmProfile ( - IN UINTN CpuIndex - ) -{ - // - // Enable Single Step DB# - // - ActivateSingleStepDB (); - - if (mBtsSupported) { - // - // We can not get useful information from LER, so we have to use BTS. - // - ActivateLBR (); - - // - // Enable BTS - // - ActivateBTS (CpuIndex); - } -} - -/** - Initialize SMM profile in SMM CPU entry point. - - @param[in] Cr3 The base address of the page tables to use in SMM. - -**/ -VOID -InitSmmProfile ( - UINT32 Cr3 - ) -{ - // - // Save Cr3 - // - mSmmProfileCr3 = Cr3; - - // - // Skip SMM profile initialization if feature is disabled - // - if (!FeaturePcdGet (PcdCpuSmmProfileEnable)) { - return; - } - - // - // Initialize SmmProfile here - // - InitSmmProfileInternal (); - - // - // Initialize profile IDT. - // - InitIdtr (); -} - -/** - Update page table to map the memory correctly in order to make the instruction - which caused page fault execute successfully. And it also save the original page - table to be restored in single-step exception. - - @param PageTable PageTable Address. - @param PFAddress The memory address which caused page fault exception. - @param CpuIndex The index of the processor. - @param ErrorCode The Error code of exception. - -**/ -VOID -RestorePageTableBelow4G ( - UINT64 *PageTable, - UINT64 PFAddress, - UINTN CpuIndex, - UINTN ErrorCode - ) -{ - UINTN PTIndex; - UINTN PFIndex; - - // - // PML4 - // - if (sizeof(UINT64) == sizeof(UINTN)) { - PTIndex = (UINTN)BitFieldRead64 (PFAddress, 39, 47); - ASSERT (PageTable[PTIndex] != 0); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); - } - - // - // PDPTE - // - PTIndex = (UINTN)BitFieldRead64 (PFAddress, 30, 38); - ASSERT (PageTable[PTIndex] != 0); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); - - // - // PD - // - PTIndex = (UINTN)BitFieldRead64 (PFAddress, 21, 29); - if ((PageTable[PTIndex] & IA32_PG_PS) != 0) { - // - // Large page - // - - // - // Record old entries with non-present status - // Old entries include the memory which instruction is at and the memory which instruction access. - // - // - ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); - if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { - PFIndex = mPFEntryCount[CpuIndex]; - mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; - mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; - mPFEntryCount[CpuIndex]++; - } - - // - // Set new entry - // - PageTable[PTIndex] = (PFAddress & ~((1ull << 21) - 1)); - PageTable[PTIndex] |= (UINT64)IA32_PG_PS; - PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS; - if ((ErrorCode & IA32_PF_EC_ID) != 0) { - PageTable[PTIndex] &= ~IA32_PG_NX; - } - } else { - // - // Small page - // - ASSERT (PageTable[PTIndex] != 0); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & PHYSICAL_ADDRESS_MASK); - - // - // 4K PTE - // - PTIndex = (UINTN)BitFieldRead64 (PFAddress, 12, 20); - - // - // Record old entries with non-present status - // Old entries include the memory which instruction is at and the memory which instruction access. - // - // - ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); - if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { - PFIndex = mPFEntryCount[CpuIndex]; - mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; - mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; - mPFEntryCount[CpuIndex]++; - } - - // - // Set new entry - // - PageTable[PTIndex] = (PFAddress & ~((1ull << 12) - 1)); - PageTable[PTIndex] |= (UINT64)PAGE_ATTRIBUTE_BITS; - if ((ErrorCode & IA32_PF_EC_ID) != 0) { - PageTable[PTIndex] &= ~IA32_PG_NX; - } - } -} - -/** - The Page fault handler to save SMM profile data. - - @param Rip The RIP when exception happens. - @param ErrorCode The Error code of exception. - -**/ -VOID -SmmProfilePFHandler ( - UINTN Rip, - UINTN ErrorCode - ) -{ - UINT64 *PageTable; - UINT64 PFAddress; - UINTN CpuIndex; - UINTN Index; - UINT64 InstructionAddress; - UINTN MaxEntryNumber; - UINTN CurrentEntryNumber; - BOOLEAN IsValidPFAddress; - SMM_PROFILE_ENTRY *SmmProfileEntry; - UINT64 SmiCommand; - EFI_STATUS Status; - UINT8 SoftSmiValue; - EFI_SMM_SAVE_STATE_IO_INFO IoInfo; - - if (!mSmmProfileStart) { - // - // If SMM profile does not start, call original page fault handler. - // - SmiDefaultPFHandler (); - return; - } - - if (mBtsSupported) { - DisableBTS (); - } - - IsValidPFAddress = FALSE; - PageTable = (UINT64 *)AsmReadCr3 (); - PFAddress = AsmReadCr2 (); - CpuIndex = GetCpuIndex (); - - if (PFAddress <= 0xFFFFFFFF) { - RestorePageTableBelow4G (PageTable, PFAddress, CpuIndex, ErrorCode); - } else { - RestorePageTableAbove4G (PageTable, PFAddress, CpuIndex, ErrorCode, &IsValidPFAddress); - } - - if (!IsValidPFAddress) { - InstructionAddress = Rip; - if ((ErrorCode & IA32_PF_EC_ID) != 0 && (mBtsSupported)) { - // - // If it is instruction fetch failure, get the correct IP from BTS. - // - InstructionAddress = GetSourceFromDestinationOnBts (CpuIndex, Rip); - if (InstructionAddress == 0) { - // - // It indicates the instruction which caused page fault is not a jump instruction, - // set instruction address same as the page fault address. - // - InstructionAddress = PFAddress; - } - } - - // - // Indicate it is not software SMI - // - SmiCommand = 0xFFFFFFFFFFFFFFFFULL; - for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { - Status = SmmReadSaveState(&mSmmCpu, sizeof(IoInfo), EFI_SMM_SAVE_STATE_REGISTER_IO, Index, &IoInfo); - if (EFI_ERROR (Status)) { - continue; - } - if (IoInfo.IoPort == mSmiCommandPort) { - // - // A software SMI triggered by SMI command port has been found, get SmiCommand from SMI command port. - // - SoftSmiValue = IoRead8 (mSmiCommandPort); - SmiCommand = (UINT64)SoftSmiValue; - break; - } - } - - SmmProfileEntry = (SMM_PROFILE_ENTRY *)(UINTN)(mSmmProfileBase + 1); - // - // Check if there is already a same entry in profile data. - // - for (Index = 0; Index < (UINTN) mSmmProfileBase->CurDataEntries; Index++) { - if ((SmmProfileEntry[Index].ErrorCode == (UINT64)ErrorCode) && - (SmmProfileEntry[Index].Address == PFAddress) && - (SmmProfileEntry[Index].CpuNum == (UINT64)CpuIndex) && - (SmmProfileEntry[Index].Instruction == InstructionAddress) && - (SmmProfileEntry[Index].SmiCmd == SmiCommand)) { - // - // Same record exist, need not save again. - // - break; - } - } - if (Index == mSmmProfileBase->CurDataEntries) { - CurrentEntryNumber = (UINTN) mSmmProfileBase->CurDataEntries; - MaxEntryNumber = (UINTN) mSmmProfileBase->MaxDataEntries; - if (FeaturePcdGet (PcdCpuSmmProfileRingBuffer)) { - CurrentEntryNumber = CurrentEntryNumber % MaxEntryNumber; - } - if (CurrentEntryNumber < MaxEntryNumber) { - // - // Log the new entry - // - SmmProfileEntry[CurrentEntryNumber].SmiNum = mSmmProfileBase->NumSmis; - SmmProfileEntry[CurrentEntryNumber].ErrorCode = (UINT64)ErrorCode; - SmmProfileEntry[CurrentEntryNumber].ApicId = (UINT64)GetApicId (); - SmmProfileEntry[CurrentEntryNumber].CpuNum = (UINT64)CpuIndex; - SmmProfileEntry[CurrentEntryNumber].Address = PFAddress; - SmmProfileEntry[CurrentEntryNumber].Instruction = InstructionAddress; - SmmProfileEntry[CurrentEntryNumber].SmiCmd = SmiCommand; - // - // Update current entry index and data size in the header. - // - mSmmProfileBase->CurDataEntries++; - mSmmProfileBase->CurDataSize = MultU64x64 (mSmmProfileBase->CurDataEntries, sizeof (SMM_PROFILE_ENTRY)); - } - } - } - // - // Flush TLB - // - CpuFlushTlb (); - - if (mBtsSupported) { - EnableBTS (); - } -} - -/** - Replace INT1 exception handler to restore page table to absent/execute-disable state - in order to trigger page fault again to save SMM profile data.. - -**/ -VOID -InitIdtr ( - VOID - ) -{ - EFI_STATUS Status; - - Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_DEBUG, DebugExceptionHandler); - ASSERT_EFI_ERROR (Status); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h deleted file mode 100644 index 04a3dfb2e8..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h +++ /dev/null @@ -1,126 +0,0 @@ -/** @file -SMM profile header file. - -Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_PROFILE_H_ -#define _SMM_PROFILE_H_ - -#include "SmmProfileInternal.h" - -// -// External functions -// - -/** - Initialize processor environment for SMM profile. - - @param CpuIndex The index of the processor. - -**/ -VOID -ActivateSmmProfile ( - IN UINTN CpuIndex - ); - -/** - Initialize SMM profile in SMM CPU entry point. - - @param[in] Cr3 The base address of the page tables to use in SMM. - -**/ -VOID -InitSmmProfile ( - UINT32 Cr3 - ); - -/** - Increase SMI number in each SMI entry. - -**/ -VOID -SmmProfileRecordSmiNum ( - VOID - ); - -/** - The Page fault handler to save SMM profile data. - - @param Rip The RIP when exception happens. - @param ErrorCode The Error code of exception. - -**/ -VOID -SmmProfilePFHandler ( - UINTN Rip, - UINTN ErrorCode - ); - -/** - Updates page table to make some memory ranges (like system memory) absent - and make some memory ranges (like MMIO) present and execute disable. It also - update 2MB-page to 4KB-page for some memory ranges. - -**/ -VOID -SmmProfileStart ( - VOID - ); - -/** - Page fault IDT handler for SMM Profile. - -**/ -VOID -EFIAPI -PageFaultIdtHandlerSmmProfile ( - VOID - ); - - -/** - Check if XD feature is supported by a processor. - -**/ -VOID -CheckFeatureSupported ( - VOID - ); - -/** - Update page table according to protected memory ranges and the 4KB-page mapped memory ranges. - -**/ -VOID -InitPaging ( - VOID - ); - -/** - Get CPU Index from APIC ID. - -**/ -UINTN -GetCpuIndex ( - VOID - ); - -// -// The flag indicates if execute-disable is supported by processor. -// -extern BOOLEAN mXdSupported; -// -// The flag indicates if execute-disable is enabled on processor. -// -extern BOOLEAN mXdEnabled; - -#endif // _SMM_PROFILE_H_ diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h deleted file mode 100644 index a21689145b..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h +++ /dev/null @@ -1,165 +0,0 @@ -/** @file -SMM profile internal header file. - -Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_PROFILE_INTERNAL_H_ -#define _SMM_PROFILE_INTERNAL_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include "SmmProfileArch.h" - -// -// Configure the SMM_PROFILE DTS region size -// -#define SMM_PROFILE_DTS_SIZE (4 * 1024 * 1024) // 4M - -#define MAX_PF_PAGE_COUNT 0x2 - -#define PEBS_RECORD_NUMBER 0x2 - -#define MAX_PF_ENTRY_COUNT 10 - -// -// This MACRO just enable unit test for the profile -// Please disable it. -// - -#define IA32_PF_EC_ID (1u << 4) - -#define SMM_PROFILE_NAME L"SmmProfileData" - -// -// CPU generic definition -// -#define CPUID1_EDX_XD_SUPPORT 0x100000 -#define MSR_EFER 0xc0000080 -#define MSR_EFER_XD 0x800 - -#define CPUID1_EDX_BTS_AVAILABLE 0x200000 - -#define DR6_SINGLE_STEP 0x4000 -#define RFLAG_TF 0x100 - -#define MSR_DEBUG_CTL 0x1D9 -#define MSR_DEBUG_CTL_LBR 0x1 -#define MSR_DEBUG_CTL_TR 0x40 -#define MSR_DEBUG_CTL_BTS 0x80 -#define MSR_DEBUG_CTL_BTINT 0x100 -#define MSR_DS_AREA 0x600 - -typedef struct { - EFI_PHYSICAL_ADDRESS Base; - EFI_PHYSICAL_ADDRESS Top; -} MEMORY_RANGE; - -typedef struct { - MEMORY_RANGE Range; - BOOLEAN Present; - BOOLEAN Nx; -} MEMORY_PROTECTION_RANGE; - -typedef struct { - UINT64 HeaderSize; - UINT64 MaxDataEntries; - UINT64 MaxDataSize; - UINT64 CurDataEntries; - UINT64 CurDataSize; - UINT64 TsegStart; - UINT64 TsegSize; - UINT64 NumSmis; - UINT64 NumCpus; -} SMM_PROFILE_HEADER; - -typedef struct { - UINT64 SmiNum; - UINT64 CpuNum; - UINT64 ApicId; - UINT64 ErrorCode; - UINT64 Instruction; - UINT64 Address; - UINT64 SmiCmd; -} SMM_PROFILE_ENTRY; - -extern SMM_S3_RESUME_STATE *mSmmS3ResumeState; -extern UINTN gSmiExceptionHandlers[]; -extern BOOLEAN mXdSupported; -extern UINTN *mPFEntryCount; -extern UINT64 (*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; -extern UINT64 *(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT]; - -// -// Internal functions -// - -/** - Update IDT table to replace page fault handler and INT 1 handler. - -**/ -VOID -InitIdtr ( - VOID - ); - -/** - Check if the memory address will be mapped by 4KB-page. - - @param Address The address of Memory. - -**/ -BOOLEAN -IsAddressSplit ( - IN EFI_PHYSICAL_ADDRESS Address - ); - -/** - Check if the memory address will be mapped by 4KB-page. - - @param Address The address of Memory. - @param Nx The flag indicates if the memory is execute-disable. - -**/ -BOOLEAN -IsAddressValid ( - IN EFI_PHYSICAL_ADDRESS Address, - IN BOOLEAN *Nx - ); - -/** - Page Fault handler for SMM use. - -**/ -VOID -SmiDefaultPFHandler ( - VOID - ); - -/** - Clear TF in FLAGS. - - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. - -**/ -VOID -ClearTrapFlag ( - IN OUT EFI_SYSTEM_CONTEXT SystemContext - ); - -#endif // _SMM_PROFILE_H_ diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c deleted file mode 100644 index 3188d43818..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c +++ /dev/null @@ -1,738 +0,0 @@ -/** @file -Provides services to access SMRAM Save State Map - -Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "PiSmmCpuDxeSmm.h" - -typedef struct { - UINT64 Signature; // Offset 0x00 - UINT16 Reserved1; // Offset 0x08 - UINT16 Reserved2; // Offset 0x0A - UINT16 Reserved3; // Offset 0x0C - UINT16 SmmCs; // Offset 0x0E - UINT16 SmmDs; // Offset 0x10 - UINT16 SmmSs; // Offset 0x12 - UINT16 SmmOtherSegment; // Offset 0x14 - UINT16 Reserved4; // Offset 0x16 - UINT64 Reserved5; // Offset 0x18 - UINT64 Reserved6; // Offset 0x20 - UINT64 Reserved7; // Offset 0x28 - UINT64 SmmGdtPtr; // Offset 0x30 - UINT32 SmmGdtSize; // Offset 0x38 - UINT32 Reserved8; // Offset 0x3C - UINT64 Reserved9; // Offset 0x40 - UINT64 Reserved10; // Offset 0x48 - UINT16 Reserved11; // Offset 0x50 - UINT16 Reserved12; // Offset 0x52 - UINT32 Reserved13; // Offset 0x54 - UINT64 Reserved14; // Offset 0x58 -} PROCESSOR_SMM_DESCRIPTOR; - -extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd; - -// -// EFER register LMA bit -// -#define LMA BIT10 - -/// -/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -#define SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field) - -/// -/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_REGISTER_RANGE -/// -#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 } - -/// -/// Structure used to describe a range of registers -/// -typedef struct { - EFI_SMM_SAVE_STATE_REGISTER Start; - EFI_SMM_SAVE_STATE_REGISTER End; - UINTN Length; -} CPU_SMM_SAVE_STATE_REGISTER_RANGE; - -/// -/// Structure used to build a lookup table to retrieve the widths and offsets -/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value -/// - -#define SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1 -#define SMM_SAVE_STATE_REGISTER_IOMISC_INDEX 2 -#define SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX 3 -#define SMM_SAVE_STATE_REGISTER_MAX_INDEX 4 - -typedef struct { - UINT8 Width32; - UINT8 Width64; - UINT16 Offset32; - UINT16 Offset64Lo; - UINT16 Offset64Hi; - BOOLEAN Writeable; -} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY; - -/// -/// Structure used to build a lookup table for the IOMisc width information -/// -typedef struct { - UINT8 Width; - EFI_SMM_SAVE_STATE_IO_WIDTH IoWidth; -} CPU_SMM_SAVE_STATE_IO_WIDTH; - -/// -/// Variables from SMI Handler -/// -extern UINT32 gSmbase; -extern volatile UINT32 gSmiStack; -extern UINT32 gSmiCr3; -extern volatile UINT8 gcSmiHandlerTemplate[]; -extern CONST UINT16 gcSmiHandlerSize; - -// -// Variables used by SMI Handler -// -IA32_DESCRIPTOR gSmiHandlerIdtr; - -/// -/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER -/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = { - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, EFI_SMM_SAVE_STATE_REGISTER_LDTINFO), - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES, EFI_SMM_SAVE_STATE_REGISTER_RIP), - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS, EFI_SMM_SAVE_STATE_REGISTER_CR4), - { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0 } -}; - -/// -/// Lookup table used to retrieve the widths and offsets associated with each -/// supported EFI_SMM_SAVE_STATE_REGISTER value -/// -CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = { - {0, 0, 0, 0, 0, FALSE}, // Reserved - - // - // Internally defined CPU Save State Registers. Not defined in PI SMM CPU Protocol. - // - {4, 4, SMM_CPU_OFFSET (x86.SMMRevId) , SMM_CPU_OFFSET (x64.SMMRevId) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX = 1 - {4, 4, SMM_CPU_OFFSET (x86.IOMisc) , SMM_CPU_OFFSET (x64.IOMisc) , 0 , FALSE}, // SMM_SAVE_STATE_REGISTER_IOMISC_INDEX = 2 - {4, 8, SMM_CPU_OFFSET (x86.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) , SMM_CPU_OFFSET (x64.IOMemAddr) + 4, FALSE}, // SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX = 3 - - // - // CPU Save State registers defined in PI SMM CPU Protocol. - // - {0, 8, 0 , SMM_CPU_OFFSET (x64.GdtBaseLoDword) , SMM_CPU_OFFSET (x64.GdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTBASE = 4 - {0, 8, 0 , SMM_CPU_OFFSET (x64.IdtBaseLoDword) , SMM_CPU_OFFSET (x64.IdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTBASE = 5 - {0, 8, 0 , SMM_CPU_OFFSET (x64.LdtBaseLoDword) , SMM_CPU_OFFSET (x64.LdtBaseHiDword), FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTBASE = 6 - {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT = 7 - {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT = 8 - {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT = 9 - {0, 0, 0 , 0 , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTINFO = 10 - - {4, 4, SMM_CPU_OFFSET (x86._ES) , SMM_CPU_OFFSET (x64._ES) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_ES = 20 - {4, 4, SMM_CPU_OFFSET (x86._CS) , SMM_CPU_OFFSET (x64._CS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CS = 21 - {4, 4, SMM_CPU_OFFSET (x86._SS) , SMM_CPU_OFFSET (x64._SS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_SS = 22 - {4, 4, SMM_CPU_OFFSET (x86._DS) , SMM_CPU_OFFSET (x64._DS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DS = 23 - {4, 4, SMM_CPU_OFFSET (x86._FS) , SMM_CPU_OFFSET (x64._FS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_FS = 24 - {4, 4, SMM_CPU_OFFSET (x86._GS) , SMM_CPU_OFFSET (x64._GS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GS = 25 - {0, 4, 0 , SMM_CPU_OFFSET (x64._LDTR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL = 26 - {4, 4, SMM_CPU_OFFSET (x86._TR) , SMM_CPU_OFFSET (x64._TR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_TR_SEL = 27 - {4, 8, SMM_CPU_OFFSET (x86._DR7) , SMM_CPU_OFFSET (x64._DR7) , SMM_CPU_OFFSET (x64._DR7) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR7 = 28 - {4, 8, SMM_CPU_OFFSET (x86._DR6) , SMM_CPU_OFFSET (x64._DR6) , SMM_CPU_OFFSET (x64._DR6) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR6 = 29 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R8) , SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R8 = 30 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R9) , SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R9 = 31 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R10) , SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R10 = 32 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R11) , SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R11 = 33 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R12) , SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R12 = 34 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R13) , SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R13 = 35 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R14) , SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R14 = 36 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R15) , SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R15 = 37 - {4, 8, SMM_CPU_OFFSET (x86._EAX) , SMM_CPU_OFFSET (x64._RAX) , SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RAX = 38 - {4, 8, SMM_CPU_OFFSET (x86._EBX) , SMM_CPU_OFFSET (x64._RBX) , SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBX = 39 - {4, 8, SMM_CPU_OFFSET (x86._ECX) , SMM_CPU_OFFSET (x64._RCX) , SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RCX = 40 - {4, 8, SMM_CPU_OFFSET (x86._EDX) , SMM_CPU_OFFSET (x64._RDX) , SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDX = 41 - {4, 8, SMM_CPU_OFFSET (x86._ESP) , SMM_CPU_OFFSET (x64._RSP) , SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSP = 42 - {4, 8, SMM_CPU_OFFSET (x86._EBP) , SMM_CPU_OFFSET (x64._RBP) , SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBP = 43 - {4, 8, SMM_CPU_OFFSET (x86._ESI) , SMM_CPU_OFFSET (x64._RSI) , SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSI = 44 - {4, 8, SMM_CPU_OFFSET (x86._EDI) , SMM_CPU_OFFSET (x64._RDI) , SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDI = 45 - {4, 8, SMM_CPU_OFFSET (x86._EIP) , SMM_CPU_OFFSET (x64._RIP) , SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RIP = 46 - - {4, 8, SMM_CPU_OFFSET (x86._EFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RFLAGS = 51 - {4, 8, SMM_CPU_OFFSET (x86._CR0) , SMM_CPU_OFFSET (x64._CR0) , SMM_CPU_OFFSET (x64._CR0) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR0 = 52 - {4, 8, SMM_CPU_OFFSET (x86._CR3) , SMM_CPU_OFFSET (x64._CR3) , SMM_CPU_OFFSET (x64._CR3) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR3 = 53 - {0, 4, 0 , SMM_CPU_OFFSET (x64._CR4) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR4 = 54 -}; - -/// -/// Lookup table for the IOMisc width information -/// -CONST CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] = { - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 0 - { 1, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // SMM_IO_LENGTH_BYTE = 1 - { 2, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT16 }, // SMM_IO_LENGTH_WORD = 2 - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 3 - { 4, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT32 }, // SMM_IO_LENGTH_DWORD = 4 - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 5 - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined = 6 - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 } // Undefined = 7 -}; - -/// -/// Lookup table for the IOMisc type information -/// -CONST EFI_SMM_SAVE_STATE_IO_TYPE mSmmCpuIoType[] = { - EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_DX = 0 - EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_IN_DX = 1 - EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_OUTS = 2 - EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_INS = 3 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 4 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 5 - EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // SMM_IO_TYPE_REP_OUTS = 6 - EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // SMM_IO_TYPE_REP_INS = 7 - EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_IMMEDIATE = 8 - EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_OUT_IMMEDIATE = 9 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 10 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 11 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 12 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 13 - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = 14 - (EFI_SMM_SAVE_STATE_IO_TYPE)0 // Undefined = 15 -}; - -/// -/// The mode of the CPU at the time an SMI occurs -/// -UINT8 mSmmSaveStateRegisterLma; - -/** - Read information from the CPU save state. - - @param Register Specifies the CPU register to read form the save state. - - @retval 0 Register is not valid - @retval >0 Index into mSmmCpuWidthOffset[] associated with Register - -**/ -UINTN -GetRegisterIndex ( - IN EFI_SMM_SAVE_STATE_REGISTER Register - ) -{ - UINTN Index; - UINTN Offset; - - for (Index = 0, Offset = SMM_SAVE_STATE_REGISTER_MAX_INDEX; mSmmCpuRegisterRanges[Index].Length != 0; Index++) { - if (Register >= mSmmCpuRegisterRanges[Index].Start && Register <= mSmmCpuRegisterRanges[Index].End) { - return Register - mSmmCpuRegisterRanges[Index].Start + Offset; - } - Offset += mSmmCpuRegisterRanges[Index].Length; - } - return 0; -} - -/** - Read a CPU Save State register on the target processor. - - This function abstracts the differences that whether the CPU Save State register is in the - IA32 CPU Save State Map or X64 CPU Save State Map. - - This function supports reading a CPU Save State register in SMBase relocation handler. - - @param[in] CpuIndex Specifies the zero-based index of the CPU save state. - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. - @retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -EFI_STATUS -ReadSaveStateRegisterByIndex ( - IN UINTN CpuIndex, - IN UINTN RegisterIndex, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - SMRAM_SAVE_STATE_MAP *CpuSaveState; - - if (RegisterIndex == 0) { - return EFI_NOT_FOUND; - } - - CpuSaveState = gSmst->CpuSaveState[CpuIndex]; - - if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { - // - // If 32-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { - return EFI_INVALID_PARAMETER; - } - - // - // Write return buffer - // - ASSERT(CpuSaveState != NULL); - CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width); - } else { - // - // If 64-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { - return EFI_INVALID_PARAMETER; - } - - // - // Write lower 32-bits of return buffer - // - CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width)); - if (Width >= 4) { - // - // Write upper 32-bits of return buffer - // - CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4); - } - } - return EFI_SUCCESS; -} - -/** - Read a CPU Save State register on the target processor. - - This function abstracts the differences that whether the CPU Save State register is in the - IA32 CPU Save State Map or X64 CPU Save State Map. - - This function supports reading a CPU Save State register in SMBase relocation handler. - - @param[in] CpuIndex Specifies the zero-based index of the CPU save state. - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. - @retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -EFI_STATUS -EFIAPI -ReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - UINT32 SmmRevId; - SMRAM_SAVE_STATE_IOMISC IoMisc; - EFI_SMM_SAVE_STATE_IO_INFO *IoInfo; - VOID *IoMemAddr; - - // - // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { - // - // Only byte access is supported for this register - // - if (Width != 1) { - return EFI_INVALID_PARAMETER; - } - - *(UINT8 *)Buffer = mSmmSaveStateRegisterLma; - - return EFI_SUCCESS; - } - - // - // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { - // - // Get SMM Revision ID - // - ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX, sizeof(SmmRevId), &SmmRevId); - - // - // See if the CPU supports the IOMisc register in the save state - // - if (SmmRevId < SMRAM_SAVE_STATE_MIN_REV_ID_IOMISC) { - return EFI_NOT_FOUND; - } - - // - // Get the IOMisc register value - // - ReadSaveStateRegisterByIndex (CpuIndex, SMM_SAVE_STATE_REGISTER_IOMISC_INDEX, sizeof(IoMisc.Uint32), &IoMisc.Uint32); - - // - // Check for the SMI_FLAG in IOMisc - // - if (IoMisc.Bits.SmiFlag == 0) { - return EFI_NOT_FOUND; - } - - // - // Compute index for the I/O Length and I/O Type lookup tables - // - if (mSmmCpuIoWidth[IoMisc.Bits.Length].Width == 0 || mSmmCpuIoType[IoMisc.Bits.Type] == 0) { - return EFI_NOT_FOUND; - } - - // - // Zero the IoInfo structure that will be returned in Buffer - // - IoInfo = (EFI_SMM_SAVE_STATE_IO_INFO *)Buffer; - ZeroMem (IoInfo, sizeof(EFI_SMM_SAVE_STATE_IO_INFO)); - - // - // Use lookup tables to help fill in all the fields of the IoInfo structure - // - IoInfo->IoPort = (UINT16)IoMisc.Bits.Port; - IoInfo->IoWidth = mSmmCpuIoWidth[IoMisc.Bits.Length].IoWidth; - IoInfo->IoType = mSmmCpuIoType[IoMisc.Bits.Type]; - if (IoInfo->IoType == EFI_SMM_SAVE_STATE_IO_TYPE_INPUT || IoInfo->IoType == EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT) { - ReadSaveStateRegister (CpuIndex, EFI_SMM_SAVE_STATE_REGISTER_RAX, mSmmCpuIoWidth[IoMisc.Bits.Length].Width, &IoInfo->IoData); - } - else { - ReadSaveStateRegisterByIndex(CpuIndex, SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX, sizeof(IoMemAddr), &IoMemAddr); - CopyMem(&IoInfo->IoData, IoMemAddr, mSmmCpuIoWidth[IoMisc.Bits.Length].Width); - } - return EFI_SUCCESS; - } - - // - // Convert Register to a register lookup table index - // - return ReadSaveStateRegisterByIndex (CpuIndex, GetRegisterIndex (Register), Width, Buffer); -} - -/** - Write value to a CPU Save State register on the target processor. - - This function abstracts the differences that whether the CPU Save State register is in the - IA32 CPU Save State Map or X64 CPU Save State Map. - - This function supports writing a CPU Save State register in SMBase relocation handler. - - @param[in] CpuIndex Specifies the zero-based index of the CPU save state. - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. - @param[in] Width The number of bytes to read from the CPU save state. - @param[in] Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written to Save State. - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. - @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct. - -**/ -EFI_STATUS -EFIAPI -WriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ) -{ - UINTN RegisterIndex; - SMRAM_SAVE_STATE_MAP *CpuSaveState; - - // - // Writes to EFI_SMM_SAVE_STATE_REGISTER_LMA are ignored - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { - return EFI_SUCCESS; - } - - // - // Writes to EFI_SMM_SAVE_STATE_REGISTER_IO are not supported - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { - return EFI_NOT_FOUND; - } - - // - // Convert Register to a register lookup table index - // - RegisterIndex = GetRegisterIndex (Register); - if (RegisterIndex == 0) { - return EFI_NOT_FOUND; - } - - CpuSaveState = gSmst->CpuSaveState[CpuIndex]; - - // - // Do not write non-writable SaveState, because it will cause exception. - // - if (!mSmmCpuWidthOffset[RegisterIndex].Writeable) { - return EFI_UNSUPPORTED; - } - - // - // Check CPU mode - // - if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { - // - // If 32-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { - return EFI_INVALID_PARAMETER; - } - // - // Write SMM State register - // - ASSERT (CpuSaveState != NULL); - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width); - } else { - // - // If 64-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { - return EFI_INVALID_PARAMETER; - } - - // - // Write lower 32-bits of SMM State register - // - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width)); - if (Width >= 4) { - // - // Write upper 32-bits of SMM State register - // - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4); - } - } - return EFI_SUCCESS; -} - -/** - Hook the code executed immediately after an RSM instruction on the currently - executing CPU. The mode of code executed immediately after RSM must be - detected, and the appropriate hook must be selected. Always clear the auto - HALT restart flag if it is set. - - @param[in] CpuIndex The processor index for the currently - executing CPU. - @param[in] CpuState Pointer to SMRAM Save State Map for the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to - 32-bit mode from 64-bit SMM. - @param[in] NewInstructionPointer Instruction pointer to use if resuming to - same mode as SMM. - - @retval The value of the original instruction pointer before it was hooked. - -**/ -UINT64 -EFIAPI -HookReturnFromSmm ( - IN UINTN CpuIndex, - SMRAM_SAVE_STATE_MAP *CpuState, - UINT64 NewInstructionPointer32, - UINT64 NewInstructionPointer - ) -{ - UINT64 OriginalInstructionPointer; - - OriginalInstructionPointer = SmmCpuFeaturesHookReturnFromSmm ( - CpuIndex, - CpuState, - NewInstructionPointer32, - NewInstructionPointer - ); - if (OriginalInstructionPointer != 0) { - return OriginalInstructionPointer; - } - - if (mSmmSaveStateRegisterLma == EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { - OriginalInstructionPointer = (UINT64)CpuState->x86._EIP; - CpuState->x86._EIP = (UINT32)NewInstructionPointer; - // - // Clear the auto HALT restart flag so the RSM instruction returns - // program control to the instruction following the HLT instruction. - // - if ((CpuState->x86.AutoHALTRestart & BIT0) != 0) { - CpuState->x86.AutoHALTRestart &= ~BIT0; - } - } else { - OriginalInstructionPointer = CpuState->x64._RIP; - if ((CpuState->x64.IA32_EFER & LMA) == 0) { - CpuState->x64._RIP = (UINT32)NewInstructionPointer32; - } else { - CpuState->x64._RIP = (UINT32)NewInstructionPointer; - } - // - // Clear the auto HALT restart flag so the RSM instruction returns - // program control to the instruction following the HLT instruction. - // - if ((CpuState->x64.AutoHALTRestart & BIT0) != 0) { - CpuState->x64.AutoHALTRestart &= ~BIT0; - } - } - return OriginalInstructionPointer; -} - -/** - Get the size of the SMI Handler in bytes. - - @retval The size, in bytes, of the SMI Handler. - -**/ -UINTN -EFIAPI -GetSmiHandlerSize ( - VOID - ) -{ - UINTN Size; - - Size = SmmCpuFeaturesGetSmiHandlerSize (); - if (Size != 0) { - return Size; - } - return gcSmiHandlerSize; -} - -/** - Install the SMI handler for the CPU specified by CpuIndex. This function - is called by the CPU that was elected as monarch during System Management - Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -InstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ) -{ - PROCESSOR_SMM_DESCRIPTOR *Psd; - - // - // Initialize PROCESSOR_SMM_DESCRIPTOR - // - Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + SMM_PSD_OFFSET); - CopyMem (Psd, &gcPsd, sizeof (gcPsd)); - Psd->SmmGdtPtr = (UINT64)GdtBase; - Psd->SmmGdtSize = (UINT32)GdtSize; - - if (SmmCpuFeaturesGetSmiHandlerSize () != 0) { - // - // Install SMI handler provided by library - // - SmmCpuFeaturesInstallSmiHandler ( - CpuIndex, - SmBase, - SmiStack, - StackSize, - GdtBase, - GdtSize, - IdtBase, - IdtSize, - Cr3 - ); - return; - } - - // - // Initialize values in template before copy - // - gSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); - gSmiCr3 = Cr3; - gSmbase = SmBase; - gSmiHandlerIdtr.Base = IdtBase; - gSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1); - - // - // Set the value at the top of the CPU stack to the CPU Index - // - *(UINTN*)(UINTN)gSmiStack = CpuIndex; - - // - // Copy template to CPU specific SMI handler location - // - CopyMem ( - (VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET), - (VOID*)gcSmiHandlerTemplate, - gcSmiHandlerSize - ); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c deleted file mode 100644 index 5a632eaa24..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c +++ /dev/null @@ -1,116 +0,0 @@ -/** @file -SMM Timer feature support - -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -UINT64 mTimeoutTicker = 0; -// -// Number of counts in a roll-over cycle of the performance counter. -// -UINT64 mCycle = 0; -// -// Flag to indicate the performance counter is count-up or count-down. -// -BOOLEAN mCountDown; - -/** - Initialize Timer for SMM AP Sync. - -**/ -VOID -InitializeSmmTimer ( - VOID - ) -{ - UINT64 TimerFrequency; - UINT64 Start; - UINT64 End; - - TimerFrequency = GetPerformanceCounterProperties (&Start, &End); - mTimeoutTicker = DivU64x32 ( - MultU64x64(TimerFrequency, PcdGet64 (PcdCpuSmmApSyncTimeout)), - 1000 * 1000 - ); - if (End < Start) { - mCountDown = TRUE; - mCycle = Start - End; - } else { - mCountDown = FALSE; - mCycle = End - Start; - } -} - -/** - Start Timer for SMM AP Sync. - -**/ -UINT64 -EFIAPI -StartSyncTimer ( - VOID - ) -{ - return GetPerformanceCounter (); -} - - -/** - Check if the SMM AP Sync timer is timeout. - - @param Timer The start timer from the begin. - -**/ -BOOLEAN -EFIAPI -IsSyncTimerTimeout ( - IN UINT64 Timer - ) -{ - UINT64 CurrentTimer; - UINT64 Delta; - - CurrentTimer = GetPerformanceCounter (); - // - // We need to consider the case that CurrentTimer is equal to Timer - // when some timer runs too slow and CPU runs fast. We think roll over - // condition does not happen on this case. - // - if (mCountDown) { - // - // The performance counter counts down. Check for roll over condition. - // - if (CurrentTimer <= Timer) { - Delta = Timer - CurrentTimer; - } else { - // - // Handle one roll-over. - // - Delta = mCycle - (CurrentTimer - Timer) + 1; - } - } else { - // - // The performance counter counts up. Check for roll over condition. - // - if (CurrentTimer >= Timer) { - Delta = CurrentTimer - Timer; - } else { - // - // Handle one roll-over. - // - Delta = mCycle - (Timer - CurrentTimer) + 1; - } - } - - return (BOOLEAN) (Delta >= mTimeoutTicker); -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S deleted file mode 100644 index d7cbc8cdc5..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.S +++ /dev/null @@ -1,204 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# MpFuncs.S -# -# Abstract: -# -# This is the assembly code for Multi-processor S3 support -# -#------------------------------------------------------------------------------ - -.equ VacantFlag, 0x0 -.equ NotVacantFlag, 0xff - -.equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart -.equ StackStartAddressLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08 -.equ StackSizeLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10 -.equ CProcedureLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x18 -.equ GdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20 -.equ IdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x2A -.equ BufferStartLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x34 -.equ Cr3OffsetLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38 - -#------------------------------------------------------------------------------------- -#RendezvousFunnelProc procedure follows. All APs execute their procedure. This -#procedure serializes all the AP processors through an Init sequence. It must be -#noted that APs arrive here very raw...ie: real mode, no stack. -#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -#IS IN MACHINE CODE. -#------------------------------------------------------------------------------------- -#RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -.code: - -ASM_GLOBAL ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: - -# At this point CS = 0x(vv00) and ip= 0x0. - - .byte 0x8c,0xc8 # mov ax, cs - .byte 0x8e,0xd8 # mov ds, ax - .byte 0x8e,0xc0 # mov es, ax - .byte 0x8e,0xd0 # mov ss, ax - .byte 0x33,0xc0 # xor ax, ax - .byte 0x8e,0xe0 # mov fs, ax - .byte 0x8e,0xe8 # mov gs, ax - -flat32Start: - - .byte 0xBE - .word BufferStartLocation - .byte 0x66,0x8B,0x14 # mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer - - .byte 0xBE - .word Cr3OffsetLocation - .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the value of CR3 - - .byte 0xBE - .word GdtrLocation - .byte 0x66 # db 66h - .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si] - - .byte 0xBE - .word IdtrLocation - .byte 0x66 # db 66h - .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si] - - .byte 0x33,0xC0 # xor ax, ax - .byte 0x8E,0xD8 # mov ds, ax - - .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0 - .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0) - .byte 0xF,0x22,0xC0 # mov cr0, eax - -FLAT32_JUMP: - - .byte 0x66,0x67,0xEA # far jump - .long 0x0 # 32-bit offset - .word 0x20 # 16-bit selector - -PMODE_ENTRY: # protected mode entry point - - .byte 0x66,0xB8,0x18,0x0 # mov ax, 18h - .byte 0x66,0x8E,0xD8 # mov ds, ax - .byte 0x66,0x8E,0xC0 # mov es, ax - .byte 0x66,0x8E,0xE0 # mov fs, ax - .byte 0x66,0x8E,0xE8 # mov gs, ax - .byte 0x66,0x8E,0xD0 # mov ss, ax ; Flat mode setup. - - .byte 0xF,0x20,0xE0 # mov eax, cr4 - .byte 0xF,0xBA,0xE8,0x5 # bts eax, 5 - .byte 0xF,0x22,0xE0 # mov cr4, eax - - .byte 0xF,0x22,0xD9 # mov cr3, ecx - - .byte 0x8B,0xF2 # mov esi, edx ; Save wakeup buffer address - - .byte 0xB9 - .long 0xC0000080 # mov ecx, 0c0000080h ; EFER MSR number. - .byte 0xF,0x32 # rdmsr ; Read EFER. - .byte 0xF,0xBA,0xE8,0x8 # bts eax, 8 ; Set LME=1. - .byte 0xF,0x30 # wrmsr ; Write EFER. - - .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Read CR0. - .byte 0xF,0xBA,0xE8,0x1F # bts eax, 31 ; Set PG=1. - .byte 0xF,0x22,0xC0 # mov cr0, eax ; Write CR0. - -LONG_JUMP: - - .byte 0x67,0xEA # far jump - .long 0x0 # 32-bit offset - .word 0x38 # 16-bit selector - -LongModeStart: - - movw $0x30,%ax - .byte 0x66 - movw %ax,%ds - .byte 0x66 - movw %ax,%es - .byte 0x66 - movw %ax,%ss - - movl %esi,%edi - addl $LockLocation, %edi - movb $NotVacantFlag, %al -TestLock: - xchgb (%edi), %al - cmpb $NotVacantFlag, %al - jz TestLock - -ProgramStack: - - movl %esi,%edi - addl $StackSizeLocation, %edi - movq (%edi), %rax - movl %esi,%edi - addl $StackStartAddressLocation, %edi - addq (%edi), %rax - movq %rax, %rsp - movq %rax, (%edi) - -Releaselock: - - movb $VacantFlag, %al - movl %esi,%edi - addl $LockLocation, %edi - xchgb (%edi), %al - - # - # Call assembly function to initialize FPU. - # - movabsq $ASM_PFX(InitializeFloatingPointUnits), %rax - subq $0x20, %rsp - call *%rax - addq $0x20, %rsp - # - # Call C Function - # - movl %esi,%edi - addl $CProcedureLocation, %edi - movq (%edi), %rax - - testq %rax, %rax - jz GoToSleep - - subq $0x20, %rsp - call *%rax - addq $0x20, %rsp - -GoToSleep: - cli - hlt - jmp .-2 - -RendezvousFunnelProcEnd: - - -#------------------------------------------------------------------------------------- -# AsmGetAddressMap (&AddressMap); -#------------------------------------------------------------------------------------- -# comments here for definition of address map -ASM_GLOBAL ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - movabsq $RendezvousFunnelProcStart, %rax - movq %rax, (%rcx) - movq $(PMODE_ENTRY - RendezvousFunnelProcStart), 0x08(%rcx) - movq $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x10(%rcx) - movq $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x18(%rcx) - movq $(LongModeStart - RendezvousFunnelProcStart), 0x20(%rcx) - movq $(LONG_JUMP - RendezvousFunnelProcStart), 0x28(%rcx) - ret - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm deleted file mode 100644 index 2c5a7c9bc2..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.asm +++ /dev/null @@ -1,206 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.asm -; -; Abstract: -; -; This is the assembly code for Multi-processor S3 support -; -;------------------------------------------------------------------------------- - -EXTERN InitializeFloatingPointUnits:PROC - -VacantFlag Equ 00h -NotVacantFlag Equ 0ffh - -LockLocation equ RendezvousFunnelProcEnd - RendezvousFunnelProcStart -StackStartAddressLocation equ LockLocation + 08h -StackSizeLocation equ LockLocation + 10h -CProcedureLocation equ LockLocation + 18h -GdtrLocation equ LockLocation + 20h -IdtrLocation equ LockLocation + 2Ah -BufferStartLocation equ LockLocation + 34h -Cr3OffsetLocation equ LockLocation + 38h - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -;text SEGMENT -.code - -RendezvousFunnelProc PROC -RendezvousFunnelProcStart:: - -; At this point CS = 0x(vv00) and ip= 0x0. - - db 8ch, 0c8h ; mov ax, cs - db 8eh, 0d8h ; mov ds, ax - db 8eh, 0c0h ; mov es, ax - db 8eh, 0d0h ; mov ss, ax - db 33h, 0c0h ; xor ax, ax - db 8eh, 0e0h ; mov fs, ax - db 8eh, 0e8h ; mov gs, ax - -flat32Start:: - - db 0BEh - dw BufferStartLocation ; mov si, BufferStartLocation - db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer - - db 0BEh - dw Cr3OffsetLocation ; mov si, Cr3Location - db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the value of CR3 - - db 0BEh - dw GdtrLocation ; mov si, GdtrProfile - db 66h ; db 66h - db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si] - - db 0BEh - dw IdtrLocation ; mov si, IdtrProfile - db 66h ; db 66h - db 2Eh, 0Fh, 01h, 1Ch ; lidt fword ptr cs:[si] - - db 33h, 0C0h ; xor ax, ax - db 8Eh, 0D8h ; mov ds, ax - - db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0 - db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0) - db 0Fh, 22h, 0C0h ; mov cr0, eax - -FLAT32_JUMP:: - - db 66h, 67h, 0EAh ; far jump - dd 0h ; 32-bit offset - dw 20h ; 16-bit selector - -PMODE_ENTRY:: ; protected mode entry point - - db 66h, 0B8h, 18h, 00h ; mov ax, 18h - db 66h, 8Eh, 0D8h ; mov ds, ax - db 66h, 8Eh, 0C0h ; mov es, ax - db 66h, 8Eh, 0E0h ; mov fs, ax - db 66h, 8Eh, 0E8h ; mov gs, ax - db 66h, 8Eh, 0D0h ; mov ss, ax ; Flat mode setup. - - db 0Fh, 20h, 0E0h ; mov eax, cr4 - db 0Fh, 0BAh, 0E8h, 05h ; bts eax, 5 - db 0Fh, 22h, 0E0h ; mov cr4, eax - - db 0Fh, 22h, 0D9h ; mov cr3, ecx - - db 8Bh, 0F2h ; mov esi, edx ; Save wakeup buffer address - - db 0B9h - dd 0C0000080h ; mov ecx, 0c0000080h ; EFER MSR number. - db 0Fh, 32h ; rdmsr ; Read EFER. - db 0Fh, 0BAh, 0E8h, 08h ; bts eax, 8 ; Set LME=1. - db 0Fh, 30h ; wrmsr ; Write EFER. - - db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Read CR0. - db 0Fh, 0BAh, 0E8h, 1Fh ; bts eax, 31 ; Set PG=1. - db 0Fh, 22h, 0C0h ; mov cr0, eax ; Write CR0. - -LONG_JUMP:: - - db 67h, 0EAh ; far jump - dd 0h ; 32-bit offset - dw 38h ; 16-bit selector - -LongModeStart:: - - mov ax, 30h - mov ds, ax - mov es, ax - mov ss, ax - - mov edi, esi - add edi, LockLocation - mov al, NotVacantFlag -TestLock:: - xchg byte ptr [edi], al - cmp al, NotVacantFlag - jz TestLock - -ProgramStack:: - - mov edi, esi - add edi, StackSizeLocation - mov rax, qword ptr [edi] - mov edi, esi - add edi, StackStartAddressLocation - add rax, qword ptr [edi] - mov rsp, rax - mov qword ptr [edi], rax - -Releaselock:: - - mov al, VacantFlag - mov edi, esi - add edi, LockLocation - xchg byte ptr [edi], al - - ; - ; Call assembly function to initialize FPU. - ; - mov rax, InitializeFloatingPointUnits - sub rsp, 20h - call rax - add rsp, 20h - - ; - ; Call C Function - ; - mov edi, esi - add edi, CProcedureLocation - mov rax, qword ptr [edi] - - test rax, rax - jz GoToSleep - - sub rsp, 20h - call rax - add rsp, 20h - -GoToSleep:: - cli - hlt - jmp $-2 - -RendezvousFunnelProcEnd:: -RendezvousFunnelProc ENDP - - -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -; comments here for definition of address map -AsmGetAddressMap PROC - mov rax, offset RendezvousFunnelProcStart - mov qword ptr [rcx], rax - mov qword ptr [rcx+8h], PMODE_ENTRY - RendezvousFunnelProcStart - mov qword ptr [rcx+10h], FLAT32_JUMP - RendezvousFunnelProcStart - mov qword ptr [rcx+18h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - mov qword ptr [rcx+20h], LongModeStart - RendezvousFunnelProcStart - mov qword ptr [rcx+28h], LONG_JUMP - RendezvousFunnelProcStart - ret - -AsmGetAddressMap ENDP - -END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm deleted file mode 100644 index 702233d6e4..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm +++ /dev/null @@ -1,196 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; MpFuncs.nasm -; -; Abstract: -; -; This is the assembly code for Multi-processor S3 support -; -;------------------------------------------------------------------------------- - -extern ASM_PFX(InitializeFloatingPointUnits) - -%define VacantFlag 0x0 -%define NotVacantFlag 0xff - -%define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart -%define StackStartAddressLocation LockLocation + 0x8 -%define StackSizeLocation LockLocation + 0x10 -%define CProcedureLocation LockLocation + 0x18 -%define GdtrLocation LockLocation + 0x20 -%define IdtrLocation LockLocation + 0x2A -%define BufferStartLocation LockLocation + 0x34 -%define Cr3OffsetLocation LockLocation + 0x38 - -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc procedure follows. All APs execute their procedure. This -;procedure serializes all the AP processors through an Init sequence. It must be -;noted that APs arrive here very raw...ie: real mode, no stack. -;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC -;IS IN MACHINE CODE. -;------------------------------------------------------------------------------------- -;RendezvousFunnelProc (&WakeUpBuffer,MemAddress); - -;text SEGMENT -DEFAULT REL -SECTION .text - -BITS 16 -global ASM_PFX(RendezvousFunnelProc) -ASM_PFX(RendezvousFunnelProc): -RendezvousFunnelProcStart: - -; At this point CS = 0x(vv00) and ip= 0x0. - - mov ax, cs - mov ds, ax - mov es, ax - mov ss, ax - xor ax, ax - mov fs, ax - mov gs, ax - -flat32Start: - - mov si, BufferStartLocation - mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer - - mov si, Cr3OffsetLocation - mov ecx,dword [si] ; ECX is keeping the value of CR3 - - mov si, GdtrLocation -o32 lgdt [cs:si] - - mov si, IdtrLocation -o32 lidt [cs:si] - - xor ax, ax - mov ds, ax - - mov eax, cr0 ; Get control register 0 - or eax, 0x000000001 ; Set PE bit (bit #0) - mov cr0, eax - -FLAT32_JUMP: - -a32 jmp dword 0x20:0x0 - -BITS 32 -PMODE_ENTRY: ; protected mode entry point - - mov ax, 0x18 -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax ; Flat mode setup. - - mov eax, cr4 - bts eax, 5 - mov cr4, eax - - mov cr3, ecx - - mov esi, edx ; Save wakeup buffer address - - mov ecx, 0xc0000080 ; EFER MSR number. - rdmsr ; Read EFER. - bts eax, 8 ; Set LME=1. - wrmsr ; Write EFER. - - mov eax, cr0 ; Read CR0. - bts eax, 31 ; Set PG=1. - mov cr0, eax ; Write CR0. - -LONG_JUMP: - -a16 jmp dword 0x38:0x0 - -BITS 64 -LongModeStart: - - mov ax, 0x30 -o16 mov ds, ax -o16 mov es, ax -o16 mov ss, ax - - mov edi, esi - add edi, LockLocation - mov al, NotVacantFlag -TestLock: - xchg byte [edi], al - cmp al, NotVacantFlag - jz TestLock - -ProgramStack: - - mov edi, esi - add edi, StackSizeLocation - mov rax, qword [edi] - mov edi, esi - add edi, StackStartAddressLocation - add rax, qword [edi] - mov rsp, rax - mov qword [edi], rax - -Releaselock: - - mov al, VacantFlag - mov edi, esi - add edi, LockLocation - xchg byte [edi], al - - ; - ; Call assembly function to initialize FPU. - ; - mov rax, ASM_PFX(InitializeFloatingPointUnits) - sub rsp, 0x20 - call rax - add rsp, 0x20 - - ; - ; Call C Function - ; - mov edi, esi - add edi, CProcedureLocation - mov rax, qword [edi] - - test rax, rax - jz GoToSleep - - sub rsp, 0x20 - call rax - add rsp, 0x20 - -GoToSleep: - cli - hlt - jmp $-2 - -RendezvousFunnelProcEnd: - -;------------------------------------------------------------------------------------- -; AsmGetAddressMap (&AddressMap); -;------------------------------------------------------------------------------------- -; comments here for definition of address map -global ASM_PFX(AsmGetAddressMap) -ASM_PFX(AsmGetAddressMap): - mov rax, RendezvousFunnelProcStart - mov qword [rcx], rax - mov qword [rcx+0x8], PMODE_ENTRY - RendezvousFunnelProcStart - mov qword [rcx+0x10], FLAT32_JUMP - RendezvousFunnelProcStart - mov qword [rcx+0x18], RendezvousFunnelProcEnd - RendezvousFunnelProcStart - mov qword [rcx+0x20], LongModeStart - RendezvousFunnelProcStart - mov qword [rcx+0x28], LONG_JUMP - RendezvousFunnelProcStart - ret - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c deleted file mode 100644 index 32385faae4..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c +++ /dev/null @@ -1,970 +0,0 @@ -/** @file -Page Fault (#PF) handler for X64 processors - -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -#define PAGE_TABLE_PAGES 8 -#define ACC_MAX_BIT BIT3 - -LIST_ENTRY mPagePool = INITIALIZE_LIST_HEAD_VARIABLE (mPagePool); -BOOLEAN m1GPageTableSupport = FALSE; -UINT8 mPhysicalAddressBits; -BOOLEAN mCpuSmmStaticPageTable; - -/** - Check if 1-GByte pages is supported by processor or not. - - @retval TRUE 1-GByte pages is supported. - @retval FALSE 1-GByte pages is not supported. - -**/ -BOOLEAN -Is1GPageSupport ( - VOID - ) -{ - UINT32 RegEax; - UINT32 RegEdx; - - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000001) { - AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT26) != 0) { - return TRUE; - } - } - return FALSE; -} - -/** - Set sub-entries number in entry. - - @param[in, out] Entry Pointer to entry - @param[in] SubEntryNum Sub-entries number based on 0: - 0 means there is 1 sub-entry under this entry - 0x1ff means there is 512 sub-entries under this entry - -**/ -VOID -SetSubEntriesNum ( - IN OUT UINT64 *Entry, - IN UINT64 SubEntryNum - ) -{ - // - // Sub-entries number is saved in BIT52 to BIT60 (reserved field) in Entry - // - *Entry = BitFieldWrite64 (*Entry, 52, 60, SubEntryNum); -} - -/** - Return sub-entries number in entry. - - @param[in] Entry Pointer to entry - - @return Sub-entries number based on 0: - 0 means there is 1 sub-entry under this entry - 0x1ff means there is 512 sub-entries under this entry -**/ -UINT64 -GetSubEntriesNum ( - IN UINT64 *Entry - ) -{ - // - // Sub-entries number is saved in BIT52 to BIT60 (reserved field) in Entry - // - return BitFieldRead64 (*Entry, 52, 60); -} - -/** - Calculate the maximum support address. - - @return the maximum support address. -**/ -UINT8 -CalculateMaximumSupportAddress ( - VOID - ) -{ - UINT32 RegEax; - UINT8 PhysicalAddressBits; - VOID *Hob; - - // - // Get physical address bits supported. - // - Hob = GetFirstHob (EFI_HOB_TYPE_CPU); - if (Hob != NULL) { - PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; - } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits = (UINT8) RegEax; - } else { - PhysicalAddressBits = 36; - } - } - - // - // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses. - // - ASSERT (PhysicalAddressBits <= 52); - if (PhysicalAddressBits > 48) { - PhysicalAddressBits = 48; - } - return PhysicalAddressBits; -} - -/** - Set static page table. - - @param[in] PageTable Address of page table. -**/ -VOID -SetStaticPageTable ( - IN UINTN PageTable - ) -{ - UINT64 PageAddress; - UINTN NumberOfPml4EntriesNeeded; - UINTN NumberOfPdpEntriesNeeded; - UINTN IndexOfPml4Entries; - UINTN IndexOfPdpEntries; - UINTN IndexOfPageDirectoryEntries; - UINT64 *PageMapLevel4Entry; - UINT64 *PageMap; - UINT64 *PageDirectoryPointerEntry; - UINT64 *PageDirectory1GEntry; - UINT64 *PageDirectoryEntry; - - if (mPhysicalAddressBits <= 39 ) { - NumberOfPml4EntriesNeeded = 1; - NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (mPhysicalAddressBits - 30)); - } else { - NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (mPhysicalAddressBits - 39)); - NumberOfPdpEntriesNeeded = 512; - } - - // - // By architecture only one PageMapLevel4 exists - so lets allocate storage for it. - // - PageMap = (VOID *) PageTable; - - PageMapLevel4Entry = PageMap; - PageAddress = 0; - for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) { - // - // Each PML4 entry points to a page of Page Directory Pointer entries. - // - PageDirectoryPointerEntry = (UINT64 *) ((*PageMapLevel4Entry) & ~mAddressEncMask & gPhyMask); - if (PageDirectoryPointerEntry == NULL) { - PageDirectoryPointerEntry = AllocatePageTableMemory (1); - ASSERT(PageDirectoryPointerEntry != NULL); - ZeroMem (PageDirectoryPointerEntry, EFI_PAGES_TO_SIZE(1)); - - *PageMapLevel4Entry = (UINT64)(UINTN)PageDirectoryPointerEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - } - - if (m1GPageTableSupport) { - PageDirectory1GEntry = PageDirectoryPointerEntry; - for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) { - if (IndexOfPml4Entries == 0 && IndexOfPageDirectoryEntries < 4) { - // - // Skip the < 4G entries - // - continue; - } - // - // Fill in the Page Directory entries - // - *PageDirectory1GEntry = PageAddress | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; - } - } else { - PageAddress = BASE_4GB; - for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) { - if (IndexOfPml4Entries == 0 && IndexOfPdpEntries < 4) { - // - // Skip the < 4G entries - // - continue; - } - // - // Each Directory Pointer entries points to a page of Page Directory entires. - // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop. - // - PageDirectoryEntry = (UINT64 *) ((*PageDirectoryPointerEntry) & ~mAddressEncMask & gPhyMask); - if (PageDirectoryEntry == NULL) { - PageDirectoryEntry = AllocatePageTableMemory (1); - ASSERT(PageDirectoryEntry != NULL); - ZeroMem (PageDirectoryEntry, EFI_PAGES_TO_SIZE(1)); - - // - // Fill in a Page Directory Pointer Entries - // - *PageDirectoryPointerEntry = (UINT64)(UINTN)PageDirectoryEntry | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - } - - for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) { - // - // Fill in the Page Directory entries - // - *PageDirectoryEntry = PageAddress | mAddressEncMask | IA32_PG_PS | PAGE_ATTRIBUTE_BITS; - } - } - } - } -} - -/** - Create PageTable for SMM use. - - @return The address of PML4 (to set CR3). - -**/ -UINT32 -SmmInitPageTable ( - VOID - ) -{ - EFI_PHYSICAL_ADDRESS Pages; - UINT64 *PTEntry; - LIST_ENTRY *FreePage; - UINTN Index; - UINTN PageFaultHandlerHookAddress; - IA32_IDT_GATE_DESCRIPTOR *IdtEntry; - EFI_STATUS Status; - - // - // Initialize spin lock - // - InitializeSpinLock (mPFLock); - - mCpuSmmStaticPageTable = PcdGetBool (PcdCpuSmmStaticPageTable); - m1GPageTableSupport = Is1GPageSupport (); - DEBUG ((DEBUG_INFO, "1GPageTableSupport - 0x%x\n", m1GPageTableSupport)); - DEBUG ((DEBUG_INFO, "PcdCpuSmmStaticPageTable - 0x%x\n", mCpuSmmStaticPageTable)); - - mPhysicalAddressBits = CalculateMaximumSupportAddress (); - DEBUG ((DEBUG_INFO, "PhysicalAddressBits - 0x%x\n", mPhysicalAddressBits)); - // - // Generate PAE page table for the first 4GB memory space - // - Pages = Gen4GPageTable (FALSE); - - // - // Set IA32_PG_PMNT bit to mask this entry - // - PTEntry = (UINT64*)(UINTN)Pages; - for (Index = 0; Index < 4; Index++) { - PTEntry[Index] |= IA32_PG_PMNT; - } - - // - // Fill Page-Table-Level4 (PML4) entry - // - PTEntry = (UINT64*)AllocatePageTableMemory (1); - ASSERT (PTEntry != NULL); - *PTEntry = Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - ZeroMem (PTEntry + 1, EFI_PAGE_SIZE - sizeof (*PTEntry)); - - // - // Set sub-entries number - // - SetSubEntriesNum (PTEntry, 3); - - if (mCpuSmmStaticPageTable) { - SetStaticPageTable ((UINTN)PTEntry); - } else { - // - // Add pages to page pool - // - FreePage = (LIST_ENTRY*)AllocatePageTableMemory (PAGE_TABLE_PAGES); - ASSERT (FreePage != NULL); - for (Index = 0; Index < PAGE_TABLE_PAGES; Index++) { - InsertTailList (&mPagePool, FreePage); - FreePage += EFI_PAGE_SIZE / sizeof (*FreePage); - } - } - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - // - // Set own Page Fault entry instead of the default one, because SMM Profile - // feature depends on IRET instruction to do Single Step - // - PageFaultHandlerHookAddress = (UINTN)PageFaultIdtHandlerSmmProfile; - IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) gcSmiIdtr.Base; - IdtEntry += EXCEPT_IA32_PAGE_FAULT; - IdtEntry->Bits.OffsetLow = (UINT16)PageFaultHandlerHookAddress; - IdtEntry->Bits.Reserved_0 = 0; - IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; - IdtEntry->Bits.OffsetHigh = (UINT16)(PageFaultHandlerHookAddress >> 16); - IdtEntry->Bits.OffsetUpper = (UINT32)(PageFaultHandlerHookAddress >> 32); - IdtEntry->Bits.Reserved_1 = 0; - } else { - // - // Register Smm Page Fault Handler - // - Status = SmmRegisterExceptionHandler (&mSmmCpuService, EXCEPT_IA32_PAGE_FAULT, SmiPFHandler); - ASSERT_EFI_ERROR (Status); - } - - // - // Additional SMM IDT initialization for SMM stack guard - // - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - InitializeIDTSmmStackGuard (); - } - - // - // Return the address of PML4 (to set CR3) - // - return (UINT32)(UINTN)PTEntry; -} - -/** - Set access record in entry. - - @param[in, out] Entry Pointer to entry - @param[in] Acc Access record value - -**/ -VOID -SetAccNum ( - IN OUT UINT64 *Entry, - IN UINT64 Acc - ) -{ - // - // Access record is saved in BIT9 to BIT11 (reserved field) in Entry - // - *Entry = BitFieldWrite64 (*Entry, 9, 11, Acc); -} - -/** - Return access record in entry. - - @param[in] Entry Pointer to entry - - @return Access record value. - -**/ -UINT64 -GetAccNum ( - IN UINT64 *Entry - ) -{ - // - // Access record is saved in BIT9 to BIT11 (reserved field) in Entry - // - return BitFieldRead64 (*Entry, 9, 11); -} - -/** - Return and update the access record in entry. - - @param[in, out] Entry Pointer to entry - - @return Access record value. - -**/ -UINT64 -GetAndUpdateAccNum ( - IN OUT UINT64 *Entry - ) -{ - UINT64 Acc; - - Acc = GetAccNum (Entry); - if ((*Entry & IA32_PG_A) != 0) { - // - // If this entry has been accessed, clear access flag in Entry and update access record - // to the initial value 7, adding ACC_MAX_BIT is to make it larger than others - // - *Entry &= ~(UINT64)(UINTN)IA32_PG_A; - SetAccNum (Entry, 0x7); - return (0x7 + ACC_MAX_BIT); - } else { - if (Acc != 0) { - // - // If the access record is not the smallest value 0, minus 1 and update the access record field - // - SetAccNum (Entry, Acc - 1); - } - } - return Acc; -} - -/** - Reclaim free pages for PageFault handler. - - Search the whole entries tree to find the leaf entry that has the smallest - access record value. Insert the page pointed by this leaf entry into the - page pool. And check its upper entries if need to be inserted into the page - pool or not. - -**/ -VOID -ReclaimPages ( - VOID - ) -{ - UINT64 *Pml4; - UINT64 *Pdpt; - UINT64 *Pdt; - UINTN Pml4Index; - UINTN PdptIndex; - UINTN PdtIndex; - UINTN MinPml4; - UINTN MinPdpt; - UINTN MinPdt; - UINT64 MinAcc; - UINT64 Acc; - UINT64 SubEntriesNum; - BOOLEAN PML4EIgnore; - BOOLEAN PDPTEIgnore; - UINT64 *ReleasePageAddress; - - Pml4 = NULL; - Pdpt = NULL; - Pdt = NULL; - MinAcc = (UINT64)-1; - MinPml4 = (UINTN)-1; - MinPdpt = (UINTN)-1; - MinPdt = (UINTN)-1; - Acc = 0; - ReleasePageAddress = 0; - - // - // First, find the leaf entry has the smallest access record value - // - Pml4 = (UINT64*)(UINTN)(AsmReadCr3 () & gPhyMask); - for (Pml4Index = 0; Pml4Index < EFI_PAGE_SIZE / sizeof (*Pml4); Pml4Index++) { - if ((Pml4[Pml4Index] & IA32_PG_P) == 0 || (Pml4[Pml4Index] & IA32_PG_PMNT) != 0) { - // - // If the PML4 entry is not present or is masked, skip it - // - continue; - } - Pdpt = (UINT64*)(UINTN)(Pml4[Pml4Index] & ~mAddressEncMask & gPhyMask); - PML4EIgnore = FALSE; - for (PdptIndex = 0; PdptIndex < EFI_PAGE_SIZE / sizeof (*Pdpt); PdptIndex++) { - if ((Pdpt[PdptIndex] & IA32_PG_P) == 0 || (Pdpt[PdptIndex] & IA32_PG_PMNT) != 0) { - // - // If the PDPT entry is not present or is masked, skip it - // - if ((Pdpt[PdptIndex] & IA32_PG_PMNT) != 0) { - // - // If the PDPT entry is masked, we will ignore checking the PML4 entry - // - PML4EIgnore = TRUE; - } - continue; - } - if ((Pdpt[PdptIndex] & IA32_PG_PS) == 0) { - // - // It's not 1-GByte pages entry, it should be a PDPT entry, - // we will not check PML4 entry more - // - PML4EIgnore = TRUE; - Pdt = (UINT64*)(UINTN)(Pdpt[PdptIndex] & ~mAddressEncMask & gPhyMask); - PDPTEIgnore = FALSE; - for (PdtIndex = 0; PdtIndex < EFI_PAGE_SIZE / sizeof(*Pdt); PdtIndex++) { - if ((Pdt[PdtIndex] & IA32_PG_P) == 0 || (Pdt[PdtIndex] & IA32_PG_PMNT) != 0) { - // - // If the PD entry is not present or is masked, skip it - // - if ((Pdt[PdtIndex] & IA32_PG_PMNT) != 0) { - // - // If the PD entry is masked, we will not PDPT entry more - // - PDPTEIgnore = TRUE; - } - continue; - } - if ((Pdt[PdtIndex] & IA32_PG_PS) == 0) { - // - // It's not 2 MByte page table entry, it should be PD entry - // we will find the entry has the smallest access record value - // - PDPTEIgnore = TRUE; - Acc = GetAndUpdateAccNum (Pdt + PdtIndex); - if (Acc < MinAcc) { - // - // If the PD entry has the smallest access record value, - // save the Page address to be released - // - MinAcc = Acc; - MinPml4 = Pml4Index; - MinPdpt = PdptIndex; - MinPdt = PdtIndex; - ReleasePageAddress = Pdt + PdtIndex; - } - } - } - if (!PDPTEIgnore) { - // - // If this PDPT entry has no PDT entries pointer to 4 KByte pages, - // it should only has the entries point to 2 MByte Pages - // - Acc = GetAndUpdateAccNum (Pdpt + PdptIndex); - if (Acc < MinAcc) { - // - // If the PDPT entry has the smallest access record value, - // save the Page address to be released - // - MinAcc = Acc; - MinPml4 = Pml4Index; - MinPdpt = PdptIndex; - MinPdt = (UINTN)-1; - ReleasePageAddress = Pdpt + PdptIndex; - } - } - } - } - if (!PML4EIgnore) { - // - // If PML4 entry has no the PDPT entry pointer to 2 MByte pages, - // it should only has the entries point to 1 GByte Pages - // - Acc = GetAndUpdateAccNum (Pml4 + Pml4Index); - if (Acc < MinAcc) { - // - // If the PML4 entry has the smallest access record value, - // save the Page address to be released - // - MinAcc = Acc; - MinPml4 = Pml4Index; - MinPdpt = (UINTN)-1; - MinPdt = (UINTN)-1; - ReleasePageAddress = Pml4 + Pml4Index; - } - } - } - // - // Make sure one PML4/PDPT/PD entry is selected - // - ASSERT (MinAcc != (UINT64)-1); - - // - // Secondly, insert the page pointed by this entry into page pool and clear this entry - // - InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(*ReleasePageAddress & ~mAddressEncMask & gPhyMask)); - *ReleasePageAddress = 0; - - // - // Lastly, check this entry's upper entries if need to be inserted into page pool - // or not - // - while (TRUE) { - if (MinPdt != (UINTN)-1) { - // - // If 4 KByte Page Table is released, check the PDPT entry - // - Pdpt = (UINT64*)(UINTN)(Pml4[MinPml4] & ~mAddressEncMask & gPhyMask); - SubEntriesNum = GetSubEntriesNum(Pdpt + MinPdpt); - if (SubEntriesNum == 0) { - // - // Release the empty Page Directory table if there was no more 4 KByte Page Table entry - // clear the Page directory entry - // - InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(Pdpt[MinPdpt] & ~mAddressEncMask & gPhyMask)); - Pdpt[MinPdpt] = 0; - // - // Go on checking the PML4 table - // - MinPdt = (UINTN)-1; - continue; - } - // - // Update the sub-entries filed in PDPT entry and exit - // - SetSubEntriesNum (Pdpt + MinPdpt, SubEntriesNum - 1); - break; - } - if (MinPdpt != (UINTN)-1) { - // - // One 2MB Page Table is released or Page Directory table is released, check the PML4 entry - // - SubEntriesNum = GetSubEntriesNum (Pml4 + MinPml4); - if (SubEntriesNum == 0) { - // - // Release the empty PML4 table if there was no more 1G KByte Page Table entry - // clear the Page directory entry - // - InsertTailList (&mPagePool, (LIST_ENTRY*)(UINTN)(Pml4[MinPml4] & ~mAddressEncMask & gPhyMask)); - Pml4[MinPml4] = 0; - MinPdpt = (UINTN)-1; - continue; - } - // - // Update the sub-entries filed in PML4 entry and exit - // - SetSubEntriesNum (Pml4 + MinPml4, SubEntriesNum - 1); - break; - } - // - // PLM4 table has been released before, exit it - // - break; - } -} - -/** - Allocate free Page for PageFault handler use. - - @return Page address. - -**/ -UINT64 -AllocPage ( - VOID - ) -{ - UINT64 RetVal; - - if (IsListEmpty (&mPagePool)) { - // - // If page pool is empty, reclaim the used pages and insert one into page pool - // - ReclaimPages (); - } - - // - // Get one free page and remove it from page pool - // - RetVal = (UINT64)(UINTN)mPagePool.ForwardLink; - RemoveEntryList (mPagePool.ForwardLink); - // - // Clean this page and return - // - ZeroMem ((VOID*)(UINTN)RetVal, EFI_PAGE_SIZE); - return RetVal; -} - -/** - Page Fault handler for SMM use. - -**/ -VOID -SmiDefaultPFHandler ( - VOID - ) -{ - UINT64 *PageTable; - UINT64 *Pml4; - UINT64 PFAddress; - UINTN StartBit; - UINTN EndBit; - UINT64 PTIndex; - UINTN Index; - SMM_PAGE_SIZE_TYPE PageSize; - UINTN NumOfPages; - UINTN PageAttribute; - EFI_STATUS Status; - UINT64 *UpperEntry; - - // - // Set default SMM page attribute - // - PageSize = SmmPageSize2M; - NumOfPages = 1; - PageAttribute = 0; - - EndBit = 0; - Pml4 = (UINT64*)(AsmReadCr3 () & gPhyMask); - PFAddress = AsmReadCr2 (); - - Status = GetPlatformPageTableAttribute (PFAddress, &PageSize, &NumOfPages, &PageAttribute); - // - // If platform not support page table attribute, set default SMM page attribute - // - if (Status != EFI_SUCCESS) { - PageSize = SmmPageSize2M; - NumOfPages = 1; - PageAttribute = 0; - } - if (PageSize >= MaxSmmPageSizeType) { - PageSize = SmmPageSize2M; - } - if (NumOfPages > 512) { - NumOfPages = 512; - } - - switch (PageSize) { - case SmmPageSize4K: - // - // BIT12 to BIT20 is Page Table index - // - EndBit = 12; - break; - case SmmPageSize2M: - // - // BIT21 to BIT29 is Page Directory index - // - EndBit = 21; - PageAttribute |= (UINTN)IA32_PG_PS; - break; - case SmmPageSize1G: - if (!m1GPageTableSupport) { - DEBUG ((DEBUG_ERROR, "1-GByte pages is not supported!")); - ASSERT (FALSE); - } - // - // BIT30 to BIT38 is Page Directory Pointer Table index - // - EndBit = 30; - PageAttribute |= (UINTN)IA32_PG_PS; - break; - default: - ASSERT (FALSE); - } - - // - // If execute-disable is enabled, set NX bit - // - if (mXdEnabled) { - PageAttribute |= IA32_PG_NX; - } - - for (Index = 0; Index < NumOfPages; Index++) { - PageTable = Pml4; - UpperEntry = NULL; - for (StartBit = 39; StartBit > EndBit; StartBit -= 9) { - PTIndex = BitFieldRead64 (PFAddress, StartBit, StartBit + 8); - if ((PageTable[PTIndex] & IA32_PG_P) == 0) { - // - // If the entry is not present, allocate one page from page pool for it - // - PageTable[PTIndex] = AllocPage () | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - } else { - // - // Save the upper entry address - // - UpperEntry = PageTable + PTIndex; - } - // - // BIT9 to BIT11 of entry is used to save access record, - // initialize value is 7 - // - PageTable[PTIndex] |= (UINT64)IA32_PG_A; - SetAccNum (PageTable + PTIndex, 7); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & gPhyMask); - } - - PTIndex = BitFieldRead64 (PFAddress, StartBit, StartBit + 8); - if ((PageTable[PTIndex] & IA32_PG_P) != 0) { - // - // Check if the entry has already existed, this issue may occur when the different - // size page entries created under the same entry - // - DEBUG ((DEBUG_ERROR, "PageTable = %lx, PTIndex = %x, PageTable[PTIndex] = %lx\n", PageTable, PTIndex, PageTable[PTIndex])); - DEBUG ((DEBUG_ERROR, "New page table overlapped with old page table!\n")); - ASSERT (FALSE); - } - // - // Fill the new entry - // - PageTable[PTIndex] = ((PFAddress | mAddressEncMask) & gPhyMask & ~((1ull << EndBit) - 1)) | - PageAttribute | IA32_PG_A | PAGE_ATTRIBUTE_BITS; - if (UpperEntry != NULL) { - SetSubEntriesNum (UpperEntry, GetSubEntriesNum (UpperEntry) + 1); - } - // - // Get the next page address if we need to create more page tables - // - PFAddress += (1ull << EndBit); - } -} - -/** - ThePage Fault handler wrapper for SMM use. - - @param InterruptType Defines the type of interrupt or exception that - occurred on the processor.This parameter is processor architecture specific. - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. -**/ -VOID -EFIAPI -SmiPFHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, - IN EFI_SYSTEM_CONTEXT SystemContext - ) -{ - UINTN PFAddress; - UINTN GuardPageAddress; - UINTN CpuIndex; - - ASSERT (InterruptType == EXCEPT_IA32_PAGE_FAULT); - - AcquireSpinLock (mPFLock); - - PFAddress = AsmReadCr2 (); - - if (mCpuSmmStaticPageTable && (PFAddress >= LShiftU64 (1, (mPhysicalAddressBits - 1)))) { - DumpCpuContext (InterruptType, SystemContext); - DEBUG ((DEBUG_ERROR, "Do not support address 0x%lx by processor!\n", PFAddress)); - CpuDeadLoop (); - } - - // - // If a page fault occurs in SMRAM range, it might be in a SMM stack guard page, - // or SMM page protection violation. - // - if ((PFAddress >= mCpuHotPlugData.SmrrBase) && - (PFAddress < (mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize))) { - DumpCpuContext (InterruptType, SystemContext); - CpuIndex = GetCpuIndex (); - GuardPageAddress = (mSmmStackArrayBase + EFI_PAGE_SIZE + CpuIndex * mSmmStackSize); - if ((FeaturePcdGet (PcdCpuSmmStackGuard)) && - (PFAddress >= GuardPageAddress) && - (PFAddress < (GuardPageAddress + EFI_PAGE_SIZE))) { - DEBUG ((DEBUG_ERROR, "SMM stack overflow!\n")); - } else { - if ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0) { - DEBUG ((DEBUG_ERROR, "SMM exception at execution (0x%lx)\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp); - ); - } else { - DEBUG ((DEBUG_ERROR, "SMM exception at access (0x%lx)\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); - ); - } - } - CpuDeadLoop (); - } - - // - // If a page fault occurs in SMM range - // - if ((PFAddress < mCpuHotPlugData.SmrrBase) || - (PFAddress >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) { - DumpCpuContext (InterruptType, SystemContext); - if ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0) { - DEBUG ((DEBUG_ERROR, "Code executed on IP(0x%lx) out of SMM range after SMM is locked!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp (*(UINTN *)(UINTN)SystemContext.SystemContextX64->Rsp); - ); - CpuDeadLoop (); - } - if (IsSmmCommBufferForbiddenAddress (PFAddress)) { - DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress)); - DEBUG_CODE ( - DumpModuleInfoByIp ((UINTN)SystemContext.SystemContextX64->Rip); - ); - CpuDeadLoop (); - } - } - - if (FeaturePcdGet (PcdCpuSmmProfileEnable)) { - SmmProfilePFHandler ( - SystemContext.SystemContextX64->Rip, - SystemContext.SystemContextX64->ExceptionData - ); - } else { - SmiDefaultPFHandler (); - } - - ReleaseSpinLock (mPFLock); -} - -/** - This function sets memory attribute for page table. -**/ -VOID -SetPageTableAttributes ( - VOID - ) -{ - UINTN Index2; - UINTN Index3; - UINTN Index4; - UINT64 *L1PageTable; - UINT64 *L2PageTable; - UINT64 *L3PageTable; - UINT64 *L4PageTable; - BOOLEAN IsSplitted; - BOOLEAN PageTableSplitted; - - if (!mCpuSmmStaticPageTable) { - return ; - } - - DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n")); - - // - // Disable write protection, because we need mark page table to be write protected. - // We need *write* page table memory, to mark itself to be *read only*. - // - AsmWriteCr0 (AsmReadCr0() & ~CR0_WP); - - do { - DEBUG ((DEBUG_INFO, "Start...\n")); - PageTableSplitted = FALSE; - - L4PageTable = (UINT64 *)GetPageTableBase (); - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L4PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - - for (Index4 = 0; Index4 < SIZE_4KB/sizeof(UINT64); Index4++) { - L3PageTable = (UINT64 *)(UINTN)(L4PageTable[Index4] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L3PageTable == NULL) { - continue; - } - - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L3PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - - for (Index3 = 0; Index3 < SIZE_4KB/sizeof(UINT64); Index3++) { - if ((L3PageTable[Index3] & IA32_PG_PS) != 0) { - // 1G - continue; - } - L2PageTable = (UINT64 *)(UINTN)(L3PageTable[Index3] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L2PageTable == NULL) { - continue; - } - - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L2PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - - for (Index2 = 0; Index2 < SIZE_4KB/sizeof(UINT64); Index2++) { - if ((L2PageTable[Index2] & IA32_PG_PS) != 0) { - // 2M - continue; - } - L1PageTable = (UINT64 *)(UINTN)(L2PageTable[Index2] & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64); - if (L1PageTable == NULL) { - continue; - } - SmmSetMemoryAttributesEx ((EFI_PHYSICAL_ADDRESS)(UINTN)L1PageTable, SIZE_4KB, EFI_MEMORY_RO, &IsSplitted); - PageTableSplitted = (PageTableSplitted || IsSplitted); - } - } - } - } while (PageTableSplitted); - - // - // Enable write protection, after page table updated. - // - AsmWriteCr0 (AsmReadCr0() | CR0_WP); - - return ; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c deleted file mode 100644 index 6dbcb086aa..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c +++ /dev/null @@ -1,67 +0,0 @@ -/** @file -Semaphore mechanism to indicate to the BSP that an AP has exited SMM -after SMBASE relocation. - -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -extern UINT32 mSmmRelocationOriginalAddressPtr32; -extern UINT32 mRebasedFlagAddr32; - -UINTN mSmmRelocationOriginalAddress; -volatile BOOLEAN *mRebasedFlag; - -/** -AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode. -**/ -VOID -SmmRelocationSemaphoreComplete32 ( - VOID - ); - -/** - Hook return address of SMM Save State so that semaphore code - can be executed immediately after AP exits SMM to indicate to - the BSP that an AP has exited SMM after SMBASE relocation. - - @param[in] CpuIndex The processor index. - @param[in] RebasedFlag A pointer to a flag that is set to TRUE - immediately after AP exits SMM. - -**/ -VOID -SemaphoreHook ( - IN UINTN CpuIndex, - IN volatile BOOLEAN *RebasedFlag - ) -{ - SMRAM_SAVE_STATE_MAP *CpuState; - UINTN TempValue; - - mRebasedFlag = RebasedFlag; - mRebasedFlagAddr32 = (UINT32)(UINTN)mRebasedFlag; - - CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); - mSmmRelocationOriginalAddress = HookReturnFromSmm ( - CpuIndex, - CpuState, - (UINT64)(UINTN)&SmmRelocationSemaphoreComplete32, - (UINT64)(UINTN)&SmmRelocationSemaphoreComplete - ); - - // - // Use temp value to fix ICC complier warning - // - TempValue = (UINTN)&mSmmRelocationOriginalAddress; - mSmmRelocationOriginalAddressPtr32 = (UINT32)TempValue; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S deleted file mode 100644 index 600d8623cd..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S +++ /dev/null @@ -1,243 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiEntry.S -# -# Abstract: -# -# Code template of the SMI handler for a particular processor -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gcSmiHandlerTemplate) -ASM_GLOBAL ASM_PFX(gcSmiHandlerSize) -ASM_GLOBAL ASM_PFX(gSmiCr3) -ASM_GLOBAL ASM_PFX(gSmiStack) -ASM_GLOBAL ASM_PFX(gSmbase) -ASM_GLOBAL ASM_PFX(mXdSupported) -ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr) - -.equ MSR_IA32_MISC_ENABLE, 0x1A0 -.equ MSR_EFER, 0xc0000080 -.equ MSR_EFER_XD, 0x800 - -# -# Constants relating to PROCESSOR_SMM_DESCRIPTOR -# -.equ DSC_OFFSET, 0xfb00 -.equ DSC_GDTPTR, 0x30 -.equ DSC_GDTSIZ, 0x38 -.equ DSC_CS, 14 -.equ DSC_DS, 16 -.equ DSC_SS, 18 -.equ DSC_OTHERSEG, 20 -# -# Constants relating to CPU State Save Area -# -.equ SSM_DR6, 0xffd0 -.equ SSM_DR7, 0xffc8 - -.equ PROTECT_MODE_CS, 0x08 -.equ PROTECT_MODE_DS, 0x20 -.equ LONG_MODE_CS, 0x38 -.equ TSS_SEGMENT, 0x40 -.equ GDT_SIZE, 0x50 - - .text - -ASM_PFX(gcSmiHandlerTemplate): - -_SmiEntryPoint: - # - # The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- - # bit addressing mode. And that coincidence has been used in the following - # "64-bit like" 16-bit code. Be aware that once RDI is referenced as a - # base address register, it is actually BX that is referenced. - # - .byte 0xbb # mov bx, imm16 - .word _GdtDesc - _SmiEntryPoint + 0x8000 - # - # fix GDT descriptor - # - .byte 0x2e,0xa1 # mov ax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTSIZ - .byte 0x48 # dec ax - .byte 0x2e - movl %eax, (%rdi) # mov cs:[bx], ax - .byte 0x66,0x2e,0xa1 # mov eax, cs:[offset16] - .word DSC_OFFSET + DSC_GDTPTR - .byte 0x2e - movw %ax, 2(%rdi) - .byte 0x66,0x2e - lgdt (%rdi) - # - # Patch ProtectedMode Segment - # - .byte 0xb8 - .word PROTECT_MODE_CS - .byte 0x2e - movl %eax, -2(%rdi) - # - # Patch ProtectedMode entry - # - .byte 0x66, 0xbf # mov edi, SMBASE -ASM_PFX(gSmbase): .space 4 - lea ((ProtectedMode - _SmiEntryPoint) + 0x8000)(%edi), %ax - .byte 0x2e - movw %ax, -6(%rdi) - # - # Switch into ProtectedMode - # - movq %cr0, %rbx - .byte 0x66 - andl $0x9ffafff3, %ebx - .byte 0x66 - orl $0x00000023, %ebx - - movq %rbx, %cr0 - .byte 0x66, 0xea - .space 6 - -_GdtDesc: .space 6 - -ProtectedMode: - movw $PROTECT_MODE_DS, %ax - movl %eax, %ds - movl %eax, %es - movl %eax, %fs - movl %eax, %gs - movl %eax, %ss - .byte 0xbc # mov esp, imm32 -ASM_PFX(gSmiStack): .space 4 - jmp ProtFlatMode - -ProtFlatMode: - .byte 0xb8 -ASM_PFX(gSmiCr3): .space 4 - movq %rax, %cr3 - movl $0x668,%eax # as cr4.PGE is not set here, refresh cr3 - movq %rax, %cr4 # in PreModifyMtrrs() to flush TLB. -# Load TSS - subl $8, %esp # reserve room in stack - sgdt (%rsp) - movl 2(%rsp), %eax # eax = GDT base - addl $8, %esp - movb $0x89, %dl - movb %dl, (TSS_SEGMENT + 5)(%rax) # clear busy flag - movl $TSS_SEGMENT, %eax - ltr %ax - -# enable NXE if supported - .byte 0xb0 # mov al, imm8 -ASM_PFX(mXdSupported): .byte 1 - cmpb $0, %al - jz SkipNxe -# -# Check XD disable bit -# - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - subl $4, %esp - pushq %rdx # save MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34] - jz L13 - andw $0x0FFFB, %dx # clear XD Disable bit if it is set - wrmsr -L13: - movl $MSR_EFER, %ecx - rdmsr - orw $MSR_EFER_XD,%ax # enable NXE - wrmsr - jmp NxeDone -SkipNxe: - subl $8, %esp -NxeDone: - - # - # Switch to LongMode - # - pushq $LONG_MODE_CS # push cs hardcore here - call Base # push return address for retf later -Base: - addl $(LongMode - Base), (%rsp) # offset for far retf, seg is the 1st arg - - movl $MSR_EFER, %ecx - rdmsr - orb $1,%ah # enable LME - wrmsr - movq %cr0, %rbx - orl $0x080010023, %ebx # enable paging + WP + NE + MP + PE - movq %rbx, %cr0 - retf -LongMode: # long mode (64-bit code) starts here - movabsq $ASM_PFX(gSmiHandlerIdtr), %rax - lidt (%rax) - lea (DSC_OFFSET)(%rdi), %ebx - movw DSC_DS(%rbx), %ax - movl %eax,%ds - movw DSC_OTHERSEG(%rbx), %ax - movl %eax,%es - movl %eax,%fs - movl %eax,%gs - movw DSC_SS(%rbx), %ax - movl %eax,%ss -# jmp _SmiHandler ; instruction is not needed - -_SmiHandler: - movq 8(%rsp), %rbx - # Save FP registers - - subq $0x200, %rsp - .byte 0x48 # FXSAVE64 - fxsave (%rsp) - - addq $-0x20, %rsp - - movq %rbx, %rcx - movabsq $ASM_PFX(CpuSmmDebugEntry), %rax - call *%rax - - movq %rbx, %rcx - movabsq $ASM_PFX(SmiRendezvous), %rax - call *%rax - - movq %rbx, %rcx - movabsq $ASM_PFX(CpuSmmDebugExit), %rax - call *%rax - - addq $0x20, %rsp - - # - # Restore FP registers - # - .byte 0x48 # FXRSTOR64 - fxrstor (%rsp) - - addq $0x200, %rsp - - movabsq $ASM_PFX(mXdSupported), %rax - movb (%rax), %al - cmpb $0, %al - jz L16 - popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32] - testl $BIT2, %edx - jz L16 - movl $MSR_IA32_MISC_ENABLE, %ecx - rdmsr - orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM - wrmsr - -L16: - rsm - -ASM_PFX(gcSmiHandlerSize): .word . - _SmiEntryPoint diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm deleted file mode 100644 index c74f82aac8..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm +++ /dev/null @@ -1,242 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.asm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -; -; Variables referenced by C code -; -EXTERNDEF SmiRendezvous:PROC -EXTERNDEF CpuSmmDebugEntry:PROC -EXTERNDEF CpuSmmDebugExit:PROC -EXTERNDEF gcSmiHandlerTemplate:BYTE -EXTERNDEF gcSmiHandlerSize:WORD -EXTERNDEF gSmiCr3:DWORD -EXTERNDEF gSmiStack:DWORD -EXTERNDEF gSmbase:DWORD -EXTERNDEF mXdSupported:BYTE -EXTERNDEF gSmiHandlerIdtr:FWORD - -MSR_IA32_MISC_ENABLE EQU 1A0h -MSR_EFER EQU 0c0000080h -MSR_EFER_XD EQU 0800h - -; -; Constants relating to PROCESSOR_SMM_DESCRIPTOR -; -DSC_OFFSET EQU 0fb00h -DSC_GDTPTR EQU 30h -DSC_GDTSIZ EQU 38h -DSC_CS EQU 14 -DSC_DS EQU 16 -DSC_SS EQU 18 -DSC_OTHERSEG EQU 20 -; -; Constants relating to CPU State Save Area -; -SSM_DR6 EQU 0ffd0h -SSM_DR7 EQU 0ffc8h - -PROTECT_MODE_CS EQU 08h -PROTECT_MODE_DS EQU 20h -LONG_MODE_CS EQU 38h -TSS_SEGMENT EQU 40h -GDT_SIZE EQU 50h - - .code - -gcSmiHandlerTemplate LABEL BYTE - -_SmiEntryPoint: - ; - ; The encoding of BX in 16-bit addressing mode is the same as of RDI in 64- - ; bit addressing mode. And that coincidence has been used in the following - ; "64-bit like" 16-bit code. Be aware that once RDI is referenced as a - ; base address register, it is actually BX that is referenced. - ; - DB 0bbh ; mov bx, imm16 - DW offset _GdtDesc - _SmiEntryPoint + 8000h ; bx = GdtDesc offset -; fix GDT descriptor - DB 2eh, 0a1h ; mov ax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTSIZ - DB 48h ; dec ax - DB 2eh - mov [rdi], eax ; mov cs:[bx], ax - DB 66h, 2eh, 0a1h ; mov eax, cs:[offset16] - DW DSC_OFFSET + DSC_GDTPTR - DB 2eh - mov [rdi + 2], ax ; mov cs:[bx + 2], eax - DB 66h, 2eh - lgdt fword ptr [rdi] ; lgdt fword ptr cs:[bx] -; Patch ProtectedMode Segment - DB 0b8h ; mov ax, imm16 - DW PROTECT_MODE_CS ; set AX for segment directly - DB 2eh - mov [rdi - 2], eax ; mov cs:[bx - 2], ax -; Patch ProtectedMode entry - DB 66h, 0bfh ; mov edi, SMBASE -gSmbase DD ? - lea ax, [edi + (@ProtectedMode - _SmiEntryPoint) + 8000h] - DB 2eh - mov [rdi - 6], ax ; mov cs:[bx - 6], eax -; Switch into @ProtectedMode - mov rbx, cr0 - DB 66h - and ebx, 9ffafff3h - DB 66h - or ebx, 00000023h - - mov cr0, rbx - DB 66h, 0eah - DD ? - DW ? - -_GdtDesc FWORD ? -@ProtectedMode: - mov ax, PROTECT_MODE_DS - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - DB 0bch ; mov esp, imm32 -gSmiStack DD ? - jmp ProtFlatMode - -ProtFlatMode: - DB 0b8h ; mov eax, offset gSmiCr3 -gSmiCr3 DD ? - mov cr3, rax - mov eax, 668h ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. -; Load TSS - sub esp, 8 ; reserve room in stack - sgdt fword ptr [rsp] - mov eax, [rsp + 2] ; eax = GDT base - add esp, 8 - mov dl, 89h - mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax - -; enable NXE if supported - DB 0b0h ; mov al, imm8 -mXdSupported DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - sub esp, 4 - push rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz @f - and dx, 0FFFBh ; clear XD Disable bit if it is set - wrmsr -@@: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 8 -@XdDone: - -; Switch into @LongMode - push LONG_MODE_CS ; push cs hardcore here - call Base ; push return address for retf later -Base: - add dword ptr [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg - - mov ecx, MSR_EFER - rdmsr - or ah, 1 ; enable LME - wrmsr - mov rbx, cr0 - or ebx, 080010023h ; enable paging + WP + NE + MP + PE - mov cr0, rbx - retf -@LongMode: ; long mode (64-bit code) starts here - mov rax, offset gSmiHandlerIdtr - lidt fword ptr [rax] - lea ebx, [rdi + DSC_OFFSET] - mov ax, [rbx + DSC_DS] - mov ds, eax - mov ax, [rbx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [rbx + DSC_SS] - mov ss, eax -; jmp _SmiHandler ; instruction is not needed - -_SmiHandler: - mov rbx, [rsp] ; rbx <- CpuIndex - - ; - ; Save FP registers - ; - sub rsp, 200h - DB 48h ; FXSAVE64 - fxsave [rsp] - - add rsp, -20h - - mov rcx, rbx - mov rax, CpuSmmDebugEntry - call rax - - mov rcx, rbx - mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous - call rax - - mov rcx, rbx - mov rax, CpuSmmDebugExit - call rax - - add rsp, 20h - - ; - ; Restore FP registers - ; - DB 48h ; FXRSTOR64 - fxrstor [rsp] - - add rsp, 200h - - mov rax, offset ASM_PFX(mXdSupported) - mov al, [rax] - cmp al, 0 - jz @f - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz @f - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -@@: - rsm - -gcSmiHandlerSize DW $ - _SmiEntryPoint - - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm deleted file mode 100644 index c3c094ff9f..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm +++ /dev/null @@ -1,224 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiEntry.nasm -; -; Abstract: -; -; Code template of the SMI handler for a particular processor -; -;------------------------------------------------------------------------------- - -; -; Variables referrenced by C code -; - -%define MSR_IA32_MISC_ENABLE 0x1A0 -%define MSR_EFER 0xc0000080 -%define MSR_EFER_XD 0x800 - -; -; Constants relating to PROCESSOR_SMM_DESCRIPTOR -; -%define DSC_OFFSET 0xfb00 -%define DSC_GDTPTR 0x30 -%define DSC_GDTSIZ 0x38 -%define DSC_CS 14 -%define DSC_DS 16 -%define DSC_SS 18 -%define DSC_OTHERSEG 20 -; -; Constants relating to CPU State Save Area -; -%define SSM_DR6 0xffd0 -%define SSM_DR7 0xffc8 - -%define PROTECT_MODE_CS 0x8 -%define PROTECT_MODE_DS 0x20 -%define LONG_MODE_CS 0x38 -%define TSS_SEGMENT 0x40 -%define GDT_SIZE 0x50 - -extern ASM_PFX(SmiRendezvous) -extern ASM_PFX(gSmiHandlerIdtr) -extern ASM_PFX(CpuSmmDebugEntry) -extern ASM_PFX(CpuSmmDebugExit) - -global ASM_PFX(gSmbase) -global ASM_PFX(mXdSupported) -global ASM_PFX(gSmiStack) -global ASM_PFX(gSmiCr3) -global ASM_PFX(gcSmiHandlerTemplate) -global ASM_PFX(gcSmiHandlerSize) - - DEFAULT REL - SECTION .text - -BITS 16 -ASM_PFX(gcSmiHandlerTemplate): -_SmiEntryPoint: - mov bx, _GdtDesc - _SmiEntryPoint + 0x8000 - mov ax,[cs:DSC_OFFSET + DSC_GDTSIZ] - dec ax - mov [cs:bx], ax - mov eax, [cs:DSC_OFFSET + DSC_GDTPTR] - mov [cs:bx + 2], eax -o32 lgdt [cs:bx] ; lgdt fword ptr cs:[bx] - mov ax, PROTECT_MODE_CS - mov [cs:bx-0x2],ax - DB 0x66, 0xbf ; mov edi, SMBASE -ASM_PFX(gSmbase): DD 0 - lea eax, [edi + (@ProtectedMode - _SmiEntryPoint) + 0x8000] - mov [cs:bx-0x6],eax - mov ebx, cr0 - and ebx, 0x9ffafff3 - or ebx, 0x23 - mov cr0, ebx - jmp dword 0x0:0x0 -_GdtDesc: - DW 0 - DD 0 - -BITS 32 -@ProtectedMode: - mov ax, PROTECT_MODE_DS -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax - DB 0xbc ; mov esp, imm32 -ASM_PFX(gSmiStack): DD 0 - jmp ProtFlatMode - -BITS 64 -ProtFlatMode: - DB 0xb8 ; mov eax, offset gSmiCr3 -ASM_PFX(gSmiCr3): DD 0 - mov cr3, rax - mov eax, 0x668 ; as cr4.PGE is not set here, refresh cr3 - mov cr4, rax ; in PreModifyMtrrs() to flush TLB. -; Load TSS - sub esp, 8 ; reserve room in stack - sgdt [rsp] - mov eax, [rsp + 2] ; eax = GDT base - add esp, 8 - mov dl, 0x89 - mov [rax + TSS_SEGMENT + 5], dl ; clear busy flag - mov eax, TSS_SEGMENT - ltr ax - -; enable NXE if supported - DB 0xb0 ; mov al, imm8 -ASM_PFX(mXdSupported): DB 1 - cmp al, 0 - jz @SkipXd -; -; Check XD disable bit -; - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - sub esp, 4 - push rdx ; save MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34] - jz .0 - and dx, 0xFFFB ; clear XD Disable bit if it is set - wrmsr -.0: - mov ecx, MSR_EFER - rdmsr - or ax, MSR_EFER_XD ; enable NXE - wrmsr - jmp @XdDone -@SkipXd: - sub esp, 8 -@XdDone: - -; Switch into @LongMode - push LONG_MODE_CS ; push cs hardcore here - call Base ; push return address for retf later -Base: - add dword [rsp], @LongMode - Base; offset for far retf, seg is the 1st arg - - mov ecx, MSR_EFER - rdmsr - or ah, 1 ; enable LME - wrmsr - mov rbx, cr0 - or ebx, 0x80010023 ; enable paging + WP + NE + MP + PE - mov cr0, rbx - retf -@LongMode: ; long mode (64-bit code) starts here - mov rax, ASM_PFX(gSmiHandlerIdtr) - lidt [rax] - lea ebx, [rdi + DSC_OFFSET] - mov ax, [rbx + DSC_DS] - mov ds, eax - mov ax, [rbx + DSC_OTHERSEG] - mov es, eax - mov fs, eax - mov gs, eax - mov ax, [rbx + DSC_SS] - mov ss, eax -; jmp _SmiHandler ; instruction is not needed - -_SmiHandler: - mov rbx, [rsp + 0x8] ; rcx <- CpuIndex - - ; - ; Save FP registers - ; - sub rsp, 0x200 - DB 0x48 ; FXSAVE64 - fxsave [rsp] - - add rsp, -0x20 - - mov rcx, rbx - mov rax, CpuSmmDebugEntry - call rax - - mov rcx, rbx - mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous - call rax - - mov rcx, rbx - mov rax, CpuSmmDebugExit - call rax - - add rsp, 0x20 - - ; - ; Restore FP registers - ; - DB 0x48 ; FXRSTOR64 - fxrstor [rsp] - - add rsp, 0x200 - - mov rax, ASM_PFX(mXdSupported) - mov al, [rax] - cmp al, 0 - jz .1 - pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32] - test edx, BIT2 - jz .1 - mov ecx, MSR_IA32_MISC_ENABLE - rdmsr - or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM - wrmsr - -.1: - rsm - -gcSmiHandlerSize DW $ - _SmiEntryPoint - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S deleted file mode 100644 index 338bb70dd8..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S +++ /dev/null @@ -1,365 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmiException.S -# -# Abstract: -# -# Exception handlers used in SM mode -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(SmiPFHandler) -ASM_GLOBAL ASM_PFX(gcSmiIdtr) -ASM_GLOBAL ASM_PFX(gcSmiGdtr) -ASM_GLOBAL ASM_PFX(gcPsd) - - .data - -NullSeg: .quad 0 # reserved by architecture -CodeSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -ProtModeCodeSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -ProtModeSsSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x93 - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -DataSeg32: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x93 - .byte 0xcf # LimitHigh - .byte 0 # BaseHigh -CodeSeg16: - .word -1 - .word 0 - .byte 0 - .byte 0x9b - .byte 0x8f - .byte 0 -DataSeg16: - .word -1 - .word 0 - .byte 0 - .byte 0x93 - .byte 0x8f - .byte 0 -CodeSeg64: - .word -1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x9b - .byte 0xaf # LimitHigh - .byte 0 # BaseHigh -# TSS Segment for X64 specially -TssSeg: - .word TSS_DESC_SIZE - 1 # LimitLow - .word 0 # BaseLow - .byte 0 # BaseMid - .byte 0x89 - .byte 0x00 # LimitHigh - .byte 0 # BaseHigh - .long 0 # BaseUpper - .long 0 # Reserved -.equ GDT_SIZE, .- NullSeg - -TssDescriptor: - .space 104, 0 -.equ TSS_DESC_SIZE, .- TssDescriptor - -# -# This structure serves as a template for all processors. -# -ASM_PFX(gcPsd): - .ascii "PSDSIG " - .word PSD_SIZE - .word 2 - .word 1 << 2 - .word CODE_SEL - .word DATA_SEL - .word DATA_SEL - .word DATA_SEL - .word 0 - .quad 0 - .quad 0 - .quad 0 # fixed in InitializeMpServiceData() - .quad NullSeg - .long GDT_SIZE - .long 0 - .space 24, 0 - .quad 0 -.equ PSD_SIZE, . - ASM_PFX(gcPsd) - -# -# CODE & DATA segments for SMM runtime -# -.equ CODE_SEL, CodeSeg64 - NullSeg -.equ DATA_SEL, DataSeg32 - NullSeg -.equ CODE32_SEL, CodeSeg32 - NullSeg - -ASM_PFX(gcSmiGdtr): - .word GDT_SIZE - 1 - .quad NullSeg - -ASM_PFX(gcSmiIdtr): - .word 0 - .quad 0 - - .text - -#------------------------------------------------------------------------------ -# _SmiExceptionEntryPoints is the collection of exception entry points followed -# by a common exception handler. -# -# Stack frame would be as follows as specified in IA32 manuals: -# +---------------------+ <-- 16-byte aligned ensured by processor -# + Old SS + -# +---------------------+ -# + Old RSP + -# +---------------------+ -# + RFlags + -# +---------------------+ -# + CS + -# +---------------------+ -# + RIP + -# +---------------------+ -# + Error Code + -# +---------------------+ -# + Vector Number + -# +---------------------+ -# + RBP + -# +---------------------+ <-- RBP, 16-byte aligned -# -# RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(PageFaultIdtHandlerSmmProfile) -ASM_PFX(PageFaultIdtHandlerSmmProfile): - pushq $0x0e # Page Fault - .byte 0x40, 0xf6, 0xc4, 0x08 #test spl, 8 - jnz L1 - pushq (%rsp) - movq $0, 8(%rsp) -L1: - pushq %rbp - movq %rsp, %rbp - - # - # Since here the stack pointer is 16-byte aligned, so - # EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - # is 16-byte aligned - # - -## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -## UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pushq %r15 - pushq %r14 - pushq %r13 - pushq %r12 - pushq %r11 - pushq %r10 - pushq %r9 - pushq %r8 - pushq %rax - pushq %rcx - pushq %rdx - pushq %rbx - pushq 48(%rbp) # RSP - pushq (%rbp) # RBP - pushq %rsi - pushq %rdi - -## UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzwq 56(%rbp), %rax - pushq %rax # for ss - movzwq 32(%rbp), %rax - pushq %rax # for cs - movq %ds, %rax - pushq %rax - movq %es, %rax - pushq %rax - movq %fs, %rax - pushq %rax - movq %gs, %rax - pushq %rax - -## UINT64 Rip; - pushq 24(%rbp) - -## UINT64 Gdtr[2], Idtr[2]; - subq $16, %rsp - sidt (%rsp) - subq $16, %rsp - sgdt (%rsp) - -## UINT64 Ldtr, Tr; - xorq %rax, %rax - strw %ax - pushq %rax - sldtw %ax - pushq %rax - -## UINT64 RFlags; - pushq 40(%rbp) - -## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - movq %cr8, %rax - pushq %rax - movq %cr4, %rax - orq $0x208, %rax - movq %rax, %cr4 - pushq %rax - movq %cr3, %rax - pushq %rax - movq %cr2, %rax - pushq %rax - xorq %rax, %rax - pushq %rax - movq %cr0, %rax - pushq %rax - -## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - movq %dr7, %rax - pushq %rax - movq %dr6, %rax - pushq %rax - movq %dr3, %rax - pushq %rax - movq %dr2, %rax - pushq %rax - movq %dr1, %rax - pushq %rax - movq %dr0, %rax - pushq %rax - -## FX_SAVE_STATE_X64 FxSaveState; - - subq $512, %rsp - movq %rsp, %rdi - .byte 0xf, 0xae, 0x7 # fxsave [rdi] - -# UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -## UINT32 ExceptionData; - pushq 16(%rbp) - -## call into exception handler - movq 8(%rbp), %rcx - movabsq $ASM_PFX(SmiPFHandler), %rax - -## Prepare parameter and call - movq %rsp, %rdx - # - # Per X64 calling convention, allocate maximum parameter stack space - # and make sure RSP is 16-byte aligned - # - subq $4 * 8 + 8, %rsp - call *%rax - addq $4 * 8 + 8, %rsp - jmp L5 - -L5: -## UINT64 ExceptionData; - addq $8, %rsp - -## FX_SAVE_STATE_X64 FxSaveState; - - movq %rsp, %rsi - .byte 0xf, 0xae, 0xe # fxrstor [rsi] - addq $512, %rsp - -## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -## Skip restoration of DRx registers to support debuggers -## that set breakpoints in interrupt/exception context - addq $8 * 6, %rsp - -## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - popq %rax - movq %rax, %cr0 - addq $8, %rsp # not for Cr1 - popq %rax - movq %rax, %cr2 - popq %rax - movq %rax, %cr3 - popq %rax - movq %rax, %cr4 - popq %rax - movq %rax, %cr8 - -## UINT64 RFlags; - popq 40(%rbp) - -## UINT64 Ldtr, Tr; -## UINT64 Gdtr[2], Idtr[2]; -## Best not let anyone mess with these particular registers... - addq $48, %rsp - -## UINT64 Rip; - popq 24(%rbp) - -## UINT64 Gs, Fs, Es, Ds, Cs, Ss; - popq %rax - # mov gs, rax ; not for gs - popq %rax - # mov fs, rax ; not for fs - # (X64 will not use fs and gs, so we do not restore it) - popq %rax - movq %rax, %es - popq %rax - movq %rax, %ds - popq 32(%rbp) # for cs - popq 56(%rbp) # for ss - -## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -## UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - popq %rdi - popq %rsi - addq $8, %rsp # not for rbp - popq 48(%rbp) # for rsp - popq %rbx - popq %rdx - popq %rcx - popq %rax - popq %r8 - popq %r9 - popq %r10 - popq %r11 - popq %r12 - popq %r13 - popq %r14 - popq %r15 - - movq %rbp, %rsp - -# Enable TF bit after page fault handler runs - btsl $8, 40(%rsp) #RFLAGS - - popq %rbp - addq $16, %rsp # skip INT# & ErrCode - iretq - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm deleted file mode 100644 index 80bd739ff4..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm +++ /dev/null @@ -1,383 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.asm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -EXTERNDEF SmiPFHandler:PROC -EXTERNDEF gcSmiIdtr:FWORD -EXTERNDEF gcSmiGdtr:FWORD -EXTERNDEF gcPsd:BYTE - - .const - -NullSeg DQ 0 ; reserved by architecture -CodeSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -ProtModeCodeSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -ProtModeSsSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 93h - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -DataSeg32 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 93h - DB 0cfh ; LimitHigh - DB 0 ; BaseHigh -CodeSeg16 LABEL QWORD - DW -1 - DW 0 - DB 0 - DB 9bh - DB 8fh - DB 0 -DataSeg16 LABEL QWORD - DW -1 - DW 0 - DB 0 - DB 93h - DB 8fh - DB 0 -CodeSeg64 LABEL QWORD - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 9bh - DB 0afh ; LimitHigh - DB 0 ; BaseHigh -; TSS Segment for X64 specially -TssSeg LABEL QWORD - DW TSS_DESC_SIZE - 1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 89h - DB 00h ; LimitHigh - DB 0 ; BaseHigh - DD 0 ; BaseUpper - DD 0 ; Reserved -GDT_SIZE = $ - offset NullSeg - -; Create TSS Descriptor just after GDT -TssDescriptor LABEL BYTE - DD 0 ; Reserved - DQ 0 ; RSP0 - DQ 0 ; RSP1 - DQ 0 ; RSP2 - DD 0 ; Reserved - DD 0 ; Reserved - DQ 0 ; IST1 - DQ 0 ; IST2 - DQ 0 ; IST3 - DQ 0 ; IST4 - DQ 0 ; IST5 - DQ 0 ; IST6 - DQ 0 ; IST7 - DD 0 ; Reserved - DD 0 ; Reserved - DW 0 ; Reserved - DW 0 ; I/O Map Base Address -TSS_DESC_SIZE = $ - offset TssDescriptor - -; -; This structure serves as a template for all processors. -; -gcPsd LABEL BYTE - DB 'PSDSIG ' - DW PSD_SIZE - DW 2 - DW 1 SHL 2 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW 0 - DQ 0 - DQ 0 - DQ 0 ; fixed in InitializeMpServiceData() - DQ offset NullSeg - DD GDT_SIZE - DD 0 - DB 24 dup (0) - DQ 0 -PSD_SIZE = $ - offset gcPsd - -; -; CODE & DATA segments for SMM runtime -; -CODE_SEL = offset CodeSeg64 - offset NullSeg -DATA_SEL = offset DataSeg32 - offset NullSeg -CODE32_SEL = offset CodeSeg32 - offset NullSeg - -gcSmiGdtr LABEL FWORD - DW GDT_SIZE - 1 - DQ offset NullSeg - -gcSmiIdtr LABEL FWORD - DW 0 - DQ 0 - - .code - -;------------------------------------------------------------------------------ -; _SmiExceptionEntryPoints is the collection of exception entry points followed -; by a common exception handler. -; -; Stack frame would be as follows as specified in IA32 manuals: -; -; +---------------------+ <-- 16-byte aligned ensured by processor -; + Old SS + -; +---------------------+ -; + Old RSP + -; +---------------------+ -; + RFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + RIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + RBP + -; +---------------------+ <-- RBP, 16-byte aligned -; -; RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT -;------------------------------------------------------------------------------ -PageFaultIdtHandlerSmmProfile PROC - push 0eh ; Page Fault - test spl, 8 ; odd multiple of 8 => ErrCode present - jnz @F - push [rsp] ; duplicate INT# if no ErrCode - mov qword ptr [rsp + 8], 0 -@@: - push rbp - mov rbp, rsp - - ; - ; Since here the stack pointer is 16-byte aligned, so - ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - ; is 16-byte aligned - ; - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - push r15 - push r14 - push r13 - push r12 - push r11 - push r10 - push r9 - push r8 - push rax - push rcx - push rdx - push rbx - push qword ptr [rbp + 48] ; RSP - push qword ptr [rbp] ; RBP - push rsi - push rdi - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzx rax, word ptr [rbp + 56] - push rax ; for ss - movzx rax, word ptr [rbp + 32] - push rax ; for cs - mov rax, ds - push rax - mov rax, es - push rax - mov rax, fs - push rax - mov rax, gs - push rax - -;; UINT64 Rip; - push qword ptr [rbp + 24] - -;; UINT64 Gdtr[2], Idtr[2]; - sub rsp, 16 - sidt fword ptr [rsp] - sub rsp, 16 - sgdt fword ptr [rsp] - -;; UINT64 Ldtr, Tr; - xor rax, rax - str ax - push rax - sldt ax - push rax - -;; UINT64 RFlags; - push qword ptr [rbp + 40] - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - mov rax, cr8 - push rax - mov rax, cr4 - or rax, 208h - mov cr4, rax - push rax - mov rax, cr3 - push rax - mov rax, cr2 - push rax - xor rax, rax - push rax - mov rax, cr0 - push rax - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov rax, dr7 - push rax - mov rax, dr6 - push rax - mov rax, dr3 - push rax - mov rax, dr2 - push rax - mov rax, dr1 - push rax - mov rax, dr0 - push rax - -;; FX_SAVE_STATE_X64 FxSaveState; - - sub rsp, 512 - mov rdi, rsp - db 0fh, 0aeh, 00000111y ;fxsave [rdi] - -; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push qword ptr [rbp + 16] - -;; call into exception handler - mov rcx, [rbp + 8] - mov rax, SmiPFHandler - -;; Prepare parameter and call - mov rdx, rsp - ; - ; Per X64 calling convention, allocate maximum parameter stack space - ; and make sure RSP is 16-byte aligned - ; - sub rsp, 4 * 8 + 8 - call rax - add rsp, 4 * 8 + 8 - jmp @F - -@@: -;; UINT64 ExceptionData; - add rsp, 8 - -;; FX_SAVE_STATE_X64 FxSaveState; - - mov rsi, rsp - db 0fh, 0aeh, 00001110y ; fxrstor [rsi] - add rsp, 512 - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoints in interrupt/exception context - add rsp, 8 * 6 - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - pop rax - mov cr0, rax - add rsp, 8 ; not for Cr1 - pop rax - mov cr2, rax - pop rax - mov cr3, rax - pop rax - mov cr4, rax - pop rax - mov cr8, rax - -;; UINT64 RFlags; - pop qword ptr [rbp + 40] - -;; UINT64 Ldtr, Tr; -;; UINT64 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add rsp, 48 - -;; UINT64 Rip; - pop qword ptr [rbp + 24] - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; - pop rax - ; mov gs, rax ; not for gs - pop rax - ; mov fs, rax ; not for fs - ; (X64 will not use fs and gs, so we do not restore it) - pop rax - mov es, rax - pop rax - mov ds, rax - pop qword ptr [rbp + 32] ; for cs - pop qword ptr [rbp + 56] ; for ss - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pop rdi - pop rsi - add rsp, 8 ; not for rbp - pop qword ptr [rbp + 48] ; for rsp - pop rbx - pop rdx - pop rcx - pop rax - pop r8 - pop r9 - pop r10 - pop r11 - pop r12 - pop r13 - pop r14 - pop r15 - - mov rsp, rbp - -; Enable TF bit after page fault handler runs - bts dword ptr [rsp + 40], 8 ;RFLAGS - - pop rbp - add rsp, 16 ; skip INT# & ErrCode - iretq -PageFaultIdtHandlerSmmProfile ENDP - - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm deleted file mode 100644 index b2e2e6dee6..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm +++ /dev/null @@ -1,384 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmiException.nasm -; -; Abstract: -; -; Exception handlers used in SM mode -; -;------------------------------------------------------------------------------- - -extern ASM_PFX(SmiPFHandler) - -global ASM_PFX(gcSmiIdtr) -global ASM_PFX(gcSmiGdtr) -global ASM_PFX(gcPsd) - - SECTION .data - -NullSeg: DQ 0 ; reserved by architecture -CodeSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -ProtModeCodeSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -ProtModeSsSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x93 - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -DataSeg32: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x93 - DB 0xcf ; LimitHigh - DB 0 ; BaseHigh -CodeSeg16: - DW -1 - DW 0 - DB 0 - DB 0x9b - DB 0x8f - DB 0 -DataSeg16: - DW -1 - DW 0 - DB 0 - DB 0x93 - DB 0x8f - DB 0 -CodeSeg64: - DW -1 ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x9b - DB 0xaf ; LimitHigh - DB 0 ; BaseHigh -; TSS Segment for X64 specially -TssSeg: - DW TSS_DESC_SIZE ; LimitLow - DW 0 ; BaseLow - DB 0 ; BaseMid - DB 0x89 - DB 0x80 ; LimitHigh - DB 0 ; BaseHigh - DD 0 ; BaseUpper - DD 0 ; Reserved -GDT_SIZE equ $ - NullSeg - -; Create TSS Descriptor just after GDT -TssDescriptor: - DD 0 ; Reserved - DQ 0 ; RSP0 - DQ 0 ; RSP1 - DQ 0 ; RSP2 - DD 0 ; Reserved - DD 0 ; Reserved - DQ 0 ; IST1 - DQ 0 ; IST2 - DQ 0 ; IST3 - DQ 0 ; IST4 - DQ 0 ; IST5 - DQ 0 ; IST6 - DQ 0 ; IST7 - DD 0 ; Reserved - DD 0 ; Reserved - DW 0 ; Reserved - DW 0 ; I/O Map Base Address -TSS_DESC_SIZE equ $ - TssDescriptor - -; -; This structure serves as a template for all processors. -; -ASM_PFX(gcPsd): - DB 'PSDSIG ' - DW PSD_SIZE - DW 2 - DW 1 << 2 - DW CODE_SEL - DW DATA_SEL - DW DATA_SEL - DW DATA_SEL - DW 0 - DQ 0 - DQ 0 - DQ 0 ; fixed in InitializeMpServiceData() - DQ NullSeg - DD GDT_SIZE - DD 0 - times 24 DB 0 - DQ 0 -PSD_SIZE equ $ - ASM_PFX(gcPsd) - -; -; CODE & DATA segments for SMM runtime -; -CODE_SEL equ CodeSeg64 - NullSeg -DATA_SEL equ DataSeg32 - NullSeg -CODE32_SEL equ CodeSeg32 - NullSeg - -ASM_PFX(gcSmiGdtr): - DW GDT_SIZE - 1 - DQ NullSeg - -ASM_PFX(gcSmiIdtr): - DW 0 - DQ 0 - - DEFAULT REL - SECTION .text - -;------------------------------------------------------------------------------ -; _SmiExceptionEntryPoints is the collection of exception entrypoints followed -; by a common exception handler. -; -; Stack frame would be as follows as specified in IA32 manuals: -; -; +---------------------+ <-- 16-byte aligned ensured by processor -; + Old SS + -; +---------------------+ -; + Old RSP + -; +---------------------+ -; + RFlags + -; +---------------------+ -; + CS + -; +---------------------+ -; + RIP + -; +---------------------+ -; + Error Code + -; +---------------------+ -; + Vector Number + -; +---------------------+ -; + RBP + -; +---------------------+ <-- RBP, 16-byte aligned -; -; RSP set to odd multiple of 8 at @CommonEntryPoint means ErrCode PRESENT -;------------------------------------------------------------------------------ -global ASM_PFX(PageFaultIdtHandlerSmmProfile) -ASM_PFX(PageFaultIdtHandlerSmmProfile): - push 0xe ; Page Fault - test spl, 8 ; odd multiple of 8 => ErrCode present - jnz .0 - push qword [rsp] ; duplicate INT# if no ErrCode - mov qword [rsp + 8], 0 -.0: - push rbp - mov rbp, rsp - - ; - ; Since here the stack pointer is 16-byte aligned, so - ; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64 - ; is 16-byte aligned - ; - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - push r15 - push r14 - push r13 - push r12 - push r11 - push r10 - push r9 - push r8 - push rax - push rcx - push rdx - push rbx - push qword [rbp + 48] ; RSP - push qword [rbp] ; RBP - push rsi - push rdi - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero - movzx rax, word [rbp + 56] - push rax ; for ss - movzx rax, word [rbp + 32] - push rax ; for cs - mov rax, ds - push rax - mov rax, es - push rax - mov rax, fs - push rax - mov rax, gs - push rax - -;; UINT64 Rip; - push qword [rbp + 24] - -;; UINT64 Gdtr[2], Idtr[2]; - sub rsp, 16 - sidt [rsp] - sub rsp, 16 - sgdt [rsp] - -;; UINT64 Ldtr, Tr; - xor rax, rax - str ax - push rax - sldt ax - push rax - -;; UINT64 RFlags; - push qword [rbp + 40] - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - mov rax, cr8 - push rax - mov rax, cr4 - or rax, 0x208 - mov cr4, rax - push rax - mov rax, cr3 - push rax - mov rax, cr2 - push rax - xor rax, rax - push rax - mov rax, cr0 - push rax - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; - mov rax, dr7 - push rax - mov rax, dr6 - push rax - mov rax, dr3 - push rax - mov rax, dr2 - push rax - mov rax, dr1 - push rax - mov rax, dr0 - push rax - -;; FX_SAVE_STATE_X64 FxSaveState; - - sub rsp, 512 - mov rdi, rsp - db 0xf, 0xae, 00000111y ;fxsave [rdi] - -; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear - cld - -;; UINT32 ExceptionData; - push qword [rbp + 16] - -;; call into exception handler - mov rcx, [rbp + 8] - mov rax, ASM_PFX(SmiPFHandler) - -;; Prepare parameter and call - mov rdx, rsp - ; - ; Per X64 calling convention, allocate maximum parameter stack space - ; and make sure RSP is 16-byte aligned - ; - sub rsp, 4 * 8 + 8 - call rax - add rsp, 4 * 8 + 8 - jmp .1 - -.1: -;; UINT64 ExceptionData; - add rsp, 8 - -;; FX_SAVE_STATE_X64 FxSaveState; - - mov rsi, rsp - db 0xf, 0xae, 00001110y ; fxrstor [rsi] - add rsp, 512 - -;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; -;; Skip restoration of DRx registers to support debuggers -;; that set breakpoints in interrupt/exception context - add rsp, 8 * 6 - -;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8; - pop rax - mov cr0, rax - add rsp, 8 ; not for Cr1 - pop rax - mov cr2, rax - pop rax - mov cr3, rax - pop rax - mov cr4, rax - pop rax - mov cr8, rax - -;; UINT64 RFlags; - pop qword [rbp + 40] - -;; UINT64 Ldtr, Tr; -;; UINT64 Gdtr[2], Idtr[2]; -;; Best not let anyone mess with these particular registers... - add rsp, 48 - -;; UINT64 Rip; - pop qword [rbp + 24] - -;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; - pop rax - ; mov gs, rax ; not for gs - pop rax - ; mov fs, rax ; not for fs - ; (X64 will not use fs and gs, so we do not restore it) - pop rax - mov es, rax - pop rax - mov ds, rax - pop qword [rbp + 32] ; for cs - pop qword [rbp + 56] ; for ss - -;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax; -;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15; - pop rdi - pop rsi - add rsp, 8 ; not for rbp - pop qword [rbp + 48] ; for rsp - pop rbx - pop rdx - pop rcx - pop rax - pop r8 - pop r9 - pop r10 - pop r11 - pop r12 - pop r13 - pop r14 - pop r15 - - mov rsp, rbp - -; Enable TF bit after page fault handler runs - bts dword [rsp + 40], 8 ;RFLAGS - - pop rbp - add rsp, 16 ; skip INT# & ErrCode - iretq - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c deleted file mode 100644 index 9d26e44a9a..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c +++ /dev/null @@ -1,204 +0,0 @@ -/** @file - SMM CPU misc functions for x64 arch specific. - -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" - -EFI_PHYSICAL_ADDRESS mGdtBuffer; -UINTN mGdtBufferSize; - -/** - Initialize IDT for SMM Stack Guard. - -**/ -VOID -EFIAPI -InitializeIDTSmmStackGuard ( - VOID - ) -{ - IA32_IDT_GATE_DESCRIPTOR *IdtGate; - - // - // If SMM Stack Guard feature is enabled, set the IST field of - // the interrupt gate for Page Fault Exception to be 1 - // - IdtGate = (IA32_IDT_GATE_DESCRIPTOR *)gcSmiIdtr.Base; - IdtGate += EXCEPT_IA32_PAGE_FAULT; - IdtGate->Bits.Reserved_0 = 1; -} - -/** - Initialize Gdt for all processors. - - @param[in] Cr3 CR3 value. - @param[out] GdtStepSize The step size for GDT table. - - @return GdtBase for processor 0. - GdtBase for processor X is: GdtBase + (GdtStepSize * X) -**/ -VOID * -InitGdt ( - IN UINTN Cr3, - OUT UINTN *GdtStepSize - ) -{ - UINTN Index; - IA32_SEGMENT_DESCRIPTOR *GdtDescriptor; - UINTN TssBase; - UINTN GdtTssTableSize; - UINT8 *GdtTssTables; - UINTN GdtTableStepSize; - - // - // For X64 SMM, we allocate separate GDT/TSS for each CPUs to avoid TSS load contention - // on each SMI entry. - // - GdtTssTableSize = (gcSmiGdtr.Limit + 1 + TSS_SIZE + 7) & ~7; // 8 bytes aligned - mGdtBufferSize = GdtTssTableSize * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; - GdtTssTables = (UINT8*)AllocateCodePages (EFI_SIZE_TO_PAGES (mGdtBufferSize)); - ASSERT (GdtTssTables != NULL); - mGdtBuffer = (UINTN)GdtTssTables; - GdtTableStepSize = GdtTssTableSize; - - for (Index = 0; Index < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; Index++) { - CopyMem (GdtTssTables + GdtTableStepSize * Index, (VOID*)(UINTN)gcSmiGdtr.Base, gcSmiGdtr.Limit + 1 + TSS_SIZE); - - // - // Fixup TSS descriptors - // - TssBase = (UINTN)(GdtTssTables + GdtTableStepSize * Index + gcSmiGdtr.Limit + 1); - GdtDescriptor = (IA32_SEGMENT_DESCRIPTOR *)(TssBase) - 2; - GdtDescriptor->Bits.BaseLow = (UINT16)(UINTN)TssBase; - GdtDescriptor->Bits.BaseMid = (UINT8)((UINTN)TssBase >> 16); - GdtDescriptor->Bits.BaseHigh = (UINT8)((UINTN)TssBase >> 24); - - if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - // - // Setup top of known good stack as IST1 for each processor. - // - *(UINTN *)(TssBase + TSS_X64_IST1_OFFSET) = (mSmmStackArrayBase + EFI_PAGE_SIZE + Index * mSmmStackSize); - } - } - - *GdtStepSize = GdtTableStepSize; - return GdtTssTables; -} - -/** - This function sets GDT/IDT buffer to be RO and XP. -**/ -VOID -PatchGdtIdtMap ( - VOID - ) -{ - EFI_PHYSICAL_ADDRESS BaseAddress; - UINTN Size; - - // - // GDT - // - DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n")); - - BaseAddress = mGdtBuffer; - Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_RO - ); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_XP - ); - - // - // IDT - // - DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n")); - - BaseAddress = gcSmiIdtr.Base; - Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_RO - ); - SmmSetMemoryAttributes ( - BaseAddress, - Size, - EFI_MEMORY_XP - ); -} - -/** - Get Protected mode code segment from current GDT table. - - @return Protected mode code segment value. -**/ -UINT16 -GetProtectedModeCS ( - VOID - ) -{ - IA32_DESCRIPTOR GdtrDesc; - IA32_SEGMENT_DESCRIPTOR *GdtEntry; - UINTN GdtEntryCount; - UINT16 Index; - - Index = (UINT16) -1; - AsmReadGdtr (&GdtrDesc); - GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR); - GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base; - for (Index = 0; Index < GdtEntryCount; Index++) { - if (GdtEntry->Bits.L == 0) { - if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.L == 0) { - break; - } - } - GdtEntry++; - } - ASSERT (Index != -1); - return Index * 8; -} - -/** - Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch. - - @param[in] ApHltLoopCode The address of the safe hlt-loop function. - @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode. - @param[in] NumberToFinishAddress Address of Semaphore of APs finish count. - -**/ -VOID -TransferApToSafeState ( - IN UINTN ApHltLoopCode, - IN UINTN TopOfStack, - IN UINTN NumberToFinishAddress - ) -{ - AsmDisablePaging64 ( - GetProtectedModeCS (), - (UINT32)ApHltLoopCode, - (UINT32)NumberToFinishAddress, - 0, - (UINT32)TopOfStack - ); - // - // It should never reach here - // - ASSERT (FALSE); -} - diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S deleted file mode 100644 index 5e352f57c3..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.S +++ /dev/null @@ -1,141 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# Module Name: -# -# SmmInit.S -# -# Abstract: -# -# Functions for relocating SMBASE's for all processors -# -#------------------------------------------------------------------------------ - -ASM_GLOBAL ASM_PFX(gSmmCr0) -ASM_GLOBAL ASM_PFX(gSmmCr3) -ASM_GLOBAL ASM_PFX(gSmmCr4) -ASM_GLOBAL ASM_PFX(gSmmJmpAddr) -ASM_GLOBAL ASM_PFX(gcSmmInitTemplate) -ASM_GLOBAL ASM_PFX(gcSmmInitSize) -ASM_GLOBAL ASM_PFX(mRebasedFlagAddr32) -ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete) -ASM_GLOBAL ASM_PFX(SmmRelocationSemaphoreComplete32) -ASM_GLOBAL ASM_PFX(mSmmRelocationOriginalAddressPtr32) -ASM_GLOBAL ASM_PFX(gSmmInitStack) -ASM_GLOBAL ASM_PFX(gcSmiInitGdtr) - - - .text - -ASM_PFX(gcSmiInitGdtr): - .word 0 - .quad 0 - -SmmStartup: - .byte 0x66,0xb8 # mov eax, imm32 -ASM_PFX(gSmmCr3): .space 4 - movq %rax, %cr3 - .byte 0x66,0x2e - lgdt (ASM_PFX(gcSmiInitGdtr) - SmmStartup)(%ebp) - .byte 0x66,0xb8 # mov eax, imm32 -ASM_PFX(gSmmCr4): .space 4 - orb $2, %ah # enable XMM registers access - movq %rax, %cr4 - .byte 0x66 - movl $0xc0000080,%ecx # IA32_EFER MSR - rdmsr - orb $1,%ah # set LME bit - wrmsr - .byte 0x66,0xb8 # mov eax, imm32 -ASM_PFX(gSmmCr0): .space 4 - movq %rax, %cr0 - .byte 0x66,0xea # far jmp to long mode -ASM_PFX(gSmmJmpAddr): .quad LongMode -LongMode: # long-mode starts here - .byte 0x48,0xbc # mov rsp, imm64 -ASM_PFX(gSmmInitStack): .space 8 - andw $0xfff0, %sp # make sure RSP is 16-byte aligned - # - # Accoring to X64 calling convention, XMM0~5 are volatile, we need to save - # them before calling C-function. - # - subq $0x60, %rsp - movdqa %xmm0, 0x0(%rsp) - movdqa %xmm1, 0x10(%rsp) - movdqa %xmm2, 0x20(%rsp) - movdqa %xmm3, 0x30(%rsp) - movdqa %xmm4, 0x40(%rsp) - movdqa %xmm5, 0x50(%rsp) - - - addq $-0x20, %rsp - call ASM_PFX(SmmInitHandler) - addq $0x20, %rsp - # - # Restore XMM0~5 after calling C-function. - # - movdqa 0x0(%rsp), %xmm0 - movdqa 0x10(%rsp), %xmm1 - movdqa 0x20(%rsp), %xmm2 - movdqa 0x30(%rsp), %xmm3 - movdqa 0x40(%rsp), %xmm4 - movdqa 0x50(%rsp), %xmm5 - - rsm - -ASM_PFX(gcSmmInitTemplate): - -_SmmInitTemplate: - .byte 0x66,0x2e,0x8b,0x2e # mov ebp, cs:[@F] - .word L1 - _SmmInitTemplate + 0x8000 - .byte 0x66, 0x81, 0xed, 0, 0, 3, 0 # sub ebp, 0x30000 - jmp *%bp # jmp ebp actually -L1: - .quad SmmStartup - -ASM_PFX(gcSmmInitSize): .word . - ASM_PFX(gcSmmInitTemplate) - -ASM_PFX(SmmRelocationSemaphoreComplete): - # Create a simple stack frame to store RAX and the original RSM location - pushq %rax # Used to store return address - pushq %rax - - # Load the original RSM location onto stack - movabsq $ASM_PFX(mSmmRelocationOriginalAddress), %rax - movq (%rax), %rax - movq %rax, 0x08(%rsp) - - # Update rebase flag - movabsq $ASM_PFX(mRebasedFlag), %rax - movq (%rax), %rax - movb $1, (%rax) - - #restore RAX and return to original RSM location - popq %rax - retq - -# -# Semaphore code running in 32-bit mode -# -ASM_PFX(SmmRelocationSemaphoreComplete32): - # - # movb $1, () - # - .byte 0xc6, 0x05 -ASM_PFX(mRebasedFlagAddr32): - .long 0 - .byte 1 - # - # jmpd () - # - .byte 0xff, 0x25 -ASM_PFX(mSmmRelocationOriginalAddressPtr32): - .long 0 diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm deleted file mode 100644 index 9182f0293a..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.asm +++ /dev/null @@ -1,132 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmmInit.Asm -; -; Abstract: -; -; Functions for relocating SMBASE's for all processors -; -;------------------------------------------------------------------------------- - -EXTERNDEF SmmInitHandler:PROC -EXTERNDEF gSmmCr0:DWORD -EXTERNDEF gSmmCr3:DWORD -EXTERNDEF gSmmCr4:DWORD -EXTERNDEF gSmmJmpAddr:QWORD -EXTERNDEF gcSmmInitTemplate:BYTE -EXTERNDEF gcSmmInitSize:WORD -EXTERNDEF mRebasedFlag:PTR BYTE -EXTERNDEF mSmmRelocationOriginalAddress:QWORD -EXTERNDEF mRebasedFlagAddr32:DWORD -EXTERNDEF mSmmRelocationOriginalAddressPtr32:DWORD -EXTERNDEF gSmmInitStack:QWORD -EXTERNDEF gcSmiInitGdtr:FWORD - - .code - -gcSmiInitGdtr LABEL FWORD - DW 0 - DQ 0 - -SmmStartup PROC - DB 66h, 0b8h ; mov eax, imm32 -gSmmCr3 DD ? - mov cr3, rax - DB 66h, 2eh - lgdt fword ptr [ebp + (offset gcSmiInitGdtr - SmmStartup)] - DB 66h, 0b8h ; mov eax, imm32 -gSmmCr4 DD ? - or ah, 2 ; enable XMM registers access - mov cr4, rax - DB 66h - mov ecx, 0c0000080h ; IA32_EFER MSR - rdmsr - or ah, 1 ; set LME bit - wrmsr - DB 66h, 0b8h ; mov eax, imm32 -gSmmCr0 DD ? - mov cr0, rax ; enable protected mode & paging - DB 66h, 0eah ; far jmp to long mode -gSmmJmpAddr DQ @LongMode -@LongMode: ; long-mode starts here - DB 48h, 0bch ; mov rsp, imm64 -gSmmInitStack DQ ? - and sp, 0fff0h ; make sure RSP is 16-byte aligned - ; - ; Accoring to X64 calling convention, XMM0~5 are volatile, we need to save - ; them before calling C-function. - ; - sub rsp, 60h - movdqa [rsp], xmm0 - movdqa [rsp + 10h], xmm1 - movdqa [rsp + 20h], xmm2 - movdqa [rsp + 30h], xmm3 - movdqa [rsp + 40h], xmm4 - movdqa [rsp + 50h], xmm5 - - add rsp, -20h - call SmmInitHandler - add rsp, 20h - - ; - ; Restore XMM0~5 after calling C-function. - ; - movdqa xmm0, [rsp] - movdqa xmm1, [rsp + 10h] - movdqa xmm2, [rsp + 20h] - movdqa xmm3, [rsp + 30h] - movdqa xmm4, [rsp + 40h] - movdqa xmm5, [rsp + 50h] - - rsm -SmmStartup ENDP - -gcSmmInitTemplate LABEL BYTE - -_SmmInitTemplate PROC - DB 66h, 2eh, 8bh, 2eh ; mov ebp, cs:[@F] - DW @L1 - _SmmInitTemplate + 8000h - DB 66h, 81h, 0edh, 00h, 00h, 03h, 00 ; sub ebp, 30000h - jmp bp ; jmp ebp actually -@L1: - DQ SmmStartup -_SmmInitTemplate ENDP - -gcSmmInitSize DW $ - gcSmmInitTemplate - -SmmRelocationSemaphoreComplete PROC - push rax - mov rax, mRebasedFlag - mov byte ptr [rax], 1 - pop rax - jmp [mSmmRelocationOriginalAddress] -SmmRelocationSemaphoreComplete ENDP - -; -; Semaphore code running in 32-bit mode -; -SmmRelocationSemaphoreComplete32 PROC - ; - ; mov byte ptr [], 1 - ; - db 0c6h, 05h -mRebasedFlagAddr32 dd 0 - db 1 - ; - ; jmp dword ptr [] - ; - db 0ffh, 25h -mSmmRelocationOriginalAddressPtr32 dd 0 -SmmRelocationSemaphoreComplete32 ENDP - - END diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm deleted file mode 100644 index 9d05e2cb05..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm +++ /dev/null @@ -1,130 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; SmmInit.nasm -; -; Abstract: -; -; Functions for relocating SMBASE's for all processors -; -;------------------------------------------------------------------------------- - -extern ASM_PFX(SmmInitHandler) -extern ASM_PFX(mRebasedFlag) -extern ASM_PFX(mSmmRelocationOriginalAddress) - -global ASM_PFX(gSmmCr3) -global ASM_PFX(gSmmCr4) -global ASM_PFX(gSmmCr0) -global ASM_PFX(gSmmJmpAddr) -global ASM_PFX(gSmmInitStack) -global ASM_PFX(gcSmiInitGdtr) -global ASM_PFX(gcSmmInitSize) -global ASM_PFX(gcSmmInitTemplate) -global ASM_PFX(mRebasedFlagAddr32) -global ASM_PFX(mSmmRelocationOriginalAddressPtr32) - - DEFAULT REL - SECTION .text - -ASM_PFX(gcSmiInitGdtr): - DW 0 - DQ 0 - -global ASM_PFX(SmmStartup) -ASM_PFX(SmmStartup): - DB 0x66, 0xb8 ; mov eax, imm32 -ASM_PFX(gSmmCr3): DD 0 - mov cr3, rax - DB 0x66, 0x2e - lgdt [ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] - DB 0x66, 0xb8 ; mov eax, imm32 -ASM_PFX(gSmmCr4): DD 0 - or ah, 2 ; enable XMM registers access - mov cr4, rax - DB 0x66 - mov ecx, 0xc0000080 ; IA32_EFER MSR - rdmsr - or ah, 1 ; set LME bit - wrmsr - DB 0x66, 0xb8 ; mov eax, imm32 -ASM_PFX(gSmmCr0): DD 0 - mov cr0, rax ; enable protected mode & paging - DB 0x66, 0xea ; far jmp to long mode -ASM_PFX(gSmmJmpAddr): DQ @LongMode -@LongMode: ; long-mode starts here - DB 0x48, 0xbc ; mov rsp, imm64 -ASM_PFX(gSmmInitStack): DQ 0 - and sp, 0xfff0 ; make sure RSP is 16-byte aligned - ; - ; Accoring to X64 calling convention, XMM0~5 are volatile, we need to save - ; them before calling C-function. - ; - sub rsp, 0x60 - movdqa [rsp], xmm0 - movdqa [rsp + 0x10], xmm1 - movdqa [rsp + 0x20], xmm2 - movdqa [rsp + 0x30], xmm3 - movdqa [rsp + 0x40], xmm4 - movdqa [rsp + 0x50], xmm5 - - add rsp, -0x20 - call ASM_PFX(SmmInitHandler) - add rsp, 0x20 - - ; - ; Restore XMM0~5 after calling C-function. - ; - movdqa xmm0, [rsp] - movdqa xmm1, [rsp + 0x10] - movdqa xmm2, [rsp + 0x20] - movdqa xmm3, [rsp + 0x30] - movdqa xmm4, [rsp + 0x40] - movdqa xmm5, [rsp + 0x50] - - rsm - -BITS 16 -ASM_PFX(gcSmmInitTemplate): - mov ebp, [cs:@L1 - ASM_PFX(gcSmmInitTemplate) + 0x8000] - sub ebp, 0x30000 - jmp ebp -@L1: - DQ ASM_PFX(SmmStartup) - -ASM_PFX(gcSmmInitSize): DW $ - ASM_PFX(gcSmmInitTemplate) - -BITS 64 -global ASM_PFX(SmmRelocationSemaphoreComplete) -ASM_PFX(SmmRelocationSemaphoreComplete): - push rax - mov rax, [ASM_PFX(mRebasedFlag)] - mov byte [rax], 1 - pop rax - jmp [ASM_PFX(mSmmRelocationOriginalAddress)] - -; -; Semaphore code running in 32-bit mode -; -global ASM_PFX(SmmRelocationSemaphoreComplete32) -ASM_PFX(SmmRelocationSemaphoreComplete32): - ; - ; mov byte ptr [], 1 - ; - db 0xc6, 0x5 -ASM_PFX(mRebasedFlagAddr32): dd 0 - db 1 - ; - ; jmp dword ptr [] - ; - db 0xff, 0x25 -ASM_PFX(mSmmRelocationOriginalAddressPtr32): dd 0 diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c deleted file mode 100644 index 37da5fb78d..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c +++ /dev/null @@ -1,319 +0,0 @@ -/** @file -X64 processor specific functions to enable SMM profile. - -Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
-Copyright (c) 2017, AMD Incorporated. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiSmmCpuDxeSmm.h" -#include "SmmProfileInternal.h" - -// -// Current page index. -// -UINTN mPFPageIndex; - -// -// Pool for dynamically creating page table in page fault handler. -// -UINT64 mPFPageBuffer; - -// -// Store the uplink information for each page being used. -// -UINT64 *mPFPageUplink[MAX_PF_PAGE_COUNT]; - -/** - Create SMM page table for S3 path. - -**/ -VOID -InitSmmS3Cr3 ( - VOID - ) -{ - EFI_PHYSICAL_ADDRESS Pages; - UINT64 *PTEntry; - - // - // Generate PAE page table for the first 4GB memory space - // - Pages = Gen4GPageTable (FALSE); - - // - // Fill Page-Table-Level4 (PML4) entry - // - PTEntry = (UINT64*)AllocatePageTableMemory (1); - ASSERT (PTEntry != NULL); - *PTEntry = Pages | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - ZeroMem (PTEntry + 1, EFI_PAGE_SIZE - sizeof (*PTEntry)); - - // - // Return the address of PML4 (to set CR3) - // - mSmmS3ResumeState->SmmS3Cr3 = (UINT32)(UINTN)PTEntry; - - return ; -} - -/** - Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. - -**/ -VOID -InitPagesForPFHandler ( - VOID - ) -{ - VOID *Address; - - // - // Pre-Allocate memory for page fault handler - // - Address = NULL; - Address = AllocatePages (MAX_PF_PAGE_COUNT); - ASSERT (Address != NULL); - - mPFPageBuffer = (UINT64)(UINTN) Address; - mPFPageIndex = 0; - ZeroMem ((VOID *) (UINTN) mPFPageBuffer, EFI_PAGE_SIZE * MAX_PF_PAGE_COUNT); - ZeroMem (mPFPageUplink, sizeof (mPFPageUplink)); - - return; -} - -/** - Allocate one page for creating 4KB-page based on 2MB-page. - - @param Uplink The address of Page-Directory entry. - -**/ -VOID -AcquirePage ( - UINT64 *Uplink - ) -{ - UINT64 Address; - - // - // Get the buffer - // - Address = mPFPageBuffer + EFI_PAGES_TO_SIZE (mPFPageIndex); - ZeroMem ((VOID *) (UINTN) Address, EFI_PAGE_SIZE); - - // - // Cut the previous uplink if it exists and wasn't overwritten - // - if ((mPFPageUplink[mPFPageIndex] != NULL) && ((*mPFPageUplink[mPFPageIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK) == Address)) { - *mPFPageUplink[mPFPageIndex] = 0; - } - - // - // Link & Record the current uplink - // - *Uplink = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - mPFPageUplink[mPFPageIndex] = Uplink; - - mPFPageIndex = (mPFPageIndex + 1) % MAX_PF_PAGE_COUNT; -} - -/** - Update page table to map the memory correctly in order to make the instruction - which caused page fault execute successfully. And it also save the original page - table to be restored in single-step exception. - - @param PageTable PageTable Address. - @param PFAddress The memory address which caused page fault exception. - @param CpuIndex The index of the processor. - @param ErrorCode The Error code of exception. - @param IsValidPFAddress The flag indicates if SMM profile data need be added. - -**/ -VOID -RestorePageTableAbove4G ( - UINT64 *PageTable, - UINT64 PFAddress, - UINTN CpuIndex, - UINTN ErrorCode, - BOOLEAN *IsValidPFAddress - ) -{ - UINTN PTIndex; - UINT64 Address; - BOOLEAN Nx; - BOOLEAN Existed; - UINTN Index; - UINTN PFIndex; - - ASSERT ((PageTable != NULL) && (IsValidPFAddress != NULL)); - - // - // If page fault address is 4GB above. - // - - // - // Check if page fault address has existed in page table. - // If it exists in page table but page fault is generated, - // there are 2 possible reasons: 1. present flag is set to 0; 2. instruction fetch in protected memory range. - // - Existed = FALSE; - PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK); - PTIndex = BitFieldRead64 (PFAddress, 39, 47); - if ((PageTable[PTIndex] & IA32_PG_P) != 0) { - // PML4E - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - PTIndex = BitFieldRead64 (PFAddress, 30, 38); - if ((PageTable[PTIndex] & IA32_PG_P) != 0) { - // PDPTE - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - PTIndex = BitFieldRead64 (PFAddress, 21, 29); - // PD - if ((PageTable[PTIndex] & IA32_PG_PS) != 0) { - // - // 2MB page - // - Address = (UINT64)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - if ((Address & ~((1ull << 21) - 1)) == ((PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 21) - 1)))) { - Existed = TRUE; - } - } else { - // - // 4KB page - // - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask& PHYSICAL_ADDRESS_MASK); - if (PageTable != 0) { - // - // When there is a valid entry to map to 4KB page, need not create a new entry to map 2MB. - // - PTIndex = BitFieldRead64 (PFAddress, 12, 20); - Address = (UINT64)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - if ((Address & ~((1ull << 12) - 1)) == (PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 12) - 1))) { - Existed = TRUE; - } - } - } - } - } - - // - // If page entry does not existed in page table at all, create a new entry. - // - if (!Existed) { - - if (IsAddressValid (PFAddress, &Nx)) { - // - // If page fault address above 4GB is in protected range but it causes a page fault exception, - // Will create a page entry for this page fault address, make page table entry as present/rw and execution-disable. - // this access is not saved into SMM profile data. - // - *IsValidPFAddress = TRUE; - } - - // - // Create one entry in page table for page fault address. - // - SmiDefaultPFHandler (); - // - // Find the page table entry created just now. - // - PageTable = (UINT64*)(AsmReadCr3 () & PHYSICAL_ADDRESS_MASK); - PFAddress = AsmReadCr2 (); - // PML4E - PTIndex = BitFieldRead64 (PFAddress, 39, 47); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - // PDPTE - PTIndex = BitFieldRead64 (PFAddress, 30, 38); - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - // PD - PTIndex = BitFieldRead64 (PFAddress, 21, 29); - Address = PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK; - // - // Check if 2MB-page entry need be changed to 4KB-page entry. - // - if (IsAddressSplit (Address)) { - AcquirePage (&PageTable[PTIndex]); - - // PTE - PageTable = (UINT64*)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK); - for (Index = 0; Index < 512; Index++) { - PageTable[Index] = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS; - if (!IsAddressValid (Address, &Nx)) { - PageTable[Index] = PageTable[Index] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); - } - if (Nx && mXdSupported) { - PageTable[Index] = PageTable[Index] | IA32_PG_NX; - } - if (Address == (PFAddress & PHYSICAL_ADDRESS_MASK & ~((1ull << 12) - 1))) { - PTIndex = Index; - } - Address += SIZE_4KB; - } // end for PT - } else { - // - // Update 2MB page entry. - // - if (!IsAddressValid (Address, &Nx)) { - // - // Patch to remove present flag and rw flag. - // - PageTable[PTIndex] = PageTable[PTIndex] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS); - } - // - // Set XD bit to 1 - // - if (Nx && mXdSupported) { - PageTable[PTIndex] = PageTable[PTIndex] | IA32_PG_NX; - } - } - } - - // - // Record old entries with non-present status - // Old entries include the memory which instruction is at and the memory which instruction access. - // - // - ASSERT (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT); - if (mPFEntryCount[CpuIndex] < MAX_PF_ENTRY_COUNT) { - PFIndex = mPFEntryCount[CpuIndex]; - mLastPFEntryValue[CpuIndex][PFIndex] = PageTable[PTIndex]; - mLastPFEntryPointer[CpuIndex][PFIndex] = &PageTable[PTIndex]; - mPFEntryCount[CpuIndex]++; - } - - // - // Add present flag or clear XD flag to make page fault handler succeed. - // - PageTable[PTIndex] |= (UINT64)(PAGE_ATTRIBUTE_BITS); - if ((ErrorCode & IA32_PF_EC_ID) != 0) { - // - // If page fault is caused by instruction fetch, clear XD bit in the entry. - // - PageTable[PTIndex] &= ~IA32_PG_NX; - } - - return; -} - -/** - Clear TF in FLAGS. - - @param SystemContext A pointer to the processor context when - the interrupt occurred on the processor. - -**/ -VOID -ClearTrapFlag ( - IN OUT EFI_SYSTEM_CONTEXT SystemContext - ) -{ - SystemContext.SystemContextX64->Rflags &= (UINTN) ~BIT8; -} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h deleted file mode 100644 index 32f33139bf..0000000000 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h +++ /dev/null @@ -1,105 +0,0 @@ -/** @file -X64 processor specific header file to enable SMM profile. - -Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMM_PROFILE_ARCH_H_ -#define _SMM_PROFILE_ARCH_H_ - -#pragma pack (1) - -typedef struct _MSR_DS_AREA_STRUCT { - UINT64 BTSBufferBase; - UINT64 BTSIndex; - UINT64 BTSAbsoluteMaximum; - UINT64 BTSInterruptThreshold; - UINT64 PEBSBufferBase; - UINT64 PEBSIndex; - UINT64 PEBSAbsoluteMaximum; - UINT64 PEBSInterruptThreshold; - UINT64 PEBSCounterReset[2]; - UINT64 Reserved; -} MSR_DS_AREA_STRUCT; - -typedef struct _BRANCH_TRACE_RECORD { - UINT64 LastBranchFrom; - UINT64 LastBranchTo; - UINT64 Rsvd0 : 4; - UINT64 BranchPredicted : 1; - UINT64 Rsvd1 : 59; -} BRANCH_TRACE_RECORD; - -typedef struct _PEBS_RECORD { - UINT64 Rflags; - UINT64 LinearIP; - UINT64 Rax; - UINT64 Rbx; - UINT64 Rcx; - UINT64 Rdx; - UINT64 Rsi; - UINT64 Rdi; - UINT64 Rbp; - UINT64 Rsp; - UINT64 R8; - UINT64 R9; - UINT64 R10; - UINT64 R11; - UINT64 R12; - UINT64 R13; - UINT64 R14; - UINT64 R15; -} PEBS_RECORD; - -#pragma pack () - -#define PHYSICAL_ADDRESS_MASK ((1ull << 52) - SIZE_4KB) - -/** - Update page table to map the memory correctly in order to make the instruction - which caused page fault execute successfully. And it also save the original page - table to be restored in single-step exception. - - @param PageTable PageTable Address. - @param PFAddress The memory address which caused page fault exception. - @param CpuIndex The index of the processor. - @param ErrorCode The Error code of exception. - @param IsValidPFAddress The flag indicates if SMM profile data need be added. - -**/ -VOID -RestorePageTableAbove4G ( - UINT64 *PageTable, - UINT64 PFAddress, - UINTN CpuIndex, - UINTN ErrorCode, - BOOLEAN *IsValidPFAddress - ); - -/** - Create SMM page table for S3 path. - -**/ -VOID -InitSmmS3Cr3 ( - VOID - ); - -/** - Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. - -**/ -VOID -InitPagesForPFHandler ( - VOID - ); - -#endif // _SMM_PROFILE_ARCH_H_ diff --git a/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni b/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni deleted file mode 100644 index 06af9d2ff0..0000000000 --- a/UefiCpuPkg/ResetVector/FixupVtf/ResetVector.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Reset Vector -// -// This VTF requires build time fixups in order to find the SEC entry point. -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Reset Vector" - -#string STR_MODULE_DESCRIPTION #language en-US "This VTF requires build time fixups in order to find the SEC entry point" - diff --git a/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni b/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni deleted file mode 100644 index f18a4f0443..0000000000 --- a/UefiCpuPkg/ResetVector/FixupVtf/ResetVectorExtra.uni +++ /dev/null @@ -1,17 +0,0 @@ -// /** @file -// ResetVector Localized Strings and Content -// -// Copyright (c) 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" - - diff --git a/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf b/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf deleted file mode 100644 index ed41c3807d..0000000000 --- a/UefiCpuPkg/ResetVector/FixupVtf/Vtf.inf +++ /dev/null @@ -1,38 +0,0 @@ -## @file -# Reset Vector -# -# This VTF requires build time fixups in order to find the SEC entry point. -# -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ResetVector - FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 - MODULE_TYPE = SEC - VERSION_STRING = 1.1 - MODULE_UNI_FILE = ResetVector.uni - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - Vtf.nasmb - -[Packages] - MdePkg/MdePkg.dec - -[UserExtensions.TianoCore."ExtraFiles"] - ResetVectorExtra.uni diff --git a/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb b/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb deleted file mode 100644 index 5aa733ea59..0000000000 --- a/UefiCpuPkg/ResetVector/FixupVtf/Vtf.nasmb +++ /dev/null @@ -1,60 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; First code exectuted by processor after resetting. -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 16 - -ALIGN 16 ; 0xffffffd0 - -applicationProcessorEntryPoint: -; -; Application Processors entry point -; -; GenFv generates code aligned on a 4k boundary which will jump to this -; location. (0xffffffd0) This allows the Local APIC Startup IPI to be -; used to wake up the application processors. -; - jmp short resetVector - -ALIGN 16 ; 0xffffffe0 - -peiCoreEntryPoint: -; -; PEI Core entry point -; -; GenFv fills the address of the PEI Core into this location -; - DD 0x12345678 - -ALIGN 16 ; 0xfffffff0 - -resetVector: -; -; Reset Vector -; -; This is where the processor will begin execution -; - nop - nop - jmp near $ - -ALIGN 8 - -ApStartupSegment: - DD 0x12345678 - -BootFvBaseAddress: - DD 0x12345678 - -ALIGN 16 ; 0x100000000 diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw deleted file mode 100644 index 2c6ff655de..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.port80.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw deleted file mode 100644 index e34780a3a2..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw deleted file mode 100644 index 6dfa68eabb..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.ia32.serial.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf deleted file mode 100644 index 72abd6e91c..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf +++ /dev/null @@ -1,36 +0,0 @@ -## @file -# Reset Vector binary -# -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ResetVector - MODULE_UNI_FILE = ResetVector.uni - FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 - MODULE_TYPE = SEC - VERSION_STRING = 1.1 - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Binaries.Ia32] - RAW|ResetVector.ia32.raw|* - -[Binaries.X64] - RAW|ResetVector.x64.raw|* - -[UserExtensions.TianoCore."ExtraFiles"] - ResetVectorExtra.uni diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni deleted file mode 100644 index 43eba267b6..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Reset Vector binary -// -// Reset Vector binary -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Reset Vector binary" - -#string STR_MODULE_DESCRIPTION #language en-US "Reset Vector binary" - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw deleted file mode 100644 index 6c0bcc47eb..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.port80.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw deleted file mode 100644 index a78d5b407c..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw deleted file mode 100644 index 61c71349a8..0000000000 Binary files a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.x64.serial.raw and /dev/null differ diff --git a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni b/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni deleted file mode 100644 index f18a4f0443..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVectorExtra.uni +++ /dev/null @@ -1,17 +0,0 @@ -// /** @file -// ResetVector Localized Strings and Content -// -// Copyright (c) 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" - - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Build.py b/UefiCpuPkg/ResetVector/Vtf0/Build.py deleted file mode 100644 index a645c371b9..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Build.py +++ /dev/null @@ -1,53 +0,0 @@ -## @file -# Automate the process of building the various reset vector types -# -# Copyright (c) 2009, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -import glob -import os -import subprocess -import sys - -def RunCommand(commandLine): - #print ' '.join(commandLine) - return subprocess.call(commandLine) - -for filename in glob.glob(os.path.join('Bin', '*.raw')): - os.remove(filename) - -for arch in ('ia32', 'x64'): - for debugType in (None, 'port80', 'serial'): - output = os.path.join('Bin', 'ResetVector') - output += '.' + arch - if debugType is not None: - output += '.' + debugType - output += '.raw' - commandLine = ( - 'nasm', - '-D', 'ARCH_%s' % arch.upper(), - '-D', 'DEBUG_%s' % str(debugType).upper(), - '-o', output, - 'Vtf0.nasmb', - ) - ret = RunCommand(commandLine) - print '\tASM\t' + output - if ret != 0: sys.exit(ret) - - commandLine = ( - 'python', - 'Tools/FixupForRawSection.py', - output, - ) - print '\tFIXUP\t' + output - ret = RunCommand(commandLine) - if ret != 0: sys.exit(ret) - diff --git a/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc b/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc deleted file mode 100644 index b46da27686..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/CommonMacros.inc +++ /dev/null @@ -1,31 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Common macros used in the ResetVector VTF module. -; -; Copyright (c) 2008, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -%define ADDR16_OF(x) (0x10000 - fourGigabytes + x) -%define ADDR_OF(x) (0x100000000 - fourGigabytes + x) - -%macro OneTimeCall 1 - jmp %1 -%1 %+ OneTimerCallReturn: -%endmacro - -%macro OneTimeCallRet 1 - jmp %1 %+ OneTimerCallReturn -%endmacro - -StartOfResetVectorCode: - -%define ADDR_OF_START_OF_RESET_CODE ADDR_OF(StartOfResetVectorCode) - diff --git a/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm b/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm deleted file mode 100644 index 883cef03e0..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/DebugDisabled.asm +++ /dev/null @@ -1,26 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Debug disabled -; -; Copyright (c) 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 16 - -%macro debugInitialize 0 - ; - ; No initialization is required - ; -%endmacro - -%macro debugShowPostCode 1 -%endmacro - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm deleted file mode 100644 index 226c49f220..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Init16.asm +++ /dev/null @@ -1,48 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; 16-bit initialization code -; -; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - - -BITS 16 - -; -; @param[out] DI 'BP' to indicate boot-strap processor -; -EarlyBspInitReal16: - mov di, 'BP' - jmp short Main16 - -; -; @param[out] DI 'AP' to indicate application processor -; -EarlyApInitReal16: - mov di, 'AP' - jmp short Main16 - -; -; Modified: EAX -; -; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test) -; @param[out] ESP Initial value of the EAX register (BIST: Built-in Self Test) -; -EarlyInit16: - ; - ; ESP - Initial value of the EAX register (BIST: Built-in Self Test) - ; - mov esp, eax - - debugInitialize - - OneTimeCallRet EarlyInit16 - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm deleted file mode 100644 index 146df600a6..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm +++ /dev/null @@ -1,133 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Transition from 16 bit real mode into 32 bit flat protected mode -; -; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -%define SEC_DEFAULT_CR0 0x40000023 -%define SEC_DEFAULT_CR4 0x640 - -BITS 16 - -; -; Modified: EAX, EBX -; -TransitionFromReal16To32BitFlat: - - debugShowPostCode POSTCODE_16BIT_MODE - - cli - - mov bx, 0xf000 - mov ds, bx - - mov bx, ADDR16_OF(gdtr) - -o32 lgdt [cs:bx] - - mov eax, SEC_DEFAULT_CR0 - mov cr0, eax - - jmp LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere) -BITS 32 -jumpTo32BitAndLandHere: - - mov eax, SEC_DEFAULT_CR4 - mov cr4, eax - - debugShowPostCode POSTCODE_32BIT_MODE - - mov ax, LINEAR_SEL - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - - OneTimeCallRet TransitionFromReal16To32BitFlat - -ALIGN 2 - -gdtr: - dw GDT_END - GDT_BASE - 1 ; GDT limit - dd ADDR_OF(GDT_BASE) - -ALIGN 16 - -; -; Macros for GDT entries -; - -%define PRESENT_FLAG(p) (p << 7) -%define DPL(dpl) (dpl << 5) -%define SYSTEM_FLAG(s) (s << 4) -%define DESC_TYPE(t) (t) - -; Type: data, expand-up, writable, accessed -%define DATA32_TYPE 3 - -; Type: execute, readable, expand-up, accessed -%define CODE32_TYPE 0xb - -; Type: execute, readable, expand-up, accessed -%define CODE64_TYPE 0xb - -%define GRANULARITY_FLAG(g) (g << 7) -%define DEFAULT_SIZE32(d) (d << 6) -%define CODE64_FLAG(l) (l << 5) -%define UPPER_LIMIT(l) (l) - -; -; The Global Descriptor Table (GDT) -; - -GDT_BASE: -; null descriptor -NULL_SEL equ $-GDT_BASE - DW 0 ; limit 15:0 - DW 0 ; base 15:0 - DB 0 ; base 23:16 - DB 0 ; sys flag, dpl, type - DB 0 ; limit 19:16, flags - DB 0 ; base 31:24 - -; linear data segment descriptor -LINEAR_SEL equ $-GDT_BASE - DW 0xffff ; limit 15:0 - DW 0 ; base 15:0 - DB 0 ; base 23:16 - DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(DATA32_TYPE) - DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf) - DB 0 ; base 31:24 - -; linear code segment descriptor -LINEAR_CODE_SEL equ $-GDT_BASE - DW 0xffff ; limit 15:0 - DW 0 ; base 15:0 - DB 0 ; base 23:16 - DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE32_TYPE) - DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(1)|CODE64_FLAG(0)|UPPER_LIMIT(0xf) - DB 0 ; base 31:24 - -%ifdef ARCH_X64 -; linear code (64-bit) segment descriptor -LINEAR_CODE64_SEL equ $-GDT_BASE - DW 0xffff ; limit 15:0 - DW 0 ; base 15:0 - DB 0 ; base 23:16 - DB PRESENT_FLAG(1)|DPL(0)|SYSTEM_FLAG(1)|DESC_TYPE(CODE64_TYPE) - DB GRANULARITY_FLAG(1)|DEFAULT_SIZE32(0)|CODE64_FLAG(1)|UPPER_LIMIT(0xf) - DB 0 ; base 31:24 -%endif - -GDT_END: - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm deleted file mode 100644 index 142d9f3212..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/ResetVectorVtf0.asm +++ /dev/null @@ -1,71 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; First code executed by processor after resetting. -; -; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 16 - -ALIGN 16 - -; -; Pad the image size to 4k when page tables are in VTF0 -; -; If the VTF0 image has page tables built in, then we need to make -; sure the end of VTF0 is 4k above where the page tables end. -; -; This is required so the page tables will be 4k aligned when VTF0 is -; located just below 0x100000000 (4GB) in the firmware device. -; -%ifdef ALIGN_TOP_TO_4K_FOR_PAGING - TIMES (0x1000 - ($ - EndOfPageTables) - 0x20) DB 0 -%endif - -applicationProcessorEntryPoint: -; -; Application Processors entry point -; -; GenFv generates code aligned on a 4k boundary which will jump to this -; location. (0xffffffe0) This allows the Local APIC Startup IPI to be -; used to wake up the application processors. -; - jmp EarlyApInitReal16 - -ALIGN 8 - - DD 0 - -; -; The VTF signature -; -; VTF-0 means that the VTF (Volume Top File) code does not require -; any fixups. -; -vtfSignature: - DB 'V', 'T', 'F', 0 - -ALIGN 16 - -resetVector: -; -; Reset Vector -; -; This is where the processor will begin execution -; - nop - nop - jmp EarlyBspInitReal16 - -ALIGN 16 - -fourGigabytes: - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm deleted file mode 100644 index 62e71da3d5..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm +++ /dev/null @@ -1,45 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Transition from 32 bit flat protected mode into 64 bit flat protected mode -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 32 - -; -; Modified: EAX -; -Transition32FlatTo64Flat: - - OneTimeCall SetCr3ForPageTables64 - - mov eax, cr4 - bts eax, 5 ; enable PAE - mov cr4, eax - - mov ecx, 0xc0000080 - rdmsr - bts eax, 8 ; set LME - wrmsr - - mov eax, cr0 - bts eax, 31 ; set PG - mov cr0, eax ; enable paging - - jmp LINEAR_CODE64_SEL:ADDR_OF(jumpTo64BitAndLandHere) -BITS 64 -jumpTo64BitAndLandHere: - - debugShowPostCode POSTCODE_64BIT_MODE - - OneTimeCallRet Transition32FlatTo64Flat - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm deleted file mode 100644 index 2e16e71f6a..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm +++ /dev/null @@ -1,30 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Sets the CR3 register for 64-bit paging -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 32 - -; -; Modified: EAX -; -SetCr3ForPageTables64: - - ; - ; These pages are built into the ROM image in X64/PageTables.asm - ; - mov eax, ADDR_OF(TopLevelPageDirectory) - mov cr3, eax - - OneTimeCallRet SetCr3ForPageTables64 - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm deleted file mode 100644 index d0c2d8c39c..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm +++ /dev/null @@ -1,86 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Search for the Boot Firmware Volume (BFV) base address -; -; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \ -; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } } -%define FFS_GUID_DWORD0 0x8c8ce578 -%define FFS_GUID_DWORD1 0x4f1c8a3d -%define FFS_GUID_DWORD2 0x61893599 -%define FFS_GUID_DWORD3 0xd32dc385 - -BITS 32 - -; -; Modified: EAX, EBX -; Preserved: EDI, ESP -; -; @param[out] EBP Address of Boot Firmware Volume (BFV) -; -Flat32SearchForBfvBase: - - xor eax, eax -searchingForBfvHeaderLoop: - ; - ; We check for a firmware volume at every 4KB address in the top 16MB - ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.) - ; - sub eax, 0x1000 - cmp eax, 0xff000000 - jb searchedForBfvHeaderButNotFound - - ; - ; Check FFS GUID - ; - cmp dword [eax + 0x10], FFS_GUID_DWORD0 - jne searchingForBfvHeaderLoop - cmp dword [eax + 0x14], FFS_GUID_DWORD1 - jne searchingForBfvHeaderLoop - cmp dword [eax + 0x18], FFS_GUID_DWORD2 - jne searchingForBfvHeaderLoop - cmp dword [eax + 0x1c], FFS_GUID_DWORD3 - jne searchingForBfvHeaderLoop - - ; - ; Check FV Length - ; - cmp dword [eax + 0x24], 0 - jne searchingForBfvHeaderLoop - mov ebx, eax - add ebx, dword [eax + 0x20] - jnz searchingForBfvHeaderLoop - - jmp searchedForBfvHeaderAndItWasFound - -searchedForBfvHeaderButNotFound: - ; - ; Hang if the SEC entry point was not found - ; - debugShowPostCode POSTCODE_BFV_NOT_FOUND - - ; - ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed - ; for debugging purposes. - ; - mov eax, 0xBFBFBFBF - mov ebp, eax - jmp $ - -searchedForBfvHeaderAndItWasFound: - mov ebp, eax - - debugShowPostCode POSTCODE_BFV_FOUND - - OneTimeCallRet Flat32SearchForBfvBase - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm deleted file mode 100644 index 6206b44485..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForSecEntry.asm +++ /dev/null @@ -1,200 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Search for the SEC Core entry point -; -; Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 32 - -%define EFI_FV_FILETYPE_SECURITY_CORE 0x03 - -; -; Modified: EAX, EBX, ECX, EDX -; Preserved: EDI, EBP, ESP -; -; @param[in] EBP Address of Boot Firmware Volume (BFV) -; @param[out] ESI SEC Core Entry Point Address -; -Flat32SearchForSecEntryPoint: - - ; - ; Initialize EBP and ESI to 0 - ; - xor ebx, ebx - mov esi, ebx - - ; - ; Pass over the BFV header - ; - mov eax, ebp - mov bx, [ebp + 0x30] - add eax, ebx - jc secEntryPointWasNotFound - - jmp searchingForFfsFileHeaderLoop - -moveForwardWhileSearchingForFfsFileHeaderLoop: - ; - ; Make forward progress in the search - ; - inc eax - jc secEntryPointWasNotFound - -searchingForFfsFileHeaderLoop: - test eax, eax - jz secEntryPointWasNotFound - - ; - ; Ensure 8 byte alignment - ; - add eax, 7 - jc secEntryPointWasNotFound - and al, 0xf8 - - ; - ; Look to see if there is an FFS file at eax - ; - mov bl, [eax + 0x17] - test bl, 0x20 - jz moveForwardWhileSearchingForFfsFileHeaderLoop - mov ecx, [eax + 0x14] - and ecx, 0x00ffffff - or ecx, ecx - jz moveForwardWhileSearchingForFfsFileHeaderLoop - add ecx, eax - jz jumpSinceWeFoundTheLastFfsFile - jc moveForwardWhileSearchingForFfsFileHeaderLoop -jumpSinceWeFoundTheLastFfsFile: - - ; - ; There seems to be a valid file at eax - ; - cmp byte [eax + 0x12], EFI_FV_FILETYPE_SECURITY_CORE ; Check File Type - jne readyToTryFfsFileAtEcx - -fileTypeIsSecCore: - OneTimeCall GetEntryPointOfFfsFile - test eax, eax - jnz doneSeachingForSecEntryPoint - -readyToTryFfsFileAtEcx: - ; - ; Try the next FFS file at ECX - ; - mov eax, ecx - jmp searchingForFfsFileHeaderLoop - -secEntryPointWasNotFound: - xor eax, eax - -doneSeachingForSecEntryPoint: - mov esi, eax - - test esi, esi - jnz secCoreEntryPointWasFound - -secCoreEntryPointWasNotFound: - ; - ; Hang if the SEC entry point was not found - ; - debugShowPostCode POSTCODE_SEC_NOT_FOUND - jz $ - -secCoreEntryPointWasFound: - debugShowPostCode POSTCODE_SEC_FOUND - - OneTimeCallRet Flat32SearchForSecEntryPoint - -%define EFI_SECTION_PE32 0x10 -%define EFI_SECTION_TE 0x12 - -; -; Input: -; EAX - Start of FFS file -; ECX - End of FFS file -; -; Output: -; EAX - Entry point of PE32 (or 0 if not found) -; -; Modified: -; EBX -; -GetEntryPointOfFfsFile: - test eax, eax - jz getEntryPointOfFfsFileErrorReturn - add eax, 0x18 ; EAX = Start of section - -getEntryPointOfFfsFileLoopForSections: - cmp eax, ecx - jae getEntryPointOfFfsFileErrorReturn - - cmp byte [eax + 3], EFI_SECTION_PE32 - je getEntryPointOfFfsFileFoundPe32Section - - cmp byte [eax + 3], EFI_SECTION_TE - je getEntryPointOfFfsFileFoundTeSection - - ; - ; The section type was not PE32 or TE, so move to next section - ; - mov ebx, dword [eax] - and ebx, 0x00ffffff - add eax, ebx - jc getEntryPointOfFfsFileErrorReturn - - ; - ; Ensure that FFS section is 32-bit aligned - ; - add eax, 3 - jc getEntryPointOfFfsFileErrorReturn - and al, 0xfc - jmp getEntryPointOfFfsFileLoopForSections - -getEntryPointOfFfsFileFoundPe32Section: - add eax, 4 ; EAX = Start of PE32 image - - cmp word [eax], 'MZ' - jne getEntryPointOfFfsFileErrorReturn - movzx ebx, word [eax + 0x3c] - add ebx, eax - - ; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) - cmp dword [ebx], `PE\x00\x00` - jne getEntryPointOfFfsFileErrorReturn - - ; *EntryPoint = (VOID *)((UINTN)Pe32Data + - ; (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff)); - add eax, [ebx + 0x4 + 0x14 + 0x10] - jmp getEntryPointOfFfsFileReturn - -getEntryPointOfFfsFileFoundTeSection: - add eax, 4 ; EAX = Start of TE image - mov ebx, eax - - ; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) - cmp word [ebx], 'VZ' - jne getEntryPointOfFfsFileErrorReturn - ; *EntryPoint = (VOID *)((UINTN)Pe32Data + - ; (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) + - ; sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize); - add eax, [ebx + 0x8] - add eax, 0x28 - movzx ebx, word [ebx + 0x6] - sub eax, ebx - jmp getEntryPointOfFfsFileReturn - -getEntryPointOfFfsFileErrorReturn: - mov eax, 0 - -getEntryPointOfFfsFileReturn: - OneTimeCallRet GetEntryPointOfFfsFile - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Main.asm b/UefiCpuPkg/ResetVector/Vtf0/Main.asm deleted file mode 100644 index ebfb9015d4..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Main.asm +++ /dev/null @@ -1,106 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Main routine of the pre-SEC code up through the jump into SEC -; -; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - - -BITS 16 - -; -; Modified: EBX, ECX, EDX, EBP -; -; @param[in,out] RAX/EAX Initial value of the EAX register -; (BIST: Built-in Self Test) -; @param[in,out] DI 'BP': boot-strap processor, or -; 'AP': application processor -; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV) -; -; @return None This routine jumps to SEC and does not return -; -Main16: - OneTimeCall EarlyInit16 - - ; - ; Transition the processor from 16-bit real mode to 32-bit flat mode - ; - OneTimeCall TransitionFromReal16To32BitFlat - -BITS 32 - - ; - ; Search for the Boot Firmware Volume (BFV) - ; - OneTimeCall Flat32SearchForBfvBase - - ; - ; EBP - Start of BFV - ; - - ; - ; Search for the SEC entry point - ; - OneTimeCall Flat32SearchForSecEntryPoint - - ; - ; ESI - SEC Core entry point - ; EBP - Start of BFV - ; - -%ifdef ARCH_IA32 - - ; - ; Restore initial EAX value into the EAX register - ; - mov eax, esp - - ; - ; Jump to the 32-bit SEC entry point - ; - jmp esi - -%else - - ; - ; Transition the processor from 32-bit flat mode to 64-bit flat mode - ; - OneTimeCall Transition32FlatTo64Flat - -BITS 64 - - ; - ; Some values were calculated in 32-bit mode. Make sure the upper - ; 32-bits of 64-bit registers are zero for these values. - ; - mov rax, 0x00000000ffffffff - and rsi, rax - and rbp, rax - and rsp, rax - - ; - ; RSI - SEC Core entry point - ; RBP - Start of BFV - ; - - ; - ; Restore initial EAX value into the RAX register - ; - mov rax, rsp - - ; - ; Jump to the 64-bit SEC entry point - ; - jmp rsi - -%endif - - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm b/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm deleted file mode 100644 index 4b13c4860b..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Port80Debug.asm +++ /dev/null @@ -1,28 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Port 0x80 debug support macros -; -; Copyright (c) 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 16 - -%macro debugInitialize 0 - ; - ; No initialization is required - ; -%endmacro - -%macro debugShowPostCode 1 - mov al, %1 - out 0x80, al -%endmacro - diff --git a/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc b/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc deleted file mode 100644 index 62eda5d992..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/PostCodes.inc +++ /dev/null @@ -1,25 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Definitions of POST CODES for the reset vector module -; -; Copyright (c) 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -%define POSTCODE_16BIT_MODE 0x16 -%define POSTCODE_32BIT_MODE 0x32 -%define POSTCODE_64BIT_MODE 0x64 - -%define POSTCODE_BFV_NOT_FOUND 0xb0 -%define POSTCODE_BFV_FOUND 0xb1 - -%define POSTCODE_SEC_NOT_FOUND 0xf0 -%define POSTCODE_SEC_FOUND 0xf1 - diff --git a/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt b/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt deleted file mode 100644 index e6e5b54243..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt +++ /dev/null @@ -1,41 +0,0 @@ - -=== HOW TO USE VTF0 === - -Add this line to your FDF FV section: -INF RuleOverride=RESET_VECTOR USE = IA32 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf -(For X64 SEC/PEI change IA32 to X64 => 'USE = X64') - -In your FDF FFS file rules sections add: -[Rule.Common.SEC.RESET_VECTOR] - FILE RAW = $(NAMED_GUID) { - RAW RAW |.raw - } - -=== VTF0 Boot Flow === - -1. Transition to IA32 flat mode -2. Locate BFV (Boot Firmware Volume) by checking every 4kb boundary -3. Locate SEC image -4. X64 VTF0 transitions to X64 mode -5. Call SEC image entry point - -== VTF0 SEC input parameters == - -All inputs to SEC image are register based: -EAX/RAX - Initial value of the EAX register (BIST: Built-in Self Test) -DI - 'BP': boot-strap processor, or 'AP': application processor -EBP/RBP - Pointer to the start of the Boot Firmware Volume - -=== HOW TO BUILD VTF0 === - -Dependencies: -* Python 2.5~2.7 -* Nasm 2.03 or newer - -To rebuild the VTF0 binaries: -1. Change to VTF0 source dir: UefiCpuPkg/ResetVector/Vtf0 -2. nasm and python should be in executable path -3. Run this command: - python Build.py -4. Binaries output will be in UefiCpuPkg/ResetVector/Vtf0/Bin - diff --git a/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni b/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni deleted file mode 100644 index 3fcc3f084c..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/ResetVector.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file -// Reset Vector -// -// Reset Vector -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Reset Vector" - -#string STR_MODULE_DESCRIPTION #language en-US "Reset Vector" - diff --git a/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni b/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni deleted file mode 100644 index f18a4f0443..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/ResetVectorExtra.uni +++ /dev/null @@ -1,17 +0,0 @@ -// /** @file -// ResetVector Localized Strings and Content -// -// Copyright (c) 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME #language en-US "ResetVector module" - - diff --git a/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm b/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm deleted file mode 100644 index ebd0910f4a..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/SerialDebug.asm +++ /dev/null @@ -1,132 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Serial port debug support macros -; -; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -;//--------------------------------------------- -;// UART Register Offsets -;//--------------------------------------------- -%define BAUD_LOW_OFFSET 0x00 -%define BAUD_HIGH_OFFSET 0x01 -%define IER_OFFSET 0x01 -%define LCR_SHADOW_OFFSET 0x01 -%define FCR_SHADOW_OFFSET 0x02 -%define IR_CONTROL_OFFSET 0x02 -%define FCR_OFFSET 0x02 -%define EIR_OFFSET 0x02 -%define BSR_OFFSET 0x03 -%define LCR_OFFSET 0x03 -%define MCR_OFFSET 0x04 -%define LSR_OFFSET 0x05 -%define MSR_OFFSET 0x06 - -;//--------------------------------------------- -;// UART Register Bit Defines -;//--------------------------------------------- -%define LSR_TXRDY 0x20 -%define LSR_RXDA 0x01 -%define DLAB 0x01 - -; UINT16 gComBase = 0x3f8; -; UINTN gBps = 115200; -; UINT8 gData = 8; -; UINT8 gStop = 1; -; UINT8 gParity = 0; -; UINT8 gBreakSet = 0; - -%define DEFAULT_COM_BASE 0x3f8 -%define DEFAULT_BPS 115200 -%define DEFAULT_DATA 8 -%define DEFAULT_STOP 1 -%define DEFAULT_PARITY 0 -%define DEFAULT_BREAK_SET 0 - -%define SERIAL_DEFAULT_LCR ( \ - (DEFAULT_BREAK_SET << 6) | \ - (DEFAULT_PARITY << 3) | \ - (DEFAULT_STOP << 2) | \ - (DEFAULT_DATA - 5) \ - ) - -%define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE - -%macro inFromSerialPort 1 - mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1) - in al, dx -%endmacro - -%macro waitForSerialTxReady 0 - -%%waitingForTx: - inFromSerialPort LSR_OFFSET - test al, LSR_TXRDY - jz %%waitingForTx - -%endmacro - -%macro outToSerialPort 2 - mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1) - mov al, %2 - out dx, al -%endmacro - -%macro debugShowCharacter 1 - waitForSerialTxReady - outToSerialPort 0, %1 -%endmacro - -%macro debugShowHexDigit 1 - %if (%1 < 0xa) - debugShowCharacter BYTE ('0' + (%1)) - %else - debugShowCharacter BYTE ('a' + ((%1) - 0xa)) - %endif -%endmacro - -%macro debugNewline 0 - debugShowCharacter `\r` - debugShowCharacter `\n` -%endmacro - -%macro debugShowPostCode 1 - debugShowHexDigit (((%1) >> 4) & 0xf) - debugShowHexDigit ((%1) & 0xf) - debugNewline -%endmacro - -BITS 16 - -%macro debugInitialize 0 - jmp real16InitDebug -real16InitDebugReturn: -%endmacro - -real16InitDebug: - ; - ; Set communications format - ; - outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR) - - ; - ; Configure baud rate - ; - outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8) - outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff) - - ; - ; Switch back to bank 0 - ; - outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR - - jmp real16InitDebugReturn - diff --git a/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py b/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py deleted file mode 100644 index a70ce7501d..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Tools/FixupForRawSection.py +++ /dev/null @@ -1,26 +0,0 @@ -## @file -# Apply fixup to VTF binary image for FFS Raw section -# -# Copyright (c) 2008, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -import sys - -filename = sys.argv[1] - -d = open(sys.argv[1], 'rb').read() -c = ((len(d) + 4 + 7) & ~7) - 4 -if c > len(d): - c -= len(d) - f = open(sys.argv[1], 'wb') - f.write('\x90' * c) - f.write(d) - f.close() diff --git a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf b/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf deleted file mode 100644 index 41aba45a14..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.inf +++ /dev/null @@ -1,36 +0,0 @@ -## @file -# Reset Vector -# -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ResetVector - FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 - MODULE_TYPE = SEC - VERSION_STRING = 1.1 - MODULE_UNI_FILE = ResetVector.uni - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - Vtf0.nasmb - -[Packages] - MdePkg/MdePkg.dec - -[UserExtensions.TianoCore."ExtraFiles"] - ResetVectorExtra.uni diff --git a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb b/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb deleted file mode 100644 index f4a29e8d89..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb +++ /dev/null @@ -1,70 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; This file includes all other code files to assemble the reset vector code -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -; -; If neither ARCH_IA32 nor ARCH_X64 are defined, then try to include -; Base.h to use the C pre-processor to determine the architecture. -; -%ifndef ARCH_IA32 - %ifndef ARCH_X64 - #include - #if defined (MDE_CPU_IA32) - %define ARCH_IA32 - #elif defined (MDE_CPU_X64) - %define ARCH_X64 - #endif - %endif -%endif - -%ifdef ARCH_IA32 - %ifdef ARCH_X64 - %error "Only one of ARCH_IA32 or ARCH_X64 can be defined." - %endif -%elifdef ARCH_X64 -%else - %error "Either ARCH_IA32 or ARCH_X64 must be defined." -%endif - -%include "CommonMacros.inc" - -%include "PostCodes.inc" - -%ifdef ARCH_X64 -%include "X64/PageTables.asm" -%endif - -%ifdef DEBUG_PORT80 - %include "Port80Debug.asm" -%elifdef DEBUG_SERIAL - %include "SerialDebug.asm" -%else - %include "DebugDisabled.asm" -%endif - -%include "Ia32/SearchForBfvBase.asm" -%include "Ia32/SearchForSecEntry.asm" - -%ifdef ARCH_X64 -%include "Ia32/Flat32ToFlat64.asm" -%include "Ia32/PageTables64.asm" -%endif - -%include "Ia16/Real16ToFlat32.asm" -%include "Ia16/Init16.asm" - -%include "Main.asm" - -%include "Ia16/ResetVectorVtf0.asm" - diff --git a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm b/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm deleted file mode 100644 index 3d703c74f6..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm +++ /dev/null @@ -1,78 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x100000000 (4GB) -; -; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 64 - -%define ALIGN_TOP_TO_4K_FOR_PAGING - -%define PAGE_PRESENT 0x01 -%define PAGE_READ_WRITE 0x02 -%define PAGE_USER_SUPERVISOR 0x04 -%define PAGE_WRITE_THROUGH 0x08 -%define PAGE_CACHE_DISABLE 0x010 -%define PAGE_ACCESSED 0x020 -%define PAGE_DIRTY 0x040 -%define PAGE_PAT 0x080 -%define PAGE_GLOBAL 0x0100 -%define PAGE_2M_MBO 0x080 -%define PAGE_2M_PAT 0x01000 - -%define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \ - PAGE_ACCESSED + \ - PAGE_DIRTY + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -%define PAGE_PDP_ATTR (PAGE_ACCESSED + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -%define PGTBLS_OFFSET(x) ((x) - TopLevelPageDirectory) -%define PGTBLS_ADDR(x) (ADDR_OF(TopLevelPageDirectory) + (x)) - -%define PDP(offset) (ADDR_OF(TopLevelPageDirectory) + (offset) + \ - PAGE_PDP_ATTR) -%define PTE_2MB(x) ((x << 21) + PAGE_2M_PDE_ATTR) - -TopLevelPageDirectory: - - ; - ; Top level Page Directory Pointers (1 * 512GB entry) - ; - DQ PDP(0x1000) - - - ; - ; Next level Page Directory Pointers (4 * 1GB entries => 4GB) - ; - TIMES 0x1000-PGTBLS_OFFSET($) DB 0 - - DQ PDP(0x2000) - DQ PDP(0x3000) - DQ PDP(0x4000) - DQ PDP(0x5000) - - ; - ; Page Table Entries (2048 * 2MB entries => 4GB) - ; - TIMES 0x2000-PGTBLS_OFFSET($) DB 0 - -%assign i 0 -%rep 0x800 - DQ PTE_2MB(i) - %assign i i+1 -%endrep - -EndOfPageTables: diff --git a/UefiCpuPkg/SecCore/FindPeiCore.c b/UefiCpuPkg/SecCore/FindPeiCore.c deleted file mode 100644 index 60ccaa9667..0000000000 --- a/UefiCpuPkg/SecCore/FindPeiCore.c +++ /dev/null @@ -1,198 +0,0 @@ -/** @file - Locate the entry point for the PEI Core - - Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "SecMain.h" - -/** - Find core image base. - - @param BootFirmwareVolumePtr Point to the boot firmware volume. - @param SecCoreImageBase The base address of the SEC core image. - @param PeiCoreImageBase The base address of the PEI core image. - -**/ -EFI_STATUS -EFIAPI -FindImageBase ( - IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, - OUT EFI_PHYSICAL_ADDRESS *SecCoreImageBase, - OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase - ) -{ - EFI_PHYSICAL_ADDRESS CurrentAddress; - EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume; - EFI_FFS_FILE_HEADER *File; - UINT32 Size; - EFI_PHYSICAL_ADDRESS EndOfFile; - EFI_COMMON_SECTION_HEADER *Section; - EFI_PHYSICAL_ADDRESS EndOfSection; - - *SecCoreImageBase = 0; - *PeiCoreImageBase = 0; - - CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) BootFirmwareVolumePtr; - EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr->FvLength; - - // - // Loop through the FFS files in the Boot Firmware Volume - // - for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr->HeaderLength; ; ) { - - CurrentAddress = (EndOfFile + 7) & 0xfffffffffffffff8ULL; - if (CurrentAddress > EndOfFirmwareVolume) { - return EFI_NOT_FOUND; - } - - File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress; - if (IS_FFS_FILE2 (File)) { - Size = FFS_FILE2_SIZE (File); - if (Size <= 0x00FFFFFF) { - return EFI_NOT_FOUND; - } - } else { - Size = FFS_FILE_SIZE (File); - if (Size < sizeof (EFI_FFS_FILE_HEADER)) { - return EFI_NOT_FOUND; - } - } - - EndOfFile = CurrentAddress + Size; - if (EndOfFile > EndOfFirmwareVolume) { - return EFI_NOT_FOUND; - } - - // - // Look for SEC Core / PEI Core files - // - if (File->Type != EFI_FV_FILETYPE_SECURITY_CORE && - File->Type != EFI_FV_FILETYPE_PEI_CORE) { - continue; - } - - // - // Loop through the FFS file sections within the FFS file - // - if (IS_FFS_FILE2 (File)) { - EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER2)); - } else { - EndOfSection = (EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) File + sizeof (EFI_FFS_FILE_HEADER)); - } - for (;;) { - CurrentAddress = (EndOfSection + 3) & 0xfffffffffffffffcULL; - Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress; - - if (IS_SECTION2 (Section)) { - Size = SECTION2_SIZE (Section); - if (Size <= 0x00FFFFFF) { - return EFI_NOT_FOUND; - } - } else { - Size = SECTION_SIZE (Section); - if (Size < sizeof (EFI_COMMON_SECTION_HEADER)) { - return EFI_NOT_FOUND; - } - } - - EndOfSection = CurrentAddress + Size; - if (EndOfSection > EndOfFile) { - return EFI_NOT_FOUND; - } - - // - // Look for executable sections - // - if (Section->Type == EFI_SECTION_PE32 || Section->Type == EFI_SECTION_TE) { - if (File->Type == EFI_FV_FILETYPE_SECURITY_CORE) { - if (IS_SECTION2 (Section)) { - *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); - } else { - *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); - } - } else { - if (IS_SECTION2 (Section)) { - *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2)); - } else { - *PeiCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER)); - } - } - break; - } - } - - // - // Both SEC Core and PEI Core images found - // - if (*SecCoreImageBase != 0 && *PeiCoreImageBase != 0) { - return EFI_SUCCESS; - } - } -} - -/** - Find and return Pei Core entry point. - - It also find SEC and PEI Core file debug information. It will report them if - remote debug is enabled. - - @param BootFirmwareVolumePtr Point to the boot firmware volume. - @param PeiCoreEntryPoint The entry point of the PEI core. - -**/ -VOID -EFIAPI -FindAndReportEntryPoints ( - IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, - OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS SecCoreImageBase; - EFI_PHYSICAL_ADDRESS PeiCoreImageBase; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - - // - // Find SEC Core and PEI Core image base - // - Status = FindImageBase (BootFirmwareVolumePtr, &SecCoreImageBase, &PeiCoreImageBase); - ASSERT_EFI_ERROR (Status); - - ZeroMem ((VOID *) &ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); - // - // Report SEC Core debug information when remote debug is enabled - // - ImageContext.ImageAddress = SecCoreImageBase; - ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); - PeCoffLoaderRelocateImageExtraAction (&ImageContext); - - // - // Report PEI Core debug information when remote debug is enabled - // - ImageContext.ImageAddress = PeiCoreImageBase; - ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); - PeCoffLoaderRelocateImageExtraAction (&ImageContext); - - // - // Find PEI Core entry point - // - Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, (VOID**) PeiCoreEntryPoint); - if (EFI_ERROR (Status)) { - *PeiCoreEntryPoint = 0; - } - - return; -} diff --git a/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 b/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 deleted file mode 100644 index d90613c4d0..0000000000 --- a/UefiCpuPkg/SecCore/Ia32/ResetVec.asm16 +++ /dev/null @@ -1,106 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ResetVec.asm -; -; Abstract: -; -; Reset Vector Data structure -; This structure is located at 0xFFFFFFC0 -; -;------------------------------------------------------------------------------ - - .model tiny - .686p - .stack 0h - .code - -; -; The layout of this file is fixed. The build tool makes assumption of the layout. -; - - ORG 0h -; -; Reserved -; -ReservedData DD 0eeeeeeeeh, 0eeeeeeeeh - - ORG 10h -; -; This is located at 0xFFFFFFD0h -; - mov di, "AP" - jmp ApStartup - - ORG 20h -; -; Pointer to the entry point of the PEI core -; It is located at 0xFFFFFFE0, and is fixed up by some build tool -; So if the value 8..1 appears in the final FD image, tool failure occurs. -; -PeiCoreEntryPoint DD 87654321h - -; -; This is the handler for all kinds of exceptions. Since it's for debugging -; purpose only, nothing except a dead loop would be done here. Developers could -; analyze the cause of the exception if a debugger had been attached. -; -InterruptHandler PROC - jmp $ - iret -InterruptHandler ENDP - - ORG 30h -; -; For IA32, the reset vector must be at 0xFFFFFFF0, i.e., 4G-16 byte -; Execution starts here upon power-on/platform-reset. -; -ResetHandler: - nop - nop -ApStartup: - ; - ; Jmp Rel16 instruction - ; Use machine code directly in case of the assembler optimization - ; SEC entry point relative address will be fixed up by some build tool. - ; - ; Typically, SEC entry point is the function _ModuleEntryPoint() defined in - ; SecEntry.asm - ; - DB 0e9h - DW -3 - - - ORG 38h -; -; Ap reset vector segment address is at 0xFFFFFFF8 -; This will be fixed up by some build tool, -; so if the value 1..8 appears in the final FD image, -; tool failure occurs -; -ApSegAddress dd 12345678h - - ORG 3ch -; -; BFV Base is at 0xFFFFFFFC -; This will be fixed up by some build tool, -; so if the value 1..8 appears in the final FD image, -; tool failure occurs. -; -BfvBase DD 12345678h - -; -; Nothing can go here, otherwise the layout of this file would change. -; - - END diff --git a/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb b/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb deleted file mode 100644 index 2fcdc85e47..0000000000 --- a/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb +++ /dev/null @@ -1,103 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ResetVec.nasmb -; -; Abstract: -; -; Reset Vector Data structure -; This structure is located at 0xFFFFFFC0 -; -;------------------------------------------------------------------------------ - -; .stack 0x0 -; SECTION .text -USE16 - -; -; The layout of this file is fixed. The build tool makes assumption of the layout. -; - - ORG 0h -; -; Reserved -; -ReservedData: DD 0eeeeeeeeh, 0eeeeeeeeh - - TIMES 0x10-($-$$) DB 0 -; -; This is located at 0xFFFFFFD0h -; - mov di, "PA" - jmp ApStartup - - TIMES 0x20-($-$$) DB 0 -; -; Pointer to the entry point of the PEI core -; It is located at 0xFFFFFFE0, and is fixed up by some build tool -; So if the value 8..1 appears in the final FD image, tool failure occurs. -; -PeiCoreEntryPoint: DD 87654321h - -; -; This is the handler for all kinds of exceptions. Since it's for debugging -; purpose only, nothing except a dead loop would be done here. Developers could -; analyze the cause of the exception if a debugger had been attached. -; -global ASM_PFX(InterruptHandler) -ASM_PFX(InterruptHandler): - jmp $ - iret - - TIMES 0x30-($-$$) DB 0 -; -; For IA32, the reset vector must be at 0xFFFFFFF0, i.e., 4G-16 byte -; Execution starts here upon power-on/platform-reset. -; -ResetHandler: - nop - nop -ApStartup: - ; - ; Jmp Rel16 instruction - ; Use machine code directly in case of the assembler optimization - ; SEC entry point relative address will be fixed up by some build tool. - ; - ; Typically, SEC entry point is the function _ModuleEntryPoint() defined in - ; SecEntry.asm - ; - DB 0e9h - DW -3 - - - TIMES 0x38-($-$$) DB 0 -; -; Ap reset vector segment address is at 0xFFFFFFF8 -; This will be fixed up by some build tool, -; so if the value 1..8 appears in the final FD image, -; tool failure occurs -; -ApSegAddress: dd 12345678h - - TIMES 0x3c-($-$$) DB 0 -; -; BFV Base is at 0xFFFFFFFC -; This will be fixed up by some build tool, -; so if the value 1..8 appears in the final FD image, -; tool failure occurs. -; -BfvBase: DD 12345678h - -; -; Nothing can go here, otherwise the layout of this file would change. -; diff --git a/UefiCpuPkg/SecCore/SecBist.c b/UefiCpuPkg/SecCore/SecBist.c deleted file mode 100644 index a9d36acadb..0000000000 --- a/UefiCpuPkg/SecCore/SecBist.c +++ /dev/null @@ -1,270 +0,0 @@ -/** @file - Get SEC platform information(2) PPI and reinstall it. - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SecMain.h" - -EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformation = { - SecPlatformInformationBist -}; - -EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiSecPlatformInformationPpiGuid, - &mSecPlatformInformation -}; - -EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2 = { - SecPlatformInformation2Bist -}; - -EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2 = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiSecPlatformInformation2PpiGuid, - &mSecPlatformInformation2 -}; - -/** - Worker function to parse CPU BIST information from Guided HOB. - - @param[in, out] StructureSize Pointer to the variable describing size of the input buffer. - @param[in, out] StructureBuffer Pointer to the buffer save CPU BIST information. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. - -**/ -EFI_STATUS -GetBistFromHob ( - IN OUT UINT64 *StructureSize, - IN OUT VOID *StructureBuffer - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - VOID *DataInHob; - UINTN DataSize; - - GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid); - if (GuidHob == NULL) { - *StructureSize = 0; - return EFI_SUCCESS; - } - - DataInHob = GET_GUID_HOB_DATA (GuidHob); - DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); - - // - // return the information from BistHob - // - if ((*StructureSize) < (UINT64) DataSize) { - *StructureSize = (UINT64) DataSize; - return EFI_BUFFER_TOO_SMALL; - } - - *StructureSize = (UINT64) DataSize; - CopyMem (StructureBuffer, DataInHob, DataSize); - return EFI_SUCCESS; -} - -/** - Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI. - - @param[in] PeiServices Pointer to the PEI Services Table. - @param[in, out] StructureSize Pointer to the variable describing size of the input buffer. - @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformationBist ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord - ) -{ - return GetBistFromHob (StructureSize, PlatformInformationRecord); -} - -/** - Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. - - @param[in] PeiServices The pointer to the PEI Services Table. - @param[in, out] StructureSize The pointer to the variable describing size of the input buffer. - @param[out] PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to - hold the record is returned in StructureSize. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation2Bist ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 - ) -{ - return GetBistFromHob (StructureSize, PlatformInformationRecord2); -} - -/** - Worker function to get CPUs' BIST by calling SecPlatformInformationPpi - or SecPlatformInformation2Ppi. - - @param[in] PeiServices Pointer to PEI Services Table - @param[in] Guid PPI Guid - @param[out] PpiDescriptor Return a pointer to instance of the - EFI_PEI_PPI_DESCRIPTOR - @param[out] BistInformationData Pointer to BIST information data - @param[out] BistInformationSize Return the size in bytes of BIST information - - @retval EFI_SUCCESS Retrieve of the BIST data successfully - @retval EFI_NOT_FOUND No sec platform information(2) ppi export - @retval EFI_DEVICE_ERROR Failed to get CPU Information - -**/ -EFI_STATUS -GetBistInfoFromPpi ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN CONST EFI_GUID *Guid, - OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, - OUT VOID **BistInformationData, - OUT UINT64 *BistInformationSize OPTIONAL - ) -{ - EFI_STATUS Status; - EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi; - EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; - UINT64 InformationSize; - - Status = PeiServicesLocatePpi ( - Guid, // GUID - 0, // INSTANCE - PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR - (VOID **)&SecPlatformInformation2Ppi // PPI - ); - if (Status == EFI_NOT_FOUND) { - return EFI_NOT_FOUND; - } - - if (Status == EFI_SUCCESS) { - // - // Get the size of the sec platform information2(BSP/APs' BIST data) - // - InformationSize = 0; - SecPlatformInformation2 = NULL; - Status = SecPlatformInformation2Ppi->PlatformInformation2 ( - PeiServices, - &InformationSize, - SecPlatformInformation2 - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - Status = PeiServicesAllocatePool ( - (UINTN) InformationSize, - (VOID **) &SecPlatformInformation2 - ); - if (Status == EFI_SUCCESS) { - // - // Retrieve BIST data - // - Status = SecPlatformInformation2Ppi->PlatformInformation2 ( - PeiServices, - &InformationSize, - SecPlatformInformation2 - ); - if (Status == EFI_SUCCESS) { - *BistInformationData = SecPlatformInformation2; - if (BistInformationSize != NULL) { - *BistInformationSize = InformationSize; - } - return EFI_SUCCESS; - } - } - } - } - - return EFI_DEVICE_ERROR; -} - -/** - Get CPUs' BIST by calling SecPlatformInformationPpi/SecPlatformInformation2Ppi. - -**/ -VOID -RepublishSecPlatformInformationPpi ( - VOID - ) -{ - EFI_STATUS Status; - CONST EFI_PEI_SERVICES **PeiServices; - UINT64 BistInformationSize; - VOID *BistInformationData; - EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor; - - PeiServices = GetPeiServicesTablePointer (); - Status = GetBistInfoFromPpi ( - PeiServices, - &gEfiSecPlatformInformation2PpiGuid, - &SecInformationDescriptor, - &BistInformationData, - &BistInformationSize - ); - if (Status == EFI_SUCCESS) { - BuildGuidDataHob ( - &gEfiCallerIdGuid, - BistInformationData, - (UINTN) BistInformationSize - ); - // - // The old SecPlatformInformation2 data is on temporary memory. - // After memory discovered, we should never get it from temporary memory, - // or the data will be crashed. So, we reinstall SecPlatformInformation2 PPI here. - // - Status = PeiServicesReInstallPpi ( - SecInformationDescriptor, - &mPeiSecPlatformInformation2 - ); - } if (Status == EFI_NOT_FOUND) { - Status = GetBistInfoFromPpi ( - PeiServices, - &gEfiSecPlatformInformationPpiGuid, - &SecInformationDescriptor, - &BistInformationData, - &BistInformationSize - ); - if (Status == EFI_SUCCESS) { - BuildGuidDataHob ( - &gEfiCallerIdGuid, - BistInformationData, - (UINTN) BistInformationSize - ); - // - // The old SecPlatformInformation data is on temporary memory. - // After memory discovered, we should never get it from temporary memory, - // or the data will be crashed. So, we reinstall SecPlatformInformation PPI here. - // - Status = PeiServicesReInstallPpi ( - SecInformationDescriptor, - &mPeiSecPlatformInformation - ); - } else if (Status == EFI_NOT_FOUND) { - return; - } - } - - ASSERT_EFI_ERROR(Status); -} diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf deleted file mode 100644 index 0d135e62ec..0000000000 --- a/UefiCpuPkg/SecCore/SecCore.inf +++ /dev/null @@ -1,79 +0,0 @@ -## @file -# SecCore module that implements the SEC phase. -# -# This is the first module taking control of the platform upon power-on/reset. -# It implements the first phase of the security phase. The entry point function is -# _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to -# protected mode, setup flat memory model, enable temporary memory and -# call into SecStartup(). -# -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SecCore - MODULE_UNI_FILE = SecCore.uni - FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 - MODULE_TYPE = SEC - VERSION_STRING = 1.0 - - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - SecMain.c - SecMain.h - FindPeiCore.c - SecBist.c - -[Sources.IA32] - Ia32/ResetVec.nasmb - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - BaseLib - PlatformSecLib - PcdLib - DebugAgentLib - UefiCpuLib - PeCoffGetEntryPointLib - PeCoffExtraActionLib - CpuExceptionHandlerLib - ReportStatusCodeLib - PeiServicesLib - PeiServicesTablePointerLib - HobLib - -[Ppis] - ## SOMETIMES_CONSUMES - ## PRODUCES - gEfiSecPlatformInformationPpiGuid - ## SOMETIMES_CONSUMES - ## SOMETIMES_PRODUCES - gEfiSecPlatformInformation2PpiGuid - gEfiTemporaryRamDonePpiGuid ## PRODUCES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## CONSUMES - -[UserExtensions.TianoCore."ExtraFiles"] - SecCoreExtra.uni diff --git a/UefiCpuPkg/SecCore/SecCore.uni b/UefiCpuPkg/SecCore/SecCore.uni deleted file mode 100644 index bd43c8b753..0000000000 --- a/UefiCpuPkg/SecCore/SecCore.uni +++ /dev/null @@ -1,24 +0,0 @@ -// /** @file -// SecCore module that implements the SEC phase. -// -// This is the first module taking control of the platform upon power-on/reset. -// It implements the first phase of the security phase. The entry point function is -// _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to -// protected mode, setup flat memory model, enable temporary memory and -// call into SecStartup(). -// -// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_MODULE_ABSTRACT #language en-US "SecCore module that implements the SEC phase" - -#string STR_MODULE_DESCRIPTION #language en-US "This is the first module taking control of the platform upon power-on/reset. It implements the first phase of the security phase. The entry point function is _ModuleEntryPoint in PlatformSecLib. The entry point function will switch to protected mode, will setup flat memory model, will enable temporary memory and will call into SecStartup()." diff --git a/UefiCpuPkg/SecCore/SecCoreExtra.uni b/UefiCpuPkg/SecCore/SecCoreExtra.uni deleted file mode 100644 index c4bd4da20e..0000000000 --- a/UefiCpuPkg/SecCore/SecCoreExtra.uni +++ /dev/null @@ -1,18 +0,0 @@ -// /** @file -// SecCore Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"SEC Core Module" diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c deleted file mode 100644 index 077d0db49f..0000000000 --- a/UefiCpuPkg/SecCore/SecMain.c +++ /dev/null @@ -1,310 +0,0 @@ -/** @file - C functions in SEC - - Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SecMain.h" - -EFI_PEI_TEMPORARY_RAM_DONE_PPI gSecTemporaryRamDonePpi = { - SecTemporaryRamDone -}; - -EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformationPpi = { SecPlatformInformation }; - -EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformationPpi[] = { - { - EFI_PEI_PPI_DESCRIPTOR_PPI, - &gEfiTemporaryRamDonePpiGuid, - &gSecTemporaryRamDonePpi - }, - { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiSecPlatformInformationPpiGuid, - &mSecPlatformInformationPpi - } -}; - -// -// These are IDT entries pointing to 10:FFFFFFE4h. -// -UINT64 mIdtEntryTemplate = 0xffff8e000010ffe4ULL; - -/** - Caller provided function to be invoked at the end of InitializeDebugAgent(). - - Entry point to the C language phase of SEC. After the SEC assembly - code has initialized some temporary memory and set up the stack, - the control is transferred to this function. - - @param[in] Context The first input parameter of InitializeDebugAgent(). - -**/ -VOID -NORETURN -EFIAPI -SecStartupPhase2( - IN VOID *Context - ); - -/** - - Entry point to the C language phase of SEC. After the SEC assembly - code has initialized some temporary memory and set up the stack, - the control is transferred to this function. - - - @param SizeOfRam Size of the temporary memory available for use. - @param TempRamBase Base address of temporary ram - @param BootFirmwareVolume Base address of the Boot Firmware Volume. -**/ -VOID -EFIAPI -SecStartup ( - IN UINT32 SizeOfRam, - IN UINT32 TempRamBase, - IN VOID *BootFirmwareVolume - ) -{ - EFI_SEC_PEI_HAND_OFF SecCoreData; - IA32_DESCRIPTOR IdtDescriptor; - SEC_IDT_TABLE IdtTableInStack; - UINT32 Index; - UINT32 PeiStackSize; - EFI_STATUS Status; - - // - // Report Status Code to indicate entering SEC core - // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - EFI_SOFTWARE_SEC | EFI_SW_SEC_PC_ENTRY_POINT - ); - - PeiStackSize = PcdGet32 (PcdPeiTemporaryRamStackSize); - if (PeiStackSize == 0) { - PeiStackSize = (SizeOfRam >> 1); - } - - ASSERT (PeiStackSize < SizeOfRam); - - // - // Process all libraries constructor function linked to SecCore. - // - ProcessLibraryConstructorList (); - - // - // Initialize floating point operating environment - // to be compliant with UEFI spec. - // - InitializeFloatingPointUnits (); - - // |-------------------|----> - // |IDT Table | - // |-------------------| - // |PeiService Pointer | PeiStackSize - // |-------------------| - // | | - // | Stack | - // |-------------------|----> - // | | - // | | - // | Heap | PeiTemporayRamSize - // | | - // | | - // |-------------------|----> TempRamBase - - IdtTableInStack.PeiService = 0; - for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) { - CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&mIdtEntryTemplate, sizeof (UINT64)); - } - - IdtDescriptor.Base = (UINTN) &IdtTableInStack.IdtTable; - IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1); - - AsmWriteIdtr (&IdtDescriptor); - - // - // Setup the default exception handlers - // - Status = InitializeCpuExceptionHandlers (NULL); - ASSERT_EFI_ERROR (Status); - - // - // Update the base address and length of Pei temporary memory - // - SecCoreData.DataSize = (UINT16) sizeof (EFI_SEC_PEI_HAND_OFF); - SecCoreData.BootFirmwareVolumeBase = BootFirmwareVolume; - SecCoreData.BootFirmwareVolumeSize = (UINTN)(0x100000000ULL - (UINTN) BootFirmwareVolume); - SecCoreData.TemporaryRamBase = (VOID*)(UINTN) TempRamBase; - SecCoreData.TemporaryRamSize = SizeOfRam; - SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase; - SecCoreData.PeiTemporaryRamSize = SizeOfRam - PeiStackSize; - SecCoreData.StackBase = (VOID*)(UINTN)(TempRamBase + SecCoreData.PeiTemporaryRamSize); - SecCoreData.StackSize = PeiStackSize; - - // - // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready. - // - InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, &SecCoreData, SecStartupPhase2); -} - -/** - Caller provided function to be invoked at the end of InitializeDebugAgent(). - - Entry point to the C language phase of SEC. After the SEC assembly - code has initialized some temporary memory and set up the stack, - the control is transferred to this function. - - @param[in] Context The first input parameter of InitializeDebugAgent(). - -**/ -VOID -NORETURN -EFIAPI -SecStartupPhase2( - IN VOID *Context - ) -{ - EFI_SEC_PEI_HAND_OFF *SecCoreData; - EFI_PEI_PPI_DESCRIPTOR *PpiList; - UINT32 Index; - EFI_PEI_PPI_DESCRIPTOR *AllSecPpiList; - EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint; - - SecCoreData = (EFI_SEC_PEI_HAND_OFF *) Context; - AllSecPpiList = (EFI_PEI_PPI_DESCRIPTOR *) SecCoreData->PeiTemporaryRamBase; - // - // Find Pei Core entry point. It will report SEC and Pei Core debug information if remote debug - // is enabled. - // - FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint); - if (PeiCoreEntryPoint == NULL) - { - CpuDeadLoop (); - } - - // - // Perform platform specific initialization before entering PeiCore. - // - PpiList = SecPlatformMain (SecCoreData); - if (PpiList != NULL) { - // - // Remove the terminal flag from the terminal PPI - // - CopyMem (AllSecPpiList, mPeiSecPlatformInformationPpi, sizeof (mPeiSecPlatformInformationPpi)); - Index = sizeof (mPeiSecPlatformInformationPpi) / sizeof (EFI_PEI_PPI_DESCRIPTOR) - 1; - AllSecPpiList[Index].Flags = AllSecPpiList[Index].Flags & (~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); - - // - // Append the platform additional PPI list - // - Index += 1; - while (((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) != EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)) { - CopyMem (&AllSecPpiList[Index], PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR)); - Index++; - PpiList++; - } - - // - // Add the terminal PPI - // - CopyMem (&AllSecPpiList[Index ++], PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR)); - - // - // Set PpiList to the total PPI - // - PpiList = AllSecPpiList; - - // - // Adjust PEI TEMP RAM Range. - // - ASSERT (SecCoreData->PeiTemporaryRamSize > Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); - SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN) SecCoreData->PeiTemporaryRamBase + Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); - SecCoreData->PeiTemporaryRamSize = SecCoreData->PeiTemporaryRamSize - Index * sizeof (EFI_PEI_PPI_DESCRIPTOR); - } else { - // - // No addition PPI, PpiList directly point to the common PPI list. - // - PpiList = &mPeiSecPlatformInformationPpi[0]; - } - - DEBUG (( - DEBUG_INFO, - "%a() Stack Base: 0x%p, Stack Size: 0x%x\n", - __FUNCTION__, - SecCoreData->StackBase, - (UINT32) SecCoreData->StackSize - )); - - // - // Report Status Code to indicate transferring to PEI core - // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - EFI_SOFTWARE_SEC | EFI_SW_SEC_PC_HANDOFF_TO_NEXT - ); - - // - // Transfer the control to the PEI core - // - ASSERT (PeiCoreEntryPoint != NULL); - (*PeiCoreEntryPoint) (SecCoreData, PpiList); - - // - // Should not come here. - // - UNREACHABLE (); -} - -/** - TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked - by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. - - @retval EFI_SUCCESS Use of Temporary RAM was disabled. - @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. - -**/ -EFI_STATUS -EFIAPI -SecTemporaryRamDone ( - VOID - ) -{ - BOOLEAN State; - - // - // Republish Sec Platform Information(2) PPI - // - RepublishSecPlatformInformationPpi (); - - // - // Migrate DebugAgentContext. - // - InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL); - - // - // Disable interrupts and save current interrupt state - // - State = SaveAndDisableInterrupts(); - - // - // Disable Temporary RAM after Stack and Heap have been migrated at this point. - // - SecPlatformDisableTemporaryMemory (); - - // - // Restore original interrupt state - // - SetInterruptState (State); - - return EFI_SUCCESS; -} diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h deleted file mode 100644 index 6e31a953f7..0000000000 --- a/UefiCpuPkg/SecCore/SecMain.h +++ /dev/null @@ -1,160 +0,0 @@ -/** @file - Master header file for SecCore. - - Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SEC_CORE_H_ -#define _SEC_CORE_H_ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SEC_IDT_ENTRY_COUNT 34 - -typedef struct _SEC_IDT_TABLE { - // - // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base - // address should be 8-byte alignment. - // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store - // EFI_PEI_SERVICES** - // - UINT64 PeiService; - UINT64 IdtTable[SEC_IDT_ENTRY_COUNT]; -} SEC_IDT_TABLE; - -/** - TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked - by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. - - @retval EFI_SUCCESS Use of Temporary RAM was disabled. - @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. - -**/ -EFI_STATUS -EFIAPI -SecTemporaryRamDone ( - VOID - ); - -/** - Entry point to the C language phase of SEC. After the SEC assembly - code has initialized some temporary memory and set up the stack, - the control is transferred to this function. - - @param SizeOfRam Size of the temporary memory available for use. - @param TempRamBase Base address of temporary ram - @param BootFirmwareVolume Base address of the Boot Firmware Volume. -**/ -VOID -EFIAPI -SecStartup ( - IN UINT32 SizeOfRam, - IN UINT32 TempRamBase, - IN VOID *BootFirmwareVolume - ); - -/** - Find and return Pei Core entry point. - - It also find SEC and PEI Core file debug information. It will report them if - remote debug is enabled. - - @param BootFirmwareVolumePtr Point to the boot firmware volume. - @param PeiCoreEntryPoint Point to the PEI core entry point. - -**/ -VOID -EFIAPI -FindAndReportEntryPoints ( - IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, - OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint - ); - -/** - Auto-generated function that calls the library constructors for all of the module's - dependent libraries. This function must be called by the SEC Core once a stack has - been established. - -**/ -VOID -EFIAPI -ProcessLibraryConstructorList ( - VOID - ); - -/** - Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI. - - @param PeiServices Pointer to the PEI Services Table. - @param StructureSize Pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformationBist ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord - ); - -/** - Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. - - @param PeiServices The pointer to the PEI Services Table. - @param StructureSize The pointer to the variable describing size of the input buffer. - @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. - - @retval EFI_SUCCESS The data was successfully returned. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to - hold the record is returned in StructureSize. - -**/ -EFI_STATUS -EFIAPI -SecPlatformInformation2Bist ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN OUT UINT64 *StructureSize, - OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 - ); - -/** - Republish SecPlatformInformationPpi/SecPlatformInformation2Ppi. - -**/ -VOID -RepublishSecPlatformInformationPpi ( - VOID - ); - -#endif diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec deleted file mode 100644 index 6f30ad032d..0000000000 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ /dev/null @@ -1,289 +0,0 @@ -## @file UefiCpuPkg.dec -# This Package provides UEFI compatible CPU modules and libraries. -# -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available under -# the terms and conditions of the BSD License which accompanies this distribution. -# The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - DEC_SPECIFICATION = 0x00010005 - PACKAGE_NAME = UefiCpuPkg - PACKAGE_UNI_FILE = UefiCpuPkg.uni - PACKAGE_GUID = 2171df9b-0d39-45aa-ac37-2de190010d23 - PACKAGE_VERSION = 0.3 - -[Includes] - Include - -[LibraryClasses] - ## @libraryclass Defines some routines that are generic for IA32 family CPU - ## to be UEFI specification compliant. - ## - UefiCpuLib|Include/Library/UefiCpuLib.h - - ## @libraryclass Defines some routines that are used to register/manage/program - ## CPU features. - ## - RegisterCpuFeaturesLib|Include/Library/RegisterCpuFeaturesLib.h - -[LibraryClasses.IA32, LibraryClasses.X64] - ## @libraryclass Provides functions to manage MTRR settings on IA32 and X64 CPUs. - ## - MtrrLib|Include/Library/MtrrLib.h - - ## @libraryclass Provides functions to manage the Local APIC on IA32 and X64 CPUs. - ## - LocalApicLib|Include/Library/LocalApicLib.h - - ## @libraryclass Provides platform specific initialization functions in the SEC phase. - ## - PlatformSecLib|Include/Library/PlatformSecLib.h - - ## @libraryclass Public include file for the SMM CPU Platform Hook Library. - ## - SmmCpuPlatformHookLib|Include/Library/SmmCpuPlatformHookLib.h - - ## @libraryclass Provides the CPU specific programming for PiSmmCpuDxeSmm module. - ## - SmmCpuFeaturesLib|Include/Library/SmmCpuFeaturesLib.h - - ## @libraryclass Provides functions to support MP services on CpuMpPei and CpuDxe module. - ## - MpInitLib|Include/Library/MpInitLib.h - - ## @libraryclass Provides services to access Microcode region on flash device. - # - MicrocodeFlashAccessLib|Include/Library/MicrocodeFlashAccessLib.h - -[Guids] - gUefiCpuPkgTokenSpaceGuid = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} - gMsegSmramGuid = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} - - ## Include/Guid/MicrocodeFmp.h - gMicrocodeFmpImageTypeIdGuid = { 0x96d4fdcd, 0x1502, 0x424d, { 0x9d, 0x4c, 0x9b, 0x12, 0xd2, 0xdc, 0xae, 0x5c } } - - ## Include/Guid/CpuFeaturesSetDone.h - gEdkiiCpuFeaturesSetDoneGuid = { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 }} - - ## Include/Guid/CpuFeaturesInitDone.h - gEdkiiCpuFeaturesInitDoneGuid = { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 }} - -[Protocols] - ## Include/Protocol/SmmCpuService.h - gEfiSmmCpuServiceProtocolGuid = { 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 }} - - ## Include/Protocol/SmMonitorInit.h - gEfiSmMonitorInitProtocolGuid = { 0x228f344d, 0xb3de, 0x43bb, { 0xa4, 0xd7, 0xea, 0x20, 0xb, 0x1b, 0x14, 0x82 }} - -# -# [Error.gUefiCpuPkgTokenSpaceGuid] -# 0x80000001 | Invalid value provided. -# - -[PcdsFeatureFlag] - ## Indicates if SMM Profile will be enabled. - # If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged. - # This PCD is only for validation purpose. It should be set to false in production.

- # TRUE - SMM Profile will be enabled.
- # FALSE - SMM Profile will be disabled.
- # @Prompt Enable SMM Profile. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileEnable|FALSE|BOOLEAN|0x32132109 - - ## Indicates if the SMM profile log buffer is a ring buffer. - # If disabled, no additional log can be done when the buffer is full.

- # TRUE - the SMM profile log buffer is a ring buffer.
- # FALSE - the SMM profile log buffer is a normal buffer.
- # @Prompt The SMM profile log buffer is a ring buffer. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer|FALSE|BOOLEAN|0x3213210a - - ## Indicates if SMM Startup AP in a blocking fashion. - # TRUE - SMM Startup AP in a blocking fashion.
- # FALSE - SMM Startup AP in a non-blocking fashion.
- # @Prompt SMM Startup AP in a blocking fashion. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmBlockStartupThisAp|FALSE|BOOLEAN|0x32132108 - - ## Indicates if SMM Stack Guard will be enabled. - # If enabled, stack overflow in SMM can be caught, preventing chaotic consequences.

- # TRUE - SMM Stack Guard will be enabled.
- # FALSE - SMM Stack Guard will be disabled.
- # @Prompt Enable SMM Stack Guard. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard|TRUE|BOOLEAN|0x1000001C - - ## Indicates if BSP election in SMM will be enabled. - # If enabled, a BSP will be dynamically elected among all processors in each SMI. - # Otherwise, processor 0 is always as BSP in each SMI.

- # TRUE - BSP election in SMM will be enabled.
- # FALSE - BSP election in SMM will be disabled.
- # @Prompt Enable BSP election in SMM. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|TRUE|BOOLEAN|0x32132106 - - ## Indicates if CPU SMM hot-plug will be enabled.

- # TRUE - SMM CPU hot-plug will be enabled.
- # FALSE - SMM CPU hot-plug will be disabled.
- # @Prompt SMM CPU hot-plug. - gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport|FALSE|BOOLEAN|0x3213210C - - ## Indicates if SMM Debug will be enabled. - # If enabled, hardware breakpoints in SMRAM can be set outside of SMM mode and take effect in SMM.

- # TRUE - SMM Debug will be enabled.
- # FALSE - SMM Debug will be disabled.
- # @Prompt Enable SMM Debug. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug|FALSE|BOOLEAN|0x1000001B - - ## Indicates if lock SMM Feature Control MSR.

- # TRUE - SMM Feature Control MSR will be locked.
- # FALSE - SMM Feature Control MSR will not be locked.
- # @Prompt Lock SMM Feature Control MSR. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock|TRUE|BOOLEAN|0x3213210B - -[PcdsFixedAtBuild, PcdsPatchableInModule] - ## This value is the CPU Local APIC base address, which aligns the address on a 4-KByte boundary. - # @Prompt Configure base address of CPU Local APIC - # @Expression 0x80000001 | (gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress & 0xfff) == 0 - gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress|0xfee00000|UINT32|0x00000001 - - ## Specifies delay value in microseconds after sending out an INIT IPI. - # @Prompt Configure delay value after send an INIT IPI - gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds|10000|UINT32|0x30000002 - - ## This value specifies the Application Processor (AP) stack size, used for Mp Service, which must - ## aligns the address on a 4-KByte boundary. - # @Prompt Configure stack size for Application Processor (AP) - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize|0x8000|UINT32|0x00000003 - - ## Specifies stack size in the temporary RAM. 0 means half of TemporaryRamSize. - # @Prompt Stack size in the temporary RAM. - gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize|0|UINT32|0x10001003 - - ## Specifies buffer size in bytes to save SMM profile data. The value should be a multiple of 4KB. - # @Prompt SMM profile data buffer size. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize|0x200000|UINT32|0x32132107 - - ## Specifies stack size in bytes for each processor in SMM. - # @Prompt Processor stack size in SMM. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x2000|UINT32|0x32132105 - - ## Indicates if SMM Code Access Check is enabled. - # If enabled, the SMM handler cannot execute the code outside SMM regions. - # This PCD is suggested to TRUE in production image.

- # TRUE - SMM Code Access Check will be enabled.
- # FALSE - SMM Code Access Check will be disabled.
- # @Prompt SMM Code Access Check. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable|TRUE|BOOLEAN|0x60000013 - - ## Specifies the number of variable MTRRs reserved for OS use. The default number of - # MTRRs reserved for OS use is 2. - # @Prompt Number of reserved variable MTRRs. - gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0x2|UINT32|0x00000015 - - ## Specifies buffer size in bytes for STM exception stack. The value should be a multiple of 4KB. - # @Prompt STM exception stack size. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStmExceptionStackSize|0x1000|UINT32|0x32132111 - - ## Specifies buffer size in bytes of MSEG. The value should be a multiple of 4KB. - # @Prompt MSEG size. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMsegSize|0x200000|UINT32|0x32132112 - - ## Specifies the supported CPU features bit in array. - # @Prompt Supported CPU features. - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport|{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}|VOID*|0x00000016 - - ## Specifies if CPU features will be initialized after SMM relocation. - # @Prompt If CPU features will be initialized after SMM relocation. - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation|FALSE|BOOLEAN|0x0000001C - - ## Specifies if CPU features will be initialized during S3 resume. - # @Prompt If CPU features will be initialized during S3 resume. - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|FALSE|BOOLEAN|0x0000001D - -[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] - ## Specifies max supported number of Logical Processors. - # @Prompt Configure max supported number of Logical Processors - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64|UINT32|0x00000002 - ## Specifies timeout value in microseconds for the BSP to detect all APs for the first time. - # @Prompt Timeout for the BSP to detect all APs for the first time. - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000|UINT32|0x00000004 - ## Specifies the base address of the first microcode Patch in the microcode Region. - # @Prompt Microcode Region base address. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress|0x0|UINT64|0x00000005 - ## Specifies the size of the microcode Region. - # @Prompt Microcode Region size. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize|0x0|UINT64|0x00000006 - ## Specifies the AP wait loop state during POST phase. - # The value is defined as below.

- # 1: Place AP in the Hlt-Loop state.
- # 2: Place AP in the Mwait-Loop state.
- # 3: Place AP in the Run-Loop state.
- # @Prompt The AP wait loop state. - # @ValidRange 0x80000001 | 1 - 3 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode|1|UINT8|0x60008006 - ## Specifies the AP target C-state for Mwait during POST phase. - # The default value 0 means C1 state. - # The value is defined as below.

- # @Prompt The specified AP target C-state for Mwait. - gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate|0|UINT8|0x00000007 - - ## Indicates if SMM uses static page table. - # If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.

- # This flag only impacts X64 build, because SMM alway builds static page table for IA32. - # TRUE - SMM uses static page table for all memory.
- # FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.
- # @Prompt Use static page table for all memory in SMM. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStaticPageTable|TRUE|BOOLEAN|0x3213210D - - ## Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM. - # @Prompt AP synchronization timeout value in SMM. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000000|UINT64|0x32132104 - - ## Indicates the CPU synchronization method used when processing an SMI. - # 0x00 - Traditional CPU synchronization method.
- # 0x01 - Relaxed CPU synchronization method.
- # @Prompt SMM CPU Synchronization Method. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014 - - ## Specifies user's desired settings for enabling/disabling processor features. - # @Prompt User settings for enabling/disabling processor features. - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000017 - - ## Specifies the On-demand clock modulation duty cycle when ACPI feature is enabled. - # @Prompt The encoded values for target duty cycle modulation. - # @ValidRange 0x80000001 | 0 - 15 - gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle|0x0|UINT8|0x0000001A - - ## Indicates if the current boot is a power-on reset.

- # TRUE - Current boot is a power-on reset.
- # FALSE - Current boot is not a power-on reset.
- # @Prompt Current boot is a power-on reset. - gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset|FALSE|BOOLEAN|0x0000001B - -[PcdsDynamic, PcdsDynamicEx] - ## Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA. - # @Prompt The pointer to a CPU S3 data buffer. - # @ValidList 0x80000001 | 0 - gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress|0x0|UINT64|0x60000010 - - ## Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported. - # @Prompt The pointer to CPU Hot Plug Data. - # @ValidList 0x80000001 | 0 - gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress|0x0|UINT64|0x60000011 - - ## Indicates processor feature capabilities, each bit corresponding to a specific feature. - # @Prompt Processor feature capabilities. - # @ValidList 0x80000001 | 0 - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000018 - - ## Specifies actual settings for processor features, each bit corresponding to a specific feature. - # @Prompt Actual processor feature settings. - # @ValidList 0x80000001 | 0 - gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000019 - -[UserExtensions.TianoCore."ExtraFiles"] - UefiCpuPkgExtra.uni diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc deleted file mode 100644 index 1336b0cfc0..0000000000 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ /dev/null @@ -1,158 +0,0 @@ -## @file -# UefiCpuPkg Package -# -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - PLATFORM_NAME = UefiCpu - PLATFORM_GUID = a1b7be22-78b3-4260-9569-8649e8c17d49 - PLATFORM_VERSION = 0.3 - DSC_SPECIFICATION = 0x00010005 - OUTPUT_DIRECTORY = Build/UefiCpu - SUPPORTED_ARCHITECTURES = IA32|IPF|X64 - BUILD_TARGETS = DEBUG|RELEASE|NOOPT - SKUID_IDENTIFIER = DEFAULT - -# -# External libraries to build package -# - -[LibraryClasses] - BaseLib|MdePkg/Library/BaseLib/BaseLib.inf - BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf - CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf - SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf - DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - UefiLib|MdePkg/Library/UefiLib/UefiLib.inf - UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf - UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf - UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf - TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf - DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf - LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf - ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf - SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf - PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf - SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf - MicrocodeFlashAccessLib|UefiCpuPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/MicrocodeFlashAccessLibNull.inf - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - -[LibraryClasses.common.SEC] - PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - -[LibraryClasses.common.PEIM] - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf - RegisterCpuFeaturesLib|UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf - -[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM] - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf - -[LibraryClasses.IPF.PEIM] - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointerLibKr7.inf - -[LibraryClasses.common.DXE_DRIVER] - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - RegisterCpuFeaturesLib|UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf - -[LibraryClasses.common.DXE_SMM_DRIVER] - SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf - MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf - -[LibraryClasses.common.UEFI_APPLICATION] - UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - -# -# Drivers/Libraries within this package -# - -[Components] - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf - UefiCpuPkg/CpuIoPei/CpuIoPei.inf - UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.inf - UefiCpuPkg/Application/Cpuid/Cpuid.inf - -[Components.IA32, Components.X64] - UefiCpuPkg/CpuDxe/CpuDxe.inf - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf { - - NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf - } - UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf { - - NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf - } - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf - UefiCpuPkg/CpuMpPei/CpuMpPei.inf - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf - UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf - UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf - UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf - UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf - UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf - UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf - UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf - UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf - UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - UefiCpuPkg/Library/MtrrLib/MtrrLib.inf - UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf - UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf - UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf - UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf - UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf - UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf - UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf - UefiCpuPkg/SecCore/SecCore.inf - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { - - FILE_GUID = D1D74FE9-7A4E-41D3-A0B3-67F13AD34D94 - - SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf - } - UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf - UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf - -[BuildOptions] - *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni deleted file mode 100644 index cd0ecab611..0000000000 --- a/UefiCpuPkg/UefiCpuPkg.uni +++ /dev/null @@ -1,196 +0,0 @@ -// /** @file -// This Package provides UEFI compatible CPU modules and libraries. -// -// This Package provides UEFI compatible CPU modules and libraries. -// -// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are licensed and made available under -// the terms and conditions of the BSD License which accompanies this distribution. -// The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PACKAGE_ABSTRACT #language en-US "Provides UEFI compatible CPU modules and libraries" - -#string STR_PACKAGE_DESCRIPTION #language en-US "This Package provides UEFI compatible CPU modules and libraries." - - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuLocalApicBaseAddress_PROMPT #language en-US "Configure base address of CPU Local APIC" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuLocalApicBaseAddress_HELP #language en-US "This value is the CPU Local APIC base address, which aligns the address on a 4-KByte boundary." - -#string STR_gUefiCpuPkgTokenSpaceGuid_ERR_80000001 #language en-US "Invalid value provided." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuInitIpiDelayInMicroSeconds_PROMPT #language en-US "Configure delay value after send an INIT IPI" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuInitIpiDelayInMicroSeconds_HELP #language en-US "Specifies delay value in microseconds after sending out an INIT IPI." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMaxLogicalProcessorNumber_PROMPT #language en-US "Configure max supported number of Logical Processors" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMaxLogicalProcessorNumber_HELP #language en-US "Specifies max supported number of Logical Processors." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStackSize_PROMPT #language en-US "Configure stack size for Application Processor (AP)" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApStackSize_HELP #language en-US "This value specifies the Application Processor (AP) stack size, used for Mp Service, which must\n" - "aligns the address on a 4-KByte boundary." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_PROMPT #language en-US "Timeout for the BSP to detect all APs for the first time." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_HELP #language en-US "Specifies timeout value in microseconds for the BSP to detect all APs for the first time." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_PROMPT #language en-US "Microcode Region base address." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_HELP #language en-US "Specifies the base address of the first microcode Patch in the microcode Region." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchRegionSize_PROMPT #language en-US "Microcode Region size." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchRegionSize_HELP #language en-US "Specifies the size of the microcode Region." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_PROMPT #language en-US "Enable SMM Profile" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_HELP #language en-US "Indicates if SMM Profile will be enabled. If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged. This PCD is only for validation purpose. It should be set to false in production.

\n" - "TRUE - SMM Profile will be enabled.
\n" - "FALSE - SMM Profile will be disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileRingBuffer_PROMPT #language en-US "The SMM profile log buffer is a ring buffer" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileRingBuffer_HELP #language en-US "Indicates if the SMM profile log buffer is a ring buffer. If disabled, no additional log can be done when the buffer is full.

\n" - "TRUE - the SMM profile log buffer is a ring buffer.
\n" - "FALSE - the SMM profile log buffer is a normal buffer.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmBlockStartupThisAp_PROMPT #language en-US "SMM Startup AP in a blocking fashion" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmBlockStartupThisAp_HELP #language en-US "Indicates if SMM Startup AP in a blocking fashion.\n" - "TRUE - SMM Startup AP in a blocking fashion.
\n" - "FALSE - SMM Startup AP in a non-blocking fashion.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackGuard_PROMPT #language en-US "Enable SMM Stack Guard" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackGuard_HELP #language en-US "Indicates if SMM Stack Guard will be enabled. If enabled, stack overflow in SMM can be caught, which eases debugging.

\n" - "TRUE - SMM Stack Guard will be enabled.
\n" - "FALSE - SMM Stack Guard will be disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmEnableBspElection_PROMPT #language en-US "Enable BSP election in SMM" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmEnableBspElection_HELP #language en-US "Indicates if BSP election in SMM will be enabled. If enabled, a BSP will be dynamically elected among all processors in each SMI. Otherwise, processor 0 is always as BSP in each SMI.

\n" - "TRUE - BSP election in SMM will be enabled.
\n" - "FALSE - BSP election in SMM will be disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugSupport_PROMPT #language en-US "SMM CPU hot-plug" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugSupport_HELP #language en-US "Enable CPU SMM hot-plug?

\n" - "TRUE - enabled.
\n" - "FALSE - disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmDebug_PROMPT #language en-US "Enable SMM Debug" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmDebug_HELP #language en-US "Indicates if SMM Debug will be enabled. If enabled, hardware breakpoints in SMRAM can be set outside of SMM mode and take effect in SMM.

\n" - "TRUE - SMM Debug will be enabled.
\n" - "FALSE - SMM Debug will be disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmFeatureControlMsrLock_PROMPT #language en-US "Lock SMM Feature Control MSR" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmFeatureControlMsrLock_HELP #language en-US "Lock SMM Feature Control MSR?

\n" - "TRUE - locked.
\n" - "FALSE - unlocked.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdPeiTemporaryRamStackSize_PROMPT #language en-US "Stack size in the temporary RAM" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdPeiTemporaryRamStackSize_HELP #language en-US "Specifies stack size in the temporary RAM. 0 means half of TemporaryRamSize." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileSize_PROMPT #language en-US "SMM profile data buffer size" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileSize_HELP #language en-US "Specifies buffer size in bytes to save SMM profile data. The value should be a multiple of 4KB." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_PROMPT #language en-US "Processor stack size in SMM" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStackSize_HELP #language en-US "Specifies stack size in bytes for each processor in SMM." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_PROMPT #language en-US "AP synchronization timeout value in SMM" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmApSyncTimeout_HELP #language en-US "Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmCodeAccessCheckEnable_PROMPT #language en-US "SMM Code Access Check" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmCodeAccessCheckEnable_HELP #language en-US "Enable SMM Code Access Check? If enabled, the SMM handler cannot execute the code outside SMM regions. This PCD is suggested to TRUE in production image.

\n" - "TRUE - SMM Code Access Check will be enabled.
\n" - "FALSE - SMM Code Access Check will be disabled.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmSyncMode_PROMPT #language en-US "SMM CPU Synchronization Method" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmSyncMode_HELP #language en-US "Indicates the CPU synchronization method used when processing an SMI.

\n" - "0x00 - Traditional CPU synchronization method.
\n" - "0x01 - Relaxed CPU synchronization method.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuS3DataAddress_PROMPT #language en-US "The pointer to a CPU S3 data buffer" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuS3DataAddress_HELP #language en-US "Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_PROMPT #language en-US "The pointer to CPU Hot Plug Data" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_HELP #language en-US "Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT #language en-US "Number of reserved variable MTRRs" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP #language en-US "Specifies the number of variable MTRRs reserved for OS use." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_PROMPT #language en-US "The AP wait loop state" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_HELP #language en-US "Specifies the AP wait loop state during POST phase." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApTargetCstate_PROMPT #language en-US "The specified AP target C-state for Mwait" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApTargetCstate_HELP #language en-US "Specifies the AP target C-state for Mwait during POST phase." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_PROMPT #language en-US "Use static page table for all memory in SMM." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_HELP #language en-US "Indicates if SMM uses static page table.\n" - "If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.

\n" - "This flag only impacts X64 build, because SMM alway builds static page table for IA32.\n" - "TRUE - SMM uses static page table for all memory.
\n" - "FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.
" - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStmExceptionStackSize_PROMPT #language en-US "STM exception stack size." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStmExceptionStackSize_HELP #language en-US "Specifies buffer size in bytes for STM exception stack. The value should be a multiple of 4KB." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMsegSize_PROMPT #language en-US "MSEG size." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMsegSize_HELP #language en-US "Specifies buffer size in bytes of MSEG. The value should be a multiple of 4KB." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSupport_PROMPT #language en-US "Supported CPU features." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSupport_HELP #language en-US "Specifies the supported CPU features bit in array." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitAfterSmmRelocation_PROMPT #language en-US "If CPU features will be initialized after SMM relocation." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitAfterSmmRelocation_HELP #language en-US "Specifies if CPU features will be initialized after SMM relocation." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitOnS3Resume_PROMPT #language en-US "If CPU features will be initialized during S3 resume." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesInitOnS3Resume_HELP #language en-US "Specifies if CPU features will be initialized during S3 resume." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesUserConfiguration_PROMPT #language en-US "User settings for enabling/disabling processor features." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesUserConfiguration_HELP #language en-US "Specifies user's desired settings for enabling/disabling processor features." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuClockModulationDutyCycle_PROMPT #language en-US "The encoded values for target duty cycle modulation." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuClockModulationDutyCycle_HELP #language en-US "Specifies the On-demand clock modulation duty cycle when ACPI feature is enabled." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdIsPowerOnReset_PROMPT #language en-US "Current boot is a power-on reset." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdIsPowerOnReset_HELP #language en-US "Indicates if the current boot is a power-on reset." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesCapability_PROMPT #language en-US "Processor feature capabilities." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesCapability_HELP #language en-US "Indicates processor feature capabilities, each bit corresponding to a specific feature." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSetting_PROMPT #language en-US "Actual processor feature settings." - -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuFeaturesSetting_HELP #language en-US "Specifies actual settings for processor features, each bit corresponding to a specific feature." diff --git a/UefiCpuPkg/UefiCpuPkgExtra.uni b/UefiCpuPkg/UefiCpuPkgExtra.uni deleted file mode 100644 index 858761af24..0000000000 --- a/UefiCpuPkg/UefiCpuPkgExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// UefiCpu Package Localized Strings and Content. -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are licensed and made available under -// the terms and conditions of the BSD License which accompanies this distribution. -// The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_PACKAGE_NAME -#language en-US -"UefiCpu package" - - diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S deleted file mode 100644 index ede19f21c3..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.S +++ /dev/null @@ -1,38 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2012, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* AsmFuncs.S -#* -#* Abstract: -#* -#* Assembly function to set segment selectors. -# -#------------------------------------------------------------------------------ - -.text - -#------------------------------------------------------------------------------ -# -# VOID -# EFIAPI -# AsmSetDataSelectors ( -# IN UINT16 SelectorValue -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmSetDataSelectors) -ASM_PFX(AsmSetDataSelectors): - movl 4(%esp), %eax - movw %ax, %ss - movw %ax, %ds - movw %ax, %es - movw %ax, %fs - movw %ax, %gs - ret diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm deleted file mode 100644 index 79496c48d7..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.asm +++ /dev/null @@ -1,45 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2012, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; AsmFuncs.Asm -; -; Abstract: -; -; Assembly function to set segment selectors. -; -; Notes: -; -;------------------------------------------------------------------------------ - -.686 -.model flat,C - -.code - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; AsmSetDataSelectors ( -; IN UINT16 SelectorValue -; ); -;------------------------------------------------------------------------------ -AsmSetDataSelectors PROC near public - mov eax, [esp + 4] - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - ret -AsmSetDataSelectors ENDP - -END diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm deleted file mode 100644 index fa5dda1466..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/Ia32/AsmFuncs.nasm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; AsmFuncs.Asm -; -; Abstract: -; -; Assembly function to set segment selectors. -; -; Notes: -; -;------------------------------------------------------------------------------ - -SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; AsmSetDataSelectors ( -; IN UINT16 SelectorValue -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(AsmSetDataSelectors) -ASM_PFX(AsmSetDataSelectors): - mov eax, [esp + 4] -o16 mov ds, ax -o16 mov es, ax -o16 mov fs, ax -o16 mov gs, ax -o16 mov ss, ax - ret - diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c deleted file mode 100644 index e53ed21bdc..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ /dev/null @@ -1,1176 +0,0 @@ -/** @file - This module produces the EFI_PEI_S3_RESUME2_PPI. - This module works with StandAloneBootScriptExecutor to S3 resume to OS. - This module will execute the boot script saved during last boot and after that, - control is passed to OS waking up handler. - - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
- Copyright (c) 2017, AMD Incorporated. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions - of the BSD License which accompanies this distribution. The - full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - This macro aligns the address of a variable with auto storage - duration down to CPU_STACK_ALIGNMENT. - - Since the stack grows downward, the result preserves more of the - stack than the original address (or the same amount), not less. -**/ -#define STACK_ALIGN_DOWN(Ptr) \ - ((UINTN)(Ptr) & ~(UINTN)(CPU_STACK_ALIGNMENT - 1)) - -#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull - -#pragma pack(1) -typedef union { - struct { - UINT32 LimitLow : 16; - UINT32 BaseLow : 16; - UINT32 BaseMid : 8; - UINT32 Type : 4; - UINT32 System : 1; - UINT32 Dpl : 2; - UINT32 Present : 1; - UINT32 LimitHigh : 4; - UINT32 Software : 1; - UINT32 Reserved : 1; - UINT32 DefaultSize : 1; - UINT32 Granularity : 1; - UINT32 BaseHigh : 8; - } Bits; - UINT64 Uint64; -} IA32_GDT; - -// -// Page-Map Level-4 Offset (PML4) and -// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB -// -typedef union { - struct { - UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User - UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Reserved:1; // Reserved - UINT64 MustBeZero:2; // Must Be Zero - UINT64 Available:3; // Available for use by system software - UINT64 PageTableBaseAddress:40; // Page Table Base Address - UINT64 AvabilableHigh:11; // Available for use by system software - UINT64 Nx:1; // No Execute bit - } Bits; - UINT64 Uint64; -} PAGE_MAP_AND_DIRECTORY_POINTER; - -// -// Page Table Entry 2MB -// -typedef union { - struct { - UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User - UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page - UINT64 MustBe1:1; // Must be 1 - UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write - UINT64 Available:3; // Available for use by system software - UINT64 PAT:1; // - UINT64 MustBeZero:8; // Must be zero; - UINT64 PageTableBaseAddress:31; // Page Table Base Address - UINT64 AvabilableHigh:11; // Available for use by system software - UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution - } Bits; - UINT64 Uint64; -} PAGE_TABLE_ENTRY; - -// -// Page Table Entry 1GB -// -typedef union { - struct { - UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory - UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write - UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User - UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching - UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached - UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) - UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page - UINT64 MustBe1:1; // Must be 1 - UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write - UINT64 Available:3; // Available for use by system software - UINT64 PAT:1; // - UINT64 MustBeZero:17; // Must be zero; - UINT64 PageTableBaseAddress:22; // Page Table Base Address - UINT64 AvabilableHigh:11; // Available for use by system software - UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution - } Bits; - UINT64 Uint64; -} PAGE_TABLE_1G_ENTRY; - -#pragma pack() - -// -// Function prototypes -// -/** - a ASM function to transfer control to OS. - - @param S3WakingVector The S3 waking up vector saved in ACPI Facs table - @param AcpiLowMemoryBase a buffer under 1M which could be used during the transfer -**/ -typedef -VOID -(EFIAPI *ASM_TRANSFER_CONTROL) ( - IN UINT32 S3WakingVector, - IN UINT32 AcpiLowMemoryBase - ); - -/** - Restores the platform to its preboot configuration for an S3 resume and - jumps to the OS waking vector. - - This function will restore the platform to its pre-boot configuration that was - pre-stored in the boot script table and transfer control to OS waking vector. - Upon invocation, this function is responsible for locating the following - information before jumping to OS waking vector: - - ACPI tables - - boot script table - - any other information that it needs - - The S3RestoreConfig() function then executes the pre-stored boot script table - and transitions the platform to the pre-boot state. The boot script is recorded - during regular boot using the EFI_S3_SAVE_STATE_PROTOCOL.Write() and - EFI_S3_SMM_SAVE_STATE_PROTOCOL.Write() functions. Finally, this function - transfers control to the OS waking vector. If the OS supports only a real-mode - waking vector, this function will switch from flat mode to real mode before - jumping to the waking vector. If all platform pre-boot configurations are - successfully restored and all other necessary information is ready, this - function will never return and instead will directly jump to the OS waking - vector. If this function returns, it indicates that the attempt to resume - from the ACPI S3 sleep state failed. - - @param[in] This Pointer to this instance of the PEI_S3_RESUME_PPI - - @retval EFI_ABORTED Execution of the S3 resume boot script table failed. - @retval EFI_NOT_FOUND Some necessary information that is used for the S3 - resume boot path could not be located. - -**/ -EFI_STATUS -EFIAPI -S3RestoreConfig2 ( - IN EFI_PEI_S3_RESUME2_PPI *This - ); - -/** - Set data segment selectors value including DS/ES/FS/GS/SS. - - @param[in] SelectorValue Segment selector value to be set. - -**/ -VOID -EFIAPI -AsmSetDataSelectors ( - IN UINT16 SelectorValue - ); - -// -// Globals -// -EFI_PEI_S3_RESUME2_PPI mS3ResumePpi = { S3RestoreConfig2 }; - -EFI_PEI_PPI_DESCRIPTOR mPpiList = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiS3Resume2PpiGuid, - &mS3ResumePpi -}; - -EFI_PEI_PPI_DESCRIPTOR mPpiListPostScriptTable = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gPeiPostScriptTablePpiGuid, - 0 -}; - -EFI_PEI_PPI_DESCRIPTOR mPpiListEndOfPeiTable = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiEndOfPeiSignalPpiGuid, - 0 -}; - -// -// Global Descriptor Table (GDT) -// -GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = { -/* selector { Global Segment Descriptor } */ -/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, -/* 0x08 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, -/* 0x10 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, -/* 0x18 */ {{0xFFFF, 0, 0, 0x3, 1, 0, 1, 0xF, 0, 0, 1, 1, 0}}, -/* 0x20 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, -/* 0x28 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 0, 0, 1, 0}}, -/* 0x30 */ {{0xFFFF, 0, 0, 0x3, 1, 0, 1, 0xF, 0, 0, 0, 1, 0}}, -/* 0x38 */ {{0xFFFF, 0, 0, 0xB, 1, 0, 1, 0xF, 0, 1, 0, 1, 0}}, -/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, -}; - -#define DATA_SEGEMENT_SELECTOR 0x18 - -// -// IA32 Gdt register -// -GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = { - sizeof (mGdtEntries) - 1, - (UINTN) mGdtEntries - }; - -/** - Performance measure function to get S3 detailed performance data. - - This function will getS3 detailed performance data and saved in pre-reserved ACPI memory. -**/ -VOID -WriteToOsS3PerformanceData ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase; - PERF_HEADER *PerfHeader; - PERF_DATA *PerfData; - UINT64 Ticker; - UINTN Index; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; - UINTN VarSize; - UINTN LogEntryKey; - CONST VOID *Handle; - CONST CHAR8 *Token; - CONST CHAR8 *Module; - UINT64 StartTicker; - UINT64 EndTicker; - UINT64 StartValue; - UINT64 EndValue; - BOOLEAN CountUp; - UINT64 Freq; - - // - // Retrieve time stamp count as early as possible - // - Ticker = GetPerformanceCounter (); - - Freq = GetPerformanceCounterProperties (&StartValue, &EndValue); - - Freq = DivU64x32 (Freq, 1000); - - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **) &VariableServices - ); - if (EFI_ERROR (Status)) { - return; - } - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = VariableServices->GetVariable ( - VariableServices, - L"PerfDataMemAddr", - &gPerformanceProtocolGuid, - NULL, - &VarSize, - &mAcpiLowMemoryBase - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Fail to retrieve variable to log S3 performance data \n")); - return; - } - - PerfHeader = (PERF_HEADER *) (UINTN) mAcpiLowMemoryBase; - - if (PerfHeader->Signiture != PERFORMANCE_SIGNATURE) { - DEBUG ((EFI_D_ERROR, "Performance data in ACPI memory get corrupted! \n")); - return; - } - - // - // Record total S3 resume time. - // - if (EndValue >= StartValue) { - PerfHeader->S3Resume = Ticker - StartValue; - CountUp = TRUE; - } else { - PerfHeader->S3Resume = StartValue - Ticker; - CountUp = FALSE; - } - - // - // Get S3 detailed performance data - // - Index = 0; - LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( - LogEntryKey, - &Handle, - &Token, - &Module, - &StartTicker, - &EndTicker)) != 0) { - if (EndTicker != 0) { - PerfData = &PerfHeader->S3Entry[Index]; - - // - // Use File Handle to specify the different performance log for PEIM. - // File Handle is the base address of PEIM FFS file. - // - if ((AsciiStrnCmp (Token, "PEIM", PEI_PERFORMANCE_STRING_SIZE) == 0) && (Handle != NULL)) { - AsciiSPrint (PerfData->Token, PERF_TOKEN_LENGTH, "0x%11p", Handle); - } else { - AsciiStrnCpyS (PerfData->Token, PERF_TOKEN_SIZE, Token, PERF_TOKEN_LENGTH); - } - if (StartTicker == 1) { - StartTicker = StartValue; - } - if (EndTicker == 1) { - EndTicker = StartValue; - } - Ticker = CountUp? (EndTicker - StartTicker) : (StartTicker - EndTicker); - PerfData->Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq); - - // - // Only Record > 1ms performance data so that more big performance can be recorded. - // - if ((Ticker > Freq) && (++Index >= PERF_PEI_ENTRY_MAX_NUM)) { - // - // Reach the maximum number of PEI performance log entries. - // - break; - } - } - } - PerfHeader->S3EntryNum = (UINT32) Index; -} - -/** - The function will check if current waking vector is long mode. - - @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT - - @retval TRUE Current context need long mode waking vector. - @retval FALSE Current context need not long mode waking vector. -**/ -BOOLEAN -IsLongModeWakingVector ( - IN ACPI_S3_CONTEXT *AcpiS3Context - ) -{ - EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; - - Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); - if ((Facs == NULL) || - (Facs->Signature != EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) || - ((Facs->FirmwareWakingVector == 0) && (Facs->XFirmwareWakingVector == 0)) ) { - // Something wrong with FACS - return FALSE; - } - if (Facs->XFirmwareWakingVector != 0) { - if ((Facs->Version == EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && - ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0) && - ((Facs->Flags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) != 0)) { - // Both BIOS and OS wants 64bit vector - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - return TRUE; - } - } - } - return FALSE; -} - -/** - Jump to OS waking vector. - The function will install boot script done PPI, report S3 resume status code, and then jump to OS waking vector. - - @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT - @param PeiS3ResumeState a pointer to a structure of PEI_S3_RESUME_STATE -**/ -VOID -EFIAPI -S3ResumeBootOs ( - IN ACPI_S3_CONTEXT *AcpiS3Context, - IN PEI_S3_RESUME_STATE *PeiS3ResumeState - ) -{ - EFI_STATUS Status; - EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; - ASM_TRANSFER_CONTROL AsmTransferControl; - UINTN TempStackTop; - UINTN TempStack[0x10]; - - // - // Restore IDT - // - AsmWriteIdtr (&PeiS3ResumeState->Idtr); - - if (PeiS3ResumeState->ReturnStatus != EFI_SUCCESS) { - // - // Report Status code that boot script execution is failed - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_BOOT_SCRIPT_ERROR) - ); - } - - // - // NOTE: Because Debug Timer interrupt and system interrupts will be disabled - // in BootScriptExecuteDxe, the rest code in S3ResumeBootOs() cannot be halted - // by soft debugger. - // - - PERF_END (NULL, "ScriptExec", NULL, 0); - - // - // Install BootScriptDonePpi - // - Status = PeiServicesInstallPpi (&mPpiListPostScriptTable); - ASSERT_EFI_ERROR (Status); - - // - // Get ACPI Table Address - // - Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); - - if ((Facs == NULL) || - (Facs->Signature != EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) || - ((Facs->FirmwareWakingVector == 0) && (Facs->XFirmwareWakingVector == 0)) ) { - // - // Report Status code that no valid vector is found - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) - ); - CpuDeadLoop (); - return ; - } - - // - // Install EndOfPeiPpi - // - Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable); - ASSERT_EFI_ERROR (Status); - - // - // report status code on S3 resume - // - REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); - - PERF_CODE ( - WriteToOsS3PerformanceData (); - ); - - AsmTransferControl = (ASM_TRANSFER_CONTROL)(UINTN)PeiS3ResumeState->AsmTransferControl; - if (Facs->XFirmwareWakingVector != 0) { - // - // Switch to native waking vector - // - TempStackTop = (UINTN)&TempStack + sizeof(TempStack); - DEBUG (( - DEBUG_INFO, - "%a() Stack Base: 0x%x, Stack Size: 0x%x\n", - __FUNCTION__, - TempStackTop, - sizeof (TempStack) - )); - if ((Facs->Version == EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && - ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0) && - ((Facs->Flags & EFI_ACPI_4_0_OSPM_64BIT_WAKE__F) != 0)) { - // - // X64 long mode waking vector - // - DEBUG ((DEBUG_INFO, "Transfer to 64bit OS waking vector - %x\r\n", (UINTN)Facs->XFirmwareWakingVector)); - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - AsmEnablePaging64 ( - 0x38, - Facs->XFirmwareWakingVector, - 0, - 0, - (UINT64)(UINTN)TempStackTop - ); - } else { - // - // Report Status code that no valid waking vector is found - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) - ); - DEBUG (( EFI_D_ERROR, "Unsupported for 32bit DXE transfer to 64bit OS waking vector!\r\n")); - ASSERT (FALSE); - CpuDeadLoop (); - return ; - } - } else { - // - // IA32 protected mode waking vector (Page disabled) - // - DEBUG ((DEBUG_INFO, "Transfer to 32bit OS waking vector - %x\r\n", (UINTN)Facs->XFirmwareWakingVector)); - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT) (UINTN) Facs->XFirmwareWakingVector, - NULL, - NULL, - (VOID *)(UINTN)TempStackTop - ); - } - } else { - // - // 16bit Realmode waking vector - // - DEBUG ((DEBUG_INFO, "Transfer to 16bit OS waking vector - %x\r\n", (UINTN)Facs->FirmwareWakingVector)); - AsmTransferControl (Facs->FirmwareWakingVector, 0x0); - } - - // - // Report Status code the failure of S3Resume - // - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR) - ); - - // - // Never run to here - // - CpuDeadLoop(); -} - -/** - Restore S3 page table because we do not trust ACPINvs content. - If BootScriptExector driver will not run in 64-bit mode, this function will do nothing. - - @param S3NvsPageTableAddress PageTableAddress in ACPINvs - @param Build4GPageTableOnly If BIOS just build 4G page table only -**/ -VOID -RestoreS3PageTables ( - IN UINTN S3NvsPageTableAddress, - IN BOOLEAN Build4GPageTableOnly - ) -{ - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - UINT32 RegEax; - UINT32 RegEdx; - UINT8 PhysicalAddressBits; - EFI_PHYSICAL_ADDRESS PageAddress; - UINTN IndexOfPml4Entries; - UINTN IndexOfPdpEntries; - UINTN IndexOfPageDirectoryEntries; - UINT32 NumberOfPml4EntriesNeeded; - UINT32 NumberOfPdpEntriesNeeded; - PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry; - PAGE_MAP_AND_DIRECTORY_POINTER *PageMap; - PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry; - PAGE_TABLE_ENTRY *PageDirectoryEntry; - VOID *Hob; - BOOLEAN Page1GSupport; - PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry; - UINT64 AddressEncMask; - - // - // Make sure AddressEncMask is contained to smallest supported address field - // - AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64; - - // - // NOTE: We have to ASSUME the page table generation format, because we do not know whole page table information. - // The whole page table is too large to be saved in SMRAM. - // - // The assumption is : whole page table is allocated in CONTINUOUS memory and CR3 points to TOP page. - // - DEBUG ((DEBUG_INFO, "S3NvsPageTableAddress - %x (%x)\n", (UINTN)S3NvsPageTableAddress, (UINTN)Build4GPageTableOnly)); - - // - // By architecture only one PageMapLevel4 exists - so lets allocate storage for it. - // - PageMap = (PAGE_MAP_AND_DIRECTORY_POINTER *)S3NvsPageTableAddress; - S3NvsPageTableAddress += SIZE_4KB; - - Page1GSupport = FALSE; - if (PcdGetBool(PcdUse1GPageTable)) { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000001) { - AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT26) != 0) { - Page1GSupport = TRUE; - } - } - } - - // - // Get physical address bits supported. - // - Hob = GetFirstHob (EFI_HOB_TYPE_CPU); - if (Hob != NULL) { - PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; - } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits = (UINT8) RegEax; - } else { - PhysicalAddressBits = 36; - } - } - - // - // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses. - // - ASSERT (PhysicalAddressBits <= 52); - if (PhysicalAddressBits > 48) { - PhysicalAddressBits = 48; - } - - // - // NOTE: In order to save time to create full page table, we just create 4G page table by default. - // And let PF handler in BootScript driver to create more on request. - // - if (Build4GPageTableOnly) { - PhysicalAddressBits = 32; - ZeroMem (PageMap, EFI_PAGES_TO_SIZE(2)); - } - // - // Calculate the table entries needed. - // - if (PhysicalAddressBits <= 39) { - NumberOfPml4EntriesNeeded = 1; - NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30)); - } else { - NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39)); - NumberOfPdpEntriesNeeded = 512; - } - - PageMapLevel4Entry = PageMap; - PageAddress = 0; - for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) { - // - // Each PML4 entry points to a page of Page Directory Pointer entires. - // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop. - // - PageDirectoryPointerEntry = (PAGE_MAP_AND_DIRECTORY_POINTER *)S3NvsPageTableAddress; - S3NvsPageTableAddress += SIZE_4KB; - - // - // Make a PML4 Entry - // - PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry | AddressEncMask; - PageMapLevel4Entry->Bits.ReadWrite = 1; - PageMapLevel4Entry->Bits.Present = 1; - - if (Page1GSupport) { - PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry; - - for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) { - // - // Fill in the Page Directory entries - // - PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; - PageDirectory1GEntry->Bits.ReadWrite = 1; - PageDirectory1GEntry->Bits.Present = 1; - PageDirectory1GEntry->Bits.MustBe1 = 1; - } - } else { - for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) { - // - // Each Directory Pointer entries points to a page of Page Directory entires. - // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop. - // - PageDirectoryEntry = (PAGE_TABLE_ENTRY *)S3NvsPageTableAddress; - S3NvsPageTableAddress += SIZE_4KB; - - // - // Fill in a Page Directory Pointer Entries - // - PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask; - PageDirectoryPointerEntry->Bits.ReadWrite = 1; - PageDirectoryPointerEntry->Bits.Present = 1; - - for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) { - // - // Fill in the Page Directory entries - // - PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask; - PageDirectoryEntry->Bits.ReadWrite = 1; - PageDirectoryEntry->Bits.Present = 1; - PageDirectoryEntry->Bits.MustBe1 = 1; - } - } - } - } - return ; - } else { - // - // If DXE is running 32-bit mode, no need to establish page table. - // - return ; - } -} - -/** - Jump to boot script executor driver. - - The function will close and lock SMRAM and then jump to boot script execute driver to executing S3 boot script table. - - @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT - @param EfiBootScriptExecutorVariable The function entry to executing S3 boot Script table. This function is build in - boot script execute driver -**/ -VOID -EFIAPI -S3ResumeExecuteBootScript ( - IN ACPI_S3_CONTEXT *AcpiS3Context, - IN BOOT_SCRIPT_EXECUTOR_VARIABLE *EfiBootScriptExecutorVariable - ) -{ - EFI_STATUS Status; - PEI_SMM_ACCESS_PPI *SmmAccess; - UINTN Index; - VOID *GuidHob; - IA32_DESCRIPTOR *IdtDescriptor; - VOID *IdtBuffer; - PEI_S3_RESUME_STATE *PeiS3ResumeState; - BOOLEAN InterruptStatus; - - DEBUG ((DEBUG_INFO, "S3ResumeExecuteBootScript()\n")); - - // - // Attempt to use content from SMRAM first - // - GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); - if (GuidHob != NULL) { - // - // Last step for SMM - send SMI for initialization - // - - // - // Send SMI to APs - // - SendSmiIpiAllExcludingSelf (); - // - // Send SMI to BSP - // - SendSmiIpi (GetApicId ()); - - Status = PeiServicesLocatePpi ( - &gPeiSmmAccessPpiGuid, - 0, - NULL, - (VOID **) &SmmAccess - ); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "Close all SMRAM regions before executing boot script\n")); - - for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) { - Status = SmmAccess->Close ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); - } - - DEBUG ((DEBUG_INFO, "Lock all SMRAM regions before executing boot script\n")); - - for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) { - Status = SmmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); - } - } - } - - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - AsmWriteCr3 ((UINTN)AcpiS3Context->S3NvsPageTableAddress); - } - - if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) { - // - // On some platform, such as ECP, a dispatch node in boot script table may execute a 32-bit PEIM which may need PeiServices - // pointer. So PeiServices need preserve in (IDTBase- sizeof (UINTN)). - // - IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile); - // - // Make sure the newly allocated IDT align with 16-bytes - // - IdtBuffer = AllocatePages (EFI_SIZE_TO_PAGES((IdtDescriptor->Limit + 1) + 16)); - if (IdtBuffer == NULL) { - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_RESUME_FAILED) - ); - ASSERT (FALSE); - } - // - // Additional 16 bytes allocated to save IA32 IDT descriptor and Pei Service Table Pointer - // IA32 IDT descriptor will be used to setup IA32 IDT table for 32-bit Framework Boot Script code - // - ZeroMem (IdtBuffer, 16); - AsmReadIdtr ((IA32_DESCRIPTOR *)IdtBuffer); - CopyMem ((VOID*)((UINT8*)IdtBuffer + 16),(VOID*)(IdtDescriptor->Base), (IdtDescriptor->Limit + 1)); - IdtDescriptor->Base = (UINTN)((UINT8*)IdtBuffer + 16); - *(UINTN*)(IdtDescriptor->Base - sizeof(UINTN)) = (UINTN)GetPeiServicesTablePointer (); - } - - InterruptStatus = SaveAndDisableInterrupts (); - // - // Need to make sure the GDT is loaded with values that support long mode and real mode. - // - AsmWriteGdtr (&mGdt); - // - // update segment selectors per the new GDT. - // - AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR); - // - // Restore interrupt state. - // - SetInterruptState (InterruptStatus); - - // - // Prepare data for return back - // - PeiS3ResumeState = AllocatePool (sizeof(*PeiS3ResumeState)); - if (PeiS3ResumeState == NULL) { - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_RESUME_FAILED) - ); - ASSERT (FALSE); - } - DEBUG ((DEBUG_INFO, "PeiS3ResumeState - %x\r\n", PeiS3ResumeState)); - PeiS3ResumeState->ReturnCs = 0x10; - PeiS3ResumeState->ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)S3ResumeBootOs; - PeiS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status); - // - // Save IDT - // - AsmReadIdtr (&PeiS3ResumeState->Idtr); - - // - // Report Status Code to indicate S3 boot script execution - // - REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_S3_BOOT_SCRIPT); - - PERF_START (NULL, "ScriptExec", NULL, 0); - - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - // - // X64 S3 Resume - // - DEBUG ((DEBUG_INFO, "Enable X64 and transfer control to Standalone Boot Script Executor\r\n")); - - // - // Switch to long mode to complete resume. - // - AsmEnablePaging64 ( - 0x38, - EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint, - (UINT64)(UINTN)AcpiS3Context, - (UINT64)(UINTN)PeiS3ResumeState, - (UINT64)(UINTN)(AcpiS3Context->BootScriptStackBase + AcpiS3Context->BootScriptStackSize) - ); - } else { - // - // IA32 S3 Resume - // - DEBUG ((DEBUG_INFO, "transfer control to Standalone Boot Script Executor\r\n")); - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT) (UINTN) EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint, - (VOID *)AcpiS3Context, - (VOID *)PeiS3ResumeState, - (VOID *)(UINTN)(AcpiS3Context->BootScriptStackBase + AcpiS3Context->BootScriptStackSize) - ); - } - - // - // Never run to here - // - CpuDeadLoop(); -} -/** - Restores the platform to its preboot configuration for an S3 resume and - jumps to the OS waking vector. - - This function will restore the platform to its pre-boot configuration that was - pre-stored in the boot script table and transfer control to OS waking vector. - Upon invocation, this function is responsible for locating the following - information before jumping to OS waking vector: - - ACPI tables - - boot script table - - any other information that it needs - - The S3RestoreConfig() function then executes the pre-stored boot script table - and transitions the platform to the pre-boot state. The boot script is recorded - during regular boot using the EFI_S3_SAVE_STATE_PROTOCOL.Write() and - EFI_S3_SMM_SAVE_STATE_PROTOCOL.Write() functions. Finally, this function - transfers control to the OS waking vector. If the OS supports only a real-mode - waking vector, this function will switch from flat mode to real mode before - jumping to the waking vector. If all platform pre-boot configurations are - successfully restored and all other necessary information is ready, this - function will never return and instead will directly jump to the OS waking - vector. If this function returns, it indicates that the attempt to resume - from the ACPI S3 sleep state failed. - - @param[in] This Pointer to this instance of the PEI_S3_RESUME_PPI - - @retval EFI_ABORTED Execution of the S3 resume boot script table failed. - @retval EFI_NOT_FOUND Some necessary information that is used for the S3 - resume boot path could not be located. - -**/ -EFI_STATUS -EFIAPI -S3RestoreConfig2 ( - IN EFI_PEI_S3_RESUME2_PPI *This - ) -{ - EFI_STATUS Status; - PEI_SMM_ACCESS_PPI *SmmAccess; - UINTN Index; - ACPI_S3_CONTEXT *AcpiS3Context; - EFI_PHYSICAL_ADDRESS TempEfiBootScriptExecutorVariable; - EFI_PHYSICAL_ADDRESS TempAcpiS3Context; - BOOT_SCRIPT_EXECUTOR_VARIABLE *EfiBootScriptExecutorVariable; - UINTN VarSize; - EFI_SMRAM_DESCRIPTOR *SmramDescriptor; - SMM_S3_RESUME_STATE *SmmS3ResumeState; - VOID *GuidHob; - BOOLEAN Build4GPageTableOnly; - BOOLEAN InterruptStatus; - - TempAcpiS3Context = 0; - TempEfiBootScriptExecutorVariable = 0; - - DEBUG ((DEBUG_INFO, "Enter S3 PEIM\r\n")); - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = RestoreLockBox ( - &gEfiAcpiVariableGuid, - &TempAcpiS3Context, - &VarSize - ); - ASSERT_EFI_ERROR (Status); - - Status = RestoreLockBox ( - &gEfiAcpiS3ContextGuid, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); - - AcpiS3Context = (ACPI_S3_CONTEXT *)(UINTN)TempAcpiS3Context; - ASSERT (AcpiS3Context != NULL); - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = RestoreLockBox ( - &gEfiBootScriptExecutorVariableGuid, - &TempEfiBootScriptExecutorVariable, - &VarSize - ); - ASSERT_EFI_ERROR (Status); - - Status = RestoreLockBox ( - &gEfiBootScriptExecutorContextGuid, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); - - EfiBootScriptExecutorVariable = (BOOT_SCRIPT_EXECUTOR_VARIABLE *) (UINTN) TempEfiBootScriptExecutorVariable; - ASSERT (EfiBootScriptExecutorVariable != NULL); - - DEBUG (( DEBUG_INFO, "AcpiS3Context = %x\n", AcpiS3Context)); - DEBUG (( DEBUG_INFO, "Waking Vector = %x\n", ((EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)))->FirmwareWakingVector)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->AcpiFacsTable = %x\n", AcpiS3Context->AcpiFacsTable)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->IdtrProfile = %x\n", AcpiS3Context->IdtrProfile)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->S3NvsPageTableAddress = %x\n", AcpiS3Context->S3NvsPageTableAddress)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->S3DebugBufferAddress = %x\n", AcpiS3Context->S3DebugBufferAddress)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->BootScriptStackBase = %x\n", AcpiS3Context->BootScriptStackBase)); - DEBUG (( DEBUG_INFO, "AcpiS3Context->BootScriptStackSize = %x\n", AcpiS3Context->BootScriptStackSize)); - DEBUG (( DEBUG_INFO, "EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint = %x\n", EfiBootScriptExecutorVariable->BootScriptExecutorEntrypoint)); - - // - // Additional step for BootScript integrity - we only handle BootScript and BootScriptExecutor. - // Script dispatch image and context (parameter) are handled by platform. - // We just use restore all lock box in place, no need restore one by one. - // - Status = RestoreAllLockBoxInPlace (); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - // Something wrong - CpuDeadLoop (); - } - - if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - // - // Need reconstruct page table here, since we do not trust ACPINvs. - // - if (IsLongModeWakingVector (AcpiS3Context)) { - Build4GPageTableOnly = FALSE; - } else { - Build4GPageTableOnly = TRUE; - } - RestoreS3PageTables ((UINTN)AcpiS3Context->S3NvsPageTableAddress, Build4GPageTableOnly); - } - - // - // Attempt to use content from SMRAM first - // - GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid); - if (GuidHob != NULL) { - Status = PeiServicesLocatePpi ( - &gPeiSmmAccessPpiGuid, - 0, - NULL, - (VOID **) &SmmAccess - ); - for (Index = 0; !EFI_ERROR (Status); Index++) { - Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); - } - - SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob); - SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; - - SmmS3ResumeState->ReturnCs = AsmReadCs (); - SmmS3ResumeState->ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)S3ResumeExecuteBootScript; - SmmS3ResumeState->ReturnContext1 = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context; - SmmS3ResumeState->ReturnContext2 = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable; - SmmS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status); - - DEBUG (( DEBUG_INFO, "SMM S3 Signature = %x\n", SmmS3ResumeState->Signature)); - DEBUG (( DEBUG_INFO, "SMM S3 Stack Base = %x\n", SmmS3ResumeState->SmmS3StackBase)); - DEBUG (( DEBUG_INFO, "SMM S3 Stack Size = %x\n", SmmS3ResumeState->SmmS3StackSize)); - DEBUG (( DEBUG_INFO, "SMM S3 Resume Entry Point = %x\n", SmmS3ResumeState->SmmS3ResumeEntryPoint)); - DEBUG (( DEBUG_INFO, "SMM S3 CR0 = %x\n", SmmS3ResumeState->SmmS3Cr0)); - DEBUG (( DEBUG_INFO, "SMM S3 CR3 = %x\n", SmmS3ResumeState->SmmS3Cr3)); - DEBUG (( DEBUG_INFO, "SMM S3 CR4 = %x\n", SmmS3ResumeState->SmmS3Cr4)); - DEBUG (( DEBUG_INFO, "SMM S3 Return CS = %x\n", SmmS3ResumeState->ReturnCs)); - DEBUG (( DEBUG_INFO, "SMM S3 Return Entry Point = %x\n", SmmS3ResumeState->ReturnEntryPoint)); - DEBUG (( DEBUG_INFO, "SMM S3 Return Context1 = %x\n", SmmS3ResumeState->ReturnContext1)); - DEBUG (( DEBUG_INFO, "SMM S3 Return Context2 = %x\n", SmmS3ResumeState->ReturnContext2)); - DEBUG (( DEBUG_INFO, "SMM S3 Return Stack Pointer = %x\n", SmmS3ResumeState->ReturnStackPointer)); - DEBUG (( DEBUG_INFO, "SMM S3 Smst = %x\n", SmmS3ResumeState->Smst)); - - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) { - SwitchStack ( - (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint, - (VOID *)AcpiS3Context, - 0, - (VOID *)(UINTN)(SmmS3ResumeState->SmmS3StackBase + SmmS3ResumeState->SmmS3StackSize) - ); - } - if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) { - // - // Switch to long mode to complete resume. - // - - InterruptStatus = SaveAndDisableInterrupts (); - // - // Need to make sure the GDT is loaded with values that support long mode and real mode. - // - AsmWriteGdtr (&mGdt); - // - // update segment selectors per the new GDT. - // - AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR); - // - // Restore interrupt state. - // - SetInterruptState (InterruptStatus); - - AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3); - - // - // Disable interrupt of Debug timer, since IDT table cannot work in long mode. - // NOTE: On x64 platforms, because DisablePaging64() will disable interrupts, - // the code in S3ResumeExecuteBootScript() cannot be halted by soft debugger. - // - SaveAndSetDebugTimerInterrupt (FALSE); - - AsmEnablePaging64 ( - 0x38, - SmmS3ResumeState->SmmS3ResumeEntryPoint, - (UINT64)(UINTN)AcpiS3Context, - 0, - SmmS3ResumeState->SmmS3StackBase + SmmS3ResumeState->SmmS3StackSize - ); - } - - } - - S3ResumeExecuteBootScript (AcpiS3Context, EfiBootScriptExecutorVariable ); - return EFI_SUCCESS; -} -/** - Main entry for S3 Resume PEIM. - - This routine is to install EFI_PEI_S3_RESUME2_PPI. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Pointer to PEI Services table. - - @retval EFI_SUCCESS S3Resume Ppi is installed successfully. - -**/ -EFI_STATUS -EFIAPI -PeimS3ResumeEntryPoint ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - - // - // Install S3 Resume Ppi - // - Status = (**PeiServices).InstallPpi (PeiServices, &mPpiList); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} - diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf deleted file mode 100644 index d514523089..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf +++ /dev/null @@ -1,101 +0,0 @@ -## @file -# S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI. -# -# This module works with StandAloneBootScriptExecutor to S3 resume to OS. -# This module will excute the boot script saved during last boot and after that, -# control is passed to OS waking up handler. -# -# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# -# This program and the accompanying materials are -# licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = S3Resume2Pei - MODULE_UNI_FILE = S3Resume2Pei.uni - FILE_GUID = 89E549B0-7CFE-449d-9BA3-10D8B2312D71 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = PeimS3ResumeEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - S3Resume.c - -[Sources.IA32] - Ia32/AsmFuncs.asm - Ia32/AsmFuncs.nasm - Ia32/AsmFuncs.S - -[Sources.X64] - X64/AsmFuncs.asm - X64/AsmFuncs.nasm - X64/AsmFuncs.S - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - PeiServicesTablePointerLib - PerformanceLib - HobLib - PeiServicesLib - PeimEntryPoint - TimerLib - BaseLib - DebugLib - PcdLib - IoLib - BaseMemoryLib - MemoryAllocationLib - DebugAgentLib - LocalApicLib - ReportStatusCodeLib - LockBoxLib - PrintLib - -[Guids] - gEfiBootScriptExecutorVariableGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox - gEfiBootScriptExecutorContextGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox - gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## Variable:L"PerfDataMemAddr" - ## SOMETIMES_CONSUMES ## HOB - ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox - gEfiAcpiVariableGuid - gEfiAcpiS3ContextGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox - -[Ppis] - gEfiPeiReadOnlyVariable2PpiGuid ## CONSUMES - gEfiPeiS3Resume2PpiGuid ## PRODUCES - gPeiSmmAccessPpiGuid ## SOMETIMES_CONSUMES - gPeiPostScriptTablePpiGuid ## SOMETIMES_PRODUCES - gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES - -[FeaturePcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES - -[Depex] - TRUE - -[UserExtensions.TianoCore."ExtraFiles"] - S3Resume2PeiExtra.uni diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni deleted file mode 100644 index 0f78a15173..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.uni +++ /dev/null @@ -1,26 +0,0 @@ -// /** @file -// S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI. -// -// This module works with StandAloneBootScriptExecutor to S3 resume to OS. -// This module will excute the boot script saved during last boot and after that, -// control is passed to OS waking up handler. -// -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "S3 Resume Module installs EFI_PEI_S3_RESUME2_PPI" - -#string STR_MODULE_DESCRIPTION #language en-US "This module works with StandAloneBootScriptExecutor to S3 resume to OS.\n" - "This module will execute the boot script saved during last boot and after that,\n" - "control is passed to the OS waking up handler." - diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni deleted file mode 100644 index 4d88423149..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2PeiExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// S3Resume2Pei Localized Strings and Content -// -// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"S3 Resume v2 PEI Module" - - diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S deleted file mode 100644 index 2ced09f35c..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.S +++ /dev/null @@ -1,37 +0,0 @@ -#------------------------------------------------------------------------------ -#* -#* Copyright (c) 2012, Intel Corporation. All rights reserved.
-#* This program and the accompanying materials -#* are licensed and made available under the terms and conditions of the BSD License -#* which accompanies this distribution. The full text of the license may be found at -#* http://opensource.org/licenses/bsd-license.php -#* -#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -#* -#* AsmFuncs.S -#* -#* Abstract: -#* -#* Assembly function to set segment selectors. -# -#------------------------------------------------------------------------------ - -.text - -#------------------------------------------------------------------------------ -# -# VOID -# EFIAPI -# AsmSetDataSelectors ( -# IN UINT16 SelectorValue -# ); -#------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmSetDataSelectors) -ASM_PFX(AsmSetDataSelectors): - movw %cx, %ss - movw %cx, %ds - movw %cx, %es - movw %cx, %fs - movw %cx, %gs - ret diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm deleted file mode 100644 index eb014a5862..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.asm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2012, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; AsmFuncs.Asm -; -; Abstract: -; -; Assembly function to set segment selectors. -; -; Notes: -; -;------------------------------------------------------------------------------ - -.code - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; AsmSetDataSelectors ( -; IN UINT16 SelectorValue -; ); -;------------------------------------------------------------------------------ -AsmSetDataSelectors PROC - mov ds, cx - mov es, cx - mov fs, cx - mov gs, cx - mov ss, cx - ret -AsmSetDataSelectors ENDP - -END diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm deleted file mode 100644 index add73cacc0..0000000000 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/X64/AsmFuncs.nasm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; AsmFuncs.Asm -; -; Abstract: -; -; Assembly function to set segment selectors. -; -; Notes: -; -;------------------------------------------------------------------------------ - -DEFAULT REL -SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; AsmSetDataSelectors ( -; IN UINT16 SelectorValue -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(AsmSetDataSelectors) -ASM_PFX(AsmSetDataSelectors): -o16 mov ds, cx -o16 mov es, cx -o16 mov fs, cx -o16 mov gs, cx -o16 mov ss, cx - ret - -- cgit v1.2.3