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