aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_selftest
diff options
context:
space:
mode:
authorTom Rini2018-12-03 17:52:40 -0500
committerTom Rini2018-12-03 17:52:40 -0500
commitf388e3bed7318efe97058b673801dda6f563d319 (patch)
treeed391f6b8cfad1bc53dabeb7239ffcc716a8ca4e /lib/efi_selftest
parentec0d0d8742df12a4c0d3e8382b77c0672cd4aab6 (diff)
parent1a82b3413cb577cd52cf8a1dc22dd306e4ce0772 (diff)
Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot
Patch queue for efi - 2018-12-03 This release is fully packed with lots of glorious improvements in UEFI land again! - Make PE images more standards compliant - Improve sandbox support - Improve correctness - Fix RISC-V execution on virt model - Honor board defined top of ram (fixes a few boards) - Imply DM USB access when distro boot is available - Code cleanups
Diffstat (limited to 'lib/efi_selftest')
-rw-r--r--lib/efi_selftest/Kconfig2
-rw-r--r--lib/efi_selftest/Makefile12
-rw-r--r--lib/efi_selftest/efi_selftest.c31
-rw-r--r--lib/efi_selftest/efi_selftest_config_table.c12
-rw-r--r--lib/efi_selftest/efi_selftest_controllers.c2
-rw-r--r--lib/efi_selftest/efi_selftest_crc32.c4
-rw-r--r--lib/efi_selftest/efi_selftest_devicepath.c2
-rw-r--r--lib/efi_selftest/efi_selftest_event_groups.c4
-rw-r--r--lib/efi_selftest/efi_selftest_events.c2
-rw-r--r--lib/efi_selftest/efi_selftest_exception.c50
-rw-r--r--lib/efi_selftest/efi_selftest_fdt.c2
-rw-r--r--lib/efi_selftest/efi_selftest_loaded_image.c2
-rw-r--r--lib/efi_selftest/efi_selftest_manageprotocols.c18
-rw-r--r--lib/efi_selftest/efi_selftest_memory.c187
-rw-r--r--lib/efi_selftest/efi_selftest_snp.c16
-rw-r--r--lib/efi_selftest/efi_selftest_textinput.c2
-rw-r--r--lib/efi_selftest/efi_selftest_tpl.c2
-rw-r--r--lib/efi_selftest/efi_selftest_unicode_collation.c6
-rw-r--r--lib/efi_selftest/efi_selftest_variables.c6
-rw-r--r--lib/efi_selftest/efi_selftest_watchdog.c2
20 files changed, 310 insertions, 54 deletions
diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig
index b52696778dd..59f9f36801c 100644
--- a/lib/efi_selftest/Kconfig
+++ b/lib/efi_selftest/Kconfig
@@ -1,6 +1,6 @@
config CMD_BOOTEFI_SELFTEST
bool "Allow booting an EFI efi_selftest"
- depends on CMD_BOOTEFI && !SANDBOX
+ depends on CMD_BOOTEFI
imply FAT
imply FAT_WRITE
help
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 2f55d9d66ff..743b4820449 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -10,7 +10,7 @@ CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI) -Os
CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI) -Os
-obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += \
+obj-y += \
efi_selftest.o \
efi_selftest_bitblt.o \
efi_selftest_config_table.o \
@@ -21,11 +21,13 @@ efi_selftest_devicepath.o \
efi_selftest_devicepath_util.o \
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_rtc.o \
efi_selftest_snp.o \
efi_selftest_textinput.o \
@@ -37,20 +39,16 @@ efi_selftest_util.o \
efi_selftest_variables.o \
efi_selftest_watchdog.o
-ifeq ($(CONFIG_CMD_BOOTEFI_SELFTEST),y)
obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o
-endif
ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
-obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += efi_selftest_block_device.o
+obj-y += efi_selftest_block_device.o
endif
# TODO: As of v2018.01 the relocation code for the EFI application cannot
# be built on x86_64.
ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)
-ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),)
-
obj-y += \
efi_selftest_startimage_exit.o \
efi_selftest_startimage_return.o
@@ -74,5 +72,3 @@ $(obj)/efi_selftest_startimage_exit.o: $(obj)/efi_miniapp_file_image_exit.h
$(obj)/efi_selftest_startimage_return.o: $(obj)/efi_miniapp_file_image_return.h
endif
-
-endif
diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c
index dd338db687e..5b01610eca1 100644
--- a/lib/efi_selftest/efi_selftest.c
+++ b/lib/efi_selftest/efi_selftest.c
@@ -18,6 +18,7 @@ static const struct efi_boot_services *boottime;
static const struct efi_runtime_services *runtime;
static efi_handle_t handle;
static u16 reset_message[] = L"Selftest completed";
+static int *setup_status;
/*
* Exit the boot services.
@@ -74,20 +75,20 @@ void efi_st_exit_boot_services(void)
*/
static int setup(struct efi_unit_test *test, unsigned int *failures)
{
- if (!test->setup) {
- test->setup_ok = EFI_ST_SUCCESS;
+ int ret;
+
+ if (!test->setup)
return EFI_ST_SUCCESS;
- }
efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name);
- test->setup_ok = test->setup(handle, systable);
- if (test->setup_ok != EFI_ST_SUCCESS) {
+ ret = test->setup(handle, systable);
+ if (ret != EFI_ST_SUCCESS) {
efi_st_error("Setting up '%s' failed\n", test->name);
++*failures;
} else {
efi_st_printc(EFI_LIGHTGREEN,
"Setting up '%s' succeeded\n", test->name);
}
- return test->setup_ok;
+ return ret;
}
/*
@@ -186,18 +187,20 @@ static void list_all_tests(void)
void efi_st_do_tests(const u16 *testname, unsigned int phase,
unsigned int steps, unsigned int *failures)
{
+ int i = 0;
struct efi_unit_test *test;
for (test = ll_entry_start(struct efi_unit_test, efi_unit_test);
- test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) {
+ test < ll_entry_end(struct efi_unit_test, efi_unit_test);
+ ++test, ++i) {
if (testname ?
efi_st_strcmp_16_8(testname, test->name) : test->on_request)
continue;
if (test->phase != phase)
continue;
if (steps & EFI_ST_SETUP)
- setup(test, failures);
- if (steps & EFI_ST_EXECUTE && test->setup_ok == EFI_ST_SUCCESS)
+ setup_status[i] = setup(test, failures);
+ if (steps & EFI_ST_EXECUTE && setup_status[i] == EFI_ST_SUCCESS)
execute(test, failures);
if (steps & EFI_ST_TEARDOWN)
teardown(test, failures);
@@ -271,6 +274,16 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
ll_entry_count(struct efi_unit_test,
efi_unit_test));
+ /* Allocate buffer for setup results */
+ ret = boottime->allocate_pool(EFI_RUNTIME_SERVICES_DATA, sizeof(int) *
+ ll_entry_count(struct efi_unit_test,
+ efi_unit_test),
+ (void **)&setup_status);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Allocate pool failed\n");
+ return ret;
+ }
+
/* Execute boottime tests */
efi_st_do_tests(testname, EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN,
diff --git a/lib/efi_selftest/efi_selftest_config_table.c b/lib/efi_selftest/efi_selftest_config_table.c
index 2aa3fc72847..0bc5da6b0ce 100644
--- a/lib/efi_selftest/efi_selftest_config_table.c
+++ b/lib/efi_selftest/efi_selftest_config_table.c
@@ -18,7 +18,7 @@ static efi_guid_t table_guid =
0x17, 0x2e, 0x51, 0x6b, 0x49, 0x75);
/*
- * Notification function, increments the notfication count if parameter
+ * Notification function, increments the notification count if parameter
* context is provided.
*
* @event notified event
@@ -33,23 +33,23 @@ static void EFIAPI notify(struct efi_event *event, void *context)
}
/*
- * Check crc32 of a table.
+ * Check CRC32 of a table.
*/
static int check_table(const void *table)
{
efi_status_t ret;
u32 crc32, res;
- /* Casting from const to not const */
+ /* Casting from constant to not constant */
struct efi_table_hdr *hdr = (struct efi_table_hdr *)table;
crc32 = hdr->crc32;
/*
- * Setting the crc32 of the 'const' table to zero is easier than
+ * Setting the CRC32 of the 'const' table to zero is easier than
* copying
*/
hdr->crc32 = 0;
ret = boottime->calculate_crc32(table, hdr->headersize, &res);
- /* Reset table crc32 so it stays constant */
+ /* Reset table CRC32 so it stays constant */
hdr->crc32 = crc32;
if (ret != EFI_ST_SUCCESS) {
efi_st_error("CalculateCrc32 failed\n");
@@ -203,7 +203,7 @@ static int execute(void)
return EFI_ST_FAILURE;
}
if (tabcnt > 1) {
- efi_st_error("Duplicate table guid\n");
+ efi_st_error("Duplicate table GUID\n");
return EFI_ST_FAILURE;
}
if (table != &tables[1]) {
diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c
index d08c377c72c..38720bb63d3 100644
--- a/lib/efi_selftest/efi_selftest_controllers.c
+++ b/lib/efi_selftest/efi_selftest_controllers.c
@@ -33,7 +33,7 @@ static efi_handle_t handle_driver;
* Count child controllers
*
* @handle handle on which child controllers are installed
- * @protocol protocol for which the child controlles where installed
+ * @protocol protocol for which the child controllers were installed
* @count number of child controllers
* @return status code
*/
diff --git a/lib/efi_selftest/efi_selftest_crc32.c b/lib/efi_selftest/efi_selftest_crc32.c
index 8555b8f1140..4881e8ac6f2 100644
--- a/lib/efi_selftest/efi_selftest_crc32.c
+++ b/lib/efi_selftest/efi_selftest_crc32.c
@@ -5,7 +5,7 @@
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
*
* This unit test checks the CalculateCrc32 bootservice and checks the
- * headers of the system table, the boot services tablle, and the runtime
+ * headers of the system table, the boot services table, and the runtime
* services table before and after ExitBootServices().
*/
@@ -19,7 +19,7 @@ static int check_table(const void *table)
{
efi_status_t ret;
u32 crc32, res;
- /* Casting from const to not const */
+ /* Casting from constant to not constant */
struct efi_table_hdr *hdr = (struct efi_table_hdr *)table;
if (!hdr->signature) {
diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c
index adcf531e90a..105ce2c92b3 100644
--- a/lib/efi_selftest/efi_selftest_devicepath.c
+++ b/lib/efi_selftest/efi_selftest_devicepath.c
@@ -257,7 +257,7 @@ static int teardown(void)
static int execute(void)
{
struct efi_device_path *remaining_dp;
- void *handle;
+ efi_handle_t handle;
/*
* This device path node ends with the letter 't' of 'u-boot'.
* The following '.bin' does not belong to the node but is
diff --git a/lib/efi_selftest/efi_selftest_event_groups.c b/lib/efi_selftest/efi_selftest_event_groups.c
index 9b3c5132ef7..5a7980c5d0b 100644
--- a/lib/efi_selftest/efi_selftest_event_groups.c
+++ b/lib/efi_selftest/efi_selftest_event_groups.c
@@ -19,7 +19,7 @@ static efi_guid_t event_group =
0x0e, 0x5b, 0x45, 0xc0, 0x56, 0x91);
/*
- * Notification function, increments the notfication count if parameter
+ * Notification function, increments the notification count if parameter
* context is provided.
*
* @event notified event
@@ -114,7 +114,7 @@ static int execute(void)
(unsigned int)i, (unsigned int)j,
(unsigned int)counter[j]);
efi_st_error(
- "Nofification function not called\n");
+ "Notification function not called\n");
return EFI_ST_FAILURE;
}
}
diff --git a/lib/efi_selftest/efi_selftest_events.c b/lib/efi_selftest/efi_selftest_events.c
index 47f9f99318d..ed99a538045 100644
--- a/lib/efi_selftest/efi_selftest_events.c
+++ b/lib/efi_selftest/efi_selftest_events.c
@@ -17,7 +17,7 @@ static unsigned int timer_ticks;
static struct efi_boot_services *boottime;
/*
- * Notification function, increments the notfication count if parameter
+ * Notification function, increments the notification count if parameter
* context is provided.
*
* @event notified event
diff --git a/lib/efi_selftest/efi_selftest_exception.c b/lib/efi_selftest/efi_selftest_exception.c
new file mode 100644
index 00000000000..76cfb88d7c7
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_exception.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_exception
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Test the handling of exceptions by trying to execute an undefined
+ * instruction.
+ */
+
+#include <efi_selftest.h>
+
+/**
+ * undefined_instruction() - try to executed an undefined instruction
+ */
+static void undefined_instruction(void)
+{
+#if defined(CONFIG_ARM)
+ /*
+ * 0xe7f...f. is undefined in ARM mode
+ * 0xde.. is undefined in Thumb mode
+ */
+ asm volatile (".word 0xe7f7defb\n");
+#elif defined(CONFIG_RISCV)
+ asm volatile (".word 0xffffffff\n");
+#elif defined(CONFIG_X86)
+ asm volatile (".word 0xffff\n");
+#endif
+}
+
+/**
+ * execute() - execute unit test
+ *
+ * Return: EFI_ST_SUCCESS for success
+ */
+static int execute(void)
+{
+ undefined_instruction();
+
+ efi_st_error("An undefined instruction exception was not raised\n");
+
+ return EFI_ST_FAILURE;
+}
+
+EFI_UNIT_TEST(exception) = {
+ .name = "exception",
+ .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+ .execute = execute,
+ .on_request = true,
+};
diff --git a/lib/efi_selftest/efi_selftest_fdt.c b/lib/efi_selftest/efi_selftest_fdt.c
index c7bc242b5c4..d545d518120 100644
--- a/lib/efi_selftest/efi_selftest_fdt.c
+++ b/lib/efi_selftest/efi_selftest_fdt.c
@@ -16,7 +16,7 @@
static struct efi_boot_services *boottime;
static const char *fdt;
-/* This should be sufficent for */
+/* This should be sufficient for */
#define BUFFERSIZE 0x100000
static efi_guid_t fdt_guid = EFI_FDT_GUID;
diff --git a/lib/efi_selftest/efi_selftest_loaded_image.c b/lib/efi_selftest/efi_selftest_loaded_image.c
index f9b54ae2635..ea2b380a777 100644
--- a/lib/efi_selftest/efi_selftest_loaded_image.c
+++ b/lib/efi_selftest/efi_selftest_loaded_image.c
@@ -53,7 +53,7 @@ static int execute(void)
efi_st_error("ProtocolsPerHandle failed\n");
return EFI_ST_FAILURE;
}
- if (!protocol_buffer_count | !protocol_buffer) {
+ if (!protocol_buffer_count || !protocol_buffer) {
efi_st_error("ProtocolsPerHandle returned no protocol\n");
return EFI_ST_FAILURE;
}
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index b09e4cdcfa5..0ff35cec8a7 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -189,7 +189,14 @@ static int execute(void)
/*
* Test error handling in UninstallMultipleProtocols
*
- * Try to uninstall more protocols than there are installed.
+ * These are the installed protocol interfaces on handle 2:
+ *
+ * guid1 interface4
+ * guid2 interface2
+ *
+ * Try to uninstall more protocols than there are installed. This
+ * should return an error EFI_INVALID_PARAMETER. All deleted protocols
+ * should be reinstalled.
*/
ret = boottime->uninstall_multiple_protocol_interfaces(
handle2,
@@ -197,13 +204,18 @@ static int execute(void)
&guid2, &interface2,
&guid3, &interface3,
NULL);
- if (ret == EFI_SUCCESS) {
+ if (ret != EFI_INVALID_PARAMETER) {
+ printf("%lx", ret);
efi_st_error("UninstallMultipleProtocolInterfaces did not catch error\n");
return EFI_ST_FAILURE;
}
/*
* Test LocateHandleBuffer with ByProtocol
+ *
+ * These are the handles with a guid1 protocol interface installed:
+ *
+ * handle1, handle2
*/
count = buffer_size;
ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
@@ -213,7 +225,7 @@ static int execute(void)
return EFI_ST_FAILURE;
}
if (count != 2) {
- efi_st_error("LocateHandleBuffer failed to locate new handles\n");
+ efi_st_error("UninstallMultipleProtocolInterfaces deleted handle\n");
return EFI_ST_FAILURE;
}
ret = find_in_buffer(handle1, count, buffer);
diff --git a/lib/efi_selftest/efi_selftest_memory.c b/lib/efi_selftest/efi_selftest_memory.c
new file mode 100644
index 00000000000..24b4438ce4f
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_memory.c
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_memory
+ *
+ * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * This unit test checks the following runtime services:
+ * AllocatePages, FreePages, GetMemoryMap
+ *
+ * The memory type used for the device tree is checked.
+ */
+
+#include <efi_selftest.h>
+
+#define EFI_ST_NUM_PAGES 8
+
+static const efi_guid_t fdt_guid = EFI_FDT_GUID;
+static struct efi_boot_services *boottime;
+static u64 fdt_addr;
+
+/**
+ * setup() - setup unit test
+ *
+ * @handle: handle of the loaded image
+ * @systable: system table
+ * Return: EFI_ST_SUCCESS for success
+ */
+static int setup(const efi_handle_t handle,
+ const struct efi_system_table *systable)
+{
+ size_t i;
+
+ 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 (fdt_addr) {
+ efi_st_error("Duplicate device tree\n");
+ return EFI_ST_FAILURE;
+ }
+ fdt_addr = (uintptr_t)systable->tables[i].table;
+ }
+ }
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * find_in_memory_map() - check matching memory map entry exists
+ *
+ * @memory_map: memory map
+ * @desc_size: number of memory map entries
+ * @addr: physical address to find in the map
+ * @type: expected memory type
+ * Return: EFI_ST_SUCCESS for success
+ */
+static int find_in_memory_map(efi_uintn_t map_size,
+ struct efi_mem_desc *memory_map,
+ efi_uintn_t desc_size,
+ u64 addr, int memory_type)
+{
+ efi_uintn_t i;
+ bool found = false;
+
+ for (i = 0; map_size; ++i, map_size -= desc_size) {
+ struct efi_mem_desc *entry = &memory_map[i];
+
+ if (addr >= entry->physical_start &&
+ addr < entry->physical_start +
+ (entry->num_pages << EFI_PAGE_SHIFT)) {
+ if (found) {
+ efi_st_error("Duplicate memory map entry\n");
+ return EFI_ST_FAILURE;
+ }
+ found = true;
+ if (memory_type != entry->type) {
+ efi_st_error
+ ("Wrong memory type %d, expected %d\n",
+ entry->type, memory_type);
+ return EFI_ST_FAILURE;
+ }
+ }
+ }
+ if (!found) {
+ efi_st_error("Missing memory map entry\n");
+ return EFI_ST_FAILURE;
+ }
+ return EFI_ST_SUCCESS;
+}
+
+/*
+ * execute() - execute unit test
+ *
+ * Return: EFI_ST_SUCCESS for success
+ */
+static int execute(void)
+{
+ u64 p1;
+ u64 p2;
+ efi_uintn_t map_size = 0;
+ efi_uintn_t map_key;
+ efi_uintn_t desc_size;
+ u32 desc_version;
+ struct efi_mem_desc *memory_map;
+ efi_status_t ret;
+
+ /* Allocate two page ranges with different memory type */
+ ret = boottime->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_RUNTIME_SERVICES_CODE,
+ EFI_ST_NUM_PAGES, &p1);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("AllocatePages did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+ ret = boottime->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_RUNTIME_SERVICES_DATA,
+ EFI_ST_NUM_PAGES, &p2);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("AllocatePages did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* Load memory map */
+ ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size,
+ &desc_version);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ efi_st_error
+ ("GetMemoryMap did not return EFI_BUFFER_TOO_SMALL\n");
+ return EFI_ST_FAILURE;
+ }
+ /* Allocate extra space for newly allocated memory */
+ map_size += sizeof(struct efi_mem_desc);
+ ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,
+ (void **)&memory_map);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("AllocatePool did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+ ret = boottime->get_memory_map(&map_size, memory_map, &map_key,
+ &desc_size, &desc_version);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("GetMemoryMap did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* Check memory map entries */
+ if (find_in_memory_map(map_size, memory_map, desc_size, p1,
+ EFI_RUNTIME_SERVICES_CODE) != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+ if (find_in_memory_map(map_size, memory_map, desc_size, p2,
+ EFI_RUNTIME_SERVICES_DATA) != EFI_ST_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ /* Free memory */
+ ret = boottime->free_pages(p1, EFI_ST_NUM_PAGES);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("FreePages did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+ ret = boottime->free_pages(p2, EFI_ST_NUM_PAGES);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("FreePages did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+ ret = boottime->free_pool(memory_map);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("FreePool did not return EFI_SUCCESS\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* Check memory reservation for the device tree */
+ if (fdt_addr &&
+ find_in_memory_map(map_size, memory_map, desc_size, fdt_addr,
+ EFI_RUNTIME_SERVICES_DATA) != EFI_ST_SUCCESS) {
+ efi_st_error
+ ("Device tree not marked as runtime services data\n");
+ return EFI_ST_FAILURE;
+ }
+ return EFI_ST_SUCCESS;
+}
+
+EFI_UNIT_TEST(memory) = {
+ .name = "memory",
+ .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+ .setup = setup,
+ .execute = execute,
+};
diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c
index 09bd53da82d..e10a34ba645 100644
--- a/lib/efi_selftest/efi_selftest_snp.c
+++ b/lib/efi_selftest/efi_selftest_snp.c
@@ -103,7 +103,7 @@ static efi_status_t send_dhcp_discover(void)
struct dhcp p = {};
/*
- * Fill ethernet header
+ * Fill Ethernet header
*/
boottime->copy_mem(p.eth_hdr.et_dest, (void *)BROADCAST_MAC, ARP_HLEN);
boottime->copy_mem(p.eth_hdr.et_src, &net->mode->current_address,
@@ -229,19 +229,19 @@ static int setup(const efi_handle_t handle,
return EFI_ST_FAILURE;
}
/*
- * Initialize network adapter.
+ * Start network adapter.
*/
- ret = net->initialize(net, 0, 0);
- if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to initialize network adapter\n");
+ ret = net->start(net);
+ if (ret != EFI_SUCCESS && ret != EFI_ALREADY_STARTED) {
+ efi_st_error("Failed to start network adapter\n");
return EFI_ST_FAILURE;
}
/*
- * Start network adapter.
+ * Initialize network adapter.
*/
- ret = net->start(net);
+ ret = net->initialize(net, 0, 0);
if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to start network adapter\n");
+ efi_st_error("Failed to initialize network adapter\n");
return EFI_ST_FAILURE;
}
return EFI_ST_SUCCESS;
diff --git a/lib/efi_selftest/efi_selftest_textinput.c b/lib/efi_selftest/efi_selftest_textinput.c
index 164fbffe6c2..b90671cdd20 100644
--- a/lib/efi_selftest/efi_selftest_textinput.c
+++ b/lib/efi_selftest/efi_selftest_textinput.c
@@ -5,7 +5,7 @@
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
*
* Provides a unit test for the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
- * The unicode character and the scan code are printed for text
+ * The Unicode character and the scan code are printed for text
* input. To run the test:
*
* setenv efi_selftest text input
diff --git a/lib/efi_selftest/efi_selftest_tpl.c b/lib/efi_selftest/efi_selftest_tpl.c
index 61ae46b7976..97d256abe4f 100644
--- a/lib/efi_selftest/efi_selftest_tpl.c
+++ b/lib/efi_selftest/efi_selftest_tpl.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * efi_selftest_events
+ * efi_selftest_tpl
*
* Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
*
diff --git a/lib/efi_selftest/efi_selftest_unicode_collation.c b/lib/efi_selftest/efi_selftest_unicode_collation.c
index 9765bd3e44b..75294307d9f 100644
--- a/lib/efi_selftest/efi_selftest_unicode_collation.c
+++ b/lib/efi_selftest/efi_selftest_unicode_collation.c
@@ -52,7 +52,7 @@ static int test_stri_coll(void)
c1, c2);
if (ret) {
efi_st_error(
- "stri_coll(\"%ps\", \"%ps\") = %zu\n", c1, c2, ret);
+ "stri_coll(\"%ps\", \"%ps\") = %d\n", c1, c2, (int)ret);
return EFI_ST_FAILURE;
}
@@ -60,7 +60,7 @@ static int test_stri_coll(void)
c1, c3);
if (ret >= 0) {
efi_st_error(
- "stri_coll(\"%ps\", \"%ps\") = %zu\n", c1, c3, ret);
+ "stri_coll(\"%ps\", \"%ps\") = %d\n", c1, c3, (int)ret);
return EFI_ST_FAILURE;
}
@@ -68,7 +68,7 @@ static int test_stri_coll(void)
c3, c1);
if (ret <= 0) {
efi_st_error(
- "stri_coll(\"%ps\", \"%ps\") = %zu\n", c3, c1, ret);
+ "stri_coll(\"%ps\", \"%ps\") = %d\n", c3, c1, (int)ret);
return EFI_ST_FAILURE;
}
diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c
index 146378fb9a2..e4c389a872f 100644
--- a/lib/efi_selftest/efi_selftest_variables.c
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -4,10 +4,8 @@
*
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>
*
- * This unit test checks the following protocol services:
- * ConnectController, DisconnectController,
- * InstallProtocol, ReinstallProtocol, UninstallProtocol,
- * OpenProtocol, CloseProtcol, OpenProtocolInformation
+ * This unit test checks the runtime services for variables:
+ * GetVariable, GetNextVariableName, SetVariable, QueryVariableInfo.
*/
#include <efi_selftest.h>
diff --git a/lib/efi_selftest/efi_selftest_watchdog.c b/lib/efi_selftest/efi_selftest_watchdog.c
index bff2330918c..cbc6761721c 100644
--- a/lib/efi_selftest/efi_selftest_watchdog.c
+++ b/lib/efi_selftest/efi_selftest_watchdog.c
@@ -35,7 +35,7 @@ static struct notify_context notification_context;
static bool watchdog_reset;
/*
- * Notification function, increments the notfication count if parameter
+ * Notification function, increments the notification count if parameter
* context is provided.
*
* @event notified event