summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-04-30 09:58:12 -0500
committerRonald G. Minnich <rminnich@gmail.com>2013-05-01 07:19:12 +0200
commit340ca91f18a448e09973341f60bb6f46102d2410 (patch)
treee7b1f531a6412d9f12de19a1271ba572ad90376c /src/include
parent6b0fb0dc3c1cb89af52224a1610daf7b9e943aa6 (diff)
downloadcoreboot-340ca91f18a448e09973341f60bb6f46102d2410.tar.xz
coreboot: add timer queue implementation
A timer queue provides the mechanism for calling functions in the future by way of a callback. It utilizes the MONOTONIC_TIMER to track time through the boot. The implementation is a min-heap for keeping track of the next-to-expire callback. Change-Id: Ia56bab8444cd6177b051752342f53b53d5f6afc1 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/3158 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/timer.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/timer.h b/src/include/timer.h
index 2b112dd5a9..e950c81eee 100644
--- a/src/include/timer.h
+++ b/src/include/timer.h
@@ -38,6 +38,17 @@ struct rela_time {
long microseconds;
};
+/* A timeout_callback structure is used for the book keeping for scheduling
+ * work in the future. When a callback is called the structure can be
+ * re-used for scheduling as it is not being tracked by the core timer
+ * library any more. */
+struct timeout_callback {
+ void *priv;
+ void (*callback)(struct timeout_callback *tocb);
+ /* Not for public use. The timer library uses the fields below. */
+ struct mono_time expiration;
+};
+
/* Obtain the current monotonic time. The assumption is that the time counts
* up from the value 0 with value 0 being the point when the timer was
* initialized. Additionally, the timer is assumed to only be valid for the
@@ -49,6 +60,13 @@ struct rela_time {
* of 10 seconds. */
void timer_monotonic_get(struct mono_time *mt);
+/* Returns 1 if callbacks still present in the queue. 0 if no timers left. */
+int timers_run(void);
+
+/* Schedule a callback to be ran microseconds from time of invocation.
+ * 0 returned on success, < 0 on error. */
+int timer_sched_callback(struct timeout_callback *tocb, unsigned long us);
+
/* Add microseconds to an absoute time. */
static inline void mono_time_add_usecs(struct mono_time *mt, long us)
{