diff options
author | Simon Glass | 2022-09-06 20:27:09 -0600 |
---|---|---|
committer | Tom Rini | 2022-09-29 16:09:56 -0400 |
commit | 9859d89b6e859a242d083a96950e0c05f60a5152 (patch) | |
tree | 2a325a1ef333f05acdf5f7016d9da33cdbb34dc5 /arch/sandbox/cpu | |
parent | 73c5cb9dacbcf2e988fffa66750c4206fccc8cbc (diff) |
sandbox: Support loading the other FDT
We need an 'other' FDT which is different from the control FDT, so we can
check that the ofnode tests correctly handle them both.
Add this to the build along with a way to read it into the sandbox state.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu')
-rw-r--r-- | arch/sandbox/cpu/state.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 787e0216594..fcc4a337e59 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -418,6 +418,32 @@ int state_get_rel_filename(const char *rel_path, char *buf, int size) return len; } +int state_load_other_fdt(const char **bufp, int *sizep) +{ + struct sandbox_state *state = state_get_current(); + char fname[256]; + int len, ret; + + /* load the file if needed */ + if (!state->other_fdt_buf) { + len = state_get_rel_filename("arch/sandbox/dts/other.dtb", + fname, sizeof(fname)); + if (len < 0) + return len; + + ret = os_read_file(fname, &state->other_fdt_buf, + &state->other_size); + if (ret) { + log_err("Cannot read file '%s'\n", fname); + return ret; + } + } + *bufp = state->other_fdt_buf; + *sizep = state->other_size; + + return 0; +} + int state_init(void) { state = &main_state; |