summaryrefslogtreecommitdiff
path: root/core/host/timer.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-07-23 11:50:59 +0800
committerChromeBot <chrome-bot@google.com>2013-07-23 16:06:24 -0700
commitb702babbb7ae1c9c225e9937f4a7656d36151310 (patch)
tree224e24cf13975f52c0faa0623cc6b364cdf8e44c /core/host/timer.c
parentf98def750d61d48e654f02e2384c517e0d698a99 (diff)
downloadchrome-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/host/timer.c')
-rw-r--r--core/host/timer.c11
1 files changed, 10 insertions, 1 deletions
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();
}