diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-05-11 12:26:49 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-05-11 13:36:34 -0700 |
commit | 27e8bdb7c099ff4642c5c1d567029467da35da4f (patch) | |
tree | a22aa72b80161b73341bb633cee1157597e0b453 /core | |
parent | 2f2a5d90224a1a408c6eca408e4d6e87f0fa0503 (diff) | |
download | chrome-ec-27e8bdb7c099ff4642c5c1d567029467da35da4f.tar.gz |
Maintain timer value across sysjumps and clean up init debug output
This helps us keep track of how long vboot is taking on the EC.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=chrome-os-partner:9651
TEST=reboot system and look at debug log. time shouldn't start over after it jumps to image A.
Change-Id: Iad86e90d42dabf1c67b2c2be80dda1151cf9a288
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/timer.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/core/cortex-m/timer.c b/core/cortex-m/timer.c index 0078936f5a..10c83c8921 100644 --- a/core/cortex-m/timer.c +++ b/core/cortex-m/timer.c @@ -5,15 +5,15 @@ /* Timer module for Chrome EC operating system */ -#include <stdint.h> - -#include "task.h" -#include "timer.h" -#include "hwtimer.h" #include "atomic.h" #include "console.h" +#include "hooks.h" +#include "hwtimer.h" +#include "system.h" #include "uart.h" #include "util.h" +#include "task.h" +#include "timer.h" /* high word of the 64-bit timestamp counter */ static volatile uint32_t clksrc_high; @@ -212,11 +212,37 @@ int command_timer_info(int argc, char **argv) DECLARE_CONSOLE_COMMAND(timerinfo, command_timer_info); +#define TIMER_SYSJUMP_TAG 0x4d54 /* "TM" */ + + +/* Preserve time across a sysjump */ +static int timer_sysjump(void) +{ + timestamp_t ts = get_time(); + system_add_jump_tag(TIMER_SYSJUMP_TAG, 1, sizeof(ts), &ts); + + return EC_SUCCESS; +} +DECLARE_HOOK(HOOK_SYSJUMP, timer_sysjump, HOOK_PRIO_DEFAULT); + + int timer_init(void) { + const timestamp_t *ts; + int size, version; + BUILD_ASSERT(TASK_ID_COUNT < sizeof(timer_running) * 8); - timer_irq = __hw_clock_source_init(); + /* Restore time from before sysjump */ + ts = (const timestamp_t *)system_get_jump_tag(TIMER_SYSJUMP_TAG, + &version, &size); + if (ts && version == 1 && size == sizeof(timestamp_t)) { + clksrc_high = ts->le.hi; + timer_irq = __hw_clock_source_init(ts->le.lo); + } else { + clksrc_high = 0; + timer_irq = __hw_clock_source_init(0); + } return EC_SUCCESS; } |