]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / Semaphore.c
1 /** @file
2 Semaphore mechanism to indicate to the BSP that an AP has exited SMM
3 after SMBASE relocation.
4
5 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "PiSmmCpuDxeSmm.h"
11
12 UINTN mSmmRelocationOriginalAddress;
13 volatile BOOLEAN *mRebasedFlag;
14
15 /**
16 Hook return address of SMM Save State so that semaphore code
17 can be executed immediately after AP exits SMM to indicate to
18 the BSP that an AP has exited SMM after SMBASE relocation.
19
20 @param[in] CpuIndex The processor index.
21 @param[in] RebasedFlag A pointer to a flag that is set to TRUE
22 immediately after AP exits SMM.
23
24 **/
25 VOID
26 SemaphoreHook (
27 IN UINTN CpuIndex,
28 IN volatile BOOLEAN *RebasedFlag
29 )
30 {
31 SMRAM_SAVE_STATE_MAP *CpuState;
32
33 mRebasedFlag = RebasedFlag;
34
35 CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
36 mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm (
37 CpuIndex,
38 CpuState,
39 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete,
40 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete
41 );
42 }