]>
Commit | Line | Data |
---|---|---|
d2a16030 JY |
1 | /** @file\r |
2 | Capsule library runtime support.\r | |
3 | \r | |
96b17e00 | 4 | Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
d2a16030 JY |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <PiDxe.h>\r | |
10 | \r | |
11 | #include <Guid/FmpCapsule.h>\r | |
12 | #include <Guid/SystemResourceTable.h>\r | |
13 | #include <Guid/EventGroup.h>\r | |
14 | \r | |
15 | #include <Library/BaseLib.h>\r | |
16 | #include <Library/DebugLib.h>\r | |
17 | #include <Library/BaseMemoryLib.h>\r | |
18 | #include <Library/DxeServicesTableLib.h>\r | |
19 | #include <Library/UefiBootServicesTableLib.h>\r | |
20 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
21 | #include <Library/MemoryAllocationLib.h>\r | |
22 | \r | |
03286264 DB |
23 | extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;\r |
24 | extern BOOLEAN mIsVirtualAddrConverted;\r | |
96b17e00 | 25 | EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;\r |
d2a16030 JY |
26 | \r |
27 | /**\r | |
28 | Convert EsrtTable physical address to virtual address.\r | |
29 | \r | |
30 | @param[in] Event Event whose notification function is being invoked.\r | |
31 | @param[in] Context The pointer to the notification function's context, which\r | |
32 | is implementation-dependent.\r | |
33 | **/\r | |
34 | VOID\r | |
35 | EFIAPI\r | |
36 | DxeCapsuleLibVirtualAddressChangeEvent (\r | |
37 | IN EFI_EVENT Event,\r | |
38 | IN VOID *Context\r | |
39 | )\r | |
40 | {\r | |
41 | UINTN Index;\r | |
42 | EFI_CONFIGURATION_TABLE *ConfigEntry;\r | |
43 | \r | |
44 | //\r | |
45 | // Get Esrt table first\r | |
46 | //\r | |
47 | ConfigEntry = gST->ConfigurationTable;\r | |
48 | for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r | |
49 | if (CompareGuid(&gEfiSystemResourceTableGuid, &ConfigEntry->VendorGuid)) {\r | |
50 | break;\r | |
51 | }\r | |
52 | ConfigEntry++;\r | |
53 | }\r | |
54 | \r | |
55 | //\r | |
56 | // If no Esrt table installed in Configure Table\r | |
57 | //\r | |
58 | if (Index < gST->NumberOfTableEntries) {\r | |
59 | //\r | |
60 | // Search Esrt to check given capsule is qualified\r | |
61 | //\r | |
62 | mEsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;\r | |
63 | \r | |
64 | //\r | |
65 | // Update protocol pointer to Esrt Table.\r | |
66 | //\r | |
67 | gRT->ConvertPointer (0x00, (VOID**) &(mEsrtTable));\r | |
68 | }\r | |
69 | \r | |
70 | mIsVirtualAddrConverted = TRUE;\r | |
71 | \r | |
72 | }\r | |
73 | \r | |
74 | /**\r | |
75 | The constructor function hook VirtualAddressChange event to use ESRT table as capsule routing table.\r | |
76 | \r | |
77 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
78 | @param SystemTable A pointer to the EFI System Table.\r | |
79 | \r | |
80 | @retval EFI_SUCCESS The constructor successfully .\r | |
81 | **/\r | |
82 | EFI_STATUS\r | |
83 | EFIAPI\r | |
84 | DxeRuntimeCapsuleLibConstructor (\r | |
85 | IN EFI_HANDLE ImageHandle,\r | |
86 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
87 | )\r | |
88 | {\r | |
89 | EFI_STATUS Status;\r | |
d2a16030 JY |
90 | \r |
91 | //\r | |
92 | // Make sure we can handle virtual address changes.\r | |
93 | //\r | |
d2a16030 JY |
94 | Status = gBS->CreateEventEx (\r |
95 | EVT_NOTIFY_SIGNAL,\r | |
96 | TPL_NOTIFY,\r | |
97 | DxeCapsuleLibVirtualAddressChangeEvent,\r | |
98 | NULL,\r | |
99 | &gEfiEventVirtualAddressChangeGuid,\r | |
96b17e00 | 100 | &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent\r |
d2a16030 JY |
101 | );\r |
102 | ASSERT_EFI_ERROR (Status);\r | |
103 | \r | |
104 | return EFI_SUCCESS;\r | |
105 | }\r | |
96b17e00 HW |
106 | \r |
107 | /**\r | |
108 | The destructor function closes the VirtualAddressChange event.\r | |
109 | \r | |
110 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
111 | @param SystemTable A pointer to the EFI System Table.\r | |
112 | \r | |
113 | @retval EFI_SUCCESS The destructor completed successfully.\r | |
114 | **/\r | |
115 | EFI_STATUS\r | |
116 | EFIAPI\r | |
117 | DxeRuntimeCapsuleLibDestructor (\r | |
118 | IN EFI_HANDLE ImageHandle,\r | |
119 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
120 | )\r | |
121 | {\r | |
122 | EFI_STATUS Status;\r | |
123 | \r | |
124 | //\r | |
125 | // Close the VirtualAddressChange event.\r | |
126 | //\r | |
127 | Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);\r | |
128 | ASSERT_EFI_ERROR (Status);\r | |
129 | \r | |
130 | return EFI_SUCCESS;\r | |
131 | }\r |