From a8170e5e97ad17ca169c64ba87ae2f53850dab4c Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 23 Oct 2012 12:30:10 +0200 Subject: Rename target_phys_addr_t to hwaddr target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori --- hw/sh_timer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'hw/sh_timer.c') diff --git a/hw/sh_timer.c b/hw/sh_timer.c index 64bf604ba4..c0365b1142 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -59,7 +59,7 @@ static void sh_timer_update(sh_timer_state *s) s->int_level = new_level; } -static uint32_t sh_timer_read(void *opaque, target_phys_addr_t offset) +static uint32_t sh_timer_read(void *opaque, hwaddr offset) { sh_timer_state *s = (sh_timer_state *)opaque; @@ -79,7 +79,7 @@ static uint32_t sh_timer_read(void *opaque, target_phys_addr_t offset) } } -static void sh_timer_write(void *opaque, target_phys_addr_t offset, +static void sh_timer_write(void *opaque, hwaddr offset, uint32_t value) { sh_timer_state *s = (sh_timer_state *)opaque; @@ -222,7 +222,7 @@ typedef struct { int feat; } tmu012_state; -static uint64_t tmu012_read(void *opaque, target_phys_addr_t offset, +static uint64_t tmu012_read(void *opaque, hwaddr offset, unsigned size) { tmu012_state *s = (tmu012_state *)opaque; @@ -253,7 +253,7 @@ static uint64_t tmu012_read(void *opaque, target_phys_addr_t offset, return 0; } -static void tmu012_write(void *opaque, target_phys_addr_t offset, +static void tmu012_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { tmu012_state *s = (tmu012_state *)opaque; @@ -303,7 +303,7 @@ static const MemoryRegionOps tmu012_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -void tmu012_init(MemoryRegion *sysmem, target_phys_addr_t base, +void tmu012_init(MemoryRegion *sysmem, hwaddr base, int feat, uint32_t freq, qemu_irq ch0_irq, qemu_irq ch1_irq, qemu_irq ch2_irq0, qemu_irq ch2_irq1) -- cgit v1.2.3-55-g7522 From 022c62cbbcf1ff40b23c92874f8670cddfec2414 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:49 +0100 Subject: exec: move include files to include/exec/ Signed-off-by: Paolo Bonzini --- arch_init.c | 4 +- balloon.c | 2 +- bsd-user/qemu.h | 4 +- cpu-all.h | 522 ---------------------- cpu-common.h | 112 ----- cpu-defs.h | 213 --------- cpus.c | 2 +- cputlb.c | 18 +- cputlb.h | 46 -- def-helper.h | 275 ------------ dma.h | 2 +- dump.c | 6 +- exec-all.h | 412 ------------------ exec-memory.h | 41 -- exec.c | 8 +- gdbstub.c | 2 +- gdbstub.h | 53 --- gen-icount.h | 53 --- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 4 +- hw/alpha_typhoon.c | 4 +- hw/an5206.c | 2 +- hw/apb_pci.c | 2 +- hw/apic_internal.h | 2 +- hw/apm.h | 2 +- hw/arm-misc.h | 2 +- hw/armv7m_nvic.c | 2 +- hw/axis_dev88.c | 2 +- hw/bonito.c | 2 +- hw/collie.c | 2 +- hw/dummy_m68k.c | 2 +- hw/etraxfs_dma.c | 2 +- hw/exynos4210.h | 2 +- hw/exynos4210_fimd.c | 2 +- hw/exynos4_boards.c | 2 +- hw/flash.h | 2 +- hw/framebuffer.h | 2 +- hw/gt64xxx.c | 2 +- hw/gumstix.c | 2 +- hw/highbank.c | 2 +- hw/hw.h | 4 +- hw/ide.h | 2 +- hw/ide/ahci.c | 2 +- hw/ide/internal.h | 2 +- hw/integratorcp.c | 2 +- hw/ioapic_internal.h | 2 +- hw/isa-bus.c | 2 +- hw/isa.h | 4 +- hw/isa_mmio.c | 2 +- hw/kzm.c | 2 +- hw/leon3.c | 2 +- hw/lm32_boards.c | 2 +- hw/loader.c | 4 +- hw/lpc_ich9.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.h | 2 +- hw/mainstone.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/mcf_fec.c | 2 +- hw/mcf_intc.c | 2 +- hw/mcf_uart.c | 2 +- hw/milkymist.c | 2 +- hw/mips.h | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_jazz.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 2 +- hw/musicpal.c | 2 +- hw/ne2000-isa.c | 2 +- hw/nseries.c | 2 +- hw/omap.h | 2 +- hw/omap_gpmc.c | 4 +- hw/omap_sx1.c | 2 +- hw/omap_uart.c | 2 +- hw/onenand.c | 4 +- hw/openrisc_sim.c | 2 +- hw/palm.c | 2 +- hw/pam.h | 2 +- hw/pc.c | 4 +- hw/pc.h | 6 +- hw/pc_piix.c | 4 +- hw/pc_q35.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci.h | 2 +- hw/pci/pcie_host.c | 2 +- hw/pci/pcie_host.h | 2 +- hw/pci/shpc.h | 2 +- hw/pci_bridge_dev.c | 2 +- hw/pcnet.h | 2 +- hw/petalogix_ml605_mmu.c | 2 +- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/pflash_cfi01.c | 2 +- hw/pflash_cfi02.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc405_boards.c | 2 +- hw/ppc405_uc.c | 2 +- hw/ppc440_bamboo.c | 2 +- hw/ppc4xx_devs.c | 2 +- hw/ppc4xx_pci.c | 2 +- hw/ppc_mac.h | 2 +- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 2 +- hw/prep_pci.c | 2 +- hw/puv3.c | 2 +- hw/pxa.h | 2 +- hw/qdev-addr.c | 2 +- hw/r2d.c | 2 +- hw/realview.c | 2 +- hw/s390-virtio.c | 2 +- hw/s390x/sclp.c | 2 +- hw/serial.c | 2 +- hw/serial.h | 2 +- hw/sh7750.c | 2 +- hw/sh_intc.h | 2 +- hw/sh_pci.c | 2 +- hw/sh_serial.c | 2 +- hw/sh_timer.c | 2 +- hw/shix.c | 2 +- hw/soc_dma.h | 2 +- hw/spapr.c | 2 +- hw/spapr_iommu.c | 2 +- hw/spapr_pci.c | 2 +- hw/spitz.c | 2 +- hw/stellaris.c | 2 +- hw/strongarm.h | 2 +- hw/sun4u.c | 2 +- hw/sysbus.c | 2 +- hw/sysbus.h | 2 +- hw/tosa.c | 2 +- hw/usb/libhw.c | 2 +- hw/versatile_pci.c | 2 +- hw/versatilepb.c | 2 +- hw/vexpress.c | 2 +- hw/vfio_pci.c | 4 +- hw/vga_int.h | 2 +- hw/vhost.c | 2 +- hw/vhost.h | 2 +- hw/virtex_ml507.c | 2 +- hw/virtio-balloon.c | 2 +- hw/vt82c686.c | 2 +- hw/xen_platform.c | 2 +- hw/xen_pt.c | 2 +- hw/xilinx_zynq.c | 2 +- hw/xtensa_lx60.c | 4 +- hw/xtensa_sim.c | 4 +- hw/z2.c | 2 +- hwaddr.h | 24 -- include/exec/address-spaces.h | 41 ++ include/exec/cpu-all.h | 522 ++++++++++++++++++++++ include/exec/cpu-common.h | 112 +++++ include/exec/cpu-defs.h | 213 +++++++++ include/exec/cputlb.h | 46 ++ include/exec/def-helper.h | 275 ++++++++++++ include/exec/exec-all.h | 412 ++++++++++++++++++ include/exec/gdbstub.h | 53 +++ include/exec/gen-icount.h | 53 +++ include/exec/hwaddr.h | 24 ++ include/exec/ioport.h | 78 ++++ include/exec/iorange.h | 31 ++ include/exec/memory-internal.h | 141 ++++++ include/exec/memory.h | 882 ++++++++++++++++++++++++++++++++++++++ include/exec/poison.h | 64 +++ include/exec/softmmu-semi.h | 77 ++++ include/exec/softmmu_defs.h | 37 ++ include/exec/softmmu_exec.h | 163 +++++++ include/exec/softmmu_header.h | 213 +++++++++ include/exec/softmmu_template.h | 354 +++++++++++++++ include/exec/spinlock.h | 49 +++ include/exec/user/abitypes.h | 36 ++ include/exec/user/thunk.h | 189 ++++++++ ioport.c | 4 +- ioport.h | 78 ---- iorange.h | 31 -- kvm-all.c | 6 +- kvm-stub.c | 2 +- linux-user/qemu.h | 6 +- memory-internal.h | 141 ------ memory.c | 8 +- memory.h | 882 -------------------------------------- memory_mapping-stub.c | 2 +- memory_mapping.c | 2 +- monitor.c | 4 +- poison.h | 64 --- qemu-lock.h | 49 --- qemu-user-types.h | 36 -- qtest.c | 4 +- savevm.c | 2 +- scripts/feature_to_c.sh | 2 +- softmmu-semi.h | 77 ---- softmmu_defs.h | 37 -- softmmu_exec.h | 163 ------- softmmu_header.h | 213 --------- softmmu_template.h | 354 --------------- target-alpha/cpu.h | 6 +- target-alpha/helper.h | 4 +- target-alpha/mem_helper.c | 10 +- target-alpha/translate.c | 2 +- target-arm/arm-semi.c | 4 +- target-arm/cpu.h | 6 +- target-arm/helper.c | 2 +- target-arm/helper.h | 4 +- target-arm/iwmmxt_helper.c | 2 +- target-arm/neon_helper.c | 2 +- target-arm/op_helper.c | 10 +- target-arm/translate.c | 2 +- target-cris/cpu.h | 6 +- target-cris/helper.h | 4 +- target-cris/op_helper.c | 10 +- target-cris/translate.c | 2 +- target-i386/arch_dump.c | 2 +- target-i386/arch_memory_mapping.c | 2 +- target-i386/cpu.h | 6 +- target-i386/fpu_helper.c | 2 +- target-i386/helper.h | 4 +- target-i386/ioport-user.c | 2 +- target-i386/kvm.c | 4 +- target-i386/mem_helper.c | 10 +- target-i386/misc_helper.c | 4 +- target-i386/seg_helper.c | 2 +- target-i386/svm_helper.c | 4 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 6 +- target-lm32/helper.h | 4 +- target-lm32/op_helper.c | 8 +- target-lm32/translate.c | 2 +- target-m68k/cpu.h | 6 +- target-m68k/helper.c | 2 +- target-m68k/helpers.h | 4 +- target-m68k/m68k-semi.c | 4 +- target-m68k/op_helper.c | 10 +- target-m68k/translate.c | 2 +- target-microblaze/cpu.h | 6 +- target-microblaze/helper.h | 4 +- target-microblaze/op_helper.c | 10 +- target-microblaze/translate.c | 2 +- target-mips/cpu.h | 6 +- target-mips/helper.h | 4 +- target-mips/op_helper.c | 10 +- target-mips/translate.c | 2 +- target-openrisc/cpu.h | 6 +- target-openrisc/helper.h | 4 +- target-openrisc/interrupt.c | 2 +- target-openrisc/mmu.c | 2 +- target-openrisc/mmu_helper.c | 10 +- target-openrisc/translate.c | 4 +- target-ppc/cpu.h | 6 +- target-ppc/helper.h | 4 +- target-ppc/kvm_ppc.h | 2 +- target-ppc/mem_helper.c | 10 +- target-ppc/translate.c | 2 +- target-ppc/translate_init.c | 2 +- target-s390x/cpu.h | 6 +- target-s390x/fpu_helper.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/helper.h | 4 +- target-s390x/mem_helper.c | 10 +- target-s390x/misc_helper.c | 4 +- target-s390x/translate.c | 2 +- target-sh4/cpu.h | 6 +- target-sh4/helper.h | 4 +- target-sh4/op_helper.c | 10 +- target-sh4/translate.c | 2 +- target-sparc/cpu.h | 6 +- target-sparc/helper.h | 4 +- target-sparc/ldst_helper.c | 10 +- target-sparc/mmu_helper.c | 2 +- target-sparc/translate.c | 2 +- target-unicore32/cpu.h | 6 +- target-unicore32/helper.c | 2 +- target-unicore32/helper.h | 4 +- target-unicore32/op_helper.c | 8 +- target-unicore32/translate.c | 2 +- target-xtensa/core-dc232b.c | 4 +- target-xtensa/core-dc233c.c | 4 +- target-xtensa/core-fsf.c | 4 +- target-xtensa/cpu.h | 6 +- target-xtensa/helper.c | 4 +- target-xtensa/helper.h | 4 +- target-xtensa/op_helper.c | 8 +- target-xtensa/translate.c | 4 +- tcg/arm/tcg-target.c | 2 +- tcg/hppa/tcg-target.c | 2 +- tcg/i386/tcg-target.c | 2 +- tcg/ia64/tcg-target.c | 2 +- tcg/mips/tcg-target.c | 2 +- tcg/ppc/tcg-target.c | 2 +- tcg/ppc64/tcg-target.c | 2 +- tcg/s390/tcg-target.c | 2 +- tcg/sparc/tcg-target.c | 2 +- tci.c | 2 +- thunk.c | 2 +- thunk.h | 189 -------- translate-all.c | 6 +- vl.c | 2 +- xen-all.c | 2 +- xen-stub.c | 2 +- 300 files changed, 4474 insertions(+), 4474 deletions(-) delete mode 100644 cpu-all.h delete mode 100644 cpu-common.h delete mode 100644 cpu-defs.h delete mode 100644 cputlb.h delete mode 100644 def-helper.h delete mode 100644 exec-all.h delete mode 100644 exec-memory.h delete mode 100644 gdbstub.h delete mode 100644 gen-icount.h delete mode 100644 hwaddr.h create mode 100644 include/exec/address-spaces.h create mode 100644 include/exec/cpu-all.h create mode 100644 include/exec/cpu-common.h create mode 100644 include/exec/cpu-defs.h create mode 100644 include/exec/cputlb.h create mode 100644 include/exec/def-helper.h create mode 100644 include/exec/exec-all.h create mode 100644 include/exec/gdbstub.h create mode 100644 include/exec/gen-icount.h create mode 100644 include/exec/hwaddr.h create mode 100644 include/exec/ioport.h create mode 100644 include/exec/iorange.h create mode 100644 include/exec/memory-internal.h create mode 100644 include/exec/memory.h create mode 100644 include/exec/poison.h create mode 100644 include/exec/softmmu-semi.h create mode 100644 include/exec/softmmu_defs.h create mode 100644 include/exec/softmmu_exec.h create mode 100644 include/exec/softmmu_header.h create mode 100644 include/exec/softmmu_template.h create mode 100644 include/exec/spinlock.h create mode 100644 include/exec/user/abitypes.h create mode 100644 include/exec/user/thunk.h delete mode 100644 ioport.h delete mode 100644 iorange.h delete mode 100644 memory-internal.h delete mode 100644 memory.h delete mode 100644 poison.h delete mode 100644 qemu-lock.h delete mode 100644 qemu-user-types.h delete mode 100644 softmmu-semi.h delete mode 100644 softmmu_defs.h delete mode 100644 softmmu_exec.h delete mode 100644 softmmu_header.h delete mode 100644 softmmu_template.h delete mode 100644 thunk.h (limited to 'hw/sh_timer.c') diff --git a/arch_init.c b/arch_init.c index e479a2566c..e15cedad04 100644 --- a/arch_init.c +++ b/arch_init.c @@ -40,9 +40,9 @@ #include "hw/audiodev.h" #include "kvm.h" #include "migration.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "hw/smbios.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/pcspk.h" #include "qemu/page_cache.h" #include "qemu-config.h" diff --git a/balloon.c b/balloon.c index 610fe6d626..c24458b5f9 100644 --- a/balloon.c +++ b/balloon.c @@ -25,7 +25,7 @@ */ #include "monitor.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "kvm.h" #include "balloon.h" #include "trace.h" diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d2688995bd..c64c3ccca3 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -11,7 +11,7 @@ #include #endif /* DEBUG_REMAP */ -#include "qemu-user-types.h" +#include "exec/user/abitypes.h" enum BSDType { target_freebsd, @@ -23,7 +23,7 @@ extern enum BSDType bsd_type; #include "syscall_defs.h" #include "syscall.h" #include "target_signal.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread diff --git a/cpu-all.h b/cpu-all.h deleted file mode 100644 index d6b2b19743..0000000000 --- a/cpu-all.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - * defines common to all virtual CPUs - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPU_ALL_H -#define CPU_ALL_H - -#include "qemu-common.h" -#include "qemu-tls.h" -#include "cpu-common.h" - -/* some important defines: - * - * WORDS_ALIGNED : if defined, the host cpu can only make word aligned - * memory accesses. - * - * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and - * otherwise little endian. - * - * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet)) - * - * TARGET_WORDS_BIGENDIAN : same for target cpu - */ - -#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) -#define BSWAP_NEEDED -#endif - -#ifdef BSWAP_NEEDED - -static inline uint16_t tswap16(uint16_t s) -{ - return bswap16(s); -} - -static inline uint32_t tswap32(uint32_t s) -{ - return bswap32(s); -} - -static inline uint64_t tswap64(uint64_t s) -{ - return bswap64(s); -} - -static inline void tswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void tswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void tswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#else - -static inline uint16_t tswap16(uint16_t s) -{ - return s; -} - -static inline uint32_t tswap32(uint32_t s) -{ - return s; -} - -static inline uint64_t tswap64(uint64_t s) -{ - return s; -} - -static inline void tswap16s(uint16_t *s) -{ -} - -static inline void tswap32s(uint32_t *s) -{ -} - -static inline void tswap64s(uint64_t *s) -{ -} - -#endif - -#if TARGET_LONG_SIZE == 4 -#define tswapl(s) tswap32(s) -#define tswapls(s) tswap32s((uint32_t *)(s)) -#define bswaptls(s) bswap32s(s) -#else -#define tswapl(s) tswap64(s) -#define tswapls(s) tswap64s((uint64_t *)(s)) -#define bswaptls(s) bswap64s(s) -#endif - -/* CPU memory access without any memory or io remapping */ - -/* - * the generic syntax for the memory accesses is: - * - * load: ld{type}{sign}{size}{endian}_{access_type}(ptr) - * - * store: st{type}{size}{endian}_{access_type}(ptr, val) - * - * type is: - * (empty): integer access - * f : float access - * - * sign is: - * (empty): for floats or 32 bit size - * u : unsigned - * s : signed - * - * size is: - * b: 8 bits - * w: 16 bits - * l: 32 bits - * q: 64 bits - * - * endian is: - * (empty): target cpu endianness or 8 bit access - * r : reversed target cpu endianness (not implemented yet) - * be : big endian (not implemented yet) - * le : little endian (not implemented yet) - * - * access_type is: - * raw : host memory access - * user : user mode access using soft MMU - * kernel : kernel mode access using soft MMU - */ - -/* target-endianness CPU memory access functions */ -#if defined(TARGET_WORDS_BIGENDIAN) -#define lduw_p(p) lduw_be_p(p) -#define ldsw_p(p) ldsw_be_p(p) -#define ldl_p(p) ldl_be_p(p) -#define ldq_p(p) ldq_be_p(p) -#define ldfl_p(p) ldfl_be_p(p) -#define ldfq_p(p) ldfq_be_p(p) -#define stw_p(p, v) stw_be_p(p, v) -#define stl_p(p, v) stl_be_p(p, v) -#define stq_p(p, v) stq_be_p(p, v) -#define stfl_p(p, v) stfl_be_p(p, v) -#define stfq_p(p, v) stfq_be_p(p, v) -#else -#define lduw_p(p) lduw_le_p(p) -#define ldsw_p(p) ldsw_le_p(p) -#define ldl_p(p) ldl_le_p(p) -#define ldq_p(p) ldq_le_p(p) -#define ldfl_p(p) ldfl_le_p(p) -#define ldfq_p(p) ldfq_le_p(p) -#define stw_p(p, v) stw_le_p(p, v) -#define stl_p(p, v) stl_le_p(p, v) -#define stq_p(p, v) stq_le_p(p, v) -#define stfl_p(p, v) stfl_le_p(p, v) -#define stfq_p(p, v) stfq_le_p(p, v) -#endif - -/* MMU memory access macros */ - -#if defined(CONFIG_USER_ONLY) -#include -#include "qemu-user-types.h" - -/* On some host systems the guest address space is reserved on the host. - * This allows the guest address space to be offset to a convenient location. - */ -#if defined(CONFIG_USE_GUEST_BASE) -extern unsigned long guest_base; -extern int have_guest_base; -extern unsigned long reserved_va; -#define GUEST_BASE guest_base -#define RESERVED_VA reserved_va -#else -#define GUEST_BASE 0ul -#define RESERVED_VA 0ul -#endif - -/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ -#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE)) - -#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS -#define h2g_valid(x) 1 -#else -#define h2g_valid(x) ({ \ - unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ - (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ - (!RESERVED_VA || (__guest < RESERVED_VA)); \ -}) -#endif - -#define h2g(x) ({ \ - unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ - /* Check if given address fits target address space */ \ - assert(h2g_valid(x)); \ - (abi_ulong)__ret; \ -}) - -#define saddr(x) g2h(x) -#define laddr(x) g2h(x) - -#else /* !CONFIG_USER_ONLY */ -/* NOTE: we use double casts if pointers and target_ulong have - different sizes */ -#define saddr(x) (uint8_t *)(intptr_t)(x) -#define laddr(x) (uint8_t *)(intptr_t)(x) -#endif - -#define ldub_raw(p) ldub_p(laddr((p))) -#define ldsb_raw(p) ldsb_p(laddr((p))) -#define lduw_raw(p) lduw_p(laddr((p))) -#define ldsw_raw(p) ldsw_p(laddr((p))) -#define ldl_raw(p) ldl_p(laddr((p))) -#define ldq_raw(p) ldq_p(laddr((p))) -#define ldfl_raw(p) ldfl_p(laddr((p))) -#define ldfq_raw(p) ldfq_p(laddr((p))) -#define stb_raw(p, v) stb_p(saddr((p)), v) -#define stw_raw(p, v) stw_p(saddr((p)), v) -#define stl_raw(p, v) stl_p(saddr((p)), v) -#define stq_raw(p, v) stq_p(saddr((p)), v) -#define stfl_raw(p, v) stfl_p(saddr((p)), v) -#define stfq_raw(p, v) stfq_p(saddr((p)), v) - - -#if defined(CONFIG_USER_ONLY) - -/* if user mode, no other memory access functions */ -#define ldub(p) ldub_raw(p) -#define ldsb(p) ldsb_raw(p) -#define lduw(p) lduw_raw(p) -#define ldsw(p) ldsw_raw(p) -#define ldl(p) ldl_raw(p) -#define ldq(p) ldq_raw(p) -#define ldfl(p) ldfl_raw(p) -#define ldfq(p) ldfq_raw(p) -#define stb(p, v) stb_raw(p, v) -#define stw(p, v) stw_raw(p, v) -#define stl(p, v) stl_raw(p, v) -#define stq(p, v) stq_raw(p, v) -#define stfl(p, v) stfl_raw(p, v) -#define stfq(p, v) stfq_raw(p, v) - -#define cpu_ldub_code(env1, p) ldub_raw(p) -#define cpu_ldsb_code(env1, p) ldsb_raw(p) -#define cpu_lduw_code(env1, p) lduw_raw(p) -#define cpu_ldsw_code(env1, p) ldsw_raw(p) -#define cpu_ldl_code(env1, p) ldl_raw(p) -#define cpu_ldq_code(env1, p) ldq_raw(p) - -#define cpu_ldub_data(env, addr) ldub_raw(addr) -#define cpu_lduw_data(env, addr) lduw_raw(addr) -#define cpu_ldsw_data(env, addr) ldsw_raw(addr) -#define cpu_ldl_data(env, addr) ldl_raw(addr) -#define cpu_ldq_data(env, addr) ldq_raw(addr) - -#define cpu_stb_data(env, addr, data) stb_raw(addr, data) -#define cpu_stw_data(env, addr, data) stw_raw(addr, data) -#define cpu_stl_data(env, addr, data) stl_raw(addr, data) -#define cpu_stq_data(env, addr, data) stq_raw(addr, data) - -#define cpu_ldub_kernel(env, addr) ldub_raw(addr) -#define cpu_lduw_kernel(env, addr) lduw_raw(addr) -#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr) -#define cpu_ldl_kernel(env, addr) ldl_raw(addr) -#define cpu_ldq_kernel(env, addr) ldq_raw(addr) - -#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data) -#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data) -#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data) -#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data) - -#define ldub_kernel(p) ldub_raw(p) -#define ldsb_kernel(p) ldsb_raw(p) -#define lduw_kernel(p) lduw_raw(p) -#define ldsw_kernel(p) ldsw_raw(p) -#define ldl_kernel(p) ldl_raw(p) -#define ldq_kernel(p) ldq_raw(p) -#define ldfl_kernel(p) ldfl_raw(p) -#define ldfq_kernel(p) ldfq_raw(p) -#define stb_kernel(p, v) stb_raw(p, v) -#define stw_kernel(p, v) stw_raw(p, v) -#define stl_kernel(p, v) stl_raw(p, v) -#define stq_kernel(p, v) stq_raw(p, v) -#define stfl_kernel(p, v) stfl_raw(p, v) -#define stfq_kernel(p, vt) stfq_raw(p, v) - -#define cpu_ldub_data(env, addr) ldub_raw(addr) -#define cpu_lduw_data(env, addr) lduw_raw(addr) -#define cpu_ldl_data(env, addr) ldl_raw(addr) - -#define cpu_stb_data(env, addr, data) stb_raw(addr, data) -#define cpu_stw_data(env, addr, data) stw_raw(addr, data) -#define cpu_stl_data(env, addr, data) stl_raw(addr, data) -#endif /* defined(CONFIG_USER_ONLY) */ - -/* page related stuff */ - -#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) - -/* ??? These should be the larger of uintptr_t and target_ulong. */ -extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) - -/* same as PROT_xxx */ -#define PAGE_READ 0x0001 -#define PAGE_WRITE 0x0002 -#define PAGE_EXEC 0x0004 -#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) -#define PAGE_VALID 0x0008 -/* original state of the write flag (used when tracking self-modifying - code */ -#define PAGE_WRITE_ORG 0x0010 -#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) -/* FIXME: Code that sets/uses this is broken and needs to go away. */ -#define PAGE_RESERVED 0x0020 -#endif - -#if defined(CONFIG_USER_ONLY) -void page_dump(FILE *f); - -typedef int (*walk_memory_regions_fn)(void *, abi_ulong, - abi_ulong, unsigned long); -int walk_memory_regions(void *, walk_memory_regions_fn); - -int page_get_flags(target_ulong address); -void page_set_flags(target_ulong start, target_ulong end, int flags); -int page_check_range(target_ulong start, target_ulong len, int flags); -#endif - -CPUArchState *cpu_copy(CPUArchState *env); -CPUArchState *qemu_get_cpu(int cpu); - -#define CPU_DUMP_CODE 0x00010000 -#define CPU_DUMP_FPU 0x00020000 /* dump FPU register state, not just integer */ -/* dump info about TCG QEMU's condition code optimization state */ -#define CPU_DUMP_CCOP 0x00040000 - -void cpu_dump_state(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, - int flags); -void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, - int flags); - -void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...) - GCC_FMT_ATTR(2, 3); -extern CPUArchState *first_cpu; -DECLARE_TLS(CPUArchState *,cpu_single_env); -#define cpu_single_env tls_var(cpu_single_env) - -/* Flags for use in ENV->INTERRUPT_PENDING. - - The numbers assigned here are non-sequential in order to preserve - binary compatibility with the vmstate dump. Bit 0 (0x0001) was - previously used for CPU_INTERRUPT_EXIT, and is cleared when loading - the vmstate dump. */ - -/* External hardware interrupt pending. This is typically used for - interrupts from devices. */ -#define CPU_INTERRUPT_HARD 0x0002 - -/* Exit the current TB. This is typically used when some system-level device - makes some change to the memory mapping. E.g. the a20 line change. */ -#define CPU_INTERRUPT_EXITTB 0x0004 - -/* Halt the CPU. */ -#define CPU_INTERRUPT_HALT 0x0020 - -/* Debug event pending. */ -#define CPU_INTERRUPT_DEBUG 0x0080 - -/* Several target-specific external hardware interrupts. Each target/cpu.h - should define proper names based on these defines. */ -#define CPU_INTERRUPT_TGT_EXT_0 0x0008 -#define CPU_INTERRUPT_TGT_EXT_1 0x0010 -#define CPU_INTERRUPT_TGT_EXT_2 0x0040 -#define CPU_INTERRUPT_TGT_EXT_3 0x0200 -#define CPU_INTERRUPT_TGT_EXT_4 0x1000 - -/* Several target-specific internal interrupts. These differ from the - preceding target-specific interrupts in that they are intended to - originate from within the cpu itself, typically in response to some - instruction being executed. These, therefore, are not masked while - single-stepping within the debugger. */ -#define CPU_INTERRUPT_TGT_INT_0 0x0100 -#define CPU_INTERRUPT_TGT_INT_1 0x0400 -#define CPU_INTERRUPT_TGT_INT_2 0x0800 -#define CPU_INTERRUPT_TGT_INT_3 0x2000 - -/* First unused bit: 0x4000. */ - -/* The set of all bits that should be masked when single-stepping. */ -#define CPU_INTERRUPT_SSTEP_MASK \ - (CPU_INTERRUPT_HARD \ - | CPU_INTERRUPT_TGT_EXT_0 \ - | CPU_INTERRUPT_TGT_EXT_1 \ - | CPU_INTERRUPT_TGT_EXT_2 \ - | CPU_INTERRUPT_TGT_EXT_3 \ - | CPU_INTERRUPT_TGT_EXT_4) - -#ifndef CONFIG_USER_ONLY -typedef void (*CPUInterruptHandler)(CPUArchState *, int); - -extern CPUInterruptHandler cpu_interrupt_handler; - -static inline void cpu_interrupt(CPUArchState *s, int mask) -{ - cpu_interrupt_handler(s, mask); -} -#else /* USER_ONLY */ -void cpu_interrupt(CPUArchState *env, int mask); -#endif /* USER_ONLY */ - -void cpu_reset_interrupt(CPUArchState *env, int mask); - -void cpu_exit(CPUArchState *s); - -/* Breakpoint/watchpoint flags */ -#define BP_MEM_READ 0x01 -#define BP_MEM_WRITE 0x02 -#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE) -#define BP_STOP_BEFORE_ACCESS 0x04 -#define BP_WATCHPOINT_HIT 0x08 -#define BP_GDB 0x10 -#define BP_CPU 0x20 - -int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags, - CPUBreakpoint **breakpoint); -int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags); -void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint); -void cpu_breakpoint_remove_all(CPUArchState *env, int mask); -int cpu_watchpoint_insert(CPUArchState *env, target_ulong addr, target_ulong len, - int flags, CPUWatchpoint **watchpoint); -int cpu_watchpoint_remove(CPUArchState *env, target_ulong addr, - target_ulong len, int flags); -void cpu_watchpoint_remove_by_ref(CPUArchState *env, CPUWatchpoint *watchpoint); -void cpu_watchpoint_remove_all(CPUArchState *env, int mask); - -#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ -#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ -#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */ - -void cpu_single_step(CPUArchState *env, int enabled); - -#if !defined(CONFIG_USER_ONLY) - -/* Return the physical page corresponding to a virtual one. Use it - only for debugging because no protection checks are done. Return -1 - if no page found. */ -hwaddr cpu_get_phys_page_debug(CPUArchState *env, target_ulong addr); - -/* memory API */ - -extern int phys_ram_fd; -extern ram_addr_t ram_size; - -/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ -#define RAM_PREALLOC_MASK (1 << 0) - -typedef struct RAMBlock { - struct MemoryRegion *mr; - uint8_t *host; - ram_addr_t offset; - ram_addr_t length; - uint32_t flags; - char idstr[256]; - QLIST_ENTRY(RAMBlock) next; -#if defined(__linux__) && !defined(TARGET_S390X) - int fd; -#endif -} RAMBlock; - -typedef struct RAMList { - uint8_t *phys_dirty; - QLIST_HEAD(, RAMBlock) blocks; -} RAMList; -extern RAMList ram_list; - -extern const char *mem_path; -extern int mem_prealloc; - -/* Flags stored in the low bits of the TLB virtual address. These are - defined so that fast path ram access is all zeros. */ -/* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << 3) -/* Set if TLB entry references a clean RAM page. The iotlb entry will - contain the page physical address. */ -#define TLB_NOTDIRTY (1 << 4) -/* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << 5) - -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); -ram_addr_t last_ram_offset(void); -#endif /* !CONFIG_USER_ONLY */ - -int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, - uint8_t *buf, int len, int is_write); - -#endif /* CPU_ALL_H */ diff --git a/cpu-common.h b/cpu-common.h deleted file mode 100644 index d2fbafac9c..0000000000 --- a/cpu-common.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef CPU_COMMON_H -#define CPU_COMMON_H 1 - -/* CPU interfaces that are target independent. */ - -#include "hwaddr.h" - -#ifndef NEED_CPU_H -#include "poison.h" -#endif - -#include "bswap.h" -#include "qemu-queue.h" - -#if !defined(CONFIG_USER_ONLY) - -enum device_endian { - DEVICE_NATIVE_ENDIAN, - DEVICE_BIG_ENDIAN, - DEVICE_LITTLE_ENDIAN, -}; - -/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND) -typedef uint64_t ram_addr_t; -# define RAM_ADDR_MAX UINT64_MAX -# define RAM_ADDR_FMT "%" PRIx64 -#else -typedef uintptr_t ram_addr_t; -# define RAM_ADDR_MAX UINTPTR_MAX -# define RAM_ADDR_FMT "%" PRIxPTR -#endif - -/* memory API */ - -typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); -typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); - -void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); -/* This should only be used for ram local to a device. */ -void *qemu_get_ram_ptr(ram_addr_t addr); -void qemu_put_ram_ptr(void *addr); -/* This should not be used by devices. */ -int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); -ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); -void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev); - -void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, - int len, int is_write); -static inline void cpu_physical_memory_read(hwaddr addr, - void *buf, int len) -{ - cpu_physical_memory_rw(addr, buf, len, 0); -} -static inline void cpu_physical_memory_write(hwaddr addr, - const void *buf, int len) -{ - cpu_physical_memory_rw(addr, (void *)buf, len, 1); -} -void *cpu_physical_memory_map(hwaddr addr, - hwaddr *plen, - int is_write); -void cpu_physical_memory_unmap(void *buffer, hwaddr len, - int is_write, hwaddr access_len); -void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); - -bool cpu_physical_memory_is_io(hwaddr phys_addr); - -/* Coalesced MMIO regions are areas where write operations can be reordered. - * This usually implies that write operations are side-effect free. This allows - * batching which can make a major impact on performance when using - * virtualization. - */ -void qemu_flush_coalesced_mmio_buffer(void); - -uint32_t ldub_phys(hwaddr addr); -uint32_t lduw_le_phys(hwaddr addr); -uint32_t lduw_be_phys(hwaddr addr); -uint32_t ldl_le_phys(hwaddr addr); -uint32_t ldl_be_phys(hwaddr addr); -uint64_t ldq_le_phys(hwaddr addr); -uint64_t ldq_be_phys(hwaddr addr); -void stb_phys(hwaddr addr, uint32_t val); -void stw_le_phys(hwaddr addr, uint32_t val); -void stw_be_phys(hwaddr addr, uint32_t val); -void stl_le_phys(hwaddr addr, uint32_t val); -void stl_be_phys(hwaddr addr, uint32_t val); -void stq_le_phys(hwaddr addr, uint64_t val); -void stq_be_phys(hwaddr addr, uint64_t val); - -#ifdef NEED_CPU_H -uint32_t lduw_phys(hwaddr addr); -uint32_t ldl_phys(hwaddr addr); -uint64_t ldq_phys(hwaddr addr); -void stl_phys_notdirty(hwaddr addr, uint32_t val); -void stq_phys_notdirty(hwaddr addr, uint64_t val); -void stw_phys(hwaddr addr, uint32_t val); -void stl_phys(hwaddr addr, uint32_t val); -void stq_phys(hwaddr addr, uint64_t val); -#endif - -void cpu_physical_memory_write_rom(hwaddr addr, - const uint8_t *buf, int len); - -extern struct MemoryRegion io_mem_ram; -extern struct MemoryRegion io_mem_rom; -extern struct MemoryRegion io_mem_unassigned; -extern struct MemoryRegion io_mem_notdirty; - -#endif - -#endif /* !CPU_COMMON_H */ diff --git a/cpu-defs.h b/cpu-defs.h deleted file mode 100644 index 3669241faf..0000000000 --- a/cpu-defs.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * common defines for all CPUs - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPU_DEFS_H -#define CPU_DEFS_H - -#ifndef NEED_CPU_H -#error cpu.h included from common code -#endif - -#include "config.h" -#include -#include -#include -#include "osdep.h" -#include "qemu-queue.h" -#include "hwaddr.h" - -#ifndef TARGET_LONG_BITS -#error TARGET_LONG_BITS must be defined before including this header -#endif - -#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) - -typedef int16_t target_short __attribute__ ((aligned(TARGET_SHORT_ALIGNMENT))); -typedef uint16_t target_ushort __attribute__((aligned(TARGET_SHORT_ALIGNMENT))); -typedef int32_t target_int __attribute__((aligned(TARGET_INT_ALIGNMENT))); -typedef uint32_t target_uint __attribute__((aligned(TARGET_INT_ALIGNMENT))); -typedef int64_t target_llong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); -typedef uint64_t target_ullong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); -/* target_ulong is the type of a virtual address */ -#if TARGET_LONG_SIZE == 4 -typedef int32_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -typedef uint32_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -#define TARGET_FMT_lx "%08x" -#define TARGET_FMT_ld "%d" -#define TARGET_FMT_lu "%u" -#elif TARGET_LONG_SIZE == 8 -typedef int64_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -#define TARGET_FMT_lx "%016" PRIx64 -#define TARGET_FMT_ld "%" PRId64 -#define TARGET_FMT_lu "%" PRIu64 -#else -#error TARGET_LONG_SIZE undefined -#endif - -#define EXCP_INTERRUPT 0x10000 /* async interruption */ -#define EXCP_HLT 0x10001 /* hlt instruction reached */ -#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ -#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ - -#define TB_JMP_CACHE_BITS 12 -#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) - -/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for - addresses on the same page. The top bits are the same. This allows - TLB invalidation to quickly clear a subset of the hash table. */ -#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) -#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) -#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) -#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) - -#if !defined(CONFIG_USER_ONLY) -#define CPU_TLB_BITS 8 -#define CPU_TLB_SIZE (1 << CPU_TLB_BITS) - -#if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 -#define CPU_TLB_ENTRY_BITS 4 -#else -#define CPU_TLB_ENTRY_BITS 5 -#endif - -typedef struct CPUTLBEntry { - /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address - bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not - go directly to ram. - bit 3 : indicates that the entry is invalid - bit 2..0 : zero - */ - target_ulong addr_read; - target_ulong addr_write; - target_ulong addr_code; - /* Addend to virtual address to get host address. IO accesses - use the corresponding iotlb value. */ - uintptr_t addend; - /* padding to get a power of two size */ - uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - - (sizeof(target_ulong) * 3 + - ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + - sizeof(uintptr_t))]; -} CPUTLBEntry; - -extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1]; - -#define CPU_COMMON_TLB \ - /* The meaning of the MMU modes is defined in the target code. */ \ - CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ - hwaddr iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ - target_ulong tlb_flush_addr; \ - target_ulong tlb_flush_mask; - -#else - -#define CPU_COMMON_TLB - -#endif - - -#ifdef HOST_WORDS_BIGENDIAN -typedef struct icount_decr_u16 { - uint16_t high; - uint16_t low; -} icount_decr_u16; -#else -typedef struct icount_decr_u16 { - uint16_t low; - uint16_t high; -} icount_decr_u16; -#endif - -struct kvm_run; -struct KVMState; -struct qemu_work_item; - -typedef struct CPUBreakpoint { - target_ulong pc; - int flags; /* BP_* */ - QTAILQ_ENTRY(CPUBreakpoint) entry; -} CPUBreakpoint; - -typedef struct CPUWatchpoint { - target_ulong vaddr; - target_ulong len_mask; - int flags; /* BP_* */ - QTAILQ_ENTRY(CPUWatchpoint) entry; -} CPUWatchpoint; - -#define CPU_TEMP_BUF_NLONGS 128 -#define CPU_COMMON \ - struct TranslationBlock *current_tb; /* currently executing TB */ \ - /* soft mmu support */ \ - /* in order to avoid passing too many arguments to the MMIO \ - helpers, we store some rarely used information in the CPU \ - context) */ \ - uintptr_t mem_io_pc; /* host pc at which the memory was \ - accessed */ \ - target_ulong mem_io_vaddr; /* target virtual addr at which the \ - memory was accessed */ \ - uint32_t halted; /* Nonzero if the CPU is in suspend state */ \ - uint32_t interrupt_request; \ - volatile sig_atomic_t exit_request; \ - CPU_COMMON_TLB \ - struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ - /* buffer for temporaries in the code generator */ \ - long temp_buf[CPU_TEMP_BUF_NLONGS]; \ - \ - int64_t icount_extra; /* Instructions until next timer event. */ \ - /* Number of cycles left, with interrupt flag in high bit. \ - This allows a single read-compare-cbranch-write sequence to test \ - for both decrementer underflow and exceptions. */ \ - union { \ - uint32_t u32; \ - icount_decr_u16 u16; \ - } icount_decr; \ - uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \ - \ - /* from this point: preserved by CPU reset */ \ - /* ice debug support */ \ - QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ - int singlestep_enabled; \ - \ - QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ - CPUWatchpoint *watchpoint_hit; \ - \ - struct GDBRegisterState *gdb_regs; \ - \ - /* Core interrupt code */ \ - jmp_buf jmp_env; \ - int exception_index; \ - \ - CPUArchState *next_cpu; /* next CPU sharing TB cache */ \ - int cpu_index; /* CPU index (informative) */ \ - uint32_t host_tid; /* host thread ID */ \ - int numa_node; /* NUMA node this cpu is belonging to */ \ - int nr_cores; /* number of cores within this CPU package */ \ - int nr_threads;/* number of threads within this CPU */ \ - int running; /* Nonzero if cpu is currently running(usermode). */ \ - /* user data */ \ - void *opaque; \ - \ - const char *cpu_model_str; \ - struct KVMState *kvm_state; \ - struct kvm_run *kvm_run; \ - int kvm_fd; \ - int kvm_vcpu_dirty; - -#endif diff --git a/cpus.c b/cpus.c index d9c332fcb8..8926873ad1 100644 --- a/cpus.c +++ b/cpus.c @@ -27,7 +27,7 @@ #include "monitor.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "dma.h" #include "kvm.h" #include "qmp-commands.h" diff --git a/cputlb.c b/cputlb.c index d6d0372615..88239c494a 100644 --- a/cputlb.c +++ b/cputlb.c @@ -19,13 +19,13 @@ #include "config.h" #include "cpu.h" -#include "exec-all.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/exec-all.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" -#include "cputlb.h" +#include "exec/cputlb.h" -#include "memory-internal.h" +#include "exec/memory-internal.h" //#define DEBUG_TLB //#define DEBUG_TLB_CHECK @@ -347,15 +347,15 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) #define SOFTMMU_CODE_ACCESS #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #undef env diff --git a/cputlb.h b/cputlb.h deleted file mode 100644 index 733c885a1f..0000000000 --- a/cputlb.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Common CPU TLB handling - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPUTLB_H -#define CPUTLB_H - -#if !defined(CONFIG_USER_ONLY) -/* cputlb.c */ -void tlb_protect_code(ram_addr_t ram_addr); -void tlb_unprotect_code_phys(CPUArchState *env, ram_addr_t ram_addr, - target_ulong vaddr); -void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start, - uintptr_t length); -MemoryRegionSection *phys_page_find(struct AddressSpaceDispatch *d, - hwaddr index); -void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length); -void tlb_set_dirty(CPUArchState *env, target_ulong vaddr); -extern int tlb_flush_count; - -/* exec.c */ -void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr); -hwaddr memory_region_section_get_iotlb(CPUArchState *env, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, - int prot, - target_ulong *address); -bool memory_region_is_unassigned(MemoryRegion *mr); - -#endif -#endif diff --git a/def-helper.h b/def-helper.h deleted file mode 100644 index 022a9ceb6a..0000000000 --- a/def-helper.h +++ /dev/null @@ -1,275 +0,0 @@ -/* Helper file for declaring TCG helper functions. - Should be included at the start and end of target-foo/helper.h. - - Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper - functions. Names should be specified without the helper_ prefix, and - the return and argument types specified. 3 basic types are understood - (i32, i64 and ptr). Additional aliases are provided for convenience and - to match the types used by the C helper implementation. - - The target helper.h should be included in all files that use/define - helper functions. THis will ensure that function prototypes are - consistent. In addition it should be included an extra two times for - helper.c, defining: - GEN_HELPER 1 to produce op generation functions (gen_helper_*) - GEN_HELPER 2 to do runtime registration helper functions. - */ - -#ifndef DEF_HELPER_H -#define DEF_HELPER_H 1 - -#define HELPER(name) glue(helper_, name) - -#define GET_TCGV_i32 GET_TCGV_I32 -#define GET_TCGV_i64 GET_TCGV_I64 -#define GET_TCGV_ptr GET_TCGV_PTR - -/* Some types that make sense in C, but not for TCG. */ -#define dh_alias_i32 i32 -#define dh_alias_s32 i32 -#define dh_alias_int i32 -#define dh_alias_i64 i64 -#define dh_alias_s64 i64 -#define dh_alias_f32 i32 -#define dh_alias_f64 i64 -#if TARGET_LONG_BITS == 32 -#define dh_alias_tl i32 -#else -#define dh_alias_tl i64 -#endif -#define dh_alias_ptr ptr -#define dh_alias_void void -#define dh_alias_noreturn noreturn -#define dh_alias_env ptr -#define dh_alias(t) glue(dh_alias_, t) - -#define dh_ctype_i32 uint32_t -#define dh_ctype_s32 int32_t -#define dh_ctype_int int -#define dh_ctype_i64 uint64_t -#define dh_ctype_s64 int64_t -#define dh_ctype_f32 float32 -#define dh_ctype_f64 float64 -#define dh_ctype_tl target_ulong -#define dh_ctype_ptr void * -#define dh_ctype_void void -#define dh_ctype_noreturn void QEMU_NORETURN -#define dh_ctype_env CPUArchState * -#define dh_ctype(t) dh_ctype_##t - -/* We can't use glue() here because it falls foul of C preprocessor - recursive expansion rules. */ -#define dh_retvar_decl0_void void -#define dh_retvar_decl0_noreturn void -#define dh_retvar_decl0_i32 TCGv_i32 retval -#define dh_retvar_decl0_i64 TCGv_i64 retval -#define dh_retvar_decl0_ptr TCGv_ptr retval -#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t)) - -#define dh_retvar_decl_void -#define dh_retvar_decl_noreturn -#define dh_retvar_decl_i32 TCGv_i32 retval, -#define dh_retvar_decl_i64 TCGv_i64 retval, -#define dh_retvar_decl_ptr TCGv_ptr retval, -#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t)) - -#define dh_retvar_void TCG_CALL_DUMMY_ARG -#define dh_retvar_noreturn TCG_CALL_DUMMY_ARG -#define dh_retvar_i32 GET_TCGV_i32(retval) -#define dh_retvar_i64 GET_TCGV_i64(retval) -#define dh_retvar_ptr GET_TCGV_ptr(retval) -#define dh_retvar(t) glue(dh_retvar_, dh_alias(t)) - -#define dh_is_64bit_void 0 -#define dh_is_64bit_noreturn 0 -#define dh_is_64bit_i32 0 -#define dh_is_64bit_i64 1 -#define dh_is_64bit_ptr (TCG_TARGET_REG_BITS == 64) -#define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t)) - -#define dh_is_signed_void 0 -#define dh_is_signed_noreturn 0 -#define dh_is_signed_i32 0 -#define dh_is_signed_s32 1 -#define dh_is_signed_i64 0 -#define dh_is_signed_s64 1 -#define dh_is_signed_f32 0 -#define dh_is_signed_f64 0 -#define dh_is_signed_tl 0 -#define dh_is_signed_int 1 -/* ??? This is highly specific to the host cpu. There are even special - extension instructions that may be required, e.g. ia64's addp4. But - for now we don't support any 64-bit targets with 32-bit pointers. */ -#define dh_is_signed_ptr 0 -#define dh_is_signed_env dh_is_signed_ptr -#define dh_is_signed(t) dh_is_signed_##t - -#define dh_sizemask(t, n) \ - sizemask |= dh_is_64bit(t) << (n*2); \ - sizemask |= dh_is_signed(t) << (n*2+1) - -#define dh_arg(t, n) \ - args[n - 1] = glue(GET_TCGV_, dh_alias(t))(glue(arg, n)); \ - dh_sizemask(t, n) - -#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n) - - -#define DEF_HELPER_0(name, ret) \ - DEF_HELPER_FLAGS_0(name, 0, ret) -#define DEF_HELPER_1(name, ret, t1) \ - DEF_HELPER_FLAGS_1(name, 0, ret, t1) -#define DEF_HELPER_2(name, ret, t1, t2) \ - DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2) -#define DEF_HELPER_3(name, ret, t1, t2, t3) \ - DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3) -#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \ - DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4) -#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \ - DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5) - -/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ - -#endif /* DEF_HELPER_H */ - -#ifndef GEN_HELPER -/* Function prototypes. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -dh_ctype(ret) HELPER(name) (void); - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1)); - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2)); - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3)); - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ - dh_ctype(t4)); - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ - dh_ctype(t4), dh_ctype(t5)); - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == 1 -/* Gen functions. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ -{ \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 0, NULL); \ -} - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1)) \ -{ \ - TCGArg args[1]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \ -} - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2)) \ -{ \ - TCGArg args[2]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \ -} - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ -{ \ - TCGArg args[3]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 3, args); \ -} - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ -{ \ - TCGArg args[4]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - dh_arg(t4, 4); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 4, args); \ -} - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ - dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ - dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ -{ \ - TCGArg args[5]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - dh_arg(t4, 4); \ - dh_arg(t5, 5); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 5, args); \ -} - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == 2 -/* Register helpers. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -tcg_register_helper(HELPER(name), #name); - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == -1 -/* Undefine macros. */ - -#undef DEF_HELPER_FLAGS_0 -#undef DEF_HELPER_FLAGS_1 -#undef DEF_HELPER_FLAGS_2 -#undef DEF_HELPER_FLAGS_3 -#undef DEF_HELPER_FLAGS_4 -#undef DEF_HELPER_FLAGS_5 -#undef GEN_HELPER - -#endif diff --git a/dma.h b/dma.h index 40280365ce..fd68f74c5b 100644 --- a/dma.h +++ b/dma.h @@ -11,7 +11,7 @@ #define DMA_H #include -#include "memory.h" +#include "exec/memory.h" #include "hw/hw.h" #include "block/block.h" #include "kvm.h" diff --git a/dump.c b/dump.c index 7b45b53a8f..e70e0f3b21 100644 --- a/dump.c +++ b/dump.c @@ -14,8 +14,8 @@ #include "qemu-common.h" #include "elf.h" #include "cpu.h" -#include "cpu-all.h" -#include "hwaddr.h" +#include "exec/cpu-all.h" +#include "exec/hwaddr.h" #include "monitor.h" #include "kvm.h" #include "dump.h" @@ -23,7 +23,7 @@ #include "memory_mapping.h" #include "qapi/error.h" #include "qmp-commands.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" static uint16_t cpu_convert_to_target16(uint16_t val, int endian) { diff --git a/exec-all.h b/exec-all.h deleted file mode 100644 index e9b07cd986..0000000000 --- a/exec-all.h +++ /dev/null @@ -1,412 +0,0 @@ -/* - * internal execution defines for qemu - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef _EXEC_ALL_H_ -#define _EXEC_ALL_H_ - -#include "qemu-common.h" - -/* allow to see translation results - the slowdown should be negligible, so we leave it */ -#define DEBUG_DISAS - -/* Page tracking code uses ram addresses in system mode, and virtual - addresses in userspace mode. Define tb_page_addr_t to be an appropriate - type. */ -#if defined(CONFIG_USER_ONLY) -typedef abi_ulong tb_page_addr_t; -#else -typedef ram_addr_t tb_page_addr_t; -#endif - -/* is_jmp field values */ -#define DISAS_NEXT 0 /* next instruction can be analyzed */ -#define DISAS_JUMP 1 /* only pc was modified dynamically */ -#define DISAS_UPDATE 2 /* cpu state was modified dynamically */ -#define DISAS_TB_JUMP 3 /* only pc was modified statically */ - -struct TranslationBlock; -typedef struct TranslationBlock TranslationBlock; - -/* XXX: make safe guess about sizes */ -#define MAX_OP_PER_INSTR 208 - -#if HOST_LONG_BITS == 32 -#define MAX_OPC_PARAM_PER_ARG 2 -#else -#define MAX_OPC_PARAM_PER_ARG 1 -#endif -#define MAX_OPC_PARAM_IARGS 5 -#define MAX_OPC_PARAM_OARGS 1 -#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) - -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N = number of input arguments + output arguments). */ -#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) -#define OPC_BUF_SIZE 640 -#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) - -/* Maximum size a TCG op can expand to. This is complicated because a - single op may require several host instructions and register reloads. - For now take a wild guess at 192 bytes, which should allow at least - a couple of fixup instructions per argument. */ -#define TCG_MAX_OP_SIZE 192 - -#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) - -#include "qemu-log.h" - -void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); -void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); -void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, - int pc_pos); - -void cpu_gen_init(void); -int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb, - int *gen_code_size_ptr); -bool cpu_restore_state(CPUArchState *env, uintptr_t searched_pc); - -void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); -void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); -TranslationBlock *tb_gen_code(CPUArchState *env, - target_ulong pc, target_ulong cs_base, int flags, - int cflags); -void cpu_exec_init(CPUArchState *env); -void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1); -int page_unprotect(target_ulong address, uintptr_t pc, void *puc); -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access); -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access); -#if !defined(CONFIG_USER_ONLY) -/* cputlb.c */ -void tlb_flush_page(CPUArchState *env, target_ulong addr); -void tlb_flush(CPUArchState *env, int flush_global); -void tlb_set_page(CPUArchState *env, target_ulong vaddr, - hwaddr paddr, int prot, - int mmu_idx, target_ulong size); -void tb_invalidate_phys_addr(hwaddr addr); -#else -static inline void tlb_flush_page(CPUArchState *env, target_ulong addr) -{ -} - -static inline void tlb_flush(CPUArchState *env, int flush_global) -{ -} -#endif - -#define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ - -#define CODE_GEN_PHYS_HASH_BITS 15 -#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) - -/* estimated block size for TB allocation */ -/* XXX: use a per code average code fragment size and modulate it - according to the host CPU */ -#if defined(CONFIG_SOFTMMU) -#define CODE_GEN_AVG_BLOCK_SIZE 128 -#else -#define CODE_GEN_AVG_BLOCK_SIZE 64 -#endif - -#if defined(__arm__) || defined(_ARCH_PPC) \ - || defined(__x86_64__) || defined(__i386__) \ - || defined(__sparc__) \ - || defined(CONFIG_TCG_INTERPRETER) -#define USE_DIRECT_JUMP -#endif - -struct TranslationBlock { - target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ - target_ulong cs_base; /* CS base for this block */ - uint64_t flags; /* flags defining in which context the code was generated */ - uint16_t size; /* size of target code for this block (1 <= - size <= TARGET_PAGE_SIZE) */ - uint16_t cflags; /* compile flags */ -#define CF_COUNT_MASK 0x7fff -#define CF_LAST_IO 0x8000 /* Last insn may be an IO access. */ - - uint8_t *tc_ptr; /* pointer to the translated code */ - /* next matching tb for physical address. */ - struct TranslationBlock *phys_hash_next; - /* first and second physical page containing code. The lower bit - of the pointer tells the index in page_next[] */ - struct TranslationBlock *page_next[2]; - tb_page_addr_t page_addr[2]; - - /* the following data are used to directly call another TB from - the code of this one. */ - uint16_t tb_next_offset[2]; /* offset of original jump target */ -#ifdef USE_DIRECT_JUMP - uint16_t tb_jmp_offset[2]; /* offset of jump instruction */ -#else - uintptr_t tb_next[2]; /* address of jump generated code */ -#endif - /* list of TBs jumping to this one. This is a circular list using - the two least significant bits of the pointers to tell what is - the next pointer: 0 = jmp_next[0], 1 = jmp_next[1], 2 = - jmp_first */ - struct TranslationBlock *jmp_next[2]; - struct TranslationBlock *jmp_first; - uint32_t icount; -}; - -static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; -} - -static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) - | (tmp & TB_JMP_ADDR_MASK)); -} - -static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) -{ - return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); -} - -void tb_free(TranslationBlock *tb); -void tb_flush(CPUArchState *env); -void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); - -extern TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; - -#if defined(USE_DIRECT_JUMP) - -#if defined(CONFIG_TCG_INTERPRETER) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ - /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); - /* no need to flush icache explicitly */ -} -#elif defined(_ARCH_PPC) -void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); -#define tb_set_jmp_target1 ppc_tb_set_jmp_target -#elif defined(__i386__) || defined(__x86_64__) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ - /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); - /* no need to flush icache explicitly */ -} -#elif defined(__arm__) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ -#if !QEMU_GNUC_PREREQ(4, 1) - register unsigned long _beg __asm ("a1"); - register unsigned long _end __asm ("a2"); - register unsigned long _flg __asm ("a3"); -#endif - - /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */ - *(uint32_t *)jmp_addr = - (*(uint32_t *)jmp_addr & ~0xffffff) - | (((addr - (jmp_addr + 8)) >> 2) & 0xffffff); - -#if QEMU_GNUC_PREREQ(4, 1) - __builtin___clear_cache((char *) jmp_addr, (char *) jmp_addr + 4); -#else - /* flush icache */ - _beg = jmp_addr; - _end = jmp_addr + 4; - _flg = 0; - __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); -#endif -} -#elif defined(__sparc__) -void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); -#else -#error tb_set_jmp_target1 is missing -#endif - -static inline void tb_set_jmp_target(TranslationBlock *tb, - int n, uintptr_t addr) -{ - uint16_t offset = tb->tb_jmp_offset[n]; - tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr); -} - -#else - -/* set the jump target */ -static inline void tb_set_jmp_target(TranslationBlock *tb, - int n, uintptr_t addr) -{ - tb->tb_next[n] = addr; -} - -#endif - -static inline void tb_add_jump(TranslationBlock *tb, int n, - TranslationBlock *tb_next) -{ - /* NOTE: this test is only needed for thread safety */ - if (!tb->jmp_next[n]) { - /* patch the native jump address */ - tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); - - /* add in TB jmp circular list */ - tb->jmp_next[n] = tb_next->jmp_first; - tb_next->jmp_first = (TranslationBlock *)((uintptr_t)(tb) | (n)); - } -} - -#include "qemu-lock.h" - -extern spinlock_t tb_lock; - -extern int tb_invalidated_flag; - -/* The return address may point to the start of the next instruction. - Subtracting one gets us the call instruction itself. */ -#if defined(CONFIG_TCG_INTERPRETER) -/* Softmmu, Alpha, MIPS, SH4 and SPARC user mode emulations call GETPC(). - For all others, GETPC remains undefined (which makes TCI a little faster. */ -# if defined(CONFIG_SOFTMMU) || \ - defined(TARGET_ALPHA) || defined(TARGET_MIPS) || \ - defined(TARGET_SH4) || defined(TARGET_SPARC) -extern uintptr_t tci_tb_ptr; -# define GETPC() tci_tb_ptr -# endif -#elif defined(__s390__) && !defined(__s390x__) -# define GETPC() \ - (((uintptr_t)__builtin_return_address(0) & 0x7fffffffUL) - 1) -#elif defined(__arm__) -/* Thumb return addresses have the low bit set, so we need to subtract two. - This is still safe in ARM mode because instructions are 4 bytes. */ -# define GETPC() ((uintptr_t)__builtin_return_address(0) - 2) -#else -# define GETPC() ((uintptr_t)__builtin_return_address(0) - 1) -#endif - -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION) && defined(CONFIG_SOFTMMU) -/* qemu_ld/st optimization split code generation to fast and slow path, thus, - it needs special handling for an MMU helper which is called from the slow - path, to get the fast path's pc without any additional argument. - It uses a tricky solution which embeds the fast path pc into the slow path. - - Code flow in slow path: - (1) pre-process - (2) call MMU helper - (3) jump to (5) - (4) fast path information (implementation specific) - (5) post-process (e.g. stack adjust) - (6) jump to corresponding code of the next of fast path - */ -# if defined(__i386__) || defined(__x86_64__) -/* To avoid broken disassembling, long jmp is used for embedding fast path pc, - so that the destination is the next code of fast path, though this jmp is - never executed. - - call MMU helper - jmp POST_PROC (2byte) <- GETRA() - jmp NEXT_CODE (5byte) - POST_PROCESS ... <- GETRA() + 7 - */ -# define GETRA() ((uintptr_t)__builtin_return_address(0)) -# define GETPC_LDST() ((uintptr_t)(GETRA() + 7 + \ - *(int32_t *)((void *)GETRA() + 3) - 1)) -# elif defined (_ARCH_PPC) && !defined (_ARCH_PPC64) -# define GETRA() ((uintptr_t)__builtin_return_address(0)) -# define GETPC_LDST() ((uintptr_t) ((*(int32_t *)(GETRA() - 4)) - 1)) -# else -# error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!" -# endif -bool is_tcg_gen_code(uintptr_t pc_ptr); -# define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC()) -#else -# define GETPC_EXT() GETPC() -#endif - -#if !defined(CONFIG_USER_ONLY) - -struct MemoryRegion *iotlb_to_region(hwaddr index); -uint64_t io_mem_read(struct MemoryRegion *mr, hwaddr addr, - unsigned size); -void io_mem_write(struct MemoryRegion *mr, hwaddr addr, - uint64_t value, unsigned size); - -void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx, - uintptr_t retaddr); - -#include "softmmu_defs.h" - -#define ACCESS_TYPE (NB_MMU_MODES + 1) -#define MEMSUFFIX _code - -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" - -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#endif - -#if defined(CONFIG_USER_ONLY) -static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) -{ - return addr; -} -#else -/* cputlb.c */ -tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); -#endif - -typedef void (CPUDebugExcpHandler)(CPUArchState *env); - -void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); - -/* vl.c */ -extern int singlestep; - -/* cpu-exec.c */ -extern volatile sig_atomic_t exit_request; - -/* Deterministic execution requires that IO only be performed on the last - instruction of a TB so that interrupts take effect immediately. */ -static inline int can_do_io(CPUArchState *env) -{ - if (!use_icount) { - return 1; - } - /* If not executing code then assume we are ok. */ - if (!env->current_tb) { - return 1; - } - return env->can_do_io != 0; -} - -#endif diff --git a/exec-memory.h b/exec-memory.h deleted file mode 100644 index ac1d07dfe4..0000000000 --- a/exec-memory.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Internal memory management interfaces - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef EXEC_MEMORY_H -#define EXEC_MEMORY_H - -/* - * Internal interfaces between memory.c/exec.c/vl.c. Do not #include unless - * you're one of them. - */ - -#include "memory.h" - -#ifndef CONFIG_USER_ONLY - -/* Get the root memory region. This interface should only be used temporarily - * until a proper bus interface is available. - */ -MemoryRegion *get_system_memory(void); - -/* Get the root I/O port region. This interface should only be used - * temporarily until a proper bus interface is available. - */ -MemoryRegion *get_system_io(void); - -extern AddressSpace address_space_memory; -extern AddressSpace address_space_io; - -#endif - -#endif diff --git a/exec.c b/exec.c index 986084146c..17fc7cf854 100644 --- a/exec.c +++ b/exec.c @@ -34,9 +34,9 @@ #include "hw/xen.h" #include "qemu-timer.h" #include "qemu-config.h" -#include "memory.h" +#include "exec/memory.h" #include "dma.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) #include #else /* !CONFIG_USER_ONLY */ @@ -44,10 +44,10 @@ #include "trace.h" #endif -#include "cputlb.h" +#include "exec/cputlb.h" #include "translate-all.h" -#include "memory-internal.h" +#include "exec/memory-internal.h" //#define DEBUG_UNASSIGNED //#define DEBUG_SUBPAGE diff --git a/gdbstub.c b/gdbstub.c index d02ec75384..70ad79a748 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -32,7 +32,7 @@ #include "monitor.h" #include "qemu-char.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #endif #define MAX_PACKET_LENGTH 4096 diff --git a/gdbstub.h b/gdbstub.h deleted file mode 100644 index 668de66000..0000000000 --- a/gdbstub.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GDBSTUB_H -#define GDBSTUB_H - -#define DEFAULT_GDBSTUB_PORT "1234" - -/* GDB breakpoint/watchpoint types */ -#define GDB_BREAKPOINT_SW 0 -#define GDB_BREAKPOINT_HW 1 -#define GDB_WATCHPOINT_WRITE 2 -#define GDB_WATCHPOINT_READ 3 -#define GDB_WATCHPOINT_ACCESS 4 - -#ifdef NEED_CPU_H -typedef void (*gdb_syscall_complete_cb)(CPUArchState *env, - target_ulong ret, target_ulong err); - -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); -int use_gdb_syscalls(void); -void gdb_set_stop_cpu(CPUArchState *env); -void gdb_exit(CPUArchState *, int); -#ifdef CONFIG_USER_ONLY -int gdb_queuesig (void); -int gdb_handlesig (CPUArchState *, int); -void gdb_signalled(CPUArchState *, int); -void gdbserver_fork(CPUArchState *); -#endif -/* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); -void gdb_register_coprocessor(CPUArchState *env, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, - int num_regs, const char *xml, int g_pos); - -static inline int cpu_index(CPUArchState *env) -{ -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) - return env->host_tid; -#else - return env->cpu_index + 1; -#endif -} - -#endif - -#ifdef CONFIG_USER_ONLY -int gdbserver_start(int); -#else -int gdbserver_start(const char *port); -#endif - -/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ -extern const char *const xml_builtin[][2]; - -#endif diff --git a/gen-icount.h b/gen-icount.h deleted file mode 100644 index 1541f0b1e4..0000000000 --- a/gen-icount.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GEN_ICOUNT_H -#define GEN_ICOUNT_H 1 - -#include "qemu-timer.h" - -/* Helpers for instruction counting code generation. */ - -static TCGArg *icount_arg; -static int icount_label; - -static inline void gen_icount_start(void) -{ - TCGv_i32 count; - - if (!use_icount) - return; - - icount_label = gen_new_label(); - count = tcg_temp_local_new_i32(); - tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); - /* This is a horrid hack to allow fixing up the value later. */ - icount_arg = tcg_ctx.gen_opparam_ptr + 1; - tcg_gen_subi_i32(count, count, 0xdeadbeef); - - tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label); - tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); - tcg_temp_free_i32(count); -} - -static void gen_icount_end(TranslationBlock *tb, int num_insns) -{ - if (use_icount) { - *icount_arg = num_insns; - gen_set_label(icount_label); - tcg_gen_exit_tb((tcg_target_long)tb + 2); - } -} - -static inline void gen_io_start(void) -{ - TCGv_i32 tmp = tcg_const_i32(1); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); - tcg_temp_free_i32(tmp); -} - -static inline void gen_io_end(void) -{ - TCGv_i32 tmp = tcg_const_i32(0); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); - tcg_temp_free_i32(tmp); -} - -#endif diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 755fa050f7..92af3a554c 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -30,7 +30,7 @@ #include "sysemu.h" #include "acpi.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ich9.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 46f9843891..4f43f6e070 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -26,9 +26,9 @@ #include "acpi.h" #include "sysemu.h" #include "range.h" -#include "ioport.h" +#include "exec/ioport.h" #include "fw_cfg.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c index 9b16d96612..d61b2f483c 100644 --- a/hw/alpha_typhoon.c +++ b/hw/alpha_typhoon.c @@ -7,12 +7,12 @@ */ #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "hw.h" #include "devices.h" #include "sysemu.h" #include "alpha_sys.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost" diff --git a/hw/an5206.c b/hw/an5206.c index d887c0e7eb..dcfe34b3ae 100644 --- a/hw/an5206.c +++ b/hw/an5206.c @@ -11,7 +11,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define KERNEL_LOAD_ADDR 0x10000 #define AN5206_MBAR_ADDR 0x10000000 diff --git a/hw/apb_pci.c b/hw/apb_pci.c index fb7a07de37..144a7cc8d3 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -33,7 +33,7 @@ #include "pci/pci_bus.h" #include "apb_pci.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* debug APB */ //#define DEBUG_APB diff --git a/hw/apic_internal.h b/hw/apic_internal.h index 79e2de2243..fea95654ca 100644 --- a/hw/apic_internal.h +++ b/hw/apic_internal.h @@ -20,7 +20,7 @@ #ifndef QEMU_APIC_INTERNAL_H #define QEMU_APIC_INTERNAL_H -#include "memory.h" +#include "exec/memory.h" #include "sysbus.h" #include "qemu-timer.h" diff --git a/hw/apm.h b/hw/apm.h index 5431b6d7c8..9abb47f99f 100644 --- a/hw/apm.h +++ b/hw/apm.h @@ -4,7 +4,7 @@ #include #include "qemu-common.h" #include "hw.h" -#include "memory.h" +#include "exec/memory.h" typedef void (*apm_ctrl_changed_t)(uint32_t val, void *arg); diff --git a/hw/arm-misc.h b/hw/arm-misc.h index d129678b26..cba7553039 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -11,7 +11,7 @@ #ifndef ARM_MISC_H #define ARM_MISC_H 1 -#include "memory.h" +#include "exec/memory.h" #include "hw/irq.h" /* The CPU is also modeled as an interrupt controller. */ diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 4963678bf1..270c307717 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -13,7 +13,7 @@ #include "sysbus.h" #include "qemu-timer.h" #include "arm-misc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "arm_gic_internal.h" typedef struct { diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c index 50ddbc920d..e537aecc78 100644 --- a/hw/axis_dev88.c +++ b/hw/axis_dev88.c @@ -31,7 +31,7 @@ #include "elf.h" #include "cris-boot.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define D(x) #define DNAND(x) diff --git a/hw/bonito.c b/hw/bonito.c index a1fc38c784..78e264ccc0 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -45,7 +45,7 @@ #include "mips.h" #include "pci/pci_host.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_BONITO diff --git a/hw/collie.c b/hw/collie.c index 695982a99f..faf5ac9ac7 100644 --- a/hw/collie.c +++ b/hw/collie.c @@ -16,7 +16,7 @@ #include "arm-misc.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static struct arm_boot_info collie_binfo = { .loader_start = SA_SDCS0, diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c index 20f790b1a6..7878cc3e15 100644 --- a/hw/dummy_m68k.c +++ b/hw/dummy_m68k.c @@ -10,7 +10,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define KERNEL_LOAD_ADDR 0x10000 diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c index 49221abc1a..089267fcc1 100644 --- a/hw/etraxfs_dma.c +++ b/hw/etraxfs_dma.c @@ -24,7 +24,7 @@ #include #include #include "hw.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "qemu-common.h" #include "sysemu.h" diff --git a/hw/exynos4210.h b/hw/exynos4210.h index 777f0f5b2f..bb9a1dddc8 100644 --- a/hw/exynos4210.h +++ b/hw/exynos4210.h @@ -27,7 +27,7 @@ #define EXYNOS4210_H_ #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #define EXYNOS4210_NCPUS 2 diff --git a/hw/exynos4210_fimd.c b/hw/exynos4210_fimd.c index 3ef0847271..cfca72ab67 100644 --- a/hw/exynos4210_fimd.c +++ b/hw/exynos4210_fimd.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "sysbus.h" #include "ui/console.h" #include "ui/pixel_ops.h" diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c index c375f16479..5dd2961459 100644 --- a/hw/exynos4_boards.c +++ b/hw/exynos4_boards.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "net/net.h" #include "arm-misc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "exynos4210.h" #include "boards.h" diff --git a/hw/flash.h b/hw/flash.h index bda2158c13..920d7596e3 100644 --- a/hw/flash.h +++ b/hw/flash.h @@ -3,7 +3,7 @@ /* NOR flash devices */ -#include "memory.h" +#include "exec/memory.h" typedef struct pflash_t pflash_t; diff --git a/hw/framebuffer.h b/hw/framebuffer.h index 46e375b5ec..11f53edec0 100644 --- a/hw/framebuffer.h +++ b/hw/framebuffer.h @@ -1,7 +1,7 @@ #ifndef QEMU_FRAMEBUFFER_H #define QEMU_FRAMEBUFFER_H -#include "memory.h" +#include "exec/memory.h" /* Framebuffer device helper routines. */ diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c index 5aa49c6148..977a2c5e69 100644 --- a/hw/gt64xxx.c +++ b/hw/gt64xxx.c @@ -27,7 +27,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "pc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG diff --git a/hw/gumstix.c b/hw/gumstix.c index 545b92fd95..4acb32c2a9 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -41,7 +41,7 @@ #include "devices.h" #include "boards.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static const int sector_len = 128 * 1024; diff --git a/hw/highbank.c b/hw/highbank.c index 90f7cb5ef2..6f5f2a9d9d 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -26,7 +26,7 @@ #include "boards.h" #include "sysbus.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0x100 #define SMP_BOOT_REG 0x40 diff --git a/hw/hw.h b/hw/hw.h index 003d974866..7368470bb1 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -5,10 +5,10 @@ #include "qemu-common.h" #if !defined(CONFIG_USER_ONLY) && !defined(NEED_CPU_H) -#include "cpu-common.h" +#include "exec/cpu-common.h" #endif -#include "ioport.h" +#include "exec/ioport.h" #include "irq.h" #include "block/aio.h" #include "qemu-file.h" diff --git a/hw/ide.h b/hw/ide.h index 081c710d56..7e23cda8e0 100644 --- a/hw/ide.h +++ b/hw/ide.h @@ -3,7 +3,7 @@ #include "isa.h" #include "pci/pci.h" -#include "memory.h" +#include "exec/memory.h" #define MAX_IDE_DEVS 2 diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 2ea64bd316..f32a84761d 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -29,7 +29,7 @@ #include "monitor.h" #include "dma.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "internal.h" #include #include diff --git a/hw/ide/internal.h b/hw/ide/internal.h index bf7d313cf4..c5016f0cea 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -8,7 +8,7 @@ */ #include #include -#include "iorange.h" +#include "exec/iorange.h" #include "dma.h" #include "sysemu.h" #include "hw/block-common.h" diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 2b59fea9f1..c995dc724f 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -12,7 +12,7 @@ #include "boards.h" #include "arm-misc.h" #include "net/net.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" typedef struct { diff --git a/hw/ioapic_internal.h b/hw/ioapic_internal.h index e04c9f3c12..c8447d7f3b 100644 --- a/hw/ioapic_internal.h +++ b/hw/ioapic_internal.h @@ -23,7 +23,7 @@ #define QEMU_IOAPIC_INTERNAL_H #include "hw.h" -#include "memory.h" +#include "exec/memory.h" #include "sysbus.h" #define MAX_IOAPICS 1 diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 144a88e272..8f40974166 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -21,7 +21,7 @@ #include "sysbus.h" #include "sysemu.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static ISABus *isabus; hwaddr isa_mem_base = 0; diff --git a/hw/isa.h b/hw/isa.h index 9d719fa3c8..62e89d3bcd 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -3,8 +3,8 @@ /* ISA bus */ -#include "ioport.h" -#include "memory.h" +#include "exec/ioport.h" +#include "exec/memory.h" #include "qdev.h" #define ISA_NUM_IRQS 16 diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c index 14053960cb..487cf6a8fb 100644 --- a/hw/isa_mmio.c +++ b/hw/isa_mmio.c @@ -24,7 +24,7 @@ #include "hw.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static void isa_mmio_writeb (void *opaque, hwaddr addr, uint32_t val) diff --git a/hw/kzm.c b/hw/kzm.c index a27ecbba84..9f92d30928 100644 --- a/hw/kzm.c +++ b/hw/kzm.c @@ -14,7 +14,7 @@ */ #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw.h" #include "arm-misc.h" #include "devices.h" diff --git a/hw/leon3.c b/hw/leon3.c index ef83dffd85..e8d54e5d06 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -30,7 +30,7 @@ #include "loader.h" #include "elf.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "grlib.h" diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c index f59d3bfef8..81afdf675c 100644 --- a/hw/lm32_boards.c +++ b/hw/lm32_boards.c @@ -27,7 +27,7 @@ #include "elf.h" #include "lm32_hwsetup.h" #include "lm32.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { LM32CPU *cpu; diff --git a/hw/loader.c b/hw/loader.c index 52f0940778..03f0318d91 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -49,8 +49,8 @@ #include "uboot_image.h" #include "loader.h" #include "fw_cfg.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index 30505789f8..e225693721 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -43,7 +43,7 @@ #include "acpi_ich9.h" #include "pam.h" #include "pci/pci_bus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" static int ich9_lpc_sci_irq(ICH9LPCState *lpc); diff --git a/hw/m48t59.c b/hw/m48t59.c index 7da7e7c822..491d433ae7 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -27,7 +27,7 @@ #include "sysemu.h" #include "sysbus.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_NVRAM diff --git a/hw/mac_dbdma.h b/hw/mac_dbdma.h index e596837f46..691263eede 100644 --- a/hw/mac_dbdma.h +++ b/hw/mac_dbdma.h @@ -22,7 +22,7 @@ #ifndef HW_MAC_DBDMA_H #define HW_MAC_DBDMA_H 1 -#include "memory.h" +#include "exec/memory.h" typedef struct DBDMA_io DBDMA_io; diff --git a/hw/mainstone.c b/hw/mainstone.c index 58c8b0748e..80d6a9d54d 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -20,7 +20,7 @@ #include "flash.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Device addresses */ #define MST_FPGA_PHYS 0x08000000 diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 510d77047e..5edc931abd 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -10,7 +10,7 @@ #include "qemu-timer.h" #include "ptimer.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* General purpose timer module. */ typedef struct { diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 6326624111..997b34847c 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -14,7 +14,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SYS_FREQ 66000000 diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c index b5fb18f67f..2423f64bf6 100644 --- a/hw/mcf_fec.c +++ b/hw/mcf_fec.c @@ -10,7 +10,7 @@ #include "mcf.h" /* For crc32 */ #include -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_FEC 1 diff --git a/hw/mcf_intc.c b/hw/mcf_intc.c index 6ef6dac931..3bed3a2e4c 100644 --- a/hw/mcf_intc.c +++ b/hw/mcf_intc.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem; diff --git a/hw/mcf_uart.c b/hw/mcf_uart.c index d1655f8f2c..2eca2c6ae9 100644 --- a/hw/mcf_uart.c +++ b/hw/mcf_uart.c @@ -8,7 +8,7 @@ #include "hw.h" #include "mcf.h" #include "qemu-char.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem; diff --git a/hw/milkymist.c b/hw/milkymist.c index c26ea4aed2..588522260b 100644 --- a/hw/milkymist.c +++ b/hw/milkymist.c @@ -28,7 +28,7 @@ #include "blockdev.h" #include "milkymist-hw.h" #include "lm32.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "mmone-bios.bin" #define BIOS_OFFSET 0x00860000 diff --git a/hw/mips.h b/hw/mips.h index f7e9b7e2c1..291e85f6b9 100644 --- a/hw/mips.h +++ b/hw/mips.h @@ -2,7 +2,7 @@ #define HW_MIPS_H /* Definitions for mips board emulation. */ -#include "memory.h" +#include "exec/memory.h" /* gt64xxx.c */ PCIBus *gt64120_register(qemu_irq *pic); diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index b46f7fdcb1..34619b7e3e 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -42,7 +42,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define DEBUG_FULONG2E_INIT diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 8e5e8ef1af..0befc99210 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -41,7 +41,7 @@ #include "pcspk.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" enum jazz_model_e { diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 60f237987f..d65d1256fd 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -46,7 +46,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" /* SysBusDevice */ //#define DEBUG_BOARD_INIT diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 78317426a7..ac7dfa9b74 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -36,7 +36,7 @@ #include "loader.h" #include "elf.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static struct _loaderparams { int ram_size; diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index ec99d7d6a6..05494b9b40 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -25,7 +25,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define MAX_IDE_BUS 2 diff --git a/hw/musicpal.c b/hw/musicpal.c index d7672e92a5..436b3f7c37 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -23,7 +23,7 @@ #include "ui/console.h" #include "i2c.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ui/pixel_ops.h" #define MP_MISC_BASE 0x80002000 diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c index 99477a412a..c2c00c215f 100644 --- a/hw/ne2000-isa.c +++ b/hw/ne2000-isa.c @@ -27,7 +27,7 @@ #include "qdev.h" #include "net/net.h" #include "ne2000.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct ISANE2000State { ISADevice dev; diff --git a/hw/nseries.c b/hw/nseries.c index dcd3dc97d0..83adb97211 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -33,7 +33,7 @@ #include "loader.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Nokia N8x0 support */ struct n800_s { diff --git a/hw/omap.h b/hw/omap.h index 2b383ffc44..188cda8771 100644 --- a/hw/omap.h +++ b/hw/omap.h @@ -17,7 +17,7 @@ * with this program; if not, see . */ #ifndef hw_omap_h -#include "memory.h" +#include "exec/memory.h" # define hw_omap_h "omap.h" #include "hw/irq.h" diff --git a/hw/omap_gpmc.c b/hw/omap_gpmc.c index 1f7c5bc5f3..02ab0ab568 100644 --- a/hw/omap_gpmc.c +++ b/hw/omap_gpmc.c @@ -21,8 +21,8 @@ #include "hw.h" #include "flash.h" #include "omap.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" /* General-Purpose Memory Controller */ struct omap_gpmc_s { diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c index 918a6f6a04..ca6eb9ddeb 100644 --- a/hw/omap_sx1.c +++ b/hw/omap_sx1.c @@ -32,7 +32,7 @@ #include "arm-misc.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /*****************************************************************************/ /* Siemens SX1 Cellphone V1 */ diff --git a/hw/omap_uart.c b/hw/omap_uart.c index 92f27021bb..159b2d1cdd 100644 --- a/hw/omap_uart.c +++ b/hw/omap_uart.c @@ -21,7 +21,7 @@ #include "hw.h" #include "omap.h" #include "serial.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* UARTs */ struct omap_uart_s { diff --git a/hw/onenand.c b/hw/onenand.c index 1803e4c264..7d255c563f 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -23,8 +23,8 @@ #include "flash.h" #include "irq.h" #include "blockdev.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #include "qemu-error.h" diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c index a879fb0dd0..c12097e12b 100644 --- a/hw/openrisc_sim.c +++ b/hw/openrisc_sim.c @@ -24,7 +24,7 @@ #include "serial.h" #include "net/net.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" #include "sysbus.h" #include "qtest.h" diff --git a/hw/palm.c b/hw/palm.c index 5aaeb07460..e091bbcfc1 100644 --- a/hw/palm.c +++ b/hw/palm.c @@ -25,7 +25,7 @@ #include "arm-misc.h" #include "devices.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static uint32_t static_readb(void *opaque, hwaddr offset) { diff --git a/hw/pam.h b/hw/pam.h index 2d77ebe0d9..8e9e349b1d 100644 --- a/hw/pam.h +++ b/hw/pam.h @@ -51,7 +51,7 @@ */ #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #define SMRAM_C_BASE 0xa0000 #define SMRAM_C_END 0xc0000 diff --git a/hw/pc.c b/hw/pc.c index d1b102c879..2452fd4214 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -47,8 +47,8 @@ #include "blockdev.h" #include "hw/block-common.h" #include "ui/qemu-spice.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "arch_init.h" #include "bitmap.h" diff --git a/hw/pc.h b/hw/pc.h index 5e4d103813..a73e3e7b5b 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -2,12 +2,12 @@ #define HW_PC_H #include "qemu-common.h" -#include "memory.h" -#include "ioport.h" +#include "exec/memory.h" +#include "exec/ioport.h" #include "isa.h" #include "fdc.h" #include "net/net.h" -#include "memory.h" +#include "exec/memory.h" #include "ioapic.h" /* PC-style peripherals (also used by other machines). */ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 7268dcd944..0d011348f2 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -41,8 +41,8 @@ #include "blockdev.h" #include "smbus.h" #include "xen.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "cpu.h" #ifdef CONFIG_XEN # include diff --git a/hw/pc_q35.c b/hw/pc_q35.c index 3429a9ae8f..2580d5ff34 100644 --- a/hw/pc_q35.c +++ b/hw/pc_q35.c @@ -36,7 +36,7 @@ #include "kvm.h" #include "kvm/clock.h" #include "q35.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ich9.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 105fe9560e..fa0f08eb0a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -33,7 +33,7 @@ #include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_PCI #ifdef DEBUG_PCI diff --git a/hw/pci/pci.h b/hw/pci/pci.h index 41e5ddd1c4..d6ef4f6574 100644 --- a/hw/pci/pci.h +++ b/hw/pci/pci.h @@ -4,7 +4,7 @@ #include "qemu-common.h" #include "hw/qdev.h" -#include "memory.h" +#include "exec/memory.h" #include "dma.h" /* PCI includes legacy ISA access. */ diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c index ab8d251de6..b2d942bce1 100644 --- a/hw/pci/pcie_host.c +++ b/hw/pci/pcie_host.c @@ -22,7 +22,7 @@ #include "hw/hw.h" #include "hw/pci/pci.h" #include "hw/pci/pcie_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* * PCI express mmcfig address diff --git a/hw/pci/pcie_host.h b/hw/pci/pcie_host.h index 150bef9736..1228e36cb2 100644 --- a/hw/pci/pcie_host.h +++ b/hw/pci/pcie_host.h @@ -22,7 +22,7 @@ #define PCIE_HOST_H #include "hw/pci/pci_host.h" -#include "memory.h" +#include "exec/memory.h" #define TYPE_PCIE_HOST_BRIDGE "pcie-host-bridge" #define PCIE_HOST_BRIDGE(obj) \ diff --git a/hw/pci/shpc.h b/hw/pci/shpc.h index 130b71df30..6374e68bdb 100644 --- a/hw/pci/shpc.h +++ b/hw/pci/shpc.h @@ -2,7 +2,7 @@ #define SHPC_H #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #include "vmstate.h" struct SHPCDevice { diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c index dbb4b3b433..7818dcc350 100644 --- a/hw/pci_bridge_dev.c +++ b/hw/pci_bridge_dev.c @@ -24,7 +24,7 @@ #include "pci/msi.h" #include "pci/shpc.h" #include "pci/slotid_cap.h" -#include "memory.h" +#include "exec/memory.h" #include "pci/pci_bus.h" #define REDHAT_PCI_VENDOR_ID 0x1b36 diff --git a/hw/pcnet.h b/hw/pcnet.h index 96643117a0..9dee6f3e2c 100644 --- a/hw/pcnet.h +++ b/hw/pcnet.h @@ -7,7 +7,7 @@ #define PCNET_LOOPTEST_CRC 1 #define PCNET_LOOPTEST_NOCRC 2 -#include "memory.h" +#include "exec/memory.h" /* BUS CONFIGURATION REGISTERS */ #define BCR_MSRDA 0 diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c index df51a74450..4eab0f2d8b 100644 --- a/hw/petalogix_ml605_mmu.c +++ b/hw/petalogix_ml605_mmu.c @@ -35,7 +35,7 @@ #include "xilinx.h" #include "blockdev.h" #include "serial.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ssi.h" #include "microblaze_boot.h" diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c index 37b0d5595a..124a88eeda 100644 --- a/hw/petalogix_s3adsp1800_mmu.c +++ b/hw/petalogix_s3adsp1800_mmu.c @@ -32,7 +32,7 @@ #include "boards.h" #include "xilinx.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "microblaze_boot.h" #include "microblaze_pic_cpu.h" diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index a2f6360838..36af4647df 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -40,7 +40,7 @@ #include "flash.h" #include "block/block.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "sysbus.h" diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index beab67fc87..c689cc9f42 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -39,7 +39,7 @@ #include "flash.h" #include "qemu-timer.h" #include "block/block.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "sysbus.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 4690bd8b00..798e67cedf 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -33,7 +33,7 @@ #include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "hw/ppce500_pci.h" diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index b875e3b615..5a0e0260e6 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -32,7 +32,7 @@ #include "qemu-log.h" #include "loader.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "ppc405_rom.bin" #define BIOS_SIZE (2048 * 1024) diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index 0f458ef772..aabb2efb48 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -28,7 +28,7 @@ #include "qemu-timer.h" #include "sysemu.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define DEBUG_OPBA #define DEBUG_SDRAM diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 5193a0c4be..591d7b0088 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -22,7 +22,7 @@ #include "device_tree.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "serial.h" #include "ppc.h" #include "ppc405.h" diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c index bac8d8769a..3b9dc06716 100644 --- a/hw/ppc4xx_devs.c +++ b/hw/ppc4xx_devs.c @@ -25,7 +25,7 @@ #include "ppc.h" #include "ppc4xx.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_MMIO //#define DEBUG_UNASSIGNED diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c index 3e8af11f08..ba2d669b83 100644 --- a/hw/ppc4xx_pci.c +++ b/hw/ppc4xx_pci.c @@ -24,7 +24,7 @@ #include "ppc4xx.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #undef DEBUG #ifdef DEBUG diff --git a/hw/ppc_mac.h b/hw/ppc_mac.h index 524b2368a4..89c7d66386 100644 --- a/hw/ppc_mac.h +++ b/hw/ppc_mac.h @@ -25,7 +25,7 @@ #if !defined(__PPC_MAC_H__) #define __PPC_MAC_H__ -#include "memory.h" +#include "exec/memory.h" /* SMP is not enabled, for now */ #define MAX_CPUS 1 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 657f405f1b..b2d02eaff2 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -66,7 +66,7 @@ #include "kvm_ppc.h" #include "hw/usb.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #define MAX_IDE_BUS 2 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index a149306cc9..7a8a039d7e 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -42,7 +42,7 @@ #include "kvm.h" #include "kvm_ppc.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define MAX_IDE_BUS 2 #define CFG_ADDR 0xf0000510 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 25cc0490f9..aa46cc6f55 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -39,7 +39,7 @@ #include "mc146818rtc.h" #include "blockdev.h" #include "arch_init.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define HARD_DEBUG_PPC_IO //#define DEBUG_PPC_IO diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 9bffbb9f87..feefc6596b 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -317,7 +317,7 @@ static const VMStateDescription vmstate_ppce500_pci = { } }; -#include "exec-memory.h" +#include "exec/address-spaces.h" static int e500_pcihost_bridge_initfn(PCIDevice *d) { diff --git a/hw/prep_pci.c b/hw/prep_pci.c index 5f22de647a..212a2ac4f1 100644 --- a/hw/prep_pci.c +++ b/hw/prep_pci.c @@ -26,7 +26,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "pc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost" diff --git a/hw/puv3.c b/hw/puv3.c index 9f8e294ad5..7814bc5051 100644 --- a/hw/puv3.c +++ b/hw/puv3.c @@ -12,7 +12,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #include "boards.h" #include "loader.h" diff --git a/hw/pxa.h b/hw/pxa.h index 49ac820ea2..c2577d1d94 100644 --- a/hw/pxa.h +++ b/hw/pxa.h @@ -9,7 +9,7 @@ #ifndef PXA_H # define PXA_H "pxa.h" -#include "memory.h" +#include "exec/memory.h" /* Interrupt numbers */ # define PXA2XX_PIC_SSP3 0 diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c index 552ee21f82..3bfe101d79 100644 --- a/hw/qdev-addr.c +++ b/hw/qdev-addr.c @@ -1,6 +1,6 @@ #include "qdev.h" #include "qdev-addr.h" -#include "hwaddr.h" +#include "exec/hwaddr.h" #include "qapi/visitor.h" /* --- target physical address --- */ diff --git a/hw/r2d.c b/hw/r2d.c index b1c278f73f..d7a26bf398 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -37,7 +37,7 @@ #include "usb.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define FLASH_BASE 0x00000000 #define FLASH_SIZE 0x02000000 diff --git a/hw/realview.c b/hw/realview.c index 17d1ba2266..9c55bf29b7 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -17,7 +17,7 @@ #include "boards.h" #include "i2c.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0xe0000000 #define SMP_BOOTREG_ADDR 0x10000030 diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index b732bccef8..0a15625b73 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -29,7 +29,7 @@ #include "hw/virtio.h" #include "hw/sysbus.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/s390-virtio-bus.h" #include "hw/s390x/sclp.h" diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 5c274fa03d..bc9b0aeb00 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -14,7 +14,7 @@ #include "cpu.h" #include "kvm.h" -#include "memory.h" +#include "exec/memory.h" #include "sclp.h" diff --git a/hw/serial.c b/hw/serial.c index 07a2a11931..3968c4fc46 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -26,7 +26,7 @@ #include "serial.h" #include "qemu-char.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/serial.h b/hw/serial.h index 2d7d614e09..5722f8a353 100644 --- a/hw/serial.h +++ b/hw/serial.h @@ -27,7 +27,7 @@ #include "hw.h" #include "sysemu.h" -#include "memory.h" +#include "exec/memory.h" #define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */ diff --git a/hw/sh7750.c b/hw/sh7750.c index 8bcf0df96f..08945750c4 100644 --- a/hw/sh7750.c +++ b/hw/sh7750.c @@ -30,7 +30,7 @@ #include "sh7750_regnames.h" #include "sh_intc.h" #include "cpu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define NB_DEVICES 4 diff --git a/hw/sh_intc.h b/hw/sh_intc.h index 80c9430577..6f11beeddd 100644 --- a/hw/sh_intc.h +++ b/hw/sh_intc.h @@ -3,7 +3,7 @@ #include "qemu-common.h" #include "irq.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef unsigned char intc_enum; diff --git a/hw/sh_pci.c b/hw/sh_pci.c index 9ea08c8f8e..d5218420a3 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -26,7 +26,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "bswap.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct SHPCIState { SysBusDevice busdev; diff --git a/hw/sh_serial.c b/hw/sh_serial.c index 9da5d08fee..63723496f1 100644 --- a/hw/sh_serial.c +++ b/hw/sh_serial.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sh.h" #include "qemu-char.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/sh_timer.c b/hw/sh_timer.c index c0365b1142..da6689f369 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -11,7 +11,7 @@ #include "hw.h" #include "sh.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ptimer.h" //#define DEBUG_TIMER diff --git a/hw/shix.c b/hw/shix.c index b56dd54f75..821196e84c 100644 --- a/hw/shix.c +++ b/hw/shix.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "boards.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "shix_bios.bin" #define BIOS_ADDRESS 0xA0000000 diff --git a/hw/soc_dma.h b/hw/soc_dma.h index 6ca4166184..7379731afd 100644 --- a/hw/soc_dma.h +++ b/hw/soc_dma.h @@ -22,7 +22,7 @@ #define HW_SOC_DMA_H 1 -#include "memory.h" +#include "exec/memory.h" #include "hw/irq.h" struct soc_dma_s; diff --git a/hw/spapr.c b/hw/spapr.c index 395c4ac69b..d1252fc68c 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -47,7 +47,7 @@ #include "kvm_ppc.h" #include "pci/pci.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/usb.h" #include "qemu-config.h" diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c index 3011b251d3..fb968b250b 100644 --- a/hw/spapr_iommu.c +++ b/hw/spapr_iommu.c @@ -21,7 +21,7 @@ #include "qdev.h" #include "kvm_ppc.h" #include "dma.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/spapr.h" diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c index 786f6f4222..27b3ad3d60 100644 --- a/hw/spapr_pci.c +++ b/hw/spapr_pci.c @@ -29,7 +29,7 @@ #include "pci/pci_host.h" #include "hw/spapr.h" #include "hw/spapr_pci.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include #include "trace.h" diff --git a/hw/spitz.c b/hw/spitz.c index 1500161d44..48668a0f10 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -27,7 +27,7 @@ #include "boards.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #undef REG_FMT #define REG_FMT "0x%02lx" diff --git a/hw/stellaris.c b/hw/stellaris.c index f3eb4bbc01..368f8a5e73 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -15,7 +15,7 @@ #include "i2c.h" #include "net/net.h" #include "boards.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define GPIO_A 0 #define GPIO_B 1 diff --git a/hw/strongarm.h b/hw/strongarm.h index d30dd6ac5e..2893f94445 100644 --- a/hw/strongarm.h +++ b/hw/strongarm.h @@ -1,7 +1,7 @@ #ifndef _STRONGARM_H #define _STRONGARM_H -#include "memory.h" +#include "exec/memory.h" #define SA_CS0 0x00000000 #define SA_CS1 0x08000000 diff --git a/hw/sun4u.c b/hw/sun4u.c index d9e752fe83..000f6118e1 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -39,7 +39,7 @@ #include "loader.h" #include "elf.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_IRQ //#define DEBUG_EBUS diff --git a/hw/sysbus.c b/hw/sysbus.c index ef8ffb6603..7ab250463c 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -19,7 +19,7 @@ #include "sysbus.h" #include "monitor.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); static char *sysbus_get_fw_dev_path(DeviceState *dev); diff --git a/hw/sysbus.h b/hw/sysbus.h index e58baaae36..669cf87ae9 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -4,7 +4,7 @@ /* Devices attached directly to the main system bus. */ #include "qdev.h" -#include "memory.h" +#include "exec/memory.h" #define QDEV_MAX_MMIO 32 #define QDEV_MAX_PIO 32 diff --git a/hw/tosa.c b/hw/tosa.c index 3991a909b5..6fdbec53ee 100644 --- a/hw/tosa.c +++ b/hw/tosa.c @@ -23,7 +23,7 @@ #include "ssi.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TOSA_RAM 0x04000000 #define TOSA_ROM 0x00800000 diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index 24d3cad3a2..672d7a5598 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -20,7 +20,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "hw/usb.h" #include "dma.h" diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index 7a543b47d0..1f4d66934c 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -10,7 +10,7 @@ #include "sysbus.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { SysBusDevice busdev; diff --git a/hw/versatilepb.c b/hw/versatilepb.c index af398d9cca..bd9c01564a 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -16,7 +16,7 @@ #include "i2c.h" #include "boards.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "flash.h" #define VERSATILE_FLASH_ADDR 0x34000000 diff --git a/hw/vexpress.c b/hw/vexpress.c index 5c9c08b991..e7b9e93852 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -28,7 +28,7 @@ #include "net/net.h" #include "sysemu.h" #include "boards.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "blockdev.h" #include "flash.h" diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 264e58a68b..096621cdbd 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -28,9 +28,9 @@ #include "config.h" #include "event_notifier.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "kvm.h" -#include "memory.h" +#include "exec/memory.h" #include "pci/msi.h" #include "pci/msix.h" #include "pci/pci.h" diff --git a/hw/vga_int.h b/hw/vga_int.h index 5efaee81d9..8d496ea9bf 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -26,7 +26,7 @@ #include #include "qapi/error.h" -#include "memory.h" +#include "exec/memory.h" #define ST01_V_RETRACE 0x08 #define ST01_DISP_ENABLE 0x01 diff --git a/hw/vhost.c b/hw/vhost.c index 16322a14f4..feaff64c15 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -18,7 +18,7 @@ #include "hw/hw.h" #include "range.h" #include -#include "exec-memory.h" +#include "exec/address-spaces.h" static void vhost_dev_sync_region(struct vhost_dev *dev, MemoryRegionSection *section, diff --git a/hw/vhost.h b/hw/vhost.h index 0c47229f91..6f6a906f4f 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -3,7 +3,7 @@ #include "hw/hw.h" #include "hw/virtio.h" -#include "memory.h" +#include "exec/memory.h" /* Generic structures common for any vhost based device. */ struct vhost_virtqueue { diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 1fdbc497cc..0f27c2b414 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -33,7 +33,7 @@ #include "loader.h" #include "elf.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ppc.h" #include "ppc4xx.h" diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index dd1a6506cf..97d3a932d9 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -21,7 +21,7 @@ #include "balloon.h" #include "virtio-balloon.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #if defined(__linux__) #include diff --git a/hw/vt82c686.c b/hw/vt82c686.c index f963912112..edceb5a01d 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -24,7 +24,7 @@ #include "pm_smbus.h" #include "sysemu.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef uint32_t pci_addr_t; #include "pci/pci_host.h" diff --git a/hw/xen_platform.c b/hw/xen_platform.c index 023499eb55..e7611bb353 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -32,7 +32,7 @@ #include "xen_common.h" #include "xen_backend.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include diff --git a/hw/xen_pt.c b/hw/xen_pt.c index c782cdb283..5c50d562d9 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -59,7 +59,7 @@ #include "xen_backend.h" #include "xen_pt.h" #include "range.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define XEN_PT_NR_IRQS (256) static uint8_t xen_pt_mapped_machine_irq[XEN_PT_NR_IRQS] = {0}; diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c index 67adc52725..156648a5d1 100644 --- a/hw/xilinx_zynq.c +++ b/hw/xilinx_zynq.c @@ -18,7 +18,7 @@ #include "sysbus.h" #include "arm-misc.h" #include "net/net.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" #include "boards.h" #include "flash.h" diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index 0399de777e..c6c880eba5 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -29,8 +29,8 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "serial.h" #include "net/net.h" #include "sysbus.h" diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c index 0d633e4724..29b5f22a18 100644 --- a/hw/xtensa_sim.c +++ b/hw/xtensa_sim.c @@ -29,8 +29,8 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" static uint64_t translate_phys_addr(void *env, uint64_t addr) { diff --git a/hw/z2.c b/hw/z2.c index d46186430f..ec35f3e444 100644 --- a/hw/z2.c +++ b/hw/z2.c @@ -23,7 +23,7 @@ #include "blockdev.h" #include "ui/console.h" #include "audio/audio.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #ifdef DEBUG_Z2 #define DPRINTF(fmt, ...) \ diff --git a/hwaddr.h b/hwaddr.h deleted file mode 100644 index 251cf9216f..0000000000 --- a/hwaddr.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Define hwaddr if it exists. */ - -#ifndef HWADDR_H -#define HWADDR_H - -#ifndef CONFIG_USER_ONLY - -#define HWADDR_BITS 64 -/* hwaddr is the type of a physical address (its size can - be different from 'target_ulong'). */ - -typedef uint64_t hwaddr; -#define HWADDR_MAX UINT64_MAX -#define TARGET_FMT_plx "%016" PRIx64 -#define HWADDR_PRId PRId64 -#define HWADDR_PRIi PRIi64 -#define HWADDR_PRIo PRIo64 -#define HWADDR_PRIu PRIu64 -#define HWADDR_PRIx PRIx64 -#define HWADDR_PRIX PRIX64 - -#endif - -#endif diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h new file mode 100644 index 0000000000..3d12cddeec --- /dev/null +++ b/include/exec/address-spaces.h @@ -0,0 +1,41 @@ +/* + * Internal memory management interfaces + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef EXEC_MEMORY_H +#define EXEC_MEMORY_H + +/* + * Internal interfaces between memory.c/exec.c/vl.c. Do not #include unless + * you're one of them. + */ + +#include "exec/memory.h" + +#ifndef CONFIG_USER_ONLY + +/* Get the root memory region. This interface should only be used temporarily + * until a proper bus interface is available. + */ +MemoryRegion *get_system_memory(void); + +/* Get the root I/O port region. This interface should only be used + * temporarily until a proper bus interface is available. + */ +MemoryRegion *get_system_io(void); + +extern AddressSpace address_space_memory; +extern AddressSpace address_space_io; + +#endif + +#endif diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h new file mode 100644 index 0000000000..bec04e2008 --- /dev/null +++ b/include/exec/cpu-all.h @@ -0,0 +1,522 @@ +/* + * defines common to all virtual CPUs + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPU_ALL_H +#define CPU_ALL_H + +#include "qemu-common.h" +#include "qemu-tls.h" +#include "exec/cpu-common.h" + +/* some important defines: + * + * WORDS_ALIGNED : if defined, the host cpu can only make word aligned + * memory accesses. + * + * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and + * otherwise little endian. + * + * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet)) + * + * TARGET_WORDS_BIGENDIAN : same for target cpu + */ + +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) +#define BSWAP_NEEDED +#endif + +#ifdef BSWAP_NEEDED + +static inline uint16_t tswap16(uint16_t s) +{ + return bswap16(s); +} + +static inline uint32_t tswap32(uint32_t s) +{ + return bswap32(s); +} + +static inline uint64_t tswap64(uint64_t s) +{ + return bswap64(s); +} + +static inline void tswap16s(uint16_t *s) +{ + *s = bswap16(*s); +} + +static inline void tswap32s(uint32_t *s) +{ + *s = bswap32(*s); +} + +static inline void tswap64s(uint64_t *s) +{ + *s = bswap64(*s); +} + +#else + +static inline uint16_t tswap16(uint16_t s) +{ + return s; +} + +static inline uint32_t tswap32(uint32_t s) +{ + return s; +} + +static inline uint64_t tswap64(uint64_t s) +{ + return s; +} + +static inline void tswap16s(uint16_t *s) +{ +} + +static inline void tswap32s(uint32_t *s) +{ +} + +static inline void tswap64s(uint64_t *s) +{ +} + +#endif + +#if TARGET_LONG_SIZE == 4 +#define tswapl(s) tswap32(s) +#define tswapls(s) tswap32s((uint32_t *)(s)) +#define bswaptls(s) bswap32s(s) +#else +#define tswapl(s) tswap64(s) +#define tswapls(s) tswap64s((uint64_t *)(s)) +#define bswaptls(s) bswap64s(s) +#endif + +/* CPU memory access without any memory or io remapping */ + +/* + * the generic syntax for the memory accesses is: + * + * load: ld{type}{sign}{size}{endian}_{access_type}(ptr) + * + * store: st{type}{size}{endian}_{access_type}(ptr, val) + * + * type is: + * (empty): integer access + * f : float access + * + * sign is: + * (empty): for floats or 32 bit size + * u : unsigned + * s : signed + * + * size is: + * b: 8 bits + * w: 16 bits + * l: 32 bits + * q: 64 bits + * + * endian is: + * (empty): target cpu endianness or 8 bit access + * r : reversed target cpu endianness (not implemented yet) + * be : big endian (not implemented yet) + * le : little endian (not implemented yet) + * + * access_type is: + * raw : host memory access + * user : user mode access using soft MMU + * kernel : kernel mode access using soft MMU + */ + +/* target-endianness CPU memory access functions */ +#if defined(TARGET_WORDS_BIGENDIAN) +#define lduw_p(p) lduw_be_p(p) +#define ldsw_p(p) ldsw_be_p(p) +#define ldl_p(p) ldl_be_p(p) +#define ldq_p(p) ldq_be_p(p) +#define ldfl_p(p) ldfl_be_p(p) +#define ldfq_p(p) ldfq_be_p(p) +#define stw_p(p, v) stw_be_p(p, v) +#define stl_p(p, v) stl_be_p(p, v) +#define stq_p(p, v) stq_be_p(p, v) +#define stfl_p(p, v) stfl_be_p(p, v) +#define stfq_p(p, v) stfq_be_p(p, v) +#else +#define lduw_p(p) lduw_le_p(p) +#define ldsw_p(p) ldsw_le_p(p) +#define ldl_p(p) ldl_le_p(p) +#define ldq_p(p) ldq_le_p(p) +#define ldfl_p(p) ldfl_le_p(p) +#define ldfq_p(p) ldfq_le_p(p) +#define stw_p(p, v) stw_le_p(p, v) +#define stl_p(p, v) stl_le_p(p, v) +#define stq_p(p, v) stq_le_p(p, v) +#define stfl_p(p, v) stfl_le_p(p, v) +#define stfq_p(p, v) stfq_le_p(p, v) +#endif + +/* MMU memory access macros */ + +#if defined(CONFIG_USER_ONLY) +#include +#include "exec/user/abitypes.h" + +/* On some host systems the guest address space is reserved on the host. + * This allows the guest address space to be offset to a convenient location. + */ +#if defined(CONFIG_USE_GUEST_BASE) +extern unsigned long guest_base; +extern int have_guest_base; +extern unsigned long reserved_va; +#define GUEST_BASE guest_base +#define RESERVED_VA reserved_va +#else +#define GUEST_BASE 0ul +#define RESERVED_VA 0ul +#endif + +/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ +#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE)) + +#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS +#define h2g_valid(x) 1 +#else +#define h2g_valid(x) ({ \ + unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ + (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ + (!RESERVED_VA || (__guest < RESERVED_VA)); \ +}) +#endif + +#define h2g(x) ({ \ + unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ + /* Check if given address fits target address space */ \ + assert(h2g_valid(x)); \ + (abi_ulong)__ret; \ +}) + +#define saddr(x) g2h(x) +#define laddr(x) g2h(x) + +#else /* !CONFIG_USER_ONLY */ +/* NOTE: we use double casts if pointers and target_ulong have + different sizes */ +#define saddr(x) (uint8_t *)(intptr_t)(x) +#define laddr(x) (uint8_t *)(intptr_t)(x) +#endif + +#define ldub_raw(p) ldub_p(laddr((p))) +#define ldsb_raw(p) ldsb_p(laddr((p))) +#define lduw_raw(p) lduw_p(laddr((p))) +#define ldsw_raw(p) ldsw_p(laddr((p))) +#define ldl_raw(p) ldl_p(laddr((p))) +#define ldq_raw(p) ldq_p(laddr((p))) +#define ldfl_raw(p) ldfl_p(laddr((p))) +#define ldfq_raw(p) ldfq_p(laddr((p))) +#define stb_raw(p, v) stb_p(saddr((p)), v) +#define stw_raw(p, v) stw_p(saddr((p)), v) +#define stl_raw(p, v) stl_p(saddr((p)), v) +#define stq_raw(p, v) stq_p(saddr((p)), v) +#define stfl_raw(p, v) stfl_p(saddr((p)), v) +#define stfq_raw(p, v) stfq_p(saddr((p)), v) + + +#if defined(CONFIG_USER_ONLY) + +/* if user mode, no other memory access functions */ +#define ldub(p) ldub_raw(p) +#define ldsb(p) ldsb_raw(p) +#define lduw(p) lduw_raw(p) +#define ldsw(p) ldsw_raw(p) +#define ldl(p) ldl_raw(p) +#define ldq(p) ldq_raw(p) +#define ldfl(p) ldfl_raw(p) +#define ldfq(p) ldfq_raw(p) +#define stb(p, v) stb_raw(p, v) +#define stw(p, v) stw_raw(p, v) +#define stl(p, v) stl_raw(p, v) +#define stq(p, v) stq_raw(p, v) +#define stfl(p, v) stfl_raw(p, v) +#define stfq(p, v) stfq_raw(p, v) + +#define cpu_ldub_code(env1, p) ldub_raw(p) +#define cpu_ldsb_code(env1, p) ldsb_raw(p) +#define cpu_lduw_code(env1, p) lduw_raw(p) +#define cpu_ldsw_code(env1, p) ldsw_raw(p) +#define cpu_ldl_code(env1, p) ldl_raw(p) +#define cpu_ldq_code(env1, p) ldq_raw(p) + +#define cpu_ldub_data(env, addr) ldub_raw(addr) +#define cpu_lduw_data(env, addr) lduw_raw(addr) +#define cpu_ldsw_data(env, addr) ldsw_raw(addr) +#define cpu_ldl_data(env, addr) ldl_raw(addr) +#define cpu_ldq_data(env, addr) ldq_raw(addr) + +#define cpu_stb_data(env, addr, data) stb_raw(addr, data) +#define cpu_stw_data(env, addr, data) stw_raw(addr, data) +#define cpu_stl_data(env, addr, data) stl_raw(addr, data) +#define cpu_stq_data(env, addr, data) stq_raw(addr, data) + +#define cpu_ldub_kernel(env, addr) ldub_raw(addr) +#define cpu_lduw_kernel(env, addr) lduw_raw(addr) +#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr) +#define cpu_ldl_kernel(env, addr) ldl_raw(addr) +#define cpu_ldq_kernel(env, addr) ldq_raw(addr) + +#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data) +#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data) +#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data) +#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data) + +#define ldub_kernel(p) ldub_raw(p) +#define ldsb_kernel(p) ldsb_raw(p) +#define lduw_kernel(p) lduw_raw(p) +#define ldsw_kernel(p) ldsw_raw(p) +#define ldl_kernel(p) ldl_raw(p) +#define ldq_kernel(p) ldq_raw(p) +#define ldfl_kernel(p) ldfl_raw(p) +#define ldfq_kernel(p) ldfq_raw(p) +#define stb_kernel(p, v) stb_raw(p, v) +#define stw_kernel(p, v) stw_raw(p, v) +#define stl_kernel(p, v) stl_raw(p, v) +#define stq_kernel(p, v) stq_raw(p, v) +#define stfl_kernel(p, v) stfl_raw(p, v) +#define stfq_kernel(p, vt) stfq_raw(p, v) + +#define cpu_ldub_data(env, addr) ldub_raw(addr) +#define cpu_lduw_data(env, addr) lduw_raw(addr) +#define cpu_ldl_data(env, addr) ldl_raw(addr) + +#define cpu_stb_data(env, addr, data) stb_raw(addr, data) +#define cpu_stw_data(env, addr, data) stw_raw(addr, data) +#define cpu_stl_data(env, addr, data) stl_raw(addr, data) +#endif /* defined(CONFIG_USER_ONLY) */ + +/* page related stuff */ + +#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) +#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) + +/* ??? These should be the larger of uintptr_t and target_ulong. */ +extern uintptr_t qemu_real_host_page_size; +extern uintptr_t qemu_host_page_size; +extern uintptr_t qemu_host_page_mask; + +#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) + +/* same as PROT_xxx */ +#define PAGE_READ 0x0001 +#define PAGE_WRITE 0x0002 +#define PAGE_EXEC 0x0004 +#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) +#define PAGE_VALID 0x0008 +/* original state of the write flag (used when tracking self-modifying + code */ +#define PAGE_WRITE_ORG 0x0010 +#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) +/* FIXME: Code that sets/uses this is broken and needs to go away. */ +#define PAGE_RESERVED 0x0020 +#endif + +#if defined(CONFIG_USER_ONLY) +void page_dump(FILE *f); + +typedef int (*walk_memory_regions_fn)(void *, abi_ulong, + abi_ulong, unsigned long); +int walk_memory_regions(void *, walk_memory_regions_fn); + +int page_get_flags(target_ulong address); +void page_set_flags(target_ulong start, target_ulong end, int flags); +int page_check_range(target_ulong start, target_ulong len, int flags); +#endif + +CPUArchState *cpu_copy(CPUArchState *env); +CPUArchState *qemu_get_cpu(int cpu); + +#define CPU_DUMP_CODE 0x00010000 +#define CPU_DUMP_FPU 0x00020000 /* dump FPU register state, not just integer */ +/* dump info about TCG QEMU's condition code optimization state */ +#define CPU_DUMP_CCOP 0x00040000 + +void cpu_dump_state(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, + int flags); +void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, + int flags); + +void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); +extern CPUArchState *first_cpu; +DECLARE_TLS(CPUArchState *,cpu_single_env); +#define cpu_single_env tls_var(cpu_single_env) + +/* Flags for use in ENV->INTERRUPT_PENDING. + + The numbers assigned here are non-sequential in order to preserve + binary compatibility with the vmstate dump. Bit 0 (0x0001) was + previously used for CPU_INTERRUPT_EXIT, and is cleared when loading + the vmstate dump. */ + +/* External hardware interrupt pending. This is typically used for + interrupts from devices. */ +#define CPU_INTERRUPT_HARD 0x0002 + +/* Exit the current TB. This is typically used when some system-level device + makes some change to the memory mapping. E.g. the a20 line change. */ +#define CPU_INTERRUPT_EXITTB 0x0004 + +/* Halt the CPU. */ +#define CPU_INTERRUPT_HALT 0x0020 + +/* Debug event pending. */ +#define CPU_INTERRUPT_DEBUG 0x0080 + +/* Several target-specific external hardware interrupts. Each target/cpu.h + should define proper names based on these defines. */ +#define CPU_INTERRUPT_TGT_EXT_0 0x0008 +#define CPU_INTERRUPT_TGT_EXT_1 0x0010 +#define CPU_INTERRUPT_TGT_EXT_2 0x0040 +#define CPU_INTERRUPT_TGT_EXT_3 0x0200 +#define CPU_INTERRUPT_TGT_EXT_4 0x1000 + +/* Several target-specific internal interrupts. These differ from the + preceding target-specific interrupts in that they are intended to + originate from within the cpu itself, typically in response to some + instruction being executed. These, therefore, are not masked while + single-stepping within the debugger. */ +#define CPU_INTERRUPT_TGT_INT_0 0x0100 +#define CPU_INTERRUPT_TGT_INT_1 0x0400 +#define CPU_INTERRUPT_TGT_INT_2 0x0800 +#define CPU_INTERRUPT_TGT_INT_3 0x2000 + +/* First unused bit: 0x4000. */ + +/* The set of all bits that should be masked when single-stepping. */ +#define CPU_INTERRUPT_SSTEP_MASK \ + (CPU_INTERRUPT_HARD \ + | CPU_INTERRUPT_TGT_EXT_0 \ + | CPU_INTERRUPT_TGT_EXT_1 \ + | CPU_INTERRUPT_TGT_EXT_2 \ + | CPU_INTERRUPT_TGT_EXT_3 \ + | CPU_INTERRUPT_TGT_EXT_4) + +#ifndef CONFIG_USER_ONLY +typedef void (*CPUInterruptHandler)(CPUArchState *, int); + +extern CPUInterruptHandler cpu_interrupt_handler; + +static inline void cpu_interrupt(CPUArchState *s, int mask) +{ + cpu_interrupt_handler(s, mask); +} +#else /* USER_ONLY */ +void cpu_interrupt(CPUArchState *env, int mask); +#endif /* USER_ONLY */ + +void cpu_reset_interrupt(CPUArchState *env, int mask); + +void cpu_exit(CPUArchState *s); + +/* Breakpoint/watchpoint flags */ +#define BP_MEM_READ 0x01 +#define BP_MEM_WRITE 0x02 +#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE) +#define BP_STOP_BEFORE_ACCESS 0x04 +#define BP_WATCHPOINT_HIT 0x08 +#define BP_GDB 0x10 +#define BP_CPU 0x20 + +int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags, + CPUBreakpoint **breakpoint); +int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags); +void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint); +void cpu_breakpoint_remove_all(CPUArchState *env, int mask); +int cpu_watchpoint_insert(CPUArchState *env, target_ulong addr, target_ulong len, + int flags, CPUWatchpoint **watchpoint); +int cpu_watchpoint_remove(CPUArchState *env, target_ulong addr, + target_ulong len, int flags); +void cpu_watchpoint_remove_by_ref(CPUArchState *env, CPUWatchpoint *watchpoint); +void cpu_watchpoint_remove_all(CPUArchState *env, int mask); + +#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ +#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ +#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */ + +void cpu_single_step(CPUArchState *env, int enabled); + +#if !defined(CONFIG_USER_ONLY) + +/* Return the physical page corresponding to a virtual one. Use it + only for debugging because no protection checks are done. Return -1 + if no page found. */ +hwaddr cpu_get_phys_page_debug(CPUArchState *env, target_ulong addr); + +/* memory API */ + +extern int phys_ram_fd; +extern ram_addr_t ram_size; + +/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ +#define RAM_PREALLOC_MASK (1 << 0) + +typedef struct RAMBlock { + struct MemoryRegion *mr; + uint8_t *host; + ram_addr_t offset; + ram_addr_t length; + uint32_t flags; + char idstr[256]; + QLIST_ENTRY(RAMBlock) next; +#if defined(__linux__) && !defined(TARGET_S390X) + int fd; +#endif +} RAMBlock; + +typedef struct RAMList { + uint8_t *phys_dirty; + QLIST_HEAD(, RAMBlock) blocks; +} RAMList; +extern RAMList ram_list; + +extern const char *mem_path; +extern int mem_prealloc; + +/* Flags stored in the low bits of the TLB virtual address. These are + defined so that fast path ram access is all zeros. */ +/* Zero if TLB entry is valid. */ +#define TLB_INVALID_MASK (1 << 3) +/* Set if TLB entry references a clean RAM page. The iotlb entry will + contain the page physical address. */ +#define TLB_NOTDIRTY (1 << 4) +/* Set if TLB entry is an IO callback. */ +#define TLB_MMIO (1 << 5) + +void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); +ram_addr_t last_ram_offset(void); +#endif /* !CONFIG_USER_ONLY */ + +int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, + uint8_t *buf, int len, int is_write); + +#endif /* CPU_ALL_H */ diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h new file mode 100644 index 0000000000..f83d6180f3 --- /dev/null +++ b/include/exec/cpu-common.h @@ -0,0 +1,112 @@ +#ifndef CPU_COMMON_H +#define CPU_COMMON_H 1 + +/* CPU interfaces that are target independent. */ + +#include "exec/hwaddr.h" + +#ifndef NEED_CPU_H +#include "exec/poison.h" +#endif + +#include "bswap.h" +#include "qemu-queue.h" + +#if !defined(CONFIG_USER_ONLY) + +enum device_endian { + DEVICE_NATIVE_ENDIAN, + DEVICE_BIG_ENDIAN, + DEVICE_LITTLE_ENDIAN, +}; + +/* address in the RAM (different from a physical address) */ +#if defined(CONFIG_XEN_BACKEND) +typedef uint64_t ram_addr_t; +# define RAM_ADDR_MAX UINT64_MAX +# define RAM_ADDR_FMT "%" PRIx64 +#else +typedef uintptr_t ram_addr_t; +# define RAM_ADDR_MAX UINTPTR_MAX +# define RAM_ADDR_FMT "%" PRIxPTR +#endif + +/* memory API */ + +typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); +typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); + +void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); +/* This should only be used for ram local to a device. */ +void *qemu_get_ram_ptr(ram_addr_t addr); +void qemu_put_ram_ptr(void *addr); +/* This should not be used by devices. */ +int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); +ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); +void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev); + +void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, + int len, int is_write); +static inline void cpu_physical_memory_read(hwaddr addr, + void *buf, int len) +{ + cpu_physical_memory_rw(addr, buf, len, 0); +} +static inline void cpu_physical_memory_write(hwaddr addr, + const void *buf, int len) +{ + cpu_physical_memory_rw(addr, (void *)buf, len, 1); +} +void *cpu_physical_memory_map(hwaddr addr, + hwaddr *plen, + int is_write); +void cpu_physical_memory_unmap(void *buffer, hwaddr len, + int is_write, hwaddr access_len); +void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); + +bool cpu_physical_memory_is_io(hwaddr phys_addr); + +/* Coalesced MMIO regions are areas where write operations can be reordered. + * This usually implies that write operations are side-effect free. This allows + * batching which can make a major impact on performance when using + * virtualization. + */ +void qemu_flush_coalesced_mmio_buffer(void); + +uint32_t ldub_phys(hwaddr addr); +uint32_t lduw_le_phys(hwaddr addr); +uint32_t lduw_be_phys(hwaddr addr); +uint32_t ldl_le_phys(hwaddr addr); +uint32_t ldl_be_phys(hwaddr addr); +uint64_t ldq_le_phys(hwaddr addr); +uint64_t ldq_be_phys(hwaddr addr); +void stb_phys(hwaddr addr, uint32_t val); +void stw_le_phys(hwaddr addr, uint32_t val); +void stw_be_phys(hwaddr addr, uint32_t val); +void stl_le_phys(hwaddr addr, uint32_t val); +void stl_be_phys(hwaddr addr, uint32_t val); +void stq_le_phys(hwaddr addr, uint64_t val); +void stq_be_phys(hwaddr addr, uint64_t val); + +#ifdef NEED_CPU_H +uint32_t lduw_phys(hwaddr addr); +uint32_t ldl_phys(hwaddr addr); +uint64_t ldq_phys(hwaddr addr); +void stl_phys_notdirty(hwaddr addr, uint32_t val); +void stq_phys_notdirty(hwaddr addr, uint64_t val); +void stw_phys(hwaddr addr, uint32_t val); +void stl_phys(hwaddr addr, uint32_t val); +void stq_phys(hwaddr addr, uint64_t val); +#endif + +void cpu_physical_memory_write_rom(hwaddr addr, + const uint8_t *buf, int len); + +extern struct MemoryRegion io_mem_ram; +extern struct MemoryRegion io_mem_rom; +extern struct MemoryRegion io_mem_unassigned; +extern struct MemoryRegion io_mem_notdirty; + +#endif + +#endif /* !CPU_COMMON_H */ diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h new file mode 100644 index 0000000000..8d2230e50e --- /dev/null +++ b/include/exec/cpu-defs.h @@ -0,0 +1,213 @@ +/* + * common defines for all CPUs + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPU_DEFS_H +#define CPU_DEFS_H + +#ifndef NEED_CPU_H +#error cpu.h included from common code +#endif + +#include "config.h" +#include +#include +#include +#include "osdep.h" +#include "qemu-queue.h" +#include "exec/hwaddr.h" + +#ifndef TARGET_LONG_BITS +#error TARGET_LONG_BITS must be defined before including this header +#endif + +#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) + +typedef int16_t target_short __attribute__ ((aligned(TARGET_SHORT_ALIGNMENT))); +typedef uint16_t target_ushort __attribute__((aligned(TARGET_SHORT_ALIGNMENT))); +typedef int32_t target_int __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef uint32_t target_uint __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef int64_t target_llong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); +typedef uint64_t target_ullong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); +/* target_ulong is the type of a virtual address */ +#if TARGET_LONG_SIZE == 4 +typedef int32_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint32_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +#define TARGET_FMT_lx "%08x" +#define TARGET_FMT_ld "%d" +#define TARGET_FMT_lu "%u" +#elif TARGET_LONG_SIZE == 8 +typedef int64_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +#define TARGET_FMT_lx "%016" PRIx64 +#define TARGET_FMT_ld "%" PRId64 +#define TARGET_FMT_lu "%" PRIu64 +#else +#error TARGET_LONG_SIZE undefined +#endif + +#define EXCP_INTERRUPT 0x10000 /* async interruption */ +#define EXCP_HLT 0x10001 /* hlt instruction reached */ +#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ +#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ + +#define TB_JMP_CACHE_BITS 12 +#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) + +/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for + addresses on the same page. The top bits are the same. This allows + TLB invalidation to quickly clear a subset of the hash table. */ +#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) +#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) +#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) +#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) + +#if !defined(CONFIG_USER_ONLY) +#define CPU_TLB_BITS 8 +#define CPU_TLB_SIZE (1 << CPU_TLB_BITS) + +#if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 +#define CPU_TLB_ENTRY_BITS 4 +#else +#define CPU_TLB_ENTRY_BITS 5 +#endif + +typedef struct CPUTLBEntry { + /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address + bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not + go directly to ram. + bit 3 : indicates that the entry is invalid + bit 2..0 : zero + */ + target_ulong addr_read; + target_ulong addr_write; + target_ulong addr_code; + /* Addend to virtual address to get host address. IO accesses + use the corresponding iotlb value. */ + uintptr_t addend; + /* padding to get a power of two size */ + uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - + (sizeof(target_ulong) * 3 + + ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + + sizeof(uintptr_t))]; +} CPUTLBEntry; + +extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1]; + +#define CPU_COMMON_TLB \ + /* The meaning of the MMU modes is defined in the target code. */ \ + CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ + hwaddr iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ + target_ulong tlb_flush_addr; \ + target_ulong tlb_flush_mask; + +#else + +#define CPU_COMMON_TLB + +#endif + + +#ifdef HOST_WORDS_BIGENDIAN +typedef struct icount_decr_u16 { + uint16_t high; + uint16_t low; +} icount_decr_u16; +#else +typedef struct icount_decr_u16 { + uint16_t low; + uint16_t high; +} icount_decr_u16; +#endif + +struct kvm_run; +struct KVMState; +struct qemu_work_item; + +typedef struct CPUBreakpoint { + target_ulong pc; + int flags; /* BP_* */ + QTAILQ_ENTRY(CPUBreakpoint) entry; +} CPUBreakpoint; + +typedef struct CPUWatchpoint { + target_ulong vaddr; + target_ulong len_mask; + int flags; /* BP_* */ + QTAILQ_ENTRY(CPUWatchpoint) entry; +} CPUWatchpoint; + +#define CPU_TEMP_BUF_NLONGS 128 +#define CPU_COMMON \ + struct TranslationBlock *current_tb; /* currently executing TB */ \ + /* soft mmu support */ \ + /* in order to avoid passing too many arguments to the MMIO \ + helpers, we store some rarely used information in the CPU \ + context) */ \ + uintptr_t mem_io_pc; /* host pc at which the memory was \ + accessed */ \ + target_ulong mem_io_vaddr; /* target virtual addr at which the \ + memory was accessed */ \ + uint32_t halted; /* Nonzero if the CPU is in suspend state */ \ + uint32_t interrupt_request; \ + volatile sig_atomic_t exit_request; \ + CPU_COMMON_TLB \ + struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ + /* buffer for temporaries in the code generator */ \ + long temp_buf[CPU_TEMP_BUF_NLONGS]; \ + \ + int64_t icount_extra; /* Instructions until next timer event. */ \ + /* Number of cycles left, with interrupt flag in high bit. \ + This allows a single read-compare-cbranch-write sequence to test \ + for both decrementer underflow and exceptions. */ \ + union { \ + uint32_t u32; \ + icount_decr_u16 u16; \ + } icount_decr; \ + uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \ + \ + /* from this point: preserved by CPU reset */ \ + /* ice debug support */ \ + QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ + int singlestep_enabled; \ + \ + QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ + CPUWatchpoint *watchpoint_hit; \ + \ + struct GDBRegisterState *gdb_regs; \ + \ + /* Core interrupt code */ \ + jmp_buf jmp_env; \ + int exception_index; \ + \ + CPUArchState *next_cpu; /* next CPU sharing TB cache */ \ + int cpu_index; /* CPU index (informative) */ \ + uint32_t host_tid; /* host thread ID */ \ + int numa_node; /* NUMA node this cpu is belonging to */ \ + int nr_cores; /* number of cores within this CPU package */ \ + int nr_threads;/* number of threads within this CPU */ \ + int running; /* Nonzero if cpu is currently running(usermode). */ \ + /* user data */ \ + void *opaque; \ + \ + const char *cpu_model_str; \ + struct KVMState *kvm_state; \ + struct kvm_run *kvm_run; \ + int kvm_fd; \ + int kvm_vcpu_dirty; + +#endif diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h new file mode 100644 index 0000000000..733c885a1f --- /dev/null +++ b/include/exec/cputlb.h @@ -0,0 +1,46 @@ +/* + * Common CPU TLB handling + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPUTLB_H +#define CPUTLB_H + +#if !defined(CONFIG_USER_ONLY) +/* cputlb.c */ +void tlb_protect_code(ram_addr_t ram_addr); +void tlb_unprotect_code_phys(CPUArchState *env, ram_addr_t ram_addr, + target_ulong vaddr); +void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start, + uintptr_t length); +MemoryRegionSection *phys_page_find(struct AddressSpaceDispatch *d, + hwaddr index); +void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length); +void tlb_set_dirty(CPUArchState *env, target_ulong vaddr); +extern int tlb_flush_count; + +/* exec.c */ +void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr); +hwaddr memory_region_section_get_iotlb(CPUArchState *env, + MemoryRegionSection *section, + target_ulong vaddr, + hwaddr paddr, + int prot, + target_ulong *address); +bool memory_region_is_unassigned(MemoryRegion *mr); + +#endif +#endif diff --git a/include/exec/def-helper.h b/include/exec/def-helper.h new file mode 100644 index 0000000000..022a9ceb6a --- /dev/null +++ b/include/exec/def-helper.h @@ -0,0 +1,275 @@ +/* Helper file for declaring TCG helper functions. + Should be included at the start and end of target-foo/helper.h. + + Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper + functions. Names should be specified without the helper_ prefix, and + the return and argument types specified. 3 basic types are understood + (i32, i64 and ptr). Additional aliases are provided for convenience and + to match the types used by the C helper implementation. + + The target helper.h should be included in all files that use/define + helper functions. THis will ensure that function prototypes are + consistent. In addition it should be included an extra two times for + helper.c, defining: + GEN_HELPER 1 to produce op generation functions (gen_helper_*) + GEN_HELPER 2 to do runtime registration helper functions. + */ + +#ifndef DEF_HELPER_H +#define DEF_HELPER_H 1 + +#define HELPER(name) glue(helper_, name) + +#define GET_TCGV_i32 GET_TCGV_I32 +#define GET_TCGV_i64 GET_TCGV_I64 +#define GET_TCGV_ptr GET_TCGV_PTR + +/* Some types that make sense in C, but not for TCG. */ +#define dh_alias_i32 i32 +#define dh_alias_s32 i32 +#define dh_alias_int i32 +#define dh_alias_i64 i64 +#define dh_alias_s64 i64 +#define dh_alias_f32 i32 +#define dh_alias_f64 i64 +#if TARGET_LONG_BITS == 32 +#define dh_alias_tl i32 +#else +#define dh_alias_tl i64 +#endif +#define dh_alias_ptr ptr +#define dh_alias_void void +#define dh_alias_noreturn noreturn +#define dh_alias_env ptr +#define dh_alias(t) glue(dh_alias_, t) + +#define dh_ctype_i32 uint32_t +#define dh_ctype_s32 int32_t +#define dh_ctype_int int +#define dh_ctype_i64 uint64_t +#define dh_ctype_s64 int64_t +#define dh_ctype_f32 float32 +#define dh_ctype_f64 float64 +#define dh_ctype_tl target_ulong +#define dh_ctype_ptr void * +#define dh_ctype_void void +#define dh_ctype_noreturn void QEMU_NORETURN +#define dh_ctype_env CPUArchState * +#define dh_ctype(t) dh_ctype_##t + +/* We can't use glue() here because it falls foul of C preprocessor + recursive expansion rules. */ +#define dh_retvar_decl0_void void +#define dh_retvar_decl0_noreturn void +#define dh_retvar_decl0_i32 TCGv_i32 retval +#define dh_retvar_decl0_i64 TCGv_i64 retval +#define dh_retvar_decl0_ptr TCGv_ptr retval +#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t)) + +#define dh_retvar_decl_void +#define dh_retvar_decl_noreturn +#define dh_retvar_decl_i32 TCGv_i32 retval, +#define dh_retvar_decl_i64 TCGv_i64 retval, +#define dh_retvar_decl_ptr TCGv_ptr retval, +#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t)) + +#define dh_retvar_void TCG_CALL_DUMMY_ARG +#define dh_retvar_noreturn TCG_CALL_DUMMY_ARG +#define dh_retvar_i32 GET_TCGV_i32(retval) +#define dh_retvar_i64 GET_TCGV_i64(retval) +#define dh_retvar_ptr GET_TCGV_ptr(retval) +#define dh_retvar(t) glue(dh_retvar_, dh_alias(t)) + +#define dh_is_64bit_void 0 +#define dh_is_64bit_noreturn 0 +#define dh_is_64bit_i32 0 +#define dh_is_64bit_i64 1 +#define dh_is_64bit_ptr (TCG_TARGET_REG_BITS == 64) +#define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t)) + +#define dh_is_signed_void 0 +#define dh_is_signed_noreturn 0 +#define dh_is_signed_i32 0 +#define dh_is_signed_s32 1 +#define dh_is_signed_i64 0 +#define dh_is_signed_s64 1 +#define dh_is_signed_f32 0 +#define dh_is_signed_f64 0 +#define dh_is_signed_tl 0 +#define dh_is_signed_int 1 +/* ??? This is highly specific to the host cpu. There are even special + extension instructions that may be required, e.g. ia64's addp4. But + for now we don't support any 64-bit targets with 32-bit pointers. */ +#define dh_is_signed_ptr 0 +#define dh_is_signed_env dh_is_signed_ptr +#define dh_is_signed(t) dh_is_signed_##t + +#define dh_sizemask(t, n) \ + sizemask |= dh_is_64bit(t) << (n*2); \ + sizemask |= dh_is_signed(t) << (n*2+1) + +#define dh_arg(t, n) \ + args[n - 1] = glue(GET_TCGV_, dh_alias(t))(glue(arg, n)); \ + dh_sizemask(t, n) + +#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n) + + +#define DEF_HELPER_0(name, ret) \ + DEF_HELPER_FLAGS_0(name, 0, ret) +#define DEF_HELPER_1(name, ret, t1) \ + DEF_HELPER_FLAGS_1(name, 0, ret, t1) +#define DEF_HELPER_2(name, ret, t1, t2) \ + DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2) +#define DEF_HELPER_3(name, ret, t1, t2, t3) \ + DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3) +#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \ + DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4) +#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \ + DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5) + +/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ + +#endif /* DEF_HELPER_H */ + +#ifndef GEN_HELPER +/* Function prototypes. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +dh_ctype(ret) HELPER(name) (void); + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1)); + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2)); + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3)); + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ + dh_ctype(t4)); + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ + dh_ctype(t4), dh_ctype(t5)); + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == 1 +/* Gen functions. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ +{ \ + int sizemask; \ + sizemask = dh_is_64bit(ret); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 0, NULL); \ +} + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1)) \ +{ \ + TCGArg args[1]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \ +} + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2)) \ +{ \ + TCGArg args[2]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \ +} + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ +{ \ + TCGArg args[3]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 3, args); \ +} + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ +{ \ + TCGArg args[4]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + dh_arg(t4, 4); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 4, args); \ +} + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ + dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ + dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ +{ \ + TCGArg args[5]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + dh_arg(t4, 4); \ + dh_arg(t5, 5); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 5, args); \ +} + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == 2 +/* Register helpers. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +tcg_register_helper(HELPER(name), #name); + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == -1 +/* Undefine macros. */ + +#undef DEF_HELPER_FLAGS_0 +#undef DEF_HELPER_FLAGS_1 +#undef DEF_HELPER_FLAGS_2 +#undef DEF_HELPER_FLAGS_3 +#undef DEF_HELPER_FLAGS_4 +#undef DEF_HELPER_FLAGS_5 +#undef GEN_HELPER + +#endif diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h new file mode 100644 index 0000000000..2ae8aae3d6 --- /dev/null +++ b/include/exec/exec-all.h @@ -0,0 +1,412 @@ +/* + * internal execution defines for qemu + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef _EXEC_ALL_H_ +#define _EXEC_ALL_H_ + +#include "qemu-common.h" + +/* allow to see translation results - the slowdown should be negligible, so we leave it */ +#define DEBUG_DISAS + +/* Page tracking code uses ram addresses in system mode, and virtual + addresses in userspace mode. Define tb_page_addr_t to be an appropriate + type. */ +#if defined(CONFIG_USER_ONLY) +typedef abi_ulong tb_page_addr_t; +#else +typedef ram_addr_t tb_page_addr_t; +#endif + +/* is_jmp field values */ +#define DISAS_NEXT 0 /* next instruction can be analyzed */ +#define DISAS_JUMP 1 /* only pc was modified dynamically */ +#define DISAS_UPDATE 2 /* cpu state was modified dynamically */ +#define DISAS_TB_JUMP 3 /* only pc was modified statically */ + +struct TranslationBlock; +typedef struct TranslationBlock TranslationBlock; + +/* XXX: make safe guess about sizes */ +#define MAX_OP_PER_INSTR 208 + +#if HOST_LONG_BITS == 32 +#define MAX_OPC_PARAM_PER_ARG 2 +#else +#define MAX_OPC_PARAM_PER_ARG 1 +#endif +#define MAX_OPC_PARAM_IARGS 5 +#define MAX_OPC_PARAM_OARGS 1 +#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) + +/* A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N = number of input arguments + output arguments). */ +#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) +#define OPC_BUF_SIZE 640 +#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) + +/* Maximum size a TCG op can expand to. This is complicated because a + single op may require several host instructions and register reloads. + For now take a wild guess at 192 bytes, which should allow at least + a couple of fixup instructions per argument. */ +#define TCG_MAX_OP_SIZE 192 + +#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) + +#include "qemu-log.h" + +void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); +void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); +void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, + int pc_pos); + +void cpu_gen_init(void); +int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb, + int *gen_code_size_ptr); +bool cpu_restore_state(CPUArchState *env, uintptr_t searched_pc); + +void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); +void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); +TranslationBlock *tb_gen_code(CPUArchState *env, + target_ulong pc, target_ulong cs_base, int flags, + int cflags); +void cpu_exec_init(CPUArchState *env); +void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1); +int page_unprotect(target_ulong address, uintptr_t pc, void *puc); +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access); +void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access); +#if !defined(CONFIG_USER_ONLY) +/* cputlb.c */ +void tlb_flush_page(CPUArchState *env, target_ulong addr); +void tlb_flush(CPUArchState *env, int flush_global); +void tlb_set_page(CPUArchState *env, target_ulong vaddr, + hwaddr paddr, int prot, + int mmu_idx, target_ulong size); +void tb_invalidate_phys_addr(hwaddr addr); +#else +static inline void tlb_flush_page(CPUArchState *env, target_ulong addr) +{ +} + +static inline void tlb_flush(CPUArchState *env, int flush_global) +{ +} +#endif + +#define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ + +#define CODE_GEN_PHYS_HASH_BITS 15 +#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) + +/* estimated block size for TB allocation */ +/* XXX: use a per code average code fragment size and modulate it + according to the host CPU */ +#if defined(CONFIG_SOFTMMU) +#define CODE_GEN_AVG_BLOCK_SIZE 128 +#else +#define CODE_GEN_AVG_BLOCK_SIZE 64 +#endif + +#if defined(__arm__) || defined(_ARCH_PPC) \ + || defined(__x86_64__) || defined(__i386__) \ + || defined(__sparc__) \ + || defined(CONFIG_TCG_INTERPRETER) +#define USE_DIRECT_JUMP +#endif + +struct TranslationBlock { + target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ + target_ulong cs_base; /* CS base for this block */ + uint64_t flags; /* flags defining in which context the code was generated */ + uint16_t size; /* size of target code for this block (1 <= + size <= TARGET_PAGE_SIZE) */ + uint16_t cflags; /* compile flags */ +#define CF_COUNT_MASK 0x7fff +#define CF_LAST_IO 0x8000 /* Last insn may be an IO access. */ + + uint8_t *tc_ptr; /* pointer to the translated code */ + /* next matching tb for physical address. */ + struct TranslationBlock *phys_hash_next; + /* first and second physical page containing code. The lower bit + of the pointer tells the index in page_next[] */ + struct TranslationBlock *page_next[2]; + tb_page_addr_t page_addr[2]; + + /* the following data are used to directly call another TB from + the code of this one. */ + uint16_t tb_next_offset[2]; /* offset of original jump target */ +#ifdef USE_DIRECT_JUMP + uint16_t tb_jmp_offset[2]; /* offset of jump instruction */ +#else + uintptr_t tb_next[2]; /* address of jump generated code */ +#endif + /* list of TBs jumping to this one. This is a circular list using + the two least significant bits of the pointers to tell what is + the next pointer: 0 = jmp_next[0], 1 = jmp_next[1], 2 = + jmp_first */ + struct TranslationBlock *jmp_next[2]; + struct TranslationBlock *jmp_first; + uint32_t icount; +}; + +static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; +} + +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) + | (tmp & TB_JMP_ADDR_MASK)); +} + +static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) +{ + return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); +} + +void tb_free(TranslationBlock *tb); +void tb_flush(CPUArchState *env); +void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); + +extern TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; + +#if defined(USE_DIRECT_JUMP) + +#if defined(CONFIG_TCG_INTERPRETER) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ + /* patch the branch destination */ + *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + /* no need to flush icache explicitly */ +} +#elif defined(_ARCH_PPC) +void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); +#define tb_set_jmp_target1 ppc_tb_set_jmp_target +#elif defined(__i386__) || defined(__x86_64__) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ + /* patch the branch destination */ + *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + /* no need to flush icache explicitly */ +} +#elif defined(__arm__) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ +#if !QEMU_GNUC_PREREQ(4, 1) + register unsigned long _beg __asm ("a1"); + register unsigned long _end __asm ("a2"); + register unsigned long _flg __asm ("a3"); +#endif + + /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */ + *(uint32_t *)jmp_addr = + (*(uint32_t *)jmp_addr & ~0xffffff) + | (((addr - (jmp_addr + 8)) >> 2) & 0xffffff); + +#if QEMU_GNUC_PREREQ(4, 1) + __builtin___clear_cache((char *) jmp_addr, (char *) jmp_addr + 4); +#else + /* flush icache */ + _beg = jmp_addr; + _end = jmp_addr + 4; + _flg = 0; + __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); +#endif +} +#elif defined(__sparc__) +void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); +#else +#error tb_set_jmp_target1 is missing +#endif + +static inline void tb_set_jmp_target(TranslationBlock *tb, + int n, uintptr_t addr) +{ + uint16_t offset = tb->tb_jmp_offset[n]; + tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr); +} + +#else + +/* set the jump target */ +static inline void tb_set_jmp_target(TranslationBlock *tb, + int n, uintptr_t addr) +{ + tb->tb_next[n] = addr; +} + +#endif + +static inline void tb_add_jump(TranslationBlock *tb, int n, + TranslationBlock *tb_next) +{ + /* NOTE: this test is only needed for thread safety */ + if (!tb->jmp_next[n]) { + /* patch the native jump address */ + tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); + + /* add in TB jmp circular list */ + tb->jmp_next[n] = tb_next->jmp_first; + tb_next->jmp_first = (TranslationBlock *)((uintptr_t)(tb) | (n)); + } +} + +#include "exec/spinlock.h" + +extern spinlock_t tb_lock; + +extern int tb_invalidated_flag; + +/* The return address may point to the start of the next instruction. + Subtracting one gets us the call instruction itself. */ +#if defined(CONFIG_TCG_INTERPRETER) +/* Softmmu, Alpha, MIPS, SH4 and SPARC user mode emulations call GETPC(). + For all others, GETPC remains undefined (which makes TCI a little faster. */ +# if defined(CONFIG_SOFTMMU) || \ + defined(TARGET_ALPHA) || defined(TARGET_MIPS) || \ + defined(TARGET_SH4) || defined(TARGET_SPARC) +extern uintptr_t tci_tb_ptr; +# define GETPC() tci_tb_ptr +# endif +#elif defined(__s390__) && !defined(__s390x__) +# define GETPC() \ + (((uintptr_t)__builtin_return_address(0) & 0x7fffffffUL) - 1) +#elif defined(__arm__) +/* Thumb return addresses have the low bit set, so we need to subtract two. + This is still safe in ARM mode because instructions are 4 bytes. */ +# define GETPC() ((uintptr_t)__builtin_return_address(0) - 2) +#else +# define GETPC() ((uintptr_t)__builtin_return_address(0) - 1) +#endif + +#if defined(CONFIG_QEMU_LDST_OPTIMIZATION) && defined(CONFIG_SOFTMMU) +/* qemu_ld/st optimization split code generation to fast and slow path, thus, + it needs special handling for an MMU helper which is called from the slow + path, to get the fast path's pc without any additional argument. + It uses a tricky solution which embeds the fast path pc into the slow path. + + Code flow in slow path: + (1) pre-process + (2) call MMU helper + (3) jump to (5) + (4) fast path information (implementation specific) + (5) post-process (e.g. stack adjust) + (6) jump to corresponding code of the next of fast path + */ +# if defined(__i386__) || defined(__x86_64__) +/* To avoid broken disassembling, long jmp is used for embedding fast path pc, + so that the destination is the next code of fast path, though this jmp is + never executed. + + call MMU helper + jmp POST_PROC (2byte) <- GETRA() + jmp NEXT_CODE (5byte) + POST_PROCESS ... <- GETRA() + 7 + */ +# define GETRA() ((uintptr_t)__builtin_return_address(0)) +# define GETPC_LDST() ((uintptr_t)(GETRA() + 7 + \ + *(int32_t *)((void *)GETRA() + 3) - 1)) +# elif defined (_ARCH_PPC) && !defined (_ARCH_PPC64) +# define GETRA() ((uintptr_t)__builtin_return_address(0)) +# define GETPC_LDST() ((uintptr_t) ((*(int32_t *)(GETRA() - 4)) - 1)) +# else +# error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!" +# endif +bool is_tcg_gen_code(uintptr_t pc_ptr); +# define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC()) +#else +# define GETPC_EXT() GETPC() +#endif + +#if !defined(CONFIG_USER_ONLY) + +struct MemoryRegion *iotlb_to_region(hwaddr index); +uint64_t io_mem_read(struct MemoryRegion *mr, hwaddr addr, + unsigned size); +void io_mem_write(struct MemoryRegion *mr, hwaddr addr, + uint64_t value, unsigned size); + +void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx, + uintptr_t retaddr); + +#include "exec/softmmu_defs.h" + +#define ACCESS_TYPE (NB_MMU_MODES + 1) +#define MEMSUFFIX _code + +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" + +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#endif + +#if defined(CONFIG_USER_ONLY) +static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) +{ + return addr; +} +#else +/* cputlb.c */ +tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); +#endif + +typedef void (CPUDebugExcpHandler)(CPUArchState *env); + +void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); + +/* vl.c */ +extern int singlestep; + +/* cpu-exec.c */ +extern volatile sig_atomic_t exit_request; + +/* Deterministic execution requires that IO only be performed on the last + instruction of a TB so that interrupts take effect immediately. */ +static inline int can_do_io(CPUArchState *env) +{ + if (!use_icount) { + return 1; + } + /* If not executing code then assume we are ok. */ + if (!env->current_tb) { + return 1; + } + return env->can_do_io != 0; +} + +#endif diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h new file mode 100644 index 0000000000..668de66000 --- /dev/null +++ b/include/exec/gdbstub.h @@ -0,0 +1,53 @@ +#ifndef GDBSTUB_H +#define GDBSTUB_H + +#define DEFAULT_GDBSTUB_PORT "1234" + +/* GDB breakpoint/watchpoint types */ +#define GDB_BREAKPOINT_SW 0 +#define GDB_BREAKPOINT_HW 1 +#define GDB_WATCHPOINT_WRITE 2 +#define GDB_WATCHPOINT_READ 3 +#define GDB_WATCHPOINT_ACCESS 4 + +#ifdef NEED_CPU_H +typedef void (*gdb_syscall_complete_cb)(CPUArchState *env, + target_ulong ret, target_ulong err); + +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); +int use_gdb_syscalls(void); +void gdb_set_stop_cpu(CPUArchState *env); +void gdb_exit(CPUArchState *, int); +#ifdef CONFIG_USER_ONLY +int gdb_queuesig (void); +int gdb_handlesig (CPUArchState *, int); +void gdb_signalled(CPUArchState *, int); +void gdbserver_fork(CPUArchState *); +#endif +/* Get or set a register. Returns the size of the register. */ +typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +void gdb_register_coprocessor(CPUArchState *env, + gdb_reg_cb get_reg, gdb_reg_cb set_reg, + int num_regs, const char *xml, int g_pos); + +static inline int cpu_index(CPUArchState *env) +{ +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) + return env->host_tid; +#else + return env->cpu_index + 1; +#endif +} + +#endif + +#ifdef CONFIG_USER_ONLY +int gdbserver_start(int); +#else +int gdbserver_start(const char *port); +#endif + +/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ +extern const char *const xml_builtin[][2]; + +#endif diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h new file mode 100644 index 0000000000..1541f0b1e4 --- /dev/null +++ b/include/exec/gen-icount.h @@ -0,0 +1,53 @@ +#ifndef GEN_ICOUNT_H +#define GEN_ICOUNT_H 1 + +#include "qemu-timer.h" + +/* Helpers for instruction counting code generation. */ + +static TCGArg *icount_arg; +static int icount_label; + +static inline void gen_icount_start(void) +{ + TCGv_i32 count; + + if (!use_icount) + return; + + icount_label = gen_new_label(); + count = tcg_temp_local_new_i32(); + tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); + /* This is a horrid hack to allow fixing up the value later. */ + icount_arg = tcg_ctx.gen_opparam_ptr + 1; + tcg_gen_subi_i32(count, count, 0xdeadbeef); + + tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label); + tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); + tcg_temp_free_i32(count); +} + +static void gen_icount_end(TranslationBlock *tb, int num_insns) +{ + if (use_icount) { + *icount_arg = num_insns; + gen_set_label(icount_label); + tcg_gen_exit_tb((tcg_target_long)tb + 2); + } +} + +static inline void gen_io_start(void) +{ + TCGv_i32 tmp = tcg_const_i32(1); + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_temp_free_i32(tmp); +} + +static inline void gen_io_end(void) +{ + TCGv_i32 tmp = tcg_const_i32(0); + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_temp_free_i32(tmp); +} + +#endif diff --git a/include/exec/hwaddr.h b/include/exec/hwaddr.h new file mode 100644 index 0000000000..251cf9216f --- /dev/null +++ b/include/exec/hwaddr.h @@ -0,0 +1,24 @@ +/* Define hwaddr if it exists. */ + +#ifndef HWADDR_H +#define HWADDR_H + +#ifndef CONFIG_USER_ONLY + +#define HWADDR_BITS 64 +/* hwaddr is the type of a physical address (its size can + be different from 'target_ulong'). */ + +typedef uint64_t hwaddr; +#define HWADDR_MAX UINT64_MAX +#define TARGET_FMT_plx "%016" PRIx64 +#define HWADDR_PRId PRId64 +#define HWADDR_PRIi PRIi64 +#define HWADDR_PRIo PRIo64 +#define HWADDR_PRIu PRIu64 +#define HWADDR_PRIx PRIx64 +#define HWADDR_PRIX PRIX64 + +#endif + +#endif diff --git a/include/exec/ioport.h b/include/exec/ioport.h new file mode 100644 index 0000000000..fc28350a3c --- /dev/null +++ b/include/exec/ioport.h @@ -0,0 +1,78 @@ +/* + * defines ioport related functions + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/************************************************************************** + * IO ports API + */ + +#ifndef IOPORT_H +#define IOPORT_H + +#include "qemu-common.h" +#include "exec/iorange.h" + +typedef uint32_t pio_addr_t; +#define FMT_pioaddr PRIx32 + +#define MAX_IOPORTS (64 * 1024) +#define IOPORTS_MASK (MAX_IOPORTS - 1) + +/* These should really be in isa.h, but are here to make pc.h happy. */ +typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); +typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); +typedef void (IOPortDestructor)(void *opaque); + +void ioport_register(IORange *iorange); +int register_ioport_read(pio_addr_t start, int length, int size, + IOPortReadFunc *func, void *opaque); +int register_ioport_write(pio_addr_t start, int length, int size, + IOPortWriteFunc *func, void *opaque); +void isa_unassign_ioport(pio_addr_t start, int length); +bool isa_is_ioport_assigned(pio_addr_t start); + +void cpu_outb(pio_addr_t addr, uint8_t val); +void cpu_outw(pio_addr_t addr, uint16_t val); +void cpu_outl(pio_addr_t addr, uint32_t val); +uint8_t cpu_inb(pio_addr_t addr); +uint16_t cpu_inw(pio_addr_t addr); +uint32_t cpu_inl(pio_addr_t addr); + +struct MemoryRegion; +struct MemoryRegionPortio; + +typedef struct PortioList { + const struct MemoryRegionPortio *ports; + struct MemoryRegion *address_space; + unsigned nr; + struct MemoryRegion **regions; + struct MemoryRegion **aliases; + void *opaque; + const char *name; +} PortioList; + +void portio_list_init(PortioList *piolist, + const struct MemoryRegionPortio *callbacks, + void *opaque, const char *name); +void portio_list_destroy(PortioList *piolist); +void portio_list_add(PortioList *piolist, + struct MemoryRegion *address_space, + uint32_t addr); +void portio_list_del(PortioList *piolist); + +#endif /* IOPORT_H */ diff --git a/include/exec/iorange.h b/include/exec/iorange.h new file mode 100644 index 0000000000..cd980a8312 --- /dev/null +++ b/include/exec/iorange.h @@ -0,0 +1,31 @@ +#ifndef IORANGE_H +#define IORANGE_H + +#include + +typedef struct IORange IORange; +typedef struct IORangeOps IORangeOps; + +struct IORangeOps { + void (*read)(IORange *iorange, uint64_t offset, unsigned width, + uint64_t *data); + void (*write)(IORange *iorange, uint64_t offset, unsigned width, + uint64_t data); + void (*destructor)(IORange *iorange); +}; + +struct IORange { + const IORangeOps *ops; + uint64_t base; + uint64_t len; +}; + +static inline void iorange_init(IORange *iorange, const IORangeOps *ops, + uint64_t base, uint64_t len) +{ + iorange->ops = ops; + iorange->base = base; + iorange->len = len; +} + +#endif diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h new file mode 100644 index 0000000000..1da240039d --- /dev/null +++ b/include/exec/memory-internal.h @@ -0,0 +1,141 @@ +/* + * Declarations for obsolete exec.c functions + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + * + */ + +/* + * This header is for use by exec.c and memory.c ONLY. Do not include it. + * The functions declared here will be removed soon. + */ + +#ifndef MEMORY_INTERNAL_H +#define MEMORY_INTERNAL_H + +#ifndef CONFIG_USER_ONLY +#include "hw/xen.h" + +typedef struct PhysPageEntry PhysPageEntry; + +struct PhysPageEntry { + uint16_t is_leaf : 1; + /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */ + uint16_t ptr : 15; +}; + +typedef struct AddressSpaceDispatch AddressSpaceDispatch; + +struct AddressSpaceDispatch { + /* This is a multi-level map on the physical address space. + * The bottom level has pointers to MemoryRegionSections. + */ + PhysPageEntry phys_map; + MemoryListener listener; +}; + +void address_space_init_dispatch(AddressSpace *as); +void address_space_destroy_dispatch(AddressSpace *as); + +ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, + MemoryRegion *mr); +ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); +void qemu_ram_free(ram_addr_t addr); +void qemu_ram_free_from_ptr(ram_addr_t addr); + +struct MemoryRegion; +struct MemoryRegionSection; + +void qemu_register_coalesced_mmio(hwaddr addr, ram_addr_t size); +void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size); + +#define VGA_DIRTY_FLAG 0x01 +#define CODE_DIRTY_FLAG 0x02 +#define MIGRATION_DIRTY_FLAG 0x08 + +static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) +{ + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; +} + +/* read dirty bit (return 0 or 1) */ +static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) +{ + return cpu_physical_memory_get_dirty_flags(addr) == 0xff; +} + +static inline int cpu_physical_memory_get_dirty(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + int ret = 0; + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; + } + return ret; +} + +static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, + int dirty_flags) +{ + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; +} + +static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) +{ + cpu_physical_memory_set_dirty_flags(addr, 0xff); +} + +static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, + int dirty_flags) +{ + int mask = ~dirty_flags; + + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; +} + +static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + cpu_physical_memory_set_dirty_flags(addr, dirty_flags); + } + xen_modified_memory(addr, length); +} + +static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); + } +} + +void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, + int dirty_flags); + +extern const IORangeOps memory_region_iorange_ops; + +#endif + +#endif diff --git a/include/exec/memory.h b/include/exec/memory.h new file mode 100644 index 0000000000..b0c474584f --- /dev/null +++ b/include/exec/memory.h @@ -0,0 +1,882 @@ +/* + * Physical memory management API + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef MEMORY_H +#define MEMORY_H + +#ifndef CONFIG_USER_ONLY + +#include +#include +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "exec/hwaddr.h" +#include "qemu-queue.h" +#include "exec/iorange.h" +#include "exec/ioport.h" +#include "int128.h" + +typedef struct MemoryRegionOps MemoryRegionOps; +typedef struct MemoryRegion MemoryRegion; +typedef struct MemoryRegionPortio MemoryRegionPortio; +typedef struct MemoryRegionMmio MemoryRegionMmio; + +/* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic + * registration. + */ +#define DIRTY_MEMORY_VGA 0 +#define DIRTY_MEMORY_CODE 1 +#define DIRTY_MEMORY_MIGRATION 3 + +struct MemoryRegionMmio { + CPUReadMemoryFunc *read[3]; + CPUWriteMemoryFunc *write[3]; +}; + +/* Internal use; thunks between old-style IORange and MemoryRegions. */ +typedef struct MemoryRegionIORange MemoryRegionIORange; +struct MemoryRegionIORange { + IORange iorange; + MemoryRegion *mr; + hwaddr offset; +}; + +/* + * Memory region callbacks + */ +struct MemoryRegionOps { + /* Read from the memory region. @addr is relative to @mr; @size is + * in bytes. */ + uint64_t (*read)(void *opaque, + hwaddr addr, + unsigned size); + /* Write to the memory region. @addr is relative to @mr; @size is + * in bytes. */ + void (*write)(void *opaque, + hwaddr addr, + uint64_t data, + unsigned size); + + enum device_endian endianness; + /* Guest-visible constraints: */ + struct { + /* If nonzero, specify bounds on access sizes beyond which a machine + * check is thrown. + */ + unsigned min_access_size; + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise unaligned + * accesses throw machine checks. + */ + bool unaligned; + /* + * If present, and returns #false, the transaction is not accepted + * by the device (and results in machine dependent behaviour such + * as a machine check exception). + */ + bool (*accepts)(void *opaque, hwaddr addr, + unsigned size, bool is_write); + } valid; + /* Internal implementation constraints: */ + struct { + /* If nonzero, specifies the minimum size implemented. Smaller sizes + * will be rounded upwards and a partial result will be returned. + */ + unsigned min_access_size; + /* If nonzero, specifies the maximum size implemented. Larger sizes + * will be done as a series of accesses with smaller sizes. + */ + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise all accesses + * are converted to (possibly multiple) naturally aligned accesses. + */ + bool unaligned; + } impl; + + /* If .read and .write are not present, old_portio may be used for + * backwards compatibility with old portio registration + */ + const MemoryRegionPortio *old_portio; + /* If .read and .write are not present, old_mmio may be used for + * backwards compatibility with old mmio registration + */ + const MemoryRegionMmio old_mmio; +}; + +typedef struct CoalescedMemoryRange CoalescedMemoryRange; +typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; + +struct MemoryRegion { + /* All fields are private - violators will be prosecuted */ + const MemoryRegionOps *ops; + void *opaque; + MemoryRegion *parent; + Int128 size; + hwaddr addr; + void (*destructor)(MemoryRegion *mr); + ram_addr_t ram_addr; + bool subpage; + bool terminates; + bool readable; + bool ram; + bool readonly; /* For RAM regions */ + bool enabled; + bool rom_device; + bool warning_printed; /* For reservations */ + bool flush_coalesced_mmio; + MemoryRegion *alias; + hwaddr alias_offset; + unsigned priority; + bool may_overlap; + QTAILQ_HEAD(subregions, MemoryRegion) subregions; + QTAILQ_ENTRY(MemoryRegion) subregions_link; + QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; + const char *name; + uint8_t dirty_log_mask; + unsigned ioeventfd_nb; + MemoryRegionIoeventfd *ioeventfds; +}; + +struct MemoryRegionPortio { + uint32_t offset; + uint32_t len; + unsigned size; + IOPortReadFunc *read; + IOPortWriteFunc *write; +}; + +#define PORTIO_END_OF_LIST() { } + +typedef struct AddressSpace AddressSpace; + +/** + * AddressSpace: describes a mapping of addresses to #MemoryRegion objects + */ +struct AddressSpace { + /* All fields are private. */ + const char *name; + MemoryRegion *root; + struct FlatView *current_map; + int ioeventfd_nb; + struct MemoryRegionIoeventfd *ioeventfds; + struct AddressSpaceDispatch *dispatch; + QTAILQ_ENTRY(AddressSpace) address_spaces_link; +}; + +typedef struct MemoryRegionSection MemoryRegionSection; + +/** + * MemoryRegionSection: describes a fragment of a #MemoryRegion + * + * @mr: the region, or %NULL if empty + * @address_space: the address space the region is mapped in + * @offset_within_region: the beginning of the section, relative to @mr's start + * @size: the size of the section; will not exceed @mr's boundaries + * @offset_within_address_space: the address of the first byte of the section + * relative to the region's address space + * @readonly: writes to this section are ignored + */ +struct MemoryRegionSection { + MemoryRegion *mr; + AddressSpace *address_space; + hwaddr offset_within_region; + uint64_t size; + hwaddr offset_within_address_space; + bool readonly; +}; + +typedef struct MemoryListener MemoryListener; + +/** + * MemoryListener: callbacks structure for updates to the physical memory map + * + * Allows a component to adjust to changes in the guest-visible memory map. + * Use with memory_listener_register() and memory_listener_unregister(). + */ +struct MemoryListener { + void (*begin)(MemoryListener *listener); + void (*commit)(MemoryListener *listener); + void (*region_add)(MemoryListener *listener, MemoryRegionSection *section); + void (*region_del)(MemoryListener *listener, MemoryRegionSection *section); + void (*region_nop)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_start)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_global_start)(MemoryListener *listener); + void (*log_global_stop)(MemoryListener *listener); + void (*eventfd_add)(MemoryListener *listener, MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e); + void (*eventfd_del)(MemoryListener *listener, MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e); + void (*coalesced_mmio_add)(MemoryListener *listener, MemoryRegionSection *section, + hwaddr addr, hwaddr len); + void (*coalesced_mmio_del)(MemoryListener *listener, MemoryRegionSection *section, + hwaddr addr, hwaddr len); + /* Lower = earlier (during add), later (during del) */ + unsigned priority; + AddressSpace *address_space_filter; + QTAILQ_ENTRY(MemoryListener) link; +}; + +/** + * memory_region_init: Initialize a memory region + * + * The region typically acts as a container for other memory regions. Use + * memory_region_add_subregion() to add subregions. + * + * @mr: the #MemoryRegion to be initialized + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region; any subregions beyond this size will be clipped + */ +void memory_region_init(MemoryRegion *mr, + const char *name, + uint64_t size); +/** + * memory_region_init_io: Initialize an I/O memory region. + * + * Accesses into the region will cause the callbacks in @ops to be called. + * if @size is nonzero, subregions will be clipped to @size. + * + * @mr: the #MemoryRegion to be initialized. + * @ops: a structure containing read and write callbacks to be used when + * I/O is performed on the region. + * @opaque: passed to to the read and write callbacks of the @ops structure. + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region. + */ +void memory_region_init_io(MemoryRegion *mr, + const MemoryRegionOps *ops, + void *opaque, + const char *name, + uint64_t size); + +/** + * memory_region_init_ram: Initialize RAM memory region. Accesses into the + * region will modify memory directly. + * + * @mr: the #MemoryRegion to be initialized. + * @name: the name of the region. + * @size: size of the region. + */ +void memory_region_init_ram(MemoryRegion *mr, + const char *name, + uint64_t size); + +/** + * memory_region_init_ram_ptr: Initialize RAM memory region from a + * user-provided pointer. Accesses into the + * region will modify memory directly. + * + * @mr: the #MemoryRegion to be initialized. + * @name: the name of the region. + * @size: size of the region. + * @ptr: memory to be mapped; must contain at least @size bytes. + */ +void memory_region_init_ram_ptr(MemoryRegion *mr, + const char *name, + uint64_t size, + void *ptr); + +/** + * memory_region_init_alias: Initialize a memory region that aliases all or a + * part of another memory region. + * + * @mr: the #MemoryRegion to be initialized. + * @name: used for debugging; not visible to the user or ABI + * @orig: the region to be referenced; @mr will be equivalent to + * @orig between @offset and @offset + @size - 1. + * @offset: start of the section in @orig to be referenced. + * @size: size of the region. + */ +void memory_region_init_alias(MemoryRegion *mr, + const char *name, + MemoryRegion *orig, + hwaddr offset, + uint64_t size); + +/** + * memory_region_init_rom_device: Initialize a ROM memory region. Writes are + * handled via callbacks. + * + * @mr: the #MemoryRegion to be initialized. + * @ops: callbacks for write access handling. + * @name: the name of the region. + * @size: size of the region. + */ +void memory_region_init_rom_device(MemoryRegion *mr, + const MemoryRegionOps *ops, + void *opaque, + const char *name, + uint64_t size); + +/** + * memory_region_init_reservation: Initialize a memory region that reserves + * I/O space. + * + * A reservation region primariy serves debugging purposes. It claims I/O + * space that is not supposed to be handled by QEMU itself. Any access via + * the memory API will cause an abort(). + * + * @mr: the #MemoryRegion to be initialized + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region. + */ +void memory_region_init_reservation(MemoryRegion *mr, + const char *name, + uint64_t size); +/** + * memory_region_destroy: Destroy a memory region and reclaim all resources. + * + * @mr: the region to be destroyed. May not currently be a subregion + * (see memory_region_add_subregion()) or referenced in an alias + * (see memory_region_init_alias()). + */ +void memory_region_destroy(MemoryRegion *mr); + +/** + * memory_region_size: get a memory region's size. + * + * @mr: the memory region being queried. + */ +uint64_t memory_region_size(MemoryRegion *mr); + +/** + * memory_region_is_ram: check whether a memory region is random access + * + * Returns %true is a memory region is random access. + * + * @mr: the memory region being queried + */ +bool memory_region_is_ram(MemoryRegion *mr); + +/** + * memory_region_is_romd: check whether a memory region is ROMD + * + * Returns %true is a memory region is ROMD and currently set to allow + * direct reads. + * + * @mr: the memory region being queried + */ +static inline bool memory_region_is_romd(MemoryRegion *mr) +{ + return mr->rom_device && mr->readable; +} + +/** + * memory_region_name: get a memory region's name + * + * Returns the string that was used to initialize the memory region. + * + * @mr: the memory region being queried + */ +const char *memory_region_name(MemoryRegion *mr); + +/** + * memory_region_is_logging: return whether a memory region is logging writes + * + * Returns %true if the memory region is logging writes + * + * @mr: the memory region being queried + */ +bool memory_region_is_logging(MemoryRegion *mr); + +/** + * memory_region_is_rom: check whether a memory region is ROM + * + * Returns %true is a memory region is read-only memory. + * + * @mr: the memory region being queried + */ +bool memory_region_is_rom(MemoryRegion *mr); + +/** + * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. + * + * Returns a host pointer to a RAM memory region (created with + * memory_region_init_ram() or memory_region_init_ram_ptr()). Use with + * care. + * + * @mr: the memory region being queried. + */ +void *memory_region_get_ram_ptr(MemoryRegion *mr); + +/** + * memory_region_set_log: Turn dirty logging on or off for a region. + * + * Turns dirty logging on or off for a specified client (display, migration). + * Only meaningful for RAM regions. + * + * @mr: the memory region being updated. + * @log: whether dirty logging is to be enabled or disabled. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client); + +/** + * memory_region_get_dirty: Check whether a range of bytes is dirty + * for a specified client. + * + * Checks whether a range of bytes has been written to since the last + * call to memory_region_reset_dirty() with the same @client. Dirty logging + * must be enabled. + * + * @mr: the memory region being queried. + * @addr: the address (relative to the start of the region) being queried. + * @size: the size of the range being queried. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +bool memory_region_get_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size, unsigned client); + +/** + * memory_region_set_dirty: Mark a range of bytes as dirty in a memory region. + * + * Marks a range of bytes as dirty, after it has been dirtied outside + * guest code. + * + * @mr: the memory region being dirtied. + * @addr: the address (relative to the start of the region) being dirtied. + * @size: size of the range being dirtied. + */ +void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size); + +/** + * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap with + * any external TLBs (e.g. kvm) + * + * Flushes dirty information from accelerators such as kvm and vhost-net + * and makes it available to users of the memory API. + * + * @mr: the region being flushed. + */ +void memory_region_sync_dirty_bitmap(MemoryRegion *mr); + +/** + * memory_region_reset_dirty: Mark a range of pages as clean, for a specified + * client. + * + * Marks a range of pages as no longer dirty. + * + * @mr: the region being updated. + * @addr: the start of the subrange being cleaned. + * @size: the size of the subrange being cleaned. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size, unsigned client); + +/** + * memory_region_set_readonly: Turn a memory region read-only (or read-write) + * + * Allows a memory region to be marked as read-only (turning it into a ROM). + * only useful on RAM regions. + * + * @mr: the region being updated. + * @readonly: whether rhe region is to be ROM or RAM. + */ +void memory_region_set_readonly(MemoryRegion *mr, bool readonly); + +/** + * memory_region_rom_device_set_readable: enable/disable ROM readability + * + * Allows a ROM device (initialized with memory_region_init_rom_device() to + * to be marked as readable (default) or not readable. When it is readable, + * the device is mapped to guest memory. When not readable, reads are + * forwarded to the #MemoryRegion.read function. + * + * @mr: the memory region to be updated + * @readable: whether reads are satisified directly (%true) or via callbacks + * (%false) + */ +void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable); + +/** + * memory_region_set_coalescing: Enable memory coalescing for the region. + * + * Enabled writes to a region to be queued for later processing. MMIO ->write + * callbacks may be delayed until a non-coalesced MMIO is issued. + * Only useful for IO regions. Roughly similar to write-combining hardware. + * + * @mr: the memory region to be write coalesced + */ +void memory_region_set_coalescing(MemoryRegion *mr); + +/** + * memory_region_add_coalescing: Enable memory coalescing for a sub-range of + * a region. + * + * Like memory_region_set_coalescing(), but works on a sub-range of a region. + * Multiple calls can be issued coalesced disjoint ranges. + * + * @mr: the memory region to be updated. + * @offset: the start of the range within the region to be coalesced. + * @size: the size of the subrange to be coalesced. + */ +void memory_region_add_coalescing(MemoryRegion *mr, + hwaddr offset, + uint64_t size); + +/** + * memory_region_clear_coalescing: Disable MMIO coalescing for the region. + * + * Disables any coalescing caused by memory_region_set_coalescing() or + * memory_region_add_coalescing(). Roughly equivalent to uncacheble memory + * hardware. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_coalescing(MemoryRegion *mr); + +/** + * memory_region_set_flush_coalesced: Enforce memory coalescing flush before + * accesses. + * + * Ensure that pending coalesced MMIO request are flushed before the memory + * region is accessed. This property is automatically enabled for all regions + * passed to memory_region_set_coalescing() and memory_region_add_coalescing(). + * + * @mr: the memory region to be updated. + */ +void memory_region_set_flush_coalesced(MemoryRegion *mr); + +/** + * memory_region_clear_flush_coalesced: Disable memory coalescing flush before + * accesses. + * + * Clear the automatic coalesced MMIO flushing enabled via + * memory_region_set_flush_coalesced. Note that this service has no effect on + * memory regions that have MMIO coalescing enabled for themselves. For them, + * automatic flushing will stop once coalescing is disabled. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_flush_coalesced(MemoryRegion *mr); + +/** + * memory_region_add_eventfd: Request an eventfd to be triggered when a word + * is written to a location. + * + * Marks a word in an IO region (initialized with memory_region_init_io()) + * as a trigger for an eventfd event. The I/O callback will not be called. + * The caller must be prepared to handle failure (that is, take the required + * action if the callback _is_ called). + * + * @mr: the memory region being updated. + * @addr: the address within @mr that is to be monitored + * @size: the size of the access to trigger the eventfd + * @match_data: whether to match against @data, instead of just @addr + * @data: the data to match against the guest write + * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + **/ +void memory_region_add_eventfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + bool match_data, + uint64_t data, + EventNotifier *e); + +/** + * memory_region_del_eventfd: Cancel an eventfd. + * + * Cancels an eventfd trigger requested by a previous + * memory_region_add_eventfd() call. + * + * @mr: the memory region being updated. + * @addr: the address within @mr that is to be monitored + * @size: the size of the access to trigger the eventfd + * @match_data: whether to match against @data, instead of just @addr + * @data: the data to match against the guest write + * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + */ +void memory_region_del_eventfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + bool match_data, + uint64_t data, + EventNotifier *e); + +/** + * memory_region_add_subregion: Add a subregion to a container. + * + * Adds a subregion at @offset. The subregion may not overlap with other + * subregions (except for those explicitly marked as overlapping). A region + * may only be added once as a subregion (unless removed with + * memory_region_del_subregion()); use memory_region_init_alias() if you + * want a region to be a subregion in multiple locations. + * + * @mr: the region to contain the new subregion; must be a container + * initialized with memory_region_init(). + * @offset: the offset relative to @mr where @subregion is added. + * @subregion: the subregion to be added. + */ +void memory_region_add_subregion(MemoryRegion *mr, + hwaddr offset, + MemoryRegion *subregion); +/** + * memory_region_add_subregion_overlap: Add a subregion to a container + * with overlap. + * + * Adds a subregion at @offset. The subregion may overlap with other + * subregions. Conflicts are resolved by having a higher @priority hide a + * lower @priority. Subregions without priority are taken as @priority 0. + * A region may only be added once as a subregion (unless removed with + * memory_region_del_subregion()); use memory_region_init_alias() if you + * want a region to be a subregion in multiple locations. + * + * @mr: the region to contain the new subregion; must be a container + * initialized with memory_region_init(). + * @offset: the offset relative to @mr where @subregion is added. + * @subregion: the subregion to be added. + * @priority: used for resolving overlaps; highest priority wins. + */ +void memory_region_add_subregion_overlap(MemoryRegion *mr, + hwaddr offset, + MemoryRegion *subregion, + unsigned priority); + +/** + * memory_region_get_ram_addr: Get the ram address associated with a memory + * region + * + * DO NOT USE THIS FUNCTION. This is a temporary workaround while the Xen + * code is being reworked. + */ +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr); + +/** + * memory_region_del_subregion: Remove a subregion. + * + * Removes a subregion from its container. + * + * @mr: the container to be updated. + * @subregion: the region being removed; must be a current subregion of @mr. + */ +void memory_region_del_subregion(MemoryRegion *mr, + MemoryRegion *subregion); + +/* + * memory_region_set_enabled: dynamically enable or disable a region + * + * Enables or disables a memory region. A disabled memory region + * ignores all accesses to itself and its subregions. It does not + * obscure sibling subregions with lower priority - it simply behaves as + * if it was removed from the hierarchy. + * + * Regions default to being enabled. + * + * @mr: the region to be updated + * @enabled: whether to enable or disable the region + */ +void memory_region_set_enabled(MemoryRegion *mr, bool enabled); + +/* + * memory_region_set_address: dynamically update the address of a region + * + * Dynamically updates the address of a region, relative to its parent. + * May be used on regions are currently part of a memory hierarchy. + * + * @mr: the region to be updated + * @addr: new address, relative to parent region + */ +void memory_region_set_address(MemoryRegion *mr, hwaddr addr); + +/* + * memory_region_set_alias_offset: dynamically update a memory alias's offset + * + * Dynamically updates the offset into the target region that an alias points + * to, as if the fourth argument to memory_region_init_alias() has changed. + * + * @mr: the #MemoryRegion to be updated; should be an alias. + * @offset: the new offset into the target memory region + */ +void memory_region_set_alias_offset(MemoryRegion *mr, + hwaddr offset); + +/** + * memory_region_find: locate a MemoryRegion in an address space + * + * Locates the first #MemoryRegion within an address space given by + * @address_space that overlaps the range given by @addr and @size. + * + * Returns a #MemoryRegionSection that describes a contiguous overlap. + * It will have the following characteristics: + * .@offset_within_address_space >= @addr + * .@offset_within_address_space + .@size <= @addr + @size + * .@size = 0 iff no overlap was found + * .@mr is non-%NULL iff an overlap was found + * + * @address_space: a top-level (i.e. parentless) region that contains + * the region to be found + * @addr: start of the area within @address_space to be searched + * @size: size of the area to be searched + */ +MemoryRegionSection memory_region_find(MemoryRegion *address_space, + hwaddr addr, uint64_t size); + +/** + * memory_region_section_addr: get offset within MemoryRegionSection + * + * Returns offset within MemoryRegionSection + * + * @section: the memory region section being queried + * @addr: address in address space + */ +static inline hwaddr +memory_region_section_addr(MemoryRegionSection *section, + hwaddr addr) +{ + addr -= section->offset_within_address_space; + addr += section->offset_within_region; + return addr; +} + +/** + * memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory + * + * Synchronizes the dirty page log for an entire address space. + * @address_space: a top-level (i.e. parentless) region that contains the + * memory being synchronized + */ +void memory_global_sync_dirty_bitmap(MemoryRegion *address_space); + +/** + * memory_region_transaction_begin: Start a transaction. + * + * During a transaction, changes will be accumulated and made visible + * only when the transaction ends (is committed). + */ +void memory_region_transaction_begin(void); + +/** + * memory_region_transaction_commit: Commit a transaction and make changes + * visible to the guest. + */ +void memory_region_transaction_commit(void); + +/** + * memory_listener_register: register callbacks to be called when memory + * sections are mapped or unmapped into an address + * space + * + * @listener: an object containing the callbacks to be called + * @filter: if non-%NULL, only regions in this address space will be observed + */ +void memory_listener_register(MemoryListener *listener, AddressSpace *filter); + +/** + * memory_listener_unregister: undo the effect of memory_listener_register() + * + * @listener: an object containing the callbacks to be removed + */ +void memory_listener_unregister(MemoryListener *listener); + +/** + * memory_global_dirty_log_start: begin dirty logging for all regions + */ +void memory_global_dirty_log_start(void); + +/** + * memory_global_dirty_log_stop: end dirty logging for all regions + */ +void memory_global_dirty_log_stop(void); + +void mtree_info(fprintf_function mon_printf, void *f); + +/** + * address_space_init: initializes an address space + * + * @as: an uninitialized #AddressSpace + * @root: a #MemoryRegion that routes addesses for the address space + */ +void address_space_init(AddressSpace *as, MemoryRegion *root); + + +/** + * address_space_destroy: destroy an address space + * + * Releases all resources associated with an address space. After an address space + * is destroyed, its root memory region (given by address_space_init()) may be destroyed + * as well. + * + * @as: address space to be destroyed + */ +void address_space_destroy(AddressSpace *as); + +/** + * address_space_rw: read from or write to an address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + * @is_write: indicates the transfer direction + */ +void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, + int len, bool is_write); + +/** + * address_space_write: write to address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + */ +void address_space_write(AddressSpace *as, hwaddr addr, + const uint8_t *buf, int len); + +/** + * address_space_read: read from an address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + */ +void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); + +/* address_space_map: map a physical memory region into a host virtual address + * + * May map a subset of the requested range, given by and returned in @plen. + * May return %NULL if resources needed to perform the mapping are exhausted. + * Use only for reads OR writes - not for read-modify-write operations. + * Use cpu_register_map_client() to know when retrying the map operation is + * likely to succeed. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @plen: pointer to length of buffer; updated on return + * @is_write: indicates the transfer direction + */ +void *address_space_map(AddressSpace *as, hwaddr addr, + hwaddr *plen, bool is_write); + +/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() + * + * Will also mark the memory as dirty if @is_write == %true. @access_len gives + * the amount of memory that was actually read or written by the caller. + * + * @as: #AddressSpace used + * @addr: address within that address space + * @len: buffer length as returned by address_space_map() + * @access_len: amount of data actually transferred + * @is_write: indicates the transfer direction + */ +void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, + int is_write, hwaddr access_len); + + +#endif + +#endif diff --git a/include/exec/poison.h b/include/exec/poison.h new file mode 100644 index 0000000000..7d7b23b1fc --- /dev/null +++ b/include/exec/poison.h @@ -0,0 +1,64 @@ +/* Poison identifiers that should not be used when building + target independent device code. */ + +#ifndef HW_POISON_H +#define HW_POISON_H +#ifdef __GNUC__ + +#pragma GCC poison TARGET_I386 +#pragma GCC poison TARGET_X86_64 +#pragma GCC poison TARGET_ALPHA +#pragma GCC poison TARGET_ARM +#pragma GCC poison TARGET_CRIS +#pragma GCC poison TARGET_LM32 +#pragma GCC poison TARGET_M68K +#pragma GCC poison TARGET_MIPS +#pragma GCC poison TARGET_MIPS64 +#pragma GCC poison TARGET_OPENRISC +#pragma GCC poison TARGET_PPC +#pragma GCC poison TARGET_PPCEMB +#pragma GCC poison TARGET_PPC64 +#pragma GCC poison TARGET_ABI32 +#pragma GCC poison TARGET_SH4 +#pragma GCC poison TARGET_SPARC +#pragma GCC poison TARGET_SPARC64 + +#pragma GCC poison TARGET_WORDS_BIGENDIAN +#pragma GCC poison BSWAP_NEEDED + +#pragma GCC poison TARGET_LONG_BITS +#pragma GCC poison TARGET_FMT_lx +#pragma GCC poison TARGET_FMT_ld + +#pragma GCC poison TARGET_PAGE_SIZE +#pragma GCC poison TARGET_PAGE_MASK +#pragma GCC poison TARGET_PAGE_BITS +#pragma GCC poison TARGET_PAGE_ALIGN + +#pragma GCC poison CPUArchState +#pragma GCC poison env + +#pragma GCC poison lduw_phys +#pragma GCC poison ldl_phys +#pragma GCC poison ldq_phys +#pragma GCC poison stl_phys_notdirty +#pragma GCC poison stq_phys_notdirty +#pragma GCC poison stw_phys +#pragma GCC poison stl_phys +#pragma GCC poison stq_phys + +#pragma GCC poison CPU_INTERRUPT_HARD +#pragma GCC poison CPU_INTERRUPT_EXITTB +#pragma GCC poison CPU_INTERRUPT_HALT +#pragma GCC poison CPU_INTERRUPT_DEBUG +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 + +#endif +#endif diff --git a/include/exec/softmmu-semi.h b/include/exec/softmmu-semi.h new file mode 100644 index 0000000000..93798b9614 --- /dev/null +++ b/include/exec/softmmu-semi.h @@ -0,0 +1,77 @@ +/* + * Helper routines to provide target memory access for semihosting + * syscalls in system emulation mode. + * + * Copyright (c) 2007 CodeSourcery. + * + * This code is licensed under the GPL + */ +#ifndef SOFTMMU_SEMI_H +#define SOFTMMU_SEMI_H 1 + +static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr) +{ + uint32_t val; + + cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0); + return tswap32(val); +} +static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr) +{ + uint8_t val; + + cpu_memory_rw_debug(env, addr, &val, 1, 0); + return val; +} + +#define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; }) +#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; }) +#define get_user_ual(arg, p) get_user_u32(arg, p) + +static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val) +{ + val = tswap32(val); + cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1); +} +#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; }) +#define put_user_ual(arg, p) put_user_u32(arg, p) + +static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len, + int copy) +{ + uint8_t *p; + /* TODO: Make this something that isn't fixed size. */ + p = malloc(len); + if (p && copy) + cpu_memory_rw_debug(env, addr, p, len, 0); + return p; +} +#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) +static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr) +{ + char *p; + char *s; + uint8_t c; + /* TODO: Make this something that isn't fixed size. */ + s = p = malloc(1024); + if (!s) { + return NULL; + } + do { + cpu_memory_rw_debug(env, addr, &c, 1, 0); + addr++; + *(p++) = c; + } while (c); + return s; +} +#define lock_user_string(p) softmmu_lock_user_string(env, p) +static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, + target_ulong len) +{ + if (len) + cpu_memory_rw_debug(env, addr, p, len, 1); + free(p); +} +#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) + +#endif diff --git a/include/exec/softmmu_defs.h b/include/exec/softmmu_defs.h new file mode 100644 index 0000000000..1f25e33ce4 --- /dev/null +++ b/include/exec/softmmu_defs.h @@ -0,0 +1,37 @@ +/* + * Software MMU support + * + * Declare helpers used by TCG for qemu_ld/st ops. + * + * Used by softmmu_exec.h, TCG targets and exec-all.h. + * + */ +#ifndef SOFTMMU_DEFS_H +#define SOFTMMU_DEFS_H + +uint8_t helper_ldb_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, + int mmu_idx); +uint16_t helper_ldw_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, + int mmu_idx); +uint32_t helper_ldl_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, + int mmu_idx); +uint64_t helper_ldq_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, + int mmu_idx); + +uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stb_cmmu(CPUArchState *env, target_ulong addr, uint8_t val, +int mmu_idx); +uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stw_cmmu(CPUArchState *env, target_ulong addr, uint16_t val, + int mmu_idx); +uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stl_cmmu(CPUArchState *env, target_ulong addr, uint32_t val, + int mmu_idx); +uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stq_cmmu(CPUArchState *env, target_ulong addr, uint64_t val, + int mmu_idx); +#endif diff --git a/include/exec/softmmu_exec.h b/include/exec/softmmu_exec.h new file mode 100644 index 0000000000..3e4e886a30 --- /dev/null +++ b/include/exec/softmmu_exec.h @@ -0,0 +1,163 @@ +/* + * Software MMU support + * + * Generate inline load/store functions for all MMU modes (typically + * at least _user and _kernel) as well as _data versions, for all data + * sizes. + * + * Used by target op helpers. + * + * MMU mode suffixes are defined in target cpu.h. + */ + +/* XXX: find something cleaner. + * Furthermore, this is false for 64 bits targets + */ +#define ldul_user ldl_user +#define ldul_kernel ldl_kernel +#define ldul_hypv ldl_hypv +#define ldul_executive ldl_executive +#define ldul_supervisor ldl_supervisor + +#include "exec/softmmu_defs.h" + +#define ACCESS_TYPE 0 +#define MEMSUFFIX MMU_MODE0_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#define ACCESS_TYPE 1 +#define MEMSUFFIX MMU_MODE1_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#if (NB_MMU_MODES >= 3) + +#define ACCESS_TYPE 2 +#define MEMSUFFIX MMU_MODE2_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 3) */ + +#if (NB_MMU_MODES >= 4) + +#define ACCESS_TYPE 3 +#define MEMSUFFIX MMU_MODE3_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ + +#if (NB_MMU_MODES >= 5) + +#define ACCESS_TYPE 4 +#define MEMSUFFIX MMU_MODE4_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 5) */ + +#if (NB_MMU_MODES >= 6) + +#define ACCESS_TYPE 5 +#define MEMSUFFIX MMU_MODE5_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 6) */ + +#if (NB_MMU_MODES > 6) +#error "NB_MMU_MODES > 6 is not supported for now" +#endif /* (NB_MMU_MODES > 6) */ + +/* these access are slower, they must be as rare as possible */ +#define ACCESS_TYPE (NB_MMU_MODES) +#define MEMSUFFIX _data +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#define ldub(p) ldub_data(p) +#define ldsb(p) ldsb_data(p) +#define lduw(p) lduw_data(p) +#define ldsw(p) ldsw_data(p) +#define ldl(p) ldl_data(p) +#define ldq(p) ldq_data(p) + +#define stb(p, v) stb_data(p, v) +#define stw(p, v) stw_data(p, v) +#define stl(p, v) stl_data(p, v) +#define stq(p, v) stq_data(p, v) diff --git a/include/exec/softmmu_header.h b/include/exec/softmmu_header.h new file mode 100644 index 0000000000..d8d9c81b05 --- /dev/null +++ b/include/exec/softmmu_header.h @@ -0,0 +1,213 @@ +/* + * Software MMU support + * + * Generate inline load/store functions for one MMU mode and data + * size. + * + * Generate a store function as well as signed and unsigned loads. For + * 32 and 64 bit cases, also generate floating point functions with + * the same size. + * + * Not used directly but included from softmmu_exec.h and exec-all.h. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#if DATA_SIZE == 8 +#define SUFFIX q +#define USUFFIX q +#define DATA_TYPE uint64_t +#elif DATA_SIZE == 4 +#define SUFFIX l +#define USUFFIX l +#define DATA_TYPE uint32_t +#elif DATA_SIZE == 2 +#define SUFFIX w +#define USUFFIX uw +#define DATA_TYPE uint16_t +#define DATA_STYPE int16_t +#elif DATA_SIZE == 1 +#define SUFFIX b +#define USUFFIX ub +#define DATA_TYPE uint8_t +#define DATA_STYPE int8_t +#else +#error unsupported data size +#endif + +#if ACCESS_TYPE < (NB_MMU_MODES) + +#define CPU_MMU_INDEX ACCESS_TYPE +#define MMUSUFFIX _mmu + +#elif ACCESS_TYPE == (NB_MMU_MODES) + +#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define MMUSUFFIX _mmu + +#elif ACCESS_TYPE == (NB_MMU_MODES + 1) + +#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define MMUSUFFIX _cmmu + +#else +#error invalid ACCESS_TYPE +#endif + +#if DATA_SIZE == 8 +#define RES_TYPE uint64_t +#else +#define RES_TYPE uint32_t +#endif + +#if ACCESS_TYPE == (NB_MMU_MODES + 1) +#define ADDR_READ addr_code +#else +#define ADDR_READ addr_read +#endif + +/* generic load/store macros */ + +static inline RES_TYPE +glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) +{ + int page_index; + RES_TYPE res; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + res = glue(glue(ld, USUFFIX), _raw)(hostaddr); + } + return res; +} + +#if DATA_SIZE <= 2 +static inline int +glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) +{ + int res, page_index; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX), + MMUSUFFIX)(env, addr, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + res = glue(glue(lds, SUFFIX), _raw)(hostaddr); + } + return res; +} +#endif + +#if ACCESS_TYPE != (NB_MMU_MODES + 1) + +/* generic store macro */ + +static inline void +glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr, + RES_TYPE v) +{ + int page_index; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, v, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + glue(glue(st, SUFFIX), _raw)(hostaddr, v); + } +} + +#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ + +#if ACCESS_TYPE != (NB_MMU_MODES + 1) + +#if DATA_SIZE == 8 +static inline float64 glue(cpu_ldfq, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr) +{ + union { + float64 d; + uint64_t i; + } u; + u.i = glue(cpu_ldq, MEMSUFFIX)(env, ptr); + return u.d; +} + +static inline void glue(cpu_stfq, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr, float64 v) +{ + union { + float64 d; + uint64_t i; + } u; + u.d = v; + glue(cpu_stq, MEMSUFFIX)(env, ptr, u.i); +} +#endif /* DATA_SIZE == 8 */ + +#if DATA_SIZE == 4 +static inline float32 glue(cpu_ldfl, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = glue(cpu_ldl, MEMSUFFIX)(env, ptr); + return u.f; +} + +static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + glue(cpu_stl, MEMSUFFIX)(env, ptr, u.i); +} +#endif /* DATA_SIZE == 4 */ + +#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ + +#undef RES_TYPE +#undef DATA_TYPE +#undef DATA_STYPE +#undef SUFFIX +#undef USUFFIX +#undef DATA_SIZE +#undef CPU_MMU_INDEX +#undef MMUSUFFIX +#undef ADDR_READ diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.h new file mode 100644 index 0000000000..15d4c519ee --- /dev/null +++ b/include/exec/softmmu_template.h @@ -0,0 +1,354 @@ +/* + * Software MMU support + * + * Generate helpers used by TCG for qemu_ld/st ops and code load + * functions. + * + * Included from target op helpers and exec.c. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#include "qemu-timer.h" +#include "exec/memory.h" + +#define DATA_SIZE (1 << SHIFT) + +#if DATA_SIZE == 8 +#define SUFFIX q +#define USUFFIX q +#define DATA_TYPE uint64_t +#elif DATA_SIZE == 4 +#define SUFFIX l +#define USUFFIX l +#define DATA_TYPE uint32_t +#elif DATA_SIZE == 2 +#define SUFFIX w +#define USUFFIX uw +#define DATA_TYPE uint16_t +#elif DATA_SIZE == 1 +#define SUFFIX b +#define USUFFIX ub +#define DATA_TYPE uint8_t +#else +#error unsupported data size +#endif + +#ifdef SOFTMMU_CODE_ACCESS +#define READ_ACCESS_TYPE 2 +#define ADDR_READ addr_code +#else +#define READ_ACCESS_TYPE 0 +#define ADDR_READ addr_read +#endif + +static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + int mmu_idx, + uintptr_t retaddr); +static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, + hwaddr physaddr, + target_ulong addr, + uintptr_t retaddr) +{ + DATA_TYPE res; + MemoryRegion *mr = iotlb_to_region(physaddr); + + physaddr = (physaddr & TARGET_PAGE_MASK) + addr; + env->mem_io_pc = retaddr; + if (mr != &io_mem_ram && mr != &io_mem_rom + && mr != &io_mem_unassigned + && mr != &io_mem_notdirty + && !can_do_io(env)) { + cpu_io_recompile(env, retaddr); + } + + env->mem_io_vaddr = addr; +#if SHIFT <= 2 + res = io_mem_read(mr, physaddr, 1 << SHIFT); +#else +#ifdef TARGET_WORDS_BIGENDIAN + res = io_mem_read(mr, physaddr, 4) << 32; + res |= io_mem_read(mr, physaddr + 4, 4); +#else + res = io_mem_read(mr, physaddr, 4); + res |= io_mem_read(mr, physaddr + 4, 4) << 32; +#endif +#endif /* SHIFT > 2 */ + return res; +} + +/* handle all cases except unaligned access which span two pages */ +DATA_TYPE +glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, + int mmu_idx) +{ + DATA_TYPE res; + int index; + target_ulong tlb_addr; + hwaddr ioaddr; + uintptr_t retaddr; + + /* test if there is match for unaligned or IO access */ + /* XXX: could done more in memory macro in a non portable way */ + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + retaddr = GETPC_EXT(); + ioaddr = env->iotlb[mmu_idx][index]; + res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + /* slow unaligned access (it spans two pages or IO) */ + do_unaligned_access: + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); +#endif + res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr, + mmu_idx, retaddr); + } else { + /* unaligned/aligned access in the same page */ + uintptr_t addend; +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) { + retaddr = GETPC_EXT(); + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + } +#endif + addend = env->tlb_table[mmu_idx][index].addend; + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend)); + } + } else { + /* the page is not in the TLB : fill it */ + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); +#endif + tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + goto redo; + } + return res; +} + +/* handle all unaligned cases */ +static DATA_TYPE +glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + int mmu_idx, + uintptr_t retaddr) +{ + DATA_TYPE res, res1, res2; + int index, shift; + hwaddr ioaddr; + target_ulong tlb_addr, addr1, addr2; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + ioaddr = env->iotlb[mmu_idx][index]; + res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + /* slow unaligned access (it spans two pages) */ + addr1 = addr & ~(DATA_SIZE - 1); + addr2 = addr1 + DATA_SIZE; + res1 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr1, + mmu_idx, retaddr); + res2 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr2, + mmu_idx, retaddr); + shift = (addr & (DATA_SIZE - 1)) * 8; +#ifdef TARGET_WORDS_BIGENDIAN + res = (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); +#else + res = (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); +#endif + res = (DATA_TYPE)res; + } else { + /* unaligned/aligned access in the same page */ + uintptr_t addend = env->tlb_table[mmu_idx][index].addend; + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend)); + } + } else { + /* the page is not in the TLB : fill it */ + tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + goto redo; + } + return res; +} + +#ifndef SOFTMMU_CODE_ACCESS + +static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + DATA_TYPE val, + int mmu_idx, + uintptr_t retaddr); + +static inline void glue(io_write, SUFFIX)(CPUArchState *env, + hwaddr physaddr, + DATA_TYPE val, + target_ulong addr, + uintptr_t retaddr) +{ + MemoryRegion *mr = iotlb_to_region(physaddr); + + physaddr = (physaddr & TARGET_PAGE_MASK) + addr; + if (mr != &io_mem_ram && mr != &io_mem_rom + && mr != &io_mem_unassigned + && mr != &io_mem_notdirty + && !can_do_io(env)) { + cpu_io_recompile(env, retaddr); + } + + env->mem_io_vaddr = addr; + env->mem_io_pc = retaddr; +#if SHIFT <= 2 + io_mem_write(mr, physaddr, val, 1 << SHIFT); +#else +#ifdef TARGET_WORDS_BIGENDIAN + io_mem_write(mr, physaddr, (val >> 32), 4); + io_mem_write(mr, physaddr + 4, (uint32_t)val, 4); +#else + io_mem_write(mr, physaddr, (uint32_t)val, 4); + io_mem_write(mr, physaddr + 4, val >> 32, 4); +#endif +#endif /* SHIFT > 2 */ +} + +void glue(glue(helper_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, DATA_TYPE val, + int mmu_idx) +{ + hwaddr ioaddr; + target_ulong tlb_addr; + uintptr_t retaddr; + int index; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + retaddr = GETPC_EXT(); + ioaddr = env->iotlb[mmu_idx][index]; + glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); +#endif + glue(glue(slow_st, SUFFIX), MMUSUFFIX)(env, addr, val, + mmu_idx, retaddr); + } else { + /* aligned/unaligned access in the same page */ + uintptr_t addend; +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) { + retaddr = GETPC_EXT(); + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); + } +#endif + addend = env->tlb_table[mmu_idx][index].addend; + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend), val); + } + } else { + /* the page is not in the TLB : fill it */ + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); +#endif + tlb_fill(env, addr, 1, mmu_idx, retaddr); + goto redo; + } +} + +/* handles all unaligned cases */ +static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + DATA_TYPE val, + int mmu_idx, + uintptr_t retaddr) +{ + hwaddr ioaddr; + target_ulong tlb_addr; + int index, i; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + ioaddr = env->iotlb[mmu_idx][index]; + glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + /* XXX: not efficient, but simple */ + /* Note: relies on the fact that tlb_fill() does not remove the + * previous page from the TLB cache. */ + for(i = DATA_SIZE - 1; i >= 0; i--) { +#ifdef TARGET_WORDS_BIGENDIAN + glue(slow_stb, MMUSUFFIX)(env, addr + i, + val >> (((DATA_SIZE - 1) * 8) - (i * 8)), + mmu_idx, retaddr); +#else + glue(slow_stb, MMUSUFFIX)(env, addr + i, + val >> (i * 8), + mmu_idx, retaddr); +#endif + } + } else { + /* aligned/unaligned access in the same page */ + uintptr_t addend = env->tlb_table[mmu_idx][index].addend; + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend), val); + } + } else { + /* the page is not in the TLB : fill it */ + tlb_fill(env, addr, 1, mmu_idx, retaddr); + goto redo; + } +} + +#endif /* !defined(SOFTMMU_CODE_ACCESS) */ + +#undef READ_ACCESS_TYPE +#undef SHIFT +#undef DATA_TYPE +#undef SUFFIX +#undef USUFFIX +#undef DATA_SIZE +#undef ADDR_READ diff --git a/include/exec/spinlock.h b/include/exec/spinlock.h new file mode 100644 index 0000000000..a72edda1d2 --- /dev/null +++ b/include/exec/spinlock.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +/* configure guarantees us that we have pthreads on any host except + * mingw32, which doesn't support any of the user-only targets. + * So we can simply assume we have pthread mutexes here. + */ +#if defined(CONFIG_USER_ONLY) + +#include +#define spin_lock pthread_mutex_lock +#define spin_unlock pthread_mutex_unlock +#define spinlock_t pthread_mutex_t +#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER + +#else + +/* Empty implementations, on the theory that system mode emulation + * is single-threaded. This means that these functions should only + * be used from code run in the TCG cpu thread, and cannot protect + * data structures which might also be accessed from the IO thread + * or from signal handlers. + */ +typedef int spinlock_t; +#define SPIN_LOCK_UNLOCKED 0 + +static inline void spin_lock(spinlock_t *lock) +{ +} + +static inline void spin_unlock(spinlock_t *lock) +{ +} + +#endif diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h new file mode 100644 index 0000000000..fe7f6624f9 --- /dev/null +++ b/include/exec/user/abitypes.h @@ -0,0 +1,36 @@ +#ifndef QEMU_TYPES_H +#define QEMU_TYPES_H +#include "cpu.h" + +#ifdef TARGET_ABI32 +typedef uint32_t abi_ulong; +typedef int32_t abi_long; +#define TARGET_ABI_FMT_lx "%08x" +#define TARGET_ABI_FMT_ld "%d" +#define TARGET_ABI_FMT_lu "%u" +#define TARGET_ABI_BITS 32 + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswap32(v); +} + +#else +typedef target_ulong abi_ulong; +typedef target_long abi_long; +#define TARGET_ABI_FMT_lx TARGET_FMT_lx +#define TARGET_ABI_FMT_ld TARGET_FMT_ld +#define TARGET_ABI_FMT_lu TARGET_FMT_lu +#define TARGET_ABI_BITS TARGET_LONG_BITS +/* for consistency, define ABI32 too */ +#if TARGET_ABI_BITS == 32 +#define TARGET_ABI32 1 +#endif + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswapl(v); +} + +#endif +#endif diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h new file mode 100644 index 0000000000..87025c3b04 --- /dev/null +++ b/include/exec/user/thunk.h @@ -0,0 +1,189 @@ +/* + * Generic thunking code to convert data between host and target CPU + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef THUNK_H +#define THUNK_H + +#include +#include "cpu.h" + +/* types enums definitions */ + +typedef enum argtype { + TYPE_NULL, + TYPE_CHAR, + TYPE_SHORT, + TYPE_INT, + TYPE_LONG, + TYPE_ULONG, + TYPE_PTRVOID, /* pointer on unknown data */ + TYPE_LONGLONG, + TYPE_ULONGLONG, + TYPE_PTR, + TYPE_ARRAY, + TYPE_STRUCT, + TYPE_OLDDEVT, +} argtype; + +#define MK_PTR(type) TYPE_PTR, type +#define MK_ARRAY(type, size) TYPE_ARRAY, size, type +#define MK_STRUCT(id) TYPE_STRUCT, id + +#define THUNK_TARGET 0 +#define THUNK_HOST 1 + +typedef struct { + /* standard struct handling */ + const argtype *field_types; + int nb_fields; + int *field_offsets[2]; + /* special handling */ + void (*convert[2])(void *dst, const void *src); + int size[2]; + int align[2]; + const char *name; +} StructEntry; + +/* Translation table for bitmasks... */ +typedef struct bitmask_transtbl { + unsigned int x86_mask; + unsigned int x86_bits; + unsigned int alpha_mask; + unsigned int alpha_bits; +} bitmask_transtbl; + +void thunk_register_struct(int id, const char *name, const argtype *types); +void thunk_register_struct_direct(int id, const char *name, + const StructEntry *se1); +const argtype *thunk_convert(void *dst, const void *src, + const argtype *type_ptr, int to_host); +#ifndef NO_THUNK_TYPE_SIZE + +extern StructEntry struct_entries[]; + +int thunk_type_size_array(const argtype *type_ptr, int is_host); +int thunk_type_align_array(const argtype *type_ptr, int is_host); + +static inline int thunk_type_size(const argtype *type_ptr, int is_host) +{ + int type, size; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return sizeof(void *); + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_OLDDEVT: + if (is_host) { +#if defined(HOST_X86_64) + return 8; +#elif defined(HOST_ALPHA) || defined(HOST_IA64) || defined(HOST_MIPS) || \ + defined(HOST_PARISC) || defined(HOST_SPARC64) + return 4; +#elif defined(HOST_PPC) + return sizeof(void *); +#else + return 2; +#endif + } else { +#if defined(TARGET_X86_64) + return 8; +#elif defined(TARGET_ALPHA) || defined(TARGET_IA64) || defined(TARGET_MIPS) || \ + defined(TARGET_PARISC) || defined(TARGET_SPARC64) + return 4; +#elif defined(TARGET_PPC) + return TARGET_ABI_BITS / 8; +#else + return 2; +#endif + } + break; + case TYPE_ARRAY: + size = type_ptr[1]; + return size * thunk_type_size_array(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->size[is_host]; + default: + return -1; + } +} + +static inline int thunk_type_align(const argtype *type_ptr, int is_host) +{ + int type; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return sizeof(void *); + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_OLDDEVT: + return thunk_type_size(type_ptr, is_host); + case TYPE_ARRAY: + return thunk_type_align_array(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->align[is_host]; + default: + return -1; + } +} + +#endif /* NO_THUNK_TYPE_SIZE */ + +unsigned int target_to_host_bitmask(unsigned int x86_mask, + const bitmask_transtbl * trans_tbl); +unsigned int host_to_target_bitmask(unsigned int alpha_mask, + const bitmask_transtbl * trans_tbl); + +#endif diff --git a/ioport.c b/ioport.c index 6e4ca0dd91..a0ac2a0a41 100644 --- a/ioport.c +++ b/ioport.c @@ -25,9 +25,9 @@ * splitted out ioport related stuffs from vl.c. */ -#include "ioport.h" +#include "exec/ioport.h" #include "trace.h" -#include "memory.h" +#include "exec/memory.h" /***********************************************************/ /* IO Port */ diff --git a/ioport.h b/ioport.h deleted file mode 100644 index 23441cba08..0000000000 --- a/ioport.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * defines ioport related functions - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/************************************************************************** - * IO ports API - */ - -#ifndef IOPORT_H -#define IOPORT_H - -#include "qemu-common.h" -#include "iorange.h" - -typedef uint32_t pio_addr_t; -#define FMT_pioaddr PRIx32 - -#define MAX_IOPORTS (64 * 1024) -#define IOPORTS_MASK (MAX_IOPORTS - 1) - -/* These should really be in isa.h, but are here to make pc.h happy. */ -typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); -typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); -typedef void (IOPortDestructor)(void *opaque); - -void ioport_register(IORange *iorange); -int register_ioport_read(pio_addr_t start, int length, int size, - IOPortReadFunc *func, void *opaque); -int register_ioport_write(pio_addr_t start, int length, int size, - IOPortWriteFunc *func, void *opaque); -void isa_unassign_ioport(pio_addr_t start, int length); -bool isa_is_ioport_assigned(pio_addr_t start); - -void cpu_outb(pio_addr_t addr, uint8_t val); -void cpu_outw(pio_addr_t addr, uint16_t val); -void cpu_outl(pio_addr_t addr, uint32_t val); -uint8_t cpu_inb(pio_addr_t addr); -uint16_t cpu_inw(pio_addr_t addr); -uint32_t cpu_inl(pio_addr_t addr); - -struct MemoryRegion; -struct MemoryRegionPortio; - -typedef struct PortioList { - const struct MemoryRegionPortio *ports; - struct MemoryRegion *address_space; - unsigned nr; - struct MemoryRegion **regions; - struct MemoryRegion **aliases; - void *opaque; - const char *name; -} PortioList; - -void portio_list_init(PortioList *piolist, - const struct MemoryRegionPortio *callbacks, - void *opaque, const char *name); -void portio_list_destroy(PortioList *piolist); -void portio_list_add(PortioList *piolist, - struct MemoryRegion *address_space, - uint32_t addr); -void portio_list_del(PortioList *piolist); - -#endif /* IOPORT_H */ diff --git a/iorange.h b/iorange.h deleted file mode 100644 index cd980a8312..0000000000 --- a/iorange.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef IORANGE_H -#define IORANGE_H - -#include - -typedef struct IORange IORange; -typedef struct IORangeOps IORangeOps; - -struct IORangeOps { - void (*read)(IORange *iorange, uint64_t offset, unsigned width, - uint64_t *data); - void (*write)(IORange *iorange, uint64_t offset, unsigned width, - uint64_t data); - void (*destructor)(IORange *iorange); -}; - -struct IORange { - const IORangeOps *ops; - uint64_t base; - uint64_t len; -}; - -static inline void iorange_init(IORange *iorange, const IORangeOps *ops, - uint64_t base, uint64_t len) -{ - iorange->ops = ops; - iorange->base = base; - iorange->len = len; -} - -#endif diff --git a/kvm-all.c b/kvm-all.c index 759ef17ab0..c2588594e1 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -27,11 +27,11 @@ #include "sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "kvm.h" #include "bswap.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "event_notifier.h" /* This check must be after config-host.h is included */ diff --git a/kvm-stub.c b/kvm-stub.c index d65fd04507..8de8ebd3d2 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -14,7 +14,7 @@ #include "hw/hw.h" #include "hw/pci/msi.h" #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "kvm.h" KVMState *kvm_state; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ceddb3ce72..2af883bf74 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -11,13 +11,13 @@ #include #endif /* DEBUG_REMAP */ -#include "qemu-user-types.h" +#include "exec/user/abitypes.h" -#include "thunk.h" +#include "exec/user/thunk.h" #include "syscall_defs.h" #include "syscall.h" #include "target_signal.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-queue.h" #if defined(CONFIG_USE_NPTL) diff --git a/memory-internal.h b/memory-internal.h deleted file mode 100644 index 1da240039d..0000000000 --- a/memory-internal.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Declarations for obsolete exec.c functions - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2 or - * later. See the COPYING file in the top-level directory. - * - */ - -/* - * This header is for use by exec.c and memory.c ONLY. Do not include it. - * The functions declared here will be removed soon. - */ - -#ifndef MEMORY_INTERNAL_H -#define MEMORY_INTERNAL_H - -#ifndef CONFIG_USER_ONLY -#include "hw/xen.h" - -typedef struct PhysPageEntry PhysPageEntry; - -struct PhysPageEntry { - uint16_t is_leaf : 1; - /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */ - uint16_t ptr : 15; -}; - -typedef struct AddressSpaceDispatch AddressSpaceDispatch; - -struct AddressSpaceDispatch { - /* This is a multi-level map on the physical address space. - * The bottom level has pointers to MemoryRegionSections. - */ - PhysPageEntry phys_map; - MemoryListener listener; -}; - -void address_space_init_dispatch(AddressSpace *as); -void address_space_destroy_dispatch(AddressSpace *as); - -ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, - MemoryRegion *mr); -ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); -void qemu_ram_free(ram_addr_t addr); -void qemu_ram_free_from_ptr(ram_addr_t addr); - -struct MemoryRegion; -struct MemoryRegionSection; - -void qemu_register_coalesced_mmio(hwaddr addr, ram_addr_t size); -void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size); - -#define VGA_DIRTY_FLAG 0x01 -#define CODE_DIRTY_FLAG 0x02 -#define MIGRATION_DIRTY_FLAG 0x08 - -static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) -{ - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; -} - -/* read dirty bit (return 0 or 1) */ -static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) -{ - return cpu_physical_memory_get_dirty_flags(addr) == 0xff; -} - -static inline int cpu_physical_memory_get_dirty(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - int ret = 0; - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; - } - return ret; -} - -static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, - int dirty_flags) -{ - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; -} - -static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) -{ - cpu_physical_memory_set_dirty_flags(addr, 0xff); -} - -static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, - int dirty_flags) -{ - int mask = ~dirty_flags; - - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; -} - -static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - cpu_physical_memory_set_dirty_flags(addr, dirty_flags); - } - xen_modified_memory(addr, length); -} - -static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); - } -} - -void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, - int dirty_flags); - -extern const IORangeOps memory_region_iorange_ops; - -#endif - -#endif diff --git a/memory.c b/memory.c index 741985385c..d40193d474 100644 --- a/memory.c +++ b/memory.c @@ -13,14 +13,14 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "memory.h" -#include "exec-memory.h" -#include "ioport.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "exec/ioport.h" #include "bitops.h" #include "kvm.h" #include -#include "memory-internal.h" +#include "exec/memory-internal.h" static unsigned memory_region_transaction_depth; static bool memory_region_update_pending; diff --git a/memory.h b/memory.h deleted file mode 100644 index 9462bfd3ad..0000000000 --- a/memory.h +++ /dev/null @@ -1,882 +0,0 @@ -/* - * Physical memory management API - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef MEMORY_H -#define MEMORY_H - -#ifndef CONFIG_USER_ONLY - -#include -#include -#include "qemu-common.h" -#include "cpu-common.h" -#include "hwaddr.h" -#include "qemu-queue.h" -#include "iorange.h" -#include "ioport.h" -#include "int128.h" - -typedef struct MemoryRegionOps MemoryRegionOps; -typedef struct MemoryRegion MemoryRegion; -typedef struct MemoryRegionPortio MemoryRegionPortio; -typedef struct MemoryRegionMmio MemoryRegionMmio; - -/* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic - * registration. - */ -#define DIRTY_MEMORY_VGA 0 -#define DIRTY_MEMORY_CODE 1 -#define DIRTY_MEMORY_MIGRATION 3 - -struct MemoryRegionMmio { - CPUReadMemoryFunc *read[3]; - CPUWriteMemoryFunc *write[3]; -}; - -/* Internal use; thunks between old-style IORange and MemoryRegions. */ -typedef struct MemoryRegionIORange MemoryRegionIORange; -struct MemoryRegionIORange { - IORange iorange; - MemoryRegion *mr; - hwaddr offset; -}; - -/* - * Memory region callbacks - */ -struct MemoryRegionOps { - /* Read from the memory region. @addr is relative to @mr; @size is - * in bytes. */ - uint64_t (*read)(void *opaque, - hwaddr addr, - unsigned size); - /* Write to the memory region. @addr is relative to @mr; @size is - * in bytes. */ - void (*write)(void *opaque, - hwaddr addr, - uint64_t data, - unsigned size); - - enum device_endian endianness; - /* Guest-visible constraints: */ - struct { - /* If nonzero, specify bounds on access sizes beyond which a machine - * check is thrown. - */ - unsigned min_access_size; - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise unaligned - * accesses throw machine checks. - */ - bool unaligned; - /* - * If present, and returns #false, the transaction is not accepted - * by the device (and results in machine dependent behaviour such - * as a machine check exception). - */ - bool (*accepts)(void *opaque, hwaddr addr, - unsigned size, bool is_write); - } valid; - /* Internal implementation constraints: */ - struct { - /* If nonzero, specifies the minimum size implemented. Smaller sizes - * will be rounded upwards and a partial result will be returned. - */ - unsigned min_access_size; - /* If nonzero, specifies the maximum size implemented. Larger sizes - * will be done as a series of accesses with smaller sizes. - */ - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise all accesses - * are converted to (possibly multiple) naturally aligned accesses. - */ - bool unaligned; - } impl; - - /* If .read and .write are not present, old_portio may be used for - * backwards compatibility with old portio registration - */ - const MemoryRegionPortio *old_portio; - /* If .read and .write are not present, old_mmio may be used for - * backwards compatibility with old mmio registration - */ - const MemoryRegionMmio old_mmio; -}; - -typedef struct CoalescedMemoryRange CoalescedMemoryRange; -typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; - -struct MemoryRegion { - /* All fields are private - violators will be prosecuted */ - const MemoryRegionOps *ops; - void *opaque; - MemoryRegion *parent; - Int128 size; - hwaddr addr; - void (*destructor)(MemoryRegion *mr); - ram_addr_t ram_addr; - bool subpage; - bool terminates; - bool readable; - bool ram; - bool readonly; /* For RAM regions */ - bool enabled; - bool rom_device; - bool warning_printed; /* For reservations */ - bool flush_coalesced_mmio; - MemoryRegion *alias; - hwaddr alias_offset; - unsigned priority; - bool may_overlap; - QTAILQ_HEAD(subregions, MemoryRegion) subregions; - QTAILQ_ENTRY(MemoryRegion) subregions_link; - QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; - const char *name; - uint8_t dirty_log_mask; - unsigned ioeventfd_nb; - MemoryRegionIoeventfd *ioeventfds; -}; - -struct MemoryRegionPortio { - uint32_t offset; - uint32_t len; - unsigned size; - IOPortReadFunc *read; - IOPortWriteFunc *write; -}; - -#define PORTIO_END_OF_LIST() { } - -typedef struct AddressSpace AddressSpace; - -/** - * AddressSpace: describes a mapping of addresses to #MemoryRegion objects - */ -struct AddressSpace { - /* All fields are private. */ - const char *name; - MemoryRegion *root; - struct FlatView *current_map; - int ioeventfd_nb; - struct MemoryRegionIoeventfd *ioeventfds; - struct AddressSpaceDispatch *dispatch; - QTAILQ_ENTRY(AddressSpace) address_spaces_link; -}; - -typedef struct MemoryRegionSection MemoryRegionSection; - -/** - * MemoryRegionSection: describes a fragment of a #MemoryRegion - * - * @mr: the region, or %NULL if empty - * @address_space: the address space the region is mapped in - * @offset_within_region: the beginning of the section, relative to @mr's start - * @size: the size of the section; will not exceed @mr's boundaries - * @offset_within_address_space: the address of the first byte of the section - * relative to the region's address space - * @readonly: writes to this section are ignored - */ -struct MemoryRegionSection { - MemoryRegion *mr; - AddressSpace *address_space; - hwaddr offset_within_region; - uint64_t size; - hwaddr offset_within_address_space; - bool readonly; -}; - -typedef struct MemoryListener MemoryListener; - -/** - * MemoryListener: callbacks structure for updates to the physical memory map - * - * Allows a component to adjust to changes in the guest-visible memory map. - * Use with memory_listener_register() and memory_listener_unregister(). - */ -struct MemoryListener { - void (*begin)(MemoryListener *listener); - void (*commit)(MemoryListener *listener); - void (*region_add)(MemoryListener *listener, MemoryRegionSection *section); - void (*region_del)(MemoryListener *listener, MemoryRegionSection *section); - void (*region_nop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_start)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_global_start)(MemoryListener *listener); - void (*log_global_stop)(MemoryListener *listener); - void (*eventfd_add)(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, EventNotifier *e); - void (*eventfd_del)(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, EventNotifier *e); - void (*coalesced_mmio_add)(MemoryListener *listener, MemoryRegionSection *section, - hwaddr addr, hwaddr len); - void (*coalesced_mmio_del)(MemoryListener *listener, MemoryRegionSection *section, - hwaddr addr, hwaddr len); - /* Lower = earlier (during add), later (during del) */ - unsigned priority; - AddressSpace *address_space_filter; - QTAILQ_ENTRY(MemoryListener) link; -}; - -/** - * memory_region_init: Initialize a memory region - * - * The region typically acts as a container for other memory regions. Use - * memory_region_add_subregion() to add subregions. - * - * @mr: the #MemoryRegion to be initialized - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region; any subregions beyond this size will be clipped - */ -void memory_region_init(MemoryRegion *mr, - const char *name, - uint64_t size); -/** - * memory_region_init_io: Initialize an I/O memory region. - * - * Accesses into the region will cause the callbacks in @ops to be called. - * if @size is nonzero, subregions will be clipped to @size. - * - * @mr: the #MemoryRegion to be initialized. - * @ops: a structure containing read and write callbacks to be used when - * I/O is performed on the region. - * @opaque: passed to to the read and write callbacks of the @ops structure. - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region. - */ -void memory_region_init_io(MemoryRegion *mr, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size); - -/** - * memory_region_init_ram: Initialize RAM memory region. Accesses into the - * region will modify memory directly. - * - * @mr: the #MemoryRegion to be initialized. - * @name: the name of the region. - * @size: size of the region. - */ -void memory_region_init_ram(MemoryRegion *mr, - const char *name, - uint64_t size); - -/** - * memory_region_init_ram_ptr: Initialize RAM memory region from a - * user-provided pointer. Accesses into the - * region will modify memory directly. - * - * @mr: the #MemoryRegion to be initialized. - * @name: the name of the region. - * @size: size of the region. - * @ptr: memory to be mapped; must contain at least @size bytes. - */ -void memory_region_init_ram_ptr(MemoryRegion *mr, - const char *name, - uint64_t size, - void *ptr); - -/** - * memory_region_init_alias: Initialize a memory region that aliases all or a - * part of another memory region. - * - * @mr: the #MemoryRegion to be initialized. - * @name: used for debugging; not visible to the user or ABI - * @orig: the region to be referenced; @mr will be equivalent to - * @orig between @offset and @offset + @size - 1. - * @offset: start of the section in @orig to be referenced. - * @size: size of the region. - */ -void memory_region_init_alias(MemoryRegion *mr, - const char *name, - MemoryRegion *orig, - hwaddr offset, - uint64_t size); - -/** - * memory_region_init_rom_device: Initialize a ROM memory region. Writes are - * handled via callbacks. - * - * @mr: the #MemoryRegion to be initialized. - * @ops: callbacks for write access handling. - * @name: the name of the region. - * @size: size of the region. - */ -void memory_region_init_rom_device(MemoryRegion *mr, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size); - -/** - * memory_region_init_reservation: Initialize a memory region that reserves - * I/O space. - * - * A reservation region primariy serves debugging purposes. It claims I/O - * space that is not supposed to be handled by QEMU itself. Any access via - * the memory API will cause an abort(). - * - * @mr: the #MemoryRegion to be initialized - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region. - */ -void memory_region_init_reservation(MemoryRegion *mr, - const char *name, - uint64_t size); -/** - * memory_region_destroy: Destroy a memory region and reclaim all resources. - * - * @mr: the region to be destroyed. May not currently be a subregion - * (see memory_region_add_subregion()) or referenced in an alias - * (see memory_region_init_alias()). - */ -void memory_region_destroy(MemoryRegion *mr); - -/** - * memory_region_size: get a memory region's size. - * - * @mr: the memory region being queried. - */ -uint64_t memory_region_size(MemoryRegion *mr); - -/** - * memory_region_is_ram: check whether a memory region is random access - * - * Returns %true is a memory region is random access. - * - * @mr: the memory region being queried - */ -bool memory_region_is_ram(MemoryRegion *mr); - -/** - * memory_region_is_romd: check whether a memory region is ROMD - * - * Returns %true is a memory region is ROMD and currently set to allow - * direct reads. - * - * @mr: the memory region being queried - */ -static inline bool memory_region_is_romd(MemoryRegion *mr) -{ - return mr->rom_device && mr->readable; -} - -/** - * memory_region_name: get a memory region's name - * - * Returns the string that was used to initialize the memory region. - * - * @mr: the memory region being queried - */ -const char *memory_region_name(MemoryRegion *mr); - -/** - * memory_region_is_logging: return whether a memory region is logging writes - * - * Returns %true if the memory region is logging writes - * - * @mr: the memory region being queried - */ -bool memory_region_is_logging(MemoryRegion *mr); - -/** - * memory_region_is_rom: check whether a memory region is ROM - * - * Returns %true is a memory region is read-only memory. - * - * @mr: the memory region being queried - */ -bool memory_region_is_rom(MemoryRegion *mr); - -/** - * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. - * - * Returns a host pointer to a RAM memory region (created with - * memory_region_init_ram() or memory_region_init_ram_ptr()). Use with - * care. - * - * @mr: the memory region being queried. - */ -void *memory_region_get_ram_ptr(MemoryRegion *mr); - -/** - * memory_region_set_log: Turn dirty logging on or off for a region. - * - * Turns dirty logging on or off for a specified client (display, migration). - * Only meaningful for RAM regions. - * - * @mr: the memory region being updated. - * @log: whether dirty logging is to be enabled or disabled. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client); - -/** - * memory_region_get_dirty: Check whether a range of bytes is dirty - * for a specified client. - * - * Checks whether a range of bytes has been written to since the last - * call to memory_region_reset_dirty() with the same @client. Dirty logging - * must be enabled. - * - * @mr: the memory region being queried. - * @addr: the address (relative to the start of the region) being queried. - * @size: the size of the range being queried. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -bool memory_region_get_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size, unsigned client); - -/** - * memory_region_set_dirty: Mark a range of bytes as dirty in a memory region. - * - * Marks a range of bytes as dirty, after it has been dirtied outside - * guest code. - * - * @mr: the memory region being dirtied. - * @addr: the address (relative to the start of the region) being dirtied. - * @size: size of the range being dirtied. - */ -void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size); - -/** - * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap with - * any external TLBs (e.g. kvm) - * - * Flushes dirty information from accelerators such as kvm and vhost-net - * and makes it available to users of the memory API. - * - * @mr: the region being flushed. - */ -void memory_region_sync_dirty_bitmap(MemoryRegion *mr); - -/** - * memory_region_reset_dirty: Mark a range of pages as clean, for a specified - * client. - * - * Marks a range of pages as no longer dirty. - * - * @mr: the region being updated. - * @addr: the start of the subrange being cleaned. - * @size: the size of the subrange being cleaned. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size, unsigned client); - -/** - * memory_region_set_readonly: Turn a memory region read-only (or read-write) - * - * Allows a memory region to be marked as read-only (turning it into a ROM). - * only useful on RAM regions. - * - * @mr: the region being updated. - * @readonly: whether rhe region is to be ROM or RAM. - */ -void memory_region_set_readonly(MemoryRegion *mr, bool readonly); - -/** - * memory_region_rom_device_set_readable: enable/disable ROM readability - * - * Allows a ROM device (initialized with memory_region_init_rom_device() to - * to be marked as readable (default) or not readable. When it is readable, - * the device is mapped to guest memory. When not readable, reads are - * forwarded to the #MemoryRegion.read function. - * - * @mr: the memory region to be updated - * @readable: whether reads are satisified directly (%true) or via callbacks - * (%false) - */ -void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable); - -/** - * memory_region_set_coalescing: Enable memory coalescing for the region. - * - * Enabled writes to a region to be queued for later processing. MMIO ->write - * callbacks may be delayed until a non-coalesced MMIO is issued. - * Only useful for IO regions. Roughly similar to write-combining hardware. - * - * @mr: the memory region to be write coalesced - */ -void memory_region_set_coalescing(MemoryRegion *mr); - -/** - * memory_region_add_coalescing: Enable memory coalescing for a sub-range of - * a region. - * - * Like memory_region_set_coalescing(), but works on a sub-range of a region. - * Multiple calls can be issued coalesced disjoint ranges. - * - * @mr: the memory region to be updated. - * @offset: the start of the range within the region to be coalesced. - * @size: the size of the subrange to be coalesced. - */ -void memory_region_add_coalescing(MemoryRegion *mr, - hwaddr offset, - uint64_t size); - -/** - * memory_region_clear_coalescing: Disable MMIO coalescing for the region. - * - * Disables any coalescing caused by memory_region_set_coalescing() or - * memory_region_add_coalescing(). Roughly equivalent to uncacheble memory - * hardware. - * - * @mr: the memory region to be updated. - */ -void memory_region_clear_coalescing(MemoryRegion *mr); - -/** - * memory_region_set_flush_coalesced: Enforce memory coalescing flush before - * accesses. - * - * Ensure that pending coalesced MMIO request are flushed before the memory - * region is accessed. This property is automatically enabled for all regions - * passed to memory_region_set_coalescing() and memory_region_add_coalescing(). - * - * @mr: the memory region to be updated. - */ -void memory_region_set_flush_coalesced(MemoryRegion *mr); - -/** - * memory_region_clear_flush_coalesced: Disable memory coalescing flush before - * accesses. - * - * Clear the automatic coalesced MMIO flushing enabled via - * memory_region_set_flush_coalesced. Note that this service has no effect on - * memory regions that have MMIO coalescing enabled for themselves. For them, - * automatic flushing will stop once coalescing is disabled. - * - * @mr: the memory region to be updated. - */ -void memory_region_clear_flush_coalesced(MemoryRegion *mr); - -/** - * memory_region_add_eventfd: Request an eventfd to be triggered when a word - * is written to a location. - * - * Marks a word in an IO region (initialized with memory_region_init_io()) - * as a trigger for an eventfd event. The I/O callback will not be called. - * The caller must be prepared to handle failure (that is, take the required - * action if the callback _is_ called). - * - * @mr: the memory region being updated. - * @addr: the address within @mr that is to be monitored - * @size: the size of the access to trigger the eventfd - * @match_data: whether to match against @data, instead of just @addr - * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. - **/ -void memory_region_add_eventfd(MemoryRegion *mr, - hwaddr addr, - unsigned size, - bool match_data, - uint64_t data, - EventNotifier *e); - -/** - * memory_region_del_eventfd: Cancel an eventfd. - * - * Cancels an eventfd trigger requested by a previous - * memory_region_add_eventfd() call. - * - * @mr: the memory region being updated. - * @addr: the address within @mr that is to be monitored - * @size: the size of the access to trigger the eventfd - * @match_data: whether to match against @data, instead of just @addr - * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. - */ -void memory_region_del_eventfd(MemoryRegion *mr, - hwaddr addr, - unsigned size, - bool match_data, - uint64_t data, - EventNotifier *e); - -/** - * memory_region_add_subregion: Add a subregion to a container. - * - * Adds a subregion at @offset. The subregion may not overlap with other - * subregions (except for those explicitly marked as overlapping). A region - * may only be added once as a subregion (unless removed with - * memory_region_del_subregion()); use memory_region_init_alias() if you - * want a region to be a subregion in multiple locations. - * - * @mr: the region to contain the new subregion; must be a container - * initialized with memory_region_init(). - * @offset: the offset relative to @mr where @subregion is added. - * @subregion: the subregion to be added. - */ -void memory_region_add_subregion(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion); -/** - * memory_region_add_subregion_overlap: Add a subregion to a container - * with overlap. - * - * Adds a subregion at @offset. The subregion may overlap with other - * subregions. Conflicts are resolved by having a higher @priority hide a - * lower @priority. Subregions without priority are taken as @priority 0. - * A region may only be added once as a subregion (unless removed with - * memory_region_del_subregion()); use memory_region_init_alias() if you - * want a region to be a subregion in multiple locations. - * - * @mr: the region to contain the new subregion; must be a container - * initialized with memory_region_init(). - * @offset: the offset relative to @mr where @subregion is added. - * @subregion: the subregion to be added. - * @priority: used for resolving overlaps; highest priority wins. - */ -void memory_region_add_subregion_overlap(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion, - unsigned priority); - -/** - * memory_region_get_ram_addr: Get the ram address associated with a memory - * region - * - * DO NOT USE THIS FUNCTION. This is a temporary workaround while the Xen - * code is being reworked. - */ -ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr); - -/** - * memory_region_del_subregion: Remove a subregion. - * - * Removes a subregion from its container. - * - * @mr: the container to be updated. - * @subregion: the region being removed; must be a current subregion of @mr. - */ -void memory_region_del_subregion(MemoryRegion *mr, - MemoryRegion *subregion); - -/* - * memory_region_set_enabled: dynamically enable or disable a region - * - * Enables or disables a memory region. A disabled memory region - * ignores all accesses to itself and its subregions. It does not - * obscure sibling subregions with lower priority - it simply behaves as - * if it was removed from the hierarchy. - * - * Regions default to being enabled. - * - * @mr: the region to be updated - * @enabled: whether to enable or disable the region - */ -void memory_region_set_enabled(MemoryRegion *mr, bool enabled); - -/* - * memory_region_set_address: dynamically update the address of a region - * - * Dynamically updates the address of a region, relative to its parent. - * May be used on regions are currently part of a memory hierarchy. - * - * @mr: the region to be updated - * @addr: new address, relative to parent region - */ -void memory_region_set_address(MemoryRegion *mr, hwaddr addr); - -/* - * memory_region_set_alias_offset: dynamically update a memory alias's offset - * - * Dynamically updates the offset into the target region that an alias points - * to, as if the fourth argument to memory_region_init_alias() has changed. - * - * @mr: the #MemoryRegion to be updated; should be an alias. - * @offset: the new offset into the target memory region - */ -void memory_region_set_alias_offset(MemoryRegion *mr, - hwaddr offset); - -/** - * memory_region_find: locate a MemoryRegion in an address space - * - * Locates the first #MemoryRegion within an address space given by - * @address_space that overlaps the range given by @addr and @size. - * - * Returns a #MemoryRegionSection that describes a contiguous overlap. - * It will have the following characteristics: - * .@offset_within_address_space >= @addr - * .@offset_within_address_space + .@size <= @addr + @size - * .@size = 0 iff no overlap was found - * .@mr is non-%NULL iff an overlap was found - * - * @address_space: a top-level (i.e. parentless) region that contains - * the region to be found - * @addr: start of the area within @address_space to be searched - * @size: size of the area to be searched - */ -MemoryRegionSection memory_region_find(MemoryRegion *address_space, - hwaddr addr, uint64_t size); - -/** - * memory_region_section_addr: get offset within MemoryRegionSection - * - * Returns offset within MemoryRegionSection - * - * @section: the memory region section being queried - * @addr: address in address space - */ -static inline hwaddr -memory_region_section_addr(MemoryRegionSection *section, - hwaddr addr) -{ - addr -= section->offset_within_address_space; - addr += section->offset_within_region; - return addr; -} - -/** - * memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory - * - * Synchronizes the dirty page log for an entire address space. - * @address_space: a top-level (i.e. parentless) region that contains the - * memory being synchronized - */ -void memory_global_sync_dirty_bitmap(MemoryRegion *address_space); - -/** - * memory_region_transaction_begin: Start a transaction. - * - * During a transaction, changes will be accumulated and made visible - * only when the transaction ends (is committed). - */ -void memory_region_transaction_begin(void); - -/** - * memory_region_transaction_commit: Commit a transaction and make changes - * visible to the guest. - */ -void memory_region_transaction_commit(void); - -/** - * memory_listener_register: register callbacks to be called when memory - * sections are mapped or unmapped into an address - * space - * - * @listener: an object containing the callbacks to be called - * @filter: if non-%NULL, only regions in this address space will be observed - */ -void memory_listener_register(MemoryListener *listener, AddressSpace *filter); - -/** - * memory_listener_unregister: undo the effect of memory_listener_register() - * - * @listener: an object containing the callbacks to be removed - */ -void memory_listener_unregister(MemoryListener *listener); - -/** - * memory_global_dirty_log_start: begin dirty logging for all regions - */ -void memory_global_dirty_log_start(void); - -/** - * memory_global_dirty_log_stop: end dirty logging for all regions - */ -void memory_global_dirty_log_stop(void); - -void mtree_info(fprintf_function mon_printf, void *f); - -/** - * address_space_init: initializes an address space - * - * @as: an uninitialized #AddressSpace - * @root: a #MemoryRegion that routes addesses for the address space - */ -void address_space_init(AddressSpace *as, MemoryRegion *root); - - -/** - * address_space_destroy: destroy an address space - * - * Releases all resources associated with an address space. After an address space - * is destroyed, its root memory region (given by address_space_init()) may be destroyed - * as well. - * - * @as: address space to be destroyed - */ -void address_space_destroy(AddressSpace *as); - -/** - * address_space_rw: read from or write to an address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - * @is_write: indicates the transfer direction - */ -void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, - int len, bool is_write); - -/** - * address_space_write: write to address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - */ -void address_space_write(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len); - -/** - * address_space_read: read from an address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - */ -void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); - -/* address_space_map: map a physical memory region into a host virtual address - * - * May map a subset of the requested range, given by and returned in @plen. - * May return %NULL if resources needed to perform the mapping are exhausted. - * Use only for reads OR writes - not for read-modify-write operations. - * Use cpu_register_map_client() to know when retrying the map operation is - * likely to succeed. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @plen: pointer to length of buffer; updated on return - * @is_write: indicates the transfer direction - */ -void *address_space_map(AddressSpace *as, hwaddr addr, - hwaddr *plen, bool is_write); - -/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() - * - * Will also mark the memory as dirty if @is_write == %true. @access_len gives - * the amount of memory that was actually read or written by the caller. - * - * @as: #AddressSpace used - * @addr: address within that address space - * @len: buffer length as returned by address_space_map() - * @access_len: amount of data actually transferred - * @is_write: indicates the transfer direction - */ -void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, - int is_write, hwaddr access_len); - - -#endif - -#endif diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c index 76be34d89f..5f5fb99c58 100644 --- a/memory_mapping-stub.c +++ b/memory_mapping-stub.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" int qemu_get_guest_memory_mapping(MemoryMappingList *list) diff --git a/memory_mapping.c b/memory_mapping.c index a82e190cab..c829a9fa34 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" static void memory_mapping_list_add_mapping_sorted(MemoryMappingList *list, diff --git a/monitor.c b/monitor.c index 7d5c8a622c..a3e010968e 100644 --- a/monitor.c +++ b/monitor.c @@ -30,7 +30,7 @@ #include "hw/pci/pci.h" #include "hw/watchdog.h" #include "hw/loader.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "net/net.h" #include "net/slirp.h" #include "qemu-char.h" @@ -63,7 +63,7 @@ #include "trace/simple.h" #endif #include "ui/qemu-spice.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" #include "qemu-thread.h" diff --git a/poison.h b/poison.h deleted file mode 100644 index 7d7b23b1fc..0000000000 --- a/poison.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Poison identifiers that should not be used when building - target independent device code. */ - -#ifndef HW_POISON_H -#define HW_POISON_H -#ifdef __GNUC__ - -#pragma GCC poison TARGET_I386 -#pragma GCC poison TARGET_X86_64 -#pragma GCC poison TARGET_ALPHA -#pragma GCC poison TARGET_ARM -#pragma GCC poison TARGET_CRIS -#pragma GCC poison TARGET_LM32 -#pragma GCC poison TARGET_M68K -#pragma GCC poison TARGET_MIPS -#pragma GCC poison TARGET_MIPS64 -#pragma GCC poison TARGET_OPENRISC -#pragma GCC poison TARGET_PPC -#pragma GCC poison TARGET_PPCEMB -#pragma GCC poison TARGET_PPC64 -#pragma GCC poison TARGET_ABI32 -#pragma GCC poison TARGET_SH4 -#pragma GCC poison TARGET_SPARC -#pragma GCC poison TARGET_SPARC64 - -#pragma GCC poison TARGET_WORDS_BIGENDIAN -#pragma GCC poison BSWAP_NEEDED - -#pragma GCC poison TARGET_LONG_BITS -#pragma GCC poison TARGET_FMT_lx -#pragma GCC poison TARGET_FMT_ld - -#pragma GCC poison TARGET_PAGE_SIZE -#pragma GCC poison TARGET_PAGE_MASK -#pragma GCC poison TARGET_PAGE_BITS -#pragma GCC poison TARGET_PAGE_ALIGN - -#pragma GCC poison CPUArchState -#pragma GCC poison env - -#pragma GCC poison lduw_phys -#pragma GCC poison ldl_phys -#pragma GCC poison ldq_phys -#pragma GCC poison stl_phys_notdirty -#pragma GCC poison stq_phys_notdirty -#pragma GCC poison stw_phys -#pragma GCC poison stl_phys -#pragma GCC poison stq_phys - -#pragma GCC poison CPU_INTERRUPT_HARD -#pragma GCC poison CPU_INTERRUPT_EXITTB -#pragma GCC poison CPU_INTERRUPT_HALT -#pragma GCC poison CPU_INTERRUPT_DEBUG -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 - -#endif -#endif diff --git a/qemu-lock.h b/qemu-lock.h deleted file mode 100644 index a72edda1d2..0000000000 --- a/qemu-lock.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see - */ - -/* configure guarantees us that we have pthreads on any host except - * mingw32, which doesn't support any of the user-only targets. - * So we can simply assume we have pthread mutexes here. - */ -#if defined(CONFIG_USER_ONLY) - -#include -#define spin_lock pthread_mutex_lock -#define spin_unlock pthread_mutex_unlock -#define spinlock_t pthread_mutex_t -#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER - -#else - -/* Empty implementations, on the theory that system mode emulation - * is single-threaded. This means that these functions should only - * be used from code run in the TCG cpu thread, and cannot protect - * data structures which might also be accessed from the IO thread - * or from signal handlers. - */ -typedef int spinlock_t; -#define SPIN_LOCK_UNLOCKED 0 - -static inline void spin_lock(spinlock_t *lock) -{ -} - -static inline void spin_unlock(spinlock_t *lock) -{ -} - -#endif diff --git a/qemu-user-types.h b/qemu-user-types.h deleted file mode 100644 index fe7f6624f9..0000000000 --- a/qemu-user-types.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QEMU_TYPES_H -#define QEMU_TYPES_H -#include "cpu.h" - -#ifdef TARGET_ABI32 -typedef uint32_t abi_ulong; -typedef int32_t abi_long; -#define TARGET_ABI_FMT_lx "%08x" -#define TARGET_ABI_FMT_ld "%d" -#define TARGET_ABI_FMT_lu "%u" -#define TARGET_ABI_BITS 32 - -static inline abi_ulong tswapal(abi_ulong v) -{ - return tswap32(v); -} - -#else -typedef target_ulong abi_ulong; -typedef target_long abi_long; -#define TARGET_ABI_FMT_lx TARGET_FMT_lx -#define TARGET_ABI_FMT_ld TARGET_FMT_ld -#define TARGET_ABI_FMT_lu TARGET_FMT_lu -#define TARGET_ABI_BITS TARGET_LONG_BITS -/* for consistency, define ABI32 too */ -#if TARGET_ABI_BITS == 32 -#define TARGET_ABI32 1 -#endif - -static inline abi_ulong tswapal(abi_ulong v) -{ - return tswapl(v); -} - -#endif -#endif diff --git a/qtest.c b/qtest.c index fbfab4e1a7..ebe3963167 100644 --- a/qtest.c +++ b/qtest.c @@ -14,8 +14,8 @@ #include "qtest.h" #include "hw/qdev.h" #include "qemu-char.h" -#include "ioport.h" -#include "memory.h" +#include "exec/ioport.h" +#include "exec/memory.h" #include "hw/irq.h" #include "sysemu.h" #include "cpus.h" diff --git a/savevm.c b/savevm.c index ae8787868f..cb33501ecc 100644 --- a/savevm.c +++ b/savevm.c @@ -82,7 +82,7 @@ #include "qemu-queue.h" #include "qemu-timer.h" #include "cpus.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" #include "bitops.h" diff --git a/scripts/feature_to_c.sh b/scripts/feature_to_c.sh index b62da8a0bd..888548e58b 100644 --- a/scripts/feature_to_c.sh +++ b/scripts/feature_to_c.sh @@ -38,7 +38,7 @@ for input; do ${AWK:-awk} 'BEGIN { n = 0 printf "#include \"config.h\"\n" printf "#include \"qemu-common.h\"\n" - printf "#include \"gdbstub.h\"\n" + printf "#include \"exec/gdbstub.h\"\n" print "static const char '$arrayname'[] = {" for (i = 0; i < 255; i++) _ord_[sprintf("%c", i)] = i diff --git a/softmmu-semi.h b/softmmu-semi.h deleted file mode 100644 index 93798b9614..0000000000 --- a/softmmu-semi.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Helper routines to provide target memory access for semihosting - * syscalls in system emulation mode. - * - * Copyright (c) 2007 CodeSourcery. - * - * This code is licensed under the GPL - */ -#ifndef SOFTMMU_SEMI_H -#define SOFTMMU_SEMI_H 1 - -static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr) -{ - uint32_t val; - - cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0); - return tswap32(val); -} -static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr) -{ - uint8_t val; - - cpu_memory_rw_debug(env, addr, &val, 1, 0); - return val; -} - -#define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; }) -#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; }) -#define get_user_ual(arg, p) get_user_u32(arg, p) - -static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val) -{ - val = tswap32(val); - cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1); -} -#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; }) -#define put_user_ual(arg, p) put_user_u32(arg, p) - -static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len, - int copy) -{ - uint8_t *p; - /* TODO: Make this something that isn't fixed size. */ - p = malloc(len); - if (p && copy) - cpu_memory_rw_debug(env, addr, p, len, 0); - return p; -} -#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) -static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr) -{ - char *p; - char *s; - uint8_t c; - /* TODO: Make this something that isn't fixed size. */ - s = p = malloc(1024); - if (!s) { - return NULL; - } - do { - cpu_memory_rw_debug(env, addr, &c, 1, 0); - addr++; - *(p++) = c; - } while (c); - return s; -} -#define lock_user_string(p) softmmu_lock_user_string(env, p) -static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, - target_ulong len) -{ - if (len) - cpu_memory_rw_debug(env, addr, p, len, 1); - free(p); -} -#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) - -#endif diff --git a/softmmu_defs.h b/softmmu_defs.h deleted file mode 100644 index 1f25e33ce4..0000000000 --- a/softmmu_defs.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Software MMU support - * - * Declare helpers used by TCG for qemu_ld/st ops. - * - * Used by softmmu_exec.h, TCG targets and exec-all.h. - * - */ -#ifndef SOFTMMU_DEFS_H -#define SOFTMMU_DEFS_H - -uint8_t helper_ldb_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, - int mmu_idx); -uint16_t helper_ldw_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, - int mmu_idx); -uint32_t helper_ldl_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, - int mmu_idx); -uint64_t helper_ldq_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, - int mmu_idx); - -uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stb_cmmu(CPUArchState *env, target_ulong addr, uint8_t val, -int mmu_idx); -uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stw_cmmu(CPUArchState *env, target_ulong addr, uint16_t val, - int mmu_idx); -uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stl_cmmu(CPUArchState *env, target_ulong addr, uint32_t val, - int mmu_idx); -uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stq_cmmu(CPUArchState *env, target_ulong addr, uint64_t val, - int mmu_idx); -#endif diff --git a/softmmu_exec.h b/softmmu_exec.h deleted file mode 100644 index 8c73985599..0000000000 --- a/softmmu_exec.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Software MMU support - * - * Generate inline load/store functions for all MMU modes (typically - * at least _user and _kernel) as well as _data versions, for all data - * sizes. - * - * Used by target op helpers. - * - * MMU mode suffixes are defined in target cpu.h. - */ - -/* XXX: find something cleaner. - * Furthermore, this is false for 64 bits targets - */ -#define ldul_user ldl_user -#define ldul_kernel ldl_kernel -#define ldul_hypv ldl_hypv -#define ldul_executive ldl_executive -#define ldul_supervisor ldl_supervisor - -#include "softmmu_defs.h" - -#define ACCESS_TYPE 0 -#define MEMSUFFIX MMU_MODE0_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#define ACCESS_TYPE 1 -#define MEMSUFFIX MMU_MODE1_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#if (NB_MMU_MODES >= 3) - -#define ACCESS_TYPE 2 -#define MEMSUFFIX MMU_MODE2_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 3) */ - -#if (NB_MMU_MODES >= 4) - -#define ACCESS_TYPE 3 -#define MEMSUFFIX MMU_MODE3_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 4) */ - -#if (NB_MMU_MODES >= 5) - -#define ACCESS_TYPE 4 -#define MEMSUFFIX MMU_MODE4_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 5) */ - -#if (NB_MMU_MODES >= 6) - -#define ACCESS_TYPE 5 -#define MEMSUFFIX MMU_MODE5_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 6) */ - -#if (NB_MMU_MODES > 6) -#error "NB_MMU_MODES > 6 is not supported for now" -#endif /* (NB_MMU_MODES > 6) */ - -/* these access are slower, they must be as rare as possible */ -#define ACCESS_TYPE (NB_MMU_MODES) -#define MEMSUFFIX _data -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#define ldub(p) ldub_data(p) -#define ldsb(p) ldsb_data(p) -#define lduw(p) lduw_data(p) -#define ldsw(p) ldsw_data(p) -#define ldl(p) ldl_data(p) -#define ldq(p) ldq_data(p) - -#define stb(p, v) stb_data(p, v) -#define stw(p, v) stw_data(p, v) -#define stl(p, v) stl_data(p, v) -#define stq(p, v) stq_data(p, v) diff --git a/softmmu_header.h b/softmmu_header.h deleted file mode 100644 index d8d9c81b05..0000000000 --- a/softmmu_header.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Software MMU support - * - * Generate inline load/store functions for one MMU mode and data - * size. - * - * Generate a store function as well as signed and unsigned loads. For - * 32 and 64 bit cases, also generate floating point functions with - * the same size. - * - * Not used directly but included from softmmu_exec.h and exec-all.h. - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#if DATA_SIZE == 8 -#define SUFFIX q -#define USUFFIX q -#define DATA_TYPE uint64_t -#elif DATA_SIZE == 4 -#define SUFFIX l -#define USUFFIX l -#define DATA_TYPE uint32_t -#elif DATA_SIZE == 2 -#define SUFFIX w -#define USUFFIX uw -#define DATA_TYPE uint16_t -#define DATA_STYPE int16_t -#elif DATA_SIZE == 1 -#define SUFFIX b -#define USUFFIX ub -#define DATA_TYPE uint8_t -#define DATA_STYPE int8_t -#else -#error unsupported data size -#endif - -#if ACCESS_TYPE < (NB_MMU_MODES) - -#define CPU_MMU_INDEX ACCESS_TYPE -#define MMUSUFFIX _mmu - -#elif ACCESS_TYPE == (NB_MMU_MODES) - -#define CPU_MMU_INDEX (cpu_mmu_index(env)) -#define MMUSUFFIX _mmu - -#elif ACCESS_TYPE == (NB_MMU_MODES + 1) - -#define CPU_MMU_INDEX (cpu_mmu_index(env)) -#define MMUSUFFIX _cmmu - -#else -#error invalid ACCESS_TYPE -#endif - -#if DATA_SIZE == 8 -#define RES_TYPE uint64_t -#else -#define RES_TYPE uint32_t -#endif - -#if ACCESS_TYPE == (NB_MMU_MODES + 1) -#define ADDR_READ addr_code -#else -#define ADDR_READ addr_read -#endif - -/* generic load/store macros */ - -static inline RES_TYPE -glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) -{ - int page_index; - RES_TYPE res; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - res = glue(glue(ld, USUFFIX), _raw)(hostaddr); - } - return res; -} - -#if DATA_SIZE <= 2 -static inline int -glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) -{ - int res, page_index; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX), - MMUSUFFIX)(env, addr, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - res = glue(glue(lds, SUFFIX), _raw)(hostaddr); - } - return res; -} -#endif - -#if ACCESS_TYPE != (NB_MMU_MODES + 1) - -/* generic store macro */ - -static inline void -glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr, - RES_TYPE v) -{ - int page_index; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, v, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - glue(glue(st, SUFFIX), _raw)(hostaddr, v); - } -} - -#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ - -#if ACCESS_TYPE != (NB_MMU_MODES + 1) - -#if DATA_SIZE == 8 -static inline float64 glue(cpu_ldfq, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr) -{ - union { - float64 d; - uint64_t i; - } u; - u.i = glue(cpu_ldq, MEMSUFFIX)(env, ptr); - return u.d; -} - -static inline void glue(cpu_stfq, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr, float64 v) -{ - union { - float64 d; - uint64_t i; - } u; - u.d = v; - glue(cpu_stq, MEMSUFFIX)(env, ptr, u.i); -} -#endif /* DATA_SIZE == 8 */ - -#if DATA_SIZE == 4 -static inline float32 glue(cpu_ldfl, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = glue(cpu_ldl, MEMSUFFIX)(env, ptr); - return u.f; -} - -static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - glue(cpu_stl, MEMSUFFIX)(env, ptr, u.i); -} -#endif /* DATA_SIZE == 4 */ - -#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ - -#undef RES_TYPE -#undef DATA_TYPE -#undef DATA_STYPE -#undef SUFFIX -#undef USUFFIX -#undef DATA_SIZE -#undef CPU_MMU_INDEX -#undef MMUSUFFIX -#undef ADDR_READ diff --git a/softmmu_template.h b/softmmu_template.h deleted file mode 100644 index ce30d8bddc..0000000000 --- a/softmmu_template.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Software MMU support - * - * Generate helpers used by TCG for qemu_ld/st ops and code load - * functions. - * - * Included from target op helpers and exec.c. - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#include "qemu-timer.h" -#include "memory.h" - -#define DATA_SIZE (1 << SHIFT) - -#if DATA_SIZE == 8 -#define SUFFIX q -#define USUFFIX q -#define DATA_TYPE uint64_t -#elif DATA_SIZE == 4 -#define SUFFIX l -#define USUFFIX l -#define DATA_TYPE uint32_t -#elif DATA_SIZE == 2 -#define SUFFIX w -#define USUFFIX uw -#define DATA_TYPE uint16_t -#elif DATA_SIZE == 1 -#define SUFFIX b -#define USUFFIX ub -#define DATA_TYPE uint8_t -#else -#error unsupported data size -#endif - -#ifdef SOFTMMU_CODE_ACCESS -#define READ_ACCESS_TYPE 2 -#define ADDR_READ addr_code -#else -#define READ_ACCESS_TYPE 0 -#define ADDR_READ addr_read -#endif - -static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - int mmu_idx, - uintptr_t retaddr); -static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, - hwaddr physaddr, - target_ulong addr, - uintptr_t retaddr) -{ - DATA_TYPE res; - MemoryRegion *mr = iotlb_to_region(physaddr); - - physaddr = (physaddr & TARGET_PAGE_MASK) + addr; - env->mem_io_pc = retaddr; - if (mr != &io_mem_ram && mr != &io_mem_rom - && mr != &io_mem_unassigned - && mr != &io_mem_notdirty - && !can_do_io(env)) { - cpu_io_recompile(env, retaddr); - } - - env->mem_io_vaddr = addr; -#if SHIFT <= 2 - res = io_mem_read(mr, physaddr, 1 << SHIFT); -#else -#ifdef TARGET_WORDS_BIGENDIAN - res = io_mem_read(mr, physaddr, 4) << 32; - res |= io_mem_read(mr, physaddr + 4, 4); -#else - res = io_mem_read(mr, physaddr, 4); - res |= io_mem_read(mr, physaddr + 4, 4) << 32; -#endif -#endif /* SHIFT > 2 */ - return res; -} - -/* handle all cases except unaligned access which span two pages */ -DATA_TYPE -glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, - int mmu_idx) -{ - DATA_TYPE res; - int index; - target_ulong tlb_addr; - hwaddr ioaddr; - uintptr_t retaddr; - - /* test if there is match for unaligned or IO access */ - /* XXX: could done more in memory macro in a non portable way */ - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - retaddr = GETPC_EXT(); - ioaddr = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - /* slow unaligned access (it spans two pages or IO) */ - do_unaligned_access: - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); -#endif - res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr, - mmu_idx, retaddr); - } else { - /* unaligned/aligned access in the same page */ - uintptr_t addend; -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) { - retaddr = GETPC_EXT(); - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - } -#endif - addend = env->tlb_table[mmu_idx][index].addend; - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend)); - } - } else { - /* the page is not in the TLB : fill it */ - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); -#endif - tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - goto redo; - } - return res; -} - -/* handle all unaligned cases */ -static DATA_TYPE -glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - int mmu_idx, - uintptr_t retaddr) -{ - DATA_TYPE res, res1, res2; - int index, shift; - hwaddr ioaddr; - target_ulong tlb_addr, addr1, addr2; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - ioaddr = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - /* slow unaligned access (it spans two pages) */ - addr1 = addr & ~(DATA_SIZE - 1); - addr2 = addr1 + DATA_SIZE; - res1 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr1, - mmu_idx, retaddr); - res2 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr2, - mmu_idx, retaddr); - shift = (addr & (DATA_SIZE - 1)) * 8; -#ifdef TARGET_WORDS_BIGENDIAN - res = (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); -#else - res = (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); -#endif - res = (DATA_TYPE)res; - } else { - /* unaligned/aligned access in the same page */ - uintptr_t addend = env->tlb_table[mmu_idx][index].addend; - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend)); - } - } else { - /* the page is not in the TLB : fill it */ - tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - goto redo; - } - return res; -} - -#ifndef SOFTMMU_CODE_ACCESS - -static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - DATA_TYPE val, - int mmu_idx, - uintptr_t retaddr); - -static inline void glue(io_write, SUFFIX)(CPUArchState *env, - hwaddr physaddr, - DATA_TYPE val, - target_ulong addr, - uintptr_t retaddr) -{ - MemoryRegion *mr = iotlb_to_region(physaddr); - - physaddr = (physaddr & TARGET_PAGE_MASK) + addr; - if (mr != &io_mem_ram && mr != &io_mem_rom - && mr != &io_mem_unassigned - && mr != &io_mem_notdirty - && !can_do_io(env)) { - cpu_io_recompile(env, retaddr); - } - - env->mem_io_vaddr = addr; - env->mem_io_pc = retaddr; -#if SHIFT <= 2 - io_mem_write(mr, physaddr, val, 1 << SHIFT); -#else -#ifdef TARGET_WORDS_BIGENDIAN - io_mem_write(mr, physaddr, (val >> 32), 4); - io_mem_write(mr, physaddr + 4, (uint32_t)val, 4); -#else - io_mem_write(mr, physaddr, (uint32_t)val, 4); - io_mem_write(mr, physaddr + 4, val >> 32, 4); -#endif -#endif /* SHIFT > 2 */ -} - -void glue(glue(helper_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, DATA_TYPE val, - int mmu_idx) -{ - hwaddr ioaddr; - target_ulong tlb_addr; - uintptr_t retaddr; - int index; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].addr_write; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - retaddr = GETPC_EXT(); - ioaddr = env->iotlb[mmu_idx][index]; - glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); -#endif - glue(glue(slow_st, SUFFIX), MMUSUFFIX)(env, addr, val, - mmu_idx, retaddr); - } else { - /* aligned/unaligned access in the same page */ - uintptr_t addend; -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) { - retaddr = GETPC_EXT(); - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); - } -#endif - addend = env->tlb_table[mmu_idx][index].addend; - glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend), val); - } - } else { - /* the page is not in the TLB : fill it */ - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); -#endif - tlb_fill(env, addr, 1, mmu_idx, retaddr); - goto redo; - } -} - -/* handles all unaligned cases */ -static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - DATA_TYPE val, - int mmu_idx, - uintptr_t retaddr) -{ - hwaddr ioaddr; - target_ulong tlb_addr; - int index, i; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].addr_write; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - ioaddr = env->iotlb[mmu_idx][index]; - glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - /* XXX: not efficient, but simple */ - /* Note: relies on the fact that tlb_fill() does not remove the - * previous page from the TLB cache. */ - for(i = DATA_SIZE - 1; i >= 0; i--) { -#ifdef TARGET_WORDS_BIGENDIAN - glue(slow_stb, MMUSUFFIX)(env, addr + i, - val >> (((DATA_SIZE - 1) * 8) - (i * 8)), - mmu_idx, retaddr); -#else - glue(slow_stb, MMUSUFFIX)(env, addr + i, - val >> (i * 8), - mmu_idx, retaddr); -#endif - } - } else { - /* aligned/unaligned access in the same page */ - uintptr_t addend = env->tlb_table[mmu_idx][index].addend; - glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend), val); - } - } else { - /* the page is not in the TLB : fill it */ - tlb_fill(env, addr, 1, mmu_idx, retaddr); - goto redo; - } -} - -#endif /* !defined(SOFTMMU_CODE_ACCESS) */ - -#undef READ_ACCESS_TYPE -#undef SHIFT -#undef DATA_TYPE -#undef SUFFIX -#undef USUFFIX -#undef DATA_SIZE -#undef ADDR_READ diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index 9939d61ca8..137703f6d7 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -27,7 +27,7 @@ #define CPUArchState struct CPUAlphaState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -295,7 +295,7 @@ struct CPUAlphaState { #define cpu_gen_code cpu_alpha_gen_code #define cpu_signal_handler cpu_alpha_signal_handler -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "cpu-qom.h" enum { @@ -520,7 +520,7 @@ static inline bool cpu_has_work(CPUState *cpu) | CPU_INTERRUPT_MCHK); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUAlphaState *env, TranslationBlock *tb) { diff --git a/target-alpha/helper.h b/target-alpha/helper.h index dd55f89aad..eac3041b87 100644 --- a/target-alpha/helper.h +++ b/target-alpha/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(excp, noreturn, env, int, int) DEF_HELPER_FLAGS_1(load_pcc, TCG_CALL_NO_RWG_SE, i64, env) @@ -119,4 +119,4 @@ DEF_HELPER_FLAGS_0(get_time, TCG_CALL_NO_RWG, i64) DEF_HELPER_FLAGS_2(set_alarm, TCG_CALL_NO_RWG, void, env, i64) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-alpha/mem_helper.c b/target-alpha/mem_helper.c index 64b33f6518..3d2cd61358 100644 --- a/target-alpha/mem_helper.c +++ b/target-alpha/mem_helper.c @@ -117,22 +117,22 @@ void cpu_unassigned_access(CPUAlphaState *env, hwaddr addr, dynamic_excp(env, 0, EXCP_MCHK, 0); } -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-alpha/translate.c b/target-alpha/translate.c index f57c8fd91f..2d0d891128 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -88,7 +88,7 @@ static TCGv cpu_usp; /* register names */ static char cpu_reg_names[10*4+21*5 + 10*5+21*6]; -#include "gen-icount.h" +#include "exec/gen-icount.h" static void alpha_translate_init(void) { diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c index 7743d67010..847318d1f4 100644 --- a/target-arm/arm-semi.c +++ b/target-arm/arm-semi.c @@ -33,7 +33,7 @@ #define ARM_ANGEL_HEAP_SIZE (128 * 1024 * 1024) #else #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "hw/arm-misc.h" #endif @@ -113,7 +113,7 @@ static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code) return code; } -#include "softmmu-semi.h" +#include "exec/softmmu-semi.h" #endif static target_ulong arm_semi_syscall_len; diff --git a/target-arm/cpu.h b/target-arm/cpu.h index e4ff918fa4..7f87efa7d9 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -27,7 +27,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -659,7 +659,7 @@ static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Bit usage in the TB flags field: */ #define ARM_TBFLAG_THUMB_SHIFT 0 @@ -726,7 +726,7 @@ static inline bool cpu_has_work(CPUState *cpu) (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUARMState *env, TranslationBlock *tb) { diff --git a/target-arm/helper.c b/target-arm/helper.c index ab8b734933..1f7a3c04c3 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1,5 +1,5 @@ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helper.h" #include "host-utils.h" #include "sysemu.h" diff --git a/target-arm/helper.h b/target-arm/helper.h index 3d23ceb257..8544f82a94 100644 --- a/target-arm/helper.h +++ b/target-arm/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_FLAGS_1(clz, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(sxtb16, TCG_CALL_NO_RWG_SE, i32, i32) @@ -463,4 +463,4 @@ DEF_HELPER_3(neon_qzip8, void, env, i32, i32) DEF_HELPER_3(neon_qzip16, void, env, i32, i32) DEF_HELPER_3(neon_qzip32, void, env, i32, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-arm/iwmmxt_helper.c b/target-arm/iwmmxt_helper.c index 1dd8d1a3af..7953b53f7e 100644 --- a/target-arm/iwmmxt_helper.c +++ b/target-arm/iwmmxt_helper.c @@ -23,7 +23,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "helper.h" /* iwMMXt macros extracted from GNU gdb. */ diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index 89280b6eeb..b028cc2c93 100644 --- a/target-arm/neon_helper.c +++ b/target-arm/neon_helper.c @@ -10,7 +10,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "helper.h" #define SIGNBIT (uint32_t)0x80000000 diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 1fcc975945..99610d7734 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -52,21 +52,21 @@ uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def, #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-arm/translate.c b/target-arm/translate.c index 10c548d5ba..988b5428d4 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -98,7 +98,7 @@ static TCGv_i32 cpu_exclusive_info; static TCGv cpu_F0s, cpu_F1s; static TCGv_i64 cpu_F0d, cpu_F1d; -#include "gen-icount.h" +#include "exec/gen-icount.h" static const char *regnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", diff --git a/target-cris/cpu.h b/target-cris/cpu.h index 2c27506d0d..63e6234f11 100644 --- a/target-cris/cpu.h +++ b/target-cris/cpu.h @@ -27,7 +27,7 @@ #define CPUArchState struct CPUCRISState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #define TARGET_HAS_ICE 1 @@ -270,7 +270,7 @@ static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls) #define SFR_RW_MM_TLB_LO env->pregs[PR_SRS]][5 #define SFR_RW_MM_TLB_HI env->pregs[PR_SRS]][6 -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc, target_ulong *cs_base, int *flags) @@ -292,7 +292,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUCRISState *env, TranslationBlock *tb) { diff --git a/target-cris/helper.h b/target-cris/helper.h index fe12083a16..8e8365cf69 100644 --- a/target-cris/helper.h +++ b/target-cris/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_2(tlb_flush_pid, void, env, i32) @@ -26,4 +26,4 @@ DEF_HELPER_FLAGS_3(evaluate_flags_move_2, TCG_CALL_NO_SE, i32, env, i32, i32) DEF_HELPER_1(evaluate_flags, void, env) DEF_HELPER_1(top_evaluate_flags, void, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index 31db42494d..cd0e17e099 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -35,21 +35,21 @@ #endif #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-cris/translate.c b/target-cris/translate.c index 2a92727843..09e6011ea4 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -70,7 +70,7 @@ static TCGv env_btaken; static TCGv env_btarget; static TCGv env_pc; -#include "gen-icount.h" +#include "exec/gen-icount.h" /* This is the state at translation time. */ typedef struct DisasContext { diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c index 4240278edd..50d866f4c6 100644 --- a/target-i386/arch_dump.c +++ b/target-i386/arch_dump.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "dump.h" #include "elf.h" diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c index 41f9d1c3e3..6dfb0f3f56 100644 --- a/target-i386/arch_memory_mapping.c +++ b/target-i386/arch_memory_mapping.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" /* PAE Paging or IA-32e Paging */ diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 386c4f6d98..f3f50a0499 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -44,7 +44,7 @@ #define CPUArchState struct CPUX86State -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -1117,7 +1117,7 @@ static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "svm.h" #if !defined(CONFIG_USER_ONLY) @@ -1137,7 +1137,7 @@ static inline bool cpu_has_work(CPUState *cpu) CPU_INTERRUPT_MCE)); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUX86State *env, TranslationBlock *tb) { diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c index dfc34a6253..44f3d27944 100644 --- a/target-i386/fpu_helper.c +++ b/target-i386/fpu_helper.c @@ -22,7 +22,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #define FPU_RC_MASK 0xc00 diff --git a/target-i386/helper.h b/target-i386/helper.h index 970fcd98ff..9ed720d0ed 100644 --- a/target-i386/helper.h +++ b/target-i386/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_FLAGS_2(cc_compute_all, TCG_CALL_NO_SE, i32, env, int) DEF_HELPER_FLAGS_2(cc_compute_c, TCG_CALL_NO_SE, i32, env, int) @@ -220,4 +220,4 @@ DEF_HELPER_3(rclq, tl, env, tl, tl) DEF_HELPER_3(rcrq, tl, env, tl, tl) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-i386/ioport-user.c b/target-i386/ioport-user.c index 03fac22d22..f7636e0a87 100644 --- a/target-i386/ioport-user.c +++ b/target-i386/ioport-user.c @@ -21,7 +21,7 @@ #include "qemu.h" #include "qemu-common.h" -#include "ioport.h" +#include "exec/ioport.h" void cpu_outb(pio_addr_t addr, uint8_t val) { diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 824930c749..f7c95d5424 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -25,12 +25,12 @@ #include "kvm.h" #include "kvm_i386.h" #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "qemu-config.h" #include "hw/pc.h" #include "hw/apic.h" -#include "ioport.h" +#include "exec/ioport.h" #include "hyperv.h" #include "hw/pci/pci.h" diff --git a/target-i386/mem_helper.c b/target-i386/mem_helper.c index d0be77b1ed..6cf9ba076e 100644 --- a/target-i386/mem_helper.c +++ b/target-i386/mem_helper.c @@ -21,7 +21,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* broken thread support */ @@ -114,16 +114,16 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #endif diff --git a/target-i386/misc_helper.c b/target-i386/misc_helper.c index a02037963f..db3126b79b 100644 --- a/target-i386/misc_helper.c +++ b/target-i386/misc_helper.c @@ -18,11 +18,11 @@ */ #include "cpu.h" -#include "ioport.h" +#include "exec/ioport.h" #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* check if Port I/O is allowed in TSS */ diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index ff9337441b..be795d71eb 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -25,7 +25,7 @@ //#define DEBUG_PCALL #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #ifdef DEBUG_PCALL diff --git a/target-i386/svm_helper.c b/target-i386/svm_helper.c index a238d95a55..3f246e9073 100644 --- a/target-i386/svm_helper.c +++ b/target-i386/svm_helper.c @@ -18,11 +18,11 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* Secure Virtual Machine helpers */ diff --git a/target-i386/translate.c b/target-i386/translate.c index 026201e98e..32d21f52d0 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -65,7 +65,7 @@ static TCGv cpu_tmp5; static uint8_t gen_opc_cc_op[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" #ifdef TARGET_X86_64 static int x86_64_hregs; diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h index 7243b4f7c7..4e202db32c 100644 --- a/target-lm32/cpu.h +++ b/target-lm32/cpu.h @@ -26,7 +26,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" struct CPULM32State; typedef struct CPULM32State CPULM32State; @@ -238,7 +238,7 @@ static inline int cpu_interrupts_enabled(CPULM32State *env) return env->ie & IE_IE; } -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline target_ulong cpu_get_pc(CPULM32State *env) { @@ -260,7 +260,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPULM32State *env, TranslationBlock *tb) { diff --git a/target-lm32/helper.h b/target-lm32/helper.h index 07f5670172..3ea15a6e80 100644 --- a/target-lm32/helper.h +++ b/target-lm32/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_1(hlt, void, env) @@ -11,4 +11,4 @@ DEF_HELPER_1(rcsr_ip, i32, env) DEF_HELPER_1(rcsr_jtx, i32, env) DEF_HELPER_1(rcsr_jrx, i32, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 97b9625c1a..27b3cef25c 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -9,13 +9,13 @@ #if !defined(CONFIG_USER_ONLY) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void helper_raise_exception(CPULM32State *env, uint32_t index) { diff --git a/target-lm32/translate.c b/target-lm32/translate.c index 9683b9a4b5..6b87340174 100644 --- a/target-lm32/translate.c +++ b/target-lm32/translate.c @@ -53,7 +53,7 @@ static TCGv cpu_deba; static TCGv cpu_bp[4]; static TCGv cpu_wp[4]; -#include "gen-icount.h" +#include "exec/gen-icount.h" enum { OP_FMT_RI, diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index f4fcdeee7a..b37af1fffd 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -26,7 +26,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -242,7 +242,7 @@ static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, target_ulong *cs_base, int *flags) @@ -261,7 +261,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUM68KState *env, TranslationBlock *tb) { diff --git a/target-m68k/helper.c b/target-m68k/helper.c index a5d0100473..a9a277865f 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helpers.h" diff --git a/target-m68k/helpers.h b/target-m68k/helpers.h index 8112b44a58..2b024502ba 100644 --- a/target-m68k/helpers.h +++ b/target-m68k/helpers.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_1(bitrev, i32, i32) DEF_HELPER_1(ff1, i32, i32) @@ -51,4 +51,4 @@ DEF_HELPER_3(set_mac_extu, void, env, i32, i32) DEF_HELPER_2(flush_flags, void, env, i32) DEF_HELPER_2(raise_exception, void, env, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-m68k/m68k-semi.c b/target-m68k/m68k-semi.c index 9f7a24cdb4..e6c7dd2f9b 100644 --- a/target-m68k/m68k-semi.c +++ b/target-m68k/m68k-semi.c @@ -33,8 +33,8 @@ #define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024) #else #include "qemu-common.h" -#include "gdbstub.h" -#include "softmmu-semi.h" +#include "exec/gdbstub.h" +#include "exec/softmmu-semi.h" #endif #include "sysemu.h" diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c index b97ba5e28f..16df24c0ca 100644 --- a/target-m68k/op_helper.c +++ b/target-m68k/op_helper.c @@ -34,21 +34,21 @@ void do_interrupt_m68k_hardirq(CPUM68KState *env) extern int semihosting_enabled; -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-m68k/translate.c b/target-m68k/translate.c index d955c7a409..1c9b5ec8d4 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -61,7 +61,7 @@ static TCGv NULL_QREG; /* Used to distinguish stores from bad addressing modes. */ static TCGv store_dummy; -#include "gen-icount.h" +#include "exec/gen-icount.h" void m68k_tcg_init(void) { diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h index 585bbd6dbc..5358941ae4 100644 --- a/target-microblaze/cpu.h +++ b/target-microblaze/cpu.h @@ -26,7 +26,7 @@ #define CPUArchState struct CPUMBState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" struct CPUMBState; typedef struct CPUMBState CPUMBState; @@ -353,7 +353,7 @@ static inline int cpu_interrupts_enabled(CPUMBState *env) return env->sregs[SR_MSR] & MSR_IE; } -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline target_ulong cpu_get_pc(CPUMBState *env) { @@ -381,7 +381,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUMBState *env, TranslationBlock *tb) { diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h index a667122e91..4e51429498 100644 --- a/target-microblaze/helper.h +++ b/target-microblaze/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_1(debug, void, env) @@ -38,4 +38,4 @@ DEF_HELPER_2(stackprot, void, env, i32) DEF_HELPER_2(get, i32, i32, i32) DEF_HELPER_3(put, void, i32, i32, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 7593517094..343dcc15e7 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -26,17 +26,17 @@ #define D(x) #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index 5946a5ba5c..58ce71267d 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -50,7 +50,7 @@ static TCGv env_btaken; static TCGv env_btarget; static TCGv env_iflags; -#include "gen-icount.h" +#include "exec/gen-icount.h" /* This is the state at translation time. */ typedef struct DisasContext { diff --git a/target-mips/cpu.h b/target-mips/cpu.h index aebb2d5b79..183ba9fbd8 100644 --- a/target-mips/cpu.h +++ b/target-mips/cpu.h @@ -12,7 +12,7 @@ #include "config.h" #include "qemu-common.h" #include "mips-defs.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" struct CPUMIPSState; @@ -560,7 +560,7 @@ static inline int cpu_mips_hw_interrupts_pending(CPUMIPSState *env) return r; } -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Memory access type : * may be needed for precise access rights control and precise exceptions. @@ -738,7 +738,7 @@ static inline bool cpu_has_work(CPUState *cpu) return has_work; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUMIPSState *env, TranslationBlock *tb) { diff --git a/target-mips/helper.h b/target-mips/helper.h index acf9ebd759..9ea60ec1bb 100644 --- a/target-mips/helper.h +++ b/target-mips/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int) DEF_HELPER_2(raise_exception, noreturn, env, i32) @@ -707,4 +707,4 @@ DEF_HELPER_FLAGS_2(rddsp, 0, tl, tl, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 2972ae3f0a..157f59e6bf 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -23,7 +23,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #ifndef CONFIG_USER_ONLY @@ -2116,16 +2116,16 @@ static void QEMU_NORETURN do_unaligned_access(CPUMIPSState *env, #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" static void do_unaligned_access(CPUMIPSState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr) diff --git a/target-mips/translate.c b/target-mips/translate.c index 44e7617395..e81ff38476 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -1017,7 +1017,7 @@ static TCGv_i64 fpu_f64[32]; static uint32_t gen_opc_hflags[OPC_BUF_SIZE]; static target_ulong gen_opc_btarget[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" #define gen_helper_0e0i(name, arg) do { \ TCGv_i32 helper_tmp = tcg_const_i32(arg); \ diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h index c7b1750153..8dc56c2873 100644 --- a/target-openrisc/cpu.h +++ b/target-openrisc/cpu.h @@ -30,7 +30,7 @@ struct OpenRISCCPU; #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" #include "qemu/cpu.h" #include "qapi/error.h" @@ -398,7 +398,7 @@ static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, target_ulong *pc, @@ -427,7 +427,7 @@ static inline bool cpu_has_work(CPUState *cpu) CPU_INTERRUPT_TIMER); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline target_ulong cpu_get_pc(CPUOpenRISCState *env) { diff --git a/target-openrisc/helper.h b/target-openrisc/helper.h index 404d46447f..2af97901ce 100644 --- a/target-openrisc/helper.h +++ b/target-openrisc/helper.h @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ -#include "def-helper.h" +#include "exec/def-helper.h" /* exception */ DEF_HELPER_FLAGS_2(exception, 0, void, env, i32) @@ -67,4 +67,4 @@ DEF_HELPER_FLAGS_1(rfe, 0, void, env) DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) DEF_HELPER_FLAGS_4(mfspr, 0, tl, env, tl, tl, tl) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c index 642da7de49..226ce43513 100644 --- a/target-openrisc/interrupt.c +++ b/target-openrisc/interrupt.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target-openrisc/mmu.c b/target-openrisc/mmu.c index f2a6523cfb..4eee44434f 100644 --- a/target-openrisc/mmu.c +++ b/target-openrisc/mmu.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target-openrisc/mmu_helper.c b/target-openrisc/mmu_helper.c index d2edebcb49..e46b092984 100644 --- a/target-openrisc/mmu_helper.c +++ b/target-openrisc/mmu_helper.c @@ -21,20 +21,20 @@ #include "cpu.h" #ifndef CONFIG_USER_ONLY -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUOpenRISCState *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 2cb9d69826..5883347fa7 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" #include "qemu-common.h" @@ -61,7 +61,7 @@ static TCGv_i32 fpcsr; static TCGv machi, maclo; static TCGv fpmaddhi, fpmaddlo; static TCGv_i32 env_flags; -#include "gen-icount.h" +#include "exec/gen-icount.h" void openrisc_translate_init(void) { diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 742d4f8ae3..610bcd544b 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -73,7 +73,7 @@ #define CPUArchState struct CPUPPCState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -1251,7 +1251,7 @@ static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /*****************************************************************************/ /* CRF definitions */ @@ -2224,7 +2224,7 @@ static inline bool cpu_has_work(CPUState *cpu) return msr_ee && (env->interrupt_request & CPU_INTERRUPT_HARD); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUPPCState *env, TranslationBlock *tb) { diff --git a/target-ppc/helper.h b/target-ppc/helper.h index e588370e29..d2e9a55f28 100644 --- a/target-ppc/helper.h +++ b/target-ppc/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(raise_exception_err, void, env, i32, i32) DEF_HELPER_2(raise_exception, void, env, i32) @@ -414,4 +414,4 @@ DEF_HELPER_3(store_601_batl, void, env, i32, tl) DEF_HELPER_3(store_601_batu, void, env, i32, tl) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index baad6eb75b..83f98729a2 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -9,7 +9,7 @@ #ifndef __KVM_PPC_H__ #define __KVM_PPC_H__ -#include "memory.h" +#include "exec/memory.h" void kvmppc_init(void); diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c index 04c01445f9..2d7a349c32 100644 --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -23,7 +23,7 @@ #include "helper_regs.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ //#define DEBUG_OP @@ -257,16 +257,16 @@ STVE(stvewx, cpu_stl_data, bswap32, u32) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 8a53105f89..a74d76b5a6 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -71,7 +71,7 @@ static TCGv cpu_reserve; static TCGv cpu_fpscr; static TCGv_i32 cpu_access_type; -#include "gen-icount.h" +#include "exec/gen-icount.h" void ppc_translate_init(void) { diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 984ca9fc63..cca63abf5d 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -24,7 +24,7 @@ */ #include "disas/bfd.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include #include "kvm_ppc.h" #include "arch_init.h" diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 0f9a1f7340..acb8c73174 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -28,13 +28,13 @@ #define CPUArchState struct CPUS390XState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #define TARGET_PAGE_BITS 12 #define TARGET_PHYS_ADDR_SPACE_BITS 64 #define TARGET_VIRT_ADDR_SPACE_BITS 64 -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "softfloat.h" @@ -350,7 +350,7 @@ static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls) #define cpu_gen_code cpu_s390x_gen_code #define cpu_signal_handler cpu_s390x_signal_handler -#include "exec-all.h" +#include "exec/exec-all.h" #ifdef CONFIG_USER_ONLY diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c index ee9420d446..173f820428 100644 --- a/target-s390x/fpu_helper.c +++ b/target-s390x/fpu_helper.c @@ -22,7 +22,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* #define DEBUG_HELPER */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index b7b812a7e6..6e9b209713 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-timer.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" diff --git a/target-s390x/helper.h b/target-s390x/helper.h index ac44eabd53..c4926c52ad 100644 --- a/target-s390x/helper.h +++ b/target-s390x/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(exception, void, env, i32) DEF_HELPER_4(nc, i32, env, i32, i64, i64) @@ -149,4 +149,4 @@ DEF_HELPER_3(cksm, void, env, i32, i32) DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_NO_RWG_SE, i32, env, i32, i64, i64, i64) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 91b25e309d..bed21e6e1c 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -24,21 +24,21 @@ /*****************************************************************************/ /* Softmmu support */ #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index 38d8f2a627..a3336e16b0 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "memory.h" +#include "exec/memory.h" #include "host-utils.h" #include "helper.h" #include @@ -30,7 +30,7 @@ #endif #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #include "sysemu.h" #endif diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 6e144a67a2..28e61c54b8 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -37,7 +37,7 @@ /* global register indexes */ static TCGv_ptr cpu_env; -#include "gen-icount.h" +#include "exec/gen-icount.h" #include "helper.h" #define GEN_HELPER 1 #include "helper.h" diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h index 9a0e72b1fb..7c50c798b8 100644 --- a/target-sh4/cpu.h +++ b/target-sh4/cpu.h @@ -39,7 +39,7 @@ #define CPUArchState struct CPUSH4State -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -264,7 +264,7 @@ static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Memory access type */ enum { @@ -378,7 +378,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUSH4State *env, TranslationBlock *tb) { diff --git a/target-sh4/helper.h b/target-sh4/helper.h index 304b77ba3f..7162448497 100644 --- a/target-sh4/helper.h +++ b/target-sh4/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_1(ldtlb, void, env) DEF_HELPER_1(raise_illegal_instruction, noreturn, env) @@ -47,4 +47,4 @@ DEF_HELPER_2(ftrc_DT, i32, env, f64) DEF_HELPER_3(fipr, void, env, i32, i32) DEF_HELPER_2(ftrv, void, env, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c index e8e87f5152..09e3d23aff 100644 --- a/target-sh4/op_helper.c +++ b/target-sh4/op_helper.c @@ -22,21 +22,21 @@ #include "helper.h" #ifndef CONFIG_USER_ONLY -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUSH4State *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-sh4/translate.c b/target-sh4/translate.c index 41d53e5c51..260aaab559 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -69,7 +69,7 @@ static TCGv cpu_flags, cpu_delayed_pc; static uint32_t gen_opc_hflags[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" static void sh4_translate_init(void) { diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 013ecbd063..0ed511a399 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -25,7 +25,7 @@ #define CPUArchState struct CPUSPARCState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -701,7 +701,7 @@ static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" #ifdef TARGET_SPARC64 /* sun4u.c */ @@ -767,7 +767,7 @@ static inline bool cpu_has_work(CPUState *cpu) cpu_interrupts_enabled(env1); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUSPARCState *env, TranslationBlock *tb) { diff --git a/target-sparc/helper.h b/target-sparc/helper.h index 098c482216..cfcdab1ea4 100644 --- a/target-sparc/helper.h +++ b/target-sparc/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" #ifndef TARGET_SPARC64 DEF_HELPER_1(rett, void, env) @@ -173,4 +173,4 @@ VIS_CMPHELPER(cmpne); DEF_HELPER_1(compute_psr, void, env); DEF_HELPER_1(compute_C_icc, i32, env); -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 8d815e5038..cf1bddf2db 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -68,21 +68,21 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr); -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #endif #if defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) diff --git a/target-sparc/mmu_helper.c b/target-sparc/mmu_helper.c index 2c89b20b68..a9649ae064 100644 --- a/target-sparc/mmu_helper.c +++ b/target-sparc/mmu_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Sparc MMU emulation */ diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 88802b8486..ca75e1aa48 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -64,7 +64,7 @@ static TCGv_i64 cpu_fpr[TARGET_DPREGS]; static target_ulong gen_opc_npc[OPC_BUF_SIZE]; static target_ulong gen_opc_jump_pc[2]; -#include "gen-icount.h" +#include "exec/gen-icount.h" typedef struct DisasContext { target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */ diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h index 676c5d9d99..cd8f730756 100644 --- a/target-unicore32/cpu.h +++ b/target-unicore32/cpu.h @@ -23,7 +23,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" #define NB_MMU_MODES 2 @@ -157,9 +157,9 @@ static inline void cpu_set_tls(CPUUniCore32State *env, target_ulong newtls) env->regs[16] = newtls; } -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "cpu-qom.h" -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUUniCore32State *env, TranslationBlock *tb) { diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 4b6856137d..2adbd1675d 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -10,7 +10,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helper.h" #include "host-utils.h" #include "ui/console.h" diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h index a4b81494aa..e85ce6c201 100644 --- a/target-unicore32/helper.h +++ b/target-unicore32/helper.h @@ -6,7 +6,7 @@ * published by the Free Software Foundation, or (at your option) any * later version. See the COPYING file in the top-level directory. */ -#include "def-helper.h" +#include "exec/def-helper.h" #ifndef CONFIG_USER_ONLY DEF_HELPER_4(cp0_set, void, env, i32, i32, i32) @@ -65,4 +65,4 @@ DEF_HELPER_2(ucf64_si2df, f64, f32, env) DEF_HELPER_2(ucf64_sf2si, f32, f32, env) DEF_HELPER_2(ucf64_df2si, f32, f64, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-unicore32/op_helper.c b/target-unicore32/op_helper.c index b8172ba682..6443ffec1c 100644 --- a/target-unicore32/op_helper.c +++ b/target-unicore32/op_helper.c @@ -242,16 +242,16 @@ uint32_t HELPER(ror_cc)(CPUUniCore32State *env, uint32_t x, uint32_t i) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUUniCore32State *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 8c49f4d701..218e95eaca 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -55,7 +55,7 @@ static TCGv_i32 cpu_R[32]; static TCGv cpu_F0s, cpu_F1s; static TCGv_i64 cpu_F0d, cpu_F1d; -#include "gen-icount.h" +#include "exec/gen-icount.h" static const char *regnames[] = { "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07", diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index 804fdef56a..d1a594cda2 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "core-dc232b/core-isa.h" diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index d643f41d37..ead6b3b128 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "qemu-common.h" #include "host-utils.h" diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index e36b0de9d5..a387aeeca5 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "core-fsf/core-isa.h" diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index 08fd5bc395..5acf78c692 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -35,7 +35,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "fpu/softfloat.h" #define TARGET_HAS_ICE 1 @@ -512,8 +512,8 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc, } } -#include "cpu-all.h" -#include "exec-all.h" +#include "exec/cpu-all.h" +#include "exec/exec-all.h" static inline int cpu_has_work(CPUState *cpu) { diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index bf05575eb5..3d7a399008 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" diff --git a/target-xtensa/helper.h b/target-xtensa/helper.h index 5b4cd2700f..38d7157f34 100644 --- a/target-xtensa/helper.h +++ b/target-xtensa/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(exception, noreturn, env, i32) DEF_HELPER_3(exception_cause, noreturn, env, i32, i32) @@ -58,4 +58,4 @@ DEF_HELPER_4(ult_s, void, env, i32, f32, f32) DEF_HELPER_4(ole_s, void, env, i32, f32, f32) DEF_HELPER_4(ule_s, void, env, i32, f32, f32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c index 84f0449f79..a93abcb1dd 100644 --- a/target-xtensa/op_helper.c +++ b/target-xtensa/op_helper.c @@ -36,16 +36,16 @@ static void do_unaligned_access(CPUXtensaState *env, #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" static void do_unaligned_access(CPUXtensaState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr) diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 4e81cbd9ec..3c2d1853d6 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -31,7 +31,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" #include "qemu-log.h" @@ -76,7 +76,7 @@ static TCGv_i32 cpu_FR[16]; static TCGv_i32 cpu_SR[256]; static TCGv_i32 cpu_UR[256]; -#include "gen-icount.h" +#include "exec/gen-icount.h" typedef struct XtensaReg { const char *name; diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 47612fe260..c3ac85e054 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -992,7 +992,7 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index) #ifdef CONFIG_SOFTMMU -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c index de500ae181..5b27cf6f12 100644 --- a/tcg/hppa/tcg-target.c +++ b/tcg/hppa/tcg-target.c @@ -906,7 +906,7 @@ static void tcg_out_movcond(TCGContext *s, int cond, TCGArg ret, } #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 6f3ad3ceab..ae8274652a 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -982,7 +982,7 @@ static void tcg_out_jmp(TCGContext *s, tcg_target_long dest) #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c index 06570bea38..2373d9ef79 100644 --- a/tcg/ia64/tcg-target.c +++ b/tcg/ia64/tcg-target.c @@ -1491,7 +1491,7 @@ static inline void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGArg ret, #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* Load and compare a TLB entry, and return the result in (p6, p7). R2 is loaded with the address of the addend TLB entry. diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index ae2b274d85..bd8c858989 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -920,7 +920,7 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c index d72d396270..29ca934e66 100644 --- a/tcg/ppc/tcg-target.c +++ b/tcg/ppc/tcg-target.c @@ -549,7 +549,7 @@ static void add_qemu_ldst_label (TCGContext *s, label->label_ptr[0] = label_ptr; } -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 5403fc1f91..833fe0c10b 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -546,7 +546,7 @@ static void tcg_out_ldsta (TCGContext *s, int ret, int addr, #if defined (CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index fd9286f52d..e12a15221a 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -299,7 +299,7 @@ static const uint8_t tcg_cond_to_ltr_cond[] = { #ifdef CONFIG_SOFTMMU -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index f146647874..03db514a1d 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -831,7 +831,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tci.c b/tci.c index 54cf1d9524..2b2c11f259 100644 --- a/tci.c +++ b/tci.c @@ -25,7 +25,7 @@ #endif #include "qemu-common.h" -#include "exec-all.h" /* MAX_OPC_PARAM_IARGS */ +#include "exec/exec-all.h" /* MAX_OPC_PARAM_IARGS */ #include "tcg-op.h" /* Marker for missing code. */ diff --git a/thunk.c b/thunk.c index 8ebbbb46b6..3cca047509 100644 --- a/thunk.c +++ b/thunk.c @@ -21,7 +21,7 @@ #include #include "qemu.h" -#include "thunk.h" +#include "exec/user/thunk.h" //#define DEBUG diff --git a/thunk.h b/thunk.h deleted file mode 100644 index 87025c3b04..0000000000 --- a/thunk.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Generic thunking code to convert data between host and target CPU - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef THUNK_H -#define THUNK_H - -#include -#include "cpu.h" - -/* types enums definitions */ - -typedef enum argtype { - TYPE_NULL, - TYPE_CHAR, - TYPE_SHORT, - TYPE_INT, - TYPE_LONG, - TYPE_ULONG, - TYPE_PTRVOID, /* pointer on unknown data */ - TYPE_LONGLONG, - TYPE_ULONGLONG, - TYPE_PTR, - TYPE_ARRAY, - TYPE_STRUCT, - TYPE_OLDDEVT, -} argtype; - -#define MK_PTR(type) TYPE_PTR, type -#define MK_ARRAY(type, size) TYPE_ARRAY, size, type -#define MK_STRUCT(id) TYPE_STRUCT, id - -#define THUNK_TARGET 0 -#define THUNK_HOST 1 - -typedef struct { - /* standard struct handling */ - const argtype *field_types; - int nb_fields; - int *field_offsets[2]; - /* special handling */ - void (*convert[2])(void *dst, const void *src); - int size[2]; - int align[2]; - const char *name; -} StructEntry; - -/* Translation table for bitmasks... */ -typedef struct bitmask_transtbl { - unsigned int x86_mask; - unsigned int x86_bits; - unsigned int alpha_mask; - unsigned int alpha_bits; -} bitmask_transtbl; - -void thunk_register_struct(int id, const char *name, const argtype *types); -void thunk_register_struct_direct(int id, const char *name, - const StructEntry *se1); -const argtype *thunk_convert(void *dst, const void *src, - const argtype *type_ptr, int to_host); -#ifndef NO_THUNK_TYPE_SIZE - -extern StructEntry struct_entries[]; - -int thunk_type_size_array(const argtype *type_ptr, int is_host); -int thunk_type_align_array(const argtype *type_ptr, int is_host); - -static inline int thunk_type_size(const argtype *type_ptr, int is_host) -{ - int type, size; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return sizeof(void *); - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_OLDDEVT: - if (is_host) { -#if defined(HOST_X86_64) - return 8; -#elif defined(HOST_ALPHA) || defined(HOST_IA64) || defined(HOST_MIPS) || \ - defined(HOST_PARISC) || defined(HOST_SPARC64) - return 4; -#elif defined(HOST_PPC) - return sizeof(void *); -#else - return 2; -#endif - } else { -#if defined(TARGET_X86_64) - return 8; -#elif defined(TARGET_ALPHA) || defined(TARGET_IA64) || defined(TARGET_MIPS) || \ - defined(TARGET_PARISC) || defined(TARGET_SPARC64) - return 4; -#elif defined(TARGET_PPC) - return TARGET_ABI_BITS / 8; -#else - return 2; -#endif - } - break; - case TYPE_ARRAY: - size = type_ptr[1]; - return size * thunk_type_size_array(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->size[is_host]; - default: - return -1; - } -} - -static inline int thunk_type_align(const argtype *type_ptr, int is_host) -{ - int type; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return sizeof(void *); - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_OLDDEVT: - return thunk_type_size(type_ptr, is_host); - case TYPE_ARRAY: - return thunk_type_align_array(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->align[is_host]; - default: - return -1; - } -} - -#endif /* NO_THUNK_TYPE_SIZE */ - -unsigned int target_to_host_bitmask(unsigned int x86_mask, - const bitmask_transtbl * trans_tbl); -unsigned int host_to_target_bitmask(unsigned int alpha_mask, - const bitmask_transtbl * trans_tbl); - -#endif diff --git a/translate-all.c b/translate-all.c index bbe06db6eb..e0cdad38c7 100644 --- a/translate-all.c +++ b/translate-all.c @@ -36,8 +36,8 @@ #include "disas/disas.h" #include "tcg.h" #include "qemu-timer.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) #include "qemu.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -57,7 +57,7 @@ #endif #endif -#include "cputlb.h" +#include "exec/cputlb.h" #include "translate-all.h" //#define DEBUG_TB_INVALIDATE diff --git a/vl.c b/vl.c index 975767a44b..015f0a4757 100644 --- a/vl.c +++ b/vl.c @@ -132,7 +132,7 @@ int main(int argc, char **argv) #include "monitor.h" #include "ui/console.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-timer.h" #include "qemu-char.h" #include "cache-utils.h" diff --git a/xen-all.c b/xen-all.c index e3a51ccc81..95d383f41f 100644 --- a/xen-all.c +++ b/xen-all.c @@ -19,7 +19,7 @@ #include "range.h" #include "xen-mapcache.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include #include diff --git a/xen-stub.c b/xen-stub.c index 921439263a..1ee841137e 100644 --- a/xen-stub.c +++ b/xen-stub.c @@ -10,7 +10,7 @@ #include "qemu-common.h" #include "hw/xen.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" void xenstore_store_pv_console_info(int i, CharDriverState *chr) -- cgit v1.2.3-55-g7522 From 1de7afc984b49af164e2619e6850b9732b173b34 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:20:00 +0100 Subject: misc: move include files to include/qemu/ Signed-off-by: Paolo Bonzini --- acl.c | 2 +- acl.h | 74 ----- aio-posix.c | 4 +- aio-win32.c | 4 +- arch_init.c | 6 +- async.c | 2 +- audio/alsaaudio.c | 2 +- audio/audio.c | 2 +- audio/audio.h | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 4 +- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- backends/rng-random.c | 2 +- bitmap.c | 4 +- bitmap.h | 222 ------------- bitops.c | 2 +- bitops.h | 362 -------------------- block-migration.c | 4 +- block.c | 6 +- block/blkdebug.c | 4 +- block/blkverify.c | 2 +- block/bochs.c | 2 +- block/cloop.c | 2 +- block/cow.c | 2 +- block/dmg.c | 4 +- block/gluster.c | 4 +- block/iscsi.c | 4 +- block/linux-aio.c | 4 +- block/nbd.c | 6 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 4 +- block/qed-table.c | 2 +- block/qed.c | 2 +- block/raw-posix.c | 8 +- block/raw-win32.c | 6 +- block/raw.c | 2 +- block/rbd.c | 2 +- block/sheepdog.c | 6 +- block/vdi.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- block/vvfat.c | 2 +- block/win32-aio.c | 6 +- blockdev-nbd.c | 2 +- blockdev.c | 4 +- blockdev.h | 2 +- blockjob.c | 2 +- bsd-user/main.c | 4 +- bsd-user/qemu.h | 2 +- bswap.h | 713 ---------------------------------------- bt-host.c | 2 +- bt-vhci.c | 2 +- buffered_file.c | 2 +- cache-utils.c | 2 +- cache-utils.h | 44 --- cmd.c | 2 +- compatfd.c | 2 +- compatfd.h | 44 --- compiler.h | 58 ---- cpu-exec.c | 2 +- cpus.c | 8 +- cutils.c | 6 +- device_tree.c | 4 +- dma-helpers.c | 4 +- envlist.c | 4 +- envlist.h | 22 -- event_notifier-posix.c | 4 +- event_notifier-win32.c | 4 +- event_notifier.h | 46 --- exec.c | 6 +- fpu/softfloat.h | 2 +- fsdev/qemu-fsdev-dummy.c | 4 +- fsdev/qemu-fsdev.c | 6 +- fsdev/qemu-fsdev.h | 2 +- fsdev/virtfs-proxy-helper.c | 4 +- fsdev/virtio-9p-marshal.c | 4 +- gdbstub.c | 2 +- hmp.c | 6 +- host-utils.c | 2 +- host-utils.h | 240 -------------- hw/9pfs/codir.c | 2 +- hw/9pfs/cofile.c | 2 +- hw/9pfs/cofs.c | 2 +- hw/9pfs/coxattr.c | 2 +- hw/9pfs/virtio-9p-coth.c | 2 +- hw/9pfs/virtio-9p-coth.h | 2 +- hw/9pfs/virtio-9p-device.c | 2 +- hw/9pfs/virtio-9p-handle.c | 2 +- hw/9pfs/virtio-9p-local.c | 2 +- hw/9pfs/virtio-9p-posix-acl.c | 2 +- hw/9pfs/virtio-9p-xattr.h | 2 +- hw/9pfs/virtio-9p.c | 2 +- hw/9pfs/virtio-9p.h | 2 +- hw/acpi.h | 2 +- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 2 +- hw/adlib.c | 2 +- hw/alpha_pci.c | 2 +- hw/apic.c | 4 +- hw/apic_internal.h | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 2 +- hw/arm_boot.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 2 +- hw/armv7m_nvic.c | 2 +- hw/baum.c | 2 +- hw/block-common.c | 2 +- hw/bt-hci-csr.c | 2 +- hw/bt-hci.c | 2 +- hw/bt-hid.c | 2 +- hw/bt-l2cap.c | 2 +- hw/cadence_ttc.c | 2 +- hw/cadence_uart.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231a.c | 2 +- hw/cuda.c | 2 +- hw/device-hotplug.c | 2 +- hw/dma.c | 2 +- hw/dp8393x.c | 2 +- hw/esp-pci.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_ser.c | 2 +- hw/etraxfs_timer.c | 2 +- hw/exynos4210_fimd.c | 2 +- hw/exynos4210_i2c.c | 2 +- hw/exynos4210_mct.c | 2 +- hw/exynos4210_pwm.c | 2 +- hw/exynos4210_rtc.c | 4 +- hw/fdc.c | 6 +- hw/fw_cfg.c | 4 +- hw/grlib_gptimer.c | 2 +- hw/hid.c | 2 +- hw/hpet.c | 2 +- hw/hw.h | 2 +- hw/i8254.c | 2 +- hw/i8254_common.c | 2 +- hw/i8259.c | 2 +- hw/ich9.h | 2 +- hw/ide/core.c | 4 +- hw/ide/qdev.c | 2 +- hw/imx_avic.c | 2 +- hw/imx_timer.c | 2 +- hw/intel-hda.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/pci-assign.c | 4 +- hw/lance.c | 4 +- hw/leon3.c | 2 +- hw/lm32_sys.c | 6 +- hw/lm32_timer.c | 4 +- hw/lm32_uart.c | 2 +- hw/lm832x.c | 2 +- hw/lpc_ich9.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mc146818rtc.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/megasas.c | 2 +- hw/microblaze_boot.c | 4 +- hw/milkymist-ac97.c | 2 +- hw/milkymist-hpdmc.c | 2 +- hw/milkymist-memcard.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-pfpu.c | 4 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 4 +- hw/milkymist-tmu2.c | 2 +- hw/milkymist-uart.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_r4k.c | 2 +- hw/mips_timer.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/omap1.c | 2 +- hw/omap2.c | 2 +- hw/omap_dma.c | 2 +- hw/omap_gptimer.c | 2 +- hw/omap_synctimer.c | 2 +- hw/onenand.c | 2 +- hw/openrisc_timer.c | 2 +- hw/pc.c | 2 +- hw/pci/msi.c | 2 +- hw/pci/msix.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 2 +- hw/pci/pcie.c | 2 +- hw/pci/shpc.c | 4 +- hw/pcnet-pci.c | 2 +- hw/pcnet.c | 4 +- hw/pcspk.c | 2 +- hw/pflash_cfi01.c | 4 +- hw/pflash_cfi02.c | 4 +- hw/piix_pci.c | 2 +- hw/pl031.c | 2 +- hw/ppc.c | 4 +- hw/ppc/e500.c | 4 +- hw/ppc405_boards.c | 2 +- hw/ppc405_uc.c | 4 +- hw/ppc4xx_devs.c | 2 +- hw/ppc_booke.c | 4 +- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 2 +- hw/ptimer.c | 4 +- hw/ptimer.h | 2 +- hw/pxa2xx_timer.c | 2 +- hw/q35.h | 2 +- hw/qdev-core.h | 6 +- hw/qdev-monitor.c | 2 +- hw/qxl-logger.c | 2 +- hw/qxl.c | 4 +- hw/qxl.h | 2 +- hw/rc4030.c | 2 +- hw/rtl8139.c | 4 +- hw/s390x/event-facility.h | 2 +- hw/s390x/sclpconsole.c | 2 +- hw/sb16.c | 4 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 2 +- hw/scsi-generic.c | 2 +- hw/sd.c | 2 +- hw/serial.c | 2 +- hw/sh_pci.c | 2 +- hw/sh_timer.c | 2 +- hw/slavio_timer.c | 2 +- hw/sm501.c | 2 +- hw/soc_dma.c | 2 +- hw/spapr.c | 2 +- hw/spitz.c | 2 +- hw/stellaris.c | 2 +- hw/strongarm.c | 2 +- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 2 +- hw/tusb6010.c | 2 +- hw/twl92230.c | 2 +- hw/usb.h | 2 +- hw/usb/combined-packet.c | 2 +- hw/usb/core.c | 2 +- hw/usb/dev-hid.c | 2 +- hw/usb/dev-network.c | 6 +- hw/usb/dev-serial.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 4 +- hw/usb/dev-uas.c | 4 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-musb.c | 2 +- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 4 +- hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 4 +- hw/vfio_pci.c | 8 +- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/vga-pci.c | 2 +- hw/vga.c | 2 +- hw/vhost.c | 2 +- hw/vhost_net.c | 2 +- hw/virtex_ml507.c | 2 +- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 6 +- hw/virtio-pci.c | 4 +- hw/virtio-rng.c | 2 +- hw/virtio-serial-bus.c | 4 +- hw/virtio.c | 4 +- hw/virtio.h | 2 +- hw/vt82c686.c | 2 +- hw/watchdog.c | 6 +- hw/watchdog.h | 2 +- hw/wdt_i6300esb.c | 2 +- hw/wdt_ib700.c | 2 +- hw/xen_backend.c | 2 +- hw/xen_common.h | 2 +- hw/xen_domainbuild.c | 4 +- hw/xen_pt.c | 2 +- hw/xen_pt_config_init.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 4 +- hw/xilinx_axienet.c | 2 +- hw/xilinx_spi.c | 2 +- hw/xilinx_spips.c | 4 +- hw/xilinx_timer.c | 2 +- hw/xtensa_pic.c | 4 +- hw/zynq_slcr.c | 2 +- include/block/aio.h | 4 +- include/block/block.h | 2 +- include/block/block_int.h | 6 +- include/block/coroutine.h | 4 +- include/block/coroutine_int.h | 2 +- include/block/thread-pool.h | 4 +- include/exec/cpu-all.h | 2 +- include/exec/cpu-common.h | 4 +- include/exec/cpu-defs.h | 4 +- include/exec/exec-all.h | 2 +- include/exec/gen-icount.h | 2 +- include/exec/memory.h | 4 +- include/exec/softmmu_template.h | 2 +- include/migration/migration.h | 2 +- include/net/net.h | 4 +- include/net/slirp.h | 2 +- include/qapi/error.h | 2 +- include/qapi/opts-visitor.h | 2 +- include/qapi/qmp/qdict.h | 2 +- include/qapi/qmp/qerror.h | 2 +- include/qapi/qmp/qjson.h | 2 +- include/qapi/qmp/qlist.h | 4 +- include/qemu/acl.h | 74 +++++ include/qemu/atomic.h | 67 ++++ include/qemu/bitmap.h | 222 +++++++++++++ include/qemu/bitops.h | 362 ++++++++++++++++++++ include/qemu/bswap.h | 713 ++++++++++++++++++++++++++++++++++++++++ include/qemu/cache-utils.h | 44 +++ include/qemu/compatfd.h | 44 +++ include/qemu/compiler.h | 58 ++++ include/qemu/config-file.h | 30 ++ include/qemu/envlist.h | 22 ++ include/qemu/error-report.h | 43 +++ include/qemu/event_notifier.h | 46 +++ include/qemu/host-utils.h | 240 ++++++++++++++ include/qemu/int128.h | 116 +++++++ include/qemu/iov.h | 102 ++++++ include/qemu/log.h | 160 +++++++++ include/qemu/main-loop.h | 306 +++++++++++++++++ include/qemu/module.h | 40 +++ include/qemu/notify.h | 43 +++ include/qemu/option.h | 158 +++++++++ include/qemu/option_int.h | 54 +++ include/qemu/osdep.h | 178 ++++++++++ include/qemu/queue.h | 414 +++++++++++++++++++++++ include/qemu/range.h | 29 ++ include/qemu/sockets.h | 77 +++++ include/qemu/thread-posix.h | 28 ++ include/qemu/thread-win32.h | 29 ++ include/qemu/thread.h | 56 ++++ include/qemu/timer.h | 310 +++++++++++++++++ include/qemu/tls.h | 52 +++ include/qemu/typedefs.h | 61 ++++ include/qemu/uri.h | 113 +++++++ include/qemu/xattr.h | 30 ++ include/qom/cpu.h | 2 +- include/qom/object.h | 2 +- include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- include/ui/spice-display.h | 2 +- int128.h | 116 ------- iohandler.c | 4 +- iov.c | 2 +- iov.h | 102 ------ kvm-all.c | 10 +- kvm.h | 2 +- libcacard/event.c | 2 +- libcacard/vreader.c | 2 +- libcacard/vscclient.c | 4 +- libfdt_env.h | 2 +- linux-user/main.c | 6 +- linux-user/qemu.h | 4 +- linux-user/syscall.c | 2 +- main-loop.c | 6 +- main-loop.h | 306 ----------------- memory.c | 2 +- memory_mapping.h | 2 +- migration-exec.c | 2 +- migration-fd.c | 4 +- migration-tcp.c | 2 +- migration-unix.c | 2 +- migration.c | 2 +- module.c | 4 +- module.h | 40 --- monitor.c | 8 +- nbd.c | 4 +- net/dump.c | 6 +- net/hub.c | 2 +- net/net.c | 6 +- net/queue.c | 2 +- net/slirp.c | 2 +- net/socket.c | 8 +- net/tap-bsd.c | 2 +- net/tap-linux.c | 2 +- net/tap-solaris.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 2 +- net/vde.c | 2 +- notify.c | 2 +- notify.h | 43 --- osdep.c | 2 +- osdep.h | 178 ---------- oslib-posix.c | 2 +- oslib-win32.c | 4 +- qapi/opts-visitor.c | 4 +- qapi/qapi-dealloc-visitor.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 2 +- qdict.c | 2 +- qemu-barrier.h | 67 ---- qemu-bridge-helper.c | 2 +- qemu-char.c | 4 +- qemu-char.h | 8 +- qemu-common.h | 10 +- qemu-config.c | 6 +- qemu-config.h | 30 -- qemu-coroutine-io.c | 4 +- qemu-coroutine-lock.c | 2 +- qemu-coroutine-sleep.c | 2 +- qemu-error.h | 43 --- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-log.c | 2 +- qemu-log.h | 160 --------- qemu-option-internal.h | 54 --- qemu-option.c | 4 +- qemu-option.h | 158 --------- qemu-progress.c | 2 +- qemu-queue.h | 414 ----------------------- qemu-seccomp.h | 2 +- qemu-sockets.c | 4 +- qemu-thread-posix.c | 2 +- qemu-thread-posix.h | 28 -- qemu-thread-win32.c | 2 +- qemu-thread-win32.h | 29 -- qemu-thread.h | 56 ---- qemu-timer-common.c | 2 +- qemu-timer.c | 4 +- qemu-timer.h | 310 ----------------- qemu-tls.h | 52 --- qemu-tool.c | 8 +- qemu-types.h | 61 ---- qemu-xattr.h | 30 -- qemu_socket.h | 77 ----- qga/channel-posix.c | 4 +- qga/commands-posix.c | 4 +- qga/main.c | 2 +- qlist.c | 2 +- qom/container.c | 2 +- range.h | 29 -- savevm.c | 10 +- scripts/qapi-commands.py | 2 +- slirp/if.c | 2 +- slirp/ip_input.c | 2 +- slirp/sbuf.c | 2 +- slirp/slirp.c | 2 +- slirp/slirp.h | 4 +- spice-qemu-char.c | 2 +- stubs/fd-register.c | 2 +- stubs/set-fd-handler.c | 2 +- sysemu.h | 12 +- target-alpha/int_helper.c | 2 +- target-alpha/sys_helper.c | 2 +- target-alpha/translate.c | 2 +- target-arm/helper.c | 4 +- target-arm/translate.c | 2 +- target-cris/helper.c | 2 +- target-cris/op_helper.c | 2 +- target-i386/cpu.c | 4 +- target-i386/excp_helper.c | 2 +- target-i386/int_helper.c | 2 +- target-i386/kvm.c | 4 +- target-i386/seg_helper.c | 2 +- target-lm32/helper.c | 2 +- target-lm32/op_helper.c | 2 +- target-m68k/translate.c | 2 +- target-microblaze/helper.c | 2 +- target-microblaze/op_helper.c | 2 +- target-mips/op_helper.c | 2 +- target-openrisc/int_helper.c | 2 +- target-openrisc/interrupt.c | 2 +- target-openrisc/mmu.c | 2 +- target-openrisc/translate.c | 4 +- target-ppc/int_helper.c | 2 +- target-ppc/kvm.c | 2 +- target-ppc/kvm_ppc.c | 2 +- target-ppc/mem_helper.c | 2 +- target-ppc/translate.c | 2 +- target-s390x/cpu.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/int_helper.c | 2 +- target-s390x/kvm.c | 2 +- target-s390x/misc_helper.c | 4 +- target-s390x/translate.c | 2 +- target-sparc/cpu.h | 2 +- target-sparc/helper.c | 2 +- target-sparc/machine.c | 2 +- target-unicore32/helper.c | 2 +- target-unicore32/translate.c | 2 +- target-xtensa/core-dc232b.c | 2 +- target-xtensa/core-dc233c.c | 2 +- target-xtensa/core-fsf.c | 2 +- target-xtensa/helper.c | 2 +- target-xtensa/op_helper.c | 2 +- target-xtensa/translate.c | 2 +- target-xtensa/xtensa-semi.c | 2 +- tcg/tcg.c | 6 +- tests/libqtest.c | 4 +- tests/tcg/test-i386-fprem.c | 4 +- tests/tcg/test-i386.c | 2 +- tests/test-iov.c | 4 +- tests/test-qmp-commands.c | 2 +- thread-pool.c | 8 +- trace/simple.c | 2 +- translate-all.c | 2 +- ui/console.c | 2 +- ui/sdl_zoom.c | 2 +- ui/spice-core.c | 10 +- ui/spice-display.c | 4 +- ui/vnc-auth-sasl.h | 2 +- ui/vnc-enc-tight.c | 2 +- ui/vnc-jobs.c | 2 +- ui/vnc-palette.h | 2 +- ui/vnc-tls.c | 2 +- ui/vnc-tls.h | 2 +- ui/vnc.c | 8 +- ui/vnc.h | 6 +- uri.c | 2 +- uri.h | 113 ------- vl.c | 18 +- xen-all.c | 2 +- xen-mapcache.c | 2 +- 529 files changed, 4978 insertions(+), 4978 deletions(-) delete mode 100644 acl.h delete mode 100644 bitmap.h delete mode 100644 bitops.h delete mode 100644 bswap.h delete mode 100644 cache-utils.h delete mode 100644 compatfd.h delete mode 100644 compiler.h delete mode 100644 envlist.h delete mode 100644 event_notifier.h delete mode 100644 host-utils.h create mode 100644 include/qemu/acl.h create mode 100644 include/qemu/atomic.h create mode 100644 include/qemu/bitmap.h create mode 100644 include/qemu/bitops.h create mode 100644 include/qemu/bswap.h create mode 100644 include/qemu/cache-utils.h create mode 100644 include/qemu/compatfd.h create mode 100644 include/qemu/compiler.h create mode 100644 include/qemu/config-file.h create mode 100644 include/qemu/envlist.h create mode 100644 include/qemu/error-report.h create mode 100644 include/qemu/event_notifier.h create mode 100644 include/qemu/host-utils.h create mode 100644 include/qemu/int128.h create mode 100644 include/qemu/iov.h create mode 100644 include/qemu/log.h create mode 100644 include/qemu/main-loop.h create mode 100644 include/qemu/module.h create mode 100644 include/qemu/notify.h create mode 100644 include/qemu/option.h create mode 100644 include/qemu/option_int.h create mode 100644 include/qemu/osdep.h create mode 100644 include/qemu/queue.h create mode 100644 include/qemu/range.h create mode 100644 include/qemu/sockets.h create mode 100644 include/qemu/thread-posix.h create mode 100644 include/qemu/thread-win32.h create mode 100644 include/qemu/thread.h create mode 100644 include/qemu/timer.h create mode 100644 include/qemu/tls.h create mode 100644 include/qemu/typedefs.h create mode 100644 include/qemu/uri.h create mode 100644 include/qemu/xattr.h delete mode 100644 int128.h delete mode 100644 iov.h delete mode 100644 main-loop.h delete mode 100644 module.h delete mode 100644 notify.h delete mode 100644 osdep.h delete mode 100644 qemu-barrier.h delete mode 100644 qemu-config.h delete mode 100644 qemu-error.h delete mode 100644 qemu-log.h delete mode 100644 qemu-option-internal.h delete mode 100644 qemu-option.h delete mode 100644 qemu-queue.h delete mode 100644 qemu-thread-posix.h delete mode 100644 qemu-thread-win32.h delete mode 100644 qemu-thread.h delete mode 100644 qemu-timer.h delete mode 100644 qemu-tls.h delete mode 100644 qemu-types.h delete mode 100644 qemu-xattr.h delete mode 100644 qemu_socket.h delete mode 100644 range.h delete mode 100644 uri.h (limited to 'hw/sh_timer.c') diff --git a/acl.c b/acl.c index e840b9b633..81ac25599b 100644 --- a/acl.c +++ b/acl.c @@ -24,7 +24,7 @@ #include "qemu-common.h" -#include "acl.h" +#include "qemu/acl.h" #ifdef CONFIG_FNMATCH #include diff --git a/acl.h b/acl.h deleted file mode 100644 index 0ef780401f..0000000000 --- a/acl.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * QEMU access control list management - * - * Copyright (C) 2009 Red Hat, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __QEMU_ACL_H__ -#define __QEMU_ACL_H__ - -#include "qemu-queue.h" - -typedef struct qemu_acl_entry qemu_acl_entry; -typedef struct qemu_acl qemu_acl; - -struct qemu_acl_entry { - char *match; - int deny; - - QTAILQ_ENTRY(qemu_acl_entry) next; -}; - -struct qemu_acl { - char *aclname; - unsigned int nentries; - QTAILQ_HEAD(,qemu_acl_entry) entries; - int defaultDeny; -}; - -qemu_acl *qemu_acl_init(const char *aclname); - -qemu_acl *qemu_acl_find(const char *aclname); - -int qemu_acl_party_is_allowed(qemu_acl *acl, - const char *party); - -void qemu_acl_reset(qemu_acl *acl); - -int qemu_acl_append(qemu_acl *acl, - int deny, - const char *match); -int qemu_acl_insert(qemu_acl *acl, - int deny, - const char *match, - int index); -int qemu_acl_remove(qemu_acl *acl, - const char *match); - -#endif /* __QEMU_ACL_H__ */ - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * tab-width: 8 - * End: - */ diff --git a/aio-posix.c b/aio-posix.c index d1e1bc2c75..88d09e1cfb 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -15,8 +15,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { diff --git a/aio-win32.c b/aio-win32.c index 9a26f9c3d9..f5ea027f8c 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { EventNotifier *e; diff --git a/arch_init.c b/arch_init.c index f627253a20..9dacf5689b 100644 --- a/arch_init.c +++ b/arch_init.c @@ -31,8 +31,8 @@ #include "config.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" #include "arch_init.h" #include "audio/audio.h" #include "hw/pc.h" @@ -45,7 +45,7 @@ #include "exec/address-spaces.h" #include "hw/pcspk.h" #include "migration/page_cache.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" diff --git a/async.c b/async.c index 6df4caf68a..72d268ae35 100644 --- a/async.c +++ b/async.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /***********************************************************/ /* bottom halves (can be seen as timers which expire ASAP) */ diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index cd553c2a7b..e4e5442631 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -23,7 +23,7 @@ */ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "audio.h" #if QEMU_GNUC_PREREQ(4, 3) diff --git a/audio/audio.c b/audio/audio.c index a0cc727020..eb2222c10f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -24,7 +24,7 @@ #include "hw/hw.h" #include "audio.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #define AUDIO_CAP "audio" diff --git a/audio/audio.h b/audio/audio.h index a70fda97e3..e7ea39777e 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -25,7 +25,7 @@ #define QEMU_AUDIO_H #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" typedef void (*audio_callback_fn) (void *opaque, int avail); diff --git a/audio/noaudio.c b/audio/noaudio.c index 54958f8623..9f23aa2cb3 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define AUDIO_CAP "noaudio" #include "audio_int.h" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 8249a00449..00be9c91e3 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -31,8 +31,8 @@ #include #endif #include "qemu-common.h" -#include "main-loop.h" -#include "host-utils.h" +#include "qemu/main-loop.h" +#include "qemu/host-utils.h" #include "audio.h" #define AUDIO_CAP "oss" diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6f15591a74..bc24557de4 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -18,7 +18,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/qemu-spice.h" #define AUDIO_CAP "spice" diff --git a/audio/wavaudio.c b/audio/wavaudio.c index a449b5127e..950fa8f19c 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio.h" #define AUDIO_CAP "wav" diff --git a/backends/rng-random.c b/backends/rng-random.c index c201953f29..d479ce8c56 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -13,7 +13,7 @@ #include "qemu/rng-random.h" #include "qemu/rng.h" #include "qapi/qmp/qerror.h" -#include "main-loop.h" +#include "qemu/main-loop.h" struct RndRandom { diff --git a/bitmap.c b/bitmap.c index a62c8ba681..687841dcec 100644 --- a/bitmap.c +++ b/bitmap.c @@ -9,8 +9,8 @@ * Version 2. */ -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" /* * bitmaps provide an array of bits, implemented using an an diff --git a/bitmap.h b/bitmap.h deleted file mode 100644 index 08755eba11..0000000000 --- a/bitmap.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Bitmap Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITMAP_H -#define BITMAP_H - -#include "qemu-common.h" -#include "bitops.h" - -/* - * The available bitmap operations and their rough meaning in the - * case that the bitmap is a single unsigned long are thus: - * - * Note that nbits should be always a compile time evaluable constant. - * Otherwise many inlines will generate horrible code. - * - * bitmap_zero(dst, nbits) *dst = 0UL - * bitmap_fill(dst, nbits) *dst = ~0UL - * bitmap_copy(dst, src, nbits) *dst = *src - * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 - * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 - * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 - * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) - * bitmap_complement(dst, src, nbits) *dst = ~(*src) - * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? - * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? - * bitmap_empty(src, nbits) Are all bits zero in *src? - * bitmap_full(src, nbits) Are all bits set in *src? - * bitmap_set(dst, pos, nbits) Set specified bit area - * bitmap_clear(dst, pos, nbits) Clear specified bit area - * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area - */ - -/* - * Also the following operations apply to bitmaps. - * - * set_bit(bit, addr) *addr |= bit - * clear_bit(bit, addr) *addr &= ~bit - * change_bit(bit, addr) *addr ^= bit - * test_bit(bit, addr) Is bit set in *addr? - * test_and_set_bit(bit, addr) Set bit and return old value - * test_and_clear_bit(bit, addr) Clear bit and return old value - * test_and_change_bit(bit, addr) Change bit and return old value - * find_first_zero_bit(addr, nbits) Position first zero bit in *addr - * find_first_bit(addr, nbits) Position first set bit in *addr - * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit - * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit - */ - -#define BITMAP_LAST_WORD_MASK(nbits) \ - ( \ - ((nbits) % BITS_PER_LONG) ? \ - (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ - ) - -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - -#define small_nbits(nbits) \ - ((nbits) <= BITS_PER_LONG) - -int slow_bitmap_empty(const unsigned long *bitmap, int bits); -int slow_bitmap_full(const unsigned long *bitmap, int bits); -int slow_bitmap_equal(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, - int bits); -void slow_bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits); -void slow_bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits); -int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_intersects(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); - -static inline unsigned long *bitmap_new(int nbits) -{ - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - return g_malloc0(len); -} - -static inline void bitmap_zero(unsigned long *dst, int nbits) -{ - if (small_nbits(nbits)) { - *dst = 0UL; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); - } -} - -static inline void bitmap_fill(unsigned long *dst, int nbits) -{ - size_t nlongs = BITS_TO_LONGS(nbits); - if (!small_nbits(nbits)) { - int len = (nlongs - 1) * sizeof(unsigned long); - memset(dst, 0xff, len); - } - dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); -} - -static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memcpy(dst, src, len); - } -} - -static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & *src2) != 0; - } - return slow_bitmap_and(dst, src1, src2, nbits); -} - -static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 | *src2; - } else { - slow_bitmap_or(dst, src1, src2, nbits); - } -} - -static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 ^ *src2; - } else { - slow_bitmap_xor(dst, src1, src2, nbits); - } -} - -static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & ~(*src2)) != 0; - } - return slow_bitmap_andnot(dst, src1, src2, nbits); -} - -static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); - } else { - slow_bitmap_complement(dst, src, nbits); - } -} - -static inline int bitmap_equal(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_equal(src1, src2, nbits); - } -} - -static inline int bitmap_empty(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_empty(src, nbits); - } -} - -static inline int bitmap_full(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_full(src, nbits); - } -} - -static inline int bitmap_intersects(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; - } else { - return slow_bitmap_intersects(src1, src2, nbits); - } -} - -void bitmap_set(unsigned long *map, int i, int len); -void bitmap_clear(unsigned long *map, int start, int nr); -unsigned long bitmap_find_next_zero_area(unsigned long *map, - unsigned long size, - unsigned long start, - unsigned int nr, - unsigned long align_mask); - -#endif /* BITMAP_H */ diff --git a/bitops.c b/bitops.c index d9de71f7e8..4c3a836a01 100644 --- a/bitops.c +++ b/bitops.c @@ -11,7 +11,7 @@ * 2 of the License, or (at your option) any later version. */ -#include "bitops.h" +#include "qemu/bitops.h" #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) diff --git a/bitops.h b/bitops.h deleted file mode 100644 index 74e14e5724..0000000000 --- a/bitops.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Bitops Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITOPS_H -#define BITOPS_H - -#include "qemu-common.h" - -#define BITS_PER_BYTE CHAR_BIT -#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) - -#define BIT(nr) (1UL << (nr)) -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) - -/** - * bitops_ffs - find first bit in word. - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static unsigned long bitops_ffsl(unsigned long word) -{ - int num = 0; - -#if LONG_MAX > 0x7FFFFFFF - if ((word & 0xffffffff) == 0) { - num += 32; - word >>= 32; - } -#endif - if ((word & 0xffff) == 0) { - num += 16; - word >>= 16; - } - if ((word & 0xff) == 0) { - num += 8; - word >>= 8; - } - if ((word & 0xf) == 0) { - num += 4; - word >>= 4; - } - if ((word & 0x3) == 0) { - num += 2; - word >>= 2; - } - if ((word & 0x1) == 0) { - num += 1; - } - return num; -} - -/** - * bitops_fls - find last (most-significant) set bit in a long word - * @word: the word to search - * - * Undefined if no set bit exists, so code should check against 0 first. - */ -static inline unsigned long bitops_flsl(unsigned long word) -{ - int num = BITS_PER_LONG - 1; - -#if LONG_MAX > 0x7FFFFFFF - if (!(word & (~0ul << 32))) { - num -= 32; - word <<= 32; - } -#endif - if (!(word & (~0ul << (BITS_PER_LONG-16)))) { - num -= 16; - word <<= 16; - } - if (!(word & (~0ul << (BITS_PER_LONG-8)))) { - num -= 8; - word <<= 8; - } - if (!(word & (~0ul << (BITS_PER_LONG-4)))) { - num -= 4; - word <<= 4; - } - if (!(word & (~0ul << (BITS_PER_LONG-2)))) { - num -= 2; - - word <<= 2; - } - if (!(word & (~0ul << (BITS_PER_LONG-1)))) - num -= 1; - return num; -} - -/** - * ffz - find first zero in word. - * @word: The word to search - * - * Undefined if no zero exists, so code should check against ~0UL first. - */ -static inline unsigned long ffz(unsigned long word) -{ - return bitops_ffsl(~word); -} - -/** - * set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - */ -static inline void set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p |= mask; -} - -/** - * clear_bit - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - */ -static inline void clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p &= ~mask; -} - -/** - * change_bit - Toggle a bit in memory - * @nr: Bit to change - * @addr: Address to start counting from - */ -static inline void change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p ^= mask; -} - -/** - * test_and_set_bit - Set a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - */ -static inline int test_and_set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old | mask; - return (old & mask) != 0; -} - -/** - * test_and_clear_bit - Clear a bit and return its old value - * @nr: Bit to clear - * @addr: Address to count from - */ -static inline int test_and_clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old & ~mask; - return (old & mask) != 0; -} - -/** - * test_and_change_bit - Change a bit and return its old value - * @nr: Bit to change - * @addr: Address to count from - */ -static inline int test_and_change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old ^ mask; - return (old & mask) != 0; -} - -/** - * test_bit - Determine whether a bit is set - * @nr: bit number to test - * @addr: Address to start counting from - */ -static inline int test_bit(int nr, const unsigned long *addr) -{ - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); -} - -/** - * find_last_bit - find the last set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit, or size. - */ -unsigned long find_last_bit(const unsigned long *addr, - unsigned long size); - -/** - * find_next_bit - find the next set bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ -unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, unsigned long offset); - -/** - * find_next_zero_bit - find the next cleared bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ - -unsigned long find_next_zero_bit(const unsigned long *addr, - unsigned long size, - unsigned long offset); - -/** - * find_first_bit - find the first set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit. - */ -static inline unsigned long find_first_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_bit(addr, size, 0); -} - -/** - * find_first_zero_bit - find the first cleared bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first cleared bit. - */ -static inline unsigned long find_first_zero_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_zero_bit(addr, size, 0); -} - -static inline unsigned long hweight_long(unsigned long w) -{ - unsigned long count; - - for (count = 0; w; w >>= 1) { - count += w & 1; - } - return count; -} - -/** - * extract32: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 32 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 32 bit word. It is valid to request that - * all 32 bits are returned (ie @length 32 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint32_t extract32(uint32_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 32 - start); - return (value >> start) & (~0U >> (32 - length)); -} - -/** - * extract64: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 64 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 64 bit word. It is valid to request that - * all 64 bits are returned (ie @length 64 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint64_t extract64(uint64_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 64 - start); - return (value >> start) & (~0ULL >> (64 - length)); -} - -/** - * deposit32: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 32 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 32 bit word. - * It is valid to request that all 32 bits are modified (ie @length - * 32 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint32_t deposit32(uint32_t value, int start, int length, - uint32_t fieldval) -{ - uint32_t mask; - assert(start >= 0 && length > 0 && length <= 32 - start); - mask = (~0U >> (32 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -/** - * deposit64: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 64 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 64 bit word. - * It is valid to request that all 64 bits are modified (ie @length - * 64 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint64_t deposit64(uint64_t value, int start, int length, - uint64_t fieldval) -{ - uint64_t mask; - assert(start >= 0 && length > 0 && length <= 64 - start); - mask = (~0ULL >> (64 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -#endif diff --git a/block-migration.c b/block-migration.c index 2d2dcbda94..4e865a6781 100644 --- a/block-migration.c +++ b/block-migration.c @@ -16,8 +16,8 @@ #include "qemu-common.h" #include "block/block_int.h" #include "hw/hw.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "migration/block.h" #include "migration/migration.h" #include "blockdev.h" diff --git a/block.c b/block.c index 0e7f18c6d3..1af4b99ee8 100644 --- a/block.c +++ b/block.c @@ -27,13 +27,13 @@ #include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qjson.h" #include "sysemu.h" -#include "notify.h" +#include "qemu/notify.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_BSD #include diff --git a/block/blkdebug.c b/block/blkdebug.c index cd2866e7bd..6f7463772b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -23,9 +23,9 @@ */ #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" typedef struct BDRVBlkdebugState { int state; diff --git a/block/blkverify.c b/block/blkverify.c index cde5098e5a..a7dd45909b 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -8,7 +8,7 @@ */ #include -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "block/block_int.h" typedef struct { diff --git a/block/bochs.c b/block/bochs.c index 2cc7524782..1b1d9cdbe5 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/cloop.c b/block/cloop.c index da29ff379c..5a0d0d805f 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include typedef struct BDRVCloopState { diff --git a/block/cow.c b/block/cow.c index 1438ae1e3b..a33ce950d4 100644 --- a/block/cow.c +++ b/block/cow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ /* COW block driver using file system holes */ diff --git a/block/dmg.c b/block/dmg.c index 6ee505a9f5..ac397dc8f7 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -23,8 +23,8 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "bswap.h" -#include "module.h" +#include "qemu/bswap.h" +#include "qemu/module.h" #include typedef struct BDRVDMGState { diff --git a/block/gluster.c b/block/gluster.c index 4cb4e60227..0f2c32a3fa 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -17,8 +17,8 @@ */ #include #include "block/block_int.h" -#include "qemu_socket.h" -#include "uri.h" +#include "qemu/sockets.h" +#include "qemu/uri.h" typedef struct GlusterAIOCB { BlockDriverAIOCB common; diff --git a/block/iscsi.c b/block/iscsi.c index 77e619a1fd..041ee07de3 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -27,8 +27,8 @@ #include #include #include "qemu-common.h" -#include "qemu-config.h" -#include "qemu-error.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include "trace.h" #include "hw/scsi-defs.h" diff --git a/block/linux-aio.c b/block/linux-aio.c index 28e5a04e12..ee0f8d10c9 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -9,9 +9,9 @@ */ #include "qemu-common.h" #include "block/aio.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include diff --git a/block/nbd.c b/block/nbd.c index 38d6b90ab2..a5812948d2 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -28,10 +28,10 @@ #include "qemu-common.h" #include "block/nbd.h" -#include "uri.h" +#include "qemu/uri.h" #include "block/block_int.h" -#include "module.h" -#include "qemu_socket.h" +#include "qemu/module.h" +#include "qemu/sockets.h" #include #include diff --git a/block/parallels.c b/block/parallels.c index ae88cd6359..377375046f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/qcow.c b/block/qcow.c index f36671196e..4276610afd 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "migration/migration.h" diff --git a/block/qcow2.c b/block/qcow2.c index 205d910a52..d603f98a9c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -23,11 +23,11 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "block/qcow2.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/qerror.h" #include "trace.h" diff --git a/block/qed-table.c b/block/qed-table.c index de845ec3d0..76d2dcccf8 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -13,7 +13,7 @@ */ #include "trace.h" -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" typedef struct { diff --git a/block/qed.c b/block/qed.c index 10d0827482..cf85d8f2b4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -12,7 +12,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" diff --git a/block/raw-posix.c b/block/raw-posix.c index 4e73885269..91159c7887 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include "raw-aio.h" #if defined(__APPLE__) && (__MACH__) diff --git a/block/raw-win32.c b/block/raw-win32.c index 9269fe84c0..f58334be08 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "raw-aio.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/block/raw.c b/block/raw.c index 6aec93dadb..75812db3c2 100644 --- a/block/raw.c +++ b/block/raw.c @@ -1,7 +1,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" static int raw_open(BlockDriverState *bs, int flags) { diff --git a/block/rbd.c b/block/rbd.c index 8def2f174c..8cd10a7b59 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -14,7 +14,7 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include diff --git a/block/sheepdog.c b/block/sheepdog.c index da70df2d00..13dc023fdb 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -13,10 +13,10 @@ */ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu_socket.h" +#include "qemu/error-report.h" +#include "qemu/sockets.h" #include "block/block_int.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SD_PROTO_VER 0x01 diff --git a/block/vdi.c b/block/vdi.c index b1d199a2e5..7b6231941b 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -51,7 +51,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) diff --git a/block/vmdk.c b/block/vmdk.c index 77a1a67c61..19298c2a3e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #include diff --git a/block/vpc.c b/block/vpc.c index 47b5518aee..7948609e50 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) #include diff --git a/block/vvfat.c b/block/vvfat.c index a63c3ea7cd..83706ce556 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -26,7 +26,7 @@ #include #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #ifndef S_IWGRP diff --git a/block/win32-aio.c b/block/win32-aio.c index 606e4d6925..46a5db78cc 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "qemu-common.h" #include "block/aio.h" #include "raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include #include diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 596b47499d..95b621699a 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -17,7 +17,7 @@ #include "qmp-commands.h" #include "trace.h" #include "block/nbd.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" static int server_fd = -1; diff --git a/blockdev.c b/blockdev.c index a2308fa718..3ebff44310 100644 --- a/blockdev.c +++ b/blockdev.c @@ -12,8 +12,8 @@ #include "block/blockjob.h" #include "monitor/monitor.h" #include "qapi/qmp/qerror.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/types.h" #include "sysemu.h" #include "block/block_int.h" diff --git a/blockdev.h b/blockdev.h index 4134864758..1fe533299e 100644 --- a/blockdev.h +++ b/blockdev.h @@ -12,7 +12,7 @@ #include "block/block.h" #include "qapi/error.h" -#include "qemu-queue.h" +#include "qemu/queue.h" void blockdev_mark_auto_del(BlockDriverState *bs); void blockdev_auto_del(BlockDriverState *bs); diff --git a/blockjob.c b/blockjob.c index 4bc60c7378..ca80df1d0e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -33,7 +33,7 @@ #include "qapi/qmp/qjson.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, diff --git a/bsd-user/main.c b/bsd-user/main.c index 095ae8eaaa..1dc033046b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -31,8 +31,8 @@ /* For tb_lock */ #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c64c3ccca3..a826086dab 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -146,7 +146,7 @@ int get_osversion(void); void fork_start(void); void fork_end(int child); -#include "qemu-log.h" +#include "qemu/log.h" /* strace.c */ void diff --git a/bswap.h b/bswap.h deleted file mode 100644 index cc7f84d30f..0000000000 --- a/bswap.h +++ /dev/null @@ -1,713 +0,0 @@ -#ifndef BSWAP_H -#define BSWAP_H - -#include "config-host.h" - -#include -#include "softfloat.h" - -#ifdef CONFIG_MACHINE_BSWAP_H -#include -#include -#include -#else - -#ifdef CONFIG_BYTESWAP_H -#include -#else - -#define bswap_16(x) \ -({ \ - uint16_t __x = (x); \ - ((uint16_t)( \ - (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ - (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ -}) - -#define bswap_32(x) \ -({ \ - uint32_t __x = (x); \ - ((uint32_t)( \ - (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ -}) - -#define bswap_64(x) \ -({ \ - uint64_t __x = (x); \ - ((uint64_t)( \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ -}) - -#endif /* !CONFIG_BYTESWAP_H */ - -static inline uint16_t bswap16(uint16_t x) -{ - return bswap_16(x); -} - -static inline uint32_t bswap32(uint32_t x) -{ - return bswap_32(x); -} - -static inline uint64_t bswap64(uint64_t x) -{ - return bswap_64(x); -} - -#endif /* ! CONFIG_MACHINE_BSWAP_H */ - -static inline void bswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void bswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void bswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#if defined(HOST_WORDS_BIGENDIAN) -#define be_bswap(v, size) (v) -#define le_bswap(v, size) bswap ## size(v) -#define be_bswaps(v, size) -#define le_bswaps(p, size) *p = bswap ## size(*p); -#else -#define le_bswap(v, size) (v) -#define be_bswap(v, size) bswap ## size(v) -#define le_bswaps(v, size) -#define be_bswaps(p, size) *p = bswap ## size(*p); -#endif - -#define CPU_CONVERT(endian, size, type)\ -static inline type endian ## size ## _to_cpu(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline type cpu_to_ ## endian ## size(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline void endian ## size ## _to_cpus(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## s(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline type endian ## size ## _to_cpup(const type *p)\ -{\ - return endian ## size ## _to_cpu(*p);\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ -{\ - *p = cpu_to_ ## endian ## size(v);\ -} - -CPU_CONVERT(be, 16, uint16_t) -CPU_CONVERT(be, 32, uint32_t) -CPU_CONVERT(be, 64, uint64_t) - -CPU_CONVERT(le, 16, uint16_t) -CPU_CONVERT(le, 32, uint32_t) -CPU_CONVERT(le, 64, uint64_t) - -/* unaligned versions (optimized for frequent unaligned accesses)*/ - -#if defined(__i386__) || defined(_ARCH_PPC) - -#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) -#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) -#define le16_to_cpupu(p) le16_to_cpup(p) -#define le32_to_cpupu(p) le32_to_cpup(p) -#define be32_to_cpupu(p) be32_to_cpup(p) - -#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) -#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) -#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) - -#else - -static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; -} - -static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; - p1[2] = v >> 16; - p1[3] = v >> 24; -} - -static inline uint16_t le16_to_cpupu(const uint16_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8); -} - -static inline uint32_t le32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); -} - -static inline uint32_t be32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); -} - -static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 8; - p1[1] = v & 0xff; -} - -static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 24; - p1[1] = v >> 16; - p1[2] = v >> 8; - p1[3] = v & 0xff; -} - -static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 56; - p1[1] = v >> 48; - p1[2] = v >> 40; - p1[3] = v >> 32; - p1[4] = v >> 24; - p1[5] = v >> 16; - p1[6] = v >> 8; - p1[7] = v & 0xff; -} - -#endif - -#ifdef HOST_WORDS_BIGENDIAN -#define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) -#else -#define cpu_to_32wu cpu_to_le32wu -#define leul_to_cpu(v) (v) -#endif - -#undef le_bswap -#undef be_bswap -#undef le_bswaps -#undef be_bswaps - -/* len must be one of 1, 2, 4 */ -static inline uint32_t qemu_bswap_len(uint32_t value, int len) -{ - return bswap32(value) >> (32 - 8 * len); -} - -typedef union { - float32 f; - uint32_t l; -} CPU_FloatU; - -typedef union { - float64 d; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upper; - uint32_t lower; - } l; -#else - struct { - uint32_t lower; - uint32_t upper; - } l; -#endif - uint64_t ll; -} CPU_DoubleU; - -typedef union { - floatx80 d; - struct { - uint64_t lower; - uint16_t upper; - } l; -} CPU_LDoubleU; - -typedef union { - float128 q; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upmost; - uint32_t upper; - uint32_t lower; - uint32_t lowest; - } l; - struct { - uint64_t upper; - uint64_t lower; - } ll; -#else - struct { - uint32_t lowest; - uint32_t lower; - uint32_t upper; - uint32_t upmost; - } l; - struct { - uint64_t lower; - uint64_t upper; - } ll; -#endif -} CPU_QuadU; - -/* unaligned/endian-independent pointer access */ - -/* - * the generic syntax is: - * - * load: ld{type}{sign}{size}{endian}_p(ptr) - * - * store: st{type}{size}{endian}_p(ptr, val) - * - * Note there are small differences with the softmmu access API! - * - * type is: - * (empty): integer access - * f : float access - * - * sign is: - * (empty): for floats or 32 bit size - * u : unsigned - * s : signed - * - * size is: - * b: 8 bits - * w: 16 bits - * l: 32 bits - * q: 64 bits - * - * endian is: - * (empty): 8 bit access - * be : big endian - * le : little endian - */ -static inline int ldub_p(const void *ptr) -{ - return *(uint8_t *)ptr; -} - -static inline int ldsb_p(const void *ptr) -{ - return *(int8_t *)ptr; -} - -static inline void stb_p(void *ptr, int v) -{ - *(uint8_t *)ptr = v; -} - -/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the - kernel handles unaligned load/stores may give better results, but - it is a system wide setting : bad */ -#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -/* conservative code for little endian unaligned accesses */ -static inline int lduw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8); -#endif -} - -static inline int ldsw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return (int16_t)val; -#else - const uint8_t *p = ptr; - return (int16_t)(p[0] | (p[1] << 8)); -#endif -} - -static inline int ldl_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -#endif -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - const uint8_t *p = ptr; - uint32_t v1, v2; - v1 = ldl_le_p(p); - v2 = ldl_le_p(p + 4); - return v1 | ((uint64_t)v2 << 32); -} - -static inline void stw_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; -#endif -} - -static inline void stl_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; - p[2] = v >> 16; - p[3] = v >> 24; -#endif -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - uint8_t *p = ptr; - stl_le_p(p, (uint32_t)v); - stl_le_p(p + 4, v >> 32); -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_le_p(ptr); - return u.f; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_le_p(ptr, u.i); -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.lower = ldl_le_p(ptr); - u.l.upper = ldl_le_p(ptr + 4); - return u.d; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_le_p(ptr, u.l.lower); - stl_le_p(ptr + 4, u.l.upper); -} - -#else - -static inline int lduw_le_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_le_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_le_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_le_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_le_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} -#endif - -#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -static inline int lduw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return ((b[0] << 8) | b[1]); -#endif -} - -static inline int ldsw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return (int16_t)val; -#else - const uint8_t *b = ptr; - return (int16_t)((b[0] << 8) | b[1]); -#endif -} - -static inline int ldl_be_p(const void *ptr) -{ -#if defined(__i386__) || defined(__x86_64__) - int val; - asm volatile ("movl %1, %0\n" - "bswap %0\n" - : "=r" (val) - : "m" (*(uint32_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; -#endif -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - uint32_t a,b; - a = ldl_be_p(ptr); - b = ldl_be_p((uint8_t *)ptr + 4); - return (((uint64_t)a<<32)|b); -} - -static inline void stw_be_p(void *ptr, int v) -{ -#if defined(__i386__) - asm volatile ("xchgb %b0, %h0\n" - "movw %w0, %1\n" - : "=q" (v) - : "m" (*(uint16_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 8; - d[1] = v; -#endif -} - -static inline void stl_be_p(void *ptr, int v) -{ -#if defined(__i386__) || defined(__x86_64__) - asm volatile ("bswap %0\n" - "movl %0, %1\n" - : "=r" (v) - : "m" (*(uint32_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 24; - d[1] = v >> 16; - d[2] = v >> 8; - d[3] = v; -#endif -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - stl_be_p(ptr, v >> 32); - stl_be_p((uint8_t *)ptr + 4, v); -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_be_p(ptr); - return u.f; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_be_p(ptr, u.i); -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.upper = ldl_be_p(ptr); - u.l.lower = ldl_be_p((uint8_t *)ptr + 4); - return u.d; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_be_p(ptr, u.l.upper); - stl_be_p((uint8_t *)ptr + 4, u.l.lower); -} - -#else - -static inline int lduw_be_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_be_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_be_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_be_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_be_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} - -#endif - -#endif /* BSWAP_H */ diff --git a/bt-host.c b/bt-host.c index 65aaca337c..4f5f9f93c5 100644 --- a/bt-host.c +++ b/bt-host.c @@ -19,7 +19,7 @@ #include "qemu-common.h" #include "bt-host.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 # include diff --git a/bt-vhci.c b/bt-vhci.c index 13c0e53729..f5d856a809 100644 --- a/bt-vhci.c +++ b/bt-vhci.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "bt-host.h" #include "hw/bt.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define VHCI_DEV "/dev/vhci" #define VHCI_UDEV "/dev/hci_vhci" diff --git a/buffered_file.c b/buffered_file.c index f13443ee91..27627a1b71 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "buffered_file.h" //#define DEBUG_BUFFERED_FILE diff --git a/cache-utils.c b/cache-utils.c index 2db5af2db1..b94013a8cb 100644 --- a/cache-utils.c +++ b/cache-utils.c @@ -1,4 +1,4 @@ -#include "cache-utils.h" +#include "qemu/cache-utils.h" #if defined(_ARCH_PPC) struct qemu_cache_conf qemu_cache_conf = { diff --git a/cache-utils.h b/cache-utils.h deleted file mode 100644 index 2c57f78fc1..0000000000 --- a/cache-utils.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef QEMU_CACHE_UTILS_H -#define QEMU_CACHE_UTILS_H - -#if defined(_ARCH_PPC) - -#include /* uintptr_t */ - -struct qemu_cache_conf { - unsigned long dcache_bsize; - unsigned long icache_bsize; -}; - -extern struct qemu_cache_conf qemu_cache_conf; - -void qemu_cache_utils_init(char **envp); - -/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - unsigned long p, start1, stop1; - unsigned long dsize = qemu_cache_conf.dcache_bsize; - unsigned long isize = qemu_cache_conf.icache_bsize; - - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { - asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { - asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - asm volatile ("isync" : : : "memory"); -} - -#else -#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) -#endif - -#endif /* QEMU_CACHE_UTILS_H */ diff --git a/cmd.c b/cmd.c index 01a8c3a299..10a8688b2d 100644 --- a/cmd.c +++ b/cmd.c @@ -25,7 +25,7 @@ #include "cmd.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define _(x) x /* not gettext support yet */ diff --git a/compatfd.c b/compatfd.c index 42f81cafe4..9cf3f2834d 100644 --- a/compatfd.c +++ b/compatfd.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "compatfd.h" +#include "qemu/compatfd.h" #include #include diff --git a/compatfd.h b/compatfd.h deleted file mode 100644 index 6b04877b97..0000000000 --- a/compatfd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * signalfd/eventfd compatibility - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_COMPATFD_H -#define QEMU_COMPATFD_H - -#include - -struct qemu_signalfd_siginfo { - uint32_t ssi_signo; /* Signal number */ - int32_t ssi_errno; /* Error number (unused) */ - int32_t ssi_code; /* Signal code */ - uint32_t ssi_pid; /* PID of sender */ - uint32_t ssi_uid; /* Real UID of sender */ - int32_t ssi_fd; /* File descriptor (SIGIO) */ - uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ - uint32_t ssi_band; /* Band event (SIGIO) */ - uint32_t ssi_overrun; /* POSIX timer overrun count */ - uint32_t ssi_trapno; /* Trap number that caused signal */ - int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ - int32_t ssi_int; /* Integer sent by sigqueue(2) */ - uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ - uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ - uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ - uint64_t ssi_addr; /* Address that generated signal - (for hardware-generated signals) */ - uint8_t pad[48]; /* Pad size to 128 bytes (allow for - additional fields in the future) */ -}; - -int qemu_signalfd(const sigset_t *mask); -bool qemu_signalfd_available(void); - -#endif diff --git a/compiler.h b/compiler.h deleted file mode 100644 index 2f7998b6c1..0000000000 --- a/compiler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* public domain */ - -#ifndef COMPILER_H -#define COMPILER_H - -#include "config-host.h" - -/*---------------------------------------------------------------------------- -| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. -| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. -*----------------------------------------------------------------------------*/ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define QEMU_GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -# define QEMU_GNUC_PREREQ(maj, min) 0 -#endif - -#define QEMU_NORETURN __attribute__ ((__noreturn__)) - -#if QEMU_GNUC_PREREQ(3, 4) -#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define QEMU_WARN_UNUSED_RESULT -#endif - -#if defined(_WIN32) -# define QEMU_PACKED __attribute__((gcc_struct, packed)) -#else -# define QEMU_PACKED __attribute__((packed)) -#endif - -#define cat(x,y) x ## y -#define cat2(x,y) cat(x,y) -#define QEMU_BUILD_BUG_ON(x) \ - typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; - -#if defined __GNUC__ -# if !QEMU_GNUC_PREREQ(4, 4) - /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ -# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) -# else - /* Use gnu_printf when supported (qemu uses standard format strings). */ -# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) -# if defined(_WIN32) - /* Map __printf__ to __gnu_printf__ because we want standard format strings - * even when MinGW or GLib include files use __printf__. */ -# define __printf__ __gnu_printf__ -# endif -# endif -#else -#define GCC_ATTR /**/ -#define GCC_FMT_ATTR(n, m) -#endif - -#endif /* COMPILER_H */ diff --git a/cpu-exec.c b/cpu-exec.c index b5a32b84e4..54e62ed551 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" #include "qtest.h" int tb_invalidated_flag; diff --git a/cpus.c b/cpus.c index 3a66401e0d..036418d62c 100644 --- a/cpus.c +++ b/cpus.c @@ -32,14 +32,14 @@ #include "kvm.h" #include "qmp-commands.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "cpus.h" #include "qtest.h" -#include "main-loop.h" -#include "bitmap.h" +#include "qemu/main-loop.h" +#include "qemu/bitmap.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" #endif #ifdef CONFIG_LINUX diff --git a/cutils.c b/cutils.c index 4f0692f78e..d06590b330 100644 --- a/cutils.c +++ b/cutils.c @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" void strpadcpy(char *buf, int buf_size, const char *str, char pad) { diff --git a/device_tree.c b/device_tree.c index a9236133c7..c3e1ba4904 100644 --- a/device_tree.c +++ b/device_tree.c @@ -22,8 +22,8 @@ #include "qemu-common.h" #include "device_tree.h" #include "hw/loader.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include diff --git a/dma-helpers.c b/dma-helpers.c index 4f5fb649e7..e6a6dd82fd 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -9,8 +9,8 @@ #include "dma.h" #include "trace.h" -#include "range.h" -#include "qemu-thread.h" +#include "qemu/range.h" +#include "qemu/thread.h" /* #define DEBUG_IOMMU */ diff --git a/envlist.c b/envlist.c index f2303cdd79..ff99fc44e9 100644 --- a/envlist.c +++ b/envlist.c @@ -4,8 +4,8 @@ #include #include -#include "qemu-queue.h" -#include "envlist.h" +#include "qemu/queue.h" +#include "qemu/envlist.h" struct envlist_entry { const char *ev_var; /* actual env value */ diff --git a/envlist.h b/envlist.h deleted file mode 100644 index b9addcc11f..0000000000 --- a/envlist.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ENVLIST_H -#define ENVLIST_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct envlist envlist_t; - -envlist_t *envlist_create(void); -void envlist_free(envlist_t *); -int envlist_setenv(envlist_t *, const char *); -int envlist_unsetenv(envlist_t *, const char *); -int envlist_parse_set(envlist_t *, const char *); -int envlist_parse_unset(envlist_t *, const char *); -char **envlist_to_environ(const envlist_t *, size_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* ENVLIST_H */ diff --git a/event_notifier-posix.c b/event_notifier-posix.c index f0bd839acd..a53b95688d 100644 --- a/event_notifier-posix.c +++ b/event_notifier-posix.c @@ -11,9 +11,9 @@ */ #include "qemu-common.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_EVENTFD #include diff --git a/event_notifier-win32.c b/event_notifier-win32.c index 4ed21c2a7c..6dbb530cfa 100644 --- a/event_notifier-win32.c +++ b/event_notifier-win32.c @@ -11,8 +11,8 @@ */ #include "qemu-common.h" -#include "event_notifier.h" -#include "main-loop.h" +#include "qemu/event_notifier.h" +#include "qemu/main-loop.h" int event_notifier_init(EventNotifier *e, int active) { diff --git a/event_notifier.h b/event_notifier.h deleted file mode 100644 index 88b57af7ce..0000000000 --- a/event_notifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * event notifier support - * - * Copyright Red Hat, Inc. 2010 - * - * Authors: - * Michael S. Tsirkin - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_EVENT_NOTIFIER_H -#define QEMU_EVENT_NOTIFIER_H - -#include "qemu-common.h" - -#ifdef _WIN32 -#include -#endif - -struct EventNotifier { -#ifdef _WIN32 - HANDLE event; -#else - int rfd; - int wfd; -#endif -}; - -typedef void EventNotifierHandler(EventNotifier *); - -int event_notifier_init(EventNotifier *, int active); -void event_notifier_cleanup(EventNotifier *); -int event_notifier_set(EventNotifier *); -int event_notifier_test_and_clear(EventNotifier *); -int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); - -#ifdef CONFIG_POSIX -void event_notifier_init_fd(EventNotifier *, int fd); -int event_notifier_get_fd(EventNotifier *); -#else -HANDLE event_notifier_get_handle(EventNotifier *); -#endif - -#endif diff --git a/exec.c b/exec.c index 17fc7cf854..917bec0ecd 100644 --- a/exec.c +++ b/exec.c @@ -29,11 +29,11 @@ #include "tcg.h" #include "hw/hw.h" #include "hw/qdev.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "kvm.h" #include "hw/xen.h" -#include "qemu-timer.h" -#include "qemu-config.h" +#include "qemu/timer.h" +#include "qemu/config-file.h" #include "exec/memory.h" #include "dma.h" #include "exec/address-spaces.h" diff --git a/fpu/softfloat.h b/fpu/softfloat.h index d8999b311a..0946f0739d 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -44,7 +44,7 @@ these four paragraphs for those parts of this code that are retained. #include #include "config-host.h" -#include "osdep.h" +#include "qemu/osdep.h" /*---------------------------------------------------------------------------- | Each of the following `typedef's defines the most convenient type that holds diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 300f2758be..4bcf38fe4b 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -13,8 +13,8 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-config.h" -#include "module.h" +#include "qemu/config-file.h" +#include "qemu/module.h" int qemu_fsdev_add(QemuOpts *opts) { diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index e20202a4bf..4cc04d4fde 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -13,10 +13,10 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-queue.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/osdep.h" #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries = QTAILQ_HEAD_INITIALIZER(fsdriver_entries); diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 1af1f545d8..9fa45bf510 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -12,7 +12,7 @@ */ #ifndef QEMU_FSDEV_H #define QEMU_FSDEV_H -#include "qemu-option.h" +#include "qemu/option.h" #include "file-op-9p.h" diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index df2a9392b1..6b9afd32d5 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -21,8 +21,8 @@ #include #endif #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-xattr.h" +#include "qemu/sockets.h" +#include "qemu/xattr.h" #include "virtio-9p-marshal.h" #include "hw/9pfs/virtio-9p-proxy.h" #include "fsdev/virtio-9p-marshal.h" diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c index bf980bfa38..20f308b760 100644 --- a/fsdev/virtio-9p-marshal.c +++ b/fsdev/virtio-9p-marshal.c @@ -22,9 +22,9 @@ #include #include -#include "compiler.h" +#include "qemu/compiler.h" #include "virtio-9p-marshal.h" -#include "bswap.h" +#include "qemu/bswap.h" void v9fs_string_free(V9fsString *str) { diff --git a/gdbstub.c b/gdbstub.c index 9395c829a2..4b178a608f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -38,7 +38,7 @@ #define MAX_PACKET_LENGTH 4096 #include "cpu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "kvm.h" #ifndef TARGET_CPU_MEMORY_RW_DEBUG diff --git a/hmp.c b/hmp.c index a76a8f06ea..3d056b0e38 100644 --- a/hmp.c +++ b/hmp.c @@ -16,10 +16,10 @@ #include "hmp.h" #include "net/net.h" #include "qemu-char.h" -#include "qemu-option.h" -#include "qemu-timer.h" +#include "qemu/option.h" +#include "qemu/timer.h" #include "qmp-commands.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "ui/console.h" diff --git a/host-utils.c b/host-utils.c index dc9612387b..5e3915abba 100644 --- a/host-utils.c +++ b/host-utils.c @@ -25,7 +25,7 @@ #include #include -#include "host-utils.h" +#include "qemu/host-utils.h" //#define DEBUG_MULDIV diff --git a/host-utils.h b/host-utils.h deleted file mode 100644 index a5f8464fb2..0000000000 --- a/host-utils.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Utility compute operations used by translated code. - * - * Copyright (c) 2007 Thiemo Seufer - * Copyright (c) 2007 Jocelyn Mayer - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef HOST_UTILS_H -#define HOST_UTILS_H 1 - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -#if defined(__x86_64__) -#define __HAVE_FAST_MULU64__ -static inline void mulu64(uint64_t *plow, uint64_t *phigh, - uint64_t a, uint64_t b) -{ - __asm__ ("mul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#define __HAVE_FAST_MULS64__ -static inline void muls64(uint64_t *plow, uint64_t *phigh, - int64_t a, int64_t b) -{ - __asm__ ("imul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#else -void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); -void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); -#endif - -/* Binary search for leading zeros. */ - -static inline int clz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clz(val); - else - return 32; -#else - int cnt = 0; - - if (!(val & 0xFFFF0000U)) { - cnt += 16; - val <<= 16; - } - if (!(val & 0xFF000000U)) { - cnt += 8; - val <<= 8; - } - if (!(val & 0xF0000000U)) { - cnt += 4; - val <<= 4; - } - if (!(val & 0xC0000000U)) { - cnt += 2; - val <<= 2; - } - if (!(val & 0x80000000U)) { - cnt++; - val <<= 1; - } - if (!(val & 0x80000000U)) { - cnt++; - } - return cnt; -#endif -} - -static inline int clo32(uint32_t val) -{ - return clz32(~val); -} - -static inline int clz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clzll(val); - else - return 64; -#else - int cnt = 0; - - if (!(val >> 32)) { - cnt += 32; - } else { - val >>= 32; - } - - return cnt + clz32(val); -#endif -} - -static inline int clo64(uint64_t val) -{ - return clz64(~val); -} - -static inline int ctz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctz(val); - else - return 32; -#else - int cnt; - - cnt = 0; - if (!(val & 0x0000FFFFUL)) { - cnt += 16; - val >>= 16; - } - if (!(val & 0x000000FFUL)) { - cnt += 8; - val >>= 8; - } - if (!(val & 0x0000000FUL)) { - cnt += 4; - val >>= 4; - } - if (!(val & 0x00000003UL)) { - cnt += 2; - val >>= 2; - } - if (!(val & 0x00000001UL)) { - cnt++; - val >>= 1; - } - if (!(val & 0x00000001UL)) { - cnt++; - } - - return cnt; -#endif -} - -static inline int cto32(uint32_t val) -{ - return ctz32(~val); -} - -static inline int ctz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctzll(val); - else - return 64; -#else - int cnt; - - cnt = 0; - if (!((uint32_t)val)) { - cnt += 32; - val >>= 32; - } - - return cnt + ctz32(val); -#endif -} - -static inline int cto64(uint64_t val) -{ - return ctz64(~val); -} - -static inline int ctpop8(uint8_t val) -{ - val = (val & 0x55) + ((val >> 1) & 0x55); - val = (val & 0x33) + ((val >> 2) & 0x33); - val = (val & 0x0f) + ((val >> 4) & 0x0f); - - return val; -} - -static inline int ctpop16(uint16_t val) -{ - val = (val & 0x5555) + ((val >> 1) & 0x5555); - val = (val & 0x3333) + ((val >> 2) & 0x3333); - val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); - val = (val & 0x00ff) + ((val >> 8) & 0x00ff); - - return val; -} - -static inline int ctpop32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcount(val); -#else - val = (val & 0x55555555) + ((val >> 1) & 0x55555555); - val = (val & 0x33333333) + ((val >> 2) & 0x33333333); - val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); - val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); - val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); - - return val; -#endif -} - -static inline int ctpop64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcountll(val); -#else - val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); - val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); - val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); - val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); - val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); - val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); - - return val; -#endif -} - -#endif diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index cd137330b9..65ad3298be 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c index 6d6dac7abf..2efebf3571 100644 --- a/hw/9pfs/cofile.c +++ b/hw/9pfs/cofile.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 4b9ba30157..3891050748 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/coxattr.c b/hw/9pfs/coxattr.c index 08365a697e..18ee08df0f 100644 --- a/hw/9pfs/coxattr.c +++ b/hw/9pfs/coxattr.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 958725e5cc..ae6cde8005 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index 8c48a16c10..86d5ed4169 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -15,7 +15,7 @@ #ifndef _QEMU_VIRTIO_9P_COTH_H #define _QEMU_VIRTIO_9P_COTH_H -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p.h" #include diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index b8220abae7..6761bce9dc 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index f96d17a974..e30fdb6730 100644 --- a/hw/9pfs/virtio-9p-handle.c +++ b/hw/9pfs/virtio-9p-handle.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 33a41d2e18..113602144c 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c index c064017b1f..08bb0e8bca 100644 --- a/hw/9pfs/virtio-9p-posix-acl.c +++ b/hw/9pfs/virtio-9p-posix-acl.c @@ -12,7 +12,7 @@ */ #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include "hw/virtio.h" #include "virtio-9p.h" #include "fsdev/file-op-9p.h" diff --git a/hw/9pfs/virtio-9p-xattr.h b/hw/9pfs/virtio-9p-xattr.h index 9437280c99..41cc6cbc7b 100644 --- a/hw/9pfs/virtio-9p-xattr.h +++ b/hw/9pfs/virtio-9p-xattr.h @@ -13,7 +13,7 @@ #ifndef _QEMU_VIRTIO_9P_XATTR_H #define _QEMU_VIRTIO_9P_XATTR_H -#include "qemu-xattr.h" +#include "qemu/xattr.h" typedef struct xattr_operations { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index ede20ce80e..0aaf0d2de0 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 2c0c3baad4..406fe522db 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -9,7 +9,7 @@ #include "hw/virtio.h" #include "fsdev/file-op-9p.h" #include "fsdev/virtio-9p-marshal.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" diff --git a/hw/acpi.h b/hw/acpi.h index afda153d09..c3628d070d 100644 --- a/hw/acpi.h +++ b/hw/acpi.h @@ -127,7 +127,7 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci, MemoryRegion *parent); void acpi_pm_tmr_reset(ACPIREGS *ar); -#include "qemu-timer.h" +#include "qemu/timer.h" static inline int64_t acpi_pm_tmr_get_clock(void) { return muldiv64(qemu_get_clock_ns(vm_clock), PM_TIMER_FREQUENCY, diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 92af3a554c..8d1a689a36 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -26,7 +26,7 @@ #include "hw.h" #include "pc.h" #include "pci/pci.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "acpi.h" #include "kvm.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 4f43f6e070..ebd015dc02 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -25,7 +25,7 @@ #include "pci/pci.h" #include "acpi.h" #include "sysemu.h" -#include "range.h" +#include "qemu/range.h" #include "exec/ioport.h" #include "fw_cfg.h" #include "exec/address-spaces.h" diff --git a/hw/adlib.c b/hw/adlib.c index d39cd97384..07c69fc967 100644 --- a/hw/adlib.c +++ b/hw/adlib.c @@ -32,7 +32,7 @@ #define ADLIB_KILL_TIMERS 1 #ifdef DEBUG -#include "qemu-timer.h" +#include "qemu/timer.h" #endif #define dolog(...) AUD_log ("adlib", __VA_ARGS__) diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c index 7e7b1d27d2..78d93e55ec 100644 --- a/hw/alpha_pci.c +++ b/hw/alpha_pci.c @@ -8,7 +8,7 @@ #include "config.h" #include "alpha_sys.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" diff --git a/hw/apic.c b/hw/apic.c index d66a476aac..81b82f694c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -16,12 +16,12 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ -#include "qemu-thread.h" +#include "qemu/thread.h" #include "apic_internal.h" #include "apic.h" #include "ioapic.h" #include "pci/msi.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "trace.h" #include "pc.h" #include "apic-msidef.h" diff --git a/hw/apic_internal.h b/hw/apic_internal.h index fea95654ca..dcbbfd41cb 100644 --- a/hw/apic_internal.h +++ b/hw/apic_internal.h @@ -22,7 +22,7 @@ #include "exec/memory.h" #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 diff --git a/hw/applesmc.c b/hw/applesmc.c index 91e7cb3d5c..c564b60c0a 100644 --- a/hw/applesmc.c +++ b/hw/applesmc.c @@ -33,7 +33,7 @@ #include "hw.h" #include "isa.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* #define DEBUG_SMC */ diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c index 640ed20a61..093331124a 100644 --- a/hw/arm11mpcore.c +++ b/hw/arm11mpcore.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* MPCore private memory region. */ diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 63ff559cf7..bb9889fbef 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -15,7 +15,7 @@ #include "loader.h" #include "elf.h" #include "device_tree.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 diff --git a/hw/arm_mptimer.c b/hw/arm_mptimer.c index 6790832236..1febaeb7b1 100644 --- a/hw/arm_mptimer.c +++ b/hw/arm_mptimer.c @@ -20,7 +20,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* This device implements the per-cpu private timer and watchdog block * which is used in both the ARM11MPCore and Cortex-A9MP. diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c index 58eb98216d..0884f6275c 100644 --- a/hw/arm_sysctl.c +++ b/hw/arm_sysctl.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "primecell.h" #include "sysemu.h" diff --git a/hw/arm_timer.c b/hw/arm_timer.c index af339d3d19..37e28e993c 100644 --- a/hw/arm_timer.c +++ b/hw/arm_timer.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "qdev.h" #include "ptimer.h" diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 270c307717..0907e42c0c 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -11,7 +11,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "arm-misc.h" #include "exec/address-spaces.h" #include "arm_gic_internal.h" diff --git a/hw/baum.c b/hw/baum.c index 3e94f84e51..97d13ea344 100644 --- a/hw/baum.c +++ b/hw/baum.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "baum.h" #include diff --git a/hw/block-common.c b/hw/block-common.c index f0196d78dc..c24208e560 100644 --- a/hw/block-common.c +++ b/hw/block-common.c @@ -9,7 +9,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" void blkconf_serial(BlockConf *conf, char **serial) { diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c index 0faabbb585..e1dcb6d099 100644 --- a/hw/bt-hci-csr.c +++ b/hw/bt-hci-csr.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "irq.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hci.c b/hw/bt-hci.c index d2ad57faa9..da096d8c37 100644 --- a/hw/bt-hci.c +++ b/hw/bt-hci.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hid.c b/hw/bt-hid.c index 0ec0c013b0..cfa7c145b8 100644 --- a/hw/bt-hid.c +++ b/hw/bt-hid.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "hid.h" #include "bt.h" diff --git a/hw/bt-l2cap.c b/hw/bt-l2cap.c index cb43ee7733..ba061c0da3 100644 --- a/hw/bt-l2cap.c +++ b/hw/bt-l2cap.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "bt.h" #define L2CAP_CID_MAX 0x100 /* Between 0x40 and 0x10000 */ diff --git a/hw/cadence_ttc.c b/hw/cadence_ttc.c index ec78a52180..9e1cb1f152 100644 --- a/hw/cadence_ttc.c +++ b/hw/cadence_ttc.c @@ -17,7 +17,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_TTC_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/cadence_uart.c b/hw/cadence_uart.c index 686e6172d0..f34acc8c46 100644 --- a/hw/cadence_uart.c +++ b/hw/cadence_uart.c @@ -18,7 +18,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_UART_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index 845a764446..e508380482 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -31,7 +31,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "qemu-char.h" #include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index f5b4794e90..48e4228b9d 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -9,7 +9,7 @@ */ #include "qemu-char.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/cs4231a.c b/hw/cs4231a.c index 0257fd8d2a..9d528c43b0 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -26,7 +26,7 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* Missing features: diff --git a/hw/cuda.c b/hw/cuda.c index f1f408b839..cf83956e1a 100644 --- a/hw/cuda.c +++ b/hw/cuda.c @@ -25,7 +25,7 @@ #include "hw.h" #include "ppc_mac.h" #include "adb.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" /* XXX: implement all timer modes */ diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 809a598e3a..34543786e5 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -25,7 +25,7 @@ #include "hw.h" #include "boards.h" #include "blockdev.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "monitor/monitor.h" diff --git a/hw/dma.c b/hw/dma.c index 364f54d2d7..0634baa552 100644 --- a/hw/dma.c +++ b/hw/dma.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "isa.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* #define DEBUG_DMA */ diff --git a/hw/dp8393x.c b/hw/dp8393x.c index d59b6118ad..b5014501df 100644 --- a/hw/dp8393x.c +++ b/hw/dp8393x.c @@ -18,7 +18,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "mips.h" diff --git a/hw/esp-pci.c b/hw/esp-pci.c index d433473d6a..c949e6e0d9 100644 --- a/hw/esp-pci.c +++ b/hw/esp-pci.c @@ -27,7 +27,7 @@ #include "eeprom93xx.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" #define TYPE_AM53C974_DEVICE "am53c974" diff --git a/hw/esp.c b/hw/esp.c index 6d01624a49..0e4e430880 100644 --- a/hw/esp.c +++ b/hw/esp.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" /* * On Sparc32, this is the ESP (NCR53C90) part of chip STP2000 (Master I/O), diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c index ee0d72bf87..59cb7d2172 100644 --- a/hw/etraxfs_ser.c +++ b/hw/etraxfs_ser.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c index f5601dc7a5..cc8b327715 100644 --- a/hw/etraxfs_timer.c +++ b/hw/etraxfs_timer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #define D(x) diff --git a/hw/exynos4210_fimd.c b/hw/exynos4210_fimd.c index cfca72ab67..5c29b5d01d 100644 --- a/hw/exynos4210_fimd.c +++ b/hw/exynos4210_fimd.c @@ -27,7 +27,7 @@ #include "sysbus.h" #include "ui/console.h" #include "ui/pixel_ops.h" -#include "bswap.h" +#include "qemu/bswap.h" /* Debug messages configuration */ #define EXYNOS4210_FIMD_DEBUG 0 diff --git a/hw/exynos4210_i2c.c b/hw/exynos4210_i2c.c index 1e11d9b48c..cefd736092 100644 --- a/hw/exynos4210_i2c.c +++ b/hw/exynos4210_i2c.c @@ -20,7 +20,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "i2c.h" diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c index 37dbda92df..41cd142227 100644 --- a/hw/exynos4210_mct.c +++ b/hw/exynos4210_mct.c @@ -53,7 +53,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_pwm.c b/hw/exynos4210_pwm.c index 5e2872f8f7..3a3eb8c27a 100644 --- a/hw/exynos4210_pwm.c +++ b/hw/exynos4210_pwm.c @@ -21,7 +21,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_rtc.c b/hw/exynos4210_rtc.c index c4fbd49461..6ebc9b1790 100644 --- a/hw/exynos4210_rtc.c +++ b/hw/exynos4210_rtc.c @@ -26,12 +26,12 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "exynos4210.h" diff --git a/hw/fdc.c b/hw/fdc.c index 29b5449ff8..b67d3a574b 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -29,14 +29,14 @@ #include "hw.h" #include "fdc.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "isa.h" #include "sysbus.h" #include "qdev-addr.h" #include "blockdev.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" /********************************************************/ /* debug Floppy devices */ diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 7b0e50f70d..2a00163a04 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -26,8 +26,8 @@ #include "isa.h" #include "fw_cfg.h" #include "sysbus.h" -#include "qemu-error.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" /* debug firmware config */ //#define DEBUG_FW_CFG diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c index 2fdccfba06..252ba893e3 100644 --- a/hw/grlib_gptimer.c +++ b/hw/grlib_gptimer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "trace.h" diff --git a/hw/hid.c b/hw/hid.c index 7935998e83..0fee3b6ddd 100644 --- a/hw/hid.c +++ b/hw/hid.c @@ -24,7 +24,7 @@ */ #include "hw.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hid.h" #define HID_USAGE_ERROR_ROLLOVER 0x01 diff --git a/hw/hpet.c b/hw/hpet.c index 49e1b631b5..78c0662dfc 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pc.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hpet_emul.h" #include "sysbus.h" #include "mc146818rtc.h" diff --git a/hw/hw.h b/hw/hw.h index 883ddb60f9..dfced97bbc 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -13,7 +13,7 @@ #include "block/aio.h" #include "migration/qemu-file.h" #include "migration/vmstate.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 diff --git a/hw/i8254.c b/hw/i8254.c index bea5f92fd2..7c2aa6238d 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8254_common.c b/hw/i8254_common.c index a03d7cd458..08ab8d14bd 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -25,7 +25,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8259.c b/hw/i8259.c index 5e935e7f99..8fc6339250 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -25,7 +25,7 @@ #include "pc.h" #include "isa.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8259_internal.h" /* debug PIC */ diff --git a/hw/ich9.h b/hw/ich9.h index 5c73f94caf..b8d8e6d3df 100644 --- a/hw/ich9.h +++ b/hw/ich9.h @@ -2,7 +2,7 @@ #define HW_ICH9_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index 0e5bc7fe3b..bf65cb407e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -26,8 +26,8 @@ #include #include #include -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "sysemu.h" #include "dma.h" #include "hw/block-common.h" diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index f2e4ea4207..c85e1ac018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -18,7 +18,7 @@ */ #include #include "dma.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include "blockdev.h" #include "hw/block-common.h" diff --git a/hw/imx_avic.c b/hw/imx_avic.c index 810979366d..f1f066cf9c 100644 --- a/hw/imx_avic.c +++ b/hw/imx_avic.c @@ -16,7 +16,7 @@ #include "hw.h" #include "sysbus.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define DEBUG_INT 1 #undef DEBUG_INT /* comment out for debugging */ diff --git a/hw/imx_timer.c b/hw/imx_timer.c index 33f33fb41e..e924c747c5 100644 --- a/hw/imx_timer.c +++ b/hw/imx_timer.c @@ -12,7 +12,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "imx.h" diff --git a/hw/intel-hda.c b/hw/intel-hda.c index c21bf7204a..7ef3a15e08 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -20,7 +20,7 @@ #include "hw.h" #include "pci/pci.h" #include "pci/msi.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audiodev.h" #include "intel-hda.h" #include "intel-hda-defs.h" diff --git a/hw/ivshmem.c b/hw/ivshmem.c index d5b91dd24e..af34f3b582 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -23,7 +23,7 @@ #include "kvm.h" #include "migration/migration.h" #include "qapi/qmp/qerror.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" #include diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index 53d13e3123..8ee1c352cf 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "hw/i8254.h" #include "hw/i8254_internal.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index ff0dc0dfd4..2f06c27e83 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -28,11 +28,11 @@ #include #include "hw/hw.h" #include "hw/pc.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "ui/console.h" #include "hw/loader.h" #include "monitor/monitor.h" -#include "range.h" +#include "qemu/range.h" #include "sysemu.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/lance.c b/hw/lance.c index a384676158..b7265c0fed 100644 --- a/hw/lance.c +++ b/hw/lance.c @@ -37,8 +37,8 @@ #include "sysbus.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sun4m.h" #include "pcnet.h" #include "trace.h" diff --git a/hw/leon3.c b/hw/leon3.c index e8d54e5d06..776ab97a78 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c index a7887d14f6..b3350890cb 100644 --- a/hw/lm32_sys.c +++ b/hw/lm32_sys.c @@ -31,10 +31,10 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { R_CTRL = 0, diff --git a/hw/lm32_timer.c b/hw/lm32_timer.c index a8be9cc168..bd4c346386 100644 --- a/hw/lm32_timer.c +++ b/hw/lm32_timer.c @@ -24,9 +24,9 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define DEFAULT_FREQUENCY (50*1000000) diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c index adb9287568..bf2f507523 100644 --- a/hw/lm32_uart.c +++ b/hw/lm32_uart.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/lm832x.c b/hw/lm832x.c index b14a089b32..3649e3d249 100644 --- a/hw/lm832x.c +++ b/hw/lm832x.c @@ -20,7 +20,7 @@ #include "hw.h" #include "i2c.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" typedef struct { diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index e225693721..76217a74fc 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -29,7 +29,7 @@ */ #include "qemu-common.h" #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/m48t59.c b/hw/m48t59.c index 491d433ae7..301b10ce79 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "nvram.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "sysbus.h" #include "isa.h" diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index 41eee50a35..b894ab21aa 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -39,7 +39,7 @@ #include "hw.h" #include "isa.h" #include "mac_dbdma.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* debug DBDMA */ //#define DEBUG_DBDMA diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 2a1278f393..fba75029df 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "mc146818rtc.h" #include "qapi/visitor.h" diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 5edc931abd..fbc806ac18 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "exec/address-spaces.h" diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 997b34847c..fea8a69262 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "net/net.h" diff --git a/hw/megasas.c b/hw/megasas.c index f4fbe9790a..e80c0d1c25 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -22,7 +22,7 @@ #include "pci/pci.h" #include "dma.h" #include "pci/msix.h" -#include "iov.h" +#include "qemu/iov.h" #include "scsi.h" #include "scsi-defs.h" #include "trace.h" diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c index 02c349c189..76d33021c0 100644 --- a/hw/microblaze_boot.c +++ b/hw/microblaze_boot.c @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-common.h" #include "device_tree.h" #include "loader.h" diff --git a/hw/milkymist-ac97.c b/hw/milkymist-ac97.c index d87656c9ac..f46af1c509 100644 --- a/hw/milkymist-ac97.c +++ b/hw/milkymist-ac97.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "audio/audio.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_AC97_CTRL = 0, diff --git a/hw/milkymist-hpdmc.c b/hw/milkymist-hpdmc.c index 5d120a497f..fd54d3129a 100644 --- a/hw/milkymist-hpdmc.c +++ b/hw/milkymist-hpdmc.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_SYSTEM = 0, diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c index ca5df56290..5dc30ace60 100644 --- a/hw/milkymist-memcard.c +++ b/hw/milkymist-memcard.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "blockdev.h" #include "sd.h" diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c index 926f7f9a8b..4e92ac3dcb 100644 --- a/hw/milkymist-minimac2.c +++ b/hw/milkymist-minimac2.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "net/net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qdev-addr.h" #include diff --git a/hw/milkymist-pfpu.c b/hw/milkymist-pfpu.c index 450bab921f..0521829202 100644 --- a/hw/milkymist-pfpu.c +++ b/hw/milkymist-pfpu.c @@ -25,8 +25,8 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include /* #define TRACE_EXEC */ diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c index 0743668d18..b7beb4bedb 100644 --- a/hw/milkymist-softusb.c +++ b/hw/milkymist-softusb.c @@ -26,7 +26,7 @@ #include "trace.h" #include "ui/console.h" #include "hid.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_CTRL = 0, diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index f951ef9ca8..519462afcc 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -25,9 +25,9 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { CTRL_ENABLE = (1<<0), diff --git a/hw/milkymist-tmu2.c b/hw/milkymist-tmu2.c index 3f9a684eda..a11772aebe 100644 --- a/hw/milkymist-tmu2.c +++ b/hw/milkymist-tmu2.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c index aefa8c7f1c..ef5518e5c2 100644 --- a/hw/milkymist-uart.c +++ b/hw/milkymist-uart.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/milkymist-vgafb.c b/hw/milkymist-vgafb.c index c3471315d3..561285154f 100644 --- a/hw/milkymist-vgafb.c +++ b/hw/milkymist-vgafb.c @@ -28,7 +28,7 @@ #include "ui/console.h" #include "framebuffer.h" #include "ui/pixel_ops.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define BITS 8 #include "milkymist-vgafb_template.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 34619b7e3e..60dd8c69bb 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -33,7 +33,7 @@ #include "qemu-char.h" #include "sysemu.h" #include "audio/audio.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "mips-bios.h" #include "ide.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index d65d1256fd..04c7a2612c 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -38,7 +38,7 @@ #include "sysemu.h" #include "arch_init.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 05494b9b40..511e1e41c0 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -17,7 +17,7 @@ #include "sysemu.h" #include "boards.h" #include "flash.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_timer.c b/hw/mips_timer.c index 7aa9004a0e..83c400c158 100644 --- a/hw/mips_timer.c +++ b/hw/mips_timer.c @@ -22,7 +22,7 @@ #include "hw.h" #include "mips_cpudevs.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ 100 * 1000 * 1000 diff --git a/hw/musicpal.c b/hw/musicpal.c index 436b3f7c37..5a7bf8bee1 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -16,7 +16,7 @@ #include "sysemu.h" #include "boards.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "block/block.h" #include "flash.h" diff --git a/hw/nand.c b/hw/nand.c index 01f3adaee1..a73205d866 100644 --- a/hw/nand.c +++ b/hw/nand.c @@ -22,7 +22,7 @@ # include "flash.h" # include "blockdev.h" # include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" # define NAND_CMD_READ0 0x00 # define NAND_CMD_READ1 0x01 diff --git a/hw/omap1.c b/hw/omap1.c index 4d5815eb08..50c4570f31 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -22,7 +22,7 @@ #include "sysemu.h" #include "soc_dma.h" #include "blockdev.h" -#include "range.h" +#include "qemu/range.h" #include "sysbus.h" /* Should signal the TCMI/GPMC */ diff --git a/hw/omap2.c b/hw/omap2.c index 96aba71052..7ccee69661 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -23,7 +23,7 @@ #include "arm-misc.h" #include "omap.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "flash.h" #include "soc_dma.h" diff --git a/hw/omap_dma.c b/hw/omap_dma.c index e619c7b7de..aec5874311 100644 --- a/hw/omap_dma.c +++ b/hw/omap_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" #include "irq.h" #include "soc_dma.h" diff --git a/hw/omap_gptimer.c b/hw/omap_gptimer.c index e39da74067..a5db710dcb 100644 --- a/hw/omap_gptimer.c +++ b/hw/omap_gptimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" /* GP timers */ diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c index 7031a88531..945711eff5 100644 --- a/hw/omap_synctimer.c +++ b/hw/omap_synctimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" struct omap_synctimer_s { MemoryRegion iomem; diff --git a/hw/onenand.c b/hw/onenand.c index 7d255c563f..2e26e3a05d 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -26,7 +26,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 diff --git a/hw/openrisc_timer.c b/hw/openrisc_timer.c index 7916e61d24..d965be77de 100644 --- a/hw/openrisc_timer.c +++ b/hw/openrisc_timer.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ (20 * 1000 * 1000) /* 20MHz */ diff --git a/hw/pc.c b/hw/pc.c index 7aaff0f2fd..0a92ea6bed 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -50,7 +50,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "arch_init.h" -#include "bitmap.h" +#include "qemu/bitmap.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ diff --git a/hw/pci/msi.c b/hw/pci/msi.c index 680e4637d7..2a04d18884 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -19,7 +19,7 @@ */ #include "hw/pci/msi.h" -#include "range.h" +#include "qemu/range.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10 diff --git a/hw/pci/msix.c b/hw/pci/msix.c index a6a401e286..073e22c315 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -18,7 +18,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" #define MSIX_CAP_LENGTH 12 diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index e5e8a7ab58..2bc02e344f 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -30,7 +30,7 @@ #include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "blockdev.h" #include "qapi/error.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e062f66088..c9ed95be89 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -29,7 +29,7 @@ #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" -#include "range.h" +#include "qemu/range.h" #include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 131091408d..995842a72d 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -31,7 +31,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "range.h" +#include "qemu/range.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b60a6faaf3..6c916d15ec 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -25,7 +25,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pcie_regs.h" -#include "range.h" +#include "qemu/range.h" //#define DEBUG_PCIE #ifdef DEBUG_PCIE diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 18b1512b43..f07266da66 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -1,7 +1,7 @@ #include #include -#include "range.h" -#include "range.h" +#include "qemu/range.h" +#include "qemu/range.h" #include "hw/pci/shpc.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index c6768bcbdc..5e8eed3af8 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -30,7 +30,7 @@ #include "pci/pci.h" #include "net/net.h" #include "loader.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "dma.h" #include "pcnet.h" diff --git a/hw/pcnet.c b/hw/pcnet.c index 5b03edecdd..87736542e4 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -37,8 +37,8 @@ #include "qdev.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sysemu.h" #include "pcnet.h" diff --git a/hw/pcspk.c b/hw/pcspk.c index ad6491b0f4..6d55ebe82f 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -26,7 +26,7 @@ #include "pc.h" #include "isa.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "pcspk.h" diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 36af4647df..59982dcd6f 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -39,9 +39,9 @@ #include "hw.h" #include "flash.h" #include "block/block.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" #define PFLASH_BUG(fmt, ...) \ diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index c689cc9f42..6924f064c2 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -37,10 +37,10 @@ #include "hw.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" //#define PFLASH_DEBUG diff --git a/hw/piix_pci.c b/hw/piix_pci.c index b5ea68bc61..3d79c73fda 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -28,7 +28,7 @@ #include "pci/pci_host.h" #include "isa.h" #include "sysbus.h" -#include "range.h" +#include "qemu/range.h" #include "xen.h" #include "pam.h" diff --git a/hw/pl031.c b/hw/pl031.c index 8bf0183289..834a20c917 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -12,7 +12,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" //#define DEBUG_PL031 diff --git a/hw/ppc.c b/hw/ppc.c index 11fd199eaa..f066367609 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 798e67cedf..3593f7c0e2 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -19,7 +19,7 @@ #include "e500.h" #include "e500-ccsr.h" #include "net/net.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "hw/hw.h" #include "hw/serial.h" #include "hw/pci/pci.h" @@ -34,7 +34,7 @@ #include "elf.h" #include "hw/sysbus.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/ppce500_pci.h" #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index 5a0e0260e6..31bcc4bb95 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -29,7 +29,7 @@ #include "sysemu.h" #include "block/block.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "blockdev.h" #include "exec/address-spaces.h" diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index aabb2efb48..b1ed8837d6 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -25,9 +25,9 @@ #include "ppc.h" #include "ppc405.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #define DEBUG_OPBA diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c index 3b9dc06716..d1fb1576b0 100644 --- a/hw/ppc4xx_devs.c +++ b/hw/ppc4xx_devs.c @@ -24,7 +24,7 @@ #include "hw.h" #include "ppc.h" #include "ppc4xx.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" //#define DEBUG_MMIO diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index d51e7fad67..a7182be0d3 100644 --- a/hw/ppc_booke.c +++ b/hw/ppc_booke.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index aa46cc6f55..072535294e 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -33,7 +33,7 @@ #include "pci/pci_host.h" #include "ppc.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "ide.h" #include "loader.h" #include "mc146818rtc.h" diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index feefc6596b..1e1ade3d2e 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -18,7 +18,7 @@ #include "hw/ppc/e500-ccsr.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "ppce500_pci.h" #ifdef DEBUG_PCI diff --git a/hw/ptimer.c b/hw/ptimer.c index bc0b3f802f..24af6a2afe 100644 --- a/hw/ptimer.c +++ b/hw/ptimer.c @@ -6,9 +6,9 @@ * This code is licensed under the GNU LGPL. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "host-utils.h" +#include "qemu/host-utils.h" struct ptimer_state { diff --git a/hw/ptimer.h b/hw/ptimer.h index 9d172f7764..28fcaf17f8 100644 --- a/hw/ptimer.h +++ b/hw/ptimer.h @@ -9,7 +9,7 @@ #define PTIMER_H #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/vmstate.h" /* ptimer.c */ diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c index 8242d26c37..1481c6d3e1 100644 --- a/hw/pxa2xx_timer.c +++ b/hw/pxa2xx_timer.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "pxa.h" #include "sysbus.h" diff --git a/hw/q35.h b/hw/q35.h index 2f951c8a94..246c12cb04 100644 --- a/hw/q35.h +++ b/hw/q35.h @@ -23,7 +23,7 @@ #define HW_Q35_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/qdev-core.h b/hw/qdev-core.h index 93a3a2a7bc..fdf14ec4a6 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -1,9 +1,9 @@ #ifndef QDEV_CORE_H #define QDEV_CORE_H -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-types.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/typedefs.h" #include "qom/object.h" #include "hw/irq.h" #include "qapi/error.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 207282c4a4..1c6712e6de 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -21,7 +21,7 @@ #include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" -#include "qemu-config.h" +#include "qemu/config-file.h" /* * Aliases were a bad idea from the start. Let's keep them diff --git a/hw/qxl-logger.c b/hw/qxl-logger.c index fe2878c836..3cd85d9b97 100644 --- a/hw/qxl-logger.c +++ b/hw/qxl-logger.c @@ -19,7 +19,7 @@ * along with this program; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qxl.h" static const char *qxl_type[] = { diff --git a/hw/qxl.c b/hw/qxl.c index ad0214827e..b88a39cc93 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -21,8 +21,8 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/qxl.h b/hw/qxl.h index 9130261524..f867a1d0ac 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -7,7 +7,7 @@ #include "hw.h" #include "pci/pci.h" #include "vga_int.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-spice.h" #include "ui/spice-display.h" diff --git a/hw/rc4030.c b/hw/rc4030.c index e0024c87e8..a0358a319c 100644 --- a/hw/rc4030.c +++ b/hw/rc4030.c @@ -24,7 +24,7 @@ #include "hw.h" #include "mips.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /********************************************************/ /* debug rc4030 */ diff --git a/hw/rtl8139.c b/hw/rtl8139.c index e024520b8b..19c31a02c6 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -54,11 +54,11 @@ #include "hw.h" #include "pci/pci.h" #include "dma.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "loader.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /* debug RTL8139 card */ //#define DEBUG_RTL8139 1 diff --git a/hw/s390x/event-facility.h b/hw/s390x/event-facility.h index 30af0a76a7..791ab2a6de 100644 --- a/hw/s390x/event-facility.h +++ b/hw/s390x/event-facility.h @@ -16,7 +16,7 @@ #define HW_S390_SCLP_EVENT_FACILITY_H #include -#include "qemu-thread.h" +#include "qemu/thread.h" /* SCLP event types */ #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c index 9ad297c999..ca78d6796a 100644 --- a/hw/s390x/sclpconsole.c +++ b/hw/s390x/sclpconsole.c @@ -13,7 +13,7 @@ */ #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "sclp.h" #include "event-facility.h" diff --git a/hw/sb16.c b/hw/sb16.c index 523ab0d5fd..bb460ccb60 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -26,8 +26,8 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" -#include "host-utils.h" +#include "qemu/timer.h" +#include "qemu/host-utils.h" #define dolog(...) AUD_log ("sb16", __VA_ARGS__) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index dfb2631210..5dc9f512b5 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1,5 +1,5 @@ #include "hw.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "qdev.h" diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 49b5686a92..c65da4a9c9 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -29,7 +29,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0) #endif #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "sysemu.h" diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index d9045341ba..faeb61ee2c 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "blockdev.h" diff --git a/hw/sd.c b/hw/sd.c index 2e54eea981..428bd78e32 100644 --- a/hw/sd.c +++ b/hw/sd.c @@ -32,7 +32,7 @@ #include "hw.h" #include "block/block.h" #include "sd.h" -#include "bitmap.h" +#include "qemu/bitmap.h" //#define DEBUG_SD 1 diff --git a/hw/serial.c b/hw/serial.c index 3968c4fc46..2cbb5447a7 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -25,7 +25,7 @@ #include "serial.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/sh_pci.c b/hw/sh_pci.c index d5218420a3..018b1c198b 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -25,7 +25,7 @@ #include "sh.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/address-spaces.h" typedef struct SHPCIState { diff --git a/hw/sh_timer.c b/hw/sh_timer.c index da6689f369..64ea23fce6 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -10,7 +10,7 @@ #include "hw.h" #include "sh.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" #include "ptimer.h" diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index c07ceb1de0..584629f1a5 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/sm501.c b/hw/sm501.c index 714aca0492..dd186aa7f2 100644 --- a/hw/sm501.c +++ b/hw/sm501.c @@ -29,7 +29,7 @@ #include "devices.h" #include "sysbus.h" #include "qdev-addr.h" -#include "range.h" +#include "qemu/range.h" #include "ui/pixel_ops.h" /* diff --git a/hw/soc_dma.c b/hw/soc_dma.c index 50d5f84b4e..64e8ee1d13 100644 --- a/hw/soc_dma.c +++ b/hw/soc_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "soc_dma.h" static void transfer_mem2mem(struct soc_dma_ch_s *ch) diff --git a/hw/spapr.c b/hw/spapr.c index d1252fc68c..1abfde2a05 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -49,7 +49,7 @@ #include "exec/address-spaces.h" #include "hw/usb.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include diff --git a/hw/spitz.c b/hw/spitz.c index 48668a0f10..1259e32974 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -18,7 +18,7 @@ #include "i2c.h" #include "ssi.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "devices.h" #include "sharpsl.h" #include "ui/console.h" diff --git a/hw/stellaris.c b/hw/stellaris.c index 368f8a5e73..26da3c7f60 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -11,7 +11,7 @@ #include "ssi.h" #include "arm-misc.h" #include "devices.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "net/net.h" #include "boards.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index 44bec34e07..f776fee3bc 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -28,7 +28,7 @@ */ #include "sysbus.h" #include "strongarm.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "arm-misc.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/sun4m.c b/hw/sun4m.c index 9a784dfd04..4245854949 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sun4m.h" #include "nvram.h" #include "sparc32_dma.h" diff --git a/hw/sun4u.c b/hw/sun4u.c index 000f6118e1..8bca4fdff9 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -29,7 +29,7 @@ #include "nvram.h" #include "fdc.h" #include "net/net.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "boards.h" #include "firmware_abi.h" diff --git a/hw/tsc2005.c b/hw/tsc2005.c index e2326283c0..740ff86aa8 100644 --- a/hw/tsc2005.c +++ b/hw/tsc2005.c @@ -19,7 +19,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "devices.h" diff --git a/hw/tsc210x.c b/hw/tsc210x.c index 2b3535d4fc..2076c355d2 100644 --- a/hw/tsc210x.c +++ b/hw/tsc210x.c @@ -21,7 +21,7 @@ #include "hw.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "omap.h" /* For I2SCodec and uWireSlave */ #include "devices.h" diff --git a/hw/tusb6010.c b/hw/tusb6010.c index 325200bd34..990d50619d 100644 --- a/hw/tusb6010.c +++ b/hw/tusb6010.c @@ -19,7 +19,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "omap.h" #include "irq.h" diff --git a/hw/twl92230.c b/hw/twl92230.c index ce699bdbdd..3210b9ef4e 100644 --- a/hw/twl92230.c +++ b/hw/twl92230.c @@ -20,7 +20,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "sysemu.h" #include "ui/console.h" diff --git a/hw/usb.h b/hw/usb.h index efae65dcad..81e265c4fd 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -26,7 +26,7 @@ */ #include "qdev.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* Constants related to the USB / PCI interaction */ #define USB_SBRN 0x60 /* Serial Bus Release Number Register */ diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c index 4a0c299457..13f6602ad2 100644 --- a/hw/usb/combined-packet.c +++ b/hw/usb/combined-packet.c @@ -21,7 +21,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" static void usb_combined_packet_add(USBCombinedPacket *combined, USBPacket *p) diff --git a/hw/usb/core.c b/hw/usb/core.c index 8e360d3ec0..e315fc1021 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" void usb_attach(USBPort *port) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 6953f2e710..ce38fef9f6 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -26,7 +26,7 @@ #include "ui/console.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/hid.h" /* HID interface requests */ diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index bf289ff5a6..e8ada9f02c 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -27,10 +27,10 @@ #include "hw/usb.h" #include "hw/usb/desc.h" #include "net/net.h" -#include "qemu-queue.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/config-file.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /*#define TRAFFIC_DEBUG*/ /* Thanks to NetChip Technologies for donating this product ID. diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 99b19df1d1..2ff4fe247a 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -9,7 +9,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "qemu-char.h" diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 3862c9b6c9..f26bb341f7 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -35,7 +35,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "monitor/monitor.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 0d7597b4d1..6d27bac94f 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -8,8 +8,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "hw/scsi.h" diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index a21b2ba627..9a0088928f 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -10,8 +10,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "trace.h" #include "hw/usb.h" diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 8b043966f6..ee77d41db5 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -17,7 +17,7 @@ #include "hw/usb/hcd-ehci.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" typedef struct EHCIPCIState { PCIDevice pcidev; diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 740f7309fb..5bc80031bf 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -18,7 +18,7 @@ #define HW_USB_EHCI_H 1 #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "monitor/monitor.h" #include "trace.h" diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index c707f7a2bb..64e9e834bf 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -21,7 +21,7 @@ * Only host-mode and non-DMA accesses are currently supported. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/irq.h" #include "hw/hw.h" diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 4faf8e1aed..052c4a3037 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -27,7 +27,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/sysbus.h" diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 04c944613c..c9b8a31465 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -28,8 +28,8 @@ #include "hw/hw.h" #include "hw/usb.h" #include "hw/pci/pci.h" -#include "qemu-timer.h" -#include "iov.h" +#include "qemu/timer.h" +#include "qemu/iov.h" #include "dma.h" #include "trace.h" diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 220c3b536a..e2de71ef1a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -19,7 +19,7 @@ * License along with this library; if not, see . */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 5a56e99891..9a8c26ceaf 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -31,7 +31,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 3621076020..31e5f27595 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -26,10 +26,10 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 096621cdbd..9f204bc113 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -27,7 +27,7 @@ #include #include "config.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "exec/address-spaces.h" #include "kvm.h" #include "exec/memory.h" @@ -35,9 +35,9 @@ #include "pci/msix.h" #include "pci/pci.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-queue.h" -#include "range.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qemu/range.h" /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c index 008703ff57..311c966f77 100644 --- a/hw/vga-isa-mm.c +++ b/hw/vga-isa-mm.c @@ -26,7 +26,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define VGA_RAM_SIZE (8192 * 1024) diff --git a/hw/vga-isa.c b/hw/vga-isa.c index d1d5b11828..cbe7b05a7e 100644 --- a/hw/vga-isa.c +++ b/hw/vga-isa.c @@ -28,7 +28,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" typedef struct ISAVGAState { diff --git a/hw/vga-pci.c b/hw/vga-pci.c index fe3a3d4899..87c7c0648d 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" #define PCI_VGA_IOPORT_OFFSET 0x400 diff --git a/hw/vga.c b/hw/vga.c index 4007116859..e2ba7f208c 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen.h" #include "trace.h" diff --git a/hw/vhost.c b/hw/vhost.c index feaff64c15..4e1cb47418 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -16,7 +16,7 @@ #include #include "vhost.h" #include "hw/hw.h" -#include "range.h" +#include "qemu/range.h" #include #include "exec/address-spaces.h" diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 93ad89a11c..ae2785d83f 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -18,7 +18,7 @@ #include "virtio-net.h" #include "vhost_net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "config.h" diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 0f27c2b414..5134e2f477 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -32,7 +32,7 @@ #include "device_tree.h" #include "loader.h" #include "elf.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #include "ppc.h" diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 97d3a932d9..2eb709b422 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -13,7 +13,7 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "qemu-common.h" #include "virtio.h" #include "pc.h" diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index e25cc96477..208caa2642 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "hw/block-common.h" #include "blockdev.h" diff --git a/hw/virtio-console.c b/hw/virtio-console.c index cffee3d470..df0951e973 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -11,7 +11,7 @@ */ #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio-net.c b/hw/virtio-net.c index dc7c6d6b56..5d03b31c1b 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -11,13 +11,13 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "virtio.h" #include "net/net.h" #include "net/checksum.h" #include "net/tap.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "virtio-net.h" #include "vhost_net.h" diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a2355dc867..f58917f75f 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -23,14 +23,14 @@ #include "virtio-serial.h" #include "virtio-scsi.h" #include "pci/pci.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "pci/msi.h" #include "pci/msix.h" #include "loader.h" #include "kvm.h" #include "blockdev.h" #include "virtio-pci.h" -#include "range.h" +#include "qemu/range.h" /* from Linux's linux/virtio_pci.h */ diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c index a73ef8e334..e063127df6 100644 --- a/hw/virtio-rng.c +++ b/hw/virtio-rng.c @@ -9,7 +9,7 @@ * top-level directory. */ -#include "iov.h" +#include "qemu/iov.h" #include "qdev.h" #include "virtio.h" #include "virtio-rng.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 5559518a93..fc5cb32277 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -18,9 +18,9 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #include "monitor/monitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "sysbus.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio.c b/hw/virtio.c index f40a8c5571..0455a9e8f3 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -14,9 +14,9 @@ #include #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "virtio.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" /* The alignment to use between consumer and producer parts of vring. * x86 pagesize again. */ diff --git a/hw/virtio.h b/hw/virtio.h index cdcb490733..511a16992e 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -18,7 +18,7 @@ #include "net/net.h" #include "qdev.h" #include "sysemu.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #ifdef CONFIG_LINUX #include "9p.h" #endif diff --git a/hw/vt82c686.c b/hw/vt82c686.c index edceb5a01d..a18aaed217 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -23,7 +23,7 @@ #include "acpi.h" #include "pm_smbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" typedef uint32_t pci_addr_t; diff --git a/hw/watchdog.c b/hw/watchdog.c index 623b299f71..5b04215374 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -20,9 +20,9 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qemu/queue.h" #include "qapi/qmp/types.h" #include "monitor/monitor.h" #include "sysemu.h" diff --git a/hw/watchdog.h b/hw/watchdog.h index c12a29311a..3e9a970686 100644 --- a/hw/watchdog.h +++ b/hw/watchdog.h @@ -22,7 +22,7 @@ #ifndef QEMU_WATCHDOG_H #define QEMU_WATCHDOG_H -#include "qemu-queue.h" +#include "qemu/queue.h" struct WatchdogTimerModel { QLIST_ENTRY(WatchdogTimerModel) entry; diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index 181774220d..54f0665135 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -22,7 +22,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "pci/pci.h" diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c index 7f6c21d809..4475f7b862 100644 --- a/hw/wdt_ib700.c +++ b/hw/wdt_ib700.c @@ -20,7 +20,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "isa.h" diff --git a/hw/xen_backend.c b/hw/xen_backend.c index f83a1e1d09..270584fc10 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -36,7 +36,7 @@ #include "hw.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "xen_backend.h" #include diff --git a/hw/xen_common.h b/hw/xen_common.h index 727757afb4..95bc9a7825 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -16,7 +16,7 @@ #include "hw.h" #include "xen.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* * We don't support Xen prior to 3.3.0. diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index db1497469a..a4272f0680 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -1,8 +1,8 @@ #include #include "xen_backend.h" #include "xen_domainbuild.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include diff --git a/hw/xen_pt.c b/hw/xen_pt.c index 5c50d562d9..9ebd028f2e 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -58,7 +58,7 @@ #include "xen.h" #include "xen_backend.h" #include "xen_pt.h" -#include "range.h" +#include "qemu/range.h" #include "exec/address-spaces.h" #define XEN_PT_NR_IRQS (256) diff --git a/hw/xen_pt_config_init.c b/hw/xen_pt_config_init.c index 0a5f82cb80..54a179af90 100644 --- a/hw/xen_pt_config_init.c +++ b/hw/xen_pt_config_init.c @@ -12,7 +12,7 @@ * This file implements direct PCI assignment to a HVM guest */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen_backend.h" #include "xen_pt.h" diff --git a/hw/xgmac.c b/hw/xgmac.c index d0d510ed6a..acc3d37648 100644 --- a/hw/xgmac.c +++ b/hw/xgmac.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c index 2fd6068428..ce02764b3f 100644 --- a/hw/xilinx_axidma.c +++ b/hw/xilinx_axidma.c @@ -23,9 +23,9 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "qdev-addr.h" #include "stream.h" diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c index 35979e65c9..09e49b0aee 100644 --- a/hw/xilinx_axienet.c +++ b/hw/xilinx_axienet.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c index 039027442c..4eed1828e3 100644 --- a/hw/xilinx_spi.c +++ b/hw/xilinx_spi.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" diff --git a/hw/xilinx_spips.c b/hw/xilinx_spips.c index ee7656d7d8..ebe375e56f 100644 --- a/hw/xilinx_spips.c +++ b/hw/xilinx_spips.c @@ -25,10 +25,10 @@ #include "sysbus.h" #include "sysemu.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifdef XILINX_SPIPS_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c index 2b01dc2869..69294bb83c 100644 --- a/hw/xilinx_timer.c +++ b/hw/xilinx_timer.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/xtensa_pic.c b/hw/xtensa_pic.c index 1ec70cd969..97d36be272 100644 --- a/hw/xtensa_pic.c +++ b/hw/xtensa_pic.c @@ -26,8 +26,8 @@ */ #include "hw.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/log.h" +#include "qemu/timer.h" void xtensa_advance_ccount(CPUXtensaState *env, uint32_t d) { diff --git a/hw/zynq_slcr.c b/hw/zynq_slcr.c index dde4306195..c7ce51f4a6 100644 --- a/hw/zynq_slcr.c +++ b/hw/zynq_slcr.c @@ -15,7 +15,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "sysemu.h" diff --git a/include/block/aio.h b/include/block/aio.h index 31884a8f16..0933f05878 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -15,8 +15,8 @@ #define QEMU_AIO_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "event_notifier.h" +#include "qemu/queue.h" +#include "qemu/event_notifier.h" typedef struct BlockDriverAIOCB BlockDriverAIOCB; typedef void BlockDriverCompletionFunc(void *opaque, int ret); diff --git a/include/block/block.h b/include/block/block.h index d49ce4dbc5..b81d200b03 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -3,7 +3,7 @@ #include "block/aio.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "block/coroutine.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index 14c57afd54..f83ffb8a08 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -25,10 +25,10 @@ #define BLOCK_INT_H #include "block/block.h" -#include "qemu-option.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/queue.h" #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" #include "monitor/monitor.h" diff --git a/include/block/coroutine.h b/include/block/coroutine.h index 34c15d4116..c31fae3f3c 100644 --- a/include/block/coroutine.h +++ b/include/block/coroutine.h @@ -16,8 +16,8 @@ #define QEMU_COROUTINE_H #include -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" /** * Coroutines are a mechanism for stack switching and can be used for diff --git a/include/block/coroutine_int.h b/include/block/coroutine_int.h index 282a3ceda6..17eb71e723 100644 --- a/include/block/coroutine_int.h +++ b/include/block/coroutine_int.h @@ -25,7 +25,7 @@ #ifndef QEMU_COROUTINE_INT_H #define QEMU_COROUTINE_INT_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/coroutine.h" typedef enum { diff --git a/include/block/thread-pool.h b/include/block/thread-pool.h index a87b287081..200703e35f 100644 --- a/include/block/thread-pool.h +++ b/include/block/thread-pool.h @@ -19,8 +19,8 @@ #define QEMU_THREAD_POOL_H 1 #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "block/block_int.h" diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index bec04e2008..c12e35f54d 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -20,7 +20,7 @@ #define CPU_ALL_H #include "qemu-common.h" -#include "qemu-tls.h" +#include "qemu/tls.h" #include "exec/cpu-common.h" /* some important defines: diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f83d6180f3..4d4f8d4e98 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -9,8 +9,8 @@ #include "exec/poison.h" #endif -#include "bswap.h" -#include "qemu-queue.h" +#include "qemu/bswap.h" +#include "qemu/queue.h" #if !defined(CONFIG_USER_ONLY) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 8d2230e50e..aea0ece051 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -27,8 +27,8 @@ #include #include #include -#include "osdep.h" -#include "qemu-queue.h" +#include "qemu/osdep.h" +#include "qemu/queue.h" #include "exec/hwaddr.h" #ifndef TARGET_LONG_BITS diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 2ae8aae3d6..46dca74fda 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -70,7 +70,7 @@ typedef struct TranslationBlock TranslationBlock; #define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) -#include "qemu-log.h" +#include "qemu/log.h" void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 1541f0b1e4..8043b3ba26 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -1,7 +1,7 @@ #ifndef GEN_ICOUNT_H #define GEN_ICOUNT_H 1 -#include "qemu-timer.h" +#include "qemu/timer.h" /* Helpers for instruction counting code generation. */ diff --git a/include/exec/memory.h b/include/exec/memory.h index b0c474584f..aada969628 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -21,10 +21,10 @@ #include "qemu-common.h" #include "exec/cpu-common.h" #include "exec/hwaddr.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "exec/iorange.h" #include "exec/ioport.h" -#include "int128.h" +#include "qemu/int128.h" typedef struct MemoryRegionOps MemoryRegionOps; typedef struct MemoryRegion MemoryRegion; diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.h index 15d4c519ee..b219191abd 100644 --- a/include/exec/softmmu_template.h +++ b/include/exec/softmmu_template.h @@ -21,7 +21,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #define DATA_SIZE (1 << SHIFT) diff --git a/include/migration/migration.h b/include/migration/migration.h index a95f761e4c..8b7af61e7e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -16,7 +16,7 @@ #include "qapi/qmp/qdict.h" #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" #include "qapi/error.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/net.h b/include/net/net.h index 41d3729867..de42dd76da 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -1,10 +1,10 @@ #ifndef QEMU_NET_H #define QEMU_NET_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "net/queue.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/slirp.h b/include/net/slirp.h index ac9d44964f..54b655c272 100644 --- a/include/net/slirp.h +++ b/include/net/slirp.h @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "qapi-types.h" #ifdef CONFIG_SLIRP diff --git a/include/qapi/error.h b/include/qapi/error.h index 4d52e7369e..5cd2f0c302 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -12,7 +12,7 @@ #ifndef ERROR_H #define ERROR_H -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi-types.h" #include diff --git a/include/qapi/opts-visitor.h b/include/qapi/opts-visitor.h index 31fa4c5628..5939eeebc7 100644 --- a/include/qapi/opts-visitor.h +++ b/include/qapi/opts-visitor.h @@ -14,7 +14,7 @@ #define OPTS_VISITOR_H #include "qapi/visitor.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct OptsVisitor OptsVisitor; diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index c815981d30..6d9a4be3a5 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -15,7 +15,7 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #define QDICT_BUCKET_MAX 512 diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index d912297590..6c0a18dfc4 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -14,7 +14,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi-types.h" #include diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h index 0473374bf2..73351ed6d6 100644 --- a/include/qapi/qmp/qjson.h +++ b/include/qapi/qmp/qjson.h @@ -15,7 +15,7 @@ #define QJSON_H #include -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index ffa0846d48..382f04c3c4 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -14,8 +14,8 @@ #define QLIST_H #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" +#include "qemu/queue.h" typedef struct QListEntry { QObject *value; diff --git a/include/qemu/acl.h b/include/qemu/acl.h new file mode 100644 index 0000000000..116487e282 --- /dev/null +++ b/include/qemu/acl.h @@ -0,0 +1,74 @@ +/* + * QEMU access control list management + * + * Copyright (C) 2009 Red Hat, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __QEMU_ACL_H__ +#define __QEMU_ACL_H__ + +#include "qemu/queue.h" + +typedef struct qemu_acl_entry qemu_acl_entry; +typedef struct qemu_acl qemu_acl; + +struct qemu_acl_entry { + char *match; + int deny; + + QTAILQ_ENTRY(qemu_acl_entry) next; +}; + +struct qemu_acl { + char *aclname; + unsigned int nentries; + QTAILQ_HEAD(,qemu_acl_entry) entries; + int defaultDeny; +}; + +qemu_acl *qemu_acl_init(const char *aclname); + +qemu_acl *qemu_acl_find(const char *aclname); + +int qemu_acl_party_is_allowed(qemu_acl *acl, + const char *party); + +void qemu_acl_reset(qemu_acl *acl); + +int qemu_acl_append(qemu_acl *acl, + int deny, + const char *match); +int qemu_acl_insert(qemu_acl *acl, + int deny, + const char *match, + int index); +int qemu_acl_remove(qemu_acl *acl, + const char *match); + +#endif /* __QEMU_ACL_H__ */ + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h new file mode 100644 index 0000000000..96a194bbee --- /dev/null +++ b/include/qemu/atomic.h @@ -0,0 +1,67 @@ +#ifndef __QEMU_BARRIER_H +#define __QEMU_BARRIER_H 1 + +/* Compiler barrier */ +#define barrier() asm volatile("" ::: "memory") + +#if defined(__i386__) + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +/* + * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops + * on x86(well, a compiler barrier only). Well, at least as long as + * qemu doesn't do accesses to write-combining memory or non-temporal + * load/stores from C code. + */ +#define smp_wmb() barrier() +#define smp_rmb() barrier() +/* + * We use GCC builtin if it's available, as that can use + * mfence on 32 bit as well, e.g. if built with -march=pentium-m. + * However, on i386, there seem to be known bugs as recently as 4.3. + * */ +#if QEMU_GNUC_PREREQ(4, 4) +#define smp_mb() __sync_synchronize() +#else +#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") +#endif + +#elif defined(__x86_64__) + +#define smp_wmb() barrier() +#define smp_rmb() barrier() +#define smp_mb() asm volatile("mfence" ::: "memory") + +#elif defined(_ARCH_PPC) + +/* + * We use an eieio() for wmb() on powerpc. This assumes we don't + * need to order cacheable and non-cacheable stores with respect to + * each other + */ +#define smp_wmb() asm volatile("eieio" ::: "memory") + +#if defined(__powerpc64__) +#define smp_rmb() asm volatile("lwsync" ::: "memory") +#else +#define smp_rmb() asm volatile("sync" ::: "memory") +#endif + +#define smp_mb() asm volatile("sync" ::: "memory") + +#else + +/* + * For (host) platforms we don't have explicit barrier definitions + * for, we use the gcc __sync_synchronize() primitive to generate a + * full barrier. This should be safe on all platforms, though it may + * be overkill for wmb() and rmb(). + */ +#define smp_wmb() __sync_synchronize() +#define smp_mb() __sync_synchronize() +#define smp_rmb() __sync_synchronize() + +#endif + +#endif diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h new file mode 100644 index 0000000000..308bbb71e9 --- /dev/null +++ b/include/qemu/bitmap.h @@ -0,0 +1,222 @@ +/* + * Bitmap Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITMAP_H +#define BITMAP_H + +#include "qemu-common.h" +#include "qemu/bitops.h" + +/* + * The available bitmap operations and their rough meaning in the + * case that the bitmap is a single unsigned long are thus: + * + * Note that nbits should be always a compile time evaluable constant. + * Otherwise many inlines will generate horrible code. + * + * bitmap_zero(dst, nbits) *dst = 0UL + * bitmap_fill(dst, nbits) *dst = ~0UL + * bitmap_copy(dst, src, nbits) *dst = *src + * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 + * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 + * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 + * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) + * bitmap_complement(dst, src, nbits) *dst = ~(*src) + * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? + * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? + * bitmap_empty(src, nbits) Are all bits zero in *src? + * bitmap_full(src, nbits) Are all bits set in *src? + * bitmap_set(dst, pos, nbits) Set specified bit area + * bitmap_clear(dst, pos, nbits) Clear specified bit area + * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area + */ + +/* + * Also the following operations apply to bitmaps. + * + * set_bit(bit, addr) *addr |= bit + * clear_bit(bit, addr) *addr &= ~bit + * change_bit(bit, addr) *addr ^= bit + * test_bit(bit, addr) Is bit set in *addr? + * test_and_set_bit(bit, addr) Set bit and return old value + * test_and_clear_bit(bit, addr) Clear bit and return old value + * test_and_change_bit(bit, addr) Change bit and return old value + * find_first_zero_bit(addr, nbits) Position first zero bit in *addr + * find_first_bit(addr, nbits) Position first set bit in *addr + * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit + * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit + */ + +#define BITMAP_LAST_WORD_MASK(nbits) \ + ( \ + ((nbits) % BITS_PER_LONG) ? \ + (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ + ) + +#define DECLARE_BITMAP(name,bits) \ + unsigned long name[BITS_TO_LONGS(bits)] + +#define small_nbits(nbits) \ + ((nbits) <= BITS_PER_LONG) + +int slow_bitmap_empty(const unsigned long *bitmap, int bits); +int slow_bitmap_full(const unsigned long *bitmap, int bits); +int slow_bitmap_equal(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, + int bits); +void slow_bitmap_shift_right(unsigned long *dst, + const unsigned long *src, int shift, int bits); +void slow_bitmap_shift_left(unsigned long *dst, + const unsigned long *src, int shift, int bits); +int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_intersects(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); + +static inline unsigned long *bitmap_new(int nbits) +{ + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + return g_malloc0(len); +} + +static inline void bitmap_zero(unsigned long *dst, int nbits) +{ + if (small_nbits(nbits)) { + *dst = 0UL; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memset(dst, 0, len); + } +} + +static inline void bitmap_fill(unsigned long *dst, int nbits) +{ + size_t nlongs = BITS_TO_LONGS(nbits); + if (!small_nbits(nbits)) { + int len = (nlongs - 1) * sizeof(unsigned long); + memset(dst, 0xff, len); + } + dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); +} + +static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memcpy(dst, src, len); + } +} + +static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & *src2) != 0; + } + return slow_bitmap_and(dst, src1, src2, nbits); +} + +static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 | *src2; + } else { + slow_bitmap_or(dst, src1, src2, nbits); + } +} + +static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 ^ *src2; + } else { + slow_bitmap_xor(dst, src1, src2, nbits); + } +} + +static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & ~(*src2)) != 0; + } + return slow_bitmap_andnot(dst, src1, src2, nbits); +} + +static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); + } else { + slow_bitmap_complement(dst, src, nbits); + } +} + +static inline int bitmap_equal(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_equal(src1, src2, nbits); + } +} + +static inline int bitmap_empty(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_empty(src, nbits); + } +} + +static inline int bitmap_full(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_full(src, nbits); + } +} + +static inline int bitmap_intersects(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; + } else { + return slow_bitmap_intersects(src1, src2, nbits); + } +} + +void bitmap_set(unsigned long *map, int i, int len); +void bitmap_clear(unsigned long *map, int start, int nr); +unsigned long bitmap_find_next_zero_area(unsigned long *map, + unsigned long size, + unsigned long start, + unsigned int nr, + unsigned long align_mask); + +#endif /* BITMAP_H */ diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h new file mode 100644 index 0000000000..74e14e5724 --- /dev/null +++ b/include/qemu/bitops.h @@ -0,0 +1,362 @@ +/* + * Bitops Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITOPS_H +#define BITOPS_H + +#include "qemu-common.h" + +#define BITS_PER_BYTE CHAR_BIT +#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) + +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + +/** + * bitops_ffs - find first bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static unsigned long bitops_ffsl(unsigned long word) +{ + int num = 0; + +#if LONG_MAX > 0x7FFFFFFF + if ((word & 0xffffffff) == 0) { + num += 32; + word >>= 32; + } +#endif + if ((word & 0xffff) == 0) { + num += 16; + word >>= 16; + } + if ((word & 0xff) == 0) { + num += 8; + word >>= 8; + } + if ((word & 0xf) == 0) { + num += 4; + word >>= 4; + } + if ((word & 0x3) == 0) { + num += 2; + word >>= 2; + } + if ((word & 0x1) == 0) { + num += 1; + } + return num; +} + +/** + * bitops_fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static inline unsigned long bitops_flsl(unsigned long word) +{ + int num = BITS_PER_LONG - 1; + +#if LONG_MAX > 0x7FFFFFFF + if (!(word & (~0ul << 32))) { + num -= 32; + word <<= 32; + } +#endif + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { + num -= 16; + word <<= 16; + } + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { + num -= 8; + word <<= 8; + } + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { + num -= 4; + word <<= 4; + } + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { + num -= 2; + + word <<= 2; + } + if (!(word & (~0ul << (BITS_PER_LONG-1)))) + num -= 1; + return num; +} + +/** + * ffz - find first zero in word. + * @word: The word to search + * + * Undefined if no zero exists, so code should check against ~0UL first. + */ +static inline unsigned long ffz(unsigned long word) +{ + return bitops_ffsl(~word); +} + +/** + * set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + */ +static inline void set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p |= mask; +} + +/** + * clear_bit - Clears a bit in memory + * @nr: Bit to clear + * @addr: Address to start counting from + */ +static inline void clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p &= ~mask; +} + +/** + * change_bit - Toggle a bit in memory + * @nr: Bit to change + * @addr: Address to start counting from + */ +static inline void change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p ^= mask; +} + +/** + * test_and_set_bit - Set a bit and return its old value + * @nr: Bit to set + * @addr: Address to count from + */ +static inline int test_and_set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old | mask; + return (old & mask) != 0; +} + +/** + * test_and_clear_bit - Clear a bit and return its old value + * @nr: Bit to clear + * @addr: Address to count from + */ +static inline int test_and_clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old & ~mask; + return (old & mask) != 0; +} + +/** + * test_and_change_bit - Change a bit and return its old value + * @nr: Bit to change + * @addr: Address to count from + */ +static inline int test_and_change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old ^ mask; + return (old & mask) != 0; +} + +/** + * test_bit - Determine whether a bit is set + * @nr: bit number to test + * @addr: Address to start counting from + */ +static inline int test_bit(int nr, const unsigned long *addr) +{ + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); +} + +/** + * find_last_bit - find the last set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit, or size. + */ +unsigned long find_last_bit(const unsigned long *addr, + unsigned long size); + +/** + * find_next_bit - find the next set bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ +unsigned long find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); + +/** + * find_next_zero_bit - find the next cleared bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ + +unsigned long find_next_zero_bit(const unsigned long *addr, + unsigned long size, + unsigned long offset); + +/** + * find_first_bit - find the first set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit. + */ +static inline unsigned long find_first_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_bit(addr, size, 0); +} + +/** + * find_first_zero_bit - find the first cleared bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first cleared bit. + */ +static inline unsigned long find_first_zero_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_zero_bit(addr, size, 0); +} + +static inline unsigned long hweight_long(unsigned long w) +{ + unsigned long count; + + for (count = 0; w; w >>= 1) { + count += w & 1; + } + return count; +} + +/** + * extract32: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 32 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 32 bit word. It is valid to request that + * all 32 bits are returned (ie @length 32 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint32_t extract32(uint32_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 32 - start); + return (value >> start) & (~0U >> (32 - length)); +} + +/** + * extract64: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 64 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 64 bit word. It is valid to request that + * all 64 bits are returned (ie @length 64 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint64_t extract64(uint64_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 64 - start); + return (value >> start) & (~0ULL >> (64 - length)); +} + +/** + * deposit32: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 32 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 32 bit word. + * It is valid to request that all 32 bits are modified (ie @length + * 32 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint32_t deposit32(uint32_t value, int start, int length, + uint32_t fieldval) +{ + uint32_t mask; + assert(start >= 0 && length > 0 && length <= 32 - start); + mask = (~0U >> (32 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +/** + * deposit64: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 64 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 64 bit word. + * It is valid to request that all 64 bits are modified (ie @length + * 64 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint64_t deposit64(uint64_t value, int start, int length, + uint64_t fieldval) +{ + uint64_t mask; + assert(start >= 0 && length > 0 && length <= 64 - start); + mask = (~0ULL >> (64 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +#endif diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h new file mode 100644 index 0000000000..cc7f84d30f --- /dev/null +++ b/include/qemu/bswap.h @@ -0,0 +1,713 @@ +#ifndef BSWAP_H +#define BSWAP_H + +#include "config-host.h" + +#include +#include "softfloat.h" + +#ifdef CONFIG_MACHINE_BSWAP_H +#include +#include +#include +#else + +#ifdef CONFIG_BYTESWAP_H +#include +#else + +#define bswap_16(x) \ +({ \ + uint16_t __x = (x); \ + ((uint16_t)( \ + (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ +}) + +#define bswap_32(x) \ +({ \ + uint32_t __x = (x); \ + ((uint32_t)( \ + (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ +}) + +#define bswap_64(x) \ +({ \ + uint64_t __x = (x); \ + ((uint64_t)( \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ +}) + +#endif /* !CONFIG_BYTESWAP_H */ + +static inline uint16_t bswap16(uint16_t x) +{ + return bswap_16(x); +} + +static inline uint32_t bswap32(uint32_t x) +{ + return bswap_32(x); +} + +static inline uint64_t bswap64(uint64_t x) +{ + return bswap_64(x); +} + +#endif /* ! CONFIG_MACHINE_BSWAP_H */ + +static inline void bswap16s(uint16_t *s) +{ + *s = bswap16(*s); +} + +static inline void bswap32s(uint32_t *s) +{ + *s = bswap32(*s); +} + +static inline void bswap64s(uint64_t *s) +{ + *s = bswap64(*s); +} + +#if defined(HOST_WORDS_BIGENDIAN) +#define be_bswap(v, size) (v) +#define le_bswap(v, size) bswap ## size(v) +#define be_bswaps(v, size) +#define le_bswaps(p, size) *p = bswap ## size(*p); +#else +#define le_bswap(v, size) (v) +#define be_bswap(v, size) bswap ## size(v) +#define le_bswaps(v, size) +#define be_bswaps(p, size) *p = bswap ## size(*p); +#endif + +#define CPU_CONVERT(endian, size, type)\ +static inline type endian ## size ## _to_cpu(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline type cpu_to_ ## endian ## size(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline void endian ## size ## _to_cpus(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## s(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline type endian ## size ## _to_cpup(const type *p)\ +{\ + return endian ## size ## _to_cpu(*p);\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ +{\ + *p = cpu_to_ ## endian ## size(v);\ +} + +CPU_CONVERT(be, 16, uint16_t) +CPU_CONVERT(be, 32, uint32_t) +CPU_CONVERT(be, 64, uint64_t) + +CPU_CONVERT(le, 16, uint16_t) +CPU_CONVERT(le, 32, uint32_t) +CPU_CONVERT(le, 64, uint64_t) + +/* unaligned versions (optimized for frequent unaligned accesses)*/ + +#if defined(__i386__) || defined(_ARCH_PPC) + +#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) +#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) +#define le16_to_cpupu(p) le16_to_cpup(p) +#define le32_to_cpupu(p) le32_to_cpup(p) +#define be32_to_cpupu(p) be32_to_cpup(p) + +#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) +#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) +#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) + +#else + +static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; +} + +static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; + p1[2] = v >> 16; + p1[3] = v >> 24; +} + +static inline uint16_t le16_to_cpupu(const uint16_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8); +} + +static inline uint32_t le32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); +} + +static inline uint32_t be32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); +} + +static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 8; + p1[1] = v & 0xff; +} + +static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 24; + p1[1] = v >> 16; + p1[2] = v >> 8; + p1[3] = v & 0xff; +} + +static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 56; + p1[1] = v >> 48; + p1[2] = v >> 40; + p1[3] = v >> 32; + p1[4] = v >> 24; + p1[5] = v >> 16; + p1[6] = v >> 8; + p1[7] = v & 0xff; +} + +#endif + +#ifdef HOST_WORDS_BIGENDIAN +#define cpu_to_32wu cpu_to_be32wu +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) +#else +#define cpu_to_32wu cpu_to_le32wu +#define leul_to_cpu(v) (v) +#endif + +#undef le_bswap +#undef be_bswap +#undef le_bswaps +#undef be_bswaps + +/* len must be one of 1, 2, 4 */ +static inline uint32_t qemu_bswap_len(uint32_t value, int len) +{ + return bswap32(value) >> (32 - 8 * len); +} + +typedef union { + float32 f; + uint32_t l; +} CPU_FloatU; + +typedef union { + float64 d; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upper; + uint32_t lower; + } l; +#else + struct { + uint32_t lower; + uint32_t upper; + } l; +#endif + uint64_t ll; +} CPU_DoubleU; + +typedef union { + floatx80 d; + struct { + uint64_t lower; + uint16_t upper; + } l; +} CPU_LDoubleU; + +typedef union { + float128 q; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upmost; + uint32_t upper; + uint32_t lower; + uint32_t lowest; + } l; + struct { + uint64_t upper; + uint64_t lower; + } ll; +#else + struct { + uint32_t lowest; + uint32_t lower; + uint32_t upper; + uint32_t upmost; + } l; + struct { + uint64_t lower; + uint64_t upper; + } ll; +#endif +} CPU_QuadU; + +/* unaligned/endian-independent pointer access */ + +/* + * the generic syntax is: + * + * load: ld{type}{sign}{size}{endian}_p(ptr) + * + * store: st{type}{size}{endian}_p(ptr, val) + * + * Note there are small differences with the softmmu access API! + * + * type is: + * (empty): integer access + * f : float access + * + * sign is: + * (empty): for floats or 32 bit size + * u : unsigned + * s : signed + * + * size is: + * b: 8 bits + * w: 16 bits + * l: 32 bits + * q: 64 bits + * + * endian is: + * (empty): 8 bit access + * be : big endian + * le : little endian + */ +static inline int ldub_p(const void *ptr) +{ + return *(uint8_t *)ptr; +} + +static inline int ldsb_p(const void *ptr) +{ + return *(int8_t *)ptr; +} + +static inline void stb_p(void *ptr, int v) +{ + *(uint8_t *)ptr = v; +} + +/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the + kernel handles unaligned load/stores may give better results, but + it is a system wide setting : bad */ +#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +/* conservative code for little endian unaligned accesses */ +static inline int lduw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8); +#endif +} + +static inline int ldsw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return (int16_t)val; +#else + const uint8_t *p = ptr; + return (int16_t)(p[0] | (p[1] << 8)); +#endif +} + +static inline int ldl_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); +#endif +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + const uint8_t *p = ptr; + uint32_t v1, v2; + v1 = ldl_le_p(p); + v2 = ldl_le_p(p + 4); + return v1 | ((uint64_t)v2 << 32); +} + +static inline void stw_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; +#endif +} + +static inline void stl_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; + p[2] = v >> 16; + p[3] = v >> 24; +#endif +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + uint8_t *p = ptr; + stl_le_p(p, (uint32_t)v); + stl_le_p(p + 4, v >> 32); +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_le_p(ptr); + return u.f; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_le_p(ptr, u.i); +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.lower = ldl_le_p(ptr); + u.l.upper = ldl_le_p(ptr + 4); + return u.d; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_le_p(ptr, u.l.lower); + stl_le_p(ptr + 4, u.l.upper); +} + +#else + +static inline int lduw_le_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_le_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_le_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_le_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_le_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} +#endif + +#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +static inline int lduw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return ((b[0] << 8) | b[1]); +#endif +} + +static inline int ldsw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return (int16_t)val; +#else + const uint8_t *b = ptr; + return (int16_t)((b[0] << 8) | b[1]); +#endif +} + +static inline int ldl_be_p(const void *ptr) +{ +#if defined(__i386__) || defined(__x86_64__) + int val; + asm volatile ("movl %1, %0\n" + "bswap %0\n" + : "=r" (val) + : "m" (*(uint32_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; +#endif +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + uint32_t a,b; + a = ldl_be_p(ptr); + b = ldl_be_p((uint8_t *)ptr + 4); + return (((uint64_t)a<<32)|b); +} + +static inline void stw_be_p(void *ptr, int v) +{ +#if defined(__i386__) + asm volatile ("xchgb %b0, %h0\n" + "movw %w0, %1\n" + : "=q" (v) + : "m" (*(uint16_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 8; + d[1] = v; +#endif +} + +static inline void stl_be_p(void *ptr, int v) +{ +#if defined(__i386__) || defined(__x86_64__) + asm volatile ("bswap %0\n" + "movl %0, %1\n" + : "=r" (v) + : "m" (*(uint32_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 24; + d[1] = v >> 16; + d[2] = v >> 8; + d[3] = v; +#endif +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + stl_be_p(ptr, v >> 32); + stl_be_p((uint8_t *)ptr + 4, v); +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_be_p(ptr); + return u.f; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_be_p(ptr, u.i); +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.upper = ldl_be_p(ptr); + u.l.lower = ldl_be_p((uint8_t *)ptr + 4); + return u.d; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_be_p(ptr, u.l.upper); + stl_be_p((uint8_t *)ptr + 4, u.l.lower); +} + +#else + +static inline int lduw_be_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_be_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_be_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_be_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_be_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} + +#endif + +#endif /* BSWAP_H */ diff --git a/include/qemu/cache-utils.h b/include/qemu/cache-utils.h new file mode 100644 index 0000000000..2c57f78fc1 --- /dev/null +++ b/include/qemu/cache-utils.h @@ -0,0 +1,44 @@ +#ifndef QEMU_CACHE_UTILS_H +#define QEMU_CACHE_UTILS_H + +#if defined(_ARCH_PPC) + +#include /* uintptr_t */ + +struct qemu_cache_conf { + unsigned long dcache_bsize; + unsigned long icache_bsize; +}; + +extern struct qemu_cache_conf qemu_cache_conf; + +void qemu_cache_utils_init(char **envp); + +/* mildly adjusted code from tcg-dyngen.c */ +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + unsigned long p, start1, stop1; + unsigned long dsize = qemu_cache_conf.dcache_bsize; + unsigned long isize = qemu_cache_conf.icache_bsize; + + start1 = start & ~(dsize - 1); + stop1 = (stop + dsize - 1) & ~(dsize - 1); + for (p = start1; p < stop1; p += dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &= start & ~(isize - 1); + stop1 = (stop + isize - 1) & ~(isize - 1); + for (p = start1; p < stop1; p += isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#else +#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) +#endif + +#endif /* QEMU_CACHE_UTILS_H */ diff --git a/include/qemu/compatfd.h b/include/qemu/compatfd.h new file mode 100644 index 0000000000..6b04877b97 --- /dev/null +++ b/include/qemu/compatfd.h @@ -0,0 +1,44 @@ +/* + * signalfd/eventfd compatibility + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_COMPATFD_H +#define QEMU_COMPATFD_H + +#include + +struct qemu_signalfd_siginfo { + uint32_t ssi_signo; /* Signal number */ + int32_t ssi_errno; /* Error number (unused) */ + int32_t ssi_code; /* Signal code */ + uint32_t ssi_pid; /* PID of sender */ + uint32_t ssi_uid; /* Real UID of sender */ + int32_t ssi_fd; /* File descriptor (SIGIO) */ + uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ + uint32_t ssi_band; /* Band event (SIGIO) */ + uint32_t ssi_overrun; /* POSIX timer overrun count */ + uint32_t ssi_trapno; /* Trap number that caused signal */ + int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ + int32_t ssi_int; /* Integer sent by sigqueue(2) */ + uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ + uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ + uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ + uint64_t ssi_addr; /* Address that generated signal + (for hardware-generated signals) */ + uint8_t pad[48]; /* Pad size to 128 bytes (allow for + additional fields in the future) */ +}; + +int qemu_signalfd(const sigset_t *mask); +bool qemu_signalfd_available(void); + +#endif diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h new file mode 100644 index 0000000000..2f7998b6c1 --- /dev/null +++ b/include/qemu/compiler.h @@ -0,0 +1,58 @@ +/* public domain */ + +#ifndef COMPILER_H +#define COMPILER_H + +#include "config-host.h" + +/*---------------------------------------------------------------------------- +| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. +| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. +*----------------------------------------------------------------------------*/ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define QEMU_GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define QEMU_GNUC_PREREQ(maj, min) 0 +#endif + +#define QEMU_NORETURN __attribute__ ((__noreturn__)) + +#if QEMU_GNUC_PREREQ(3, 4) +#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define QEMU_WARN_UNUSED_RESULT +#endif + +#if defined(_WIN32) +# define QEMU_PACKED __attribute__((gcc_struct, packed)) +#else +# define QEMU_PACKED __attribute__((packed)) +#endif + +#define cat(x,y) x ## y +#define cat2(x,y) cat(x,y) +#define QEMU_BUILD_BUG_ON(x) \ + typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; + +#if defined __GNUC__ +# if !QEMU_GNUC_PREREQ(4, 4) + /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ +# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) +# else + /* Use gnu_printf when supported (qemu uses standard format strings). */ +# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) +# if defined(_WIN32) + /* Map __printf__ to __gnu_printf__ because we want standard format strings + * even when MinGW or GLib include files use __printf__. */ +# define __printf__ __gnu_printf__ +# endif +# endif +#else +#define GCC_ATTR /**/ +#define GCC_FMT_ATTR(n, m) +#endif + +#endif /* COMPILER_H */ diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h new file mode 100644 index 0000000000..486c77cad4 --- /dev/null +++ b/include/qemu/config-file.h @@ -0,0 +1,30 @@ +#ifndef QEMU_CONFIG_H +#define QEMU_CONFIG_H + +#include +#include "qemu/option.h" +#include "qapi/error.h" +#include "qemu/option.h" + +extern QemuOptsList qemu_fsdev_opts; +extern QemuOptsList qemu_virtfs_opts; +extern QemuOptsList qemu_spice_opts; +extern QemuOptsList qemu_sandbox_opts; + +QemuOptsList *qemu_find_opts(const char *group); +QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); +void qemu_add_opts(QemuOptsList *list); +int qemu_set_option(const char *str); +int qemu_global_option(const char *str); +void qemu_add_globals(void); + +void qemu_config_write(FILE *fp); +int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); + +int qemu_read_config_file(const char *filename); + +/* Read default QEMU config files + */ +int qemu_read_default_config_files(bool userconfig); + +#endif /* QEMU_CONFIG_H */ diff --git a/include/qemu/envlist.h b/include/qemu/envlist.h new file mode 100644 index 0000000000..b9addcc11f --- /dev/null +++ b/include/qemu/envlist.h @@ -0,0 +1,22 @@ +#ifndef ENVLIST_H +#define ENVLIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct envlist envlist_t; + +envlist_t *envlist_create(void); +void envlist_free(envlist_t *); +int envlist_setenv(envlist_t *, const char *); +int envlist_unsetenv(envlist_t *, const char *); +int envlist_parse_set(envlist_t *, const char *); +int envlist_parse_unset(envlist_t *, const char *); +char **envlist_to_environ(const envlist_t *, size_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* ENVLIST_H */ diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h new file mode 100644 index 0000000000..c902cc10de --- /dev/null +++ b/include/qemu/error-report.h @@ -0,0 +1,43 @@ +/* + * Error reporting + * + * Copyright (C) 2010 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_ERROR_H +#define QEMU_ERROR_H + +#include + +typedef struct Location { + /* all members are private to qemu-error.c */ + enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; + int num; + const void *ptr; + struct Location *prev; +} Location; + +Location *loc_push_restore(Location *loc); +Location *loc_push_none(Location *loc); +Location *loc_pop(Location *loc); +Location *loc_save(Location *loc); +void loc_restore(Location *loc); +void loc_set_none(void); +void loc_set_cmdline(char **argv, int idx, int cnt); +void loc_set_file(const char *fname, int lno); + +void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_print_loc(void); +void error_set_progname(const char *argv0); +void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +const char *error_get_progname(void); + +#endif diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h new file mode 100644 index 0000000000..88b57af7ce --- /dev/null +++ b/include/qemu/event_notifier.h @@ -0,0 +1,46 @@ +/* + * event notifier support + * + * Copyright Red Hat, Inc. 2010 + * + * Authors: + * Michael S. Tsirkin + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_EVENT_NOTIFIER_H +#define QEMU_EVENT_NOTIFIER_H + +#include "qemu-common.h" + +#ifdef _WIN32 +#include +#endif + +struct EventNotifier { +#ifdef _WIN32 + HANDLE event; +#else + int rfd; + int wfd; +#endif +}; + +typedef void EventNotifierHandler(EventNotifier *); + +int event_notifier_init(EventNotifier *, int active); +void event_notifier_cleanup(EventNotifier *); +int event_notifier_set(EventNotifier *); +int event_notifier_test_and_clear(EventNotifier *); +int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); + +#ifdef CONFIG_POSIX +void event_notifier_init_fd(EventNotifier *, int fd); +int event_notifier_get_fd(EventNotifier *); +#else +HANDLE event_notifier_get_handle(EventNotifier *); +#endif + +#endif diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h new file mode 100644 index 0000000000..81c9a754ae --- /dev/null +++ b/include/qemu/host-utils.h @@ -0,0 +1,240 @@ +/* + * Utility compute operations used by translated code. + * + * Copyright (c) 2007 Thiemo Seufer + * Copyright (c) 2007 Jocelyn Mayer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef HOST_UTILS_H +#define HOST_UTILS_H 1 + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +#if defined(__x86_64__) +#define __HAVE_FAST_MULU64__ +static inline void mulu64(uint64_t *plow, uint64_t *phigh, + uint64_t a, uint64_t b) +{ + __asm__ ("mul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#define __HAVE_FAST_MULS64__ +static inline void muls64(uint64_t *plow, uint64_t *phigh, + int64_t a, int64_t b) +{ + __asm__ ("imul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#else +void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); +void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); +#endif + +/* Binary search for leading zeros. */ + +static inline int clz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clz(val); + else + return 32; +#else + int cnt = 0; + + if (!(val & 0xFFFF0000U)) { + cnt += 16; + val <<= 16; + } + if (!(val & 0xFF000000U)) { + cnt += 8; + val <<= 8; + } + if (!(val & 0xF0000000U)) { + cnt += 4; + val <<= 4; + } + if (!(val & 0xC0000000U)) { + cnt += 2; + val <<= 2; + } + if (!(val & 0x80000000U)) { + cnt++; + val <<= 1; + } + if (!(val & 0x80000000U)) { + cnt++; + } + return cnt; +#endif +} + +static inline int clo32(uint32_t val) +{ + return clz32(~val); +} + +static inline int clz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clzll(val); + else + return 64; +#else + int cnt = 0; + + if (!(val >> 32)) { + cnt += 32; + } else { + val >>= 32; + } + + return cnt + clz32(val); +#endif +} + +static inline int clo64(uint64_t val) +{ + return clz64(~val); +} + +static inline int ctz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctz(val); + else + return 32; +#else + int cnt; + + cnt = 0; + if (!(val & 0x0000FFFFUL)) { + cnt += 16; + val >>= 16; + } + if (!(val & 0x000000FFUL)) { + cnt += 8; + val >>= 8; + } + if (!(val & 0x0000000FUL)) { + cnt += 4; + val >>= 4; + } + if (!(val & 0x00000003UL)) { + cnt += 2; + val >>= 2; + } + if (!(val & 0x00000001UL)) { + cnt++; + val >>= 1; + } + if (!(val & 0x00000001UL)) { + cnt++; + } + + return cnt; +#endif +} + +static inline int cto32(uint32_t val) +{ + return ctz32(~val); +} + +static inline int ctz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctzll(val); + else + return 64; +#else + int cnt; + + cnt = 0; + if (!((uint32_t)val)) { + cnt += 32; + val >>= 32; + } + + return cnt + ctz32(val); +#endif +} + +static inline int cto64(uint64_t val) +{ + return ctz64(~val); +} + +static inline int ctpop8(uint8_t val) +{ + val = (val & 0x55) + ((val >> 1) & 0x55); + val = (val & 0x33) + ((val >> 2) & 0x33); + val = (val & 0x0f) + ((val >> 4) & 0x0f); + + return val; +} + +static inline int ctpop16(uint16_t val) +{ + val = (val & 0x5555) + ((val >> 1) & 0x5555); + val = (val & 0x3333) + ((val >> 2) & 0x3333); + val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); + val = (val & 0x00ff) + ((val >> 8) & 0x00ff); + + return val; +} + +static inline int ctpop32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcount(val); +#else + val = (val & 0x55555555) + ((val >> 1) & 0x55555555); + val = (val & 0x33333333) + ((val >> 2) & 0x33333333); + val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); + val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); + val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); + + return val; +#endif +} + +static inline int ctpop64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcountll(val); +#else + val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); + val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); + val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); + val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); + val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); + val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); + + return val; +#endif +} + +#endif diff --git a/include/qemu/int128.h b/include/qemu/int128.h new file mode 100644 index 0000000000..b3864b6cd4 --- /dev/null +++ b/include/qemu/int128.h @@ -0,0 +1,116 @@ +#ifndef INT128_H +#define INT128_H + +typedef struct Int128 Int128; + +struct Int128 { + uint64_t lo; + int64_t hi; +}; + +static inline Int128 int128_make64(uint64_t a) +{ + return (Int128) { a, 0 }; +} + +static inline uint64_t int128_get64(Int128 a) +{ + assert(!a.hi); + return a.lo; +} + +static inline Int128 int128_zero(void) +{ + return int128_make64(0); +} + +static inline Int128 int128_one(void) +{ + return int128_make64(1); +} + +static inline Int128 int128_2_64(void) +{ + return (Int128) { 0, 1 }; +} + +static inline Int128 int128_add(Int128 a, Int128 b) +{ + Int128 r = { a.lo + b.lo, a.hi + b.hi }; + r.hi += (r.lo < a.lo) || (r.lo < b.lo); + return r; +} + +static inline Int128 int128_neg(Int128 a) +{ + a.lo = ~a.lo; + a.hi = ~a.hi; + return int128_add(a, int128_one()); +} + +static inline Int128 int128_sub(Int128 a, Int128 b) +{ + return int128_add(a, int128_neg(b)); +} + +static inline bool int128_nonneg(Int128 a) +{ + return a.hi >= 0; +} + +static inline bool int128_eq(Int128 a, Int128 b) +{ + return a.lo == b.lo && a.hi == b.hi; +} + +static inline bool int128_ne(Int128 a, Int128 b) +{ + return !int128_eq(a, b); +} + +static inline bool int128_ge(Int128 a, Int128 b) +{ + return int128_nonneg(int128_sub(a, b)); +} + +static inline bool int128_lt(Int128 a, Int128 b) +{ + return !int128_ge(a, b); +} + +static inline bool int128_le(Int128 a, Int128 b) +{ + return int128_ge(b, a); +} + +static inline bool int128_gt(Int128 a, Int128 b) +{ + return !int128_le(a, b); +} + +static inline bool int128_nz(Int128 a) +{ + return a.lo || a.hi; +} + +static inline Int128 int128_min(Int128 a, Int128 b) +{ + return int128_le(a, b) ? a : b; +} + +static inline Int128 int128_max(Int128 a, Int128 b) +{ + return int128_ge(a, b) ? a : b; +} + +static inline void int128_addto(Int128 *a, Int128 b) +{ + *a = int128_add(*a, b); +} + +static inline void int128_subfrom(Int128 *a, Int128 b) +{ + *a = int128_sub(*a, b); +} + +#endif diff --git a/include/qemu/iov.h b/include/qemu/iov.h new file mode 100644 index 0000000000..d06f8b9ce3 --- /dev/null +++ b/include/qemu/iov.h @@ -0,0 +1,102 @@ +/* + * Helpers for using (partial) iovecs. + * + * Copyright (C) 2010 Red Hat, Inc. + * + * Author(s): + * Amit Shah + * Michael Tokarev + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef IOV_H +#define IOV_H + +#include "qemu-common.h" + +/** + * count and return data size, in bytes, of an iovec + * starting at `iov' of `iov_cnt' number of elements. + */ +size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); + +/** + * Copy from single continuous buffer to scatter-gather vector of buffers + * (iovec) and back like memcpy() between two continuous memory regions. + * Data in single continuous buffer starting at address `buf' and + * `bytes' bytes long will be copied to/from an iovec `iov' with + * `iov_cnt' number of elements, starting at byte position `offset' + * within the iovec. If the iovec does not contain enough space, + * only part of data will be copied, up to the end of the iovec. + * Number of bytes actually copied will be returned, which is + * min(bytes, iov_size(iov)-offset) + * `Offset' must point to the inside of iovec. + * It is okay to use very large value for `bytes' since we're + * limited by the size of the iovec anyway, provided that the + * buffer pointed to by buf has enough space. One possible + * such "large" value is -1 (sinice size_t is unsigned), + * so specifying `-1' as `bytes' means 'up to the end of iovec'. + */ +size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, + size_t offset, const void *buf, size_t bytes); +size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, void *buf, size_t bytes); + +/** + * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, + * starting at byte offset `start', to value `fillc', repeating it + * `bytes' number of times. `Offset' must point to the inside of iovec. + * If `bytes' is large enough, only last bytes portion of iovec, + * up to the end of it, will be filled with the specified value. + * Function return actual number of bytes processed, which is + * min(size, iov_size(iov) - offset). + * Again, it is okay to use large value for `bytes' to mean "up to the end". + */ +size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, int fillc, size_t bytes); + +/* + * Send/recv data from/to iovec buffers directly + * + * `offset' bytes in the beginning of iovec buffer are skipped and + * next `bytes' bytes are used, which must be within data of iovec. + * + * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); + * + * is logically equivalent to + * + * char *buf = malloc(bytes); + * iov_to_buf(iov, iovcnt, offset, buf, bytes); + * r = send(sockfd, buf, bytes, 0); + * free(buf); + * + * For iov_send_recv() _whole_ area being sent or received + * should be within the iovec, not only beginning of it. + */ +ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, + size_t offset, size_t bytes, bool do_send); +#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) +#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) + +/** + * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements + * in file `fp', prefixing each line with `prefix' and processing not more + * than `limit' data bytes. + */ +void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, + FILE *fp, const char *prefix, size_t limit); + +/* + * Partial copy of vector from iov to dst_iov (data is not copied). + * dst_iov overlaps iov at a specified offset. + * size of dst_iov is at most bytes. dst vector count is returned. + */ +unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, + const struct iovec *iov, unsigned int iov_cnt, + size_t offset, size_t bytes); + +#endif diff --git a/include/qemu/log.h b/include/qemu/log.h new file mode 100644 index 0000000000..58f69cb494 --- /dev/null +++ b/include/qemu/log.h @@ -0,0 +1,160 @@ +#ifndef QEMU_LOG_H +#define QEMU_LOG_H + +#include +#ifdef NEED_CPU_H +#include "disas/disas.h" +#endif + +/* Private global variables, don't use */ +extern FILE *qemu_logfile; +extern int qemu_loglevel; + +/* + * The new API: + * + */ + +/* Log settings checking macros: */ + +/* Returns true if qemu_log() will really write somewhere + */ +static inline bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +#define CPU_LOG_TB_OUT_ASM (1 << 0) +#define CPU_LOG_TB_IN_ASM (1 << 1) +#define CPU_LOG_TB_OP (1 << 2) +#define CPU_LOG_TB_OP_OPT (1 << 3) +#define CPU_LOG_INT (1 << 4) +#define CPU_LOG_EXEC (1 << 5) +#define CPU_LOG_PCALL (1 << 6) +#define CPU_LOG_IOPORT (1 << 7) +#define CPU_LOG_TB_CPU (1 << 8) +#define CPU_LOG_RESET (1 << 9) +#define LOG_UNIMP (1 << 10) +#define LOG_GUEST_ERROR (1 << 11) + +/* Returns true if a bit is set in the current loglevel mask + */ +static inline bool qemu_loglevel_mask(int mask) +{ + return (qemu_loglevel & mask) != 0; +} + +/* Logging functions: */ + +/* main logging function + */ +void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); + +/* vfprintf-like logging function + */ +static inline void GCC_FMT_ATTR(1, 0) +qemu_log_vprintf(const char *fmt, va_list va) +{ + if (qemu_logfile) { + vfprintf(qemu_logfile, fmt, va); + } +} + +/* log only if a bit is set on the current loglevel mask + */ +void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); + + +/* Special cases: */ + +#ifdef NEED_CPU_H +/* cpu_dump_state() logging functions: */ +static inline void log_cpu_state(CPUArchState *env1, int flags) +{ + if (qemu_log_enabled()) { + cpu_dump_state(env1, qemu_logfile, fprintf, flags); + } +} + +static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) +{ + if (qemu_loglevel & mask) { + log_cpu_state(env1, flags); + } +} + +/* disas() and target_disas() to qemu_logfile: */ +static inline void log_target_disas(CPUArchState *env, target_ulong start, + target_ulong len, int flags) +{ + target_disas(qemu_logfile, env, start, len, flags); +} + +static inline void log_disas(void *code, unsigned long size) +{ + disas(qemu_logfile, code, size); +} + +#if defined(CONFIG_USER_ONLY) +/* page_dump() output to the log file: */ +static inline void log_page_dump(void) +{ + page_dump(qemu_logfile); +} +#endif +#endif + + +/* Maintenance: */ + +/* fflush() the log file */ +static inline void qemu_log_flush(void) +{ + fflush(qemu_logfile); +} + +/* Close the log file */ +static inline void qemu_log_close(void) +{ + fclose(qemu_logfile); + qemu_logfile = NULL; +} + +/* Set up a new log file */ +static inline void qemu_log_set_file(FILE *f) +{ + qemu_logfile = f; +} + +/* Set up a new log file, only if none is set */ +static inline void qemu_log_try_set_file(FILE *f) +{ + if (!qemu_logfile) { + qemu_logfile = f; + } +} + +/* define log items */ +typedef struct CPULogItem { + int mask; + const char *name; + const char *help; +} CPULogItem; + +extern const CPULogItem cpu_log_items[]; + +void qemu_set_log(int log_flags, bool use_own_buffers); + +static inline void cpu_set_log(int log_flags) +{ +#ifdef CONFIG_USER_ONLY + qemu_set_log(log_flags, true); +#else + qemu_set_log(log_flags, false); +#endif +} + +void cpu_set_log_filename(const char *filename); +int cpu_str_to_log_mask(const char *str); + +#endif diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h new file mode 100644 index 0000000000..e8059c3d0a --- /dev/null +++ b/include/qemu/main-loop.h @@ -0,0 +1,306 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_MAIN_LOOP_H +#define QEMU_MAIN_LOOP_H 1 + +#include "block/aio.h" + +#define SIG_IPI SIGUSR1 + +/** + * qemu_init_main_loop: Set up the process so that it can run the main loop. + * + * This includes setting up signal handlers. It should be called before + * any other threads are created. In addition, threads other than the + * main one should block signals that are trapped by the main loop. + * For simplicity, you can consider these signals to be safe: SIGUSR1, + * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time + * signals if available. Remember that Windows in practice does not have + * signals, though. + * + * In the case of QEMU tools, this will also start/initialize timers. + */ +int qemu_init_main_loop(void); + +/** + * main_loop_wait: Run one iteration of the main loop. + * + * If @nonblocking is true, poll for events, otherwise suspend until + * one actually occurs. The main loop usually consists of a loop that + * repeatedly calls main_loop_wait(false). + * + * Main loop services include file descriptor callbacks, bottom halves + * and timers (defined in qemu-timer.h). Bottom halves are similar to timers + * that execute immediately, but have a lower overhead and scheduling them + * is wait-free, thread-safe and signal-safe. + * + * It is sometimes useful to put a whole program in a coroutine. In this + * case, the coroutine actually should be started from within the main loop, + * so that the main loop can run whenever the coroutine yields. To do this, + * you can use a bottom half to enter the coroutine as soon as the main loop + * starts: + * + * void enter_co_bh(void *opaque) { + * QEMUCoroutine *co = opaque; + * qemu_coroutine_enter(co, NULL); + * } + * + * ... + * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); + * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); + * qemu_bh_schedule(start_bh); + * while (...) { + * main_loop_wait(false); + * } + * + * (In the future we may provide a wrapper for this). + * + * @nonblocking: Whether the caller should block until an event occurs. + */ +int main_loop_wait(int nonblocking); + +/** + * qemu_notify_event: Force processing of pending events. + * + * Similar to signaling a condition variable, qemu_notify_event forces + * main_loop_wait to look at pending events and exit. The caller of + * main_loop_wait will usually call it again very soon, so qemu_notify_event + * also has the side effect of recalculating the sets of file descriptors + * that the main loop waits for. + * + * Calling qemu_notify_event is rarely necessary, because main loop + * services (bottom halves and timers) call it themselves. One notable + * exception occurs when using qemu_set_fd_handler2 (see below). + */ +void qemu_notify_event(void); + +#ifdef _WIN32 +/* return TRUE if no sleep should be done afterwards */ +typedef int PollingFunc(void *opaque); + +/** + * qemu_add_polling_cb: Register a Windows-specific polling callback + * + * Currently, under Windows some events are polled rather than waited for. + * Polling callbacks do not ensure that @func is called timely, because + * the main loop might wait for an arbitrarily long time. If possible, + * you should instead create a separate thread that does a blocking poll + * and set a Win32 event object. The event can then be passed to + * qemu_add_wait_object. + * + * Polling callbacks really have nothing Windows specific in them, but + * as they are a hack and are currently not necessary under POSIX systems, + * they are only available when QEMU is running under Windows. + * + * @func: The function that does the polling, and returns 1 to force + * immediate completion of main_loop_wait. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_polling_cb(PollingFunc *func, void *opaque); + +/** + * qemu_del_polling_cb: Unregister a Windows-specific polling callback + * + * This function removes a callback that was registered with + * qemu_add_polling_cb. + * + * @func: The function that was passed to qemu_add_polling_cb. + * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. + */ +void qemu_del_polling_cb(PollingFunc *func, void *opaque); + +/* Wait objects handling */ +typedef void WaitObjectFunc(void *opaque); + +/** + * qemu_add_wait_object: Register a callback for a Windows handle + * + * Under Windows, the iohandler mechanism can only be used with sockets. + * QEMU must use the WaitForMultipleObjects API to wait on other handles. + * This function registers a #HANDLE with QEMU, so that it will be included + * in the main loop's calls to WaitForMultipleObjects. When the handle + * is in a signaled state, QEMU will call @func. + * + * @handle: The Windows handle to be observed. + * @func: A function to be called when @handle is in a signaled state. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); + +/** + * qemu_del_wait_object: Unregister a callback for a Windows handle + * + * This function removes a callback that was registered with + * qemu_add_wait_object. + * + * @func: The function that was passed to qemu_add_wait_object. + * @opaque: A pointer-size value that was passed to qemu_add_wait_object. + */ +void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); +#endif + +/* async I/O support */ + +typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +typedef int IOCanReadHandler(void *opaque); + +/** + * qemu_set_fd_handler2: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * @fd_read_poll can be used to disable the @fd_read callback temporarily. + * This is useful to avoid calling qemu_set_fd_handler2 every time the + * client becomes interested in reading (or dually, stops being interested). + * A typical example is when @fd is a listening socket and you want to bound + * the number of active clients. Remember to call qemu_notify_event whenever + * the condition may change from %false to %true. + * + * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read_poll: A function that returns 1 if the @fd_read callback + * should be fired. If the function returns 0, the main loop will not + * end its iteration even if @fd becomes readable. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read_poll, + * @fd_read and @fd_write. + */ +int qemu_set_fd_handler2(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +/** + * qemu_set_fd_handler: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * The callbacks that are set up by qemu_set_fd_handler are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. + */ +int qemu_set_fd_handler(int fd, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +#ifdef CONFIG_POSIX +/** + * qemu_add_child_watch: Register a child process for reaping. + * + * Under POSIX systems, a parent process must read the exit status of + * its child processes using waitpid, or the operating system will not + * free some of the resources attached to that process. + * + * This function directs the QEMU main loop to observe a child process + * and call waitpid as soon as it exits; the watch is then removed + * automatically. It is useful whenever QEMU forks a child process + * but will find out about its termination by other means such as a + * "broken pipe". + * + * @pid: The pid that QEMU should observe. + */ +int qemu_add_child_watch(pid_t pid); +#endif + +/** + * qemu_mutex_lock_iothread: Lock the main loop mutex. + * + * This function locks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be taken + * by threads other than the main loop thread when calling + * qemu_bh_new(), qemu_set_fd_handler() and basically all other + * functions documented in this file. + * + * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread + * is a no-op there. + */ +void qemu_mutex_lock_iothread(void); + +/** + * qemu_mutex_unlock_iothread: Unlock the main loop mutex. + * + * This function unlocks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be unlocked + * as soon as possible by threads other than the main loop thread, + * because it prevents the main loop from processing callbacks, + * including timers and bottom halves. + * + * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread + * is a no-op there. + */ +void qemu_mutex_unlock_iothread(void); + +/* internal interfaces */ + +void qemu_fd_register(int fd); +void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); +void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); + +QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); +void qemu_bh_schedule_idle(QEMUBH *bh); + +#endif diff --git a/include/qemu/module.h b/include/qemu/module.h new file mode 100644 index 0000000000..c4ccd57166 --- /dev/null +++ b/include/qemu/module.h @@ -0,0 +1,40 @@ +/* + * QEMU Module Infrastructure + * + * Copyright IBM, Corp. 2009 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MODULE_H +#define QEMU_MODULE_H + +/* This should not be used directly. Use block_init etc. instead. */ +#define module_init(function, type) \ +static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ + register_module_init(function, type); \ +} + +typedef enum { + MODULE_INIT_BLOCK, + MODULE_INIT_MACHINE, + MODULE_INIT_QAPI, + MODULE_INIT_QOM, + MODULE_INIT_MAX +} module_init_type; + +#define block_init(function) module_init(function, MODULE_INIT_BLOCK) +#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) +#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) +#define type_init(function) module_init(function, MODULE_INIT_QOM) + +void register_module_init(void (*fn)(void), module_init_type type); + +void module_call_init(module_init_type type); + +#endif diff --git a/include/qemu/notify.h b/include/qemu/notify.h new file mode 100644 index 0000000000..4e2e7f0ec4 --- /dev/null +++ b/include/qemu/notify.h @@ -0,0 +1,43 @@ +/* + * Notifier lists + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_NOTIFY_H +#define QEMU_NOTIFY_H + +#include "qemu/queue.h" + +typedef struct Notifier Notifier; + +struct Notifier +{ + void (*notify)(Notifier *notifier, void *data); + QLIST_ENTRY(Notifier) node; +}; + +typedef struct NotifierList +{ + QLIST_HEAD(, Notifier) notifiers; +} NotifierList; + +#define NOTIFIER_LIST_INITIALIZER(head) \ + { QLIST_HEAD_INITIALIZER((head).notifiers) } + +void notifier_list_init(NotifierList *list); + +void notifier_list_add(NotifierList *list, Notifier *notifier); + +void notifier_remove(Notifier *notifier); + +void notifier_list_notify(NotifierList *list, void *data); + +#endif diff --git a/include/qemu/option.h b/include/qemu/option.h new file mode 100644 index 0000000000..ba197cddcf --- /dev/null +++ b/include/qemu/option.h @@ -0,0 +1,158 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_H +#define QEMU_OPTIONS_H + +#include +#include "qemu/queue.h" +#include "qapi/error.h" +#include "qapi/qmp/qdict.h" + +enum QEMUOptionParType { + OPT_FLAG, + OPT_NUMBER, + OPT_SIZE, + OPT_STRING, +}; + +typedef struct QEMUOptionParameter { + const char *name; + enum QEMUOptionParType type; + union { + uint64_t n; + char* s; + } value; + const char *help; +} QEMUOptionParameter; + + +const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); +const char *get_opt_value(char *buf, int buf_size, const char *p); +int get_next_param_value(char *buf, int buf_size, + const char *tag, const char **pstr); +int get_param_value(char *buf, int buf_size, + const char *tag, const char *str); +int check_params(char *buf, int buf_size, + const char * const *params, const char *str); + + +/* + * The following functions take a parameter list as input. This is a pointer to + * the first element of a QEMUOptionParameter array which is terminated by an + * entry with entry->name == NULL. + */ + +QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, + const char *name); +int set_option_parameter(QEMUOptionParameter *list, const char *name, + const char *value); +int set_option_parameter_int(QEMUOptionParameter *list, const char *name, + uint64_t value); +QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, + QEMUOptionParameter *list); +QEMUOptionParameter *parse_option_parameters(const char *param, + QEMUOptionParameter *list, QEMUOptionParameter *dest); +void free_option_parameters(QEMUOptionParameter *list); +void print_option_parameters(QEMUOptionParameter *list); +void print_option_help(QEMUOptionParameter *list); + +/* ------------------------------------------------------------------ */ + +typedef struct QemuOpt QemuOpt; +typedef struct QemuOpts QemuOpts; +typedef struct QemuOptsList QemuOptsList; + +enum QemuOptType { + QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ + QEMU_OPT_BOOL, /* on/off */ + QEMU_OPT_NUMBER, /* simple number */ + QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ +}; + +typedef struct QemuOptDesc { + const char *name; + enum QemuOptType type; + const char *help; +} QemuOptDesc; + +struct QemuOptsList { + const char *name; + const char *implied_opt_name; + bool merge_lists; /* Merge multiple uses of option into a single list? */ + QTAILQ_HEAD(, QemuOpts) head; + QemuOptDesc desc[]; +}; + +const char *qemu_opt_get(QemuOpts *opts, const char *name); +/** + * qemu_opt_has_help_opt: + * @opts: options to search for a help request + * + * Check whether the options specified by @opts include one of the + * standard strings which indicate that the user is asking for a + * list of the valid values for a command line option (as defined + * by is_help_option()). + * + * Returns: true if @opts includes 'help' or equivalent. + */ +bool qemu_opt_has_help_opt(QemuOpts *opts); +bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); +uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); +uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); +int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); +void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, + Error **errp); +int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); +int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); +typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); +int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, + int abort_on_failure); + +QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); +QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, + int fail_if_exists, Error **errp); +QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); +void qemu_opts_reset(QemuOptsList *list); +void qemu_opts_loc_restore(QemuOpts *opts); +int qemu_opts_set(QemuOptsList *list, const char *id, + const char *name, const char *value); +const char *qemu_opts_id(QemuOpts *opts); +void qemu_opts_del(QemuOpts *opts); +void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); +int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); +QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); +void qemu_opts_set_defaults(QemuOptsList *list, const char *params, + int permit_abbrev); +QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, + Error **errp); +QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); + +typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); +int qemu_opts_print(QemuOpts *opts, void *dummy); +int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, + int abort_on_failure); + +#endif diff --git a/include/qemu/option_int.h b/include/qemu/option_int.h new file mode 100644 index 0000000000..8212fa4a48 --- /dev/null +++ b/include/qemu/option_int.h @@ -0,0 +1,54 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_INTERNAL_H +#define QEMU_OPTIONS_INTERNAL_H + +#include "qemu/option.h" +#include "qemu/error-report.h" + +struct QemuOpt { + const char *name; + const char *str; + + const QemuOptDesc *desc; + union { + bool boolean; + uint64_t uint; + } value; + + QemuOpts *opts; + QTAILQ_ENTRY(QemuOpt) next; +}; + +struct QemuOpts { + char *id; + QemuOptsList *list; + Location loc; + QTAILQ_HEAD(QemuOptHead, QemuOpt) head; + QTAILQ_ENTRY(QemuOpts) next; +}; + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h new file mode 100644 index 0000000000..87d3b9cfa8 --- /dev/null +++ b/include/qemu/osdep.h @@ -0,0 +1,178 @@ +#ifndef QEMU_OSDEP_H +#define QEMU_OSDEP_H + +#include +#include +#include +#ifdef __OpenBSD__ +#include +#include +#endif + +#include + +#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 +/* [u]int_fast*_t not in */ +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef signed int int_fast16_t; +#endif + +#ifndef glue +#define xglue(x, y) x ## y +#define glue(x, y) xglue(x, y) +#define stringify(s) tostring(s) +#define tostring(s) #s +#endif + +#ifndef likely +#if __GNUC__ < 3 +#define __builtin_expect(x, n) (x) +#endif + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif + +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char __attribute__((unused)) offset_must_be_zero[ \ + -offsetof(type, field)]; \ + container_of(dev, type, field);})) +#else +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) +#endif + +#define typeof_field(type, field) typeof(((type *)0)->field) +#define type_check(t1,t2) ((t1*)0 - (t2*)0) + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef DIV_ROUND_UP +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#ifndef always_inline +#if !((__GNUC__ < 3) || defined(__APPLE__)) +#ifdef __OPTIMIZE__ +#undef inline +#define inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#else +#undef inline +#define inline always_inline +#endif + +#define qemu_printf printf + +int qemu_daemon(int nochdir, int noclose); +void *qemu_memalign(size_t alignment, size_t size); +void *qemu_vmalloc(size_t size); +void qemu_vfree(void *ptr); + +#define QEMU_MADV_INVALID -1 + +#if defined(CONFIG_MADVISE) + +#define QEMU_MADV_WILLNEED MADV_WILLNEED +#define QEMU_MADV_DONTNEED MADV_DONTNEED +#ifdef MADV_DONTFORK +#define QEMU_MADV_DONTFORK MADV_DONTFORK +#else +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#endif +#ifdef MADV_MERGEABLE +#define QEMU_MADV_MERGEABLE MADV_MERGEABLE +#else +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#endif +#ifdef MADV_DONTDUMP +#define QEMU_MADV_DONTDUMP MADV_DONTDUMP +#else +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#endif +#ifdef MADV_HUGEPAGE +#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE +#else +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#endif + +#elif defined(CONFIG_POSIX_MADVISE) + +#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED +#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#else /* no-op */ + +#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#endif + +int qemu_madvise(void *addr, size_t len, int advice); + +int qemu_open(const char *name, int flags, ...); +int qemu_close(int fd); + +#if defined(__HAIKU__) && defined(__i386__) +#define FMT_pid "%ld" +#elif defined(WIN64) +#define FMT_pid "%" PRId64 +#else +#define FMT_pid "%d" +#endif + +int qemu_create_pidfile(const char *filename); +int qemu_get_thread_id(void); + +#ifdef _WIN32 +static inline void qemu_timersub(const struct timeval *val1, + const struct timeval *val2, + struct timeval *res) +{ + res->tv_sec = val1->tv_sec - val2->tv_sec; + if (val1->tv_usec < val2->tv_usec) { + res->tv_sec--; + res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; + } else { + res->tv_usec = val1->tv_usec - val2->tv_usec; + } +} +#else +#define qemu_timersub timersub +#endif + +void qemu_set_cloexec(int fd); + +void qemu_set_version(const char *); +const char *qemu_get_version(void); + +void fips_set_state(bool requested); +bool fips_get_state(void); + +#endif diff --git a/include/qemu/queue.h b/include/qemu/queue.h new file mode 100644 index 0000000000..d433b9017c --- /dev/null +++ b/include/qemu/queue.h @@ -0,0 +1,414 @@ +/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ + +/* + * QEMU version: Copy from netbsd, removed debug code, removed some of + * the implementations. Left in singly-linked lists, lists, simple + * queues, and tail queues. + */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef QEMU_SYS_QUEUE_H_ +#define QEMU_SYS_QUEUE_H_ + +/* + * This file defines four types of data structures: singly-linked lists, + * lists, simple queues, and tail queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +#include "qemu/atomic.h" /* for smp_wmb() */ + +/* + * List definitions. + */ +#define QLIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define QLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QLIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#define QLIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ + (elm)->field.le_prev = &(head)->lh_first; \ + (elm)->field.le_next = (head)->lh_first; \ + smp_wmb(); /* fill elm before linking it */ \ + if ((head)->lh_first != NULL) { \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ + } \ + (head)->lh_first = (elm); \ + smp_wmb(); \ +} while (/* CONSTCOND*/0) + +#define QLIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->lh_first); \ + (var) && ((next_var) = ((var)->field.le_next), 1); \ + (var) = (next_var)) + +/* + * List access methods. + */ +#define QLIST_EMPTY(head) ((head)->lh_first == NULL) +#define QLIST_FIRST(head) ((head)->lh_first) +#define QLIST_NEXT(elm, field) ((elm)->field.le_next) + + +/* + * Singly-linked List definitions. + */ +#define QSLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define QSLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QSLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define QSLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = QSLIST_FIRST((head)); \ + (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List access methods. + */ +#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) +#define QSLIST_FIRST(head) ((head)->slh_first) +#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) + + +/* + * Simple queue definitions. + */ +#define QSIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define QSIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define QSIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define QSIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + QSIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) && ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +#define QSIMPLEQ_CONCAT(head1, head2) do { \ + if (!QSIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + QSIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_LAST(head, type, field) \ + (QSIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Simple queue access methods. + */ +#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) +#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define Q_TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) + +#define QTAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define Q_TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#define QTAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ + (var) = (next_var)) + +#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +/* + * Tail queue access methods. + */ +#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define QTAILQ_FIRST(head) ((head)->tqh_first) +#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define QTAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define QTAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/include/qemu/range.h b/include/qemu/range.h new file mode 100644 index 0000000000..350237212b --- /dev/null +++ b/include/qemu/range.h @@ -0,0 +1,29 @@ +#ifndef QEMU_RANGE_H +#define QEMU_RANGE_H + +/* Get last byte of a range from offset + length. + * Undefined for ranges that wrap around 0. */ +static inline uint64_t range_get_last(uint64_t offset, uint64_t len) +{ + return offset + len - 1; +} + +/* Check whether a given range covers a given byte. */ +static inline int range_covers_byte(uint64_t offset, uint64_t len, + uint64_t byte) +{ + return offset <= byte && byte <= range_get_last(offset, len); +} + +/* Check whether 2 given ranges overlap. + * Undefined if ranges that wrap around 0. */ +static inline int ranges_overlap(uint64_t first1, uint64_t len1, + uint64_t first2, uint64_t len2) +{ + uint64_t last1 = range_get_last(first1, len1); + uint64_t last2 = range_get_last(first2, len2); + + return !(last2 < first1 || last1 < first2); +} + +#endif diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h new file mode 100644 index 0000000000..803ae1798c --- /dev/null +++ b/include/qemu/sockets.h @@ -0,0 +1,77 @@ +/* headers to use the BSD sockets */ +#ifndef QEMU_SOCKET_H +#define QEMU_SOCKET_H + +#ifdef _WIN32 +#include +#include +#include + +#define socket_error() WSAGetLastError() + +int inet_aton(const char *cp, struct in_addr *ia); + +#else + +#include +#include +#include +#include +#include +#include +#include + +#define socket_error() errno +#define closesocket(s) close(s) + +#endif /* !_WIN32 */ + +#include "qemu/option.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" + +/* misc helpers */ +int qemu_socket(int domain, int type, int protocol); +int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int socket_set_cork(int fd, int v); +void socket_set_block(int fd); +void socket_set_nonblock(int fd); +int send_all(int fd, const void *buf, int len1); + +/* callback function for nonblocking connect + * valid fd on success, negative error code on failure + */ +typedef void NonBlockingConnectHandler(int fd, void *opaque); + +int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); +int inet_listen(const char *str, char *ostr, int olen, + int socktype, int port_offset, Error **errp); +int inet_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int inet_connect(const char *str, Error **errp); +int inet_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +int inet_dgram_opts(QemuOpts *opts, Error **errp); +const char *inet_strfamily(int family); + +int unix_listen_opts(QemuOpts *opts, Error **errp); +int unix_listen(const char *path, char *ostr, int olen, Error **errp); +int unix_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int unix_connect(const char *path, Error **errp); +int unix_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +SocketAddress *socket_parse(const char *str, Error **errp); +int socket_connect(SocketAddress *addr, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int socket_listen(SocketAddress *addr, Error **errp); + +/* Old, ipv4 only bits. Don't use for new code. */ +int parse_host_port(struct sockaddr_in *saddr, const char *str); +int socket_init(void); + +#endif /* QEMU_SOCKET_H */ diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h new file mode 100644 index 0000000000..380bae209b --- /dev/null +++ b/include/qemu/thread-posix.h @@ -0,0 +1,28 @@ +#ifndef __QEMU_THREAD_POSIX_H +#define __QEMU_THREAD_POSIX_H 1 +#include "pthread.h" +#include + +struct QemuMutex { + pthread_mutex_t lock; +}; + +struct QemuCond { + pthread_cond_t cond; +}; + +struct QemuSemaphore { +#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) + pthread_mutex_t lock; + pthread_cond_t cond; + int count; +#else + sem_t sem; +#endif +}; + +struct QemuThread { + pthread_t thread; +}; + +#endif diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h new file mode 100644 index 0000000000..13adb958f0 --- /dev/null +++ b/include/qemu/thread-win32.h @@ -0,0 +1,29 @@ +#ifndef __QEMU_THREAD_WIN32_H +#define __QEMU_THREAD_WIN32_H 1 +#include "windows.h" + +struct QemuMutex { + CRITICAL_SECTION lock; + LONG owner; +}; + +struct QemuCond { + LONG waiters, target; + HANDLE sema; + HANDLE continue_event; +}; + +struct QemuSemaphore { + HANDLE sema; +}; + +typedef struct QemuThreadData QemuThreadData; +struct QemuThread { + QemuThreadData *data; + unsigned tid; +}; + +/* Only valid for joinable threads. */ +HANDLE qemu_thread_get_handle(QemuThread *thread); + +#endif diff --git a/include/qemu/thread.h b/include/qemu/thread.h new file mode 100644 index 0000000000..c02404b9fb --- /dev/null +++ b/include/qemu/thread.h @@ -0,0 +1,56 @@ +#ifndef __QEMU_THREAD_H +#define __QEMU_THREAD_H 1 + +#include +#include + +typedef struct QemuMutex QemuMutex; +typedef struct QemuCond QemuCond; +typedef struct QemuSemaphore QemuSemaphore; +typedef struct QemuThread QemuThread; + +#ifdef _WIN32 +#include "qemu/thread-win32.h" +#else +#include "qemu/thread-posix.h" +#endif + +#define QEMU_THREAD_JOINABLE 0 +#define QEMU_THREAD_DETACHED 1 + +void qemu_mutex_init(QemuMutex *mutex); +void qemu_mutex_destroy(QemuMutex *mutex); +void qemu_mutex_lock(QemuMutex *mutex); +int qemu_mutex_trylock(QemuMutex *mutex); +void qemu_mutex_unlock(QemuMutex *mutex); + +#define rcu_read_lock() do { } while (0) +#define rcu_read_unlock() do { } while (0) + +void qemu_cond_init(QemuCond *cond); +void qemu_cond_destroy(QemuCond *cond); + +/* + * IMPORTANT: The implementation does not guarantee that pthread_cond_signal + * and pthread_cond_broadcast can be called except while the same mutex is + * held as in the corresponding pthread_cond_wait calls! + */ +void qemu_cond_signal(QemuCond *cond); +void qemu_cond_broadcast(QemuCond *cond); +void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); + +void qemu_sem_init(QemuSemaphore *sem, int init); +void qemu_sem_post(QemuSemaphore *sem); +void qemu_sem_wait(QemuSemaphore *sem); +int qemu_sem_timedwait(QemuSemaphore *sem, int ms); +void qemu_sem_destroy(QemuSemaphore *sem); + +void qemu_thread_create(QemuThread *thread, + void *(*start_routine)(void *), + void *arg, int mode); +void *qemu_thread_join(QemuThread *thread); +void qemu_thread_get_self(QemuThread *thread); +bool qemu_thread_is_self(QemuThread *thread); +void qemu_thread_exit(void *retval); + +#endif diff --git a/include/qemu/timer.h b/include/qemu/timer.h new file mode 100644 index 0000000000..1766b2d6c7 --- /dev/null +++ b/include/qemu/timer.h @@ -0,0 +1,310 @@ +#ifndef QEMU_TIMER_H +#define QEMU_TIMER_H + +#include "qemu-common.h" +#include "qemu/main-loop.h" +#include "qemu/notify.h" + +#ifdef __FreeBSD__ +#include +#endif + +/* timers */ + +#define SCALE_MS 1000000 +#define SCALE_US 1000 +#define SCALE_NS 1 + +typedef struct QEMUClock QEMUClock; +typedef void QEMUTimerCB(void *opaque); + +/* The real time clock should be used only for stuff which does not + change the virtual machine state, as it is run even if the virtual + machine is stopped. The real time clock has a frequency of 1000 + Hz. */ +extern QEMUClock *rt_clock; + +/* The virtual clock is only run during the emulation. It is stopped + when the virtual machine is stopped. Virtual timers use a high + precision clock, usually cpu cycles (use ticks_per_sec). */ +extern QEMUClock *vm_clock; + +/* The host clock should be use for device models that emulate accurate + real time sources. It will continue to run when the virtual machine + is suspended, and it will reflect system time changes the host may + undergo (e.g. due to NTP). The host clock has the same precision as + the virtual clock. */ +extern QEMUClock *host_clock; + +int64_t qemu_get_clock_ns(QEMUClock *clock); +int64_t qemu_clock_has_timers(QEMUClock *clock); +int64_t qemu_clock_expired(QEMUClock *clock); +int64_t qemu_clock_deadline(QEMUClock *clock); +void qemu_clock_enable(QEMUClock *clock, bool enabled); +void qemu_clock_warp(QEMUClock *clock); + +void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); +void qemu_unregister_clock_reset_notifier(QEMUClock *clock, + Notifier *notifier); + +QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, + QEMUTimerCB *cb, void *opaque); +void qemu_free_timer(QEMUTimer *ts); +void qemu_del_timer(QEMUTimer *ts); +void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); +void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); +bool qemu_timer_pending(QEMUTimer *ts); +bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); +uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); + +void qemu_run_timers(QEMUClock *clock); +void qemu_run_all_timers(void); +void configure_alarms(char const *opt); +void init_clocks(void); +int init_timer_alarm(void); + +int64_t cpu_get_ticks(void); +void cpu_enable_ticks(void); +void cpu_disable_ticks(void); + +static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_NS, cb, opaque); +} + +static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_MS, cb, opaque); +} + +static inline int64_t qemu_get_clock_ms(QEMUClock *clock) +{ + return qemu_get_clock_ns(clock) / SCALE_MS; +} + +static inline int64_t get_ticks_per_sec(void) +{ + return 1000000000LL; +} + +/* real time host monotonic timer */ +static inline int64_t get_clock_realtime(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); +} + +/* Warning: don't insert tracepoints into these functions, they are + also used by simpletrace backend and tracepoints would cause + an infinite recursion! */ +#ifdef _WIN32 +extern int64_t clock_freq; + +static inline int64_t get_clock(void) +{ + LARGE_INTEGER ti; + QueryPerformanceCounter(&ti); + return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); +} + +#else + +extern int use_rt_clock; + +static inline int64_t get_clock(void) +{ +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ + || defined(__DragonFly__) || defined(__FreeBSD_kernel__) + if (use_rt_clock) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1000000000LL + ts.tv_nsec; + } else +#endif + { + /* XXX: using gettimeofday leads to problems if the date + changes, so it should be avoided. */ + return get_clock_realtime(); + } +} +#endif + +void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); +void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); + +/* icount */ +int64_t cpu_get_icount(void); +int64_t cpu_get_clock(void); + +/*******************************************/ +/* host CPU ticks (if available) */ + +#if defined(_ARCH_PPC) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t retval; +#ifdef _ARCH_PPC64 + /* This reads timebase in one 64bit go and includes Cell workaround from: + http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html + */ + __asm__ __volatile__ ("mftb %0\n\t" + "cmpwi %0,0\n\t" + "beq- $-8" + : "=r" (retval)); +#else + /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ + unsigned long junk; + __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ + "mfspr %L0,268\n\t" /* mftb */ + "mfspr %0,269\n\t" /* mftbu */ + "cmpw %0,%1\n\t" + "bne $-16" + : "=r" (retval), "=r" (junk)); +#endif + return retval; +} + +#elif defined(__i386__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("rdtsc" : "=A" (val)); + return val; +} + +#elif defined(__x86_64__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint32_t low,high; + int64_t val; + asm volatile("rdtsc" : "=a" (low), "=d" (high)); + val = high; + val <<= 32; + val |= low; + return val; +} + +#elif defined(__hppa__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int val; + asm volatile ("mfctl %%cr16, %0" : "=r"(val)); + return val; +} + +#elif defined(__ia64) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); + return val; +} + +#elif defined(__s390__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); + return val; +} + +#elif defined(__sparc__) + +static inline int64_t cpu_get_real_ticks (void) +{ +#if defined(_LP64) + uint64_t rval; + asm volatile("rd %%tick,%0" : "=r"(rval)); + return rval; +#else + /* We need an %o or %g register for this. For recent enough gcc + there is an "h" constraint for that. Don't bother with that. */ + union { + uint64_t i64; + struct { + uint32_t high; + uint32_t low; + } i32; + } rval; + asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" + : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); + return rval.i64; +#endif +} + +#elif defined(__mips__) && \ + ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) +/* + * binutils wants to use rdhwr only on mips32r2 + * but as linux kernel emulate it, it's fine + * to use it. + * + */ +#define MIPS_RDHWR(rd, value) { \ + __asm__ __volatile__ (".set push\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %0, "rd"\n\t" \ + ".set pop" \ + : "=r" (value)); \ + } + +static inline int64_t cpu_get_real_ticks(void) +{ + /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ + uint32_t count; + static uint32_t cyc_per_count = 0; + + if (!cyc_per_count) { + MIPS_RDHWR("$3", cyc_per_count); + } + + MIPS_RDHWR("$2", count); + return (int64_t)(count * cyc_per_count); +} + +#elif defined(__alpha__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint64_t cc; + uint32_t cur, ofs; + + asm volatile("rpcc %0" : "=r"(cc)); + cur = cc; + ofs = cc >> 32; + return cur - ofs; +} + +#else +/* The host CPU doesn't have an easily accessible cycle counter. + Just return a monotonically increasing value. This will be + totally wrong, but hopefully better than nothing. */ +static inline int64_t cpu_get_real_ticks (void) +{ + static int64_t ticks = 0; + return ticks++; +} +#endif + +#ifdef CONFIG_PROFILER +static inline int64_t profile_getclock(void) +{ + return cpu_get_real_ticks(); +} + +extern int64_t qemu_time, qemu_time_start; +extern int64_t tlb_flush_time; +extern int64_t dev_time; +#endif + +#endif diff --git a/include/qemu/tls.h b/include/qemu/tls.h new file mode 100644 index 0000000000..b92ea9d7da --- /dev/null +++ b/include/qemu/tls.h @@ -0,0 +1,52 @@ +/* + * Abstraction layer for defining and using TLS variables + * + * Copyright (c) 2011 Red Hat, Inc + * Copyright (c) 2011 Linaro Limited + * + * Authors: + * Paolo Bonzini + * Peter Maydell + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef QEMU_TLS_H +#define QEMU_TLS_H + +/* Per-thread variables. Note that we only have implementations + * which are really thread-local on Linux; the dummy implementations + * define plain global variables. + * + * This means that for the moment use should be restricted to + * per-VCPU variables, which are OK because: + * - the only -user mode supporting multiple VCPU threads is linux-user + * - TCG system mode is single-threaded regarding VCPUs + * - KVM system mode is multi-threaded but limited to Linux + * + * TODO: proper implementations via Win32 .tls sections and + * POSIX pthread_getspecific. + */ +#ifdef __linux__ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#else +/* Dummy implementations which define plain global variables */ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#endif + +#endif diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h new file mode 100644 index 0000000000..fd532a268d --- /dev/null +++ b/include/qemu/typedefs.h @@ -0,0 +1,61 @@ +#ifndef QEMU_TYPEDEFS_H +#define QEMU_TYPEDEFS_H + +/* A load of opaque types so that device init declarations don't have to + pull in all the real definitions. */ +typedef struct QEMUTimer QEMUTimer; +typedef struct QEMUFile QEMUFile; +typedef struct QEMUBH QEMUBH; + +struct Monitor; +typedef struct Monitor Monitor; +typedef struct MigrationParams MigrationParams; + +typedef struct Property Property; +typedef struct PropertyInfo PropertyInfo; +typedef struct CompatProperty CompatProperty; +typedef struct DeviceState DeviceState; +typedef struct BusState BusState; +typedef struct BusClass BusClass; + +typedef struct NICInfo NICInfo; +typedef struct HCIInfo HCIInfo; +typedef struct AudioState AudioState; +typedef struct BlockDriverState BlockDriverState; +typedef struct DriveInfo DriveInfo; +typedef struct DisplayState DisplayState; +typedef struct DisplayChangeListener DisplayChangeListener; +typedef struct DisplaySurface DisplaySurface; +typedef struct PixelFormat PixelFormat; +typedef struct QemuConsole QemuConsole; +typedef struct CharDriverState CharDriverState; +typedef struct MACAddr MACAddr; +typedef struct NetClientState NetClientState; +typedef struct i2c_bus i2c_bus; +typedef struct ISABus ISABus; +typedef struct ISADevice ISADevice; +typedef struct SMBusDevice SMBusDevice; +typedef struct PCIHostState PCIHostState; +typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIBus PCIBus; +typedef struct PCIDevice PCIDevice; +typedef struct PCIExpressDevice PCIExpressDevice; +typedef struct PCIBridge PCIBridge; +typedef struct PCIEAERMsg PCIEAERMsg; +typedef struct PCIEAERLog PCIEAERLog; +typedef struct PCIEAERErr PCIEAERErr; +typedef struct PCIEPort PCIEPort; +typedef struct PCIESlot PCIESlot; +typedef struct MSIMessage MSIMessage; +typedef struct SerialState SerialState; +typedef struct PCMCIACardState PCMCIACardState; +typedef struct MouseTransformInfo MouseTransformInfo; +typedef struct uWireSlave uWireSlave; +typedef struct I2SCodec I2SCodec; +typedef struct SSIBus SSIBus; +typedef struct EventNotifier EventNotifier; +typedef struct VirtIODevice VirtIODevice; +typedef struct QEMUSGList QEMUSGList; +typedef struct SHPCDevice SHPCDevice; + +#endif /* QEMU_TYPEDEFS_H */ diff --git a/include/qemu/uri.h b/include/qemu/uri.h new file mode 100644 index 0000000000..de99b3bd4b --- /dev/null +++ b/include/qemu/uri.h @@ -0,0 +1,113 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Daniel Veillard shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from him. + * + * Author: Daniel Veillard + ** + * Copyright (C) 2007 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Richard W.M. Jones + * + * Utility functions to help parse and assemble query strings. + */ + +#ifndef QEMU_URI_H +#define QEMU_URI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * URI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + */ +typedef struct URI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query; /* the query string (as it appears in the URI) */ +} URI; + +URI *uri_new(void); +char *uri_resolve(const char *URI, const char *base); +char *uri_resolve_relative(const char *URI, const char *base); +URI *uri_parse(const char *str); +URI *uri_parse_raw(const char *str, int raw); +int uri_parse_into(URI *uri, const char *str); +char *uri_to_string(URI *uri); +char *uri_string_escape(const char *str, const char *list); +char *uri_string_unescape(const char *str, int len, char *target); +void uri_free(URI *uri); + +/* Single web service query parameter 'name=value'. */ +typedef struct QueryParam { + char *name; /* Name (unescaped). */ + char *value; /* Value (unescaped). */ + int ignore; /* Ignore this field in qparam_get_query */ +} QueryParam; + +/* Set of parameters. */ +typedef struct QueryParams { + int n; /* number of parameters used */ + int alloc; /* allocated space */ + QueryParam *p; /* array of parameters */ +} QueryParams; + +struct QueryParams *query_params_new (int init_alloc); +int query_param_append (QueryParams *ps, const char *name, const char *value); +extern char *query_param_to_string (const QueryParams *ps); +extern QueryParams *query_params_parse (const char *query); +extern void query_params_free (QueryParams *ps); + +#ifdef __cplusplus +} +#endif +#endif /* QEMU_URI_H */ diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h new file mode 100644 index 0000000000..f910d96eaf --- /dev/null +++ b/include/qemu/xattr.h @@ -0,0 +1,30 @@ +/* + * Host xattr.h abstraction + * + * Copyright 2011 Red Hat Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_XATTR_H +#define QEMU_XATTR_H + +/* + * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h + * in /usr/include/sys, and don't have ENOATTR. + */ + +#include "config-host.h" + +#ifdef CONFIG_LIBATTR +# include +#else +# define ENOATTR ENODATA +# include +#endif + +#endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9682dd59ed..9e9d044bdf 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -21,7 +21,7 @@ #define QEMU_CPU_H #include "qom/object.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /** * SECTION:cpu diff --git a/include/qom/object.h b/include/qom/object.h index ed1f47f050..abe9691cb7 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -17,7 +17,7 @@ #include #include #include -#include "qemu-queue.h" +#include "qemu/queue.h" struct Visitor; struct Error; diff --git a/include/ui/console.h b/include/ui/console.h index 3db6635b0a..fc23baa06b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -3,7 +3,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" -#include "notify.h" +#include "qemu/notify.h" #include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 3e08be06bf..73422adeee 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -22,8 +22,8 @@ #include -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "monitor/monitor.h" extern int using_spice; diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 928e0a1bae..a0d1a50487 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -19,7 +19,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-pixman.h" #include "sysemu.h" diff --git a/int128.h b/int128.h deleted file mode 100644 index b3864b6cd4..0000000000 --- a/int128.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef INT128_H -#define INT128_H - -typedef struct Int128 Int128; - -struct Int128 { - uint64_t lo; - int64_t hi; -}; - -static inline Int128 int128_make64(uint64_t a) -{ - return (Int128) { a, 0 }; -} - -static inline uint64_t int128_get64(Int128 a) -{ - assert(!a.hi); - return a.lo; -} - -static inline Int128 int128_zero(void) -{ - return int128_make64(0); -} - -static inline Int128 int128_one(void) -{ - return int128_make64(1); -} - -static inline Int128 int128_2_64(void) -{ - return (Int128) { 0, 1 }; -} - -static inline Int128 int128_add(Int128 a, Int128 b) -{ - Int128 r = { a.lo + b.lo, a.hi + b.hi }; - r.hi += (r.lo < a.lo) || (r.lo < b.lo); - return r; -} - -static inline Int128 int128_neg(Int128 a) -{ - a.lo = ~a.lo; - a.hi = ~a.hi; - return int128_add(a, int128_one()); -} - -static inline Int128 int128_sub(Int128 a, Int128 b) -{ - return int128_add(a, int128_neg(b)); -} - -static inline bool int128_nonneg(Int128 a) -{ - return a.hi >= 0; -} - -static inline bool int128_eq(Int128 a, Int128 b) -{ - return a.lo == b.lo && a.hi == b.hi; -} - -static inline bool int128_ne(Int128 a, Int128 b) -{ - return !int128_eq(a, b); -} - -static inline bool int128_ge(Int128 a, Int128 b) -{ - return int128_nonneg(int128_sub(a, b)); -} - -static inline bool int128_lt(Int128 a, Int128 b) -{ - return !int128_ge(a, b); -} - -static inline bool int128_le(Int128 a, Int128 b) -{ - return int128_ge(b, a); -} - -static inline bool int128_gt(Int128 a, Int128 b) -{ - return !int128_le(a, b); -} - -static inline bool int128_nz(Int128 a) -{ - return a.lo || a.hi; -} - -static inline Int128 int128_min(Int128 a, Int128 b) -{ - return int128_le(a, b) ? a : b; -} - -static inline Int128 int128_max(Int128 a, Int128 b) -{ - return int128_ge(a, b) ? a : b; -} - -static inline void int128_addto(Int128 *a, Int128 b) -{ - *a = int128_add(*a, b); -} - -static inline void int128_subfrom(Int128 *a, Int128 b) -{ - *a = int128_sub(*a, b); -} - -#endif diff --git a/iohandler.c b/iohandler.c index cf8276dffc..2523adc11d 100644 --- a/iohandler.c +++ b/iohandler.c @@ -24,9 +24,9 @@ #include "config-host.h" #include "qemu-common.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 #include diff --git a/iov.c b/iov.c index a81eedcedb..419e419969 100644 --- a/iov.c +++ b/iov.c @@ -16,7 +16,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #ifdef _WIN32 # include diff --git a/iov.h b/iov.h deleted file mode 100644 index d06f8b9ce3..0000000000 --- a/iov.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Helpers for using (partial) iovecs. - * - * Copyright (C) 2010 Red Hat, Inc. - * - * Author(s): - * Amit Shah - * Michael Tokarev - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#ifndef IOV_H -#define IOV_H - -#include "qemu-common.h" - -/** - * count and return data size, in bytes, of an iovec - * starting at `iov' of `iov_cnt' number of elements. - */ -size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); - -/** - * Copy from single continuous buffer to scatter-gather vector of buffers - * (iovec) and back like memcpy() between two continuous memory regions. - * Data in single continuous buffer starting at address `buf' and - * `bytes' bytes long will be copied to/from an iovec `iov' with - * `iov_cnt' number of elements, starting at byte position `offset' - * within the iovec. If the iovec does not contain enough space, - * only part of data will be copied, up to the end of the iovec. - * Number of bytes actually copied will be returned, which is - * min(bytes, iov_size(iov)-offset) - * `Offset' must point to the inside of iovec. - * It is okay to use very large value for `bytes' since we're - * limited by the size of the iovec anyway, provided that the - * buffer pointed to by buf has enough space. One possible - * such "large" value is -1 (sinice size_t is unsigned), - * so specifying `-1' as `bytes' means 'up to the end of iovec'. - */ -size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, - size_t offset, const void *buf, size_t bytes); -size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, void *buf, size_t bytes); - -/** - * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, - * starting at byte offset `start', to value `fillc', repeating it - * `bytes' number of times. `Offset' must point to the inside of iovec. - * If `bytes' is large enough, only last bytes portion of iovec, - * up to the end of it, will be filled with the specified value. - * Function return actual number of bytes processed, which is - * min(size, iov_size(iov) - offset). - * Again, it is okay to use large value for `bytes' to mean "up to the end". - */ -size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, int fillc, size_t bytes); - -/* - * Send/recv data from/to iovec buffers directly - * - * `offset' bytes in the beginning of iovec buffer are skipped and - * next `bytes' bytes are used, which must be within data of iovec. - * - * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); - * - * is logically equivalent to - * - * char *buf = malloc(bytes); - * iov_to_buf(iov, iovcnt, offset, buf, bytes); - * r = send(sockfd, buf, bytes, 0); - * free(buf); - * - * For iov_send_recv() _whole_ area being sent or received - * should be within the iovec, not only beginning of it. - */ -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, - size_t offset, size_t bytes, bool do_send); -#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) -#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) - -/** - * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements - * in file `fp', prefixing each line with `prefix' and processing not more - * than `limit' data bytes. - */ -void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, - FILE *fp, const char *prefix, size_t limit); - -/* - * Partial copy of vector from iov to dst_iov (data is not copied). - * dst_iov overlaps iov at a specified offset. - * size of dst_iov is at most bytes. dst vector count is returned. - */ -unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, - const struct iovec *iov, unsigned int iov_cnt, - size_t offset, size_t bytes); - -#endif diff --git a/kvm-all.c b/kvm-all.c index c2588594e1..41ea3aa6ee 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -21,18 +21,18 @@ #include #include "qemu-common.h" -#include "qemu-barrier.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/atomic.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" #include "exec/gdbstub.h" #include "kvm.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/address-spaces.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD diff --git a/kvm.h b/kvm.h index 72d866a966..131d2bdc15 100644 --- a/kvm.h +++ b/kvm.h @@ -16,7 +16,7 @@ #include #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #ifdef CONFIG_KVM #include diff --git a/libcacard/event.c b/libcacard/event.c index 61923761c9..2d7500fac0 100644 --- a/libcacard/event.c +++ b/libcacard/event.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vreader.h" diff --git a/libcacard/vreader.c b/libcacard/vreader.c index 96d2407e78..313349b656 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vcard_emul.h" diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c index b64c93dd69..2fce52bed5 100644 --- a/libcacard/vscclient.c +++ b/libcacard/vscclient.c @@ -13,8 +13,8 @@ #include #include "qemu-common.h" -#include "qemu-thread.h" -#include "qemu_socket.h" +#include "qemu/thread.h" +#include "qemu/sockets.h" #include "vscard_common.h" diff --git a/libfdt_env.h b/libfdt_env.h index 90d7f3b162..7938d73fae 100644 --- a/libfdt_env.h +++ b/libfdt_env.h @@ -19,7 +19,7 @@ #ifndef _LIBFDT_ENV_H #define _LIBFDT_ENV_H -#include "bswap.h" +#include "qemu/bswap.h" #ifdef HOST_WORDS_BIGENDIAN #define fdt32_to_cpu(x) (x) diff --git a/linux-user/main.c b/linux-user/main.c index 25e35cd3dc..f6c4c8d7a3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,11 +28,11 @@ #include "qemu.h" #include "qemu-common.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #include "elf.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 2af883bf74..8a3538c631 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -18,7 +18,7 @@ #include "syscall.h" #include "target_signal.h" #include "exec/gdbstub.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread @@ -217,7 +217,7 @@ unsigned long init_guest_space(unsigned long host_start, unsigned long guest_start, bool fixed); -#include "qemu-log.h" +#include "qemu/log.h" /* syscall.c */ int host_to_target_waitstatus(int status); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 31d5276465..7c304e92de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -72,7 +72,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #endif #ifdef CONFIG_ATTR -#include "qemu-xattr.h" +#include "qemu/xattr.h" #endif #define termios host_termios diff --git a/main-loop.c b/main-loop.c index f9006118ad..54f38ae1ae 100644 --- a/main-loop.c +++ b/main-loop.c @@ -23,14 +23,14 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "slirp/slirp.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/aio.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" /* If we have signalfd, we mask out the signals we want to handle and then * use signalfd to listen for them. We rely on whatever the current signal diff --git a/main-loop.h b/main-loop.h deleted file mode 100644 index e8059c3d0a..0000000000 --- a/main-loop.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_MAIN_LOOP_H -#define QEMU_MAIN_LOOP_H 1 - -#include "block/aio.h" - -#define SIG_IPI SIGUSR1 - -/** - * qemu_init_main_loop: Set up the process so that it can run the main loop. - * - * This includes setting up signal handlers. It should be called before - * any other threads are created. In addition, threads other than the - * main one should block signals that are trapped by the main loop. - * For simplicity, you can consider these signals to be safe: SIGUSR1, - * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time - * signals if available. Remember that Windows in practice does not have - * signals, though. - * - * In the case of QEMU tools, this will also start/initialize timers. - */ -int qemu_init_main_loop(void); - -/** - * main_loop_wait: Run one iteration of the main loop. - * - * If @nonblocking is true, poll for events, otherwise suspend until - * one actually occurs. The main loop usually consists of a loop that - * repeatedly calls main_loop_wait(false). - * - * Main loop services include file descriptor callbacks, bottom halves - * and timers (defined in qemu-timer.h). Bottom halves are similar to timers - * that execute immediately, but have a lower overhead and scheduling them - * is wait-free, thread-safe and signal-safe. - * - * It is sometimes useful to put a whole program in a coroutine. In this - * case, the coroutine actually should be started from within the main loop, - * so that the main loop can run whenever the coroutine yields. To do this, - * you can use a bottom half to enter the coroutine as soon as the main loop - * starts: - * - * void enter_co_bh(void *opaque) { - * QEMUCoroutine *co = opaque; - * qemu_coroutine_enter(co, NULL); - * } - * - * ... - * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); - * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); - * qemu_bh_schedule(start_bh); - * while (...) { - * main_loop_wait(false); - * } - * - * (In the future we may provide a wrapper for this). - * - * @nonblocking: Whether the caller should block until an event occurs. - */ -int main_loop_wait(int nonblocking); - -/** - * qemu_notify_event: Force processing of pending events. - * - * Similar to signaling a condition variable, qemu_notify_event forces - * main_loop_wait to look at pending events and exit. The caller of - * main_loop_wait will usually call it again very soon, so qemu_notify_event - * also has the side effect of recalculating the sets of file descriptors - * that the main loop waits for. - * - * Calling qemu_notify_event is rarely necessary, because main loop - * services (bottom halves and timers) call it themselves. One notable - * exception occurs when using qemu_set_fd_handler2 (see below). - */ -void qemu_notify_event(void); - -#ifdef _WIN32 -/* return TRUE if no sleep should be done afterwards */ -typedef int PollingFunc(void *opaque); - -/** - * qemu_add_polling_cb: Register a Windows-specific polling callback - * - * Currently, under Windows some events are polled rather than waited for. - * Polling callbacks do not ensure that @func is called timely, because - * the main loop might wait for an arbitrarily long time. If possible, - * you should instead create a separate thread that does a blocking poll - * and set a Win32 event object. The event can then be passed to - * qemu_add_wait_object. - * - * Polling callbacks really have nothing Windows specific in them, but - * as they are a hack and are currently not necessary under POSIX systems, - * they are only available when QEMU is running under Windows. - * - * @func: The function that does the polling, and returns 1 to force - * immediate completion of main_loop_wait. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_polling_cb(PollingFunc *func, void *opaque); - -/** - * qemu_del_polling_cb: Unregister a Windows-specific polling callback - * - * This function removes a callback that was registered with - * qemu_add_polling_cb. - * - * @func: The function that was passed to qemu_add_polling_cb. - * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. - */ -void qemu_del_polling_cb(PollingFunc *func, void *opaque); - -/* Wait objects handling */ -typedef void WaitObjectFunc(void *opaque); - -/** - * qemu_add_wait_object: Register a callback for a Windows handle - * - * Under Windows, the iohandler mechanism can only be used with sockets. - * QEMU must use the WaitForMultipleObjects API to wait on other handles. - * This function registers a #HANDLE with QEMU, so that it will be included - * in the main loop's calls to WaitForMultipleObjects. When the handle - * is in a signaled state, QEMU will call @func. - * - * @handle: The Windows handle to be observed. - * @func: A function to be called when @handle is in a signaled state. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); - -/** - * qemu_del_wait_object: Unregister a callback for a Windows handle - * - * This function removes a callback that was registered with - * qemu_add_wait_object. - * - * @func: The function that was passed to qemu_add_wait_object. - * @opaque: A pointer-size value that was passed to qemu_add_wait_object. - */ -void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); -#endif - -/* async I/O support */ - -typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); -typedef int IOCanReadHandler(void *opaque); - -/** - * qemu_set_fd_handler2: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * @fd_read_poll can be used to disable the @fd_read callback temporarily. - * This is useful to avoid calling qemu_set_fd_handler2 every time the - * client becomes interested in reading (or dually, stops being interested). - * A typical example is when @fd is a listening socket and you want to bound - * the number of active clients. Remember to call qemu_notify_event whenever - * the condition may change from %false to %true. - * - * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read_poll: A function that returns 1 if the @fd_read callback - * should be fired. If the function returns 0, the main loop will not - * end its iteration even if @fd becomes readable. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read_poll, - * @fd_read and @fd_write. - */ -int qemu_set_fd_handler2(int fd, - IOCanReadHandler *fd_read_poll, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -/** - * qemu_set_fd_handler: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * The callbacks that are set up by qemu_set_fd_handler are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. - */ -int qemu_set_fd_handler(int fd, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -#ifdef CONFIG_POSIX -/** - * qemu_add_child_watch: Register a child process for reaping. - * - * Under POSIX systems, a parent process must read the exit status of - * its child processes using waitpid, or the operating system will not - * free some of the resources attached to that process. - * - * This function directs the QEMU main loop to observe a child process - * and call waitpid as soon as it exits; the watch is then removed - * automatically. It is useful whenever QEMU forks a child process - * but will find out about its termination by other means such as a - * "broken pipe". - * - * @pid: The pid that QEMU should observe. - */ -int qemu_add_child_watch(pid_t pid); -#endif - -/** - * qemu_mutex_lock_iothread: Lock the main loop mutex. - * - * This function locks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be taken - * by threads other than the main loop thread when calling - * qemu_bh_new(), qemu_set_fd_handler() and basically all other - * functions documented in this file. - * - * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread - * is a no-op there. - */ -void qemu_mutex_lock_iothread(void); - -/** - * qemu_mutex_unlock_iothread: Unlock the main loop mutex. - * - * This function unlocks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be unlocked - * as soon as possible by threads other than the main loop thread, - * because it prevents the main loop from processing callbacks, - * including timers and bottom halves. - * - * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread - * is a no-op there. - */ -void qemu_mutex_unlock_iothread(void); - -/* internal interfaces */ - -void qemu_fd_register(int fd); -void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); -void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); - -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); -void qemu_bh_schedule_idle(QEMUBH *bh); - -#endif diff --git a/memory.c b/memory.c index d40193d474..d44200335b 100644 --- a/memory.c +++ b/memory.c @@ -16,7 +16,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/ioport.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "kvm.h" #include diff --git a/memory_mapping.h b/memory_mapping.h index d5ba46c7e7..1256125963 100644 --- a/memory_mapping.h +++ b/memory_mapping.h @@ -14,7 +14,7 @@ #ifndef MEMORY_MAPPING_H #define MEMORY_MAPPING_H -#include "qemu-queue.h" +#include "qemu/queue.h" /* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping { diff --git a/migration-exec.c b/migration-exec.c index 784486d2fc..68f36f41f1 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -16,7 +16,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-fd.c b/migration-fd.c index ab5abe2aa5..ea121bc0d6 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -14,12 +14,12 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" //#define DEBUG_MIGRATION_FD diff --git a/migration-tcp.c b/migration-tcp.c index a36e637ffd..3c4c315052 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-unix.c b/migration-unix.c index 9debc952da..d5f986853f 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration.c b/migration.c index 0456983bad..8c5c5670d8 100644 --- a/migration.c +++ b/migration.c @@ -19,7 +19,7 @@ #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/block.h" #include "qmp-commands.h" diff --git a/module.c b/module.c index c3a6da7a86..7acc33d076 100644 --- a/module.c +++ b/module.c @@ -14,8 +14,8 @@ */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "module.h" +#include "qemu/queue.h" +#include "qemu/module.h" typedef struct ModuleEntry { diff --git a/module.h b/module.h deleted file mode 100644 index c4ccd57166..0000000000 --- a/module.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * QEMU Module Infrastructure - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_MODULE_H -#define QEMU_MODULE_H - -/* This should not be used directly. Use block_init etc. instead. */ -#define module_init(function, type) \ -static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ - register_module_init(function, type); \ -} - -typedef enum { - MODULE_INIT_BLOCK, - MODULE_INIT_MACHINE, - MODULE_INIT_QAPI, - MODULE_INIT_QOM, - MODULE_INIT_MAX -} module_init_type; - -#define block_init(function) module_init(function, MODULE_INIT_BLOCK) -#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) -#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) -#define type_init(function) module_init(function, MODULE_INIT_QOM) - -void register_module_init(void (*fn)(void), module_init_type type); - -void module_call_init(module_init_type type); - -#endif diff --git a/monitor.c b/monitor.c index 46fdc008f4..878b2317af 100644 --- a/monitor.c +++ b/monitor.c @@ -43,10 +43,10 @@ #include "audio/audio.h" #include "disas/disas.h" #include "balloon.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/migration.h" #include "kvm.h" -#include "acl.h" +#include "qemu/acl.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qlist.h" @@ -55,7 +55,7 @@ #include "qapi/qmp/qjson.h" #include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-parser.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "cpu.h" #include "trace.h" #include "trace/control.h" @@ -66,7 +66,7 @@ #include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /* for pic/irq_info */ #if defined(TARGET_SPARC) diff --git a/nbd.c b/nbd.c index 04ff0a1d44..0698a023ad 100644 --- a/nbd.c +++ b/nbd.c @@ -36,8 +36,8 @@ #include #endif -#include "qemu_socket.h" -#include "qemu-queue.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" //#define DEBUG_NBD diff --git a/net/dump.c b/net/dump.c index e0a5d74644..4119721720 100644 --- a/net/dump.c +++ b/net/dump.c @@ -24,9 +24,9 @@ #include "clients.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/timer.h" #include "hub.h" typedef struct DumpState { diff --git a/net/hub.c b/net/hub.c index 81a73b54a7..5adfce444b 100644 --- a/net/hub.c +++ b/net/hub.c @@ -16,7 +16,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "iov.h" +#include "qemu/iov.h" /* * A hub broadcasts incoming packets to all its ports except the source port. diff --git a/net/net.c b/net/net.c index e4d85a9cfa..dbf3e1b003 100644 --- a/net/net.c +++ b/net/net.c @@ -31,11 +31,11 @@ #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-config.h" +#include "qemu/sockets.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "hw/qdev.h" -#include "iov.h" +#include "qemu/iov.h" #include "qapi-visit.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" diff --git a/net/queue.c b/net/queue.c index 542c549b1a..6eaf5b63c0 100644 --- a/net/queue.c +++ b/net/queue.c @@ -22,7 +22,7 @@ */ #include "net/queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/net.h" /* The delivery handler may only return zero if it will call diff --git a/net/slirp.c b/net/slirp.c index c37a5ef959..87bdc9d031 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -33,7 +33,7 @@ #include "clients.h" #include "hub.h" #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index bc2b951832..396dc8c0b1 100644 --- a/net/socket.c +++ b/net/socket.c @@ -27,10 +27,10 @@ #include "clients.h" #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" typedef struct NetSocketState { NetClientState nc; diff --git a/net/tap-bsd.c b/net/tap-bsd.c index a1c55ad3de..b48182f678 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -25,7 +25,7 @@ #include "tap_int.h" #include "qemu-common.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #ifdef __NetBSD__ #include diff --git a/net/tap-linux.c b/net/tap-linux.c index 3de7b3b6ce..dd4b915243 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define PATH_NET_TUN "/dev/net/tun" diff --git a/net/tap-solaris.c b/net/tap-solaris.c index f228fffb6d..3d5fee5542 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -38,7 +38,7 @@ #include #include #include -#include "qemu-error.h" +#include "qemu/error-report.h" ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { diff --git a/net/tap-win32.c b/net/tap-win32.c index e37d8ee458..1ddd6fa6e6 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -32,7 +32,7 @@ #include "clients.h" /* net_init_tap */ #include "net/net.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include #include diff --git a/net/tap.c b/net/tap.c index 9a677e9864..d34ff13398 100644 --- a/net/tap.c +++ b/net/tap.c @@ -38,7 +38,7 @@ #include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "net/tap.h" diff --git a/net/vde.c b/net/vde.c index 52d4f19fba..754a141543 100644 --- a/net/vde.c +++ b/net/vde.c @@ -28,7 +28,7 @@ #include "net/net.h" #include "clients.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct VDEState { NetClientState nc; diff --git a/notify.c b/notify.c index 12282a6745..7b7692acb2 100644 --- a/notify.c +++ b/notify.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" void notifier_list_init(NotifierList *list) { diff --git a/notify.h b/notify.h deleted file mode 100644 index 03cf26c0b6..0000000000 --- a/notify.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Notifier lists - * - * Copyright IBM, Corp. 2010 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_NOTIFY_H -#define QEMU_NOTIFY_H - -#include "qemu-queue.h" - -typedef struct Notifier Notifier; - -struct Notifier -{ - void (*notify)(Notifier *notifier, void *data); - QLIST_ENTRY(Notifier) node; -}; - -typedef struct NotifierList -{ - QLIST_HEAD(, Notifier) notifiers; -} NotifierList; - -#define NOTIFIER_LIST_INITIALIZER(head) \ - { QLIST_HEAD_INITIALIZER((head).notifiers) } - -void notifier_list_init(NotifierList *list); - -void notifier_list_add(NotifierList *list, Notifier *notifier); - -void notifier_remove(Notifier *notifier); - -void notifier_list_notify(NotifierList *list, void *data); - -#endif diff --git a/osdep.c b/osdep.c index 807e90cf97..5b51a0322e 100644 --- a/osdep.c +++ b/osdep.c @@ -47,7 +47,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/osdep.h b/osdep.h deleted file mode 100644 index 87d3b9cfa8..0000000000 --- a/osdep.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef QEMU_OSDEP_H -#define QEMU_OSDEP_H - -#include -#include -#include -#ifdef __OpenBSD__ -#include -#include -#endif - -#include - -#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 -/* [u]int_fast*_t not in */ -typedef unsigned char uint_fast8_t; -typedef unsigned int uint_fast16_t; -typedef signed int int_fast16_t; -#endif - -#ifndef glue -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) -#define stringify(s) tostring(s) -#define tostring(s) #s -#endif - -#ifndef likely -#if __GNUC__ < 3 -#define __builtin_expect(x, n) (x) -#endif - -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - offsetof(type, member));}) -#endif - -/* Convert from a base type to a parent type, with compile time checking. */ -#ifdef __GNUC__ -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ - char __attribute__((unused)) offset_must_be_zero[ \ - -offsetof(type, field)]; \ - container_of(dev, type, field);})) -#else -#define DO_UPCAST(type, field, dev) container_of(dev, type, field) -#endif - -#define typeof_field(type, field) typeof(((type *)0)->field) -#define type_check(t1,t2) ((t1*)0 - (t2*)0) - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#ifndef always_inline -#if !((__GNUC__ < 3) || defined(__APPLE__)) -#ifdef __OPTIMIZE__ -#undef inline -#define inline __attribute__ (( always_inline )) __inline__ -#endif -#endif -#else -#undef inline -#define inline always_inline -#endif - -#define qemu_printf printf - -int qemu_daemon(int nochdir, int noclose); -void *qemu_memalign(size_t alignment, size_t size); -void *qemu_vmalloc(size_t size); -void qemu_vfree(void *ptr); - -#define QEMU_MADV_INVALID -1 - -#if defined(CONFIG_MADVISE) - -#define QEMU_MADV_WILLNEED MADV_WILLNEED -#define QEMU_MADV_DONTNEED MADV_DONTNEED -#ifdef MADV_DONTFORK -#define QEMU_MADV_DONTFORK MADV_DONTFORK -#else -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#endif -#ifdef MADV_MERGEABLE -#define QEMU_MADV_MERGEABLE MADV_MERGEABLE -#else -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#endif -#ifdef MADV_DONTDUMP -#define QEMU_MADV_DONTDUMP MADV_DONTDUMP -#else -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#endif -#ifdef MADV_HUGEPAGE -#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE -#else -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#endif - -#elif defined(CONFIG_POSIX_MADVISE) - -#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED -#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#else /* no-op */ - -#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#endif - -int qemu_madvise(void *addr, size_t len, int advice); - -int qemu_open(const char *name, int flags, ...); -int qemu_close(int fd); - -#if defined(__HAIKU__) && defined(__i386__) -#define FMT_pid "%ld" -#elif defined(WIN64) -#define FMT_pid "%" PRId64 -#else -#define FMT_pid "%d" -#endif - -int qemu_create_pidfile(const char *filename); -int qemu_get_thread_id(void); - -#ifdef _WIN32 -static inline void qemu_timersub(const struct timeval *val1, - const struct timeval *val2, - struct timeval *res) -{ - res->tv_sec = val1->tv_sec - val2->tv_sec; - if (val1->tv_usec < val2->tv_usec) { - res->tv_sec--; - res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; - } else { - res->tv_usec = val1->tv_usec - val2->tv_usec; - } -} -#else -#define qemu_timersub timersub -#endif - -void qemu_set_cloexec(int fd); - -void qemu_set_version(const char *); -const char *qemu_get_version(void); - -void fips_set_state(bool requested); -bool fips_get_state(void); - -#endif diff --git a/oslib-posix.c b/oslib-posix.c index 9db9c3d8af..a737d6e0e3 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -51,7 +51,7 @@ extern int daemon(int, int); #include "config-host.h" #include "sysemu.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(CONFIG_VALGRIND) static int running_on_valgrind = -1; diff --git a/oslib-win32.c b/oslib-win32.c index 51b33e8b20..7f0dd07e5f 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -28,9 +28,9 @@ #include #include "config-host.h" #include "sysemu.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" void *qemu_oom_check(void *ptr) { diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index f8149ce455..174bd8bdb0 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -13,8 +13,8 @@ #include "qemu-common.h" #include "qapi/qmp/qerror.h" #include "qapi/opts-visitor.h" -#include "qemu-queue.h" -#include "qemu-option-internal.h" +#include "qemu/queue.h" +#include "qemu/option_int.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 98f2a58efd..1334de33cc 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -12,7 +12,7 @@ */ #include "qapi/dealloc-visitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 8087909036..67fb127050 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-input-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 8015e3f88d..74a5684ed3 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qdict.c b/qdict.c index fa7a62cff4..7543ccc10f 100644 --- a/qdict.c +++ b/qdict.c @@ -16,7 +16,7 @@ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qdict_destroy_obj(QObject *obj); diff --git a/qemu-barrier.h b/qemu-barrier.h deleted file mode 100644 index faa83d265e..0000000000 --- a/qemu-barrier.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __QEMU_BARRIER_H -#define __QEMU_BARRIER_H 1 - -/* Compiler barrier */ -#define barrier() asm volatile("" ::: "memory") - -#if defined(__i386__) - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -/* - * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops - * on x86(well, a compiler barrier only). Well, at least as long as - * qemu doesn't do accesses to write-combining memory or non-temporal - * load/stores from C code. - */ -#define smp_wmb() barrier() -#define smp_rmb() barrier() -/* - * We use GCC builtin if it's available, as that can use - * mfence on 32 bit as well, e.g. if built with -march=pentium-m. - * However, on i386, there seem to be known bugs as recently as 4.3. - * */ -#if QEMU_GNUC_PREREQ(4, 4) -#define smp_mb() __sync_synchronize() -#else -#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") -#endif - -#elif defined(__x86_64__) - -#define smp_wmb() barrier() -#define smp_rmb() barrier() -#define smp_mb() asm volatile("mfence" ::: "memory") - -#elif defined(_ARCH_PPC) - -/* - * We use an eieio() for wmb() on powerpc. This assumes we don't - * need to order cacheable and non-cacheable stores with respect to - * each other - */ -#define smp_wmb() asm volatile("eieio" ::: "memory") - -#if defined(__powerpc64__) -#define smp_rmb() asm volatile("lwsync" ::: "memory") -#else -#define smp_rmb() asm volatile("sync" ::: "memory") -#endif - -#define smp_mb() asm volatile("sync" ::: "memory") - -#else - -/* - * For (host) platforms we don't have explicit barrier definitions - * for, we use the gcc __sync_synchronize() primitive to generate a - * full barrier. This should be safe on all platforms, though it may - * be overkill for wmb() and rmb(). - */ -#define smp_wmb() __sync_synchronize() -#define smp_mb() __sync_synchronize() -#define smp_rmb() __sync_synchronize() - -#endif - -#endif diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 652eec99fd..287bfd5e38 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -39,7 +39,7 @@ #include #endif -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/tap-linux.h" diff --git a/qemu-char.c b/qemu-char.c index 16021c5a43..5a8d8f75a4 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -25,7 +25,7 @@ #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "hw/usb.h" #include "hw/baum.h" @@ -94,7 +94,7 @@ #endif #endif -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "ui/qemu-spice.h" #define READ_BUF_LEN 4096 diff --git a/qemu-char.h b/qemu-char.h index 5ff1b2ba91..baa5d035fd 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -2,13 +2,13 @@ #define QEMU_CHAR_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "block/aio.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* character device */ diff --git a/qemu-common.h b/qemu-common.h index e67478607b..40cd198fc1 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -12,9 +12,9 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "compiler.h" +#include "qemu/compiler.h" #include "config-host.h" -#include "qemu-types.h" +#include "qemu/typedefs.h" #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) #define WORDS_ALIGNED @@ -122,8 +122,8 @@ extern int use_icount; /* FIXME: Remove NEED_CPU_H. */ #ifndef NEED_CPU_H -#include "osdep.h" -#include "bswap.h" +#include "qemu/osdep.h" +#include "qemu/bswap.h" #else @@ -408,7 +408,7 @@ static inline bool is_power_of_2(uint64_t value) /* round down to the nearest power of 2*/ int64_t pow2floor(int64_t value); -#include "module.h" +#include "qemu/module.h" /* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) diff --git a/qemu-config.c b/qemu-config.c index ceec6bd155..2188c3e5ec 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -1,7 +1,7 @@ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/qdev.h" #include "qapi/error.h" diff --git a/qemu-config.h b/qemu-config.h deleted file mode 100644 index 584491a29b..0000000000 --- a/qemu-config.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QEMU_CONFIG_H -#define QEMU_CONFIG_H - -#include -#include "qemu-option.h" -#include "qapi/error.h" -#include "qemu-option.h" - -extern QemuOptsList qemu_fsdev_opts; -extern QemuOptsList qemu_virtfs_opts; -extern QemuOptsList qemu_spice_opts; -extern QemuOptsList qemu_sandbox_opts; - -QemuOptsList *qemu_find_opts(const char *group); -QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); -void qemu_add_opts(QemuOptsList *list); -int qemu_set_option(const char *str); -int qemu_global_option(const char *str); -void qemu_add_globals(void); - -void qemu_config_write(FILE *fp); -int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); - -int qemu_read_config_file(const char *filename); - -/* Read default QEMU config files - */ -int qemu_read_default_config_files(bool userconfig); - -#endif /* QEMU_CONFIG_H */ diff --git a/qemu-coroutine-io.c b/qemu-coroutine-io.c index 5fae9c7d47..e8ad1a4011 100644 --- a/qemu-coroutine-io.c +++ b/qemu-coroutine-io.c @@ -23,9 +23,9 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "block/coroutine.h" -#include "iov.h" +#include "qemu/iov.h" ssize_t coroutine_fn qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index c3939ac6ef..97ef01c796 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/coroutine.h" #include "block/coroutine_int.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" #include "trace.h" diff --git a/qemu-coroutine-sleep.c b/qemu-coroutine-sleep.c index 26e6dac2eb..169ce5ccc9 100644 --- a/qemu-coroutine-sleep.c +++ b/qemu-coroutine-sleep.c @@ -12,7 +12,7 @@ */ #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" typedef struct CoSleepCB { QEMUTimer *ts; diff --git a/qemu-error.h b/qemu-error.h deleted file mode 100644 index c902cc10de..0000000000 --- a/qemu-error.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Error reporting - * - * Copyright (C) 2010 Red Hat Inc. - * - * Authors: - * Markus Armbruster , - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_ERROR_H -#define QEMU_ERROR_H - -#include - -typedef struct Location { - /* all members are private to qemu-error.c */ - enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; - int num; - const void *ptr; - struct Location *prev; -} Location; - -Location *loc_push_restore(Location *loc); -Location *loc_push_none(Location *loc); -Location *loc_pop(Location *loc); -Location *loc_save(Location *loc); -void loc_restore(Location *loc); -void loc_set_none(void); -void loc_set_cmdline(char **argv, int idx, int cnt); -void loc_set_file(const char *fname, int lno); - -void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); -void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_print_loc(void); -void error_set_progname(const char *argv0); -void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -const char *error_get_progname(void); - -#endif diff --git a/qemu-img.c b/qemu-img.c index 2e5ca5c964..4c8e2f3849 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -25,9 +25,9 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/qmp/qjson.h" #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-error.h" -#include "osdep.h" +#include "qemu/option.h" +#include "qemu/error-report.h" +#include "qemu/osdep.h" #include "sysemu.h" #include "block/block_int.h" #include diff --git a/qemu-io.c b/qemu-io.c index e0e47423d7..61880932b3 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -15,7 +15,7 @@ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/block_int.h" #include "cmd.h" #include "trace/control.h" diff --git a/qemu-log.c b/qemu-log.c index a4c3d1f2e3..b655b305ea 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef WIN32 static const char *logfilename = "qemu.log"; diff --git a/qemu-log.h b/qemu-log.h deleted file mode 100644 index 58f69cb494..0000000000 --- a/qemu-log.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef QEMU_LOG_H -#define QEMU_LOG_H - -#include -#ifdef NEED_CPU_H -#include "disas/disas.h" -#endif - -/* Private global variables, don't use */ -extern FILE *qemu_logfile; -extern int qemu_loglevel; - -/* - * The new API: - * - */ - -/* Log settings checking macros: */ - -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -#define CPU_LOG_TB_OUT_ASM (1 << 0) -#define CPU_LOG_TB_IN_ASM (1 << 1) -#define CPU_LOG_TB_OP (1 << 2) -#define CPU_LOG_TB_OP_OPT (1 << 3) -#define CPU_LOG_INT (1 << 4) -#define CPU_LOG_EXEC (1 << 5) -#define CPU_LOG_PCALL (1 << 6) -#define CPU_LOG_IOPORT (1 << 7) -#define CPU_LOG_TB_CPU (1 << 8) -#define CPU_LOG_RESET (1 << 9) -#define LOG_UNIMP (1 << 10) -#define LOG_GUEST_ERROR (1 << 11) - -/* Returns true if a bit is set in the current loglevel mask - */ -static inline bool qemu_loglevel_mask(int mask) -{ - return (qemu_loglevel & mask) != 0; -} - -/* Logging functions: */ - -/* main logging function - */ -void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); - -/* vfprintf-like logging function - */ -static inline void GCC_FMT_ATTR(1, 0) -qemu_log_vprintf(const char *fmt, va_list va) -{ - if (qemu_logfile) { - vfprintf(qemu_logfile, fmt, va); - } -} - -/* log only if a bit is set on the current loglevel mask - */ -void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); - - -/* Special cases: */ - -#ifdef NEED_CPU_H -/* cpu_dump_state() logging functions: */ -static inline void log_cpu_state(CPUArchState *env1, int flags) -{ - if (qemu_log_enabled()) { - cpu_dump_state(env1, qemu_logfile, fprintf, flags); - } -} - -static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) -{ - if (qemu_loglevel & mask) { - log_cpu_state(env1, flags); - } -} - -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUArchState *env, target_ulong start, - target_ulong len, int flags) -{ - target_disas(qemu_logfile, env, start, len, flags); -} - -static inline void log_disas(void *code, unsigned long size) -{ - disas(qemu_logfile, code, size); -} - -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(void) -{ - page_dump(qemu_logfile); -} -#endif -#endif - - -/* Maintenance: */ - -/* fflush() the log file */ -static inline void qemu_log_flush(void) -{ - fflush(qemu_logfile); -} - -/* Close the log file */ -static inline void qemu_log_close(void) -{ - fclose(qemu_logfile); - qemu_logfile = NULL; -} - -/* Set up a new log file */ -static inline void qemu_log_set_file(FILE *f) -{ - qemu_logfile = f; -} - -/* Set up a new log file, only if none is set */ -static inline void qemu_log_try_set_file(FILE *f) -{ - if (!qemu_logfile) { - qemu_logfile = f; - } -} - -/* define log items */ -typedef struct CPULogItem { - int mask; - const char *name; - const char *help; -} CPULogItem; - -extern const CPULogItem cpu_log_items[]; - -void qemu_set_log(int log_flags, bool use_own_buffers); - -static inline void cpu_set_log(int log_flags) -{ -#ifdef CONFIG_USER_ONLY - qemu_set_log(log_flags, true); -#else - qemu_set_log(log_flags, false); -#endif -} - -void cpu_set_log_filename(const char *filename); -int cpu_str_to_log_mask(const char *str); - -#endif diff --git a/qemu-option-internal.h b/qemu-option-internal.h deleted file mode 100644 index 77899b082d..0000000000 --- a/qemu-option-internal.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_INTERNAL_H -#define QEMU_OPTIONS_INTERNAL_H - -#include "qemu-option.h" -#include "qemu-error.h" - -struct QemuOpt { - const char *name; - const char *str; - - const QemuOptDesc *desc; - union { - bool boolean; - uint64_t uint; - } value; - - QemuOpts *opts; - QTAILQ_ENTRY(QemuOpt) next; -}; - -struct QemuOpts { - char *id; - QemuOptsList *list; - Location loc; - QTAILQ_HEAD(QemuOptHead, QemuOpt) head; - QTAILQ_ENTRY(QemuOpts) next; -}; - -#endif diff --git a/qemu-option.c b/qemu-option.c index ebd3537063..f532b765a0 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -27,11 +27,11 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/types.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" -#include "qemu-option-internal.h" +#include "qemu/option_int.h" /* * Extracts the name of an option from the parameter string (p points at the diff --git a/qemu-option.h b/qemu-option.h deleted file mode 100644 index ca0dc041dd..0000000000 --- a/qemu-option.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_H -#define QEMU_OPTIONS_H - -#include -#include "qemu-queue.h" -#include "qapi/error.h" -#include "qapi/qmp/qdict.h" - -enum QEMUOptionParType { - OPT_FLAG, - OPT_NUMBER, - OPT_SIZE, - OPT_STRING, -}; - -typedef struct QEMUOptionParameter { - const char *name; - enum QEMUOptionParType type; - union { - uint64_t n; - char* s; - } value; - const char *help; -} QEMUOptionParameter; - - -const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); -const char *get_opt_value(char *buf, int buf_size, const char *p); -int get_next_param_value(char *buf, int buf_size, - const char *tag, const char **pstr); -int get_param_value(char *buf, int buf_size, - const char *tag, const char *str); -int check_params(char *buf, int buf_size, - const char * const *params, const char *str); - - -/* - * The following functions take a parameter list as input. This is a pointer to - * the first element of a QEMUOptionParameter array which is terminated by an - * entry with entry->name == NULL. - */ - -QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, - const char *name); -int set_option_parameter(QEMUOptionParameter *list, const char *name, - const char *value); -int set_option_parameter_int(QEMUOptionParameter *list, const char *name, - uint64_t value); -QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, - QEMUOptionParameter *list); -QEMUOptionParameter *parse_option_parameters(const char *param, - QEMUOptionParameter *list, QEMUOptionParameter *dest); -void free_option_parameters(QEMUOptionParameter *list); -void print_option_parameters(QEMUOptionParameter *list); -void print_option_help(QEMUOptionParameter *list); - -/* ------------------------------------------------------------------ */ - -typedef struct QemuOpt QemuOpt; -typedef struct QemuOpts QemuOpts; -typedef struct QemuOptsList QemuOptsList; - -enum QemuOptType { - QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ - QEMU_OPT_BOOL, /* on/off */ - QEMU_OPT_NUMBER, /* simple number */ - QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ -}; - -typedef struct QemuOptDesc { - const char *name; - enum QemuOptType type; - const char *help; -} QemuOptDesc; - -struct QemuOptsList { - const char *name; - const char *implied_opt_name; - bool merge_lists; /* Merge multiple uses of option into a single list? */ - QTAILQ_HEAD(, QemuOpts) head; - QemuOptDesc desc[]; -}; - -const char *qemu_opt_get(QemuOpts *opts, const char *name); -/** - * qemu_opt_has_help_opt: - * @opts: options to search for a help request - * - * Check whether the options specified by @opts include one of the - * standard strings which indicate that the user is asking for a - * list of the valid values for a command line option (as defined - * by is_help_option()). - * - * Returns: true if @opts includes 'help' or equivalent. - */ -bool qemu_opt_has_help_opt(QemuOpts *opts); -bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); -uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); -uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); -int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); -void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, - Error **errp); -int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); -int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); -typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, - int abort_on_failure); - -QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); -QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, - int fail_if_exists, Error **errp); -QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); -void qemu_opts_reset(QemuOptsList *list); -void qemu_opts_loc_restore(QemuOpts *opts); -int qemu_opts_set(QemuOptsList *list, const char *id, - const char *name, const char *value); -const char *qemu_opts_id(QemuOpts *opts); -void qemu_opts_del(QemuOpts *opts); -void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); -int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); -QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); -void qemu_opts_set_defaults(QemuOptsList *list, const char *params, - int permit_abbrev); -QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, - Error **errp); -QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); - -typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); -int qemu_opts_print(QemuOpts *opts, void *dummy); -int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, - int abort_on_failure); - -#endif diff --git a/qemu-progress.c b/qemu-progress.c index 5f1b8dfb97..08d67949a1 100644 --- a/qemu-progress.c +++ b/qemu-progress.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "sysemu.h" #include diff --git a/qemu-queue.h b/qemu-queue.h deleted file mode 100644 index 9288cd8e82..0000000000 --- a/qemu-queue.h +++ /dev/null @@ -1,414 +0,0 @@ -/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ - -/* - * QEMU version: Copy from netbsd, removed debug code, removed some of - * the implementations. Left in singly-linked lists, lists, simple - * queues, and tail queues. - */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef QEMU_SYS_QUEUE_H_ -#define QEMU_SYS_QUEUE_H_ - -/* - * This file defines four types of data structures: singly-linked lists, - * lists, simple queues, and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -#include "qemu-barrier.h" /* for smp_wmb() */ - -/* - * List definitions. - */ -#define QLIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define QLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QLIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define QLIST_INIT(head) do { \ - (head)->lh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ - (elm)->field.le_prev = &(head)->lh_first; \ - (elm)->field.le_next = (head)->lh_first; \ - smp_wmb(); /* fill elm before linking it */ \ - if ((head)->lh_first != NULL) { \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ - } \ - (head)->lh_first = (elm); \ - smp_wmb(); \ -} while (/* CONSTCOND*/0) - -#define QLIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var); \ - (var) = ((var)->field.le_next)) - -#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->lh_first); \ - (var) && ((next_var) = ((var)->field.le_next), 1); \ - (var) = (next_var)) - -/* - * List access methods. - */ -#define QLIST_EMPTY(head) ((head)->lh_first == NULL) -#define QLIST_FIRST(head) ((head)->lh_first) -#define QLIST_NEXT(elm, field) ((elm)->field.le_next) - - -/* - * Singly-linked List definitions. - */ -#define QSLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define QSLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QSLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define QSLIST_INIT(head) do { \ - (head)->slh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ - (slistelm)->field.sle_next = \ - QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) - -#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = QSLIST_FIRST((head)); \ - (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -/* - * Singly-linked List access methods. - */ -#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) -#define QSLIST_FIRST(head) ((head)->slh_first) -#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) - - -/* - * Simple queue definitions. - */ -#define QSIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define QSIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define QSIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue functions. - */ -#define QSIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - QSIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var); \ - (var) = ((var)->field.sqe_next)) - -#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) && ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) - -#define QSIMPLEQ_CONCAT(head1, head2) do { \ - if (!QSIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - QSIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_LAST(head, type, field) \ - (QSIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -/* - * Simple queue access methods. - */ -#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) -#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) -#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - - -/* - * Tail queue definitions. - */ -#define Q_TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) - -#define QTAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define Q_TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) - -/* - * Tail queue functions. - */ -#define QTAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var); \ - (var) = ((var)->field.tqe_next)) - -#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->tqh_first); \ - (var) && ((next_var) = ((var)->field.tqe_next), 1); \ - (var) = (next_var)) - -#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) - -/* - * Tail queue access methods. - */ -#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define QTAILQ_FIRST(head) ((head)->tqh_first) -#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define QTAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define QTAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/qemu-seccomp.h b/qemu-seccomp.h index b2fc3f8c3c..1189fa241d 100644 --- a/qemu-seccomp.h +++ b/qemu-seccomp.h @@ -16,7 +16,7 @@ #define QEMU_SECCOMP_H #include -#include "osdep.h" +#include "qemu/osdep.h" int seccomp_start(void); #endif diff --git a/qemu-sockets.c b/qemu-sockets.c index cea0a4b8ac..3537bf3d45 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -23,9 +23,9 @@ #include #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qemu-common.h" /* for qemu_isdigit */ -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index 4ef9c7b3f8..7be292ed68 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -20,7 +20,7 @@ #include #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" static void error_exit(int err, const char *msg) { diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h deleted file mode 100644 index 380bae209b..0000000000 --- a/qemu-thread-posix.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __QEMU_THREAD_POSIX_H -#define __QEMU_THREAD_POSIX_H 1 -#include "pthread.h" -#include - -struct QemuMutex { - pthread_mutex_t lock; -}; - -struct QemuCond { - pthread_cond_t cond; -}; - -struct QemuSemaphore { -#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) - pthread_mutex_t lock; - pthread_cond_t cond; - int count; -#else - sem_t sem; -#endif -}; - -struct QemuThread { - pthread_t thread; -}; - -#endif diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c index 4b3db60f5c..8037b39045 100644 --- a/qemu-thread-win32.c +++ b/qemu-thread-win32.c @@ -11,7 +11,7 @@ * */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include #include #include diff --git a/qemu-thread-win32.h b/qemu-thread-win32.h deleted file mode 100644 index 13adb958f0..0000000000 --- a/qemu-thread-win32.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __QEMU_THREAD_WIN32_H -#define __QEMU_THREAD_WIN32_H 1 -#include "windows.h" - -struct QemuMutex { - CRITICAL_SECTION lock; - LONG owner; -}; - -struct QemuCond { - LONG waiters, target; - HANDLE sema; - HANDLE continue_event; -}; - -struct QemuSemaphore { - HANDLE sema; -}; - -typedef struct QemuThreadData QemuThreadData; -struct QemuThread { - QemuThreadData *data; - unsigned tid; -}; - -/* Only valid for joinable threads. */ -HANDLE qemu_thread_get_handle(QemuThread *thread); - -#endif diff --git a/qemu-thread.h b/qemu-thread.h deleted file mode 100644 index 3ee2f6b1f9..0000000000 --- a/qemu-thread.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __QEMU_THREAD_H -#define __QEMU_THREAD_H 1 - -#include -#include - -typedef struct QemuMutex QemuMutex; -typedef struct QemuCond QemuCond; -typedef struct QemuSemaphore QemuSemaphore; -typedef struct QemuThread QemuThread; - -#ifdef _WIN32 -#include "qemu-thread-win32.h" -#else -#include "qemu-thread-posix.h" -#endif - -#define QEMU_THREAD_JOINABLE 0 -#define QEMU_THREAD_DETACHED 1 - -void qemu_mutex_init(QemuMutex *mutex); -void qemu_mutex_destroy(QemuMutex *mutex); -void qemu_mutex_lock(QemuMutex *mutex); -int qemu_mutex_trylock(QemuMutex *mutex); -void qemu_mutex_unlock(QemuMutex *mutex); - -#define rcu_read_lock() do { } while (0) -#define rcu_read_unlock() do { } while (0) - -void qemu_cond_init(QemuCond *cond); -void qemu_cond_destroy(QemuCond *cond); - -/* - * IMPORTANT: The implementation does not guarantee that pthread_cond_signal - * and pthread_cond_broadcast can be called except while the same mutex is - * held as in the corresponding pthread_cond_wait calls! - */ -void qemu_cond_signal(QemuCond *cond); -void qemu_cond_broadcast(QemuCond *cond); -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); - -void qemu_sem_init(QemuSemaphore *sem, int init); -void qemu_sem_post(QemuSemaphore *sem); -void qemu_sem_wait(QemuSemaphore *sem); -int qemu_sem_timedwait(QemuSemaphore *sem, int ms); -void qemu_sem_destroy(QemuSemaphore *sem); - -void qemu_thread_create(QemuThread *thread, - void *(*start_routine)(void *), - void *arg, int mode); -void *qemu_thread_join(QemuThread *thread); -void qemu_thread_get_self(QemuThread *thread); -bool qemu_thread_is_self(QemuThread *thread); -void qemu_thread_exit(void *retval); - -#endif diff --git a/qemu-timer-common.c b/qemu-timer-common.c index 755e300bc9..16f5e758b2 100644 --- a/qemu-timer-common.c +++ b/qemu-timer-common.c @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" /***********************************************************/ /* real time host monotonic timer */ diff --git a/qemu-timer.c b/qemu-timer.c index 8e0dccc087..80b3f2eb31 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -28,7 +28,7 @@ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_POSIX #include #endif @@ -477,7 +477,7 @@ static void host_alarm_handler(int host_signum) #if defined(__linux__) -#include "compatfd.h" +#include "qemu/compatfd.h" static int dynticks_start_timer(struct qemu_alarm_timer *t) { diff --git a/qemu-timer.h b/qemu-timer.h deleted file mode 100644 index da7e97cd5a..0000000000 --- a/qemu-timer.h +++ /dev/null @@ -1,310 +0,0 @@ -#ifndef QEMU_TIMER_H -#define QEMU_TIMER_H - -#include "qemu-common.h" -#include "main-loop.h" -#include "notify.h" - -#ifdef __FreeBSD__ -#include -#endif - -/* timers */ - -#define SCALE_MS 1000000 -#define SCALE_US 1000 -#define SCALE_NS 1 - -typedef struct QEMUClock QEMUClock; -typedef void QEMUTimerCB(void *opaque); - -/* The real time clock should be used only for stuff which does not - change the virtual machine state, as it is run even if the virtual - machine is stopped. The real time clock has a frequency of 1000 - Hz. */ -extern QEMUClock *rt_clock; - -/* The virtual clock is only run during the emulation. It is stopped - when the virtual machine is stopped. Virtual timers use a high - precision clock, usually cpu cycles (use ticks_per_sec). */ -extern QEMUClock *vm_clock; - -/* The host clock should be use for device models that emulate accurate - real time sources. It will continue to run when the virtual machine - is suspended, and it will reflect system time changes the host may - undergo (e.g. due to NTP). The host clock has the same precision as - the virtual clock. */ -extern QEMUClock *host_clock; - -int64_t qemu_get_clock_ns(QEMUClock *clock); -int64_t qemu_clock_has_timers(QEMUClock *clock); -int64_t qemu_clock_expired(QEMUClock *clock); -int64_t qemu_clock_deadline(QEMUClock *clock); -void qemu_clock_enable(QEMUClock *clock, bool enabled); -void qemu_clock_warp(QEMUClock *clock); - -void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); -void qemu_unregister_clock_reset_notifier(QEMUClock *clock, - Notifier *notifier); - -QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, - QEMUTimerCB *cb, void *opaque); -void qemu_free_timer(QEMUTimer *ts); -void qemu_del_timer(QEMUTimer *ts); -void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); -void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); -bool qemu_timer_pending(QEMUTimer *ts); -bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); -uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); - -void qemu_run_timers(QEMUClock *clock); -void qemu_run_all_timers(void); -void configure_alarms(char const *opt); -void init_clocks(void); -int init_timer_alarm(void); - -int64_t cpu_get_ticks(void); -void cpu_enable_ticks(void); -void cpu_disable_ticks(void); - -static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_NS, cb, opaque); -} - -static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_MS, cb, opaque); -} - -static inline int64_t qemu_get_clock_ms(QEMUClock *clock) -{ - return qemu_get_clock_ns(clock) / SCALE_MS; -} - -static inline int64_t get_ticks_per_sec(void) -{ - return 1000000000LL; -} - -/* real time host monotonic timer */ -static inline int64_t get_clock_realtime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); -} - -/* Warning: don't insert tracepoints into these functions, they are - also used by simpletrace backend and tracepoints would cause - an infinite recursion! */ -#ifdef _WIN32 -extern int64_t clock_freq; - -static inline int64_t get_clock(void) -{ - LARGE_INTEGER ti; - QueryPerformanceCounter(&ti); - return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); -} - -#else - -extern int use_rt_clock; - -static inline int64_t get_clock(void) -{ -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ - || defined(__DragonFly__) || defined(__FreeBSD_kernel__) - if (use_rt_clock) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000000000LL + ts.tv_nsec; - } else -#endif - { - /* XXX: using gettimeofday leads to problems if the date - changes, so it should be avoided. */ - return get_clock_realtime(); - } -} -#endif - -void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); -void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); - -/* icount */ -int64_t cpu_get_icount(void); -int64_t cpu_get_clock(void); - -/*******************************************/ -/* host CPU ticks (if available) */ - -#if defined(_ARCH_PPC) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t retval; -#ifdef _ARCH_PPC64 - /* This reads timebase in one 64bit go and includes Cell workaround from: - http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html - */ - __asm__ __volatile__ ("mftb %0\n\t" - "cmpwi %0,0\n\t" - "beq- $-8" - : "=r" (retval)); -#else - /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ - unsigned long junk; - __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ - "mfspr %L0,268\n\t" /* mftb */ - "mfspr %0,269\n\t" /* mftbu */ - "cmpw %0,%1\n\t" - "bne $-16" - : "=r" (retval), "=r" (junk)); -#endif - return retval; -} - -#elif defined(__i386__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("rdtsc" : "=A" (val)); - return val; -} - -#elif defined(__x86_64__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint32_t low,high; - int64_t val; - asm volatile("rdtsc" : "=a" (low), "=d" (high)); - val = high; - val <<= 32; - val |= low; - return val; -} - -#elif defined(__hppa__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int val; - asm volatile ("mfctl %%cr16, %0" : "=r"(val)); - return val; -} - -#elif defined(__ia64) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); - return val; -} - -#elif defined(__s390__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); - return val; -} - -#elif defined(__sparc__) - -static inline int64_t cpu_get_real_ticks (void) -{ -#if defined(_LP64) - uint64_t rval; - asm volatile("rd %%tick,%0" : "=r"(rval)); - return rval; -#else - /* We need an %o or %g register for this. For recent enough gcc - there is an "h" constraint for that. Don't bother with that. */ - union { - uint64_t i64; - struct { - uint32_t high; - uint32_t low; - } i32; - } rval; - asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" - : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); - return rval.i64; -#endif -} - -#elif defined(__mips__) && \ - ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) -/* - * binutils wants to use rdhwr only on mips32r2 - * but as linux kernel emulate it, it's fine - * to use it. - * - */ -#define MIPS_RDHWR(rd, value) { \ - __asm__ __volatile__ (".set push\n\t" \ - ".set mips32r2\n\t" \ - "rdhwr %0, "rd"\n\t" \ - ".set pop" \ - : "=r" (value)); \ - } - -static inline int64_t cpu_get_real_ticks(void) -{ - /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ - uint32_t count; - static uint32_t cyc_per_count = 0; - - if (!cyc_per_count) { - MIPS_RDHWR("$3", cyc_per_count); - } - - MIPS_RDHWR("$2", count); - return (int64_t)(count * cyc_per_count); -} - -#elif defined(__alpha__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint64_t cc; - uint32_t cur, ofs; - - asm volatile("rpcc %0" : "=r"(cc)); - cur = cc; - ofs = cc >> 32; - return cur - ofs; -} - -#else -/* The host CPU doesn't have an easily accessible cycle counter. - Just return a monotonically increasing value. This will be - totally wrong, but hopefully better than nothing. */ -static inline int64_t cpu_get_real_ticks (void) -{ - static int64_t ticks = 0; - return ticks++; -} -#endif - -#ifdef CONFIG_PROFILER -static inline int64_t profile_getclock(void) -{ - return cpu_get_real_ticks(); -} - -extern int64_t qemu_time, qemu_time_start; -extern int64_t tlb_flush_time; -extern int64_t dev_time; -#endif - -#endif diff --git a/qemu-tls.h b/qemu-tls.h deleted file mode 100644 index b92ea9d7da..0000000000 --- a/qemu-tls.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Abstraction layer for defining and using TLS variables - * - * Copyright (c) 2011 Red Hat, Inc - * Copyright (c) 2011 Linaro Limited - * - * Authors: - * Paolo Bonzini - * Peter Maydell - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ - -#ifndef QEMU_TLS_H -#define QEMU_TLS_H - -/* Per-thread variables. Note that we only have implementations - * which are really thread-local on Linux; the dummy implementations - * define plain global variables. - * - * This means that for the moment use should be restricted to - * per-VCPU variables, which are OK because: - * - the only -user mode supporting multiple VCPU threads is linux-user - * - TCG system mode is single-threaded regarding VCPUs - * - KVM system mode is multi-threaded but limited to Linux - * - * TODO: proper implementations via Win32 .tls sections and - * POSIX pthread_getspecific. - */ -#ifdef __linux__ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#else -/* Dummy implementations which define plain global variables */ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#endif - -#endif diff --git a/qemu-tool.c b/qemu-tool.c index d1f46222ee..8ac45ff39b 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,12 +15,12 @@ #include "qemu-common.h" #include "monitor/monitor.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "migration/migration.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "sysemu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include diff --git a/qemu-types.h b/qemu-types.h deleted file mode 100644 index fd532a268d..0000000000 --- a/qemu-types.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef QEMU_TYPEDEFS_H -#define QEMU_TYPEDEFS_H - -/* A load of opaque types so that device init declarations don't have to - pull in all the real definitions. */ -typedef struct QEMUTimer QEMUTimer; -typedef struct QEMUFile QEMUFile; -typedef struct QEMUBH QEMUBH; - -struct Monitor; -typedef struct Monitor Monitor; -typedef struct MigrationParams MigrationParams; - -typedef struct Property Property; -typedef struct PropertyInfo PropertyInfo; -typedef struct CompatProperty CompatProperty; -typedef struct DeviceState DeviceState; -typedef struct BusState BusState; -typedef struct BusClass BusClass; - -typedef struct NICInfo NICInfo; -typedef struct HCIInfo HCIInfo; -typedef struct AudioState AudioState; -typedef struct BlockDriverState BlockDriverState; -typedef struct DriveInfo DriveInfo; -typedef struct DisplayState DisplayState; -typedef struct DisplayChangeListener DisplayChangeListener; -typedef struct DisplaySurface DisplaySurface; -typedef struct PixelFormat PixelFormat; -typedef struct QemuConsole QemuConsole; -typedef struct CharDriverState CharDriverState; -typedef struct MACAddr MACAddr; -typedef struct NetClientState NetClientState; -typedef struct i2c_bus i2c_bus; -typedef struct ISABus ISABus; -typedef struct ISADevice ISADevice; -typedef struct SMBusDevice SMBusDevice; -typedef struct PCIHostState PCIHostState; -typedef struct PCIExpressHost PCIExpressHost; -typedef struct PCIBus PCIBus; -typedef struct PCIDevice PCIDevice; -typedef struct PCIExpressDevice PCIExpressDevice; -typedef struct PCIBridge PCIBridge; -typedef struct PCIEAERMsg PCIEAERMsg; -typedef struct PCIEAERLog PCIEAERLog; -typedef struct PCIEAERErr PCIEAERErr; -typedef struct PCIEPort PCIEPort; -typedef struct PCIESlot PCIESlot; -typedef struct MSIMessage MSIMessage; -typedef struct SerialState SerialState; -typedef struct PCMCIACardState PCMCIACardState; -typedef struct MouseTransformInfo MouseTransformInfo; -typedef struct uWireSlave uWireSlave; -typedef struct I2SCodec I2SCodec; -typedef struct SSIBus SSIBus; -typedef struct EventNotifier EventNotifier; -typedef struct VirtIODevice VirtIODevice; -typedef struct QEMUSGList QEMUSGList; -typedef struct SHPCDevice SHPCDevice; - -#endif /* QEMU_TYPEDEFS_H */ diff --git a/qemu-xattr.h b/qemu-xattr.h deleted file mode 100644 index f910d96eaf..0000000000 --- a/qemu-xattr.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Host xattr.h abstraction - * - * Copyright 2011 Red Hat Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2, or any - * later version. See the COPYING file in the top-level directory. - * - */ -#ifndef QEMU_XATTR_H -#define QEMU_XATTR_H - -/* - * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h - * in /usr/include/sys, and don't have ENOATTR. - */ - -#include "config-host.h" - -#ifdef CONFIG_LIBATTR -# include -#else -# define ENOATTR ENODATA -# include -#endif - -#endif diff --git a/qemu_socket.h b/qemu_socket.h deleted file mode 100644 index 42899fe138..0000000000 --- a/qemu_socket.h +++ /dev/null @@ -1,77 +0,0 @@ -/* headers to use the BSD sockets */ -#ifndef QEMU_SOCKET_H -#define QEMU_SOCKET_H - -#ifdef _WIN32 -#include -#include -#include - -#define socket_error() WSAGetLastError() - -int inet_aton(const char *cp, struct in_addr *ia); - -#else - -#include -#include -#include -#include -#include -#include -#include - -#define socket_error() errno -#define closesocket(s) close(s) - -#endif /* !_WIN32 */ - -#include "qemu-option.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -/* misc helpers */ -int qemu_socket(int domain, int type, int protocol); -int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int socket_set_cork(int fd, int v); -void socket_set_block(int fd); -void socket_set_nonblock(int fd); -int send_all(int fd, const void *buf, int len1); - -/* callback function for nonblocking connect - * valid fd on success, negative error code on failure - */ -typedef void NonBlockingConnectHandler(int fd, void *opaque); - -int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); -int inet_listen(const char *str, char *ostr, int olen, - int socktype, int port_offset, Error **errp); -int inet_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int inet_connect(const char *str, Error **errp); -int inet_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -int inet_dgram_opts(QemuOpts *opts, Error **errp); -const char *inet_strfamily(int family); - -int unix_listen_opts(QemuOpts *opts, Error **errp); -int unix_listen(const char *path, char *ostr, int olen, Error **errp); -int unix_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int unix_connect(const char *path, Error **errp); -int unix_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -SocketAddress *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddress *addr, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int socket_listen(SocketAddress *addr, Error **errp); - -/* Old, ipv4 only bits. Don't use for new code. */ -int parse_host_port(struct sockaddr_in *saddr, const char *str); -int socket_init(void); - -#endif /* QEMU_SOCKET_H */ diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 769a559456..d4fd628907 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -4,8 +4,8 @@ #include #include #include -#include "osdep.h" -#include "qemu_socket.h" +#include "qemu/osdep.h" +#include "qemu/sockets.h" #include "qga/channel.h" #ifdef CONFIG_SOLARIS diff --git a/qga/commands-posix.c b/qga/commands-posix.c index cedf2ccf28..a657201e7a 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -18,8 +18,8 @@ #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qapi/qmp/qerror.h" -#include "qemu-queue.h" -#include "host-utils.h" +#include "qemu/queue.h" +#include "qemu/host-utils.h" #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ diff --git a/qga/main.c b/qga/main.c index ead58cc11f..ba5fa1c778 100644 --- a/qga/main.c +++ b/qga/main.c @@ -25,7 +25,7 @@ #include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" #include "qga/guest-agent-core.h" -#include "module.h" +#include "qemu/module.h" #include "signal.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/dispatch.h" diff --git a/qlist.c b/qlist.c index c5ac2115af..1ced0de58e 100644 --- a/qlist.c +++ b/qlist.c @@ -12,7 +12,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qlist_destroy_obj(QObject *obj); diff --git a/qom/container.c b/qom/container.c index ceb0f0186d..5270a5ee9c 100644 --- a/qom/container.c +++ b/qom/container.c @@ -11,7 +11,7 @@ */ #include "qom/object.h" -#include "module.h" +#include "qemu/module.h" #include static TypeInfo container_info = { diff --git a/range.h b/range.h deleted file mode 100644 index 350237212b..0000000000 --- a/range.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QEMU_RANGE_H -#define QEMU_RANGE_H - -/* Get last byte of a range from offset + length. - * Undefined for ranges that wrap around 0. */ -static inline uint64_t range_get_last(uint64_t offset, uint64_t len) -{ - return offset + len - 1; -} - -/* Check whether a given range covers a given byte. */ -static inline int range_covers_byte(uint64_t offset, uint64_t len, - uint64_t byte) -{ - return offset <= byte && byte <= range_get_last(offset, len); -} - -/* Check whether 2 given ranges overlap. - * Undefined if ranges that wrap around 0. */ -static inline int ranges_overlap(uint64_t first1, uint64_t len1, - uint64_t first2, uint64_t len2) -{ - uint64_t last1 = range_get_last(first1, len1); - uint64_t last2 = range_get_last(first2, len2); - - return !(last2 < first1 || last1 < first2); -} - -#endif diff --git a/savevm.c b/savevm.c index a5205a09c3..ea01e9baf6 100644 --- a/savevm.c +++ b/savevm.c @@ -75,17 +75,17 @@ #include "net/net.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio/audio.h" #include "migration/migration.h" -#include "qemu_socket.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "cpus.h" #include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SELF_ANNOUNCE_ROUNDS 5 diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index eccc28daee..e06332bd55 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -367,7 +367,7 @@ def gen_command_def_prologue(prefix="", proxy=False): */ #include "qemu-common.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/types.h" #include "qapi/qmp/dispatch.h" diff --git a/slirp/if.c b/slirp/if.c index 533295dd07..dcd5fafe5d 100644 --- a/slirp/if.c +++ b/slirp/if.c @@ -6,7 +6,7 @@ */ #include -#include "qemu-timer.h" +#include "qemu/timer.h" static void ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead) diff --git a/slirp/ip_input.c b/slirp/ip_input.c index 6f4cff8fdd..880bdfd3cc 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -39,7 +39,7 @@ */ #include -#include +#include #include "ip_icmp.h" static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp); diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 637f8fea3d..08ec2b4f44 100644 --- a/slirp/sbuf.c +++ b/slirp/sbuf.c @@ -6,7 +6,7 @@ */ #include -#include +#include static void sbappendsb(struct sbuf *sb, struct mbuf *m); diff --git a/slirp/slirp.c b/slirp/slirp.c index 3395d509a2..4b51a67e7d 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "slirp.h" #include "hw/hw.h" diff --git a/slirp/slirp.h b/slirp/slirp.h index 0107b07e66..dfc3e3a2b8 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -133,8 +133,8 @@ void free(void *ptr); #include "debug.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" #include "libslirp.h" #include "ip.h" diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 5f95c937f3..41b1657ccd 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -5,7 +5,7 @@ #include #include -#include "osdep.h" +#include "qemu/osdep.h" #define dprintf(_scd, _level, _fmt, ...) \ do { \ diff --git a/stubs/fd-register.c b/stubs/fd-register.c index 813b6dd7c0..d0c34fd2a3 100644 --- a/stubs/fd-register.c +++ b/stubs/fd-register.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" void qemu_fd_register(int fd) { diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c index 4807b5dc22..fc874d33fe 100644 --- a/stubs/set-fd-handler.c +++ b/stubs/set-fd-handler.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, diff --git a/sysemu.h b/sysemu.h index 1b6add2dc3..8eaa4707a0 100644 --- a/sysemu.h +++ b/sysemu.h @@ -2,13 +2,13 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ -#include "qemu-types.h" -#include "qemu-option.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/typedefs.h" +#include "qemu/option.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "qapi-types.h" -#include "notify.h" -#include "main-loop.h" +#include "qemu/notify.h" +#include "qemu/main-loop.h" /* vl.c */ diff --git a/target-alpha/int_helper.c b/target-alpha/int_helper.c index 1d832f0b57..c9b42b6ed4 100644 --- a/target-alpha/int_helper.c +++ b/target-alpha/int_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" uint64_t helper_umulh(uint64_t op1, uint64_t op2) diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index 40ca49c883..2bc2b02815 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "helper.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" uint64_t helper_load_pcc(CPUAlphaState *env) diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 2d0d891128..c94126737f 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "disas/disas.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "tcg-op.h" #include "helper.h" diff --git a/target-arm/helper.c b/target-arm/helper.c index 1f7a3c04c3..eef2acd18a 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1,9 +1,9 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysemu.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifndef CONFIG_USER_ONLY static inline int get_phys_addr(CPUARMState *env, uint32_t address, diff --git a/target-arm/translate.c b/target-arm/translate.c index 988b5428d4..724e00f7cf 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-cris/helper.c b/target-cris/helper.c index 324fe052f5..8407a6d880 100644 --- a/target-cris/helper.c +++ b/target-cris/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "mmu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_HELPER_DEBUG diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index cd0e17e099..79bff38663 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "mmu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_OP_HELPER_DEBUG diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 150c4dfb0c..8abc5561e9 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -24,8 +24,8 @@ #include "cpu.h" #include "kvm.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c index aaa5ca2090..64c8346d3b 100644 --- a/target-i386/excp_helper.c +++ b/target-i386/excp_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-i386/int_helper.c b/target-i386/int_helper.c index f39747e806..84b812dcca 100644 --- a/target-i386/int_helper.c +++ b/target-i386/int_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" //#define DEBUG_MULDIV diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f7c95d5424..340ed3f33e 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -26,8 +26,8 @@ #include "kvm_i386.h" #include "cpu.h" #include "exec/gdbstub.h" -#include "host-utils.h" -#include "qemu-config.h" +#include "qemu/host-utils.h" +#include "qemu/config-file.h" #include "hw/pc.h" #include "hw/apic.h" #include "exec/ioport.h" diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index be795d71eb..c2a99ee9bc 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" //#define DEBUG_PCALL diff --git a/target-lm32/helper.c b/target-lm32/helper.c index 0ed7cfda18..d76ea3fe09 100644 --- a/target-lm32/helper.c +++ b/target-lm32/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw, int mmu_idx) diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 27b3cef25c..53410b176e 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -1,7 +1,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/lm32_pic.h" #include "hw/lm32_juart.h" diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 1c9b5ec8d4..e763195f86 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helpers.h" #define GEN_HELPER 1 diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c index 530e0b5fb0..97aedc52bb 100644 --- a/target-microblaze/helper.c +++ b/target-microblaze/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) #define DMMU(x) diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 343dcc15e7..1c62f3c68f 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -21,7 +21,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 157f59e6bf..e85edce6fa 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -18,7 +18,7 @@ */ #include #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" diff --git a/target-openrisc/int_helper.c b/target-openrisc/int_helper.c index 2fdfd27712..20f9837e6a 100644 --- a/target-openrisc/int_helper.c +++ b/target-openrisc/int_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "helper.h" #include "exception.h" -#include "host-utils.h" +#include "qemu/host-utils.h" target_ulong HELPER(ff1)(target_ulong x) { diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c index 226ce43513..7f2c025da2 100644 --- a/target-openrisc/interrupt.c +++ b/target-openrisc/interrupt.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/mmu.c b/target-openrisc/mmu.c index 4eee44434f..836465259a 100644 --- a/target-openrisc/mmu.c +++ b/target-openrisc/mmu.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 5883347fa7..1e1b30cdcb 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -23,9 +23,9 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "config.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c index f39b4f682a..783079d995 100644 --- a/target-ppc/int_helper.c +++ b/target-ppc/int_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 3f5df5772f..2546c577f6 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -23,7 +23,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c index a2e49cd423..2de59fd43b 100644 --- a/target-ppc/kvm_ppc.c +++ b/target-ppc/kvm_ppc.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "kvm_ppc.h" #include "device_tree.h" diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c index 2d7a349c32..902b1cd823 100644 --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/translate.c b/target-ppc/translate.c index a74d76b5a6..798b7acfc9 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 619b202b92..249f063d94 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -22,7 +22,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* CPUClass::reset() */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 6e9b209713..8e135457a3 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" #endif diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index f202a7e1da..b683709860 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" /* #define DEBUG_HELPER */ diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 94de764264..dc70699919 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -25,7 +25,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "cpu.h" diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index a3336e16b0..2e73d30756 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -20,11 +20,11 @@ #include "cpu.h" #include "exec/memory.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include #include "kvm.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_KVM #include #endif diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 28e61c54b8..9e34741311 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -32,7 +32,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" /* global register indexes */ static TCGv_ptr cpu_env; diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 0ed511a399..04b6659909 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -3,7 +3,7 @@ #include "config.h" #include "qemu-common.h" -#include "bswap.h" +#include "qemu/bswap.h" #if !defined(TARGET_SPARC64) #define TARGET_LONG_BITS 32 diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 3c8e865eef..e0d78f3852 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "sysemu.h" diff --git a/target-sparc/machine.c b/target-sparc/machine.c index eb4d87f158..a353dabdd9 100644 --- a/target-sparc/machine.c +++ b/target-sparc/machine.c @@ -1,6 +1,6 @@ #include "hw/hw.h" #include "hw/boards.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "cpu.h" diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 2adbd1675d..ff4f628404 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -12,7 +12,7 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "ui/console.h" #undef DEBUG_UC32 diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 218e95eaca..f4498bcb14 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -17,7 +17,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index d1a594cda2..0bfcf2414c 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc232b/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index ead6b3b128..11acbf3580 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -29,7 +29,7 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc233c/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index a387aeeca5..d4660edde9 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-fsf/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index 3d7a399008..94c03a1d3c 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c index a93abcb1dd..3813a72626 100644 --- a/target-xtensa/op_helper.c +++ b/target-xtensa/op_helper.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" static void do_unaligned_access(CPUXtensaState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr); diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 3c2d1853d6..f61a497d21 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -34,7 +34,7 @@ #include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-xtensa/xtensa-semi.c b/target-xtensa/xtensa-semi.c index 851ff546f0..5fe0361c02 100644 --- a/target-xtensa/xtensa-semi.c +++ b/target-xtensa/xtensa-semi.c @@ -31,7 +31,7 @@ #include #include "cpu.h" #include "helper.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { TARGET_SYS_exit = 1, diff --git a/tcg/tcg.c b/tcg/tcg.c index cb193f2683..ede51a3960 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -37,9 +37,9 @@ #endif #include "qemu-common.h" -#include "cache-utils.h" -#include "host-utils.h" -#include "qemu-timer.h" +#include "qemu/cache-utils.h" +#include "qemu/host-utils.h" +#include "qemu/timer.h" /* Note: the long term plan is to reduce the dependancies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/tests/libqtest.c b/tests/libqtest.c index 71b84c12dd..913fa0535c 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -26,8 +26,8 @@ #include #include -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #define MAX_IRQ 256 diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c index 8c7a4d1ff4..e91fb1ae93 100644 --- a/tests/tcg/test-i386-fprem.c +++ b/tests/tcg/test-i386-fprem.c @@ -22,8 +22,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #include #include diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c index 40392ac51d..6dc730d882 100644 --- a/tests/tcg/test-i386.c +++ b/tests/tcg/test-i386.c @@ -17,7 +17,7 @@ * along with this program; if not, see . */ #define _GNU_SOURCE -#include "compiler.h" +#include "qemu/compiler.h" #include #include #include diff --git a/tests/test-iov.c b/tests/test-iov.c index cbe7a8955c..a480bc8725 100644 --- a/tests/test-iov.c +++ b/tests/test-iov.c @@ -1,7 +1,7 @@ #include #include "qemu-common.h" -#include "iov.h" -#include "qemu_socket.h" +#include "qemu/iov.h" +#include "qemu/sockets.h" /* create a randomly-sized iovec with random vectors */ static void iov_random(struct iovec **iovp, unsigned *iov_cntp) diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 61b533a071..5a3e82a854 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -3,7 +3,7 @@ #include "qapi/qmp/types.h" #include "test-qmp-commands.h" #include "qapi/qmp/dispatch.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp-input-visitor.h" #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" diff --git a/thread-pool.c b/thread-pool.c index 4c73a7db97..e3ca64d790 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -15,13 +15,13 @@ * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/thread.h" +#include "qemu/osdep.h" #include "block/coroutine.h" #include "trace.h" #include "block/block_int.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "block/thread-pool.h" static void do_spawn_thread(void); diff --git a/trace/simple.c b/trace/simple.c index d83681b227..ce17d64bd7 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -16,7 +16,7 @@ #include #include #endif -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "trace/control.h" diff --git a/translate-all.c b/translate-all.c index e0cdad38c7..b621748ec0 100644 --- a/translate-all.c +++ b/translate-all.c @@ -35,7 +35,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) diff --git a/ui/console.c b/ui/console.c index 60bfb72ac2..a4bff8ce8a 100644 --- a/ui/console.c +++ b/ui/console.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qmp-commands.h" #include "qemu-char.h" diff --git a/ui/sdl_zoom.c b/ui/sdl_zoom.c index a986c7c14c..122027cb36 100644 --- a/ui/sdl_zoom.c +++ b/ui/sdl_zoom.c @@ -12,7 +12,7 @@ */ #include "sdl_zoom.h" -#include "osdep.h" +#include "qemu/osdep.h" #include #include diff --git a/ui/spice-core.c b/ui/spice-core.c index 962475de6b..8727bf49ca 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -23,17 +23,17 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-thread.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/thread.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "qemu-x509.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qmp-commands.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "notify.h" +#include "qemu/notify.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "hw/hw.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 56ebf80805..a19b3d95fb 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h index ee243a9d64..8091d689cb 100644 --- a/ui/vnc-auth-sasl.h +++ b/ui/vnc-auth-sasl.h @@ -32,7 +32,7 @@ typedef struct VncStateSASL VncStateSASL; typedef struct VncDisplaySASL VncDisplaySASL; -#include "acl.h" +#include "qemu/acl.h" struct VncStateSASL { sasl_conn_t *conn; diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 09199ef584..4ddea7d4f5 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -44,7 +44,7 @@ #include #endif -#include "bswap.h" +#include "qemu/bswap.h" #include "qapi/qmp/qint.h" #include "vnc.h" #include "vnc-enc-tight.h" diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 57c091683b..0bfc0c5485 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -28,7 +28,7 @@ #include "vnc.h" #include "vnc-jobs.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" /* * Locking: diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h index bfc7fe642e..d02f0236c1 100644 --- a/ui/vnc-palette.h +++ b/ui/vnc-palette.h @@ -30,7 +30,7 @@ #define VNC_PALETTE_H #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #include diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c index a7f7d07ac8..56292636d7 100644 --- a/ui/vnc-tls.c +++ b/ui/vnc-tls.c @@ -26,7 +26,7 @@ #include "qemu-x509.h" #include "vnc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 /* Very verbose, so only enabled for _VNC_DEBUG >= 2 */ diff --git a/ui/vnc-tls.h b/ui/vnc-tls.h index 2b93633896..36a2227fec 100644 --- a/ui/vnc-tls.h +++ b/ui/vnc-tls.h @@ -31,7 +31,7 @@ #include #include -#include "acl.h" +#include "qemu/acl.h" enum { VNC_WIREMODE_CLEAR, diff --git a/ui/vnc.c b/ui/vnc.c index dad2ddee29..d9e5315e79 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -27,12 +27,12 @@ #include "vnc.h" #include "vnc-jobs.h" #include "sysemu.h" -#include "qemu_socket.h" -#include "qemu-timer.h" -#include "acl.h" +#include "qemu/sockets.h" +#include "qemu/timer.h" +#include "qemu/acl.h" #include "qapi/qmp/types.h" #include "qmp-commands.h" -#include "osdep.h" +#include "qemu/osdep.h" #define VNC_REFRESH_INTERVAL_BASE 30 #define VNC_REFRESH_INTERVAL_INC 50 diff --git a/ui/vnc.h b/ui/vnc.h index e5c043ff45..8b40f09117 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -28,12 +28,12 @@ #define __QEMU_VNC_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "ui/console.h" #include "monitor/monitor.h" #include "audio/audio.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include diff --git a/uri.c b/uri.c index 138547b821..4238729b83 100644 --- a/uri.c +++ b/uri.c @@ -55,7 +55,7 @@ #include #include -#include "uri.h" +#include "qemu/uri.h" static void uri_clean(URI *uri); diff --git a/uri.h b/uri.h deleted file mode 100644 index de99b3bd4b..0000000000 --- a/uri.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Summary: library of generic URI related routines - * Description: library of generic URI related routines - * Implements RFC 2396 - * - * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Daniel Veillard shall not - * be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from him. - * - * Author: Daniel Veillard - ** - * Copyright (C) 2007 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: - * Richard W.M. Jones - * - * Utility functions to help parse and assemble query strings. - */ - -#ifndef QEMU_URI_H -#define QEMU_URI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * URI: - * - * A parsed URI reference. This is a struct containing the various fields - * as described in RFC 2396 but separated for further processing. - */ -typedef struct URI { - char *scheme; /* the URI scheme */ - char *opaque; /* opaque part */ - char *authority; /* the authority part */ - char *server; /* the server part */ - char *user; /* the user part */ - int port; /* the port number */ - char *path; /* the path string */ - char *fragment; /* the fragment identifier */ - int cleanup; /* parsing potentially unclean URI */ - char *query; /* the query string (as it appears in the URI) */ -} URI; - -URI *uri_new(void); -char *uri_resolve(const char *URI, const char *base); -char *uri_resolve_relative(const char *URI, const char *base); -URI *uri_parse(const char *str); -URI *uri_parse_raw(const char *str, int raw); -int uri_parse_into(URI *uri, const char *str); -char *uri_to_string(URI *uri); -char *uri_string_escape(const char *str, const char *list); -char *uri_string_unescape(const char *str, int len, char *target); -void uri_free(URI *uri); - -/* Single web service query parameter 'name=value'. */ -typedef struct QueryParam { - char *name; /* Name (unescaped). */ - char *value; /* Value (unescaped). */ - int ignore; /* Ignore this field in qparam_get_query */ -} QueryParam; - -/* Set of parameters. */ -typedef struct QueryParams { - int n; /* number of parameters used */ - int alloc; /* allocated space */ - QueryParam *p; /* array of parameters */ -} QueryParams; - -struct QueryParams *query_params_new (int init_alloc); -int query_param_append (QueryParams *ps, const char *name, const char *value); -extern char *query_param_to_string (const QueryParams *ps); -extern QueryParams *query_params_parse (const char *query); -extern void query_params_free (QueryParams *ps); - -#ifdef __cplusplus -} -#endif -#endif /* QEMU_URI_H */ diff --git a/vl.c b/vl.c index 2debde0a4a..9b80e7abc4 100644 --- a/vl.c +++ b/vl.c @@ -28,7 +28,7 @@ #include #include #include -#include "bitmap.h" +#include "qemu/bitmap.h" /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" @@ -133,9 +133,9 @@ int main(int argc, char **argv) #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "blockdev.h" #include "hw/block-common.h" #include "migration/block.h" @@ -144,11 +144,11 @@ int main(int argc, char **argv) #include "migration/migration.h" #include "kvm.h" #include "qapi/qmp/qjson.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-options.h" #include "qmp-commands.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -156,16 +156,16 @@ int main(int argc, char **argv) #include "disas/disas.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "trace.h" #include "trace/control.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "cpus.h" #include "arch_init.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "ui/qemu-spice.h" #include "qapi/string-input-visitor.h" diff --git a/xen-all.c b/xen-all.c index 95d383f41f..6965626db8 100644 --- a/xen-all.c +++ b/xen-all.c @@ -16,7 +16,7 @@ #include "hw/xen_backend.h" #include "qmp-commands.h" -#include "range.h" +#include "qemu/range.h" #include "xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h" diff --git a/xen-mapcache.c b/xen-mapcache.c index 31c06dc950..8f4648cc32 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -14,7 +14,7 @@ #include "hw/xen_backend.h" #include "blockdev.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include -- cgit v1.2.3-55-g7522