diff options
Diffstat (limited to 'uisimulator/win32/kernel.c')
-rw-r--r-- | uisimulator/win32/kernel.c | 167 |
1 files changed, 0 insertions, 167 deletions
diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c deleted file mode 100644 index 34100a234e..0000000000 --- a/uisimulator/win32/kernel.c +++ /dev/null | |||
@@ -1,167 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Felix Arends | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <windows.h> | ||
21 | #include "uisw32.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread-win32.h" | ||
24 | #include "thread.h" | ||
25 | #include "debug.h" | ||
26 | |||
27 | static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | ||
28 | |||
29 | int set_irq_level (int level) | ||
30 | { | ||
31 | static int _lv = 0; | ||
32 | return (_lv = level); | ||
33 | } | ||
34 | |||
35 | void queue_init(struct event_queue *q) | ||
36 | { | ||
37 | q->read = 0; | ||
38 | q->write = 0; | ||
39 | } | ||
40 | |||
41 | void queue_delete(struct event_queue *q) | ||
42 | { | ||
43 | (void)q; | ||
44 | } | ||
45 | |||
46 | void queue_wait(struct event_queue *q, struct event *ev) | ||
47 | { | ||
48 | while(q->read == q->write) | ||
49 | { | ||
50 | switch_thread(); | ||
51 | } | ||
52 | |||
53 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; | ||
54 | } | ||
55 | |||
56 | void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks) | ||
57 | { | ||
58 | unsigned int timeout = current_tick + ticks; | ||
59 | |||
60 | while(q->read == q->write && TIME_BEFORE( current_tick, timeout )) | ||
61 | { | ||
62 | sleep(1); | ||
63 | } | ||
64 | |||
65 | if(q->read != q->write) | ||
66 | { | ||
67 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; | ||
68 | } | ||
69 | else | ||
70 | { | ||
71 | ev->id = SYS_TIMEOUT; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | void queue_post(struct event_queue *q, long id, void *data) | ||
76 | { | ||
77 | int wr; | ||
78 | int oldlevel; | ||
79 | |||
80 | oldlevel = set_irq_level(15<<4); | ||
81 | wr = (q->write++) & QUEUE_LENGTH_MASK; | ||
82 | |||
83 | q->events[wr].id = id; | ||
84 | q->events[wr].data = data; | ||
85 | set_irq_level(oldlevel); | ||
86 | } | ||
87 | |||
88 | bool queue_empty(const struct event_queue* q) | ||
89 | { | ||
90 | return ( q->read == q->write ); | ||
91 | } | ||
92 | |||
93 | void queue_clear(struct event_queue* q) | ||
94 | { | ||
95 | /* fixme: This is potentially unsafe in case we do interrupt-like processing */ | ||
96 | q->read = 0; | ||
97 | q->write = 0; | ||
98 | } | ||
99 | |||
100 | void switch_thread (void) | ||
101 | { | ||
102 | yield (); | ||
103 | } | ||
104 | |||
105 | void sim_tick_tasks(void) | ||
106 | { | ||
107 | int i; | ||
108 | |||
109 | /* Run through the list of tick tasks */ | ||
110 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
111 | { | ||
112 | if(tick_funcs[i]) | ||
113 | { | ||
114 | tick_funcs[i](); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | int tick_add_task(void (*f)(void)) | ||
120 | { | ||
121 | int i; | ||
122 | |||
123 | /* Add a task if there is room */ | ||
124 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
125 | { | ||
126 | if(tick_funcs[i] == NULL) | ||
127 | { | ||
128 | tick_funcs[i] = f; | ||
129 | return 0; | ||
130 | } | ||
131 | } | ||
132 | DEBUGF("Error! tick_add_task(): out of tasks"); | ||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | int tick_remove_task(void (*f)(void)) | ||
137 | { | ||
138 | int i; | ||
139 | |||
140 | /* Remove a task if it is there */ | ||
141 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
142 | { | ||
143 | if(tick_funcs[i] == f) | ||
144 | { | ||
145 | tick_funcs[i] = NULL; | ||
146 | return 0; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | return -1; | ||
151 | } | ||
152 | |||
153 | /* TODO: Implement mutexes for win32 */ | ||
154 | void mutex_init(struct mutex *m) | ||
155 | { | ||
156 | (void)m; | ||
157 | } | ||
158 | |||
159 | void mutex_lock(struct mutex *m) | ||
160 | { | ||
161 | (void)m; | ||
162 | } | ||
163 | |||
164 | void mutex_unlock(struct mutex *m) | ||
165 | { | ||
166 | (void)m; | ||
167 | } | ||