ArmPlatformPkg: Initialize Serial Port Before Writing

PrePeiCore and Sec directly write the firmware version to the serial port.
They relies on another component to initialize the serial port, however
in certain configurations (such as release builds that don't use a
DebugLib that initializes the serial port), the serial port can be
uninitialized at this point, causing a crash when SerialPortWrite
is called here.

This patch updates PrePeiCore and Sec to call SerialPortInitialize before
calling SerialPortWrite directly, which follows the pattern of
other serial port writes. It is accepted to call the initialization
routine multiple times, it is supposed to dump out if the serial
port is already initialized.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
This commit is contained in:
Oliver Smith-Denny 2024-08-21 13:59:15 -07:00 committed by mergify[bot]
parent ded4191e10
commit 39a999eb1d
2 changed files with 8 additions and 0 deletions

View File

@ -76,6 +76,10 @@ PrintFirmwareVersion (
__TIME__,
__DATE__
);
// Because we are directly bit banging the serial port instead of going through the DebugLib, we need to make sure
// the serial port is initialized before we write to it
SerialPortInitialize ();
SerialPortWrite ((UINT8 *)Buffer, CharCount);
}

View File

@ -139,6 +139,10 @@ PrintFirmwareVersion (
__TIME__,
__DATE__
);
// Because we are directly bit banging the serial port instead of going through the DebugLib, we need to make sure
// the serial port is initialized before we write to it
SerialPortInitialize ();
SerialPortWrite ((UINT8 *)Buffer, CharCount);
}