2 Capsule library runtime support.
4 Copyright (c) 2016, 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
;
33 Convert EsrtTable physical address to virtual address.
35 @param[in] Event Event whose notification function is being invoked.
36 @param[in] Context The pointer to the notification function's context, which
37 is implementation-dependent.
41 DxeCapsuleLibVirtualAddressChangeEvent (
47 EFI_CONFIGURATION_TABLE
*ConfigEntry
;
50 // Get Esrt table first
52 ConfigEntry
= gST
->ConfigurationTable
;
53 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
54 if (CompareGuid(&gEfiSystemResourceTableGuid
, &ConfigEntry
->VendorGuid
)) {
61 // If no Esrt table installed in Configure Table
63 if (Index
< gST
->NumberOfTableEntries
) {
65 // Search Esrt to check given capsule is qualified
67 mEsrtTable
= (EFI_SYSTEM_RESOURCE_TABLE
*) ConfigEntry
->VendorTable
;
70 // Update protocol pointer to Esrt Table.
72 gRT
->ConvertPointer (0x00, (VOID
**) &(mEsrtTable
));
75 mIsVirtualAddrConverted
= TRUE
;
80 The constructor function hook VirtualAddressChange event to use ESRT table as capsule routing table.
82 @param ImageHandle The firmware allocated handle for the EFI image.
83 @param SystemTable A pointer to the EFI System Table.
85 @retval EFI_SUCCESS The constructor successfully .
89 DxeRuntimeCapsuleLibConstructor (
90 IN EFI_HANDLE ImageHandle
,
91 IN EFI_SYSTEM_TABLE
*SystemTable
98 // Make sure we can handle virtual address changes.
101 Status
= gBS
->CreateEventEx (
104 DxeCapsuleLibVirtualAddressChangeEvent
,
106 &gEfiEventVirtualAddressChangeGuid
,
109 ASSERT_EFI_ERROR (Status
);