Merge tag 'dm-9oct18' of git://git.denx.de/u-boot-dm
[platform/kernel/u-boot.git] / arch / sandbox / cpu / state.c
index cc50819..d3b9c05 100644 (file)
@@ -359,6 +359,14 @@ void state_reset_for_test(struct sandbox_state *state)
 
        memset(&state->wdt, '\0', sizeof(state->wdt));
        memset(state->spi, '\0', sizeof(state->spi));
+
+       /*
+        * Set up the memory tag list. Use the top of emulated SDRAM for the
+        * first tag number, since that address offset is outside the legal
+        * range, and can be assumed to be a tag.
+        */
+       INIT_LIST_HEAD(&state->mapmem_head);
+       state->next_tag = state->ram_size;
 }
 
 int state_init(void)
@@ -385,7 +393,7 @@ int state_uninit(void)
 
        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");
@@ -400,6 +408,10 @@ 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);