2 Capsule library runtime support.
4 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Guid/FmpCapsule.h>
18 #include <Guid/SystemResourceTable.h>
19 #include <Guid/EventGroup.h>
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/DxeServicesTableLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/UefiRuntimeServicesTableLib.h>
27 #include <Library/MemoryAllocationLib.h>
29 extern EFI_SYSTEM_RESOURCE_TABLE
*mEsrtTable
;
30 extern BOOLEAN mIsVirtualAddrConverted
;
31 EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
= NULL
;
34 Convert EsrtTable physical address to virtual address.
36 @param[in] Event Event whose notification function is being invoked.
37 @param[in] Context The pointer to the notification function's context, which
38 is implementation-dependent.
42 DxeCapsuleLibVirtualAddressChangeEvent (
48 EFI_CONFIGURATION_TABLE
*ConfigEntry
;
51 // Get Esrt table first
53 ConfigEntry
= gST
->ConfigurationTable
;
54 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
55 if (CompareGuid(&gEfiSystemResourceTableGuid
, &ConfigEntry
->VendorGuid
)) {
62 // If no Esrt table installed in Configure Table
64 if (Index
< gST
->NumberOfTableEntries
) {
66 // Search Esrt to check given capsule is qualified
68 mEsrtTable
= (EFI_SYSTEM_RESOURCE_TABLE
*) ConfigEntry
->VendorTable
;
71 // Update protocol pointer to Esrt Table.
73 gRT
->ConvertPointer (0x00, (VOID
**) &(mEsrtTable
));
76 mIsVirtualAddrConverted
= TRUE
;
81 The constructor function hook VirtualAddressChange event to use ESRT table as capsule routing table.
83 @param ImageHandle The firmware allocated handle for the EFI image.
84 @param SystemTable A pointer to the EFI System Table.
86 @retval EFI_SUCCESS The constructor successfully .
90 DxeRuntimeCapsuleLibConstructor (
91 IN EFI_HANDLE ImageHandle
,
92 IN EFI_SYSTEM_TABLE
*SystemTable
98 // Make sure we can handle virtual address changes.
100 Status
= gBS
->CreateEventEx (
103 DxeCapsuleLibVirtualAddressChangeEvent
,
105 &gEfiEventVirtualAddressChangeGuid
,
106 &mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
108 ASSERT_EFI_ERROR (Status
);
114 The destructor function closes the VirtualAddressChange event.
116 @param ImageHandle The firmware allocated handle for the EFI image.
117 @param SystemTable A pointer to the EFI System Table.
119 @retval EFI_SUCCESS The destructor completed successfully.
123 DxeRuntimeCapsuleLibDestructor (
124 IN EFI_HANDLE ImageHandle
,
125 IN EFI_SYSTEM_TABLE
*SystemTable
131 // Close the VirtualAddressChange event.
133 Status
= gBS
->CloseEvent (mDxeRuntimeCapsuleLibVirtualAddressChangeEvent
);
134 ASSERT_EFI_ERROR (Status
);