/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* Timer module for Chrome EC operating system */ #include #include "task.h" #include "timer.h" #include "hwtimer.h" #include "atomic.h" #include "console.h" #include "uart.h" #include "util.h" /* high word of the 64-bit timestamp counter */ static volatile uint32_t clksrc_high; /* bitmap of currently running timers */ static uint32_t timer_running = 0; /* deadlines of all timers */ static timestamp_t timer_deadline[TASK_ID_COUNT]; static uint32_t next_deadline = 0xffffffff; /* Hardware timer routine IRQ number */ static int timer_irq; static void expire_timer(task_id_t tskid) { /* we are done with this timer */ atomic_clear(&timer_running, 1< %10ld us from now\n" "Active timers:\n", t, deadline, deadline - t); for (tskid = 0; tskid < TASK_ID_COUNT; tskid++) { if (timer_running & (1< %10ld\n", tskid, timer_deadline[tskid].val, timer_deadline[tskid].val - t); uart_flush_output(); } } return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(timerinfo, command_timer_info); int timer_init(void) { BUILD_ASSERT(TASK_ID_COUNT < sizeof(timer_running) * 8); timer_irq = __hw_clock_source_init(); return EC_SUCCESS; }