2 Semaphore mechanism to indicate to the BSP that an AP has exited SMM
3 after SMBASE relocation.
5 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "PiSmmCpuDxeSmm.h"
12 X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32
;
13 X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32
;
15 UINTN mSmmRelocationOriginalAddress
;
16 volatile BOOLEAN
*mRebasedFlag
;
19 AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode.
22 SmmRelocationSemaphoreComplete32 (
27 Hook return address of SMM Save State so that semaphore code
28 can be executed immediately after AP exits SMM to indicate to
29 the BSP that an AP has exited SMM after SMBASE relocation.
31 @param[in] CpuIndex The processor index.
32 @param[in] RebasedFlag A pointer to a flag that is set to TRUE
33 immediately after AP exits SMM.
39 IN
volatile BOOLEAN
*RebasedFlag
42 SMRAM_SAVE_STATE_MAP
*CpuState
;
45 mRebasedFlag
= RebasedFlag
;
47 gPatchRebasedFlagAddr32
,
48 (UINT32
)(UINTN
)mRebasedFlag
,
52 CpuState
= (SMRAM_SAVE_STATE_MAP
*)(UINTN
)(SMM_DEFAULT_SMBASE
+ SMRAM_SAVE_STATE_MAP_OFFSET
);
53 mSmmRelocationOriginalAddress
= HookReturnFromSmm (
56 (UINT64
)(UINTN
)&SmmRelocationSemaphoreComplete32
,
57 (UINT64
)(UINTN
)&SmmRelocationSemaphoreComplete
61 // Use temp value to fix ICC complier warning
63 TempValue
= (UINTN
)&mSmmRelocationOriginalAddress
;
65 gPatchSmmRelocationOriginalAddressPtr32
,