diff options
author | Michael Brown <mcb30@ipxe.org> | 2023-05-23 13:47:03 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2023-05-23 13:47:44 +0100 |
commit | 4ade751029484d8e6dff74cf94f729d8841e2c99 (patch) | |
tree | c7db1176a12651a442a570fc504c383ab4b864bc | |
parent | cf79f3514c5f08ce518e4374c37179aabc88d5df (diff) | |
download | ipxe-4ade751029484d8e6dff74cf94f729d8841e2c99.tar.gz |
WIP - tidying
-rw-r--r-- | src/include/ipxe/efi/efi_shim.h | 3 | ||||
-rw-r--r-- | src/interface/efi/efi_shim.c | 97 |
2 files changed, 56 insertions, 44 deletions
diff --git a/src/include/ipxe/efi/efi_shim.h b/src/include/ipxe/efi/efi_shim.h index ad8d24dce..d8761b747 100644 --- a/src/include/ipxe/efi/efi_shim.h +++ b/src/include/ipxe/efi/efi_shim.h @@ -12,6 +12,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/image.h> #include <ipxe/efi/efi.h> +/** SBAT level variable name */ +#define EFI_SHIM_SBAT_LEVEL L"SbatLevel" + extern int efi_shim_require_loader; extern int efi_shim_allow_pxe; extern struct image_tag efi_shim __image_tag; diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c index 517d64db7..9101cfda7 100644 --- a/src/interface/efi/efi_shim.c +++ b/src/interface/efi/efi_shim.c @@ -92,6 +92,59 @@ struct image_tag efi_shim __image_tag = { /** Original GetMemoryMap() function */ static EFI_GET_MEMORY_MAP efi_shim_orig_map; +/** Original ExitBootServices() function */ +static EFI_EXIT_BOOT_SERVICES efi_shim_orig_ebs; + +/** Original GetVariable() function */ +static EFI_GET_VARIABLE efi_shim_orig_get_var; + +/** Original SetVariable() function */ +static EFI_SET_VARIABLE efi_shim_orig_set_var; +static int just_set; + + + + +// +static EFI_STATUS EFIAPI +efi_shim_get_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 *attrs, + UINTN *size, VOID *data ) { + static const CHAR16 foo[] = L"SbatLevel"; + EFI_STATUS efirc; + + efirc = orig_get_var ( name, guid, attrs, size, data ); + DBGC ( &efi_shim, "**** GetVariable ( %ls, %s ):\n", name, + efi_guid_ntoa ( guid ) ); + + if ( ( ! just_set ) && + ( memcmp ( name, foo, sizeof ( foo ) ) == 0 ) ) { + UINT8 *thing = data; + DBGC ( &efi_shim, "**** HAHAHAHAHA\n" ); + *thing = '\0'; + } + if ( data ) + just_set = 0; + + if ( data ) + DBGC_HDA ( &efi_shim, 0, data, *size ); + return efirc; +} + +static EFI_STATUS EFIAPI +efi_shim_set_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 attrs, + UINTN size, VOID *data ) { + EFI_STATUS efirc; + + DBGC ( &efi_shim, "**** SetVariable ( %ls, %s ):\n", name, + efi_guid_ntoa ( guid ) ); + DBGC_HDA ( &efi_shim, 0, data, size ); + efirc = orig_set_var ( name, guid, attrs, size, data ); + + just_set = 1; + + return efirc; +} + /** * Unlock UEFI shim * @@ -207,50 +260,6 @@ static int efi_shim_cmdline ( struct image *shim, wchar_t **cmdline ) { return 0; } -static EFI_GET_VARIABLE orig_get_var; -static EFI_SET_VARIABLE orig_set_var; -static int just_set; - -// -static EFI_STATUS EFIAPI -efi_shim_get_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 *attrs, - UINTN *size, VOID *data ) { - static const CHAR16 foo[] = L"SbatLevel"; - EFI_STATUS efirc; - - efirc = orig_get_var ( name, guid, attrs, size, data ); - DBGC ( &efi_shim, "**** GetVariable ( %ls, %s ):\n", name, - efi_guid_ntoa ( guid ) ); - - if ( ( ! just_set ) && - ( memcmp ( name, foo, sizeof ( foo ) ) == 0 ) ) { - UINT8 *thing = data; - DBGC ( &efi_shim, "**** HAHAHAHAHA\n" ); - *thing = '\0'; - } - if ( data ) - just_set = 0; - - if ( data ) - DBGC_HDA ( &efi_shim, 0, data, *size ); - return efirc; -} - -static EFI_STATUS EFIAPI -efi_shim_set_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 attrs, - UINTN size, VOID *data ) { - EFI_STATUS efirc; - - DBGC ( &efi_shim, "**** SetVariable ( %ls, %s ):\n", name, - efi_guid_ntoa ( guid ) ); - DBGC_HDA ( &efi_shim, 0, data, size ); - efirc = orig_set_var ( name, guid, attrs, size, data ); - - just_set = 1; - - return efirc; -} - /** * Install UEFI shim special handling * |