projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dma-mapping: add <asm/dma-mapping.h> for all architectures
[oweals/u-boot.git]
/
arch
/
sandbox
/
cpu
/
state.c
diff --git
a/arch/sandbox/cpu/state.c
b/arch/sandbox/cpu/state.c
index 04a11fed559fb7711a73e32fc8135b35e7a8fcbb..a347cec5284e99652ffe98c4bd99f015d05a0eb2 100644
(file)
--- 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 <errno.h>
#include <fdtdec.h>
#include <os.h>
+#include <asm/malloc.h>
#include <asm/state.h>
/* Main state record for the sandbox */
#include <asm/state.h>
/* Main state record for the sandbox */
@@
-16,28
+17,28
@@
static struct sandbox_state *state; /* Pointer to current state record */
static int state_ensure_space(int extra_size)
{
void *blob = state->state_fdt;
static int state_ensure_space(int extra_size)
{
void *blob = state->state_fdt;
- int used, size, free;
+ int used, size, free
_bytes
;
void *buf;
int ret;
used = fdt_off_dt_strings(blob) + fdt_size_dt_strings(blob);
size = fdt_totalsize(blob);
void *buf;
int ret;
used = fdt_off_dt_strings(blob) + fdt_size_dt_strings(blob);
size = fdt_totalsize(blob);
- free = size - used;
- if (free > extra_size)
+ free
_bytes
= size - used;
+ if (free
_bytes
> extra_size)
return 0;
size = used + 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) {
if (!buf)
return -ENOMEM;
ret = fdt_open_into(blob, buf, size);
if (ret) {
-
os_
free(buf);
+ free(buf);
return -EIO;
}
return -EIO;
}
-
os_
free(blob);
+ free(blob);
state->state_fdt = buf;
return 0;
}
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;
}
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;
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:
err_read:
os_close(fd);
err_open:
-
os_
free(state->state_fdt);
+ free(state->state_fdt);
state->state_fdt = NULL;
return ret;
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;
/* 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;
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:
err_write:
os_close(fd);
err_create:
-
os_
free(state->state_fdt);
+ free(state->state_fdt);
return ret;
}
return ret;
}
@@
-355,7
+356,8
@@
void state_reset_for_test(struct sandbox_state *state)
{
/* No reset yet, so mark it as such. Always allow power reset */
state->last_sysreset = SYSRESET_COUNT;
{
/* No reset yet, so mark it as such. Always allow power reset */
state->last_sysreset = SYSRESET_COUNT;
- state->sysreset_allowed[SYSRESET_POWER] = true;
+ state->sysreset_allowed[SYSRESET_POWER_OFF] = true;
+ state->allow_memio = false;
memset(&state->wdt, '\0', sizeof(state->wdt));
memset(state->spi, '\0', sizeof(state->spi));
memset(&state->wdt, '\0', sizeof(state->wdt));
memset(state->spi, '\0', sizeof(state->spi));
@@
-393,7
+395,7
@@
int state_uninit(void)
state = &main_state;
state = &main_state;
- if (state->write_ram_buf
&& !state->ram_buf_rm
) {
+ if (state->write_ram_buf) {
err = os_write_ram_buf(state->ram_buf_fname);
if (err) {
printf("Failed to write RAM buffer\n");
err = os_write_ram_buf(state->ram_buf_fname);
if (err) {
printf("Failed to write RAM buffer\n");
@@
-408,12
+410,16
@@
int state_uninit(void)
}
}
}
}
+ /* Remove old memory file if required */
+ if (state->ram_buf_rm && state->ram_buf_fname)
+ os_unlink(state->ram_buf_fname);
+
/* Delete this at the last moment so as not to upset gdb too much */
if (state->jumped_fname)
os_unlink(state->jumped_fname);
if (state->state_fdt)
/* Delete this at the last moment so as not to upset gdb too much */
if (state->jumped_fname)
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;
memset(state, '\0', sizeof(*state));
return 0;