Make verbose stuff use console_notify

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2013-09-27 11:32:49 -04:00
parent f7b849be1c
commit 09a37bbc69
6 changed files with 48 additions and 37 deletions

View File

@ -38,9 +38,9 @@ VERSION = 0.4
TARGET = shim.efi MokManager.efi.signed fallback.efi.signed
OBJS = shim.o netboot.o cert.o replacements.o
KEYS = shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key
SOURCES = shim.c shim.h netboot.c include/PeImage.h include/wincert.h replacements.c replacements.h
SOURCES = shim.c shim.h netboot.c include/PeImage.h include/wincert.h include/console.h replacements.c replacements.h include/console_control.h
MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o
MOK_SOURCES = MokManager.c shim.h console_control.h PasswordCrypt.c PasswordCrypt.h crypt_blowfish.c crypt_blowfish.h
MOK_SOURCES = MokManager.c shim.h include/console_control.h PasswordCrypt.c PasswordCrypt.h crypt_blowfish.c crypt_blowfish.h
FALLBACK_OBJS = fallback.o
FALLBACK_SRCS = fallback.c

View File

@ -6,7 +6,6 @@
#include "shim.h"
#include "PeImage.h"
#include "PasswordCrypt.h"
#include "console_control.h"
#include "guid.h"
#include "console.h"
@ -1749,34 +1748,6 @@ static EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
return EFI_SUCCESS;
}
static VOID setup_console (int text)
{
EFI_STATUS status;
EFI_GUID console_control_guid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
EFI_CONSOLE_CONTROL_PROTOCOL *concon;
static EFI_CONSOLE_CONTROL_SCREEN_MODE mode =
EfiConsoleControlScreenGraphics;
EFI_CONSOLE_CONTROL_SCREEN_MODE new_mode;
status = LibLocateProtocol(&console_control_guid, (VOID **)&concon);
if (status != EFI_SUCCESS)
return;
if (text) {
new_mode = EfiConsoleControlScreenText;
status = uefi_call_wrapper(concon->GetMode, 4, concon, &mode,
0, 0);
/* If that didn't work, assume it's graphics */
if (status != EFI_SUCCESS)
mode = EfiConsoleControlScreenGraphics;
} else {
new_mode = mode;
}
uefi_call_wrapper(concon->SetMode, 2, concon, new_mode);
}
static EFI_STATUS setup_rand (void)
{
EFI_TIME time;

View File

@ -41,4 +41,6 @@ struct _EFI_CONSOLE_CONTROL_PROTOCOL {
EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn;
};
extern VOID setup_console (int text);
#endif /* _SHIM_CONSOLE_CONTROL_H */

View File

@ -1,6 +1,6 @@
TARGET = lib.a
LIBFILES = simple_file.o guid.o console.o execute.o configtable.o shell.o variables.o security_policy.o
LIBFILES = simple_file.o guid.o console.o execute.o configtable.o shell.o variables.o security_policy.o console_control.o
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)

32
lib/console_control.c Normal file
View File

@ -0,0 +1,32 @@
#include <efi.h>
#include <efilib.h>
#include "console_control.h"
VOID setup_console (int text)
{
EFI_STATUS status;
EFI_GUID console_control_guid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
EFI_CONSOLE_CONTROL_PROTOCOL *concon;
static EFI_CONSOLE_CONTROL_SCREEN_MODE mode =
EfiConsoleControlScreenGraphics;
EFI_CONSOLE_CONTROL_SCREEN_MODE new_mode;
status = LibLocateProtocol(&console_control_guid, (VOID **)&concon);
if (status != EFI_SUCCESS)
return;
if (text) {
new_mode = EfiConsoleControlScreenText;
status = uefi_call_wrapper(concon->GetMode, 4, concon, &mode,
0, 0);
/* If that didn't work, assume it's graphics */
if (status != EFI_SUCCESS)
mode = EfiConsoleControlScreenGraphics;
} else {
new_mode = mode;
}
uefi_call_wrapper(concon->SetMode, 2, concon, new_mode);
}

16
shim.c
View File

@ -43,10 +43,12 @@
#include "replacements.h"
#include "ucs2.h"
#include "console_control.h"
#include "guid.h"
#include "variables.h"
#include "efiauthenticated.h"
#include "security_policy.h"
#include "console.h"
#define FALLBACK L"\\fallback.efi"
#define MOK_MANAGER L"\\MokManager.efi"
@ -446,7 +448,7 @@ static BOOLEAN secure_mode (void)
/* FIXME - more paranoia here? */
if (status != EFI_SUCCESS || sb != 1) {
if (verbose)
Print(L"Secure boot not enabled\n");
console_notify(L"Secure boot not enabled\n");
return FALSE;
}
@ -456,7 +458,7 @@ static BOOLEAN secure_mode (void)
if (status == EFI_SUCCESS && setupmode == 1) {
if (verbose)
Print(L"Platform is in setup mode\n");
console_notify(L"Platform is in setup mode\n");
return FALSE;
}
@ -720,7 +722,7 @@ static EFI_STATUS verify_buffer (char *data, int datasize,
if (status == EFI_SUCCESS) {
if (verbose)
Print(L"Binary is whitelisted\n");
console_notify(L"Binary is whitelisted\n");
return status;
}
@ -733,7 +735,7 @@ static EFI_STATUS verify_buffer (char *data, int datasize,
SHA256_DIGEST_SIZE)) {
status = EFI_SUCCESS;
if (verbose)
Print(L"Binary is verified by the vendor certificate\n");
console_notify(L"Binary is verified by the vendor certificate\n");
return status;
}
@ -747,7 +749,7 @@ static EFI_STATUS verify_buffer (char *data, int datasize,
SHA256_DIGEST_SIZE)) {
status = EFI_SUCCESS;
if (verbose)
Print(L"Binary is verified by the vendor certificate\n");
console_notify(L"Binary is verified by the vendor certificate\n");
return status;
}
@ -1590,6 +1592,8 @@ EFI_STATUS efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *passed_systab)
*/
InitializeLib(image_handle, systab);
setup_console(1);
verbose_check_size = 1;
efi_status = get_variable(L"SHIM_VERBOSE", (void *)&verbose_check,
&verbose_check_size, global_var);
@ -1665,5 +1669,7 @@ EFI_STATUS efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *passed_systab)
if (load_options_size > 0)
FreePool(second_stage);
setup_console(0);
return efi_status;
}