]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
UefiCpuPkg/PiSmmCpuDxeSmm: remove DBs from SmmRelocationSemaphoreComplete32()
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / X64 / Semaphore.c
CommitLineData
427e3573
MK
1/** @file\r
2Semaphore mechanism to indicate to the BSP that an AP has exited SMM\r
3after SMBASE relocation.\r
4\r
5Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "PiSmmCpuDxeSmm.h"\r
17\r
9686a467
LE
18X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32;\r
19X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32;\r
427e3573
MK
20\r
21UINTN mSmmRelocationOriginalAddress;\r
22volatile BOOLEAN *mRebasedFlag;\r
23\r
24/**\r
25AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode.\r
26**/\r
27VOID\r
28SmmRelocationSemaphoreComplete32 (\r
29 VOID\r
30 );\r
31\r
32/**\r
33 Hook return address of SMM Save State so that semaphore code\r
34 can be executed immediately after AP exits SMM to indicate to\r
35 the BSP that an AP has exited SMM after SMBASE relocation.\r
36\r
37 @param[in] CpuIndex The processor index.\r
38 @param[in] RebasedFlag A pointer to a flag that is set to TRUE\r
39 immediately after AP exits SMM.\r
40\r
41**/\r
42VOID\r
43SemaphoreHook (\r
44 IN UINTN CpuIndex,\r
45 IN volatile BOOLEAN *RebasedFlag\r
46 )\r
47{\r
48 SMRAM_SAVE_STATE_MAP *CpuState;\r
49 UINTN TempValue;\r
50\r
51 mRebasedFlag = RebasedFlag;\r
9686a467
LE
52 PatchInstructionX86 (\r
53 gPatchRebasedFlagAddr32,\r
54 (UINT32)(UINTN)mRebasedFlag,\r
55 4\r
56 );\r
427e3573
MK
57\r
58 CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);\r
59 mSmmRelocationOriginalAddress = HookReturnFromSmm (\r
60 CpuIndex,\r
61 CpuState,\r
62 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete32,\r
63 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete\r
64 );\r
65\r
66 //\r
67 // Use temp value to fix ICC complier warning\r
68 //\r
69 TempValue = (UINTN)&mSmmRelocationOriginalAddress;\r
9686a467
LE
70 PatchInstructionX86 (\r
71 gPatchSmmRelocationOriginalAddressPtr32,\r
72 (UINT32)TempValue,\r
73 4\r
74 );\r
427e3573 75}\r