summaryrefslogtreecommitdiffstats
path: root/uisimulator/sdl
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-03-26 01:50:41 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-03-26 01:50:41 +0000
commitaf395f4db6ad7b83f9d9afefb1c0ceeedd140a45 (patch)
treeb631289b4a3b28d3c65b10d272d50298f377c69f /uisimulator/sdl
parent74d678fdbcbc427c057e7682ba0a0566e49a8b97 (diff)
downloadrockbox-af395f4db6ad7b83f9d9afefb1c0ceeedd140a45.tar.gz
rockbox-af395f4db6ad7b83f9d9afefb1c0ceeedd140a45.tar.bz2
rockbox-af395f4db6ad7b83f9d9afefb1c0ceeedd140a45.zip
Do core interrupt masking in a less general fashion and save some instructions to decrease size and speed things up a little bit. Small fix to a few places where interrupts would get enabled again where they shouldn't have been (context switching calls when disabled).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16811 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/sdl')
-rw-r--r--uisimulator/sdl/system-sdl.h13
-rw-r--r--uisimulator/sdl/thread-sdl.c16
2 files changed, 21 insertions, 8 deletions
diff --git a/uisimulator/sdl/system-sdl.h b/uisimulator/sdl/system-sdl.h
index c5e7d40560..08f702d01e 100644
--- a/uisimulator/sdl/system-sdl.h
+++ b/uisimulator/sdl/system-sdl.h
@@ -24,6 +24,19 @@
#define HIGHEST_IRQ_LEVEL 1
int set_irq_level(int level);
+
+#define disable_irq() \
+ ((void)set_irq_level(HIGHEST_IRQ_LEVEL))
+
+#define enable_irq() \
+ ((void)set_irq_level(0))
+
+#define disable_irq_save() \
+ set_irq_level(HIGHEST_IRQ_LEVEL)
+
+#define restore_irq(level) \
+ ((void)set_irq_level(level))
+
void sim_enter_irq_handler(void);
void sim_exit_irq_handler(void);
bool sim_kernel_init(void);
diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c
index 78a66f72a7..5aae9a4bf8 100644
--- a/uisimulator/sdl/thread-sdl.c
+++ b/uisimulator/sdl/thread-sdl.c
@@ -246,7 +246,7 @@ void switch_thread(void)
{
struct thread_entry *current = cores[CURRENT_CORE].running;
- set_irq_level(0);
+ enable_irq();
switch (current->state)
{
@@ -266,9 +266,9 @@ void switch_thread(void)
SDL_SemWait(current->context.s);
SDL_LockMutex(m);
- oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ oldlevel = disable_irq_save();
current->state = STATE_RUNNING;
- set_irq_level(oldlevel);
+ restore_irq(oldlevel);
break;
} /* STATE_BLOCKED: */
@@ -280,7 +280,7 @@ void switch_thread(void)
result = SDL_SemWaitTimeout(current->context.s, current->tmo_tick);
SDL_LockMutex(m);
- oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ oldlevel = disable_irq_save();
if (current->state == STATE_BLOCKED_W_TMO)
{
@@ -303,7 +303,7 @@ void switch_thread(void)
SDL_SemTryWait(current->context.s);
}
- set_irq_level(oldlevel);
+ restore_irq(oldlevel);
break;
} /* STATE_BLOCKED_W_TMO: */
@@ -505,7 +505,7 @@ void remove_thread(struct thread_entry *thread)
SDL_Thread *t;
SDL_sem *s;
- int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ int oldlevel = disable_irq_save();
if (thread == NULL)
{
@@ -547,12 +547,12 @@ void remove_thread(struct thread_entry *thread)
{
/* Do a graceful exit - perform the longjmp back into the thread
function to return */
- set_irq_level(oldlevel);
+ restore_irq(oldlevel);
longjmp(thread_jmpbufs[current - threads], 1);
}
SDL_KillThread(t);
- set_irq_level(oldlevel);
+ restore_irq(oldlevel);
}
void thread_exit(void)