summaryrefslogtreecommitdiff
path: root/UefiCpuPkg
AgeCommit message (Collapse)Author
2016-08-25UefiCpuPkg/MpInitLib: Don't allocate reset vector in Exit Boot ServiceJeff Fan
In Exit Boot Services callback function, we cannot use allocate memory services because it may change the memory map that has been gotten by OS. This fix is not to allocate reset vector buffer after SaveRestoreFlag is set to TRUE in MpInitExitBootServicesCallback(). Instead AllocateResetVector() will use the previous allocated buffer address and save the contents before copying reset vector code. At the same time, FreeResetVector() will restore original contents after if SaveRestoreFlag is TRUE. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-25UefiCpuPkg/MpInitLib: Move two functions locationJeff Fan
Just move BackupAndPrepareWakeupBuffer() and RestoreWakeupBuffer() from PeiMpLib.c to MpLib.c. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-25UefiCpuPkg/MpInitLib: Fix function header comments typoJeff Fan
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-25UefiCpuPkg/MpInitLib: Rename EndOfPeiFlag to SaveRestoreFlagJeff Fan
It will be used by DxePeiLib also. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-25UefiCpuPkg/MpInitLib: Move allocating reserved memory for AP loop codeJeff Fan
In Exit Boot Services callback function, we cannot use allocate memory services because it may change the memory map that has been gotten by OS. This fix is to move allocating reserved memory for AP loop code to InitMpGlobalData() and save the memory address in one global variable. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-25UefiCpuPkg/MpInitLib: Move timeout delay to WakupAp()Jeff Fan
After sending the 1st broadcast INIT-SIPI-SIPI, BSP will collect APs count after one specified timeout delay. However, WakupAp() will restore reset vector immediately after sending 1st broadcast INIT-SIPI-SIPI. Some processors may not complete executing reset vector code. This fix is to move MicroSecondDelay() from CollectProcessorCount() to the place that is after sending 1st broadcast INIT-SIPI-SIPI and before FreeResetVector() in WakupAp(). Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-19UefiCpuPkg/PiSmmCpuDxeSmm: Revert 7503cd70fb86Jeff Fan
Revert "UefiCpuPkg/PiSmmCpuDxeSmm: Add gEfiVariableArchProtocolGuid dependency" This reverts commit 7503cd70fb864a5663edb121c9b2488b4c69e7f5. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com>
2016-08-19UefiCpuPkg/MpInitLib: MicrocodeData used but maybe uninitializedJeff Fan
Cc: Feng Tian <feng.tian@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
2016-08-17UefiCpuPkg/PiSmmCpuDxeSmm: Add gEfiVariableArchProtocolGuid dependencyJeff Fan
PiSmmCpuDxeSmm driver's entry point will get some PCDs supported dynamic type. In case those PCDs are set as DynamicHii type in platform DSC File, it implies that EFI Variable Arch protocol is required. This fix is to add gEfiVariableArchProtocolGuid dependency on PiSmmCpuDxeSmm driver to make sure those DynamicHii PCDs could be read correctly. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuDxe: Fixed typo in function header to match PI specJeff Fan
Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuDxe: Remove PcdCpuMaxLogicalProcessorNumber consumingJeff Fan
v5: If PcdCpuMaxLogicalProcessorNumber is set to 1 on UP system, MpInitLibInitialize() will be invoked. This is one bug, we need to call MpInitLibInitialize() always and get the BSP information. Just to remove PcdCpuMaxLogicalProcessorNumber() consuming from this driver. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuDxe: Remove unused codes and filesJeff Fan
v5: 1. Remove unused PcdCpuApStackSize and PcdCpuApInitTimeOutInMicroSeconds. v4: 1. Keep GDT table setup to fix IA32 S3 boot issue. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuDxe: Move SetMtrrsFromBuffer() location.Jeff Fan
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuDxe: Consume MpInitLib to produce CPU MP Protocol servicesJeff Fan
Consume MP Initialize library to produce CPU MP Protocol services to simply the code. v4: 1. Update CpuDxe.c file header to mention it produces CPU Arch protocol. 2. Update BistData type from UINT32 to EFI_HEALTH_FLAG. 3. Move some header location from CpuMp.h to CpuDxe.h. v3: 1. Move the code Consume MpInitLib APIs to produce CPU MP Protocol from patch #40 to this patch. 2. Add DxeMpInitLib.inf in DSC file Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuMpPei: Delete PeiMpServices.c and PeiMpServices.hJeff Fan
Move the code in PeiMpServices.c & PeiMpServices.h to CpuMpPei.c & CpuMpPei.h. v3: 1. Rename MpInitLibSwitchBSP to MpInitLibSwitchBSP 2. Add PeiMpInitLib.inf in DSC file Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuMpPei: Remove unused files and codesJeff Fan
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuMpPei: Consume MpInitLib to produce CPU MP PPI servicesJeff Fan
Consume MP initialize library to produce CPU MP PPI, it could simply the code. Add STATIC for some internal functions to avoid build issue with the same functions name in PeiMpInit instance. They will be removed by the next patch. v4: 1. Update BistData type from UINT32 to EFI_HEALTH_FLAGS. v3: 1. Rename MpInitLibSwitchBSP to MpInitLibSwitchBSP 2. Add PeiMpInitLib.inf in DSC file Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Place APs in safe loop before hand-off to OSJeff Fan
Register Exit Boot Service callback function MpInitExitBootServicesCallback() to place AP one safe loop before hand-off to OS. Allocated one reserved memory and copy the AsmRellocateApLoop() code into it. It could avoid the CPU Dxe driver (located in Boot Service data range) crashed after Exit Boot Service event. Place AP into the target Cx-State (specified by PcdCpuApTargetCstate) could save power if Monitor-mwait feature supported. In long mode, switch AP into protected mode could let AP not require page table when executing this safe loop. Page Table (located in Boot Service data range) may crashed after Exit Boot Service event. v3: 1. Rename *RellocateAp* to *RelocateAp* Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibStartupAllAPs()Jeff Fan
v4: 1. Simply the internal function StartupAllAPsWorker()'s function header due to it is duplicated with MpInitLibStartupAllAPs(). v3: 1. Use CamelCase for mStopCheckAllApsStatus and CheckAndUpdateApsStatus() Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibStartupThisAP()Jeff Fan
v4: 1. Simply the internal function StartupThisAPWorker()'s comment header due to it is duplicated with MpInitLibStartupThisAP(). v3: 1. Use CamelCase for mStopCheckAllApsStatus and CheckAndUpdateApsStatus(). Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Check APs Status and update APs statusJeff Fan
v3: 1. Use CamelCase for CheckAndUpdateApsStatus(). Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibEnableDisableAP()Jeff Fan
v4: 1. Simply the internal function MpInitLibEnableDisableAP()'s function header due to it is duplicated with MpInitLibEnableDisableAP(). v3: 1. Use CamelCase for mCheckAllAPsEvent, mStopCheckAllApsStatus. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibSwitchBSP()Jeff Fan
v4: 1. Simply the internal function SwitchBSPWorker()'s comment header due to it is duplicated with MpInitLibSwitchBSP(). v3: 1. Rename MpInitLibSwitchBsp to MpInitLibSwitchBSP. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibWhoAmI()Jeff Fan
v5: 1. Move checking ProcessNumber before calling GetCpuMpData. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibGetProcessorInfo()Jeff Fan
v5: 1. Remove (-1) and use the clean code to calculate the Location->Thread and Location->Core. v4: 1. Update HealthData type from UINT32 to EFI_HEALTH_FLAGS Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Implementation of MpInitLibGetNumberOfProcessors()Jeff Fan
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Skip collect processor count if GUIDed HOB existJeff Fan
If GUIDed HOB mCpuInitMpLibHobGuid exists, we could get the processor count and processor APICID and Initial APICID from CPU_INFO_IN_HOB. We needn't to delay for broadcast INIT-SIPI-SIPI results and could improve performance. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Sort processor by ascending order of APIC IDJeff Fan
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Enable x2APIC mode on BSP/APsJeff Fan
If x2APIC flag is set, enable x2APIC mode on all APs and BSP. Before we wakeup APs to enable x2APIC mode, we should wait all APs have finished initialization. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Send INIT-SIPI-SIPI to get processor countJeff Fan
CollectProcessorCount() will send the 1st INIT-SIPI-SIPI to get processor count in system. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add WakeUpAP()Jeff Fan
WakeUpAP() is used to wakeup APs per current ApLoopMode and make sure APs wake up successfully. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Fill MP_CPU_EXCHANGE_INFO fieldsJeff Fan
FillExchangeInfoData() is used to fill MP_CPU_EXCHANGE_INFO date exchanged between C code and assembly code of AP reset vector. v5: 1. Reference ApWakeupFunction instead of ApCFunction. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add ApWakeupFunction() executed by assembly codeJeff Fan
ApWakeupFunction() is the first C function executed from AP reset vector. When APs waken up at the first time, it will sync BSP's MTRR setting and load microcode on APs and collect APs' BIST information. When AP tasked finished, it will place APs it one loop specified by ApLoopMode. v5: 1. Rename ApCFunction to ApWakeupFunction to meet naming convention. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Allocate AP reset vector buffer under 1MBJeff Fan
In PeiMpInitLib, searching unallocated memory under in EFI_HOB_TYPE_RESOURCE_DESCRIPTOR hobs to find the memory under 1MB for AP reset vector. After End of PEI event triggered, we need to restore original the buffer contents to avoid crash the OS on S3 boot. In DxeMpInitLib, allocate the memory under 1MB for AP reset vector. Add helper functions AllocateResetVector()/FreeResetVector() used by WakeupAp(). v3: 1. Move SetTimer() from Patch #17 to Patch 16. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Register one period event to check APs statusJeff Fan
In DxeMpInitLib, register one period event callback function CheckAPsStatus() used to check AP Status. v5: 1. Introduce AP_CHECK_INTERVAL for adjust AP check timer interval potential. v3: 1. Use CamelCase for mCheckAllAPsEvent, mStopCheckAllApsStatus and CheckAndUpdateApsStatus(). 2. Move SetTimer() from Patch #17 to Patch 16. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Register one End of PEI callback functionJeff Fan
In PeiMpInitLib, register End of PEI callback function CpuMpEndOfPeiCallback(). v5: 1. Add comment block for mMpInitLibNotifyList. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Save CPU MP Data pointerJeff Fan
In PeiMpInitLib, save CPU MP Data pointer into one local Guided HOB. In DxeMpInitLib, save CPU MP Data pointer into one global variable. Add helper functions GetCpuMpData()/SaveCpuMpData(). v5: 1. Move CPU_INIT_MP_LIB_HOB_GUID from MpLib.c to MpLib.h to make all C files visible. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add MicrocodeDetect() and load microcode on BSPJeff Fan
v4: 1. ProcessorSignature is updated to CPU_MICROCODE_PROCESSOR_SIGNATURE instead of UINT32. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add CPU_VOLATILE_REGISTERS & worker functionsJeff Fan
Add CPU_VOLATILE_REGISTERS definitions for CRx and DRx required to be restored after APs received INIT IPI. Add worker functions SaveVolatileRegisters()/RestoreVolatileRegisters() used to save/restore CRx and DRx. It also check if Debugging Extensions supported or not. v5: 1. Add comment block for structure CPU_VOLATILE_REGISTERS. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Initialize CPU_AP_DATA for CPU APsJeff Fan
Initialize CPU_AP_DATA for CPU APs and add GetApState()/SetApState() helper functions to get/set AP state. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Allocate and initialize memory of MP Data bufferJeff Fan
v5: 1. Add comment block for enum AP_INIT_STATE and structure CPU_AP_DATA. 2. Add more comment for structure CPU_INFO_IN_HOB. 3. Add more clarification in structure _CPU_MP_DATA for those fields pass from PEI to DXE. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Get ApLoopMode and MointorFilter sizeJeff Fan
Firstly, get ApLoopMode from PcdCpuApLoopMode. If MonitorMwait feature is not supported, update ApLoopMode to ApHltLoop. If MonitorMwait feature is supported, get MointorFilter size by CPUID.[EAX=05H]:EBX.BIT0-15. v5: 1. Add comment block for enum AP_LOOP_MODE. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add MP_ASSEMBLY_ADDRESS_MAPJeff Fan
In MpInitLibInitialize(), invoke AsmGetAddress() to get get assembly functions' entry addresses and the sizes from returned MP_ASSEMBLY_ADDRESS_MAP structure. v5: 1. Add more detailed comments for structure MP_ASSEMBLY_ADDRESS_MAP. v4: 1. Add AsmRelocateApLoop information return in AsmGetAddress(). v3: 1. Rename AsmRellocateApLoop to AsmRelocateApLoop. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add AsmRelocateApLoop() assembly codeJeff Fan
AsmRelocateApLoop() is used to place APs into MWAIT-loop if MonitorMwait feature is supported before hand-off to OS, or place APs into HLT-loop if MonitorMwait feature is not supported. If the current mode is long mode, we will switch APs to protected mode before placing APs in MWAIT-loop or HLT-loop. Thus, once APs wakeup from loop, APs needn't the page table that may be crashed by OS. v3: 1. Rename AsmRellocateApLoop to AsmRelocateApLoop. 2. Fix typo Proteced to Protected. 3. Fix typo segement to segment 4. Use word MONITOR instead of mwait-monitor. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add EnableExecuteDisable in MP_CPU_EXCHANGE_INFOJeff Fan
EnableExecuteDisable in MP_CPU_EXCHANGE_INFO is used to tell AP reset vector if enable execute disable feature on APs. This feature should be enabled before CR3 is written. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Fix typo and clean up the codeJeff Fan
1. Rename NumApsExecutingLoction to NumApsExecutingLocation 2. Update some comments in NASM files. 3. Remove PeiCpuMpData from MP_CPU_EXCHANGE_INFO. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add AP assembly code and MP_CPU_EXCHANGE_INFOJeff Fan
Add assembly code for AP reset vector and the definition of MP_CPU_EXCHANGE_INFO that are used to exchange the data between C code and assembly code when AP wake up. v4: 1. Copy MP_CPU_EXCHANGE_INFO from UefiCpuPkg/CpuMpPei/CpuMpPei.h 2. Copy MpEqu.inc and MpFuncs.nasm from UefiCpuPkg/CpuMpPei. v3: 1. Rename NumApsExecutingLoction to NumApsExecutingLocation 2. Add whitespace after ; in .nasm file Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add two instances PeiMpInitLib and DxeMpInitLibJeff Fan
Add two MP Initialize Library instances PeiMpInitLib.inf and DxeMpInitLib.inf with NULL implementation. One PeiMpInitLib.inf is consumed by PEI MP driver. Another DxeMpInitLib.inf is consumed by DXE MP driver. Place MpInitLibStartupAllAPs()/MpInitLibStartupThisAp()/MpInitLibSwitchBSP()/ MpInitLibEnableDisableAP() into PeiMpLib.c and DxeMpLib.c, because they have the different implementations and will be updated in latter patches. v5: 1. Add back PeiExceptionHandlerLib.inf in UefiCpuPkg.dsc. It is removed incorrectly. v4: 1. Return EFI_UNSUPPORTED instead of EFI_SUCCESS for NULL implementation of all Functions. 2. Sync MpInitLibxxx functions header updating described in v4 part of Patch #4. v3: 1. Rename MpInitLibSwitchBsp to MpInitLibSwitchBSP to match PI spec Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/MpInitLib: Add MP Initialize library class definitionJeff Fan
MP Initialize library provides basic functionalities to do APs initialization, to manage MP information and to wakeup APs to execute AP task. It could be consumed by CPU MP PEI or DXE drivers to provide CPU MP PPI/Protocol services. v4: 1. MpInitLibGetProcessorInfo(): Update HealthData type from UINT32 to EFI_HEALTH_FLAGS. Add #include <Ppi/SecPlatformInformation.h> 2. MpInitLibSwitchBSP(): Return EFI_DEVICE_ERROR instead of EFI_SUCCESS if the calling processor is an AP. 3. MpInitLibStartupThisAP(): Fix several incorrect references to "APs" to match PI spec. 4. MpInitLibSwitchBSP() and MpInitLibEnableDisableAP(): Fix incorrect description on ProcessorNumber. 5. Trim whitespace at end of line. v3: 1. Add whitespace after MpInitLibInitialize 2. Rename MpInitLibSwitchBsp to MpInitLibSwitchBSP to match PI spec Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
2016-08-17UefiCpuPkg/CpuS3DataDxe: Move StartupVector allocation to EndOfDxe()Jeff Fan
Currently, we will allocate StartupVector buffer under 1MB at entry point function. But some modules may allocate some hard code address under 1MB. For example, LegacyBiosDxe driver tries to manage some legacy range under 640KB. To avoid the conflicts, we move StartupVector buffer allocation to End Of DXE event callback function. v4: Update the Context parameter is used as a pointer to AcpiCpuDataEx, then we needn't to add the global variable. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>