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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "PiSmmCpuDxeSmm.h"
18 X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32
;
19 X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32
;
21 UINTN mSmmRelocationOriginalAddress
;
22 volatile BOOLEAN
*mRebasedFlag
;
25 AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode.
28 SmmRelocationSemaphoreComplete32 (
33 Hook return address of SMM Save State so that semaphore code
34 can be executed immediately after AP exits SMM to indicate to
35 the BSP that an AP has exited SMM after SMBASE relocation.
37 @param[in] CpuIndex The processor index.
38 @param[in] RebasedFlag A pointer to a flag that is set to TRUE
39 immediately after AP exits SMM.
45 IN
volatile BOOLEAN
*RebasedFlag
48 SMRAM_SAVE_STATE_MAP
*CpuState
;
51 mRebasedFlag
= RebasedFlag
;
53 gPatchRebasedFlagAddr32
,
54 (UINT32
)(UINTN
)mRebasedFlag
,
58 CpuState
= (SMRAM_SAVE_STATE_MAP
*)(UINTN
)(SMM_DEFAULT_SMBASE
+ SMRAM_SAVE_STATE_MAP_OFFSET
);
59 mSmmRelocationOriginalAddress
= HookReturnFromSmm (
62 (UINT64
)(UINTN
)&SmmRelocationSemaphoreComplete32
,
63 (UINT64
)(UINTN
)&SmmRelocationSemaphoreComplete
67 // Use temp value to fix ICC complier warning
69 TempValue
= (UINTN
)&mSmmRelocationOriginalAddress
;
71 gPatchSmmRelocationOriginalAddressPtr32
,