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>
VOID\r
)\r
{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ STATIC BOOLEAN Cached = FALSE;\r
+ STATIC EFI_XEN_INFO *XenInfo;\r
+\r
+ //\r
+ // Return the cached result for the benefit of XenDetected that can be\r
+ // called many times.\r
+ //\r
+ if (Cached) {\r
+ return XenInfo;\r
+ }\r
\r
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
if (GuidHob == NULL) {\r
- return NULL;\r
+ XenInfo = NULL;\r
+ } else {\r
+ XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
}\r
-\r
- return (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
+ Cached = TRUE;\r
+ return XenInfo;\r
}\r
\r
/**\r