Skip to content

Commit

Permalink
Add call to HdwPortInitialize() when instantiating logger in DXE (#411)
Browse files Browse the repository at this point in the history
## Description

This change adds a call to AdvancedLoggerHdwPortInitialize() when the
advanced logger is created in the DxeCoreAdvancedLoggerLibConstructor().
Previously, hardware port was only initalized in AdvancedLoggerGetInfo()
if the logging info structure was present at a fixed location or in a
HOB; this would cause writes to the hardware port to potentially fail in
the path where the logger is not initialized until the Constructor is
called.

- [x] Impacts functionality?
- AdvancedLoggerHdwPortInitialize() is now called in the
DxeCoreAdvancedLoggerLibConstructor if the logger is instantiated there.
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

Verified on a platform where this was not working due to missing HdwPort
initialization; verified after this patch that it works as expected.

## Integration Instructions

N/A

---------

Co-authored-by: kuqin12 <[email protected]>
(cherry picked from commit 6d5e0c5)
  • Loading branch information
joschock authored and kuqin12 committed Jan 25, 2024
1 parent 08fb6f1 commit 833db39
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,13 @@ DxeCoreAdvancedLoggerLibConstructor (
LoggerInfo->LogBufferSize = EFI_PAGES_TO_SIZE (FixedPcdGet32 (PcdAdvancedLoggerPages)) - sizeof (ADVANCED_LOGGER_INFO);
LoggerInfo->LogCurrent = LoggerInfo->LogBuffer;
LoggerInfo->HwPrintLevel = FixedPcdGet32 (PcdAdvancedLoggerHdwPortDebugPrintErrorLevel);
mMaxAddress = LoggerInfo->LogBuffer + LoggerInfo->LogBufferSize;
mBufferSize = LoggerInfo->LogBufferSize;
if (LoggerInfo->HdwPortInitialized == FALSE) {
AdvancedLoggerHdwPortInitialize ();
LoggerInfo->HdwPortInitialized = TRUE;
}

mMaxAddress = LoggerInfo->LogBuffer + LoggerInfo->LogBufferSize;
mBufferSize = LoggerInfo->LogBufferSize;
} else {
DEBUG ((DEBUG_ERROR, "%a: Error allocating Advanced Logger Buffer\n", __FUNCTION__));
}
Expand Down

0 comments on commit 833db39

Please sign in to comment.