From e64f7e3a6f3019be855469373920198ac19ee654 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 29 Jul 2007 04:49:19 +0000 Subject: Add a new timeout API to the kernel. Enable only for e200 right now since it's the only user. Use that as the one-shot delay for SD card inserts. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14049 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/kernel.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'firmware/export/kernel.h') diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index b40d602..bf5a9d1 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -126,6 +126,28 @@ extern void sleep(int ticks); int tick_add_task(void (*f)(void)); int tick_remove_task(void (*f)(void)); +struct timeout; + +/* timeout callback type + * tmo - pointer to struct timeout associated with event + */ +typedef bool (* timeout_cb_type)(struct timeout *tmo); + +struct timeout +{ + /* for use by callback/internal - read/write */ + timeout_cb_type callback;/* callback - returning false cancels */ + int ticks; /* timeout period in ticks */ + intptr_t data; /* data passed to callback */ + /* internal use - read-only */ + const struct timeout * const next; /* next timeout in list */ + const long expires; /* expiration tick */ +}; + +void timeout_register(struct timeout *tmo, timeout_cb_type callback, + int ticks, intptr_t data); +void timeout_cancel(struct timeout *tmo); + extern void queue_init(struct event_queue *q, bool register_queue); #if NUM_CORES > 1 extern void queue_set_irq_safe(struct event_queue *q, bool state); -- cgit v1.1