[edk2-devel] [PATCH v3 27/35] OvmfPkg/XenPlatformLib: Cache result for XenDetected

Anthony PERARD anthony.perard at citrix.com
Thu Jul 4 14:42:25 UTC 2019


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 at citrix.com>
---

Notes:
    v3:
    - new patch

 .../Library/XenPlatformLib/XenPlatformLib.c    | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
index 6f27cbffa8..b5257b0c97 100644
--- a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
+++ b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c
@@ -26,13 +26,25 @@ XenGetInfoHOB (
   )

 {

   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;

 }

 

 /**

-- 
Anthony PERARD


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43303): https://edk2.groups.io/g/devel/message/43303
Mute This Topic: https://groups.io/mt/32308727/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list