]> git.proxmox.com Git - efi-boot-shim.git/commitdiff
console: Add console_print and console_print_at helpers
authorHans de Goede <hdegoede@redhat.com>
Mon, 12 Mar 2018 15:03:38 +0000 (16:03 +0100)
committerPeter Jones <pjones@redhat.com>
Mon, 12 Mar 2018 22:00:41 +0000 (18:00 -0400)
This is a preparation commit for removing the setup_console(1) calls from
MokManager and shim so that we don't force the EFI console to switch to
text-mode.

This commit replaces all direct calls to Print / PrintAt with calls to
the new helpers (no functional changes) so that we can delay calling
setup_console(1) till the first Print call in a follow-up patch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
15 files changed:
MokManager.c
errlog.c
fallback.c
include/console.h
include/hexdump.h
lib/configtable.c
lib/console.c
lib/execute.c
lib/shell.c
lib/simple_file.c
lib/variables.c
netboot.c
replacements.c
shim.c
shim.h

index 6f54163fe90da4dbb518bcf6e616e005bf6bd488..1a590e08e64871e4a0ab37277f166c4cf7a22349 100644 (file)
@@ -665,19 +665,19 @@ static EFI_STATUS get_line(UINT32 * length, CHAR16 * line, UINT32 line_max,
                        continue;
                } else if (key.UnicodeChar == CHAR_BACKSPACE) {
                        if (show) {
-                               Print(L"\b");
+                               console_print(L"\b");
                        }
                        line[--count] = '\0';
                        continue;
                }
 
                if (show) {
-                       Print(L"%c", key.UnicodeChar);
+                       console_print(L"%c", key.UnicodeChar);
                }
 
                line[count++] = key.UnicodeChar;
        } while (key.UnicodeChar != CHAR_CARRIAGE_RETURN);
-       Print(L"\n");
+       console_print(L"\n");
 
        *length = count;
 
@@ -734,7 +734,7 @@ static void console_save_and_set_mode(SIMPLE_TEXT_OUTPUT_MODE * SavedMode)
        SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;
 
        if (!SavedMode) {
-               Print(L"Invalid parameter: SavedMode\n");
+               console_print(L"Invalid parameter: SavedMode\n");
                return;
        }
 
@@ -1513,7 +1513,7 @@ static EFI_STATUS mok_sb_prompt(void *MokSB, UINTN MokSBSize)
                if (pass1 != var->Password[pos1] ||
                    pass2 != var->Password[pos2] ||
                    pass3 != var->Password[pos3]) {
-                       Print(L"Invalid character\n");
+                       console_print(L"Invalid character\n");
                        fail_count++;
                } else {
                        break;
@@ -1628,7 +1628,7 @@ static EFI_STATUS mok_db_prompt(void *MokDB, UINTN MokDBSize)
                if (pass1 != var->Password[pos1] ||
                    pass2 != var->Password[pos2] ||
                    pass3 != var->Password[pos3]) {
-                       Print(L"Invalid character\n");
+                       console_print(L"Invalid character\n");
                        fail_count++;
                } else {
                        break;
@@ -2051,14 +2051,16 @@ static int draw_countdown()
 
        co->QueryMode(co, co->Mode->Mode, &cols, &rows);
 
-       PrintAt((cols - StrLen(message)) / 2, rows / 2, message);
+       console_print_at((cols - StrLen(message)) / 2, rows / 2, message);
        while (1) {
                if (timeout > 1)
-                       PrintAt(2, rows - 3, L"Booting in %d seconds  ",
-                               timeout);
+                       console_print_at(2, rows - 3,
+                                        L"Booting in %d seconds  ",
+                                        timeout);
                else if (timeout)
-                       PrintAt(2, rows - 3, L"Booting in %d second   ",
-                               timeout);
+                       console_print_at(2, rows - 3,
+                                        L"Booting in %d second   ",
+                                        timeout);
 
                efi_status = WaitForSingleEvent(ci->WaitForKey, wait);
                if (efi_status != EFI_TIMEOUT) {
@@ -2279,8 +2281,8 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_ENROLL_MOK:
                        if (!MokNew) {
-                               Print(L"MokManager: internal error: %s",
-                                     L"MokNew was !NULL but is now NULL\n");
+                               console_print(L"MokManager: internal error: %s",
+                                       L"MokNew was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
                        }
@@ -2291,8 +2293,8 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_DELETE_MOK:
                        if (!MokDel) {
-                               Print(L"MokManager: internal error: %s",
-                                     L"MokDel was !NULL but is now NULL\n");
+                               console_print(L"MokManager: internal error: %s",
+                                       L"MokDel was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
                        }
@@ -2306,7 +2308,7 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_ENROLL_MOKX:
                        if (!MokXNew) {
-                               Print(L"MokManager: internal error: %s",
+                               console_print(L"MokManager: internal error: %s",
                                      L"MokXNew was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
@@ -2318,7 +2320,7 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_DELETE_MOKX:
                        if (!MokXDel) {
-                               Print(L"MokManager: internal error: %s",
+                               console_print(L"MokManager: internal error: %s",
                                      L"MokXDel was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
@@ -2330,7 +2332,7 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_CHANGE_SB:
                        if (!MokSB) {
-                               Print(L"MokManager: internal error: %s",
+                               console_print(L"MokManager: internal error: %s",
                                      L"MokSB was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
@@ -2341,7 +2343,7 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_SET_PW:
                        if (!MokPW) {
-                               Print(L"MokManager: internal error: %s",
+                               console_print(L"MokManager: internal error: %s",
                                      L"MokPW was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
@@ -2352,7 +2354,7 @@ static EFI_STATUS enter_mok_menu(EFI_HANDLE image_handle,
                        break;
                case MOK_CHANGE_DB:
                        if (!MokDB) {
-                               Print(L"MokManager: internal error: %s",
+                               console_print(L"MokManager: internal error: %s",
                                      L"MokDB was !NULL but is now NULL\n");
                                ret = EFI_ABORTED;
                                goto out;
index de0e7350955876c6e231af854e978b98ee6a3c1a..18be4822d53b1cf1f9ce70ea85362f176ef767b1 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -68,7 +68,7 @@ PrintErrors(VOID)
                return;
 
        for (i = 0; i < nerrs; i++)
-               Print(L"%s", errs[i]);
+               console_print(L"%s", errs[i]);
 }
 
 VOID
index 1a5cf3f5ea7772d2612d542a0a0e680847a2d39e..574d296a114946456b7663a17042a8597850b83a 100644 (file)
@@ -48,7 +48,7 @@ get_fallback_verbose(void)
        ({                                                              \
                UINTN ret_ = 0;                                         \
                if (get_fallback_verbose())                             \
-                       ret_ = Print((fmt), ##__VA_ARGS__);             \
+                       ret_ = console_print((fmt), ##__VA_ARGS__);     \
                ret_;                                                   \
        })
 
@@ -56,8 +56,8 @@ get_fallback_verbose(void)
        ({      UINTN line_ = __LINE__;                                 \
                UINTN ret_ = 0;                                         \
                if (get_fallback_verbose()) {                           \
-                       Print(L"%a:%d: ", __func__, line_);             \
-                       ret_ = Print((fmt), ##__VA_ARGS__);             \
+                       console_print(L"%a:%d: ", __func__, line_);     \
+                       ret_ = console_print((fmt), ##__VA_ARGS__);     \
                }                                                       \
                ret_;                                                   \
        })
@@ -109,7 +109,7 @@ get_file_size(EFI_FILE_HANDLE fh, UINTN *retsize)
 
        buffer = AllocateZeroPool(bs);
        if (!buffer) {
-               Print(L"Could not allocate memory\n");
+               console_print(L"Could not allocate memory\n");
                return EFI_OUT_OF_RESOURCES;
        }
        efi_status = fh->GetInfo(fh, &EFI_FILE_INFO_GUID, &bs, buffer);
@@ -117,7 +117,7 @@ get_file_size(EFI_FILE_HANDLE fh, UINTN *retsize)
         * the EFI_BUFFER_TOO_SMALL we're expecting, or the second GetInfo
         * call in *any* case. */
        if (EFI_ERROR(efi_status)) {
-               Print(L"Could not get file info: %r\n", efi_status);
+               console_print(L"Could not get file info: %r\n", efi_status);
                if (buffer)
                        FreePool(buffer);
                return efi_status;
@@ -136,7 +136,7 @@ read_file(EFI_FILE_HANDLE fh, CHAR16 *fullpath, CHAR16 **buffer, UINT64 *bs)
 
        efi_status = fh->Open(fh, &fh2, fullpath, EFI_FILE_READ_ONLY, 0);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Couldn't open \"%s\": %r\n", fullpath, efi_status);
+               console_print(L"Couldn't open \"%s\": %r\n", fullpath, efi_status);
                return efi_status;
        }
 
@@ -144,8 +144,8 @@ read_file(EFI_FILE_HANDLE fh, CHAR16 *fullpath, CHAR16 **buffer, UINT64 *bs)
        CHAR16 *b = NULL;
        efi_status = get_file_size(fh2, &len);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Could not get file size for \"%s\": %r\n",
-                     fullpath, efi_status);
+               console_print(L"Could not get file size for \"%s\": %r\n",
+                             fullpath, efi_status);
                fh2->Close(fh2);
                return efi_status;
        }
@@ -157,7 +157,7 @@ read_file(EFI_FILE_HANDLE fh, CHAR16 *fullpath, CHAR16 **buffer, UINT64 *bs)
 
        b = AllocateZeroPool(len + 2);
        if (!buffer) {
-               Print(L"Could not allocate memory\n");
+               console_print(L"Could not allocate memory\n");
                fh2->Close(fh2);
                return EFI_OUT_OF_RESOURCES;
        }
@@ -166,7 +166,7 @@ read_file(EFI_FILE_HANDLE fh, CHAR16 *fullpath, CHAR16 **buffer, UINT64 *bs)
        if (EFI_ERROR(efi_status)) {
                FreePool(buffer);
                fh2->Close(fh2);
-               Print(L"Could not read file: %r\n", efi_status);
+               console_print(L"Could not read file: %r\n", efi_status);
                return efi_status;
        }
        *buffer = b;
@@ -186,7 +186,7 @@ make_full_path(CHAR16 *dirname, CHAR16 *filename, CHAR16 **out, UINT64 *outlen)
 
        CHAR16 *fullpath = AllocateZeroPool(len*sizeof(CHAR16));
        if (!fullpath) {
-               Print(L"Could not allocate memory\n");
+               console_print(L"Could not allocate memory\n");
                return EFI_OUT_OF_RESOURCES;
        }
 
@@ -240,9 +240,9 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
                        cursor += DevicePathSize(hddp);
                        StrCpy((CHAR16 *)cursor, arguments);
 
-                       Print(L"Creating boot entry \"%s\" with label \"%s\" "
-                                       L"for file \"%s\"\n",
-                               varname, label, filename);
+                       console_print(L"Creating boot entry \"%s\" with label \"%s\" "
+                                     L"for file \"%s\"\n",
+                                     varname, label, filename);
 
                        if (!first_new_option) {
                                first_new_option = DuplicateDevicePath(fulldp);
@@ -259,7 +259,8 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
                        FreePool(data);
 
                        if (EFI_ERROR(efi_status)) {
-                               Print(L"Could not create variable: %r\n", efi_status);
+                               console_print(L"Could not create variable: %r\n",
+                                             efi_status);
                                return efi_status;
                        }
 
@@ -278,10 +279,11 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
                        bootorder = newbootorder;
                        nbootorder += 1;
 #ifdef DEBUG_FALLBACK
-                       Print(L"nbootorder: %d\nBootOrder: ", nbootorder);
+                       console_print(L"nbootorder: %d\nBootOrder: ",
+                                     nbootorder);
                        for (j = 0 ; j < nbootorder ; j++)
-                               Print(L"%04x ", bootorder[j]);
-                       Print(L"\n");
+                               console_print(L"%04x ", bootorder[j]);
+                       console_print(L"\n");
 #endif
 
                        return EFI_SUCCESS;
@@ -496,7 +498,7 @@ update_boot_order(void)
        UINTN j;
        for (j = 0 ; j < size / sizeof (CHAR16); j++)
                VerbosePrintUnprefixed(L"%04x ", newbootorder[j]);
-       Print(L"\n");
+       console_print(L"\n");
        efi_status = gRT->GetVariable(L"BootOrder", &GV_GUID, NULL, &len, NULL);
        if (efi_status == EFI_BUFFER_TOO_SMALL)
                LibDeleteVariable(L"BootOrder", &GV_GUID);
@@ -642,7 +644,8 @@ try_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname, CHAR16 *filename)
        UINT64 bs;
        efi_status = read_file(fh, fullpath, &buffer, &bs);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Could not read file \"%s\": %r\n", fullpath, efi_status);
+               console_print(L"Could not read file \"%s\": %r\n",
+                             fullpath, efi_status);
                FreePool(fullpath);
                return efi_status;
        }
@@ -695,8 +698,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
         * then allocate a buffer and ask again to get it filled. */
        efi_status = fh->GetInfo(fh, &EFI_FILE_INFO_GUID, &bs, NULL);
        if (EFI_ERROR(efi_status) && efi_status != EFI_BUFFER_TOO_SMALL) {
-               Print(L"Could not get directory info for \\EFI\\%s\\: %r\n",
-                     dirname, efi_status);
+               console_print(L"Could not get directory info for \\EFI\\%s\\: %r\n",
+                             dirname, efi_status);
                return efi_status;
        }
        if (bs == 0)
@@ -704,7 +707,7 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
 
        buffer = AllocateZeroPool(bs);
        if (!buffer) {
-               Print(L"Could not allocate memory\n");
+               console_print(L"Could not allocate memory\n");
                return EFI_OUT_OF_RESOURCES;
        }
 
@@ -713,8 +716,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
         * the EFI_BUFFER_TOO_SMALL we're expecting, or the second GetInfo
         * call in *any* case. */
        if (EFI_ERROR(efi_status)) {
-               Print(L"Could not get info for \"%s\": %r\n", dirname,
-                     efi_status);
+               console_print(L"Could not get info for \"%s\": %r\n", dirname,
+                             efi_status);
                if (buffer)
                        FreePool(buffer);
                return efi_status;
@@ -736,8 +739,8 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
                efi_status = fh->Read(fh, &bs, NULL);
                if (EFI_ERROR(efi_status) &&
                    efi_status != EFI_BUFFER_TOO_SMALL) {
-                       Print(L"Could not read \\EFI\\%s\\: %r\n", dirname,
-                             efi_status);
+                       console_print(L"Could not read \\EFI\\%s\\: %r\n",
+                                     dirname, efi_status);
                        return efi_status;
                }
                /* If there's no data to read, don't try to allocate 0 bytes
@@ -747,14 +750,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
 
                buffer = AllocateZeroPool(bs);
                if (!buffer) {
-                       Print(L"Could not allocate memory\n");
+                       console_print(L"Could not allocate memory\n");
                        return EFI_OUT_OF_RESOURCES;
                }
 
                efi_status = fh->Read(fh, &bs, buffer);
                if (EFI_ERROR(efi_status)) {
-                       Print(L"Could not read \\EFI\\%s\\: %r\n", dirname,
-                             efi_status);
+                       console_print(L"Could not read \\EFI\\%s\\: %r\n",
+                                     dirname, efi_status);
                        FreePool(buffer);
                        return efi_status;
                }
@@ -781,14 +784,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
                efi_status = fh->Open(fh, &fh2, bootarchcsv,
                                      EFI_FILE_READ_ONLY, 0);
                if (EFI_ERROR(efi_status) || fh2 == NULL) {
-                       Print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
-                             dirname, bootarchcsv, efi_status);
+                       console_print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
+                                     dirname, bootarchcsv, efi_status);
                } else {
                        efi_status = try_boot_csv(fh2, dirname, bootarchcsv);
                        fh2->Close(fh2);
                        if (EFI_ERROR(efi_status))
-                               Print(L"Could not process \\EFI\\%s\\%s: %r\n",
-                                     dirname, bootarchcsv, efi_status);
+                               console_print(L"Could not process \\EFI\\%s\\%s: %r\n",
+                                             dirname, bootarchcsv, efi_status);
                }
        }
        if ((EFI_ERROR(efi_status) || !bootarchcsv) && bootcsv) {
@@ -796,14 +799,14 @@ find_boot_csv(EFI_FILE_HANDLE fh, CHAR16 *dirname)
                efi_status = fh->Open(fh, &fh2, bootcsv,
                                      EFI_FILE_READ_ONLY, 0);
                if (EFI_ERROR(efi_status) || fh2 == NULL) {
-                       Print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
-                             dirname, bootcsv, efi_status);
+                       console_print(L"Couldn't open \\EFI\\%s\\%s: %r\n",
+                                     dirname, bootcsv, efi_status);
                } else {
                        efi_status = try_boot_csv(fh2, dirname, bootcsv);
                        fh2->Close(fh2);
                        if (EFI_ERROR(efi_status))
-                               Print(L"Could not process \\EFI\\%s\\%s: %r\n",
-                                     dirname, bootarchcsv, efi_status);
+                               console_print(L"Could not process \\EFI\\%s\\%s: %r\n",
+                                             dirname, bootarchcsv, efi_status);
                }
        }
        return EFI_SUCCESS;
@@ -818,7 +821,7 @@ find_boot_options(EFI_HANDLE device)
        efi_status = gBS->HandleProtocol(device, &FileSystemProtocol,
                                         (void **) &fio);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Couldn't find file system: %r\n", efi_status);
+               console_print(L"Couldn't find file system: %r\n", efi_status);
                return efi_status;
        }
 
@@ -828,20 +831,20 @@ find_boot_options(EFI_HANDLE device)
        EFI_FILE_HANDLE fh = NULL;
        efi_status = fio->OpenVolume(fio, &fh);
        if (EFI_ERROR(efi_status) || fh == NULL) {
-               Print(L"Couldn't open file system: %r\n", efi_status);
+               console_print(L"Couldn't open file system: %r\n", efi_status);
                return efi_status;
        }
 
        EFI_FILE_HANDLE fh2 = NULL;
        efi_status = fh->Open(fh, &fh2, L"EFI", EFI_FILE_READ_ONLY, 0);
        if (EFI_ERROR(efi_status) || fh2 == NULL) {
-               Print(L"Couldn't open EFI: %r\n", efi_status);
+               console_print(L"Couldn't open EFI: %r\n", efi_status);
                fh->Close(fh);
                return efi_status;
        }
        efi_status = fh2->SetPosition(fh2, 0);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Couldn't set file position: %r\n", efi_status);
+               console_print(L"Couldn't set file position: %r\n", efi_status);
                fh2->Close(fh2);
                fh->Close(fh);
                return efi_status;
@@ -853,7 +856,7 @@ find_boot_options(EFI_HANDLE device)
                bs = 0;
                efi_status = fh2->Read(fh2, &bs, NULL);
                if (EFI_ERROR(efi_status) && efi_status != EFI_BUFFER_TOO_SMALL) {
-                       Print(L"Could not read \\EFI\\: %r\n", efi_status);
+                       console_print(L"Could not read \\EFI\\: %r\n", efi_status);
                        return efi_status;
                }
                if (bs == 0)
@@ -861,7 +864,7 @@ find_boot_options(EFI_HANDLE device)
 
                buffer = AllocateZeroPool(bs);
                if (!buffer) {
-                       Print(L"Could not allocate memory\n");
+                       console_print(L"Could not allocate memory\n");
                        /* sure, this might work, why not? */
                        fh2->Close(fh2);
                        fh->Close(fh);
@@ -898,7 +901,8 @@ find_boot_options(EFI_HANDLE device)
                efi_status = fh2->Open(fh2, &fh3, fi->FileName,
                                      EFI_FILE_READ_ONLY, 0);
                if (EFI_ERROR(efi_status)) {
-                       Print(L"%d Couldn't open %s: %r\n", __LINE__, fi->FileName, efi_status);
+                       console_print(L"%d Couldn't open %s: %r\n", __LINE__,
+                                     fi->FileName, efi_status);
                        FreePool(buffer);
                        buffer = NULL;
                        continue;
@@ -938,13 +942,14 @@ try_start_first_option(EFI_HANDLE parent_image_handle)
                UINTN s = DevicePathSize(first_new_option);
                unsigned int i;
                UINT8 *dpv = (void *)first_new_option;
-               Print(L"LoadImage failed: %r\nDevice path: \"%s\"\n", efi_status, dps);
+               console_print(L"LoadImage failed: %r\nDevice path: \"%s\"\n",
+                             efi_status, dps);
                for (i = 0; i < s; i++) {
                        if (i > 0 && i % 16 == 0)
-                               Print(L"\n");
-                       Print(L"%02x ", dpv[i]);
+                               console_print(L"\n");
+                       console_print(L"%02x ", dpv[i]);
                }
-               Print(L"\n");
+               console_print(L"\n");
 
                msleep(500000000);
                return efi_status;
@@ -960,7 +965,7 @@ try_start_first_option(EFI_HANDLE parent_image_handle)
 
        efi_status = gBS->StartImage(image_handle, NULL, NULL);
        if (EFI_ERROR(efi_status)) {
-               Print(L"StartImage failed: %r\n", efi_status);
+               console_print(L"StartImage failed: %r\n", efi_status);
                msleep(500000000);
        }
        return efi_status;
@@ -989,9 +994,9 @@ debug_hook(void)
                return;
 
        x = 1;
-       Print(L"add-symbol-file "DEBUGDIR
-             L"fb" EFI_ARCH L".efi.debug %p -s .data %p\n", &_etext,
-             &_edata);
+       console_print(L"add-symbol-file "DEBUGDIR
+                     L"fb" EFI_ARCH L".efi.debug %p -s .data %p\n",
+                     &_etext, &_edata);
 }
 
 EFI_STATUS
@@ -1009,17 +1014,19 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
        efi_status = gBS->HandleProtocol(image, &LoadedImageProtocol,
                                         (void *) &this_image);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Error: could not find loaded image: %r\n", efi_status);
+               console_print(L"Error: could not find loaded image: %r\n",
+                             efi_status);
                return efi_status;
        }
 
-       Print(L"System BootOrder not found.  Initializing defaults.\n");
+       console_print(L"System BootOrder not found.  Initializing defaults.\n");
 
        set_boot_order();
 
        efi_status = find_boot_options(this_image->DeviceHandle);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Error: could not find boot options: %r\n", efi_status);
+               console_print(L"Error: could not find boot options: %r\n",
+                             efi_status);
                return efi_status;
        }
 
@@ -1031,10 +1038,10 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
                VerbosePrint(L"tpm present, resetting system\n");
        }
 
-       Print(L"Reset System\n");
+       console_print(L"Reset System\n");
 
        if (get_fallback_verbose()) {
-               Print(L"Verbose enabled, sleeping for half a second\n");
+               console_print(L"Verbose enabled, sleeping for half a second\n");
                msleep(500000);
        }
 
index 5d9cd64db49bfb369e14a0bb7f409e79dc6e7ae6..62e8d6ec2b37ff3db28975869305bd320d5b5b85 100644 (file)
@@ -1,8 +1,18 @@
 #ifndef SHIM_CONSOLE_H
 #define SHIM_CONSOLE_H
 
+#define Print(fmt, ...) \
+       ({"Do not directly call Print() use console_print() instead" = 1;});
+
+#define PrintAt(fmt, ...) \
+       ({"Do not directly call PrintAt() use console_print_at() instead" = 1;});
+
 EFI_STATUS
 console_get_keystroke(EFI_INPUT_KEY *key);
+UINTN
+console_print(const CHAR16 *fmt, ...);
+UINTN
+console_print_at(UINTN col, UINTN row, const CHAR16 *fmt, ...);
 void
 console_print_box_at(CHAR16 *str_arr[], int highlight,
                     int start_col, int start_row,
@@ -66,11 +76,11 @@ struct _EFI_CONSOLE_CONTROL_PROTOCOL {
 extern VOID setup_console (int text);
 extern VOID setup_verbosity(VOID);
 extern UINT8 verbose;
-#define dprint(fmt, ...) ({                                            \
-               UINTN __dprint_ret = 0;                                 \
-               if (verbose)                                            \
-                       __dprint_ret = Print((fmt), ##__VA_ARGS__);     \
-               __dprint_ret;                                           \
+#define dprint(fmt, ...) ({                                                    \
+               UINTN __dprint_ret = 0;                                         \
+               if (verbose)                                                    \
+                       __dprint_ret = console_print((fmt), ##__VA_ARGS__);     \
+               __dprint_ret;                                                   \
        })
 #define dprinta(fmt, ...) ({                                                                   \
                UINTN __dprinta_ret = 0;                                                        \
@@ -79,7 +89,7 @@ extern UINT8 verbose;
                        CHAR16 *__dprinta_str = AllocateZeroPool((strlena(fmt) + 1) * 2);       \
                        for (__dprinta_i = 0; fmt[__dprinta_i] != '\0'; __dprinta_i++)          \
                                __dprinta_str[__dprinta_i] = fmt[__dprinta_i];                  \
-                       __dprinta_ret = Print((__dprinta_str), ##__VA_ARGS__);                  \
+                       __dprinta_ret = console_print((__dprinta_str), ##__VA_ARGS__);          \
                        FreePool(__dprinta_str);                                                \
                }                                                                               \
                __dprinta_ret;                                                                  \
index df3a17a4159b59aad34ca30bc804af7bba116abf..d337b571d8d690bf23ce72c470dcb5ef9d0e22c7 100644 (file)
@@ -80,7 +80,7 @@ hexdump(UINT8 *data, UINTN size)
 {
        UINTN display_offset = (UINTN)data & 0xffffffff;
        UINTN offset = 0;
-       //Print(L"hexdump: data=0x%016x size=0x%x\n", data, size);
+       //console_print(L"hexdump: data=0x%016x size=0x%x\n", data, size);
 
        while (offset < size) {
                CHAR16 hexbuf[49];
@@ -93,7 +93,7 @@ hexdump(UINT8 *data, UINTN size)
                msleep(200000);
 
                format_text(data+offset, size-offset, txtbuf);
-               Print(L"%08x  %s  %s\n", display_offset, hexbuf, txtbuf);
+               console_print(L"%08x  %s  %s\n", display_offset, hexbuf, txtbuf);
                msleep(200000);
 
                display_offset += sz;
index 194637ee83bcc8f8ed0fbd2128cd92238ceb098b..df047f0e382706700f020e255791c2d8b7abbe9b 100644 (file)
@@ -45,26 +45,26 @@ configtable_find_image(const EFI_DEVICE_PATH *DevicePath)
        int i;
        for (i = 0; i < entries; i++) {
 #ifdef DEBUG_CONFIG
-               Print(L"InfoSize = %d  Action = %d\n", e->InfoSize, e->Action);
+               console_print(L"InfoSize = %d  Action = %d\n", e->InfoSize, e->Action);
 
                /* print what we have for debugging */
                UINT8 *d = (UINT8 *)e; // + sizeof(UINT32)*2;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
                d += 16;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
                d += 16;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
                d += 16;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
                d += 16;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
                d += 16;
-               Print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+               console_print(L"Data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
                      d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); 
 #endif
                CHAR16 *name = (CHAR16 *)(e->Data);
@@ -76,33 +76,33 @@ configtable_find_image(const EFI_DEVICE_PATH *DevicePath)
                if (name[0] == '\0' || (e->Data[1] == 0 && e->Data[3] == 0)) {
                        skip = StrSize(name);
 #ifdef DEBUG_CONFIG
-                       Print(L"FOUND NAME %s (%d)\n", name, skip);
+                       console_print(L"FOUND NAME %s (%d)\n", name, skip);
 #endif
                }
                EFI_DEVICE_PATH *dp = (EFI_DEVICE_PATH *)(e->Data + skip), *dpn = dp;
                if (dp->Type == 0 || dp->Type > 6 || dp->SubType == 0
                    || ((unsigned)((dp->Length[1] << 8) + dp->Length[0]) > e->InfoSize)) {
                        /* Parse error, table corrupt, bail */
-                       Print(L"Image Execution Information table corrupt\n");
+                       console_print(L"Image Execution Information table corrupt\n");
                        break;
                }
 
                UINTN Size;
                DevicePathInstance(&dpn, &Size);
 #ifdef DEBUG_CONFIG
-               Print(L"Path: %s\n", DevicePathToStr(dp));
-               Print(L"Device Path Size %d\n", Size);
+               console_print(L"Path: %s\n", DevicePathToStr(dp));
+               console_print(L"Device Path Size %d\n", Size);
 #endif
                if (Size > e->InfoSize) {
                        /* parse error; the platform obviously has a 
                         * corrupted image table; bail */
-                       Print(L"Image Execution Information table corrupt\n");
+                       console_print(L"Image Execution Information table corrupt\n");
                        break;
                }
                
                if (CompareMem(dp, (void *)DevicePath, Size) == 0) {
 #ifdef DEBUG_CONFIG
-                       Print(L"***FOUND\n");
+                       console_print(L"***FOUND\n");
                        console_get_keystroke();
 #endif
                        return e;
@@ -111,7 +111,7 @@ configtable_find_image(const EFI_DEVICE_PATH *DevicePath)
        }
 
 #ifdef DEBUG_CONFIG
-       Print(L"***NOT FOUND\n");
+       console_print(L"***NOT FOUND\n");
        console_get_keystroke();
 #endif
 
@@ -134,7 +134,7 @@ configtable_image_is_forbidden(const EFI_DEVICE_PATH *DevicePath)
                  || e->Action == EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED)) {
                /* this means the images signing key is in dbx */
 #ifdef DEBUG_CONFIG
-               Print(L"SIGNATURE IS IN DBX, FORBIDDING EXECUTION\n");
+               console_print(L"SIGNATURE IS IN DBX, FORBIDDING EXECUTION\n");
 #endif
                return 1;
        }
index 50687ea4a00e7b3396cbc056fe39cde59d2bcce1..06b806c6dbf83330b11fee0a1381cec2b4547e9c 100644 (file)
 
 #include "shim.h"
 
-#include <Library/BaseCryptLib.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-
 static int
 count_lines(CHAR16 *str_arr[])
 {
@@ -50,6 +46,36 @@ console_get_keystroke(EFI_INPUT_KEY *key)
        return efi_status;
 }
 
+UINTN
+console_print(const CHAR16 *fmt, ...)
+{
+       va_list args;
+       UINTN ret;
+
+       va_start(args, fmt);
+       ret = VPrint(fmt, args);
+       va_end(args);
+
+       return ret;
+}
+
+UINTN
+console_print_at(UINTN col, UINTN row, const CHAR16 *fmt, ...)
+{
+       SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;
+       va_list args;
+       UINTN ret;
+
+       co->SetCursorPosition(co, col, row);
+
+       va_start(args, fmt);
+       ret = VPrint(fmt, args);
+       va_end(args);
+
+       return ret;
+}
+
+
 void
 console_print_box_at(CHAR16 *str_arr[], int highlight,
                     int start_col, int start_row,
@@ -84,8 +110,8 @@ console_print_box_at(CHAR16 *str_arr[], int highlight,
                start_row = 0;
 
        if (start_col > (int)cols || start_row > (int)rows) {
-               Print(L"Starting Position (%d,%d) is off screen\n",
-                     start_col, start_row);
+               console_print(L"Starting Position (%d,%d) is off screen\n",
+                             start_col, start_row);
                return;
        }
        if (size_cols + start_col > (int)cols)
@@ -98,7 +124,7 @@ console_print_box_at(CHAR16 *str_arr[], int highlight,
 
        Line = AllocatePool((size_cols+1)*sizeof(CHAR16));
        if (!Line) {
-               Print(L"Failed Allocation\n");
+               console_print(L"Failed Allocation\n");
                return;
        }
 
@@ -242,7 +268,8 @@ console_select(CHAR16 *title[], CHAR16* selectors[], unsigned int start)
        do {
                efi_status = console_get_keystroke(&k);
                if (EFI_ERROR (efi_status)) {
-                       Print(L"Failed to read the keystroke: %r", efi_status);
+                       console_print(L"Failed to read the keystroke: %r",
+                                     efi_status);
                        selector = -1;
                        break;
                }
@@ -458,10 +485,15 @@ VOID setup_console (int text)
        concon->SetMode(concon, new_mode);
 }
 
+/* Included here because they mess up the definition of va_list and friends */
+#include <Library/BaseCryptLib.h>
+#include <openssl/err.h>
+#include <openssl/crypto.h>
+
 static int
 print_errors_cb(const char *str, size_t len, void *u)
 {
-       Print(L"%a", str);
+       console_print(L"%a", str);
 
        return len;
 }
@@ -473,7 +505,8 @@ print_crypto_errors(EFI_STATUS efi_status,
        if (!(verbose && EFI_ERROR(efi_status)))
                return efi_status;
 
-       Print(L"SSL Error: %a:%d %a(): %r\n", file, line, func, efi_status);
+       console_print(L"SSL Error: %a:%d %a(): %r\n", file, line, func,
+                     efi_status);
        ERR_print_errors_cb(print_errors_cb, NULL);
 
        return efi_status;
index 366af3c8c2950d7543fffb5b9f15fe6ed44dd80f..3aff28ad6427b1b9c19197574ad651134c0bccbe 100644 (file)
@@ -73,7 +73,7 @@ generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16
        *PathName = AllocatePool((pathlen + 1 + StrLen(name))*sizeof(CHAR16));
 
        if (!*PathName) {
-               Print(L"Failed to allocate path buffer\n");
+               console_print(L"Failed to allocate path buffer\n");
                efi_status = EFI_OUT_OF_RESOURCES;
                goto error;
        }
index 6d2312ebdddede6cf0fcebd90046a8c41f45164b..e46e7fd25bab2b27f1bb1fbe58c5a2fbaef9b9b2 100644 (file)
@@ -23,7 +23,7 @@ argsplit(EFI_HANDLE image, int *argc, CHAR16*** ARGV)
        efi_status = gBS->HandleProtocol(image, &LoadedImageProtocol,
                                         (VOID **) &info);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Failed to get arguments\n");
+               console_print(L"Failed to get arguments\n");
                return efi_status;
        }
 
index 8b2324c067e312e2670a1bc0b9799252b81e4bff..3bf92ed8e0f82bf0b40b49e06916dfa355f3376b 100644 (file)
@@ -19,14 +19,14 @@ simple_file_open_by_handle(EFI_HANDLE device, CHAR16 *name, EFI_FILE **file, UIN
        efi_status = gBS->HandleProtocol(device, &EFI_SIMPLE_FILE_SYSTEM_GUID,
                                         (void **)&drive);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Unable to find simple file protocol (%d)\n",
-                     efi_status);
+               console_print(L"Unable to find simple file protocol (%d)\n",
+                             efi_status);
                goto error;
        }
 
        efi_status = drive->OpenVolume(drive, &root);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Failed to open drive volume (%d)\n", efi_status);
+               console_print(L"Failed to open drive volume (%d)\n", efi_status);
                goto error;
        }
 
@@ -52,7 +52,7 @@ simple_file_open(EFI_HANDLE image, CHAR16 *name, EFI_FILE **file, UINT64 mode)
 
        efi_status = generate_path(name, li, &loadpath, &PathName);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Unable to generate load path for %s\n", name);
+               console_print(L"Unable to generate load path for %s\n", name);
                return efi_status;
        }
 
@@ -77,11 +77,11 @@ simple_dir_read_all_by_handle(EFI_HANDLE image, EFI_FILE *file, CHAR16* name, EF
 
        efi_status = file->GetInfo(file, &EFI_FILE_INFO_GUID, &size, fi);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Failed to get file info\n");
+               console_print(L"Failed to get file info\n");
                goto out;
        }
        if ((fi->Attribute & EFI_FILE_DIRECTORY) == 0) {
-               Print(L"Not a directory %s\n", name);
+               console_print(L"Not a directory %s\n", name);
                efi_status = EFI_INVALID_PARAMETER;
                goto out;
        }
@@ -127,7 +127,7 @@ simple_dir_read_all(EFI_HANDLE image, CHAR16 *name, EFI_FILE_INFO **entries,
 
        efi_status = simple_file_open(image, name, &file, EFI_FILE_MODE_READ);
        if (EFI_ERROR(efi_status)) {
-               Print(L"failed to open file %s: %d\n", name, efi_status);
+               console_print(L"failed to open file %s: %d\n", name, efi_status);
                return efi_status;
        }
 
@@ -146,7 +146,7 @@ simple_file_read_all(EFI_FILE *file, UINTN *size, void **buffer)
 
        efi_status = file->GetInfo(file, &EFI_FILE_INFO_GUID, size, fi);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Failed to get file info\n");
+               console_print(L"Failed to get file info\n");
                return efi_status;
        }
 
@@ -154,7 +154,7 @@ simple_file_read_all(EFI_FILE *file, UINTN *size, void **buffer)
 
        *buffer = AllocatePool(*size);
        if (!*buffer) {
-               Print(L"Failed to allocate buffer of size %d\n", *size);
+               console_print(L"Failed to allocate buffer of size %d\n", *size);
                return EFI_OUT_OF_RESOURCES;
        }
 
@@ -323,7 +323,7 @@ simple_dir_filter(EFI_HANDLE image, CHAR16 *name, CHAR16 *filter,
                if (next->Attribute & EFI_FILE_DIRECTORY) {
                                (*result)[(*count)] = PoolPrint(L"%s/", next->FileName);
                                if (!(*result)[(*count)]) {
-                                       Print(L"Failed to allocate buffer");
+                                       console_print(L"Failed to allocate buffer");
                                        return EFI_OUT_OF_RESOURCES;
                                }
                                (*count)++;
@@ -336,7 +336,7 @@ simple_dir_filter(EFI_HANDLE image, CHAR16 *name, CHAR16 *filter,
                        if (StrCmp(&next->FileName[len - offs], filterarr[c]) == 0) {
                                (*result)[(*count)] = StrDuplicate(next->FileName);
                                if (!(*result)[(*count)]) {
-                                       Print(L"Failed to allocate buffer");
+                                       console_print(L"Failed to allocate buffer");
                                        return EFI_OUT_OF_RESOURCES;
                                }
                                (*count)++;
index 9d9ac603f82626dede8b7dc3144d01b65be92f43..9c2e7d0ac2d5865c3e1f6cc558b2956b73fbdd0f 100644 (file)
@@ -141,7 +141,8 @@ SetSecureVariable(CHAR16 *var, UINT8 *Data, UINTN len, EFI_GUID owner,
                efi_status = variable_create_esl(Data, len, &X509_GUID, NULL,
                                                 (void **)&Cert, &ds);
                if (EFI_ERROR(efi_status)) {
-                       Print(L"Failed to create %s certificate %d\n", var, efi_status);
+                       console_print(L"Failed to create %s certificate %d\n",
+                                     var, efi_status);
                        return efi_status;
                }
 
@@ -153,7 +154,8 @@ SetSecureVariable(CHAR16 *var, UINT8 *Data, UINTN len, EFI_GUID owner,
        }
        efi_status = CreateTimeBasedPayload(&DataSize, (UINT8 **)&Cert);
        if (EFI_ERROR(efi_status)) {
-               Print(L"Failed to create time based payload %d\n", efi_status);
+               console_print(L"Failed to create time based payload %d\n",
+                             efi_status);
                return efi_status;
        }
 
index ea9e150b126e1aa8370c3bf1361c397af08afa3f..58babfb4d2e6c2a05f1cb41b934b321bfab2636a 100644 (file)
--- a/netboot.c
+++ b/netboot.c
@@ -195,12 +195,12 @@ static BOOLEAN extract_tftp_info(CHAR8 *url)
        memset(ip6inv, 0, sizeof(ip6inv));
 
        if (strncmp((UINT8 *)url, (UINT8 *)"tftp://", 7)) {
-               Print(L"URLS MUST START WITH tftp://\n");
+               console_print(L"URLS MUST START WITH tftp://\n");
                return FALSE;
        }
        start = url + 7;
        if (*start != '[') {
-               Print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n");
+               console_print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n");
                return FALSE;
        }
 
@@ -209,12 +209,12 @@ static BOOLEAN extract_tftp_info(CHAR8 *url)
        while ((*end != '\0') && (*end != ']')) {
                end++;
                if (end - start >= (int)sizeof(ip6str)) {
-                       Print(L"TFTP URL includes malformed IPv6 address\n");
+                       console_print(L"TFTP URL includes malformed IPv6 address\n");
                        return FALSE;
                }
        }
        if (*end == '\0') {
-               Print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n");
+               console_print(L"TFTP SERVER MUST BE ENCLOSED IN [..]\n");
                return FALSE;
        }
        memset(ip6str, 0, sizeof(ip6str));
@@ -324,7 +324,7 @@ EFI_STATUS FetchNetbootimage(EFI_HANDLE image_handle, VOID **buffer, UINT64 *buf
        BOOLEAN nobuffer = FALSE;
        UINTN blksz = 512;
 
-       Print(L"Fetching Netboot Image\n");
+       console_print(L"Fetching Netboot Image\n");
        if (*buffer == NULL) {
                *buffer = AllocatePool(4096 * 1024);
                if (!*buffer)
index 10010567a8a5222c460f26d9fad836c6696ea83d..944c779da319cdeefe48cdaa7e02af538807b22c 100644 (file)
@@ -116,9 +116,9 @@ replacement_start_image(EFI_HANDLE image_handle, UINTN *exit_data_size, CHAR16 *
                        EFI_STATUS efi_status2 = install_shim_protocols();
 
                        if (EFI_ERROR(efi_status2)) {
-                               Print(L"Something has gone seriously wrong: %r\n",
-                                       efi_status2);
-                               Print(L"shim cannot continue, sorry.\n");
+                               console_print(L"Something has gone seriously wrong: %r\n",
+                                             efi_status2);
+                               console_print(L"shim cannot continue, sorry.\n");
                                msleep(5000000);
                                gRT->ResetSystem(EfiResetShutdown,
                                                 EFI_SECURITY_VIOLATION,
@@ -144,8 +144,8 @@ exit_boot_services(EFI_HANDLE image_key, UINTN map_key)
                return efi_status;
        }
 
-       Print(L"Bootloader has not verified loaded image.\n");
-       Print(L"System is compromised.  halting.\n");
+       console_print(L"Bootloader has not verified loaded image.\n");
+       console_print(L"System is compromised.  halting.\n");
        msleep(5000000);
        gRT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION, 0, NULL);
        return EFI_SECURITY_VIOLATION;
@@ -165,9 +165,9 @@ do_exit(EFI_HANDLE ImageHandle, EFI_STATUS ExitStatus,
                EFI_STATUS efi_status2 = shim_init();
 
                if (EFI_ERROR(efi_status2)) {
-                       Print(L"Something has gone seriously wrong: %r\n",
-                               efi_status2);
-                       Print(L"shim cannot continue, sorry.\n");
+                       console_print(L"Something has gone seriously wrong: %r\n",
+                                     efi_status2);
+                       console_print(L"shim cannot continue, sorry.\n");
                        msleep(5000000);
                        gRT->ResetSystem(EfiResetShutdown,
                                         EFI_SECURITY_VIOLATION, 0, NULL);
diff --git a/shim.c b/shim.c
index 569a6084c79eddbab611bada4d65ece23cae16c8..1f17e444014d0e853263383ca4633023db784041 100644 (file)
--- a/shim.c
+++ b/shim.c
@@ -910,10 +910,10 @@ static EFI_STATUS generate_hash (char *data, unsigned int datasize_in,
                if ((datasize - SumOfBytesHashed < context->SecDir->Size) ||
                    (SumOfBytesHashed + hashsize != context->SecDir->VirtualAddress)) {
                        perror(L"Malformed binary after Attribute Certificate Table\n");
-                       Print(L"datasize: %u SumOfBytesHashed: %u SecDir->Size: %lu\n",
-                             datasize, SumOfBytesHashed, context->SecDir->Size);
-                       Print(L"hashsize: %u SecDir->VirtualAddress: 0x%08lx\n",
-                             hashsize, context->SecDir->VirtualAddress);
+                       console_print(L"datasize: %u SumOfBytesHashed: %u SecDir->Size: %lu\n",
+                                     datasize, SumOfBytesHashed, context->SecDir->Size);
+                       console_print(L"hashsize: %u SecDir->VirtualAddress: 0x%08lx\n",
+                                     hashsize, context->SecDir->VirtualAddress);
                        efi_status = EFI_INVALID_PARAMETER;
                        goto done;
                }
@@ -1942,7 +1942,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
            efi_status == EFI_ACCESS_DENIED) {
                efi_status = start_image(image_handle, MOK_MANAGER);
                if (EFI_ERROR(efi_status)) {
-                       Print(L"start_image() returned %r\n", efi_status);
+                       console_print(L"start_image() returned %r\n", efi_status);
                        msleep(2000000);
                        return efi_status;
                }
@@ -1952,7 +1952,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
        }
 
        if (EFI_ERROR(efi_status)) {
-               Print(L"start_image() returned %r\n", efi_status);
+               console_print(L"start_image() returned %r\n", efi_status);
                msleep(2000000);
        }
 
@@ -2078,8 +2078,8 @@ static int is_our_path(EFI_LOADED_IMAGE *li, CHAR16 *path, UINTN len)
        if (!dppath)
                return 0;
 
-       Print(L"dppath: %s\n", dppath);
-       Print(L"path:   %s\n", path);
+       console_print(L"dppath: %s\n", dppath);
+       console_print(L"path:   %s\n", path);
        if (StrnCaseCmp(dppath, path, len))
                ret = 0;
 
@@ -2489,13 +2489,13 @@ debug_hook(void)
                return;
        }
 
-       Print(L"add-symbol-file "DEBUGDIR
-             L"shim" EFI_ARCH L".efi.debug 0x%08x -s .data 0x%08x\n", &_text,
-             &_data);
+       console_print(L"add-symbol-file "DEBUGDIR
+                     L"shim" EFI_ARCH L".efi.debug 0x%08x -s .data 0x%08x\n",
+                     &_text, &_data);
 
-       Print(L"Pausing for debugger attachment.\n");
-       Print(L"To disable this, remove the EFI variable SHIM_DEBUG-%g .\n",
-             &SHIM_LOCK_GUID);
+       console_print(L"Pausing for debugger attachment.\n");
+       console_print(L"To disable this, remove the EFI variable SHIM_DEBUG-%g .\n",
+                     &SHIM_LOCK_GUID);
        x = 1;
        while (x++) {
                /* Make this so it can't /totally/ DoS us. */
@@ -2559,8 +2559,8 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
        efi_status = import_mok_state(image_handle);
        if (EFI_ERROR(efi_status)) {
 die:
-               Print(L"Something has gone seriously wrong: %r\n",
-                     efi_status);
+               console_print(L"Something has gone seriously wrong: %r\n",
+                             efi_status);
                msleep(5000000);
                gRT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION,
                                 0, NULL);
@@ -2574,7 +2574,7 @@ die:
         * Tell the user that we're in insecure mode if necessary
         */
        if (user_insecure_mode) {
-               Print(L"Booting in insecure mode\n");
+               console_print(L"Booting in insecure mode\n");
                msleep(2000000);
        }
 
diff --git a/shim.h b/shim.h
index 4079ef8f89384f29843b803db44ff3a205a04db1..a25a660df6af108590197ba6fb5801a5736481ea 100644 (file)
--- a/shim.h
+++ b/shim.h
@@ -175,12 +175,12 @@ extern UINT8 user_insecure_mode;
 extern UINT8 ignore_db;
 extern UINT8 in_protocol;
 
-#define perror_(file, line, func, fmt, ...) ({                         \
-               UINTN __perror_ret = 0;                                 \
-               if (!in_protocol)                                       \
-                       __perror_ret = Print((fmt), ##__VA_ARGS__);     \
+#define perror_(file, line, func, fmt, ...) ({                                 \
+               UINTN __perror_ret = 0;                                         \
+               if (!in_protocol)                                               \
+                       __perror_ret = console_print((fmt), ##__VA_ARGS__);     \
                LogError_(file, line, func, fmt, ##__VA_ARGS__);                \
-               __perror_ret;                                           \
+               __perror_ret;                                                   \
        })
 #define perror(fmt, ...) perror_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
 #define LogError(fmt, ...) LogError_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)