summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/configtable.c30
-rw-r--r--lib/console.c53
-rw-r--r--lib/execute.c2
-rw-r--r--lib/shell.c2
-rw-r--r--lib/simple_file.c22
-rw-r--r--lib/variables.c6
6 files changed, 75 insertions, 40 deletions
diff --git a/lib/configtable.c b/lib/configtable.c
index 194637ee..df047f0e 100644
--- a/lib/configtable.c
+++ b/lib/configtable.c
@@ -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;
}
diff --git a/lib/console.c b/lib/console.c
index 50687ea4..06b806c6 100644
--- a/lib/console.c
+++ b/lib/console.c
@@ -11,10 +11,6 @@
#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;
diff --git a/lib/execute.c b/lib/execute.c
index 366af3c8..3aff28ad 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -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;
}
diff --git a/lib/shell.c b/lib/shell.c
index 6d2312eb..e46e7fd2 100644
--- a/lib/shell.c
+++ b/lib/shell.c
@@ -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;
}
diff --git a/lib/simple_file.c b/lib/simple_file.c
index 8b2324c0..3bf92ed8 100644
--- a/lib/simple_file.c
+++ b/lib/simple_file.c
@@ -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)++;
diff --git a/lib/variables.c b/lib/variables.c
index 9d9ac603..9c2e7d0a 100644
--- a/lib/variables.c
+++ b/lib/variables.c
@@ -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;
}