Skip to content

Commit

Permalink
[CHERRY-PICK] ArmPlatformPkg: Initialize Serial Port Before Writing
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Oliver Smith-Denny authored and os-d committed Aug 29, 2024
1 parent f3c67bd commit fce88db
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ArmPlatformPkg/PrePeiCore/PrePeiCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit fce88db

Please sign in to comment.