mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
sandbox: Zero the ram buffer on startup
At present the RAM buffer is not inited unless it is read from a file, likely produced by an earlier phase of U-Boot. This causes valgrind warnings whenever the RAM buffer is used. Correct this by initing it if needed. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
2a07269062
commit
a65d1a06c9
2 changed files with 8 additions and 0 deletions
|
@ -180,6 +180,7 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
|
||||||
printf("Failed to read RAM buffer '%s': %d\n", arg, err);
|
printf("Failed to read RAM buffer '%s': %d\n", arg, err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
state->ram_buf_read = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -301,6 +302,12 @@ int board_run_command(const char *cmdline)
|
||||||
|
|
||||||
static void setup_ram_buf(struct sandbox_state *state)
|
static void setup_ram_buf(struct sandbox_state *state)
|
||||||
{
|
{
|
||||||
|
/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
|
||||||
|
if (!state->ram_buf_read) {
|
||||||
|
memset(state->ram_buf, '\0', state->ram_size);
|
||||||
|
printf("clear %p %x\n", state->ram_buf, state->ram_size);
|
||||||
|
}
|
||||||
|
|
||||||
gd->arch.ram_buf = state->ram_buf;
|
gd->arch.ram_buf = state->ram_buf;
|
||||||
gd->ram_size = state->ram_size;
|
gd->ram_size = state->ram_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ struct sandbox_state {
|
||||||
bool show_test_output; /* Don't suppress stdout in tests */
|
bool show_test_output; /* Don't suppress stdout in tests */
|
||||||
int default_log_level; /* Default log level for sandbox */
|
int default_log_level; /* Default log level for sandbox */
|
||||||
bool show_of_platdata; /* Show of-platdata in SPL */
|
bool show_of_platdata; /* Show of-platdata in SPL */
|
||||||
|
bool ram_buf_read; /* true if we read the RAM buffer */
|
||||||
|
|
||||||
/* Pointer to information for each SPI bus/cs */
|
/* Pointer to information for each SPI bus/cs */
|
||||||
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
|
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue