diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/host/main.c | 14 | ||||
-rw-r--r-- | core/host/timer.c | 11 |
2 files changed, 24 insertions, 1 deletions
diff --git a/core/host/main.c b/core/host/main.c index b046f3b584..e7b6718ac8 100644 --- a/core/host/main.c +++ b/core/host/main.c @@ -5,6 +5,7 @@ /* Entry point of unit test executable */ +#include "console.h" #include "flash.h" #include "hooks.h" #include "system.h" @@ -13,6 +14,10 @@ #include "timer.h" #include "uart.h" +/* Console output macros */ +#define CPUTS(outstr) cputs(CC_SYSTEM, outstr) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) + int main(void) { register_test_end_hook(); @@ -25,6 +30,15 @@ int main(void) hook_init(); uart_init(); + if (system_jumped_to_this_image()) { + CPRINTF("[%T Emulator initialized after sysjump]\n"); + } else { + CPUTS("\n\n--- Emulator initialized after reboot ---\n"); + CPUTS("[Reset cause: "); + system_print_reset_flags(); + CPUTS("]\n"); + } + task_start(); return 0; diff --git a/core/host/timer.c b/core/host/timer.c index 7a19f7ef63..d945a2c4f2 100644 --- a/core/host/timer.c +++ b/core/host/timer.c @@ -22,6 +22,7 @@ #endif static timestamp_t boot_time; +static int time_set; void usleep(unsigned us) { @@ -45,6 +46,13 @@ timestamp_t get_time(void) return ret; } +void force_time(timestamp_t ts) +{ + timestamp_t now = _get_time(); + boot_time.val = now.val - ts.val; + time_set = 1; +} + void udelay(unsigned us) { timestamp_t deadline = get_time(); @@ -67,5 +75,6 @@ int timestamp_expired(timestamp_t deadline, const timestamp_t *now) void timer_init(void) { - boot_time = _get_time(); + if (!time_set) + boot_time = _get_time(); } |