diff mbox series

[edk2,2/4] MdeModulePkg: introduce runtime debug output protocol

Message ID 20180301181142.16817-3-ard.biesheuvel@linaro.org
State New
Headers show
Series implement runtime debug output protocl | expand

Commit Message

Ard Biesheuvel March 1, 2018, 6:11 p.m. UTC
Introduce a EDK2 specific protocol that may be invoked to produce
debug output at runtime. This may be used, e.g., by DebugLib library
class implementations called from DXE_RUNTIME_DRIVER modules, which
may only be able to produce debug output at boot time, and will be
able to defer to this protocol to produce debug output at runtime as
well.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h | 58 ++++++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                      |  4 ++
 2 files changed, 62 insertions(+)

-- 
2.11.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h b/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h
new file mode 100644
index 000000000000..ac6e0c27d86d
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h
@@ -0,0 +1,58 @@ 
+/** @file
+  Protocol for emitting debug output at runtime. May be consumed by DebugLib
+  implementations that can only produce output safely at boot time.
+
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution. The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __EDK2_RUNTIME_DEBUG_OUTPUT_H__
+#define __EDK2_RUNTIME_DEBUG_OUTPUT_H__
+
+#define EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL_GUID \
+  { 0x3f4fe308, 0x2284, 0x4ca2, { 0xbe, 0x2c, 0x2d, 0xa8, 0xdf, 0x7a, 0xec, 0xd6 } }
+
+typedef struct _EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL;
+
+/**
+  Write data from buffer to debug output device
+
+  Writes NumberOfBytes data bytes from Buffer to the debug output device.
+  The number of bytes actually written to the device is returned.
+  If the return value is less than NumberOfBytes, then the write operation
+  failed.
+  If NumberOfBytes is zero, then return 0.
+
+  @param  Buffer           Pointer to the data buffer to be written.
+  @param  NumberOfBytes    Number of bytes to written to the device.
+
+  @retval 0                NumberOfBytes is 0.
+  @retval >0               The number of bytes written to the serial device.
+                           If this value is less than NumberOfBytes, then the
+                           write operation failed.
+
+**/
+typedef
+UINTN
+(EFIAPI *RUNTIME_DEBUG_OUTPUT_WRITE) (
+  IN  EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL  *This,
+  IN  UINT8                               *Buffer,
+  IN  UINTN                               NumberOfBytes
+  );
+
+
+struct _EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL {
+  RUNTIME_DEBUG_OUTPUT_WRITE    Write;
+};
+
+extern EFI_GUID gEdkiiRuntimeDebugOutputProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index ba0585936b6e..faaf189fe464 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -592,6 +592,10 @@  [Protocols]
   gEdkiiPlatformSpecificResetFilterProtocolGuid  = { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }
   ## Include/Protocol/PlatformSpecificResetHandler.h
   gEdkiiPlatformSpecificResetHandlerProtocolGuid = { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }
+
+  ## Include/Protocol/RuntimeDebugOutput.h
+  gEdkiiRuntimeDebugOutputProtocolGuid = { 0x3f4fe308, 0x2284, 0x4ca2, { 0xbe, 0x2c, 0x2d, 0xa8, 0xdf, 0x7a, 0xec, 0xd6 } }
+
 #
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]
 #   0x80000001 | Invalid value provided.