diff options
author | Simon Glass <sjg@chromium.org> | 2022-09-07 05:27:10 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-09-29 23:10:43 +0300 |
commit | 756c01422dfa193097aa3d43c083b8b23e4b2301 (patch) | |
tree | dea1edaa0d86459012b5f8edb92a0fe75bc8a656 /arch/sandbox/cpu | |
parent | 9859d89b6e859a242d083a96950e0c05f60a5152 (diff) | |
download | u-boot-756c01422dfa193097aa3d43c083b8b23e4b2301.tar.xz |
sandbox: Support setting up the other FDT for testing
Provide a way to copy over the 'other' FDT when running tests. This loads
it and allocates memory for the copy, if not done already, then does the
copy.
Avoid using U-Boot's malloc() pool for these copies, at least for now,
since they are part of the test system.
Tidy up the cpu.c header files while here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu')
-rw-r--r-- | arch/sandbox/cpu/cpu.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index d077948dd7..636d3545b9 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -3,19 +3,22 @@ * Copyright (c) 2011 The Chromium OS Authors. */ +#define LOG_CATEGORY LOGC_SANDBOX + #include <common.h> #include <bootstage.h> #include <cpu_func.h> #include <errno.h> #include <log.h> -#include <asm/global_data.h> -#include <linux/delay.h> -#include <linux/libfdt.h> #include <os.h> +#include <asm/global_data.h> #include <asm/io.h> #include <asm/malloc.h> #include <asm/setjmp.h> #include <asm/state.h> +#include <dm/ofnode.h> +#include <linux/delay.h> +#include <linux/libfdt.h> DECLARE_GLOBAL_DATA_PTR; @@ -373,3 +376,28 @@ ulong timer_get_boot_us(void) return (count - base_count) / 1000; } + +int sandbox_load_other_fdt(void **fdtp, int *sizep) +{ + const char *orig; + int ret, size; + void *fdt = *fdtp; + + ret = state_load_other_fdt(&orig, &size); + if (ret) { + log_err("Cannot read other FDT\n"); + return log_msg_ret("ld", ret); + } + + if (!*fdtp) { + fdt = os_malloc(size); + if (!fdt) + return log_msg_ret("mem", -ENOMEM); + *sizep = size; + } + + memcpy(fdt, orig, *sizep); + *fdtp = fdt; + + return 0; +} |