summaryrefslogtreecommitdiff
path: root/uisimulator/x11/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/x11/kernel.c')
-rw-r--r--uisimulator/x11/kernel.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/uisimulator/x11/kernel.c b/uisimulator/x11/kernel.c
index 7405fec52f..25f2df220c 100644
--- a/uisimulator/x11/kernel.c
+++ b/uisimulator/x11/kernel.c
@@ -17,8 +17,12 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include <stddef.h>
20#include "kernel.h" 21#include "kernel.h"
21#include "thread.h" 22#include "thread.h"
23#include "debug.h"
24
25static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
22 26
23int set_irq_level (int level) 27int set_irq_level (int level)
24{ 28{
@@ -91,6 +95,54 @@ void switch_thread (void)
91 yield (); 95 yield ();
92} 96}
93 97
98void sim_tick_tasks(void)
99{
100 int i;
101
102 /* Run through the list of tick tasks */
103 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
104 {
105 if(tick_funcs[i])
106 {
107 tick_funcs[i]();
108 }
109 }
110}
111
112int tick_add_task(void (*f)(void))
113{
114 int i;
115
116 /* Add a task if there is room */
117 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
118 {
119 if(tick_funcs[i] == NULL)
120 {
121 tick_funcs[i] = f;
122 return 0;
123 }
124 }
125 DEBUGF("Error! tick_add_task(): out of tasks");
126 return -1;
127}
128
129int tick_remove_task(void (*f)(void))
130{
131 int i;
132
133 /* Remove a task if it is there */
134 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
135 {
136 if(tick_funcs[i] == f)
137 {
138 tick_funcs[i] = NULL;
139 return 0;
140 }
141 }
142
143 return -1;
144}
145
94void mutex_init(struct mutex *m) 146void mutex_init(struct mutex *m)
95{ 147{
96 (void)m; 148 (void)m;