]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/BootScriptThunkHelper/BootScriptThunkHelper.c
MdePkg: introduce standalone MM entry point library implementation
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / BootScriptThunkHelper / BootScriptThunkHelper.c
CommitLineData
b96fef9f 1/** @file\r
2 Boot Script Helper SMM driver.\r
3\r
bad73446 4 This driver is responsible to store BootScriptThunk from ReservedMemory to SMRAM for security consideration.\r
b96fef9f 5\r
bad73446 6Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
b96fef9f 7\r
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions\r
10of the BSD License which accompanies this distribution. The\r
11full text of the license may be found at\r
12http://opensource.org/licenses/bsd-license.php\r
13\r
14THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16\r
17**/\r
18\r
19#include <PiDxe.h>\r
20#include <Library/BaseLib.h>\r
21#include <Library/PcdLib.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/LockBoxLib.h>\r
24\r
25#include <Guid/BootScriptThunkData.h>\r
26\r
27EFI_GUID mBootScriptThunkGuid = {\r
28 0xa053f561, 0xf56b, 0x4140, {0x89, 0x1, 0xb4, 0xcb, 0x5d, 0x70, 0x92, 0x9e}\r
29};\r
30\r
31/**\r
32 Entry point function of the Boot Script Thunk Helper SMM driver.\r
33\r
34 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
35 @param[in] SystemTable A pointer to the EFI System Table.\r
36 \r
37 @retval EFI_SUCCESS The entry point is executed successfully.\r
38 @retval other Some error occurs when executing this entry point.\r
39**/\r
40EFI_STATUS\r
41EFIAPI\r
42BootScriptThunkHelperMain (\r
43 IN EFI_HANDLE ImageHandle,\r
44 IN EFI_SYSTEM_TABLE *SystemTable\r
45 )\r
46{\r
47 BOOT_SCRIPT_THUNK_DATA *BootScriptThunkData;\r
48 EFI_STATUS Status;\r
49\r
50 //\r
51 // Get BootScriptThunk variable\r
52 //\r
53 BootScriptThunkData = (BOOT_SCRIPT_THUNK_DATA *)(UINTN)PcdGet64(BootScriptThunkDataPtr);\r
54 ASSERT (BootScriptThunkData != NULL);\r
55 if (BootScriptThunkData == NULL) {\r
56 return EFI_NOT_FOUND;\r
57 }\r
58\r
59 //\r
60 // Save BootScriptThunk image\r
61 //\r
62 Status = SaveLockBox (\r
63 &mBootScriptThunkGuid,\r
64 (VOID *)(UINTN)BootScriptThunkData->BootScriptThunkBase,\r
65 (UINTN)BootScriptThunkData->BootScriptThunkLength\r
66 );\r
67 ASSERT_EFI_ERROR (Status);\r
68\r
69 Status = SetLockBoxAttributes (&mBootScriptThunkGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
70 ASSERT_EFI_ERROR (Status);\r
71\r
72 return Status;\r
73}\r