public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/4] implement runtime debug output protocl
@ 2018-03-01 18:11 Ard Biesheuvel
  2018-03-01 18:11 ` [PATCH 1/4] MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg Ard Biesheuvel
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 18:11 UTC (permalink / raw)
  To: edk2-devel
  Cc: lersek, leif.lindholm, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao, Ard Biesheuvel

As discussed on list, MMIO based UARTs cannot be used at runtime without
taking special precautions to register the MMIO region and switch to the
virtual address when accessing it at runtime.

So extend the recently introduced DxeRuntimeDebugLibSerialPort library by
invoking the proposed RuntimeDebugOutput protocol at runtime if one is
available, and providing an implementation of this protocol for PL011.

Ard Biesheuvel (4):
  MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg
  MdeModulePkg: introduce runtime debug output protocol
  MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke
    RuntimeDebugOutputProtocol
  ArmPlatformPkg: add PL011 UART runtime debug driver

 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c                 | 144 ++++++++++++++++++
 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf               |  62 ++++++++
 ArmVirtPkg/ArmVirt.dsc.inc                                                                     |   2 +-
 MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h                                             |  58 ++++++++
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c                       | 155 +++++++++++++++++---
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf |   5 +
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni |   0
 MdeModulePkg/MdeModulePkg.dec                                                                  |   4 +
 8 files changed, 412 insertions(+), 18 deletions(-)
 create mode 100644 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
 create mode 100644 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
 create mode 100644 MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h
 rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c (70%)
 rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf (88%)
 rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni (100%)

-- 
2.11.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg
  2018-03-01 18:11 [PATCH 0/4] implement runtime debug output protocl Ard Biesheuvel
@ 2018-03-01 18:11 ` Ard Biesheuvel
  2018-03-01 18:11 ` [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol Ard Biesheuvel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 18:11 UTC (permalink / raw)
  To: edk2-devel
  Cc: lersek, leif.lindholm, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao, Ard Biesheuvel

Before making enhancements to DxeRuntimeDebugLibSerialPort involving
EDK2 specific protocols, move the driver from MdePkg to MdeModulePkg,
which permits such EDK2 specific deviations from the PI spec.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmVirtPkg/ArmVirt.dsc.inc                                                                     | 2 +-
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c                       | 0
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf | 0
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni | 0
 4 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index cde514958da2..8f411fde1f8b 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -232,7 +232,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
 !if $(TARGET) != RELEASE
-  DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
+  DebugLib|MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
 !endif
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
similarity index 100%
rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
similarity index 100%
rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
diff --git a/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni
similarity index 100%
rename from MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni
rename to MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol
  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
  2018-03-01 18:11 ` [PATCH 3/4] MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke RuntimeDebugOutputProtocol Ard Biesheuvel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 18:11 UTC (permalink / raw)
  To: edk2-devel
  Cc: lersek, leif.lindholm, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao, Ard Biesheuvel

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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke RuntimeDebugOutputProtocol
  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 ` [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol Ard Biesheuvel
@ 2018-03-01 18:11 ` Ard Biesheuvel
  2018-03-01 18:11 ` [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver Ard Biesheuvel
  2018-03-02  2:09 ` [PATCH 0/4] implement runtime debug output protocl Zeng, Star
  4 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 18:11 UTC (permalink / raw)
  To: edk2-devel
  Cc: lersek, leif.lindholm, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao, Ard Biesheuvel

Extend the functionality of DxeRuntimeDebugLibSerialPort by invoking
any available RuntimeDebugOutputProtocol to emit debug output at
runtime rather than staying silent.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c                       | 155 +++++++++++++++++---
 MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf |   5 +
 2 files changed, 143 insertions(+), 17 deletions(-)

diff --git a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
index e1266f77fa41..b5460f10ebb6 100644
--- a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
+++ b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
@@ -25,10 +25,16 @@
 #include <Library/PcdLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/SerialPortLib.h>
+#include <Protocol/RuntimeDebugOutput.h>
 
 STATIC EFI_EVENT      mEfiExitBootServicesEvent;
+STATIC EFI_EVENT      mEfiVirtualAddressChangeEvent;
+STATIC EFI_EVENT      mRegisterRuntimeDebugOutputProtocolEvent;
+STATIC VOID           *mRegisterProtocolRegistration;
 STATIC BOOLEAN        mEfiAtRuntime = FALSE;
 
+STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL   *mRuntimeOutput = NULL;
+
 //
 // Define the maximum debug and assert message length that this library supports
 //
@@ -53,6 +59,58 @@ ExitBootServicesEvent (
 }
 
 /**
+  Attach to the RuntimeDebugOutputProtocol as soon as it gets registered
+
+  @param[in]  Event   The Event that is being processed.
+  @param[in]  Context The Event Context.
+
+**/
+STATIC
+VOID
+EFIAPI
+RegisterRuntimeDebugOutputProtocolEvent (
+  IN EFI_EVENT        Event,
+  IN VOID             *Context
+  )
+{
+  EFI_STATUS          Status;
+  EFI_BOOT_SERVICES   *BS;
+
+  BS = Context;
+
+  Status = BS->LocateProtocol (&gEdkiiRuntimeDebugOutputProtocolGuid,
+                 mRegisterProtocolRegistration,
+                 (VOID **)&mRuntimeOutput);
+  if (EFI_ERROR (Status)) {
+    return;
+  }
+
+  BS->CloseEvent (Event);
+}
+
+/**
+  Fix up virtual address of the runtime debug output protocol
+
+  @param[in]  Event   The Event that is being processed.
+  @param[in]  Context The Event Context.
+
+**/
+STATIC
+VOID
+EFIAPI
+VirtualAddressChangeEvent (
+  IN EFI_EVENT        Event,
+  IN VOID             *Context
+  )
+{
+  EFI_RUNTIME_SERVICES  *RT;
+
+  RT = Context;
+
+  RT->ConvertPointer (0x0, (VOID **)&mRuntimeOutput);
+}
+
+/**
   The constructor function to initialize the Serial Port library and
   register a callback for the ExitBootServices event.
 
@@ -70,17 +128,64 @@ DxeRuntimeDebugLibSerialPortConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  EFI_STATUS    Status;
+  EFI_STATUS          Status;
+  EFI_BOOT_SERVICES   *BS;
 
   Status = SerialPortInitialize ();
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
-  return SystemTable->BootServices->CreateEventEx (EVT_NOTIFY_SIGNAL,
-                                      TPL_NOTIFY, ExitBootServicesEvent, NULL,
-                                      &gEfiEventExitBootServicesGuid,
-                                      &mEfiExitBootServicesEvent);
+  BS = SystemTable->BootServices;
+
+  Status = BS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+                 RegisterRuntimeDebugOutputProtocolEvent, BS,
+                 &mRegisterRuntimeDebugOutputProtocolEvent);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Register for protocol notifications on this event
+  //
+  Status = BS->RegisterProtocolNotify (&gEdkiiRuntimeDebugOutputProtocolGuid,
+                 mRegisterRuntimeDebugOutputProtocolEvent,
+                 &mRegisterProtocolRegistration);
+  if (EFI_ERROR (Status)) {
+    goto CloseProtocolEvent;
+  }
+
+  //
+  // Kick the event so we will perform an initial pass of
+  // current installed drivers
+  //
+  BS->SignalEvent (mRegisterRuntimeDebugOutputProtocolEvent);
+
+  Status = BS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+                 ExitBootServicesEvent, NULL,
+                 &gEfiEventExitBootServicesGuid,
+                 &mEfiExitBootServicesEvent);
+  if (EFI_ERROR (Status)) {
+    goto CloseProtocolEvent;
+  }
+
+  Status = BS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+                 VirtualAddressChangeEvent, SystemTable->RuntimeServices,
+                 &gEfiEventVirtualAddressChangeGuid,
+                 &mEfiVirtualAddressChangeEvent);
+  if (EFI_ERROR (Status)) {
+    goto CloseExitBootServicesEvent;
+  }
+
+  return EFI_SUCCESS;
+
+CloseExitBootServicesEvent:
+  BS->CloseEvent (mEfiExitBootServicesEvent);
+
+CloseProtocolEvent:
+  BS->CloseEvent (mRegisterRuntimeDebugOutputProtocolEvent);
+
+  return Status;
 }
 
 /**
@@ -100,7 +205,29 @@ DxeRuntimeDebugLibSerialPortDestructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  return SystemTable->BootServices->CloseEvent (mEfiExitBootServicesEvent);
+  EFI_BOOT_SERVICES   *BS;
+
+  BS = SystemTable->BootServices;
+
+  BS->CloseEvent (mRegisterRuntimeDebugOutputProtocolEvent);
+  BS->CloseEvent (mEfiExitBootServicesEvent);
+
+  return EFI_SUCCESS;
+}
+
+STATIC
+UINTN
+DebugWriteOutput (
+  IN  UINT8               *Buffer,
+  IN  UINTN               NumberOfBytes
+  )
+{
+  if (!mEfiAtRuntime) {
+    return SerialPortWrite (Buffer, NumberOfBytes);
+  } else if (mRuntimeOutput != NULL) {
+    return mRuntimeOutput->Write (mRuntimeOutput, Buffer, NumberOfBytes);
+  }
+  return 0;
 }
 
 /**
@@ -129,10 +256,6 @@ DebugPrint (
   CHAR8    Buffer[MAX_DEBUG_MESSAGE_LENGTH];
   VA_LIST  Marker;
 
-  if (mEfiAtRuntime) {
-    return;
-  }
-
   //
   // If Format is NULL, then ASSERT().
   //
@@ -155,7 +278,7 @@ DebugPrint (
   //
   // Send the print string to a Serial Port
   //
-  SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
+  DebugWriteOutput ((UINT8 *)Buffer, AsciiStrLen (Buffer));
 }
 
 
@@ -196,12 +319,10 @@ DebugAssert (
   AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT [%a] %a(%d): %a\n",
     gEfiCallerBaseName, FileName, LineNumber, Description);
 
-  if (!mEfiAtRuntime) {
-    //
-    // Send the print string to the Console Output device
-    //
-    SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
-  }
+  //
+  // Send the print string to the Console Output device
+  //
+  DebugWriteOutput ((UINT8 *)Buffer, AsciiStrLen (Buffer));
 
   //
   // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
diff --git a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
index 813358096982..d2fbdde25f1d 100644
--- a/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
+++ b/MdeModulePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
@@ -36,6 +36,7 @@ [Sources]
   DebugLib.c
 
 [Packages]
+  MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
@@ -48,6 +49,10 @@ [LibraryClasses]
 
 [Guids]
   gEfiEventExitBootServicesGuid                         ## CONSUMES ## Event
+  gEfiEventVirtualAddressChangeGuid                     ## CONSUMES ## Event
+
+[Protocols]
+  gEdkiiRuntimeDebugOutputProtocolGuid                  ## SOMETIMES_CONSUMES
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue     ## SOMETIMES_CONSUMES
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver
  2018-03-01 18:11 [PATCH 0/4] implement runtime debug output protocl Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2018-03-01 18:11 ` [PATCH 3/4] MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke RuntimeDebugOutputProtocol Ard Biesheuvel
@ 2018-03-01 18:11 ` Ard Biesheuvel
  2018-03-15 12:49   ` Leif Lindholm
  2018-03-02  2:09 ` [PATCH 0/4] implement runtime debug output protocl Zeng, Star
  4 siblings, 1 reply; 9+ messages in thread
From: Ard Biesheuvel @ 2018-03-01 18:11 UTC (permalink / raw)
  To: edk2-devel
  Cc: lersek, leif.lindholm, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao, Ard Biesheuvel

Implement the new runtime debug output protocol on top of a PL011 UART.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c   | 144 ++++++++++++++++++++
 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf |  62 +++++++++
 2 files changed, 206 insertions(+)

diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
new file mode 100644
index 000000000000..155b2c50d463
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
@@ -0,0 +1,144 @@
+/** @file
+  Runtime driver to produce debug output on a PL011 UART
+
+  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.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/PL011UartLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeLib.h>
+#include <Protocol/RuntimeDebugOutput.h>
+
+STATIC UINTN        mUartBase;
+STATIC EFI_EVENT    mVirtualAddressChangeEvent;
+
+/**
+  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.
+
+**/
+STATIC
+UINTN
+PL011RuntimeDebugOutputWrite (
+  IN  EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL  *This,
+  IN  UINT8                               *Buffer,
+  IN  UINTN                               NumberOfBytes
+  )
+{
+  return PL011UartWrite (mUartBase, Buffer, NumberOfBytes);
+}
+
+STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = {
+  PL011RuntimeDebugOutputWrite
+};
+
+/**
+  Fixup internal data so that EFI can be called in virtual mode.
+
+  @param[in]    Event   The Event that is being processed
+  @param[in]    Context Event Context
+**/
+STATIC
+VOID
+EFIAPI
+VirtualNotifyEvent (
+  IN EFI_EVENT        Event,
+  IN VOID             *Context
+  )
+{
+  EfiConvertPointer (0x0, (VOID **)&mUartBase);
+}
+
+EFI_STATUS
+EFIAPI
+PL011RuntimeDebugOutputDxeEntry (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS          Status;
+  EFI_HANDLE          Handle;
+  UINT64              BaudRate;
+  UINT32              ReceiveFifoDepth;
+  EFI_PARITY_TYPE     Parity;
+  UINT8               DataBits;
+  EFI_STOP_BITS_TYPE  StopBits;
+
+  mUartBase        = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase);
+  BaudRate         = FixedPcdGet64 (PcdUartDefaultBaudRate);
+  ReceiveFifoDepth = 0;         // Use default FIFO depth
+  Parity           = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
+  DataBits         = FixedPcdGet8 (PcdUartDefaultDataBits);
+  StopBits         = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
+
+  Status = PL011UartInitializePort (mUartBase, FixedPcdGet32 (PL011UartClkInHz),
+             &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Register for the virtual address change event
+  //
+  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+                  VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChangeGuid,
+                  &mVirtualAddressChangeEvent);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Declare the UART MMIO region as EFI_MEMORY_RUNTIME
+  //
+  Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, mUartBase,
+                  SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
+  if (EFI_ERROR (Status)) {
+    goto CloseEvent;
+  }
+
+  Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB,
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
+  if (EFI_ERROR (Status)) {
+    goto CloseEvent;
+  }
+
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
+                  &gEdkiiRuntimeDebugOutputProtocolGuid, &mRuntimeDebugOutput,
+                  NULL);
+  if (EFI_ERROR (Status)) {
+    goto CloseEvent;
+  }
+
+  return EFI_SUCCESS;
+
+CloseEvent:
+  gBS->CloseEvent (mVirtualAddressChangeEvent);
+
+  return Status;
+}
diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
new file mode 100644
index 000000000000..28a8e514552e
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
@@ -0,0 +1,62 @@
+#/** @file
+#  Runtime driver to produce debug output on a PL011 UART
+#
+#  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.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x0001001A
+  BASE_NAME                      = PL011RuntimeDebugOutputDxe
+  FILE_GUID                      = 494297ca-9205-463a-aae5-215ffd067cbb
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = PL011RuntimeDebugOutputDxeEntry
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = AARCH64 ARM
+#
+
+[Sources.common]
+  PL011RuntimeDebugOutputDxe.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DxeServicesTableLib
+  PcdLib
+  PL011UartLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiRuntimeLib
+
+[Guids]
+  gEfiEventVirtualAddressChangeGuid             ## CONSUMES # Event
+
+[Protocols]
+  gEdkiiRuntimeDebugOutputProtocolGuid          ## PROTOCOL ALWAYS_PRODUCED
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+  gArmPlatformTokenSpaceGuid.PL011UartClkInHz
+
+[Depex]
+  TRUE
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] implement runtime debug output protocl
  2018-03-01 18:11 [PATCH 0/4] implement runtime debug output protocl Ard Biesheuvel
                   ` (3 preceding siblings ...)
  2018-03-01 18:11 ` [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver Ard Biesheuvel
@ 2018-03-02  2:09 ` Zeng, Star
  4 siblings, 0 replies; 9+ messages in thread
From: Zeng, Star @ 2018-03-02  2:09 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel@lists.01.org
  Cc: lersek@redhat.com, leif.lindholm@linaro.org, heyi.guo@linaro.org,
	Dong, Eric, Kinney, Michael D, Gao, Liming, Zeng, Star

Sorry, I did not follow up the thread for DxeRuntimeDebugLibSerialPort.

For this thread, do you think it is feasible below for the case?

Use PeiDxeDebugLibReportStatusCode -> RuntimeDxeReportStatusCodeLib -> ReportStatusCodeRouterRuntimeDxe

ReportStatusCodeRouterRuntimeDxe will produce gEfiRscHandlerProtocolGuid protocol.
Like StatusCodeHandlerRuntimeDxe, consumer of gEfiRscHandlerProtocolGuid protocol can register handler to show debug message and etc.


Thanks,
Star
-----Original Message-----
From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] 
Sent: Friday, March 2, 2018 2:12 AM
To: edk2-devel@lists.01.org
Cc: lersek@redhat.com; leif.lindholm@linaro.org; heyi.guo@linaro.org; Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 0/4] implement runtime debug output protocl

As discussed on list, MMIO based UARTs cannot be used at runtime without taking special precautions to register the MMIO region and switch to the virtual address when accessing it at runtime.

So extend the recently introduced DxeRuntimeDebugLibSerialPort library by invoking the proposed RuntimeDebugOutput protocol at runtime if one is available, and providing an implementation of this protocol for PL011.

Ard Biesheuvel (4):
  MdePkg: move DxeRuntimeDebugLibSerialPort to MdeModulePkg
  MdeModulePkg: introduce runtime debug output protocol
  MdeModulePkg/DxeRuntimeDebugLibSerialPort: invoke
    RuntimeDebugOutputProtocol
  ArmPlatformPkg: add PL011 UART runtime debug driver

 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c                 | 144 ++++++++++++++++++
 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf               |  62 ++++++++
 ArmVirtPkg/ArmVirt.dsc.inc                                                                     |   2 +-
 MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h                                             |  58 ++++++++
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c                       | 155 +++++++++++++++++---
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf |   5 +
 {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni |   0
 MdeModulePkg/MdeModulePkg.dec                                                                  |   4 +
 8 files changed, 412 insertions(+), 18 deletions(-)  create mode 100644 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
 create mode 100644 ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
 create mode 100644 MdeModulePkg/Include/Protocol/RuntimeDebugOutput.h
 rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c (70%)  rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf (88%)  rename {MdePkg => MdeModulePkg}/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.uni (100%)

--
2.11.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2018-03-15 12:49 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel, lersek, heyi.guo, star.zeng, eric.dong,
	michael.d.kinney, liming.gao

On Thu, Mar 01, 2018 at 06:11:42PM +0000, Ard Biesheuvel wrote:
> Implement the new runtime debug output protocol on top of a PL011 UART.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

LGTM
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---
>  ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c   | 144 ++++++++++++++++++++
>  ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf |  62 +++++++++
>  2 files changed, 206 insertions(+)
> 
> diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
> new file mode 100644
> index 000000000000..155b2c50d463
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
> @@ -0,0 +1,144 @@
> +/** @file
> +  Runtime driver to produce debug output on a PL011 UART
> +
> +  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.
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/PL011UartLib.h>
> +#include <Library/UefiDriverEntryPoint.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeLib.h>
> +#include <Protocol/RuntimeDebugOutput.h>
> +
> +STATIC UINTN        mUartBase;
> +STATIC EFI_EVENT    mVirtualAddressChangeEvent;
> +
> +/**
> +  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.
> +
> +**/
> +STATIC
> +UINTN
> +PL011RuntimeDebugOutputWrite (
> +  IN  EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL  *This,
> +  IN  UINT8                               *Buffer,
> +  IN  UINTN                               NumberOfBytes
> +  )
> +{
> +  return PL011UartWrite (mUartBase, Buffer, NumberOfBytes);
> +}
> +
> +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = {
> +  PL011RuntimeDebugOutputWrite
> +};
> +
> +/**
> +  Fixup internal data so that EFI can be called in virtual mode.
> +
> +  @param[in]    Event   The Event that is being processed
> +  @param[in]    Context Event Context
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +VirtualNotifyEvent (
> +  IN EFI_EVENT        Event,
> +  IN VOID             *Context
> +  )
> +{
> +  EfiConvertPointer (0x0, (VOID **)&mUartBase);
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +PL011RuntimeDebugOutputDxeEntry (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS          Status;
> +  EFI_HANDLE          Handle;
> +  UINT64              BaudRate;
> +  UINT32              ReceiveFifoDepth;
> +  EFI_PARITY_TYPE     Parity;
> +  UINT8               DataBits;
> +  EFI_STOP_BITS_TYPE  StopBits;
> +
> +  mUartBase        = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase);
> +  BaudRate         = FixedPcdGet64 (PcdUartDefaultBaudRate);
> +  ReceiveFifoDepth = 0;         // Use default FIFO depth
> +  Parity           = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
> +  DataBits         = FixedPcdGet8 (PcdUartDefaultDataBits);
> +  StopBits         = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
> +
> +  Status = PL011UartInitializePort (mUartBase, FixedPcdGet32 (PL011UartClkInHz),
> +             &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  //
> +  // Register for the virtual address change event
> +  //
> +  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
> +                  VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChangeGuid,
> +                  &mVirtualAddressChangeEvent);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  //
> +  // Declare the UART MMIO region as EFI_MEMORY_RUNTIME
> +  //
> +  Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, mUartBase,
> +                  SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB,
> +                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  Handle = NULL;
> +  Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
> +                  &gEdkiiRuntimeDebugOutputProtocolGuid, &mRuntimeDebugOutput,
> +                  NULL);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  return EFI_SUCCESS;
> +
> +CloseEvent:
> +  gBS->CloseEvent (mVirtualAddressChangeEvent);
> +
> +  return Status;
> +}
> diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
> new file mode 100644
> index 000000000000..28a8e514552e
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
> @@ -0,0 +1,62 @@
> +#/** @file
> +#  Runtime driver to produce debug output on a PL011 UART
> +#
> +#  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.
> +#
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = PL011RuntimeDebugOutputDxe
> +  FILE_GUID                      = 494297ca-9205-463a-aae5-215ffd067cbb
> +  MODULE_TYPE                    = DXE_RUNTIME_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = PL011RuntimeDebugOutputDxeEntry
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +#  VALID_ARCHITECTURES           = AARCH64 ARM
> +#
> +
> +[Sources.common]
> +  PL011RuntimeDebugOutputDxe.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DxeServicesTableLib
> +  PcdLib
> +  PL011UartLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiRuntimeLib
> +
> +[Guids]
> +  gEfiEventVirtualAddressChangeGuid             ## CONSUMES # Event
> +
> +[Protocols]
> +  gEdkiiRuntimeDebugOutputProtocolGuid          ## PROTOCOL ALWAYS_PRODUCED
> +
> +[FixedPcd]
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
> +  gArmPlatformTokenSpaceGuid.PL011UartClkInHz
> +
> +[Depex]
> +  TRUE
> -- 
> 2.11.0
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver
  2018-03-15 12:49   ` Leif Lindholm
@ 2018-04-20 14:14     ` Alexei Fedorov
  2018-04-23 10:31       ` Ard Biesheuvel
  0 siblings, 1 reply; 9+ messages in thread
From: Alexei Fedorov @ 2018-04-20 14:14 UTC (permalink / raw)
  To: Leif Lindholm, Ard Biesheuvel
  Cc: eric.dong@intel.com, edk2-devel@lists.01.org,
	liming.gao@intel.com, heyi.guo@linaro.org,
	michael.d.kinney@intel.com, lersek@redhat.com,
	star.zeng@intel.com

Leif, Ard


When do you plan to push this patch?


Alexei.


________________________________
From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Leif Lindholm <leif.lindholm@linaro.org>
Sent: 15 March 2018 12:49:27
To: Ard Biesheuvel
Cc: eric.dong@intel.com; edk2-devel@lists.01.org; liming.gao@intel.com; heyi.guo@linaro.org; michael.d.kinney@intel.com; lersek@redhat.com; star.zeng@intel.com
Subject: Re: [edk2] [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver

On Thu, Mar 01, 2018 at 06:11:42PM +0000, Ard Biesheuvel wrote:
> Implement the new runtime debug output protocol on top of a PL011 UART.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

LGTM
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---
>  ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c   | 144 ++++++++++++++++++++
>  ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf |  62 +++++++++
>  2 files changed, 206 insertions(+)
>
> diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
> new file mode 100644
> index 000000000000..155b2c50d463
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
> @@ -0,0 +1,144 @@
> +/** @file
> +  Runtime driver to produce debug output on a PL011 UART
> +
> +  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.
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/PL011UartLib.h>
> +#include <Library/UefiDriverEntryPoint.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeLib.h>
> +#include <Protocol/RuntimeDebugOutput.h>
> +
> +STATIC UINTN        mUartBase;
> +STATIC EFI_EVENT    mVirtualAddressChangeEvent;
> +
> +/**
> +  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.
> +
> +**/
> +STATIC
> +UINTN
> +PL011RuntimeDebugOutputWrite (
> +  IN  EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL  *This,
> +  IN  UINT8                               *Buffer,
> +  IN  UINTN                               NumberOfBytes
> +  )
> +{
> +  return PL011UartWrite (mUartBase, Buffer, NumberOfBytes);
> +}
> +
> +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = {
> +  PL011RuntimeDebugOutputWrite
> +};
> +
> +/**
> +  Fixup internal data so that EFI can be called in virtual mode.
> +
> +  @param[in]    Event   The Event that is being processed
> +  @param[in]    Context Event Context
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +VirtualNotifyEvent (
> +  IN EFI_EVENT        Event,
> +  IN VOID             *Context
> +  )
> +{
> +  EfiConvertPointer (0x0, (VOID **)&mUartBase);
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +PL011RuntimeDebugOutputDxeEntry (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS          Status;
> +  EFI_HANDLE          Handle;
> +  UINT64              BaudRate;
> +  UINT32              ReceiveFifoDepth;
> +  EFI_PARITY_TYPE     Parity;
> +  UINT8               DataBits;
> +  EFI_STOP_BITS_TYPE  StopBits;
> +
> +  mUartBase        = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase);
> +  BaudRate         = FixedPcdGet64 (PcdUartDefaultBaudRate);
> +  ReceiveFifoDepth = 0;         // Use default FIFO depth
> +  Parity           = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
> +  DataBits         = FixedPcdGet8 (PcdUartDefaultDataBits);
> +  StopBits         = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
> +
> +  Status = PL011UartInitializePort (mUartBase, FixedPcdGet32 (PL011UartClkInHz),
> +             &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  //
> +  // Register for the virtual address change event
> +  //
> +  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
> +                  VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChangeGuid,
> +                  &mVirtualAddressChangeEvent);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  //
> +  // Declare the UART MMIO region as EFI_MEMORY_RUNTIME
> +  //
> +  Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, mUartBase,
> +                  SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB,
> +                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  Handle = NULL;
> +  Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
> +                  &gEdkiiRuntimeDebugOutputProtocolGuid, &mRuntimeDebugOutput,
> +                  NULL);
> +  if (EFI_ERROR (Status)) {
> +    goto CloseEvent;
> +  }
> +
> +  return EFI_SUCCESS;
> +
> +CloseEvent:
> +  gBS->CloseEvent (mVirtualAddressChangeEvent);
> +
> +  return Status;
> +}
> diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
> new file mode 100644
> index 000000000000..28a8e514552e
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
> @@ -0,0 +1,62 @@
> +#/** @file
> +#  Runtime driver to produce debug output on a PL011 UART
> +#
> +#  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.
> +#
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001A
> +  BASE_NAME                      = PL011RuntimeDebugOutputDxe
> +  FILE_GUID                      = 494297ca-9205-463a-aae5-215ffd067cbb
> +  MODULE_TYPE                    = DXE_RUNTIME_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = PL011RuntimeDebugOutputDxeEntry
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +#  VALID_ARCHITECTURES           = AARCH64 ARM
> +#
> +
> +[Sources.common]
> +  PL011RuntimeDebugOutputDxe.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DxeServicesTableLib
> +  PcdLib
> +  PL011UartLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiRuntimeLib
> +
> +[Guids]
> +  gEfiEventVirtualAddressChangeGuid             ## CONSUMES # Event
> +
> +[Protocols]
> +  gEdkiiRuntimeDebugOutputProtocolGuid          ## PROTOCOL ALWAYS_PRODUCED
> +
> +[FixedPcd]
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
> +  gArmPlatformTokenSpaceGuid.PL011UartClkInHz
> +
> +[Depex]
> +  TRUE
> --
> 2.11.0
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver
  2018-04-20 14:14     ` Alexei Fedorov
@ 2018-04-23 10:31       ` Ard Biesheuvel
  0 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-04-23 10:31 UTC (permalink / raw)
  To: Alexei Fedorov
  Cc: Leif Lindholm, eric.dong@intel.com, edk2-devel@lists.01.org,
	liming.gao@intel.com, heyi.guo@linaro.org,
	michael.d.kinney@intel.com, lersek@redhat.com,
	star.zeng@intel.com

On 20 April 2018 at 16:14, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> Leif, Ard
>
>
> When do you plan to push this patch?
>

I don't. There was some pushback from the Intel guys regarding the use
of status codes instead of a runtime debug protocol, and nobody came
forward to say that they wanted this.

If you are interested in this functionality, please respond to the 0/4
cover letter and explain why this approach is preferred over status
codes.

Thanks,
Ard.


> ________________________________
> From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Leif
> Lindholm <leif.lindholm@linaro.org>
> Sent: 15 March 2018 12:49:27
> To: Ard Biesheuvel
> Cc: eric.dong@intel.com; edk2-devel@lists.01.org; liming.gao@intel.com;
> heyi.guo@linaro.org; michael.d.kinney@intel.com; lersek@redhat.com;
> star.zeng@intel.com
> Subject: Re: [edk2] [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug
> driver
>
> On Thu, Mar 01, 2018 at 06:11:42PM +0000, Ard Biesheuvel wrote:
>> Implement the new runtime debug output protocol on top of a PL011 UART.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> LGTM
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>
>> ---
>>
>> ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
>> | 144 ++++++++++++++++++++
>>
>> ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
>> |  62 +++++++++
>>  2 files changed, 206 insertions(+)
>>
>> diff --git
>> a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
>> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
>> new file mode 100644
>> index 000000000000..155b2c50d463
>> --- /dev/null
>> +++
>> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c
>> @@ -0,0 +1,144 @@
>> +/** @file
>> +  Runtime driver to produce debug output on a PL011 UART
>> +
>> +  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.
>> +
>> +**/
>> +
>> +#include <PiDxe.h>
>> +#include <Library/DxeServicesTableLib.h>
>> +#include <Library/PL011UartLib.h>
>> +#include <Library/UefiDriverEntryPoint.h>
>> +#include <Library/UefiBootServicesTableLib.h>
>> +#include <Library/UefiRuntimeLib.h>
>> +#include <Protocol/RuntimeDebugOutput.h>
>> +
>> +STATIC UINTN        mUartBase;
>> +STATIC EFI_EVENT    mVirtualAddressChangeEvent;
>> +
>> +/**
>> +  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.
>> +
>> +**/
>> +STATIC
>> +UINTN
>> +PL011RuntimeDebugOutputWrite (
>> +  IN  EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL  *This,
>> +  IN  UINT8                               *Buffer,
>> +  IN  UINTN                               NumberOfBytes
>> +  )
>> +{
>> +  return PL011UartWrite (mUartBase, Buffer, NumberOfBytes);
>> +}
>> +
>> +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = {
>> +  PL011RuntimeDebugOutputWrite
>> +};
>> +
>> +/**
>> +  Fixup internal data so that EFI can be called in virtual mode.
>> +
>> +  @param[in]    Event   The Event that is being processed
>> +  @param[in]    Context Event Context
>> +**/
>> +STATIC
>> +VOID
>> +EFIAPI
>> +VirtualNotifyEvent (
>> +  IN EFI_EVENT        Event,
>> +  IN VOID             *Context
>> +  )
>> +{
>> +  EfiConvertPointer (0x0, (VOID **)&mUartBase);
>> +}
>> +
>> +EFI_STATUS
>> +EFIAPI
>> +PL011RuntimeDebugOutputDxeEntry (
>> +  IN EFI_HANDLE        ImageHandle,
>> +  IN EFI_SYSTEM_TABLE  *SystemTable
>> +  )
>> +{
>> +  EFI_STATUS          Status;
>> +  EFI_HANDLE          Handle;
>> +  UINT64              BaudRate;
>> +  UINT32              ReceiveFifoDepth;
>> +  EFI_PARITY_TYPE     Parity;
>> +  UINT8               DataBits;
>> +  EFI_STOP_BITS_TYPE  StopBits;
>> +
>> +  mUartBase        = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase);
>> +  BaudRate         = FixedPcdGet64 (PcdUartDefaultBaudRate);
>> +  ReceiveFifoDepth = 0;         // Use default FIFO depth
>> +  Parity           = (EFI_PARITY_TYPE)FixedPcdGet8
>> (PcdUartDefaultParity);
>> +  DataBits         = FixedPcdGet8 (PcdUartDefaultDataBits);
>> +  StopBits         = (EFI_STOP_BITS_TYPE) FixedPcdGet8
>> (PcdUartDefaultStopBits);
>> +
>> +  Status = PL011UartInitializePort (mUartBase, FixedPcdGet32
>> (PL011UartClkInHz),
>> +             &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits,
>> &StopBits);
>> +  if (EFI_ERROR (Status)) {
>> +    return Status;
>> +  }
>> +
>> +  //
>> +  // Register for the virtual address change event
>> +  //
>> +  Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
>> +                  VirtualNotifyEvent, NULL,
>> &gEfiEventVirtualAddressChangeGuid,
>> +                  &mVirtualAddressChangeEvent);
>> +  if (EFI_ERROR (Status)) {
>> +    return Status;
>> +  }
>> +
>> +  //
>> +  // Declare the UART MMIO region as EFI_MEMORY_RUNTIME
>> +  //
>> +  Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo,
>> mUartBase,
>> +                  SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
>> +  if (EFI_ERROR (Status)) {
>> +    goto CloseEvent;
>> +  }
>> +
>> +  Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB,
>> +                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
>> +  if (EFI_ERROR (Status)) {
>> +    goto CloseEvent;
>> +  }
>> +
>> +  Handle = NULL;
>> +  Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
>> +                  &gEdkiiRuntimeDebugOutputProtocolGuid,
>> &mRuntimeDebugOutput,
>> +                  NULL);
>> +  if (EFI_ERROR (Status)) {
>> +    goto CloseEvent;
>> +  }
>> +
>> +  return EFI_SUCCESS;
>> +
>> +CloseEvent:
>> +  gBS->CloseEvent (mVirtualAddressChangeEvent);
>> +
>> +  return Status;
>> +}
>> diff --git
>> a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
>> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
>> new file mode 100644
>> index 000000000000..28a8e514552e
>> --- /dev/null
>> +++
>> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf
>> @@ -0,0 +1,62 @@
>> +#/** @file
>> +#  Runtime driver to produce debug output on a PL011 UART
>> +#
>> +#  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.
>> +#
>> +#
>> +#**/
>> +
>> +[Defines]
>> +  INF_VERSION                    = 0x0001001A
>> +  BASE_NAME                      = PL011RuntimeDebugOutputDxe
>> +  FILE_GUID                      = 494297ca-9205-463a-aae5-215ffd067cbb
>> +  MODULE_TYPE                    = DXE_RUNTIME_DRIVER
>> +  VERSION_STRING                 = 1.0
>> +  ENTRY_POINT                    = PL011RuntimeDebugOutputDxeEntry
>> +
>> +#
>> +# The following information is for reference only and not required by the
>> build tools.
>> +#
>> +#  VALID_ARCHITECTURES           = AARCH64 ARM
>> +#
>> +
>> +[Sources.common]
>> +  PL011RuntimeDebugOutputDxe.c
>> +
>> +[Packages]
>> +  ArmPlatformPkg/ArmPlatformPkg.dec
>> +  MdeModulePkg/MdeModulePkg.dec
>> +  MdePkg/MdePkg.dec
>> +
>> +[LibraryClasses]
>> +  DxeServicesTableLib
>> +  PcdLib
>> +  PL011UartLib
>> +  UefiBootServicesTableLib
>> +  UefiDriverEntryPoint
>> +  UefiRuntimeLib
>> +
>> +[Guids]
>> +  gEfiEventVirtualAddressChangeGuid             ## CONSUMES # Event
>> +
>> +[Protocols]
>> +  gEdkiiRuntimeDebugOutputProtocolGuid          ## PROTOCOL
>> ALWAYS_PRODUCED
>> +
>> +[FixedPcd]
>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
>> +  gArmPlatformTokenSpaceGuid.PL011UartClkInHz
>> +
>> +[Depex]
>> +  TRUE
>> --
>> 2.11.0
>>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-23 10:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/4] MdeModulePkg: introduce runtime debug output protocol Ard Biesheuvel
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox