summaryrefslogtreecommitdiff
path: root/firmware/kernel/include/tick.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/kernel/include/tick.h')
-rw-r--r--firmware/kernel/include/tick.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/firmware/kernel/include/tick.h b/firmware/kernel/include/tick.h
new file mode 100644
index 0000000000..9810f4a1e5
--- /dev/null
+++ b/firmware/kernel/include/tick.h
@@ -0,0 +1,67 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Björn Stenberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef TICK_H
22#define TICK_H
23
24#include "config.h"
25#include "system.h" /* for NULL */
26extern void init_tick(void);
27
28#define HZ 100 /* number of ticks per second */
29
30#define MAX_NUM_TICK_TASKS 8
31
32/* global tick variable */
33#if defined(CPU_PP) && defined(BOOTLOADER) && \
34 !defined(HAVE_BOOTLOADER_USB_MODE)
35/* We don't enable interrupts in the PP bootloader unless USB mode is
36 enabled for it, so we need to fake the current_tick variable */
37#define current_tick (signed)(USEC_TIMER/10000)
38
39static inline void call_tick_tasks(void)
40{
41}
42#else
43extern volatile long current_tick;
44
45/* inline helper for implementing target interrupt handler */
46static inline void call_tick_tasks(void)
47{
48 extern void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void);
49 void (**p)(void) = tick_funcs;
50 void (*fn)(void);
51
52 current_tick++;
53
54 for(fn = *p; fn != NULL; fn = *(++p))
55 {
56 fn();
57 }
58}
59#endif
60
61/* implemented in target tree */
62extern void tick_start(unsigned int interval_in_ms) INIT_ATTR;
63
64extern int tick_add_task(void (*f)(void));
65extern int tick_remove_task(void (*f)(void));
66
67#endif /* TICK_H */