]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
MdeModulePkg/CapsuleLib: remove ImageIndex check.
[mirror_edk2.git] / MdeModulePkg / Library / DxeCapsuleLibFmp / DxeCapsuleRuntime.c
CommitLineData
d2a16030
JY
1/** @file\r
2 Capsule library runtime support.\r
3\r
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16\r
17#include <Guid/FmpCapsule.h>\r
18#include <Guid/SystemResourceTable.h>\r
19#include <Guid/EventGroup.h>\r
20\r
21#include <Library/BaseLib.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/BaseMemoryLib.h>\r
24#include <Library/DxeServicesTableLib.h>\r
25#include <Library/UefiBootServicesTableLib.h>\r
26#include <Library/UefiRuntimeServicesTableLib.h>\r
27#include <Library/MemoryAllocationLib.h>\r
28\r
29extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;\r
30extern BOOLEAN mIsVirtualAddrConverted;\r
31\r
32/**\r
33 Convert EsrtTable physical address to virtual address.\r
34\r
35 @param[in] Event Event whose notification function is being invoked.\r
36 @param[in] Context The pointer to the notification function's context, which\r
37 is implementation-dependent.\r
38**/\r
39VOID\r
40EFIAPI\r
41DxeCapsuleLibVirtualAddressChangeEvent (\r
42 IN EFI_EVENT Event,\r
43 IN VOID *Context\r
44 )\r
45{\r
46 UINTN Index;\r
47 EFI_CONFIGURATION_TABLE *ConfigEntry;\r
48\r
49 //\r
50 // Get Esrt table first\r
51 //\r
52 ConfigEntry = gST->ConfigurationTable;\r
53 for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
54 if (CompareGuid(&gEfiSystemResourceTableGuid, &ConfigEntry->VendorGuid)) {\r
55 break;\r
56 }\r
57 ConfigEntry++;\r
58 }\r
59\r
60 //\r
61 // If no Esrt table installed in Configure Table\r
62 //\r
63 if (Index < gST->NumberOfTableEntries) {\r
64 //\r
65 // Search Esrt to check given capsule is qualified\r
66 //\r
67 mEsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;\r
68\r
69 //\r
70 // Update protocol pointer to Esrt Table.\r
71 //\r
72 gRT->ConvertPointer (0x00, (VOID**) &(mEsrtTable));\r
73 }\r
74\r
75 mIsVirtualAddrConverted = TRUE;\r
76\r
77}\r
78\r
79/**\r
80 The constructor function hook VirtualAddressChange event to use ESRT table as capsule routing table.\r
81\r
82 @param ImageHandle The firmware allocated handle for the EFI image.\r
83 @param SystemTable A pointer to the EFI System Table.\r
84\r
85 @retval EFI_SUCCESS The constructor successfully .\r
86**/\r
87EFI_STATUS\r
88EFIAPI\r
89DxeRuntimeCapsuleLibConstructor (\r
90 IN EFI_HANDLE ImageHandle,\r
91 IN EFI_SYSTEM_TABLE *SystemTable\r
92 )\r
93{\r
94 EFI_STATUS Status;\r
95 EFI_EVENT Event;\r
96\r
97 //\r
98 // Make sure we can handle virtual address changes.\r
99 //\r
100 Event = NULL;\r
101 Status = gBS->CreateEventEx (\r
102 EVT_NOTIFY_SIGNAL,\r
103 TPL_NOTIFY,\r
104 DxeCapsuleLibVirtualAddressChangeEvent,\r
105 NULL,\r
106 &gEfiEventVirtualAddressChangeGuid,\r
107 &Event\r
108 );\r
109 ASSERT_EFI_ERROR (Status);\r
110\r
111 return EFI_SUCCESS;\r
112}\r