docs/system/deprecated: Mark the 'moxie' CPU as deprecated
[qemu/ar7.git] / target / i386 / hax-cpus.c
blob99770e590ceb1d4e6beb5f9bba1103a55400c1f7
1 /*
2 * QEMU HAX support
4 * Copyright IBM, Corp. 2008
5 * Red Hat, Inc. 2008
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Glauber Costa <gcosta@redhat.com>
11 * Copyright (c) 2011 Intel Corporation
12 * Written by:
13 * Jiang Yunhong<yunhong.jiang@intel.com>
14 * Xin Xiaohui<xiaohui.xin@intel.com>
15 * Zhang Xiantao<xiantao.zhang@intel.com>
17 * This work is licensed under the terms of the GNU GPL, version 2 or later.
18 * See the COPYING file in the top-level directory.
22 #include "qemu/osdep.h"
23 #include "qemu/error-report.h"
24 #include "qemu/main-loop.h"
25 #include "sysemu/runstate.h"
26 #include "sysemu/cpus.h"
27 #include "qemu/guest-random.h"
29 #include "hax-cpus.h"
31 static void *hax_cpu_thread_fn(void *arg)
33 CPUState *cpu = arg;
34 int r;
36 rcu_register_thread();
37 qemu_mutex_lock_iothread();
38 qemu_thread_get_self(cpu->thread);
40 cpu->thread_id = qemu_get_thread_id();
41 hax_init_vcpu(cpu);
42 cpu_thread_signal_created(cpu);
43 qemu_guest_random_seed_thread_part2(cpu->random_seed);
45 do {
46 if (cpu_can_run(cpu)) {
47 r = hax_smp_cpu_exec(cpu);
48 if (r == EXCP_DEBUG) {
49 cpu_handle_guest_debug(cpu);
53 qemu_wait_io_event(cpu);
54 } while (!cpu->unplug || cpu_can_run(cpu));
55 rcu_unregister_thread();
56 return NULL;
59 static void hax_start_vcpu_thread(CPUState *cpu)
61 char thread_name[VCPU_THREAD_NAME_SIZE];
63 cpu->thread = g_malloc0(sizeof(QemuThread));
64 cpu->halt_cond = g_malloc0(sizeof(QemuCond));
65 qemu_cond_init(cpu->halt_cond);
67 snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
68 cpu->cpu_index);
69 qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn,
70 cpu, QEMU_THREAD_JOINABLE);
71 #ifdef _WIN32
72 cpu->hThread = qemu_thread_get_handle(cpu->thread);
73 #endif
76 const CpusAccel hax_cpus = {
77 .create_vcpu_thread = hax_start_vcpu_thread,
78 .kick_vcpu_thread = hax_kick_vcpu_thread,
80 .synchronize_post_reset = hax_cpu_synchronize_post_reset,
81 .synchronize_post_init = hax_cpu_synchronize_post_init,
82 .synchronize_state = hax_cpu_synchronize_state,
83 .synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm,