summaryrefslogtreecommitdiff
path: root/uisimulator/x11/kernel.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-03-18 23:51:52 +0000
committerJens Arnold <amiconn@rockbox.org>2005-03-18 23:51:52 +0000
commit74b731edc6e0495d43a37412c60cd23a24789679 (patch)
treee4d4014047b65f4cf05e9c0ba3d48a05a1eb04f9 /uisimulator/x11/kernel.c
parent9101465ae83fd89ebcdf55fc3e831dfca74884ea (diff)
downloadrockbox-74b731edc6e0495d43a37412c60cd23a24789679.tar.gz
rockbox-74b731edc6e0495d43a37412c60cd23a24789679.zip
Major rework of the x11 simulator button handling. (1) Button repeat should always work correctly now, not sending a release before the repeat(s). Fixes e.g. calling the Ondio menu. (2) Button handling is done in the timer thread, not sleep()ing the main thread for extended times. Fixes slow performance of high-workload plugins (codec tests). (3) The x11 simulator now also contains the queue handling code. (4) The new code requires X11R6 because the multi-threading extension is used.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6215 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11/kernel.c')
-rw-r--r--uisimulator/x11/kernel.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/uisimulator/x11/kernel.c b/uisimulator/x11/kernel.c
new file mode 100644
index 0000000000..7405fec52f
--- /dev/null
+++ b/uisimulator/x11/kernel.c
@@ -0,0 +1,108 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Jens Arnold
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 "kernel.h"
21#include "thread.h"
22
23int set_irq_level (int level)
24{
25 static int _lv = 0;
26 return (_lv = level);
27}
28
29void queue_init(struct event_queue *q)
30{
31 q->read = 0;
32 q->write = 0;
33}
34
35void queue_wait(struct event_queue *q, struct event *ev)
36{
37 while(q->read == q->write)
38 {
39 switch_thread();
40 }
41
42 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
43}
44
45void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
46{
47 unsigned int timeout = current_tick + ticks;
48
49 while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
50 {
51 sleep(1);
52 }
53
54 if(q->read != q->write)
55 {
56 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
57 }
58 else
59 {
60 ev->id = SYS_TIMEOUT;
61 }
62}
63
64void queue_post(struct event_queue *q, long id, void *data)
65{
66 int wr;
67 int oldlevel;
68
69 oldlevel = set_irq_level(15<<4);
70 wr = (q->write++) & QUEUE_LENGTH_MASK;
71
72 q->events[wr].id = id;
73 q->events[wr].data = data;
74 set_irq_level(oldlevel);
75}
76
77bool queue_empty(const struct event_queue* q)
78{
79 return ( q->read == q->write );
80}
81
82void queue_clear(struct event_queue* q)
83{
84 /* fixme: This is potentially unsafe in case we do interrupt-like processing */
85 q->read = 0;
86 q->write = 0;
87}
88
89void switch_thread (void)
90{
91 yield ();
92}
93
94void mutex_init(struct mutex *m)
95{
96 (void)m;
97}
98
99void mutex_lock(struct mutex *m)
100{
101 (void)m;
102}
103
104void mutex_unlock(struct mutex *m)
105{
106 (void)m;
107}
108