diff options
Diffstat (limited to 'uisimulator/sdl/kernel.c')
-rw-r--r-- | uisimulator/sdl/kernel.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/uisimulator/sdl/kernel.c b/uisimulator/sdl/kernel.c index 220d069721..7126b82072 100644 --- a/uisimulator/sdl/kernel.c +++ b/uisimulator/sdl/kernel.c | |||
@@ -34,6 +34,7 @@ static SDL_cond *sim_thread_cond; | |||
34 | * inside a handler */ | 34 | * inside a handler */ |
35 | static SDL_mutex *sim_irq_mtx; | 35 | static SDL_mutex *sim_irq_mtx; |
36 | static int interrupt_level = HIGHEST_IRQ_LEVEL; | 36 | static int interrupt_level = HIGHEST_IRQ_LEVEL; |
37 | static int handlers_pending = 0; | ||
37 | static int status_reg = 0; | 38 | static int status_reg = 0; |
38 | 39 | ||
39 | extern struct core_entry cores[NUM_CORES]; | 40 | extern struct core_entry cores[NUM_CORES]; |
@@ -53,7 +54,8 @@ int set_irq_level(int level) | |||
53 | if (status_reg == 0 && level == 0 && oldlevel != 0) | 54 | if (status_reg == 0 && level == 0 && oldlevel != 0) |
54 | { | 55 | { |
55 | /* Not in a handler and "interrupts" are being reenabled */ | 56 | /* Not in a handler and "interrupts" are being reenabled */ |
56 | SDL_CondSignal(sim_thread_cond); | 57 | if (handlers_pending > 0) |
58 | SDL_CondSignal(sim_thread_cond); | ||
57 | } | 59 | } |
58 | 60 | ||
59 | interrupt_level = level; /* save new level */ | 61 | interrupt_level = level; /* save new level */ |
@@ -65,16 +67,22 @@ int set_irq_level(int level) | |||
65 | void sim_enter_irq_handler(void) | 67 | void sim_enter_irq_handler(void) |
66 | { | 68 | { |
67 | SDL_LockMutex(sim_irq_mtx); | 69 | SDL_LockMutex(sim_irq_mtx); |
70 | handlers_pending++; | ||
71 | |||
68 | if(interrupt_level != 0) | 72 | if(interrupt_level != 0) |
69 | { | 73 | { |
70 | /* "Interrupts" are disabled. Wait for reenable */ | 74 | /* "Interrupts" are disabled. Wait for reenable */ |
71 | SDL_CondWait(sim_thread_cond, sim_irq_mtx); | 75 | SDL_CondWait(sim_thread_cond, sim_irq_mtx); |
72 | } | 76 | } |
77 | |||
73 | status_reg = 1; | 78 | status_reg = 1; |
74 | } | 79 | } |
75 | 80 | ||
76 | void sim_exit_irq_handler(void) | 81 | void sim_exit_irq_handler(void) |
77 | { | 82 | { |
83 | if (--handlers_pending > 0) | ||
84 | SDL_CondSignal(sim_thread_cond); | ||
85 | |||
78 | status_reg = 0; | 86 | status_reg = 0; |
79 | SDL_UnlockMutex(sim_irq_mtx); | 87 | SDL_UnlockMutex(sim_irq_mtx); |
80 | } | 88 | } |