edk2/ArmVirtPkg/Library/PlatformPeiLib
Luigi Leonardi f4bbef1dd7 ArmVirtPkg: introduce compile and runtime control of serial debug log level
Add a new PCD `PcdSerialDebugPrintErrorLevel` that overrides the verbosity
set in `DebugPrintErrorLevel` for the serial port debug output and does
not affect memory debug logging.

Accepted values are:
- "silent": DEBUG_ERROR only
- "verbose": use the `DebugPrintErrorLevel` value.
- a hex bitmask (e.g. "0x80000040").

This PCD value can be overridden at runtime using the fw_cfg entry
"opt/org.tianocore/DebugLevel" without rebuilding the firmware.

The runtime override takes priority over the compile-time one. When
neither is set, the serial output uses the compiled-in
PcdDebugPrintErrorLevel.

SEC and PEI_CORE phases do not support this override because they run
from flash, where global variables are not available. Supporting it
would require parsing the device tree on every debug write to locate
the fw_cfg device and read the DebugLevel value — unnecessary overhead
given the low volume of logs in those phases.

ParseSerialDebugLevel() is duplicated as a STATIC function in Flash.c
and PlatformPeiLib.c rather than shared via a header, because EDK2
coding style forbids function definitions in headers. A dedicated
library class would be excessive for a small helper with only two
consumers.

Example QEMU command line:

  -fw_cfg name=opt/org.tianocore/DebugLevel,string=silent
  -fw_cfg name=opt/org.tianocore/DebugLevel,string=verbose
  -fw_cfg name=opt/org.tianocore/DebugLevel,string=0x80000000

Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2026-07-20 16:53:45 +00:00
..
PlatformPeiLib.c ArmVirtPkg: introduce compile and runtime control of serial debug log level 2026-07-20 16:53:45 +00:00
PlatformPeiLib.inf ArmVirtPkg: introduce compile and runtime control of serial debug log level 2026-07-20 16:53:45 +00:00