diff options
Diffstat (limited to 'lib/efi_selftest')
-rw-r--r-- | lib/efi_selftest/Makefile | 6 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_bitblt.c | 2 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_block_device.c | 10 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_config_table.c | 12 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_devicepath.c | 2 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_fdt.c | 41 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_gop.c | 2 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_loaded_image.c | 5 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_loadimage.c | 9 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_manageprotocols.c | 8 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_memory.c | 4 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_miniapp_exit.c | 19 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_register_notify.c | 231 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_snp.c | 9 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_startimage_exit.c | 15 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_util.c | 14 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_variables.c | 10 |
17 files changed, 328 insertions, 71 deletions
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index c9720c9da8..c69ad7a9c0 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -23,11 +23,11 @@ efi_selftest_events.o \ efi_selftest_event_groups.o \ efi_selftest_exception.o \ efi_selftest_exitbootservices.o \ -efi_selftest_fdt.o \ efi_selftest_gop.o \ efi_selftest_loaded_image.o \ efi_selftest_manageprotocols.o \ efi_selftest_memory.o \ +efi_selftest_register_notify.o \ efi_selftest_rtc.o \ efi_selftest_snp.o \ efi_selftest_textinput.o \ @@ -42,6 +42,10 @@ efi_selftest_watchdog.o obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o +ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) +obj-y += efi_selftest_fdt.o +endif + ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy) obj-y += efi_selftest_block_device.o endif diff --git a/lib/efi_selftest/efi_selftest_bitblt.c b/lib/efi_selftest/efi_selftest_bitblt.c index 9033109807..fb33150c4b 100644 --- a/lib/efi_selftest/efi_selftest_bitblt.c +++ b/lib/efi_selftest/efi_selftest_bitblt.c @@ -23,7 +23,7 @@ static const struct efi_gop_pixel DARK_BLUE = {128, 0, 0, 0}; static const struct efi_gop_pixel LIGHT_BLUE = {255, 192, 192, 0}; static struct efi_boot_services *boottime; -static efi_guid_t efi_gop_guid = EFI_GOP_GUID; +static efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static struct efi_gop *gop; static struct efi_gop_pixel *bitmap; static struct efi_event *event; diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c index 21409aed6f..644c5ade21 100644 --- a/lib/efi_selftest/efi_selftest_block_device.c +++ b/lib/efi_selftest/efi_selftest_block_device.c @@ -24,8 +24,8 @@ static struct efi_boot_services *boottime; -static const efi_guid_t block_io_protocol_guid = BLOCK_IO_GUID; -static const efi_guid_t guid_device_path = DEVICE_PATH_GUID; +static const efi_guid_t block_io_protocol_guid = EFI_BLOCK_IO_PROTOCOL_GUID; +static const efi_guid_t guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID; static const efi_guid_t guid_simple_file_system_protocol = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; static const efi_guid_t guid_file_system_info = EFI_FILE_SYSTEM_INFO_GUID; @@ -337,7 +337,7 @@ static int execute(void) } if (len >= dp_size(dp_partition)) continue; - if (efi_st_memcmp(dp, dp_partition, len)) + if (memcmp(dp, dp_partition, len)) continue; handle_partition = handles[i]; break; @@ -409,7 +409,7 @@ static int execute(void) (unsigned int)buf_size); return EFI_ST_FAILURE; } - if (efi_st_memcmp(buf, "ello world!", 11)) { + if (memcmp(buf, "ello world!", 11)) { efi_st_error("Unexpected file content\n"); return EFI_ST_FAILURE; } @@ -480,7 +480,7 @@ static int execute(void) (unsigned int)buf_size); return EFI_ST_FAILURE; } - if (efi_st_memcmp(buf, "U-Boot", 7)) { + if (memcmp(buf, "U-Boot", 7)) { efi_st_error("Unexpected file content %s\n", buf); return EFI_ST_FAILURE; } diff --git a/lib/efi_selftest/efi_selftest_config_table.c b/lib/efi_selftest/efi_selftest_config_table.c index 0bc5da6b0c..4467f492ac 100644 --- a/lib/efi_selftest/efi_selftest_config_table.c +++ b/lib/efi_selftest/efi_selftest_config_table.c @@ -153,8 +153,8 @@ static int execute(void) } table = NULL; for (i = 0; i < sys_table->nr_tables; ++i) { - if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, - sizeof(efi_guid_t))) + if (!memcmp(&sys_table->tables[i].guid, &table_guid, + sizeof(efi_guid_t))) table = sys_table->tables[i].table; } if (!table) { @@ -192,8 +192,8 @@ static int execute(void) table = NULL; tabcnt = 0; for (i = 0; i < sys_table->nr_tables; ++i) { - if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, - sizeof(efi_guid_t))) { + if (!memcmp(&sys_table->tables[i].guid, &table_guid, + sizeof(efi_guid_t))) { table = sys_table->tables[i].table; ++tabcnt; } @@ -235,8 +235,8 @@ static int execute(void) } table = NULL; for (i = 0; i < sys_table->nr_tables; ++i) { - if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, - sizeof(efi_guid_t))) { + if (!memcmp(&sys_table->tables[i].guid, &table_guid, + sizeof(efi_guid_t))) { table = sys_table->tables[i].table; } } diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c index 105ce2c92b..4ce3fad895 100644 --- a/lib/efi_selftest/efi_selftest_devicepath.c +++ b/lib/efi_selftest/efi_selftest_devicepath.c @@ -20,7 +20,7 @@ struct interface { void (EFIAPI * inc)(void); } interface; -static efi_guid_t guid_device_path = DEVICE_PATH_GUID; +static efi_guid_t guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID; static efi_guid_t guid_device_path_to_text_protocol = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; diff --git a/lib/efi_selftest/efi_selftest_fdt.c b/lib/efi_selftest/efi_selftest_fdt.c index d545d51812..94d72d3f6d 100644 --- a/lib/efi_selftest/efi_selftest_fdt.c +++ b/lib/efi_selftest/efi_selftest_fdt.c @@ -13,13 +13,15 @@ #include <efi_selftest.h> #include <linux/libfdt.h> -static struct efi_boot_services *boottime; +static const struct efi_system_table *systemtab; +static const struct efi_boot_services *boottime; static const char *fdt; /* This should be sufficient for */ #define BUFFERSIZE 0x100000 -static efi_guid_t fdt_guid = EFI_FDT_GUID; +static const efi_guid_t fdt_guid = EFI_FDT_GUID; +static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; /* * Convert FDT value to host endianness. @@ -115,6 +117,23 @@ static char *get_property(const u16 *property) } } +/** + * efi_st_get_config_table() - get configuration table + * + * @guid: GUID of the configuration table + * Return: pointer to configuration table or NULL + */ +static void *efi_st_get_config_table(const efi_guid_t *guid) +{ + size_t i; + + for (i = 0; i < systab.nr_tables; i++) { + if (!guidcmp(guid, &systemtab->tables[i].guid)) + return systemtab->tables[i].table; + } + return NULL; +} + /* * Setup unit test. * @@ -125,21 +144,22 @@ static char *get_property(const u16 *property) static int setup(const efi_handle_t img_handle, const struct efi_system_table *systable) { - efi_uintn_t i; + void *acpi; + systemtab = systable; boottime = systable->boottime; - /* Find configuration tables */ - for (i = 0; i < systable->nr_tables; ++i) { - if (!efi_st_memcmp(&systable->tables[i].guid, &fdt_guid, - sizeof(efi_guid_t))) - fdt = systable->tables[i].table; - } + acpi = efi_st_get_config_table(&acpi_guid); + fdt = efi_st_get_config_table(&fdt_guid); + if (!fdt) { efi_st_error("Missing device tree\n"); return EFI_ST_FAILURE; } - + if (acpi) { + efi_st_error("Found ACPI table and device tree\n"); + return EFI_ST_FAILURE; + } return EFI_ST_SUCCESS; } @@ -183,5 +203,4 @@ EFI_UNIT_TEST(fdt) = { .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, .setup = setup, .execute = execute, - .on_request = true, }; diff --git a/lib/efi_selftest/efi_selftest_gop.c b/lib/efi_selftest/efi_selftest_gop.c index 5b0e2a9605..4ad043c597 100644 --- a/lib/efi_selftest/efi_selftest_gop.c +++ b/lib/efi_selftest/efi_selftest_gop.c @@ -10,7 +10,7 @@ #include <efi_selftest.h> static struct efi_boot_services *boottime; -static efi_guid_t efi_gop_guid = EFI_GOP_GUID; +static efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static struct efi_gop *gop; /* diff --git a/lib/efi_selftest/efi_selftest_loaded_image.c b/lib/efi_selftest/efi_selftest_loaded_image.c index ea2b380a77..5889ab1261 100644 --- a/lib/efi_selftest/efi_selftest_loaded_image.c +++ b/lib/efi_selftest/efi_selftest_loaded_image.c @@ -60,9 +60,8 @@ static int execute(void) efi_st_printf("%u protocols installed on image handle\n", (unsigned int)protocol_buffer_count); for (i = 0; i < protocol_buffer_count; ++i) { - if (efi_st_memcmp(protocol_buffer[i], - &loaded_image_protocol_guid, - sizeof(efi_guid_t))) + if (memcmp(protocol_buffer[i], &loaded_image_protocol_guid, + sizeof(efi_guid_t))) found = true; } if (!found) { diff --git a/lib/efi_selftest/efi_selftest_loadimage.c b/lib/efi_selftest/efi_selftest_loadimage.c index 96faa67a15..06a87df862 100644 --- a/lib/efi_selftest/efi_selftest_loadimage.c +++ b/lib/efi_selftest/efi_selftest_loadimage.c @@ -27,7 +27,7 @@ static struct efi_boot_services *boottime; static efi_handle_t handle_image; static efi_handle_t handle_volume; -static const efi_guid_t guid_device_path = DEVICE_PATH_GUID; +static const efi_guid_t guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID; static const efi_guid_t guid_simple_file_system_protocol = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; static const efi_guid_t guid_file_info = EFI_FILE_INFO_GUID; @@ -322,8 +322,7 @@ static efi_status_t EFIAPI getinfo efi_uintn_t *buffer_size, void *buffer) { if (this == &file) { - if (efi_st_memcmp(info_type, &guid_file_info, - sizeof(efi_guid_t))) + if (memcmp(info_type, &guid_file_info, sizeof(efi_guid_t))) return EFI_INVALID_PARAMETER; if (*buffer_size >= sizeof(struct file_info)) { boottime->copy_mem(buffer, file_info, @@ -333,8 +332,8 @@ static efi_status_t EFIAPI getinfo return EFI_BUFFER_TOO_SMALL; } } else if (this == &volume) { - if (efi_st_memcmp(info_type, &guid_file_system_info, - sizeof(efi_guid_t))) + if (memcmp(info_type, &guid_file_system_info, + sizeof(efi_guid_t))) return EFI_INVALID_PARAMETER; if (*buffer_size >= sizeof(struct file_system_info)) { boottime->copy_mem(buffer, file_system_info, diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c index 0ff35cec8a..8edb1e4d46 100644 --- a/lib/efi_selftest/efi_selftest_manageprotocols.c +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c @@ -332,13 +332,13 @@ static int execute(void) efi_st_error("Failed to get protocols per handle\n"); return EFI_ST_FAILURE; } - if (efi_st_memcmp(prot_buffer[0], &guid1, 16) && - efi_st_memcmp(prot_buffer[1], &guid1, 16)) { + if (memcmp(prot_buffer[0], &guid1, 16) && + memcmp(prot_buffer[1], &guid1, 16)) { efi_st_error("Failed to get protocols per handle\n"); return EFI_ST_FAILURE; } - if (efi_st_memcmp(prot_buffer[0], &guid3, 16) && - efi_st_memcmp(prot_buffer[1], &guid3, 16)) { + if (memcmp(prot_buffer[0], &guid3, 16) && + memcmp(prot_buffer[1], &guid3, 16)) { efi_st_error("Failed to get protocols per handle\n"); return EFI_ST_FAILURE; } diff --git a/lib/efi_selftest/efi_selftest_memory.c b/lib/efi_selftest/efi_selftest_memory.c index 5eeb42a9be..e71732dc6d 100644 --- a/lib/efi_selftest/efi_selftest_memory.c +++ b/lib/efi_selftest/efi_selftest_memory.c @@ -33,8 +33,8 @@ static int setup(const efi_handle_t handle, boottime = systable->boottime; for (i = 0; i < systable->nr_tables; ++i) { - if (!efi_st_memcmp(&systable->tables[i].guid, &fdt_guid, - sizeof(efi_guid_t))) { + if (!memcmp(&systable->tables[i].guid, &fdt_guid, + sizeof(efi_guid_t))) { if (fdt_addr) { efi_st_error("Duplicate device tree\n"); return EFI_ST_FAILURE; diff --git a/lib/efi_selftest/efi_selftest_miniapp_exit.c b/lib/efi_selftest/efi_selftest_miniapp_exit.c index d63b9e3add..6b5cfb01cf 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exit.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exit.c @@ -9,9 +9,9 @@ */ #include <common.h> -#include <efi_api.h> +#include <efi_selftest.h> -static efi_guid_t loaded_image_protocol_guid = LOADED_IMAGE_GUID; +static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; /** * check_loaded_image_protocol() - check image_base/image_size @@ -66,15 +66,22 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, struct efi_system_table *systable) { struct efi_simple_text_output_protocol *con_out = systable->con_out; - efi_status_t ret = EFI_UNSUPPORTED; + efi_status_t ret; + u16 text[] = EFI_ST_SUCCESS_STR; con_out->output_string(con_out, L"EFI application calling Exit\n"); - if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS) + if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS) { + con_out->output_string(con_out, + L"Loaded image protocol missing\n"); ret = EFI_NOT_FOUND; + goto out; + } - /* The return value is checked by the calling test */ - systable->boottime->exit(handle, ret, 0, NULL); + /* This return value is expected by the calling test */ + ret = EFI_UNSUPPORTED; +out: + systable->boottime->exit(handle, ret, sizeof(text), text); /* * This statement should not be reached. diff --git a/lib/efi_selftest/efi_selftest_register_notify.c b/lib/efi_selftest/efi_selftest_register_notify.c new file mode 100644 index 0000000000..ee0ef395de --- /dev/null +++ b/lib/efi_selftest/efi_selftest_register_notify.c @@ -0,0 +1,231 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * efi_selftest_register_notify + * + * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de> + * + * This unit test checks the following protocol services: + * InstallProtocolInterface, UninstallProtocolInterface, + * RegisterProtocolNotify, CreateEvent, CloseEvent. + */ + +#include <efi_selftest.h> + +/* + * The test currently does not actually call the interface function. + * So this is just a dummy structure. + */ +struct interface { + void (EFIAPI * inc)(void); +}; + +struct context { + void *registration_key; + efi_uintn_t notify_count; + efi_uintn_t handle_count; + efi_handle_t *handles; +}; + +static struct efi_boot_services *boottime; +static efi_guid_t guid1 = + EFI_GUID(0x2e7ca819, 0x21d3, 0x0a3a, + 0xf7, 0x91, 0x82, 0x1f, 0x7a, 0x83, 0x67, 0xaf); +static efi_guid_t guid2 = + EFI_GUID(0xf909f2bb, 0x90a8, 0x0d77, + 0x94, 0x0c, 0x3e, 0xa8, 0xea, 0x38, 0xd6, 0x6f); +static struct context context; +static struct efi_event *event; + +/* + * Notification function, increments the notification count if parameter + * context is provided. + * + * @event notified event + * @context pointer to the notification count + */ +static void EFIAPI notify(struct efi_event *event, void *context) +{ + struct context *cp = context; + efi_status_t ret; + + cp->notify_count++; + + ret = boottime->locate_handle_buffer(BY_REGISTER_NOTIFY, NULL, + cp->registration_key, + &cp->handle_count, + &cp->handles); + if (ret != EFI_SUCCESS) + cp->handle_count = 0; +} + +/* + * Setup unit test. + * + * @handle: handle of the loaded image + * @systable: system table + */ +static int setup(const efi_handle_t img_handle, + const struct efi_system_table *systable) +{ + efi_status_t ret; + + boottime = systable->boottime; + + ret = boottime->create_event(EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, notify, &context, + &event); + if (ret != EFI_SUCCESS) { + efi_st_error("could not create event\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->register_protocol_notify(&guid1, event, + &context.registration_key); + if (ret != EFI_SUCCESS) { + efi_st_error("could not register event\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +/* + * Tear down unit test. + * + */ +static int teardown(void) +{ + efi_status_t ret; + + if (event) { + ret = boottime->close_event(event); + event = NULL; + if (ret != EFI_SUCCESS) { + efi_st_error("could not close event\n"); + return EFI_ST_FAILURE; + } + } + + return EFI_ST_SUCCESS; +} + +/* + * Execute unit test. + * + */ +static int execute(void) +{ + efi_status_t ret; + efi_handle_t handle1 = NULL, handle2 = NULL; + struct interface interface1, interface2; + + ret = boottime->install_protocol_interface(&handle1, &guid1, + EFI_NATIVE_INTERFACE, + &interface1); + if (ret != EFI_SUCCESS) { + efi_st_error("could not install interface\n"); + return EFI_ST_FAILURE; + } + if (!context.notify_count) { + efi_st_error("install was not notified\n"); + return EFI_ST_FAILURE; + } + if (context.notify_count > 1) { + efi_st_error("install was notified too often\n"); + return EFI_ST_FAILURE; + } + if (context.handle_count != 1) { + efi_st_error("LocateHandle failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(context.handles); + if (ret != EFI_SUCCESS) { + efi_st_error("FreePool failed\n"); + return EFI_ST_FAILURE; + } + context.notify_count = 0; + ret = boottime->install_protocol_interface(&handle1, &guid2, + EFI_NATIVE_INTERFACE, + &interface1); + if (ret != EFI_SUCCESS) { + efi_st_error("could not install interface\n"); + return EFI_ST_FAILURE; + } + if (context.notify_count) { + efi_st_error("wrong protocol was notified\n"); + return EFI_ST_FAILURE; + } + context.notify_count = 0; + ret = boottime->reinstall_protocol_interface(handle1, &guid1, + &interface1, &interface2); + if (ret != EFI_SUCCESS) { + efi_st_error("could not reinstall interface\n"); + return EFI_ST_FAILURE; + } + if (!context.notify_count) { + efi_st_error("reinstall was not notified\n"); + return EFI_ST_FAILURE; + } + if (context.notify_count > 1) { + efi_st_error("reinstall was notified too often\n"); + return EFI_ST_FAILURE; + } + if (context.handle_count != 1) { + efi_st_error("LocateHandle failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(context.handles); + if (ret != EFI_SUCCESS) { + efi_st_error("FreePool failed\n"); + return EFI_ST_FAILURE; + } + context.notify_count = 0; + ret = boottime->install_protocol_interface(&handle2, &guid1, + EFI_NATIVE_INTERFACE, + &interface1); + if (ret != EFI_SUCCESS) { + efi_st_error("could not install interface\n"); + return EFI_ST_FAILURE; + } + if (!context.notify_count) { + efi_st_error("install was not notified\n"); + return EFI_ST_FAILURE; + } + if (context.notify_count > 1) { + efi_st_error("install was notified too often\n"); + return EFI_ST_FAILURE; + } + if (context.handle_count != 2) { + efi_st_error("LocateHandle failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(context.handles); + if (ret != EFI_SUCCESS) { + efi_st_error("FreePool failed\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->uninstall_multiple_protocol_interfaces + (handle1, &guid1, &interface2, + &guid2, &interface1, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->uninstall_multiple_protocol_interfaces + (handle2, &guid1, &interface1, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +EFI_UNIT_TEST(regprotnot) = { + .name = "register protocol notify", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, + .teardown = teardown, +}; diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c index f1e23c4921..4c26619001 100644 --- a/lib/efi_selftest/efi_selftest_snp.c +++ b/lib/efi_selftest/efi_selftest_snp.c @@ -66,7 +66,7 @@ struct dhcp { static struct efi_boot_services *boottime; static struct efi_simple_network *net; static struct efi_event *timer; -static const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_GUID; +static const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; /* IP packet ID */ static unsigned int net_ip_id; @@ -334,9 +334,8 @@ static int execute(void) * Unfortunately QEMU ignores the broadcast flag. * So we have to check for broadcasts too. */ - if (efi_st_memcmp(&destaddr, &net->mode->current_address, - ARP_HLEN) && - efi_st_memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) + if (memcmp(&destaddr, &net->mode->current_address, ARP_HLEN) && + memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) continue; /* * Check this is a DHCP reply @@ -360,7 +359,7 @@ static int execute(void) addr = (u8 *)&buffer.p.ip_udp.ip_src; efi_st_printf("DHCP reply received from %u.%u.%u.%u (%pm) ", addr[0], addr[1], addr[2], addr[3], &srcaddr); - if (!efi_st_memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) + if (!memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) efi_st_printf("as broadcast message.\n"); else efi_st_printf("as unicast message.\n"); diff --git a/lib/efi_selftest/efi_selftest_startimage_exit.c b/lib/efi_selftest/efi_selftest_startimage_exit.c index fa4b7d4a9b..11207b8162 100644 --- a/lib/efi_selftest/efi_selftest_startimage_exit.c +++ b/lib/efi_selftest/efi_selftest_startimage_exit.c @@ -123,6 +123,9 @@ static int execute(void) { efi_status_t ret; efi_handle_t handle; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + u16 expected_text[] = EFI_ST_SUCCESS_STR; ret = boottime->load_image(false, image_handle, NULL, image, img.length, &handle); @@ -130,11 +133,21 @@ static int execute(void) efi_st_error("Failed to load image\n"); return EFI_ST_FAILURE; } - ret = boottime->start_image(handle, NULL, NULL); + ret = boottime->start_image(handle, &exit_data_size, &exit_data); if (ret != EFI_UNSUPPORTED) { efi_st_error("Wrong return value from application\n"); return EFI_ST_FAILURE; } + if (!exit_data || exit_data_size != sizeof(expected_text) || + memcmp(exit_data, expected_text, sizeof(expected_text))) { + efi_st_error("Incorrect exit data\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(exit_data); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to free exit data\n"); + return EFI_ST_FAILURE; + } return EFI_ST_SUCCESS; } diff --git a/lib/efi_selftest/efi_selftest_util.c b/lib/efi_selftest/efi_selftest_util.c index 96a964c863..ea73c25220 100644 --- a/lib/efi_selftest/efi_selftest_util.c +++ b/lib/efi_selftest/efi_selftest_util.c @@ -102,20 +102,6 @@ u16 *efi_st_translate_code(u16 code) return efi_st_unknown; } -int efi_st_memcmp(const void *buf1, const void *buf2, size_t length) -{ - const u8 *pos1 = buf1; - const u8 *pos2 = buf2; - - for (; length; --length) { - if (*pos1 != *pos2) - return *pos1 - *pos2; - ++pos1; - ++pos2; - } - return 0; -} - int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2) { for (; *buf1 || *buf2; ++buf1, ++buf2) { diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c index 47a8e7fb95..b028c64bbc 100644 --- a/lib/efi_selftest/efi_selftest_variables.c +++ b/lib/efi_selftest/efi_selftest_variables.c @@ -78,7 +78,7 @@ static int execute(void) efi_st_error("GetVariable failed\n"); return EFI_ST_FAILURE; } - if (efi_st_memcmp(data, v + 4, 3)) { + if (memcmp(data, v + 4, 3)) { efi_st_error("GetVariable returned wrong value\n"); return EFI_ST_FAILURE; } @@ -106,7 +106,7 @@ static int execute(void) (unsigned int)len); return EFI_ST_FAILURE; } - if (efi_st_memcmp(data, v, 8)) { + if (memcmp(data, v, 8)) { efi_st_error("GetVariable returned wrong value\n"); return EFI_ST_FAILURE; } @@ -129,7 +129,7 @@ static int execute(void) if (len != 15) efi_st_todo("GetVariable returned wrong length %u\n", (unsigned int)len); - if (efi_st_memcmp(data, v, len)) + if (memcmp(data, v, len)) efi_st_todo("GetVariable returned wrong value\n"); /* Enumerate variables */ boottime->set_mem(&guid, 16, 0); @@ -145,10 +145,10 @@ static int execute(void) (unsigned int)ret); return EFI_ST_FAILURE; } - if (!efi_st_memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) && + if (!memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) && !efi_st_strcmp_16_8(varname, "efi_st_var0")) flag |= 1; - if (!efi_st_memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) && + if (!memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) && !efi_st_strcmp_16_8(varname, "efi_st_var1")) flag |= 2; } |