static int reset_requested;
static int shutdown_requested;
static int powerdown_requested;
+static int debug_requested;
int qemu_shutdown_requested(void)
{
return r;
}
+static int qemu_debug_requested(void)
+{
+ int r = debug_requested;
+ debug_requested = 0;
+ return r;
+}
+
void qemu_register_reset(QEMUResetHandler *func, void *opaque)
{
QEMUResetEntry **pre, *re;
return;
}
+#define qemu_mutex_lock_iothread() do { } while (0)
+#define qemu_mutex_unlock_iothread() do { } while (0)
+
#ifdef _WIN32
static void host_main_loop_wait(int *timeout)
{
slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
}
#endif
+ qemu_mutex_unlock_iothread();
ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
+ qemu_mutex_lock_iothread();
if (ret > 0) {
IOHandlerRecord **pioh;
return ret;
}
+static void tcg_cpu_exec(void)
+{
+ int ret;
+
+ if (next_cpu == NULL)
+ next_cpu = first_cpu;
+ for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
+ CPUState *env = cur_cpu = next_cpu;
+
+ if (!vm_running)
+ break;
+ if (timer_alarm_pending) {
+ timer_alarm_pending = 0;
+ break;
+ }
+ ret = qemu_cpu_exec(env);
+ if (ret == EXCP_DEBUG) {
+ gdb_set_stop_cpu(env);
+ debug_requested = 1;
+ break;
+ }
+ }
+}
+
static int cpu_has_work(CPUState *env)
{
if (!env->halted)
return 0;
if (shutdown_requested)
return 0;
+ if (debug_requested)
+ return 0;
return 1;
}
static void main_loop(void)
{
- int ret = 0;
-#ifdef CONFIG_PROFILER
- int64_t ti;
-#endif
-
for (;;) {
- do {
- if (next_cpu == NULL)
- next_cpu = first_cpu;
- for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
- CPUState *env = cur_cpu = next_cpu;
- if (!vm_running)
- break;
- if (timer_alarm_pending) {
- timer_alarm_pending = 0;
- break;
- }
- ret = qemu_cpu_exec(env);
- if (ret == EXCP_DEBUG) {
- gdb_set_stop_cpu(env);
- break;
- }
- }
+ do {
+#ifdef CONFIG_PROFILER
+ int64_t ti;
+#endif
+ tcg_cpu_exec();
#ifdef CONFIG_PROFILER
ti = profile_getclock();
#endif
#ifdef CONFIG_PROFILER
dev_time += profile_getclock() - ti;
#endif
- } while (ret != EXCP_DEBUG && vm_can_run());
+ } while (vm_can_run());
- if (ret == EXCP_DEBUG)
+ if (qemu_debug_requested())
vm_stop(EXCP_DEBUG);
-
if (qemu_shutdown_requested()) {
if (no_shutdown) {
vm_stop(0);