]>
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 |
d2a16030 JY |
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 | |
03286264 DB |
29 | extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;\r |
30 | extern BOOLEAN mIsVirtualAddrConverted;\r | |
96b17e00 | 31 | EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;\r |
d2a16030 JY |
32 | \r |
33 | /**\r | |
34 | Convert EsrtTable physical address to virtual address.\r | |
35 | \r | |
36 | @param[in] Event Event whose notification function is being invoked.\r | |
37 | @param[in] Context The pointer to the notification function's context, which\r | |
38 | is implementation-dependent.\r | |
39 | **/\r | |
40 | VOID\r | |
41 | EFIAPI\r | |
42 | DxeCapsuleLibVirtualAddressChangeEvent (\r | |
43 | IN EFI_EVENT Event,\r | |
44 | IN VOID *Context\r | |
45 | )\r | |
46 | {\r | |
47 | UINTN Index;\r | |
48 | EFI_CONFIGURATION_TABLE *ConfigEntry;\r | |
49 | \r | |
50 | //\r | |
51 | // Get Esrt table first\r | |
52 | //\r | |
53 | ConfigEntry = gST->ConfigurationTable;\r | |
54 | for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r | |
55 | if (CompareGuid(&gEfiSystemResourceTableGuid, &ConfigEntry->VendorGuid)) {\r | |
56 | break;\r | |
57 | }\r | |
58 | ConfigEntry++;\r | |
59 | }\r | |
60 | \r | |
61 | //\r | |
62 | // If no Esrt table installed in Configure Table\r | |
63 | //\r | |
64 | if (Index < gST->NumberOfTableEntries) {\r | |
65 | //\r | |
66 | // Search Esrt to check given capsule is qualified\r | |
67 | //\r | |
68 | mEsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;\r | |
69 | \r | |
70 | //\r | |
71 | // Update protocol pointer to Esrt Table.\r | |
72 | //\r | |
73 | gRT->ConvertPointer (0x00, (VOID**) &(mEsrtTable));\r | |
74 | }\r | |
75 | \r | |
76 | mIsVirtualAddrConverted = TRUE;\r | |
77 | \r | |
78 | }\r | |
79 | \r | |
80 | /**\r | |
81 | The constructor function hook VirtualAddressChange event to use ESRT table as capsule routing table.\r | |
82 | \r | |
83 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
84 | @param SystemTable A pointer to the EFI System Table.\r | |
85 | \r | |
86 | @retval EFI_SUCCESS The constructor successfully .\r | |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | EFIAPI\r | |
90 | DxeRuntimeCapsuleLibConstructor (\r | |
91 | IN EFI_HANDLE ImageHandle,\r | |
92 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
93 | )\r | |
94 | {\r | |
95 | EFI_STATUS Status;\r | |
d2a16030 JY |
96 | \r |
97 | //\r | |
98 | // Make sure we can handle virtual address changes.\r | |
99 | //\r | |
d2a16030 JY |
100 | Status = gBS->CreateEventEx (\r |
101 | EVT_NOTIFY_SIGNAL,\r | |
102 | TPL_NOTIFY,\r | |
103 | DxeCapsuleLibVirtualAddressChangeEvent,\r | |
104 | NULL,\r | |
105 | &gEfiEventVirtualAddressChangeGuid,\r | |
96b17e00 | 106 | &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent\r |
d2a16030 JY |
107 | );\r |
108 | ASSERT_EFI_ERROR (Status);\r | |
109 | \r | |
110 | return EFI_SUCCESS;\r | |
111 | }\r | |
96b17e00 HW |
112 | \r |
113 | /**\r | |
114 | The destructor function closes the VirtualAddressChange event.\r | |
115 | \r | |
116 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
117 | @param SystemTable A pointer to the EFI System Table.\r | |
118 | \r | |
119 | @retval EFI_SUCCESS The destructor completed successfully.\r | |
120 | **/\r | |
121 | EFI_STATUS\r | |
122 | EFIAPI\r | |
123 | DxeRuntimeCapsuleLibDestructor (\r | |
124 | IN EFI_HANDLE ImageHandle,\r | |
125 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
126 | )\r | |
127 | {\r | |
128 | EFI_STATUS Status;\r | |
129 | \r | |
130 | //\r | |
131 | // Close the VirtualAddressChange event.\r | |
132 | //\r | |
133 | Status = gBS->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent);\r | |
134 | ASSERT_EFI_ERROR (Status);\r | |
135 | \r | |
136 | return EFI_SUCCESS;\r | |
137 | }\r |