]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmbase" with PatchInstructionX86()
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / Semaphore.c
CommitLineData
7947da3c
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
18UINTN mSmmRelocationOriginalAddress;\r
19volatile BOOLEAN *mRebasedFlag;\r
20\r
21/**\r
22 Hook return address of SMM Save State so that semaphore code\r
23 can be executed immediately after AP exits SMM to indicate to\r
24 the BSP that an AP has exited SMM after SMBASE relocation.\r
25\r
26 @param[in] CpuIndex The processor index.\r
27 @param[in] RebasedFlag A pointer to a flag that is set to TRUE\r
28 immediately after AP exits SMM.\r
29\r
30**/\r
31VOID\r
32SemaphoreHook (\r
33 IN UINTN CpuIndex,\r
34 IN volatile BOOLEAN *RebasedFlag\r
35 )\r
36{\r
37 SMRAM_SAVE_STATE_MAP *CpuState;\r
38\r
39 mRebasedFlag = RebasedFlag;\r
40\r
41 CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);\r
42 mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm (\r
43 CpuIndex,\r
44 CpuState,\r
45 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete,\r
46 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete\r
47 );\r
48}\r