From 2bebba696521ef53e7f93eee737928cd136b771a Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sat, 21 Dec 2013 00:56:07 +0100 Subject: 'P' support cycling to backgroud colors for debugging --- src/efi/graphics.c | 12 ++++++++++-- src/efi/graphics.h | 3 ++- src/efi/gummiboot.c | 46 +++++++++++++++++++++++++++++++++++----------- src/efi/util.h | 2 ++ 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/efi/graphics.c b/src/efi/graphics.c index d1084cd..81089ed 100644 --- a/src/efi/graphics.c +++ b/src/efi/graphics.c @@ -316,7 +316,8 @@ EFI_STATUS bmp_to_blt(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, return EFI_SUCCESS; } -EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path) { +EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path, + const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) { EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL; UINT8 *content; @@ -332,7 +333,7 @@ EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path) { err = LibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput); if (EFI_ERROR(err)) - goto err; + return err; len = file_read(root_dir, path, &content); if (len < 0) @@ -347,6 +348,13 @@ EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path) { if(dib->y < GraphicsOutput->Mode->Info->VerticalResolution) y_pos = (GraphicsOutput->Mode->Info->VerticalResolution - dib->y) / 2; + if (background) + uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput, + (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)background, + EfiBltVideoFill, 0, 0, 0, 0, + GraphicsOutput->Mode->Info->HorizontalResolution, + GraphicsOutput->Mode->Info->VerticalResolution, 0); + /* EFI buffer */ blt_size = dib->x * dib->y * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL); blt = AllocatePool(blt_size); diff --git a/src/efi/graphics.h b/src/efi/graphics.h index c5c08b4..edec1f4 100644 --- a/src/efi/graphics.h +++ b/src/efi/graphics.h @@ -21,5 +21,6 @@ #define __GUMMIBOOT_GRAPHICS_H EFI_STATUS graphics_mode(BOOLEAN on); -EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path); +EFI_STATUS graphics_splash(EFI_FILE *root_dir, CHAR16 *path, + const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background); #endif diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.c index 9272ef3..07077ae 100644 --- a/src/efi/gummiboot.c +++ b/src/efi/gummiboot.c @@ -374,19 +374,43 @@ static VOID print_status(Config *config, EFI_FILE *root_dir, CHAR16 *loaded_imag CHAR8 *b; UINTN size; EFI_STATUS err; + UINTN color = 0; + const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *pixel = NULL; uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - err = EFI_NOT_FOUND; - if (config->splash) - err = graphics_splash(root_dir, config->splash); - if (EFI_ERROR(err)) - err = graphics_splash(root_dir, L"\\EFI\\gummiboot\\splash.bmp"); - if (!EFI_ERROR(err)) { - console_key_read(&key, TRUE); + for (;;) { + + err = EFI_NOT_FOUND; + if (config->splash) + err = graphics_splash(root_dir, config->splash, pixel); + if (EFI_ERROR(err)) + err = graphics_splash(root_dir, L"\\EFI\\gummiboot\\splash.bmp", pixel); + if (!EFI_ERROR(err)) { + static const EFI_GRAPHICS_OUTPUT_BLT_PIXEL colors[] = { + { .Red = 255, .Green = 255, .Blue = 255 }, + { .Red = 255, .Green = 0, .Blue = 0 }, + { .Red = 0, .Green = 255, .Blue = 0 }, + { .Red = 0, .Green = 0, .Blue = 255 }, + { .Red = 0, .Green = 0, .Blue = 0 }, + }; + + console_key_read(&key, TRUE); + + /* 'b' rotates through background colors */ + if (key == KEYPRESS(0, 0, 'b')) { + pixel = &colors[color++]; + if (color == ELEMENTSOF(colors)) + color = 0; + + continue; + } + } + graphics_mode(FALSE); uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); + break; } Print(L"gummiboot version: " VERSION "\n"); @@ -455,7 +479,7 @@ static VOID print_status(Config *config, EFI_FILE *root_dir, CHAR16 *loaded_imag entry = config->entries[i]; if (entry->splash) { - err = graphics_splash(root_dir, entry->splash); + err = graphics_splash(root_dir, entry->splash, NULL); if (!EFI_ERROR(err)) { console_key_read(&key, TRUE); graphics_mode(FALSE); @@ -1799,16 +1823,16 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { if (entry->splash[0] == '\0') err = EFI_SUCCESS; else - err = graphics_splash(root_dir, entry->splash); + err = graphics_splash(root_dir, entry->splash, NULL); } /* splash from config file */ if (EFI_ERROR(err) && config.splash) - err = graphics_splash(root_dir, config.splash); + err = graphics_splash(root_dir, config.splash, NULL); /* default splash */ if (EFI_ERROR(err)) - graphics_splash(root_dir, L"\\EFI\\gummiboot\\splash.bmp"); + graphics_splash(root_dir, L"\\EFI\\gummiboot\\splash.bmp", NULL); } /* export the selected boot entry to the system */ diff --git a/src/efi/util.h b/src/efi/util.h index f3d4255..ce767bb 100644 --- a/src/efi/util.h +++ b/src/efi/util.h @@ -21,6 +21,8 @@ #include #include +#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) + UINT64 ticks_read(void); UINT64 ticks_freq(void); UINT64 time_usec(void); -- cgit v1.2.3