diff options
author | Anthony PERARD <anthony.perard@citrix.com> | 2019-08-13 12:31:10 +0100 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2019-08-21 18:03:49 +0200 |
commit | 054c3fe9b5cd9bcd33ee8c7db992e13a36fa3191 (patch) | |
tree | 3c2916d1fefebf2ef24dbcfb98a31f0010ca3d5e /OvmfPkg/Library | |
parent | 198a8dc9cd6222e40a71ecadbb50ef8e34c276de (diff) | |
download | edk2-054c3fe9b5cd9bcd33ee8c7db992e13a36fa3191.tar.gz edk2-054c3fe9b5cd9bcd33ee8c7db992e13a36fa3191.tar.bz2 edk2-054c3fe9b5cd9bcd33ee8c7db992e13a36fa3191.zip |
OvmfPkg/XenPlatformLib: Cache result for XenDetected
We are going to replace XenDetected() implementation in
PlatformBootManagerLib by the one in XenPlatformLib.
PlatformBootManagerLib's implementation does cache the result of
GetFirstGuidHob(), so we do something similar in XenPlatformLib.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190813113119.14804-27-anthony.perard@citrix.com>
Diffstat (limited to 'OvmfPkg/Library')
-rw-r--r-- | OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c index 974a0e73f1..8f20ae2d45 100644 --- a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c +++ b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c @@ -25,14 +25,26 @@ XenGetInfoHOB ( VOID
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ STATIC BOOLEAN Cached = FALSE;
+ STATIC EFI_XEN_INFO *XenInfo;
+
+ //
+ // Return the cached result for the benefit of XenDetected that can be
+ // called many times.
+ //
+ if (Cached) {
+ return XenInfo;
+ }
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
if (GuidHob == NULL) {
- return NULL;
+ XenInfo = NULL;
+ } else {
+ XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
}
-
- return (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
+ Cached = TRUE;
+ return XenInfo;
}
/**
|