diff --git a/BootloaderCorePkg/BootloaderCorePkg.dsc b/BootloaderCorePkg/BootloaderCorePkg.dsc index 040ee959..f96d0fae 100644 --- a/BootloaderCorePkg/BootloaderCorePkg.dsc +++ b/BootloaderCorePkg/BootloaderCorePkg.dsc @@ -414,6 +414,7 @@ PayloadPkg/FirmwareUpdate/FirmwareUpdate.inf { gPlatformCommonLibTokenSpaceGuid.PcdDebugOutputDeviceMask | $(DEBUG_OUTPUT_DEVICE_MASK) + gPlatformCommonLibTokenSpaceGuid.PcdConsoleOutDeviceMask | ($(CONSOLE_OUT_DEVICE_MASK) + 0x02) MemoryAllocationLib | BootloaderCommonPkg/Library/FullMemoryAllocationLib/FullMemoryAllocationLib.inf PayloadEntryLib | PayloadPkg/Library/PayloadEntryLib/PayloadEntryLib.inf diff --git a/PayloadPkg/FirmwareUpdate/FirmwareUpdate.c b/PayloadPkg/FirmwareUpdate/FirmwareUpdate.c index d79fe940..8809cc12 100644 --- a/PayloadPkg/FirmwareUpdate/FirmwareUpdate.c +++ b/PayloadPkg/FirmwareUpdate/FirmwareUpdate.c @@ -26,6 +26,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include +#include +#include #include "FirmwareUpdateHelper.h" UINT32 mSblImageBiosRgnOffset; @@ -1205,6 +1208,47 @@ EndFirmwareUpdate ( return Status; } +/** + Initialize platform console. + + @retval EFI_NOT_FOUND No additional console was found. + @retval EFI_SUCCESS Console has been initialized successfully. + @retval Others There is error during console initialization. +**/ +EFI_STATUS +InitConsole ( + VOID +) +{ + EFI_STATUS Status; + UINT32 Height; + UINT32 Width; + UINT32 OffX; + UINT32 OffY; + EFI_PEI_GRAPHICS_INFO_HOB *GfxInfoHob; + + Status = EFI_NOT_FOUND; + + if (PcdGet32 (PcdConsoleOutDeviceMask) & ConsoleOutFrameBuffer) { + GfxInfoHob = (EFI_PEI_GRAPHICS_INFO_HOB *)GetGuidHobData (NULL, NULL, &gEfiGraphicsInfoHobGuid); + if (GfxInfoHob != NULL) { + Width = GfxInfoHob->GraphicsMode.HorizontalResolution; + Height = GfxInfoHob->GraphicsMode.VerticalResolution; + if ((PcdGet32 (PcdFrameBufferMaxConsoleWidth) > 0) && (Width > PcdGet32 (PcdFrameBufferMaxConsoleWidth))) { + Width = PcdGet32 (PcdFrameBufferMaxConsoleWidth); + } + if ((PcdGet32 (PcdFrameBufferMaxConsoleHeight) > 0) && (Height > PcdGet32 (PcdFrameBufferMaxConsoleHeight))) { + Height = PcdGet32 (PcdFrameBufferMaxConsoleHeight); + } + OffX = (GfxInfoHob->GraphicsMode.HorizontalResolution - Width) / 2; + OffY = (GfxInfoHob->GraphicsMode.VerticalResolution - Height) / 2; + Status = InitFrameBufferConsole (GfxInfoHob, Width, Height, OffX, OffY); + } + } + + return Status; +} + /** Payload main entry. @@ -1227,7 +1271,12 @@ PayloadMain ( EFI_STATUS Status; UINT32 BiosRgnSize; - DEBUG ((DEBUG_INFO, "Starting Firmware Update\n")); + // + // Prepare Console Print + // + InitConsole (); + ConsolePrint ("Starting Firmware Update\n"); + // // Initialize boot media to look for the capsule image // @@ -1239,6 +1288,7 @@ PayloadMain ( FlashMap = GetFlashMapPtr(); if (FlashMap == NULL) { DEBUG((DEBUG_ERROR, "Could not get flash map\n")); + Status = EFI_NO_MAPPING; goto EndOfFwu; } @@ -1248,6 +1298,7 @@ PayloadMain ( Status = GetComponentInfoByPartition (FLASH_MAP_SIG_BLRESERVED, FALSE, &RsvdBase, &RsvdSize); if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "Could not get component information for bootloader reserved region\n")); + Status = EFI_NO_MAPPING; goto EndOfFwu; } @@ -1296,10 +1347,8 @@ EndOfFwu: // // Terminate firmware update // - Status = EndFirmwareUpdate (); - if (EFI_ERROR (Status)) { - DEBUG((DEBUG_ERROR, "EndFirmwareUpdate, Status = 0x%x\n", Status)); - } + ConsolePrint ("Exiting Firmware Update (Status: %r)\n", Status); + EndFirmwareUpdate (); Reboot (EfiResetCold); } diff --git a/PayloadPkg/FirmwareUpdate/FirmwareUpdate.inf b/PayloadPkg/FirmwareUpdate/FirmwareUpdate.inf index b1a7d892..4ad46a55 100644 --- a/PayloadPkg/FirmwareUpdate/FirmwareUpdate.inf +++ b/PayloadPkg/FirmwareUpdate/FirmwareUpdate.inf @@ -50,6 +50,7 @@ ContainerLib StringSupportLib BootOptionLib + TimerLib [Guids] gLoaderMemoryMapInfoGuid @@ -60,6 +61,7 @@ gFlashMapInfoGuid gBootLoaderVersionFileGuid gBootLoaderVersionGuid + gEfiGraphicsInfoHobGuid [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress @@ -69,6 +71,9 @@ gPlatformCommonLibTokenSpaceGuid.PcdLowestSupportedFwVer gPayloadTokenSpaceGuid.PcdCsmeUpdateEnabled gPlatformCommonLibTokenSpaceGuid.PcdCompSignHashAlg + gPlatformCommonLibTokenSpaceGuid.PcdConsoleOutDeviceMask + gPlatformCommonLibTokenSpaceGuid.PcdFrameBufferMaxConsoleWidth + gPlatformCommonLibTokenSpaceGuid.PcdFrameBufferMaxConsoleHeight [Depex] TRUE diff --git a/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c b/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c index 715e3439..1decb1f2 100644 --- a/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c +++ b/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "FirmwareUpdateHelper.h" #include @@ -425,16 +427,16 @@ UpdateBootRegion ( UpdateBlockSize = SIZE_64KB; } } - DEBUG ((DEBUG_INIT, "Updating 0x%08llx, Size:0x%05x\n", UpdateAddress, UpdateBlockSize)); + ConsolePrint ("Updating 0x%08llx, Size:0x%06x\n", UpdateAddress, UpdateBlockSize); Status = UpdateRegionBlock (UpdateAddress, Buffer, UpdateBlockSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "\nFailed! Address=0x%08llx, Status = %r\n", UpdateAddress, Status)); + ConsolePrint ("\nFailed at address 0x%08llx, status: %r\n", UpdateAddress, Status); return Status; } UpdateAddress += UpdateBlockSize; Buffer += UpdateBlockSize; UpdatedSize += UpdateBlockSize; - DEBUG ((DEBUG_INIT, "\nFinished %3d%%\n", (WrittenSize + UpdatedSize) * 100 / TotalSize)); + ConsolePrint ("\nFinished %3d%%\n", (WrittenSize + UpdatedSize) * 100 / TotalSize); } return EFI_SUCCESS; @@ -1052,7 +1054,8 @@ Reboot ( IN EFI_RESET_TYPE ResetType ) { - DEBUG ((DEBUG_INFO, "Reset required to proceed with the firmware update.\n\n")); + ConsolePrint("Reset required to proceed.\n\n"); + MicroSecondDelay (3000000); ResetSystem (ResetType); CpuDeadLoop (); } diff --git a/Platform/QemuBoardPkg/Script/TestCases/firmware_update.py b/Platform/QemuBoardPkg/Script/TestCases/firmware_update.py index 2f2f5f8e..ff4d3b00 100644 --- a/Platform/QemuBoardPkg/Script/TestCases/firmware_update.py +++ b/Platform/QemuBoardPkg/Script/TestCases/firmware_update.py @@ -72,7 +72,7 @@ def get_check_lines (bp = 0, mode = 0): "===========Read Capsule Image============", "Boot from partition %s, update partition %s" % (bp_ab[0], bp_ab[1]), "Finished 100%", - "Reset required to proceed with the firmware update" + "Reset required to proceed" ]) return lines