[edk2-devel] [PATCH 0/9] ArmVirtPkg: support two PL011 UARTs

Laszlo Ersek lersek at redhat.com
Sun Oct 8 15:39:03 UTC 2023


This ArmVirtPkg series can be fetched from:

  repo:   https://pagure.io/lersek/edk2.git
  branch: armvirt-dual-serial @ 65ee08413595

The series does the following:

- It centralizes (and cleans up) two FDT parsing actions, namely looking
  up all serial ports, and looking up the /chosen "stdout-path" serial
  port, in a new library class and instance.

- It rebases Fdt16550SerialPortHookLib, EarlyFdtPL011SerialPortLib and
  PlatformPeiLib to the new library.

- If QEMU specifies just one PL011 UART, then this patch set is
  unobservable from the outside.

- If QEMU specifies (at least) two PL011 UARTs, then we distinguish a
  "chosen" one, and a (first) "non-chosen" one:

  - Both EarlyFdtPL011SerialPortLib, and (PlatformPeiLib +
    FdtPL011SerialPortLib), target the "chosen" PL011. The consequence
    of this is that (a) direct SerialPortLib traffic, (b) the dependent
    SerialIo (SerialDxe) protocol traffic, and (c) the dependent UEFI
    console traffic, all occcur on the same PL011, and do so regardless
    of the firmware phase. Furthermore, (d) the Linux serial console
    traffic is directed to the same PL011 as well. In total, the
    "chosen" PL011 UART becomes "the console", covering both firmware
    and Linux.

  - Three new DebugLib instances -- namely Flash, RAM, and DXE Runtime
    instances of "DebugLibFdtPL011Uart" -- target the (first)
    "non-chosen" PL011. The consequence is that DebugLib output is
    hermetically separated from the above-mentioned console, mirroring
    the isa-debugcon situation with x86 OVMF.

Peter's QEMU patch set that this series interoperates with is at:

  repo:   https://git.linaro.org/people/pmaydell/qemu-arm.git
  branch: uart-edk-investigation @ 66bff4241bf8

See the larger background, and my detailed test results -- using
"ArmVirtQemu.dsc" -- in the following thread:

  EDK2 ArmVirtQemu behaviour with multiple UARTs
  http://mid.mail-archive.com/CAFEAcA_P5aOTQnM2ARYgR5WvKouvndMbX95XNmDsS0KTxMkMMw@mail.gmail.com
  https://listman.redhat.com/archives/edk2-devel-archive/2023-September/068241.html
  https://edk2.groups.io/g/devel/message/108941

For my testing, I rebased Peter's set on more recent QEMU commit
36e9aab3c569. Also, importantly, Peter's last patch 66bff4241bf8 ("virt:
Reverse order of UART dtb nodes", 2023-09-21) is *indifferent* regarding
my test results (which shows that the ordering of the two PL011 UARTs in
the DTB does not matter, with this edk2 series applied). See more on
that in the above-noted thread.

"ArmVirtKvmTool.dsc" and "ArmVirtXen.dsc" are not supposed to be visibly
affected by this series; I test-built them, and checked the library
resolutions before/after in their build report files (no change).
Runtime regression testing with these platforms would be welcome.

I also test-built "ArmVirtCloudHv.dsc" and "ArmVirtQemuKernel.dsc".
Those *are* supposed to receive the same feature, but I couldn't /
didn't boot them, respectively.

I've formatted the patches with "--find-copies-harder", because (a) that
makes for an easier reading, and (b) leaves the patches applicable from
the list. The base commit is noted at the end of this message.

Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
Cc: Gerd Hoffmann <kraxel at redhat.com>
Cc: Julien Grall <julien at xen.org>
Cc: Leif Lindholm <quic_llindhol at quicinc.com>
Cc: Peter Maydell <peter.maydell at linaro.org>
Cc: Sami Mujawar <sami.mujawar at arm.com>

(I've not Cc'd Peter on the patches themselves, but I'm Cc'ing him on
the cover letter.)

Thanks,
Laszlo

Laszlo Ersek (9):
  ArmVirtPkg: introduce FdtSerialPortAddressLib
  ArmVirtPkg/Fdt16550SerialPortHookLib: rebase to
    FdtSerialPortAddressLib
  ArmVirtPkg: adjust whitespace in block scope declarations
  ArmVirtPkg: adhere to the serial port selected by /chosen
    "stdout-path"
  ArmVirtPkg: store separate console and debug PL011 addresses in GUID
    HOB
  ArmVirtPkg: introduce DebugLibFdtPL011Uart Flash instance
  ArmVirtPkg: introduce DebugLibFdtPL011Uart RAM instance
  ArmVirtPkg: introduce DebugLibFdtPL011Uart DXE Runtime instance
  ArmVirtPkg: steer DebugLib output away from SerialPortLib+console
    traffic

 ArmVirtPkg/ArmVirt.dsc.inc                                                                    |  14 +-
 ArmVirtPkg/ArmVirtKvmTool.dsc                                                                 |  11 +
 ArmVirtPkg/ArmVirtPkg.dec                                                                     |   1 +
 ArmVirtPkg/ArmVirtXen.dsc                                                                     |  11 +
 ArmVirtPkg/Include/Guid/EarlyPL011BaseAddress.h                                               |  15 +-
 ArmVirtPkg/Include/Library/FdtSerialPortAddressLib.h                                          |  83 +++++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash.inf                         |  54 +++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.inf                           |  60 +++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011Uart.inf                    |  61 +++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Flash.c                                               | 107 ++++++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.c                                                 | 124 ++++++++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.h                                                 |  18 ++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c                                       |  27 +++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c                                             |  88 +++++++
 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Write.h                                               |  39 +++
 ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLib.c                 |  88 +------
 ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLib.inf               |   3 +-
 ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c                         |  90 +++----
 ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf                       |   3 +-
 ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c                              |  20 +-
 ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.c                          | 256 ++++++++++++++++++++
 ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.inf                        |  27 +++
 ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c                                            | 108 ++++++---
 ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf                                          |   2 +
 {MdePkg/Library/BaseDebugLibSerialPort => ArmVirtPkg/Library/DebugLibFdtPL011Uart}/DebugLib.c |  41 ++--
 25 files changed, 1128 insertions(+), 223 deletions(-)
 copy {MdePkg/Library/BaseDebugLibSerialPort => ArmVirtPkg/Library/DebugLibFdtPL011Uart}/DebugLib.c (89%)
 create mode 100644 ArmVirtPkg/Include/Library/FdtSerialPortAddressLib.h
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash.inf
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.inf
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011Uart.inf
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Flash.c
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.c
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.h
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c
 create mode 100644 ArmVirtPkg/Library/DebugLibFdtPL011Uart/Write.h
 create mode 100644 ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.c
 create mode 100644 ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.inf


base-commit: 4ddd8ac3a29d9c5974a19f36c1dc5896d813dc6e


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109394): https://edk2.groups.io/g/devel/message/109394
Mute This Topic: https://groups.io/mt/101834880/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list