diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c')
-rw-r--r-- | roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c new file mode 100644 index 000000000..8c466e64e --- /dev/null +++ b/roms/edk2/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c @@ -0,0 +1,65 @@ +/** @file
+ Detection code for hypervisor debug port.
+ Non-SEC instance, caches the result of detection.
+
+ Copyright (c) 2017, Red Hat, Inc.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include "DebugLibDetect.h"
+
+//
+// Set to TRUE if the debug I/O port has been checked
+//
+STATIC BOOLEAN mDebugIoPortChecked = FALSE;
+
+//
+// Set to TRUE if the debug I/O port is enabled
+//
+STATIC BOOLEAN mDebugIoPortFound = FALSE;
+
+/**
+ This constructor function must not do anything.
+
+ Some modules consuming this library instance, such as the DXE Core, invoke
+ the DEBUG() macro before they explicitly call
+ ProcessLibraryConstructorList(). Therefore the auto-generated call from
+ ProcessLibraryConstructorList() to this constructor function may be preceded
+ by some calls to PlatformDebugLibIoPortFound() below. Hence
+ PlatformDebugLibIoPortFound() must not rely on anything this constructor
+ could set up.
+
+ @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformDebugLibIoPortConstructor (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+/**
+ At the first call, check if the debug I/O port device is present, and cache
+ the result for later use. At subsequent calls, return the cached result.
+
+ @retval TRUE if the debug I/O port device was detected.
+ @retval FALSE otherwise
+
+**/
+BOOLEAN
+EFIAPI
+PlatformDebugLibIoPortFound (
+ VOID
+ )
+{
+ if (!mDebugIoPortChecked) {
+ mDebugIoPortFound = PlatformDebugLibIoPortDetect ();
+ mDebugIoPortChecked = TRUE;
+ }
+ return mDebugIoPortFound;
+}
|