diff options
author | Vic Yang <victoryang@chromium.org> | 2013-07-23 11:50:59 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-23 16:06:24 -0700 |
commit | b702babbb7ae1c9c225e9937f4a7656d36151310 (patch) | |
tree | 224e24cf13975f52c0faa0623cc6b364cdf8e44c /core | |
parent | f98def750d61d48e654f02e2384c517e0d698a99 (diff) | |
download | chrome-ec-b702babbb7ae1c9c225e9937f4a7656d36151310.tar.gz |
Fix reset flags and sysjump time for emulator
Reset flags should be set properly according to reset type. Also, on
system jump, current time should be preserved.
BUG=chrome-os-partner:19235
TEST='sysjump rw' and check time is the same.
TEST='reboot hard' and see '[Reset cause: hard]'
BRANCH=None
Change-Id: I00fd2c652d10c237f23cc6a33e0b667422bc625d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62958
Reviewed-by: Randall Spangler <rspangler@chromium.org>
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(); } |