Lines Matching refs:state
14 static struct sandbox_state *state; /* Pointer to current state record */ variable
18 void *blob = state->state_fdt; in state_ensure_space()
41 state->state_fdt = buf; in state_ensure_space()
45 static int state_read_file(struct sandbox_state *state, const char *fname) in state_read_file() argument
56 state->state_fdt = os_malloc(size); in state_read_file()
57 if (!state->state_fdt) { in state_read_file()
67 if (os_read(fd, state->state_fdt, size) != size) { in state_read_file()
78 os_free(state->state_fdt); in state_read_file()
79 state->state_fdt = NULL; in state_read_file()
98 int sandbox_read_state_nodes(struct sandbox_state *state, in sandbox_read_state_nodes() argument
141 int sandbox_read_state(struct sandbox_state *state, const char *fname) in sandbox_read_state() argument
148 if (state->read_state && fname) { in sandbox_read_state()
149 ret = state_read_file(state, fname); in sandbox_read_state()
150 if (ret == -ENOENT && state->ignore_missing_state_on_read) in sandbox_read_state()
158 blob = state->state_fdt; in sandbox_read_state()
161 ret = sandbox_read_state_nodes(state, io, blob); in sandbox_read_state()
166 if (state->read_state && fname) { in sandbox_read_state()
188 int sandbox_write_state_node(struct sandbox_state *state, in sandbox_write_state_node() argument
205 blob = state->state_fdt; in sandbox_write_state_node()
234 int sandbox_write_state(struct sandbox_state *state, const char *fname) in sandbox_write_state() argument
243 if (!state->state_fdt) { in sandbox_write_state()
245 state->state_fdt = os_malloc(size); in sandbox_write_state()
246 if (!state->state_fdt) { in sandbox_write_state()
250 ret = fdt_create_empty_tree(state->state_fdt, size); in sandbox_write_state()
264 ret = sandbox_write_state_node(state, io); in sandbox_write_state()
276 ret = fdt_pack(state->state_fdt); in sandbox_write_state()
282 size = fdt_totalsize(state->state_fdt); in sandbox_write_state()
289 if (os_write(fd, state->state_fdt, size) != size) { in sandbox_write_state()
303 os_free(state->state_fdt); in sandbox_write_state()
314 fdt_getprop(state->state_fdt, node, prop_name, &len); in state_setprop()
322 blob = state->state_fdt; in state_setprop()
336 assert(state); in state_get_current()
337 return state; in state_get_current()
342 struct sandbox_state *state = state_get_current(); in state_set_skip_delays() local
344 state->skip_delays = skip_delays; in state_set_skip_delays()
349 struct sandbox_state *state = state_get_current(); in state_get_skip_delays() local
351 return state->skip_delays; in state_get_skip_delays()
354 void state_reset_for_test(struct sandbox_state *state) in state_reset_for_test() argument
357 state->last_sysreset = SYSRESET_COUNT; in state_reset_for_test()
358 state->sysreset_allowed[SYSRESET_POWER] = true; in state_reset_for_test()
360 memset(&state->wdt, '\0', sizeof(state->wdt)); in state_reset_for_test()
361 memset(state->spi, '\0', sizeof(state->spi)); in state_reset_for_test()
366 state = &main_state; in state_init()
368 state->ram_size = CONFIG_SYS_SDRAM_SIZE; in state_init()
369 state->ram_buf = os_malloc(state->ram_size); in state_init()
370 assert(state->ram_buf); in state_init()
372 state_reset_for_test(state); in state_init()
386 state = &main_state; in state_uninit()
388 if (state->write_ram_buf && !state->ram_buf_rm) { in state_uninit()
389 err = os_write_ram_buf(state->ram_buf_fname); in state_uninit()
396 if (state->write_state) { in state_uninit()
397 if (sandbox_write_state(state, state->state_fname)) { in state_uninit()
404 if (state->jumped_fname) in state_uninit()
405 os_unlink(state->jumped_fname); in state_uninit()
407 if (state->state_fdt) in state_uninit()
408 os_free(state->state_fdt); in state_uninit()
409 memset(state, '\0', sizeof(*state)); in state_uninit()