Compare commits
8 Commits
cherry-0e2
...
efip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a09ff35b8 | ||
|
|
2c43bef7c1 | ||
|
|
fe023fbdae | ||
|
|
a5a806a3ad | ||
|
|
77bf846ebe | ||
|
|
559e094354 | ||
|
|
8394d4f70a | ||
|
|
881dd52cf3 |
@@ -180,4 +180,5 @@ U_BOOT_DRIVER(usb_sandbox) = {
|
||||
.probe = sandbox_usb_probe,
|
||||
.ops = &sandbox_usb_ops,
|
||||
.priv_auto = sizeof(struct sandbox_usb_ctrl),
|
||||
.flags = DM_FLAG_ACTIVE_DMA,
|
||||
};
|
||||
|
||||
@@ -340,8 +340,7 @@ void show_rec(int seq, struct efil_rec_hdr *rec_hdr)
|
||||
show_ulong("pgs", (ulong)rec->pages);
|
||||
show_addr("mem", (ulong)rec->memory);
|
||||
if (rec_hdr->ended) {
|
||||
show_addr("*mem",
|
||||
(ulong)map_to_sysmem((void *)rec->e_memory));
|
||||
show_addr("*mem", rec->e_memory);
|
||||
show_ret(rec_hdr->e_ret);
|
||||
}
|
||||
break;
|
||||
@@ -349,7 +348,7 @@ void show_rec(int seq, struct efil_rec_hdr *rec_hdr)
|
||||
case EFILT_FREE_PAGES: {
|
||||
struct efil_free_pages *rec = start;
|
||||
|
||||
show_addr("mem", map_to_sysmem((void *)rec->memory));
|
||||
show_addr("mem", rec->memory);
|
||||
show_ulong("pag", (ulong)rec->pages);
|
||||
if (rec_hdr->ended)
|
||||
show_ret(rec_hdr->e_ret);
|
||||
|
||||
@@ -735,10 +735,11 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
|
||||
list_for_each_entry(lmem, &efi_mem, link) {
|
||||
memory_map->type = lmem->type;
|
||||
memory_map->reserved = 0;
|
||||
memory_map->physical_start = lmem->base;
|
||||
memory_map->physical_start = (u64)(ulong)map_sysmem(lmem->base,
|
||||
lmem->num_pages * EFI_PAGE_SIZE);
|
||||
|
||||
/* virtual and physical are always the same */
|
||||
memory_map->virtual_start = lmem->base;
|
||||
memory_map->virtual_start = memory_map->physical_start;
|
||||
memory_map->num_pages = lmem->num_pages;
|
||||
memory_map->attribute = lmem->attribute;
|
||||
memory_map--;
|
||||
@@ -836,11 +837,11 @@ int efi_memory_init(void)
|
||||
uint64_t efi_bounce_buffer_addr = 0xffffffff;
|
||||
|
||||
if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, EFI_BOOT_SERVICES_DATA,
|
||||
(64 * 1024 * 1024) >> EFI_PAGE_SHIFT,
|
||||
SZ_64M >> EFI_PAGE_SHIFT,
|
||||
&efi_bounce_buffer_addr) != EFI_SUCCESS)
|
||||
return -1;
|
||||
|
||||
efi_bounce_buffer = (void*)(uintptr_t)efi_bounce_buffer_addr;
|
||||
efi_bounce_buffer = map_sysmem(efi_bounce_buffer_addr, SZ_64M);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -28,7 +28,12 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
|
||||
struct efi_system_table *systab)
|
||||
{
|
||||
struct efi_loaded_image *loaded_image;
|
||||
struct efi_mem_desc *map;
|
||||
efi_status_t ret;
|
||||
efi_uintn_t map_size;
|
||||
efi_uintn_t map_key;
|
||||
efi_uintn_t desc_size;
|
||||
u32 desc_version;
|
||||
|
||||
systable = systab;
|
||||
boottime = systable->boottime;
|
||||
@@ -48,6 +53,38 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
|
||||
con_out->output_string(con_out, u"U-Boot test app for EFI_LOADER\r\n");
|
||||
|
||||
out:
|
||||
map_size = 0;
|
||||
ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size,
|
||||
&desc_version);
|
||||
if (ret != EFI_BUFFER_TOO_SMALL) {
|
||||
con_out->output_string(con_out, u"map error A\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,
|
||||
(void **)&map);
|
||||
if (ret) {
|
||||
con_out->output_string(con_out, u"map error B\n");
|
||||
return ret;
|
||||
}
|
||||
/* Allocate extra space for newly allocated memory */
|
||||
map_size += sizeof(struct efi_mem_desc);
|
||||
ret = boottime->get_memory_map(&map_size, map, &map_key, &desc_size,
|
||||
&desc_version);
|
||||
if (ret) {
|
||||
con_out->output_string(con_out, u"map error C\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* exit boot services so that this part of U-Boot can be tested */
|
||||
con_out->output_string(con_out, u"Exiting boot services\n");
|
||||
ret = boottime->exit_boot_services(handle, map_key);
|
||||
if (ret) {
|
||||
con_out->output_string(con_out, u"Failed exit-boot-services\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* now exit for real */
|
||||
con_out->output_string(con_out, u"Exiting test app\n");
|
||||
ret = boottime->exit(handle, ret, 0, NULL);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#include <bloblist.h>
|
||||
#include <bootdev.h>
|
||||
#include <bootflow.h>
|
||||
#include <bootmeth.h>
|
||||
@@ -14,6 +15,7 @@
|
||||
#include <dm.h>
|
||||
#include <efi.h>
|
||||
#include <efi_loader.h>
|
||||
#include <efi_log.h>
|
||||
#include <expo.h>
|
||||
#include <mapmem.h>
|
||||
#ifdef CONFIG_SANDBOX
|
||||
@@ -21,6 +23,7 @@
|
||||
#endif
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <linux/libfdt.h>
|
||||
#include <test/suites.h>
|
||||
#include <test/ut.h>
|
||||
@@ -1271,10 +1274,14 @@ BOOTSTD_TEST(bootflow_android_image_v2, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);
|
||||
/* Test EFI bootmeth */
|
||||
static int bootflow_efi(struct unit_test_state *uts)
|
||||
{
|
||||
struct efil_hdr *hdr = bloblist_find(BLOBLISTT_EFI_LOG, 0);
|
||||
static const char *order[] = {"mmc1", "usb", NULL};
|
||||
struct efil_rec_hdr *rec_hdr;
|
||||
struct bootstd_priv *std;
|
||||
struct udevice *bootstd;
|
||||
const char **old_order;
|
||||
struct udevice *usb;
|
||||
int i;
|
||||
|
||||
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
|
||||
std = dev_get_priv(bootstd);
|
||||
@@ -1310,6 +1317,10 @@ static int bootflow_efi(struct unit_test_state *uts)
|
||||
|
||||
systab.fw_vendor = test_vendor;
|
||||
|
||||
/* the USB block-device should have beeen probed */
|
||||
ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 1, &usb));
|
||||
ut_assert(device_active(usb));
|
||||
|
||||
ut_asserteq(1, run_command("bootflow boot", 0));
|
||||
ut_assert_nextline(
|
||||
"** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi");
|
||||
@@ -1320,12 +1331,77 @@ static int bootflow_efi(struct unit_test_state *uts)
|
||||
|
||||
/* TODO: Why the \r ? */
|
||||
ut_assert_nextline("U-Boot test app for EFI_LOADER\r");
|
||||
ut_assert_nextline("Exiting boot services");
|
||||
ut_assert_nextline("Exiting test app");
|
||||
ut_assert_nextline("Boot failed (err=-14)");
|
||||
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_assertok(bootstd_test_drop_bootdev_order(uts));
|
||||
/* make sure the bootflow is still present */
|
||||
ut_assertnonnull(std->cur_bootflow);
|
||||
|
||||
/* the USB block-device should have beeen removed */
|
||||
ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 1, &usb));
|
||||
ut_assert(!device_active(usb));
|
||||
|
||||
/* check memory allocations are as expected */
|
||||
if (!hdr)
|
||||
return 0;
|
||||
|
||||
for (i = 0, rec_hdr = (void *)hdr + sizeof(*hdr);
|
||||
(void *)rec_hdr - (void *)hdr < hdr->upto;
|
||||
i++, rec_hdr = (void *)rec_hdr + rec_hdr->size) {
|
||||
void *start = (void *)rec_hdr + sizeof(struct efil_rec_hdr);
|
||||
|
||||
switch (rec_hdr->tag) {
|
||||
case EFILT_ALLOCATE_PAGES: {
|
||||
struct efil_allocate_pages *rec = start;
|
||||
|
||||
ut_assert(rec_hdr->ended);
|
||||
ut_assertok(rec_hdr->e_ret);
|
||||
ut_asserteq(EFI_ALLOCATE_ANY_PAGES, rec->type);
|
||||
log_debug("rec->memory_type %d\n", rec->memory_type);
|
||||
ut_assert(rec->memory_type == EFI_RUNTIME_SERVICES_DATA ||
|
||||
rec->memory_type == EFI_BOOT_SERVICES_DATA ||
|
||||
rec->memory_type == EFI_ACPI_MEMORY_NVS ||
|
||||
rec->memory_type == EFI_LOADER_CODE);
|
||||
ut_assert(rec->e_memory < gd->ram_size);
|
||||
break;
|
||||
}
|
||||
case EFILT_FREE_PAGES: {
|
||||
struct efil_free_pages *rec = start;
|
||||
|
||||
ut_assert(rec_hdr->ended);
|
||||
ut_assertok(rec_hdr->e_ret);
|
||||
ut_assert(rec->memory < gd->ram_size);
|
||||
break;
|
||||
}
|
||||
case EFILT_ALLOCATE_POOL: {
|
||||
struct efil_allocate_pool *rec = start;
|
||||
|
||||
ut_assert(rec_hdr->ended);
|
||||
ut_assertok(rec_hdr->e_ret);
|
||||
log_debug("rec->pool_type %d\n", rec->pool_type);
|
||||
ut_assert(rec->pool_type == EFI_RUNTIME_SERVICES_DATA ||
|
||||
rec->pool_type == EFI_BOOT_SERVICES_DATA ||
|
||||
rec->pool_type == EFI_ACPI_MEMORY_NVS);
|
||||
ut_assert(map_to_sysmem((void *)rec->e_buffer) <
|
||||
gd->ram_size);
|
||||
break;
|
||||
}
|
||||
case EFILT_FREE_POOL: {
|
||||
struct efil_free_pool *rec = start;
|
||||
|
||||
ut_assert(rec_hdr->ended);
|
||||
ut_assertok(rec_hdr->e_ret);
|
||||
ut_assert(map_to_sysmem((void *)rec->buffer) <
|
||||
gd->ram_size);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user