Skip to content

Commit

Permalink
OcConsoleLib: Improve error reporting with TextoutputBuiltin (acidant…
Browse files Browse the repository at this point in the history
  • Loading branch information
dakanji authored Oct 29, 2020
1 parent 3616f57 commit ba5eea2
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions Library/OcConsoleLib/TextOutputBuiltin.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ RenderResync (

if (Info->HorizontalResolution < TGT_CHAR_WIDTH * 3
|| Info->VerticalResolution < TGT_CHAR_HEIGHT * 3) {
return EFI_DEVICE_ERROR;
return EFI_LOAD_ERROR;
}

if (mCharacterBuffer != NULL) {
Expand All @@ -376,7 +376,7 @@ RenderResync (

mCharacterBuffer = AllocatePool (TGT_CHAR_AREA * sizeof (mCharacterBuffer[0]));
if (mCharacterBuffer == NULL) {
return EFI_DEVICE_ERROR;
return EFI_OUT_OF_RESOURCES;
}

mConsoleGopMode = mGraphicsOutput->Mode->Mode;
Expand Down Expand Up @@ -406,9 +406,10 @@ RenderResync (
STATIC
EFI_STATUS
EFIAPI
AsciiTextReset (
AsciiTextResetEx (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
IN BOOLEAN ExtendedVerification,
IN BOOLEAN Debug
)
{
EFI_STATUS Status;
Expand All @@ -424,6 +425,11 @@ AsciiTextReset (

if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
if (Debug) {
DEBUG ((DEBUG_INFO, "OCC: ASCII Text Reset [HandleProtocolFallback] - %r\n", Status));
return Status;
}

return EFI_DEVICE_ERROR;
}

Expand All @@ -433,15 +439,33 @@ AsciiTextReset (
mForegroundColor.Raw = mGraphicsEfiColors[ARRAY_SIZE (mGraphicsEfiColors) / 2 - 1];

Status = RenderResync (This);
gBS->RestoreTPL (OldTpl);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
if (Debug) {
DEBUG ((DEBUG_INFO, "OCC: ASCII Text Reset [RenderResync] - %r\n", Status));
return Status;
}

return EFI_DEVICE_ERROR;
}

gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}

STATIC
EFI_STATUS
EFIAPI
AsciiTextReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
EFI_STATUS Status;

Status = AsciiTextResetEx (This, ExtendedVerification, FALSE);
return Status;
}

STATIC
EFI_STATUS
EFIAPI
Expand Down Expand Up @@ -470,7 +494,7 @@ AsciiTextOutputString (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -591,7 +615,7 @@ AsciiTextQueryMode (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -628,7 +652,7 @@ AsciiTextSetMode (
Status = RenderResync (This);
gBS->RestoreTPL (OldTpl);
if (EFI_ERROR (Status)) {
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -658,7 +682,7 @@ AsciiTextSetAttribute (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -705,7 +729,7 @@ AsciiTextClearScreen (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -763,7 +787,7 @@ AsciiTextSetCursorPosition (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -802,7 +826,7 @@ AsciiTextEnableCursor (
Status = RenderResync (This);
if (EFI_ERROR (Status)) {
gBS->RestoreTPL (OldTpl);
return Status;
return EFI_DEVICE_ERROR;
}
}

Expand Down Expand Up @@ -942,7 +966,7 @@ OcUseBuiltinTextOutput (

DEBUG ((DEBUG_INFO, "OCC: Using builtin text renderer with %d scale\n", mFontScale));

Status = AsciiTextReset (&mAsciiTextOutputProtocol, TRUE);
Status = AsciiTextResetEx (&mAsciiTextOutputProtocol, TRUE, TRUE);

if (!EFI_ERROR (Status)) {
OcConsoleControlSetMode (Mode);
Expand Down

0 comments on commit ba5eea2

Please sign in to comment.