diff options
Diffstat (limited to 'arch/sandbox/cpu')
-rw-r--r-- | arch/sandbox/cpu/cpu.c | 12 | ||||
-rw-r--r-- | arch/sandbox/cpu/os.c | 2 | ||||
-rw-r--r-- | arch/sandbox/cpu/state.c | 15 |
3 files changed, 24 insertions, 5 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 2def72212d..eefed2ebd9 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -4,6 +4,7 @@ */ #define DEBUG #include <common.h> +#include <dm.h> #include <errno.h> #include <libfdt.h> #include <os.h> @@ -138,3 +139,14 @@ done: return 0; } + +ulong timer_get_boot_us(void) +{ + static uint64_t base_count; + uint64_t count = os_get_nsec(); + + if (!base_count) + base_count = count; + + return (count - base_count) / 1000; +} diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 35ea00ce3c..7243bfc1b1 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -395,7 +395,7 @@ const char *os_dirent_typename[OS_FILET_COUNT] = { const char *os_dirent_get_typename(enum os_dirent_t type) { - if (type >= 0 && type < OS_FILET_COUNT) + if (type >= OS_FILET_REG && type < OS_FILET_COUNT) return os_dirent_typename[type]; return os_dirent_typename[OS_FILET_UNKNOWN]; diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 2b4dbd341f..07584486db 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -351,6 +351,16 @@ bool state_get_skip_delays(void) return state->skip_delays; } +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; + state->sysreset_allowed[SYSRESET_POWER] = true; + + memset(&state->wdt, '\0', sizeof(state->wdt)); + memset(state->spi, '\0', sizeof(state->spi)); +} + int state_init(void) { state = &main_state; @@ -359,10 +369,7 @@ int state_init(void) state->ram_buf = os_malloc(state->ram_size); assert(state->ram_buf); - /* No reset yet, so mark it as such. Always allow power reset */ - state->last_sysreset = SYSRESET_COUNT; - state->sysreset_allowed[SYSRESET_POWER] = true; - + state_reset_for_test(state); /* * Example of how to use GPIOs: * |