'P' support cycling to backgroud colors for debugging
authorKay Sievers <kay@vrfy.org>
Fri, 20 Dec 2013 23:56:07 +0000 (00:56 +0100)
committerKay Sievers <kay@vrfy.org>
Fri, 20 Dec 2013 23:56:29 +0000 (00:56 +0100)
src/efi/graphics.c
src/efi/graphics.h
src/efi/gummiboot.c
src/efi/util.h

index d1084cd..81089ed 100644 (file)
@@ -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);
index c5c08b4..edec1f4 100644 (file)
@@ -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
index 9272ef3..07077ae 100644 (file)
@@ -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 */
index f3d4255..ce767bb 100644 (file)
@@ -21,6 +21,8 @@
 #include <efi.h>
 #include <efilib.h>
 
+#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
+
 UINT64 ticks_read(void);
 UINT64 ticks_freq(void);
 UINT64 time_usec(void);