From 27e8bdb7c099ff4642c5c1d567029467da35da4f Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 11 May 2012 12:26:49 -0700 Subject: 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 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 --- core/cortex-m/timer.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'core') 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 - -#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; } -- cgit v1.2.1