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;
SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;
if (!SavedMode) {
- Print(L"Invalid parameter: SavedMode\n");
+ console_print(L"Invalid parameter: SavedMode\n");
return;
}
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;
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;
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) {
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;
}
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;
}
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;
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;
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;
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;
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;
return;
for (i = 0; i < nerrs; i++)
- Print(L"%s", errs[i]);
+ console_print(L"%s", errs[i]);
}
VOID
({ \
UINTN ret_ = 0; \
if (get_fallback_verbose()) \
- ret_ = Print((fmt), ##__VA_ARGS__); \
+ ret_ = console_print((fmt), ##__VA_ARGS__); \
ret_; \
})
({ 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_; \
})
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);
* 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;
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;
}
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;
}
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;
}
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;
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;
}
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);
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;
}
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;
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);
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;
}
* 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)
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;
}
* 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;
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
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;
}
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) {
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;
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;
}
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;
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)
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);
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;
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;
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;
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
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;
}
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);
}
#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,
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; \
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; \
{
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];
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;
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);
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;
}
#ifdef DEBUG_CONFIG
- Print(L"***NOT FOUND\n");
+ console_print(L"***NOT FOUND\n");
console_get_keystroke();
#endif
|| 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;
}
#include "shim.h"
-#include <Library/BaseCryptLib.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-
static int
count_lines(CHAR16 *str_arr[])
{
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,
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)
Line = AllocatePool((size_cols+1)*sizeof(CHAR16));
if (!Line) {
- Print(L"Failed Allocation\n");
+ console_print(L"Failed Allocation\n");
return;
}
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;
}
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;
}
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;
*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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
*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;
}
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)++;
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)++;
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;
}
}
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;
}
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;
}
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));
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)
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,
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;
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);
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;
}
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;
}
}
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);
}
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;
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. */
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);
* 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);
}
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__)