UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SwitchApContext()

Rename the MpHandOff parameter to FirstMpHandOff.  Add loops so the
function inspects all HOBs present in the system.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20240222160106.686484-4-kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2024-02-22 17:01:03 +01:00 committed by mergify[bot]
parent b485230462
commit e2c9d8eba4
2 changed files with 24 additions and 13 deletions

View File

@ -1938,31 +1938,42 @@ GetBspNumber (
This procedure allows the AP to switch to another section of This procedure allows the AP to switch to another section of
memory and continue its loop there. memory and continue its loop there.
@param[in] MpHandOff Pointer to MP hand-off data structure. @param[in] FirstMpHandOff Pointer to first MP hand-off HOB body.
**/ **/
VOID VOID
SwitchApContext ( SwitchApContext (
IN MP_HAND_OFF *MpHandOff IN CONST MP_HAND_OFF *FirstMpHandOff
) )
{ {
UINTN Index; UINTN Index;
UINT32 BspNumber; UINT32 BspNumber;
CONST MP_HAND_OFF *MpHandOff;
BspNumber = GetBspNumber (MpHandOff); BspNumber = GetBspNumber (FirstMpHandOff);
for (Index = 0; Index < MpHandOff->CpuCount; Index++) { for (MpHandOff = FirstMpHandOff;
if (Index != BspNumber) { MpHandOff != NULL;
*(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = (UINTN)SwitchContextPerAp; MpHandOff = GetNextMpHandOffHob (MpHandOff))
*(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOff->StartupSignalValue; {
for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
if (MpHandOff->ProcessorIndex + Index != BspNumber) {
*(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = (UINTN)SwitchContextPerAp;
*(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOff->StartupSignalValue;
}
} }
} }
// //
// Wait all APs waken up if this is not the 1st broadcast of SIPI // Wait all APs waken up if this is not the 1st broadcast of SIPI
// //
for (Index = 0; Index < MpHandOff->CpuCount; Index++) { for (MpHandOff = FirstMpHandOff;
if (Index != BspNumber) { MpHandOff != NULL;
WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSignalAddress)); MpHandOff = GetNextMpHandOffHob (MpHandOff))
{
for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
if (MpHandOff->ProcessorIndex + Index != BspNumber) {
WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSignalAddress));
}
} }
} }
} }

View File

@ -482,7 +482,7 @@ GetWakeupBuffer (
**/ **/
VOID VOID
SwitchApContext ( SwitchApContext (
IN MP_HAND_OFF *MpHandOff IN CONST MP_HAND_OFF *FirstMpHandOff
); );
/** /**