Skip to content

Commit

Permalink
Animate Combo Message & New Timeout Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Robotix22 committed Dec 31, 2024
1 parent 9afea94 commit 2b38a54
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ EFI_DEVICE_PATH_PROTOCOL**
EFIAPI
DeviceBootManagerAfterConsole ()
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *mConsoleOutHandle;
EFI_STATUS Status;

// Check if System is Good to Go
MsPreBootChecks ();
Expand All @@ -401,56 +400,6 @@ DeviceBootManagerAfterConsole ()
DEBUG ((EFI_D_ERROR, "%a: Failed to Display Boot Logo! Status = %r\n", __FUNCTION__, Status));
}

// Locate Console Out Handle
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID *)&mConsoleOutHandle);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "%a: Failed to Locate Console Out Protocol! Status %r\n", __FUNCTION__, Status));
} else {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
CHAR16 *ComboMessage;

// Combo Message
if (FixedPcdGetPtr(PcdSpecialApp) == "NULL") {
#if HAS_BUILD_IN_KEYBOARD == 1
ComboMessage = L"[Escape] UEFI Menu";
#else
ComboMessage = L"[Volume Up] UEFI Menu";
#endif
} else {
// More Memory for Combo Message
ComboMessage = AllocateZeroPool (150);
if (ComboMessage == NULL) {
DEBUG ((EFI_D_ERROR, "Failed to Allocate Memory for Combo Message! Status = %r\n", Status));
goto exit;
}

#if HAS_BUILD_IN_KEYBOARD == 1
UnicodeSPrint (ComboMessage, 150, L"[Escape] UEFI Menu - [Delete] %a", FixedPcdGetPtr(PcdSpecialAppName));
#else
UnicodeSPrint (ComboMessage, 150, L"[Volume Up] UEFI Menu - [Volume Down] %a", FixedPcdGetPtr(PcdSpecialAppName));
#endif
}

// Set Pos for Combo Message
UINTN XPos = (mConsoleOutHandle->Mode->Info->HorizontalResolution - StrLen(ComboMessage) * EFI_GLYPH_WIDTH) / 2;
UINTN YPos = (mConsoleOutHandle->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Set Color for the Message
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0x00;
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;

// Display Combo Message
PrintXY (XPos, YPos, &White, &Black, ComboMessage);

exit:
if (FixedPcdGetPtr(PcdSpecialApp) != "NULL") {
if (ComboMessage != NULL) {
FreePool (ComboMessage);
}
}
}

return GetPlatformConnectList ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
gMsOSKProtocolGuid
gMsSWMProtocolGuid

[FixedPcd]
gSiliciumPkgTokenSpaceGuid.PcdSpecialApp
gSiliciumPkgTokenSpaceGuid.PcdSpecialAppName

[Pcd]
gPcBdsPkgTokenSpaceGuid.PcdPowerAndThermalRetries
gPcBdsPkgTokenSpaceGuid.PcdShutdownGraphicDisplayTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <Library/HobLib.h>
#include <Library/PerformanceLib.h>
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>

#include <Protocol/GraphicsOutput.h>

#include <Guid/MemoryTypeInformation.h>
#include <Guid/MemoryOverwriteControl.h>
Expand Down Expand Up @@ -302,8 +305,15 @@ PlatformBootManagerAfterConsole ()
ProcessCapsules ();
}

STATIC UINTN XPos = 0;
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL *mGOPProtocol = NULL;
//
// Static Global Variables
//
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL *mGopProtocol = NULL;
STATIC CHAR16 *ComboMessage = NULL;
STATIC UINTN FormXPos = 0;
STATIC UINTN FormYPos = 0;
STATIC UINTN TextXPos = 0;
STATIC UINTN TextYPos = 0;

VOID
EFIAPI
Expand All @@ -312,46 +322,127 @@ PlatformBootManagerWaitCallback (UINT16 TimeoutRemain)
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;

// Locate GOP Protocol
if (mGOPProtocol == NULL) {
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID *)&mGOPProtocol);
// Get Timeout Time
UINT16 Timeout = PcdGet16 (PcdPlatformBootTimeOut);

// Locate GOP Protocol
if (!mGopProtocol) {
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID *)&mGopProtocol);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "%a: Failed to Locate GOP Protocol! Status = %r\n", __FUNCTION__, Status));
return;
}
}

// Get Screen Size
UINT32 ScreenWidth = mGOPProtocol->Mode->Info->HorizontalResolution;
UINT32 ScreenHeight = mGOPProtocol->Mode->Info->VerticalResolution;
// Get Screen Resolution
UINT32 ScreenWidth = mGopProtocol->Mode->Info->HorizontalResolution;
UINT32 ScreenHeight = mGopProtocol->Mode->Info->VerticalResolution;

// Default Y Position
UINTN YPos = ScreenHeight * 48 / 50;
// Set Timeout Bar Size
UINTN Width = ScreenWidth * 40 / 100 - 200;
UINTN Height = Width * 10 / 100;

// Get Timeout Time
UINT16 Timeout = PcdGet16(PcdPlatformBootTimeOut);
// Set Timeout Bar Position
if ((!FormXPos && !FormYPos) || !TimeoutRemain) {
FormXPos = (ScreenWidth - Width) / 2;
FormYPos = (ScreenHeight + Width + 200) / 2;
}

if (!TimeoutRemain) {
SetMem (&Color, sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
// Set Combo Message
if (ComboMessage == NULL) {
if (FixedPcdGetPtr (PcdSpecialApp) == "NULL") {
#if HAS_BUILD_IN_KEYBOARD == 1
ComboMessage = L"[Escape] UEFI Menu";
#else
ComboMessage = L"[Volume Up] UEFI Menu";
#endif
} else {
// Allocate Memory
ComboMessage = AllocateZeroPool (150);
if (ComboMessage == NULL) {
DEBUG ((EFI_D_ERROR, "Failed to Allocate Memory for Combo Message!\n"));
goto Form;
}

// Clear Combo Message & Timeout Bar
Status = mGOPProtocol->Blt (mGOPProtocol, &Color, EfiBltVideoFill, 0, 0, 0, YPos - EFI_GLYPH_HEIGHT, ScreenWidth, ScreenHeight - (YPos - EFI_GLYPH_HEIGHT), ScreenHeight * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "%a: Failed to Clear Combo Message! Status = %r\n", __FUNCTION__, Status));
#if HAS_BUILD_IN_KEYBOARD == 1
UnicodeSPrint (ComboMessage, 150, L"[Escape] UEFI Menu - [Delete] %a", FixedPcdGetPtr (PcdSpecialAppName));
#else
UnicodeSPrint (ComboMessage, 150, L"[Volume Up] UEFI Menu - [Volume Down] %a", FixedPcdGetPtr (PcdSpecialAppName));
#endif
}

// Set Combo Message Position
TextXPos = (ScreenWidth - StrLen (ComboMessage) * EFI_GLYPH_WIDTH) / 2;
TextYPos = (mGopProtocol->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Animate Combo Message
for (UINT8 i = 0; i < 255; i++) {
// Set New Foreground Color
Color.Blue = Color.Green = Color.Red = i;
Color.Reserved = 0xFF;

// Print Combo Message
PrintXY (TextXPos, TextYPos, &Color, NULL, ComboMessage);

// Wait a Bit
gBS->Stall (3000);
}
} else {
// Set Timeout Bar Color
Color.Blue = Color.Green = Color.Red = Color.Reserved = 0xFF;
}

for (UINTN i = 0; i < ScreenWidth / Timeout; i++) {
// Draw Timeout Bar
mGOPProtocol->Blt (mGOPProtocol, &Color, EfiBltVideoFill, 0, 0, XPos, YPos, 1, ScreenHeight / 50, (ScreenHeight / 50) * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
Form:
// Draw Background
if (TimeoutRemain == Timeout) {
for (UINT8 i = 0; i < 34; i++) {
// Set New Background Color
Color.Blue = Color.Green = Color.Red = i;
Color.Reserved = 0xFF;

XPos++;
// Draw New Color
mGopProtocol->Blt (mGopProtocol, &Color, EfiBltVideoFill, 0, 0, FormXPos, FormYPos, Width, Height, 0);

// Wait
gBS->Stall (Timeout * 1000000 / ScreenWidth);
// Wait a Bit
gBS->Stall (30000);
}
}

// Clear Timeout Bar
if (!TimeoutRemain) {
for (UINT8 i = 255; i > 0; i--) {
// Set New Foreground Color
Color.Blue = Color.Green = Color.Red = i;
Color.Reserved = 0xFF;

// Print Combo Message
if (ComboMessage != NULL) {
PrintXY (TextXPos, TextYPos, &Color, NULL, ComboMessage);
}

// Draw New Color
mGopProtocol->Blt (mGopProtocol, &Color, EfiBltVideoFill, 0, 0, FormXPos, FormYPos, Width, Height, 0);

// Wait a Bit
gBS->Stall (3000);
}

if (FixedPcdGetPtr (PcdSpecialApp) != "NULL") {
if (ComboMessage != NULL) {
FreePool (ComboMessage);
}
}

return;
}

// Set Foreground Color
Color.Blue = Color.Green = Color.Red = Color.Reserved = 0xFF;

// Draw Foreground
for (UINTN i = 0; i < Width / Timeout; i++) {
mGopProtocol->Blt (mGopProtocol, &Color, EfiBltVideoFill, 0, 0, FormXPos, FormYPos, 1, Height, 0);

FormXPos++;

// Wait
gBS->Stall (Timeout * 1000000 / Width);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
MsCorePkg/MsCorePkg.dec
SiliciumPkg/SiliciumPkg.dec

[LibraryClasses]
DebugLib
Expand All @@ -38,10 +39,15 @@
HobLib
PerformanceLib
PcdLib
PrintLib

[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut

[FixedPcd]
gSiliciumPkgTokenSpaceGuid.PcdSpecialApp
gSiliciumPkgTokenSpaceGuid.PcdSpecialAppName

[Protocols]
gEfiPciRootBridgeIoProtocolGuid
gEfiDxeSmmReadyToLockProtocolGuid
Expand Down

0 comments on commit 2b38a54

Please sign in to comment.