summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/state.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-02-03 07:36:05 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:46 -0700
commit3ff6fe5fab11a99d4b3ec94a8a4a238d6f96f5ba (patch)
tree1421254bdfe9e3484bfa99c0108081cf55f3fd88 /arch/sandbox/cpu/state.c
parent1c8c47ec802af33acf02acb6c7b09e317c850711 (diff)
downloadu-boot-3ff6fe5fab11a99d4b3ec94a8a4a238d6f96f5ba.tar.gz
sandbox: Add a new header for the system malloc()
Some files use U-Boot headers but still need to access the system malloc(). Allow this by creating a new asm/malloc.h which can be used so long as U-Boot's malloc.h has not been included. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu/state.c')
-rw-r--r--arch/sandbox/cpu/state.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index ef2e63f37a..a347cec528 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -7,6 +7,7 @@
#include <errno.h>
#include <fdtdec.h>
#include <os.h>
+#include <asm/malloc.h>
#include <asm/state.h>
/* Main state record for the sandbox */
@@ -27,17 +28,17 @@ static int state_ensure_space(int extra_size)
return 0;
size = used + extra_size;
- buf = os_malloc(size);
+ buf = malloc(size);
if (!buf)
return -ENOMEM;
ret = fdt_open_into(blob, buf, size);
if (ret) {
- os_free(buf);
+ free(buf);
return -EIO;
}
- os_free(blob);
+ free(blob);
state->state_fdt = buf;
return 0;
}
@@ -53,7 +54,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
printf("Cannot find sandbox state file '%s'\n", fname);
return -ENOENT;
}
- state->state_fdt = os_malloc(size);
+ state->state_fdt = malloc(size);
if (!state->state_fdt) {
puts("No memory to read sandbox state\n");
return -ENOMEM;
@@ -75,7 +76,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
err_read:
os_close(fd);
err_open:
- os_free(state->state_fdt);
+ free(state->state_fdt);
state->state_fdt = NULL;
return ret;
@@ -242,7 +243,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
/* Create a state FDT if we don't have one */
if (!state->state_fdt) {
size = 0x4000;
- state->state_fdt = os_malloc(size);
+ state->state_fdt = malloc(size);
if (!state->state_fdt) {
puts("No memory to create FDT\n");
return -ENOMEM;
@@ -300,7 +301,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
err_write:
os_close(fd);
err_create:
- os_free(state->state_fdt);
+ free(state->state_fdt);
return ret;
}
@@ -418,7 +419,7 @@ int state_uninit(void)
os_unlink(state->jumped_fname);
if (state->state_fdt)
- os_free(state->state_fdt);
+ free(state->state_fdt);
memset(state, '\0', sizeof(*state));
return 0;