public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: lersek@redhat.com, leif.lindholm@linaro.org, heyi.guo@linaro.org,
	star.zeng@intel.com, eric.dong@intel.com,
	michael.d.kinney@intel.com, liming.gao@intel.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol
Date: Thu,  1 Mar 2018 18:11:40 +0000	[thread overview]
Message-ID: <20180301181142.16817-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180301181142.16817-1-ard.biesheuvel@linaro.org>

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(+)

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.
-- 
2.11.0



  parent reply	other threads:[~2018-03-01 18:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 18:11 [PATCH 0/4] implement runtime debug output protocl Ard Biesheuvel
2018-03-01 18:11 ` [PATCH 1/4] MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg Ard Biesheuvel
2018-03-01 18:11 ` Ard Biesheuvel [this message]
2018-03-01 18:11 ` [PATCH 3/4] MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke RuntimeDebugOutputProtocol Ard Biesheuvel
2018-03-01 18:11 ` [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver Ard Biesheuvel
2018-03-15 12:49   ` Leif Lindholm
2018-04-20 14:14     ` Alexei Fedorov
2018-04-23 10:31       ` Ard Biesheuvel
2018-03-02  2:09 ` [PATCH 0/4] implement runtime debug output protocl Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180301181142.16817-3-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox