diff mbox

[42/49] qemu-common: push cpu.h inclusion out of qemu-common.h

Message ID 1458125219-131698-43-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini March 16, 2016, 10:46 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch_init.c                              |  2 ++
 cpus.c                                   |  3 ++-
 exec.c                                   |  2 +-
 gdbstub.c                                |  1 +
 hw/arm/nseries.c                         |  1 +
 hw/arm/pxa2xx_gpio.c                     |  1 +
 hw/core/nmi.c                            |  5 +++++
 hw/display/cg3.c                         |  1 +
 hw/i386/kvm/apic.c                       |  2 ++
 hw/i386/kvm/clock.c                      |  1 +
 hw/i386/kvmvapic.c                       |  2 ++
 hw/intc/apic.c                           |  2 ++
 hw/intc/apic_common.c                    |  2 ++
 hw/intc/arm_gic_kvm.c                    |  2 ++
 hw/intc/armv7m_nvic.c                    |  1 +
 hw/intc/openpic_kvm.c                    |  2 ++
 hw/intc/s390_flic_kvm.c                  |  2 ++
 hw/ppc/ppc4xx_devs.c                     |  1 +
 hw/ppc/prep.c                            |  1 +
 hw/ppc/virtex_ml507.c                    |  1 +
 hw/xtensa/pic_cpu.c                      |  1 +
 include/disas/disas.h                    |  2 ++
 include/exec/gdbstub.h                   |  2 ++
 include/exec/hwaddr.h                    |  2 ++
 include/hw/arm/digic.h                   |  1 +
 include/hw/arm/virt-acpi-build.h         |  1 +
 include/hw/arm/virt.h                    |  1 +
 include/hw/hw.h                          |  1 -
 include/hw/sd/sd.h                       |  2 ++
 include/hw/xen/xen.h                     |  7 ++++---
 include/qemu-common.h                    |  5 -----
 include/sysemu/kvm.h                     |  1 +
 ioport.c                                 |  2 ++
 memory.c                                 |  2 ++
 migration/ram.c                          |  2 ++
 migration/savevm.c                       |  1 +
 monitor.c                                |  2 ++
 qtest.c                                  |  2 ++
 scripts/tracetool/format/tcg_helper_c.py |  1 +
 target-alpha/gdbstub.c                   |  1 +
 target-alpha/machine.c                   |  2 ++
 target-arm/gdbstub.c                     |  1 +
 target-arm/gdbstub64.c                   |  1 +
 target-arm/kvm-stub.c                    |  1 +
 target-arm/kvm32.c                       |  2 +-
 target-arm/kvm64.c                       |  2 +-
 target-arm/machine.c                     |  2 ++
 target-cris/gdbstub.c                    |  1 +
 target-cris/machine.c                    |  2 ++
 target-i386/gdbstub.c                    |  1 +
 target-i386/kvm-stub.c                   |  1 +
 target-i386/kvm.c                        |  2 +-
 target-i386/machine.c                    |  2 ++
 target-lm32/gdbstub.c                    |  1 +
 target-lm32/machine.c                    |  2 ++
 target-m68k/gdbstub.c                    |  1 +
 target-microblaze/gdbstub.c              |  1 +
 target-mips/cpu.h                        | 18 ++----------------
 target-mips/gdbstub.c                    |  1 +
 target-mips/helper.c                     | 17 +++++++++++++++++
 target-mips/kvm.c                        |  2 +-
 target-mips/machine.c                    |  2 ++
 target-moxie/machine.c                   |  2 ++
 target-openrisc/gdbstub.c                |  1 +
 target-openrisc/machine.c                |  2 ++
 target-ppc/gdbstub.c                     |  1 +
 target-ppc/kvm-stub.c                    |  1 +
 target-ppc/kvm.c                         |  2 +-
 target-ppc/machine.c                     |  2 ++
 target-s390x/gdbstub.c                   |  1 +
 target-s390x/kvm.c                       |  2 +-
 target-sh4/gdbstub.c                     |  1 +
 target-sparc/gdbstub.c                   |  1 +
 target-sparc/machine.c                   |  2 ++
 target-xtensa/gdbstub.c                  |  1 +
 tcg/optimize.c                           |  3 +--
 tcg/tcg-op.c                             |  2 ++
 tcg/tcg.h                                |  1 +
 78 files changed, 129 insertions(+), 35 deletions(-)
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index f6aba02..7537b36 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -22,6 +22,8 @@ 
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
diff --git a/cpus.c b/cpus.c
index bc774e2..cdbe4ec 100644
--- a/cpus.c
+++ b/cpus.c
@@ -24,7 +24,8 @@ 
 
 /* Needed early for CONFIG_BSD etc. */
 #include "qemu/osdep.h"
-
+#include "qemu-common.h"
+#include "cpu.h"
 #include "monitor/monitor.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
diff --git a/exec.c b/exec.c
index 10408f2..bd2b334 100644
--- a/exec.c
+++ b/exec.c
@@ -28,10 +28,10 @@ 
 #include "hw/qdev-core.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/boards.h"
+#include "hw/xen/xen.h"
 #endif
 #include "sysemu/kvm.h"
 #include "sysemu/sysemu.h"
-#include "hw/xen/xen.h"
 #include "qemu/timer.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
diff --git a/gdbstub.c b/gdbstub.c
index 492e1e4..f533b60 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -19,6 +19,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #ifdef CONFIG_USER_ONLY
 
 #include "qemu.h"
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index b6e1bf4..1c074e4 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -21,6 +21,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/bswap.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/omap.h"
diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
index 67e7e70..8c9626e 100644
--- a/hw/arm/pxa2xx_gpio.c
+++ b/hw/arm/pxa2xx_gpio.c
@@ -8,6 +8,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/sysbus.h"
 #include "hw/arm/pxa.h"
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index e8bcc41..f616a79 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -20,11 +20,16 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qom/cpu.h"
 #include "hw/nmi.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "monitor/monitor.h"
 
+#if defined(TARGET_I386)
+#include "cpu.h"
+#endif
+
 struct do_nmi_s {
     int cpu_index;
     Error *err;
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index fc0d97f..eb0e71a 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -26,6 +26,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/error-report.h"
 #include "ui/console.h"
 #include "hw/sysbus.h"
diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
index 694d398..59e4789 100644
--- a/hw/i386/kvm/apic.c
+++ b/hw/i386/kvm/apic.c
@@ -10,6 +10,8 @@ 
  * See the COPYING file in the top-level directory.
  */
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/i386/apic_internal.h"
 #include "hw/pci/msi.h"
 #include "sysemu/kvm.h"
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index a3b300c..0f75dd3 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -15,6 +15,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/host-utils.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index c69f374..315857e 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -9,6 +9,8 @@ 
  * top-level directory.
  */
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/cpus.h"
 #include "sysemu/kvm.h"
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index a299462..27151f0 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -17,6 +17,8 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>
  */
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/thread.h"
 #include "hw/i386/apic_internal.h"
 #include "hw/i386/apic.h"
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 4abe145..e6eb694 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -19,6 +19,8 @@ 
  */
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/i386/apic.h"
 #include "hw/i386/apic_internal.h"
 #include "trace.h"
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index e61c5d9..d35cbef 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -20,6 +20,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/sysbus.h"
 #include "migration/migration.h"
 #include "sysemu/kvm.h"
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 669e82a..4d584ef 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -13,6 +13,7 @@ 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "hw/arm/arm.h"
diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
index 4dcdb61..4c069bb 100644
--- a/hw/intc/openpic_kvm.c
+++ b/hw/intc/openpic_kvm.c
@@ -23,6 +23,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include <sys/ioctl.h>
 #include "exec/address-spaces.h"
 #include "hw/hw.h"
diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index 02449b3..eed6325 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -11,6 +11,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include <sys/ioctl.h>
 #include "qemu/error-report.h"
 #include "hw/sysbus.h"
diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
index 7d59018..e7f413e 100644
--- a/hw/ppc/ppc4xx_devs.c
+++ b/hw/ppc/ppc4xx_devs.c
@@ -22,6 +22,7 @@ 
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/ppc/ppc.h"
 #include "hw/ppc/ppc4xx.h"
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 793b9ed..eeffb79 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -22,6 +22,7 @@ 
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/timer/m48t59.h"
 #include "hw/i386/pc.h"
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index b807a08..b97d966 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -23,6 +23,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/hw.h"
 #include "hw/char/serial.h"
diff --git a/hw/xtensa/pic_cpu.c b/hw/xtensa/pic_cpu.c
index c835bd0..ccf65fd 100644
--- a/hw/xtensa/pic_cpu.c
+++ b/hw/xtensa/pic_cpu.c
@@ -26,6 +26,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "qemu/log.h"
 #include "qemu/timer.h"
diff --git a/include/disas/disas.h b/include/disas/disas.h
index 2b9293b..4930d78 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -4,6 +4,8 @@ 
 #include "qemu-common.h"
 
 #ifdef NEED_CPU_H
+#include "cpu.h"
+
 /* Disassemble this for me please... (debugging). */
 void disas(FILE *out, void *code, unsigned long size);
 void target_disas(FILE *out, CPUState *cpu, target_ulong code,
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index d9e8cf7..8e3f8d8 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -11,6 +11,8 @@ 
 #define GDB_WATCHPOINT_ACCESS    4
 
 #ifdef NEED_CPU_H
+#include "cpu.h"
+
 typedef void (*gdb_syscall_complete_cb)(CPUState *cpu,
                                         target_ulong ret, target_ulong err);
 
diff --git a/include/exec/hwaddr.h b/include/exec/hwaddr.h
index c9eb78f..bb41588 100644
--- a/include/exec/hwaddr.h
+++ b/include/exec/hwaddr.h
@@ -3,6 +3,8 @@ 
 #ifndef HWADDR_H
 #define HWADDR_H
 
+#include <inttypes.h>
+
 #define HWADDR_BITS 64
 /* hwaddr is the type of a physical address (its size can
    be different from 'target_ulong').  */
diff --git a/include/hw/arm/digic.h b/include/hw/arm/digic.h
index aaefe0b..63785ba 100644
--- a/include/hw/arm/digic.h
+++ b/include/hw/arm/digic.h
@@ -18,6 +18,7 @@ 
 #ifndef HW_ARM_DIGIC_H
 #define HW_ARM_DIGIC_H
 
+#include "cpu.h"
 #include "hw/timer/digic-timer.h"
 #include "hw/char/digic-uart.h"
 
diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h
index 7d3700e..e43330a 100644
--- a/include/hw/arm/virt-acpi-build.h
+++ b/include/hw/arm/virt-acpi-build.h
@@ -22,6 +22,7 @@ 
 
 #include "qemu-common.h"
 #include "hw/arm/virt.h"
+#include "qemu/notify.h"
 
 #define ACPI_GICC_ENABLED 1
 
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index ecd8589..82703d2 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -31,6 +31,7 @@ 
 #define QEMU_ARM_VIRT_H
 
 #include "qemu-common.h"
+#include "exec/hwaddr.h"
 
 #define NUM_GICV2M_SPIS       64
 #define NUM_VIRTIO_TRANSPORTS 32
diff --git a/include/hw/hw.h b/include/hw/hw.h
index 29931d1..a20321b 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -2,7 +2,6 @@ 
 #ifndef QEMU_HW_H
 #define QEMU_HW_H
 
-
 #ifdef CONFIG_USER_ONLY
 #error Cannot include hw/hw.h from user emulation
 #endif
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h
index d5d273a..c8a4b98 100644
--- a/include/hw/sd/sd.h
+++ b/include/hw/sd/sd.h
@@ -29,6 +29,8 @@ 
 #ifndef __hw_sd_h
 #define __hw_sd_h		1
 
+#include "hw/qdev.h"
+
 #define OUT_OF_RANGE		(1 << 31)
 #define ADDRESS_ERROR		(1 << 30)
 #define BLOCK_LEN_ERROR		(1 << 29)
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 6eb815a..6365483 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -7,8 +7,10 @@ 
  *   /usr/include/xen, so it can be included unconditionally.
  */
 
-#include "hw/irq.h"
 #include "qemu-common.h"
+#include "qemu/typedefs.h"
+#include "exec/cpu-common.h"
+#include "hw/irq.h"
 
 /* xen-machine.c */
 enum xen_mode {
@@ -37,12 +39,11 @@  qemu_irq *xen_interrupt_controller_init(void);
 
 void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
 
-#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
 void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory);
+
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
                    struct MemoryRegion *mr, Error **errp);
 void xen_modified_memory(ram_addr_t start, ram_addr_t length);
-#endif
 
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 6e2da3e..b732f36 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -22,11 +22,6 @@ 
 
 #include "qemu/option.h"
 
-/* FIXME: Remove NEED_CPU_H.  */
-#ifdef NEED_CPU_H
-#include "cpu.h"
-#endif /* !defined(NEED_CPU_H) */
-
 /* main function, renamed */
 #if defined(CONFIG_COCOA)
 int qemu_main(int argc, char **argv, char **envp);
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 6695fa7..d219d70 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -218,6 +218,7 @@  int kvm_init_vcpu(CPUState *cpu);
 int kvm_cpu_exec(CPUState *cpu);
 
 #ifdef NEED_CPU_H
+#include "cpu.h"
 
 void kvm_setup_guest_memory(void *start, size_t size);
 void kvm_flush_coalesced_mmio_buffer(void);
diff --git a/ioport.c b/ioport.c
index 7a84d54..901a997 100644
--- a/ioport.c
+++ b/ioport.c
@@ -26,6 +26,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "exec/ioport.h"
 #include "trace.h"
 #include "exec/memory.h"
diff --git a/memory.c b/memory.c
index 44bf93e..440b11a 100644
--- a/memory.c
+++ b/memory.c
@@ -15,6 +15,8 @@ 
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
 #include "exec/ioport.h"
diff --git a/migration/ram.c b/migration/ram.c
index 704f6a9..0ff0d14 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -26,6 +26,8 @@ 
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include <zlib.h>
 #include "qapi-event.h"
 #include "qemu/bitops.h"
diff --git a/migration/savevm.c b/migration/savevm.c
index 0a33c22..c9cea8a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -28,6 +28,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
diff --git a/monitor.c b/monitor.c
index e99ca8c..3c4c9ac 100644
--- a/monitor.c
+++ b/monitor.c
@@ -23,6 +23,8 @@ 
  */
 #include "qemu/osdep.h"
 #include <dirent.h>
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "monitor/qdev.h"
 #include "hw/usb.h"
diff --git a/qtest.c b/qtest.c
index 87575bc..da4826c 100644
--- a/qtest.c
+++ b/qtest.c
@@ -13,6 +13,8 @@ 
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "sysemu/qtest.h"
 #include "hw/qdev.h"
 #include "sysemu/char.h"
diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py
index a089b0b..e3485b7 100644
--- a/scripts/tracetool/format/tcg_helper_c.py
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -48,6 +48,7 @@  def generate(events, backend):
         '',
         '#include "qemu/osdep.h"',
         '#include "qemu-common.h"',
+        '#include "cpu.h"',
         '#include "trace.h"',
         '#include "exec/helper-proto.h"',
         '',
diff --git a/target-alpha/gdbstub.c b/target-alpha/gdbstub.c
index 199f028..d64bccc 100644
--- a/target-alpha/gdbstub.c
+++ b/target-alpha/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int alpha_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 3f72943..710b783 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "migration/cpu.h"
diff --git a/target-arm/gdbstub.c b/target-arm/gdbstub.c
index 3ba9aad..04c1208 100644
--- a/target-arm/gdbstub.c
+++ b/target-arm/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 /* Old gdb always expect FPA registers.  Newer (xml-aware) gdb only expect
diff --git a/target-arm/gdbstub64.c b/target-arm/gdbstub64.c
index 634c6bc..49bc3fc 100644
--- a/target-arm/gdbstub64.c
+++ b/target-arm/gdbstub64.c
@@ -18,6 +18,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int aarch64_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-arm/kvm-stub.c b/target-arm/kvm-stub.c
index 38bf433..b2c66df 100644
--- a/target-arm/kvm-stub.c
+++ b/target-arm/kvm-stub.c
@@ -11,6 +11,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "kvm_arm.h"
 
 bool write_kvmstate_to_list(ARMCPU *cpu)
diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
index d44a7f9..7f5935a 100644
--- a/target-arm/kvm32.c
+++ b/target-arm/kvm32.c
@@ -15,11 +15,11 @@ 
 #include <linux/kvm.h>
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "kvm_arm.h"
-#include "cpu.h"
 #include "internals.h"
 #include "hw/arm/arm.h"
 
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index e8527bf..e2a34f6 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -18,6 +18,7 @@ 
 #include <linux/kvm.h>
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/timer.h"
 #include "qemu/error-report.h"
 #include "qemu/host-utils.h"
@@ -25,7 +26,6 @@ 
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "kvm_arm.h"
-#include "cpu.h"
 #include "internals.h"
 #include "hw/arm/arm.h"
 
diff --git a/target-arm/machine.c b/target-arm/machine.c
index c23feb1..2f45260 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "qemu/error-report.h"
diff --git a/target-cris/gdbstub.c b/target-cris/gdbstub.c
index 1bbf17b..3a72ee2 100644
--- a/target-cris/gdbstub.c
+++ b/target-cris/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int crisv10_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-cris/machine.c b/target-cris/machine.c
index 4c9287f..6b797e8 100644
--- a/target-cris/machine.c
+++ b/target-cris/machine.c
@@ -19,6 +19,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "migration/cpu.h"
 
diff --git a/target-i386/gdbstub.c b/target-i386/gdbstub.c
index 4b50713..c494535 100644
--- a/target-i386/gdbstub.c
+++ b/target-i386/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 #ifdef TARGET_X86_64
diff --git a/target-i386/kvm-stub.c b/target-i386/kvm-stub.c
index 8df9c59..cdf1506 100644
--- a/target-i386/kvm-stub.c
+++ b/target-i386/kvm-stub.c
@@ -11,6 +11,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "kvm_i386.h"
 
 bool kvm_allows_irq0_override(void)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 940b494..6f96bec 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -22,10 +22,10 @@ 
 #include <linux/kvm_para.h>
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm_int.h"
 #include "kvm_i386.h"
-#include "cpu.h"
 #include "hyperv.h"
 
 #include "exec/gdbstub.h"
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 57203b2..658b066 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/i386/pc.h"
diff --git a/target-lm32/gdbstub.c b/target-lm32/gdbstub.c
index 8ac1288..cf929dd 100644
--- a/target-lm32/gdbstub.c
+++ b/target-lm32/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 #include "hw/lm32/lm32_pic.h"
 
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 6f56216..3c258a4 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "migration/cpu.h"
diff --git a/target-m68k/gdbstub.c b/target-m68k/gdbstub.c
index f02bb5c..c7f44c9 100644
--- a/target-m68k/gdbstub.c
+++ b/target-m68k/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int m68k_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-microblaze/gdbstub.c b/target-microblaze/gdbstub.c
index 89d3898..7fb076c 100644
--- a/target-microblaze/gdbstub.c
+++ b/target-microblaze/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int mb_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index 1baa57a..4465a78 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -1130,22 +1130,8 @@  static inline void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val)
 }
 #endif
 
-static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
-                                                        uint32_t exception,
-                                                        int error_code,
-                                                        uintptr_t pc)
-{
-    CPUState *cs = CPU(mips_env_get_cpu(env));
-
-    if (exception < EXCP_SC) {
-        qemu_log_mask(CPU_LOG_INT, "%s: %d %d\n",
-                      __func__, exception, error_code);
-    }
-    cs->exception_index = exception;
-    env->error_code = error_code;
-
-    cpu_loop_exit_restore(cs, pc);
-}
+void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, uint32_t exception,
+                                          int error_code, uintptr_t pc);
 
 static inline void QEMU_NORETURN do_raise_exception(CPUMIPSState *env,
                                                     uint32_t exception,
diff --git a/target-mips/gdbstub.c b/target-mips/gdbstub.c
index b0b4a32..2707ff5 100644
--- a/target-mips/gdbstub.c
+++ b/target-mips/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-mips/helper.c b/target-mips/helper.c
index 1004ede..0fabfec 100644
--- a/target-mips/helper.c
+++ b/target-mips/helper.c
@@ -840,3 +840,20 @@  void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra)
     }
 }
 #endif
+
+void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
+                                          uint32_t exception,
+                                          int error_code,
+                                          uintptr_t pc)
+{
+    CPUState *cs = CPU(mips_env_get_cpu(env));
+
+    if (exception < EXCP_SC) {
+        qemu_log_mask(CPU_LOG_INT, "%s: %d %d\n",
+                      __func__, exception, error_code);
+    }
+    cs->exception_index = exception;
+    env->error_code = error_code;
+
+    cpu_loop_exit_restore(cs, pc);
+}
diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index 950bc05..a854e4d 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -16,11 +16,11 @@ 
 #include <linux/kvm.h>
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
-#include "cpu.h"
 #include "sysemu/cpus.h"
 #include "kvm_mips.h"
 #include "exec/memattrs.h"
diff --git a/target-mips/machine.c b/target-mips/machine.c
index e7b2cf9..f07289e 100644
--- a/target-mips/machine.c
+++ b/target-mips/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "cpu.h"
 #include "migration/cpu.h"
diff --git a/target-moxie/machine.c b/target-moxie/machine.c
index 7810e1c..282dcd8 100644
--- a/target-moxie/machine.c
+++ b/target-moxie/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "machine.h"
diff --git a/target-openrisc/gdbstub.c b/target-openrisc/gdbstub.c
index edc301a..cb16e76 100644
--- a/target-openrisc/gdbstub.c
+++ b/target-openrisc/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int openrisc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c
index bd5d50f..17b0c77 100644
--- a/target-openrisc/machine.c
+++ b/target-openrisc/machine.c
@@ -18,6 +18,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "migration/cpu.h"
diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
index 569c380..7a33813 100644
--- a/target-ppc/gdbstub.c
+++ b/target-ppc/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 static int ppc_gdb_register_len_apple(int n)
diff --git a/target-ppc/kvm-stub.c b/target-ppc/kvm-stub.c
index 627bcb4..efeafca 100644
--- a/target-ppc/kvm-stub.c
+++ b/target-ppc/kvm-stub.c
@@ -11,6 +11,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "hw/ppc/openpic.h"
 
 int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *cs)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index d67c169..e64c8dc 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -24,11 +24,11 @@ 
 
 #include "qemu-common.h"
 #include "qemu/error-report.h"
+#include "cpu.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
-#include "cpu.h"
 #include "sysemu/cpus.h"
 #include "sysemu/device_tree.h"
 #include "mmu-hash64.h"
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index 2ea29dd..7a9995d 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "sysemu/kvm.h"
diff --git a/target-s390x/gdbstub.c b/target-s390x/gdbstub.c
index 9fc36cb..0992ae7 100644
--- a/target-s390x/gdbstub.c
+++ b/target-s390x/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 #include "qemu/bitops.h"
 
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index e1859ca..4d563e3 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -29,12 +29,12 @@ 
 #include <asm/ptrace.h>
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "hw/hw.h"
-#include "cpu.h"
 #include "sysemu/device_tree.h"
 #include "qapi/qmp/qjson.h"
 #include "exec/gdbstub.h"
diff --git a/target-sh4/gdbstub.c b/target-sh4/gdbstub.c
index 1b59ea8..13bea00 100644
--- a/target-sh4/gdbstub.c
+++ b/target-sh4/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 /* Hint: Use "set architecture sh4" in GDB to see fpu registers */
diff --git a/target-sparc/gdbstub.c b/target-sparc/gdbstub.c
index e530dc5..ffc2baa 100644
--- a/target-sparc/gdbstub.c
+++ b/target-sparc/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 #ifdef TARGET_ABI32
diff --git a/target-sparc/machine.c b/target-sparc/machine.c
index 04806f6..c8823af 100644
--- a/target-sparc/machine.c
+++ b/target-sparc/machine.c
@@ -1,4 +1,6 @@ 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "qemu/timer.h"
diff --git a/target-xtensa/gdbstub.c b/target-xtensa/gdbstub.c
index 51d4db0..bfcd591 100644
--- a/target-xtensa/gdbstub.c
+++ b/target-xtensa/gdbstub.c
@@ -19,6 +19,7 @@ 
  */
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "cpu.h"
 #include "exec/gdbstub.h"
 
 int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 6d68f57..701f552 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -24,9 +24,8 @@ 
  */
 
 #include "qemu/osdep.h"
-
-
 #include "qemu-common.h"
+#include "cpu.h"
 #include "tcg-op.h"
 
 #define CASE_OP_32_64(x)                        \
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index f554b86..7a15914 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -23,6 +23,8 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "cpu.h"
 #include "tcg.h"
 #include "tcg-op.h"
 
diff --git a/tcg/tcg.h b/tcg/tcg.h
index b83f763..d8a3abe 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -26,6 +26,7 @@ 
 #define TCG_H
 
 #include "qemu-common.h"
+#include "cpu.h"
 #include "qemu/bitops.h"
 #include "tcg-target.h"