about API hierarchy
Subsystems (4)
cover about API hierarchy
Hi Community,
Q1) Is it helpful for the document docs/api_hierarchy.txt I wrote? Would you
please help review/correct it?
Q2) Does it make sense to remove NEED_CPU_H from qemu-common.h?
Q3) In include/sysemu/kvm.h, CONFIG_KVM is used thus considering dependency
we should include "config-target.h", what is the best conditional to use? Or we don't use any conditional and assume architecture-independent code should NOT include include/sysemu/kvm.h?
Q4) Is it better for include/qemu-common.h to only include C99 API and QEMU
basic API declared in include/qemu/*?
Q5) Should we move exec/def-helper.h => tcg/def-helper.h and
exec/spinlock.h => include/qemu/spinlock.h, to reflect the definition of exec is: memory API, translation API and cpu API?
After this patchset, cpu-all.h and exec-all.h should ONLY be included from target-xxx/*.
Thanks.
Xuebing Wang (10):
docs: add docs/api-hierarchy.txt
NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
NEED_CPU_H: remove unnecessary use of NEED_CPU_H
memory_mapping: make this architecture-independent
NEED_CPU_H: remove unnecessary inclusion of "cpu.h" in root
memory: move contents in include/exec/address-spaces.h => memory.h
memory: remove file include/exec/address-spaces.h
exec: move TranslationBlock API from exec-all.h => translate.h
exec: remove the unnecessary include of "exec-all.h"
translate: remove file translate-all.h
arch_init.c | 2 - cpu-exec.c | 7 +- cputlb.c | 8 +- disas.c | 7 +- docs/api-hierarchy.txt | 93 +++++++++ dump.c | 2 - exec.c | 5 - gdbstub.c | 8 +- hw/acpi/ich9.c | 1 - hw/acpi/pcihp.c | 1 - hw/acpi/piix4.c | 1 - hw/alpha/typhoon.c | 1 - hw/arm/boot.c | 1 - hw/arm/collie.c | 1 - hw/arm/digic_boards.c | 1 - hw/arm/exynos4_boards.c | 1 - hw/arm/gumstix.c | 1 - hw/arm/highbank.c | 1 - hw/arm/integratorcp.c | 1 - hw/arm/kzm.c | 1 - hw/arm/mainstone.c | 1 - hw/arm/musicpal.c | 1 - hw/arm/nseries.c | 1 - hw/arm/omap_sx1.c | 1 - hw/arm/palm.c | 1 - hw/arm/realview.c | 1 - hw/arm/spitz.c | 1 - hw/arm/stellaris.c | 1 - hw/arm/tosa.c | 1 - hw/arm/versatilepb.c | 1 - hw/arm/vexpress.c | 1 - hw/arm/virt.c | 1 - hw/arm/xilinx_zynq.c | 1 - hw/arm/z2.c | 1 - hw/block/onenand.c | 1 - hw/block/pflash_cfi01.c | 1 - hw/block/pflash_cfi02.c | 1 - hw/char/mcf_uart.c | 1 - hw/char/omap_uart.c | 1 - hw/char/serial.c | 1 - hw/char/sh_serial.c | 1 - hw/core/loader.c | 1 - hw/core/sysbus.c | 1 - hw/cris/axis_dev88.c | 1 - hw/display/sm501.c | 1 - hw/dma/etraxfs_dma.c | 1 - hw/dma/pl080.c | 1 - hw/dma/soc_dma.c | 5 + hw/dma/sun4m_iommu.c | 1 - hw/i386/pc.c | 1 - hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 1 - hw/intc/armv7m_nvic.c | 1 - hw/intc/openpic_kvm.c | 1 - hw/isa/isa-bus.c | 1 - hw/isa/lpc_ich9.c | 1 - hw/isa/vt82c686.c | 1 - hw/lm32/lm32_boards.c | 1 - hw/lm32/milkymist.c | 1 - hw/m68k/an5206.c | 1 - hw/m68k/dummy_m68k.c | 1 - hw/m68k/mcf5206.c | 1 - hw/m68k/mcf5208.c | 1 - hw/m68k/mcf_intc.c | 1 - hw/microblaze/petalogix_ml605_mmu.c | 1 - hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 - hw/mips/gt64xxx_pci.c | 1 - hw/mips/mips_fulong2e.c | 1 - hw/mips/mips_jazz.c | 1 - hw/mips/mips_malta.c | 1 - hw/mips/mips_mipssim.c | 1 - hw/mips/mips_r4k.c | 1 - hw/misc/arm_integrator_debug.c | 1 - hw/misc/omap_gpmc.c | 1 - hw/misc/vfio.c | 1 - hw/moxie/moxiesim.c | 1 - hw/net/mcf_fec.c | 1 - hw/net/ne2000-isa.c | 1 - hw/openrisc/openrisc_sim.c | 1 - hw/pci-host/apb.c | 1 - hw/pci-host/bonito.c | 1 - hw/pci-host/ppce500.c | 1 - hw/pci-host/prep.c | 1 - hw/pci-host/versatile.c | 1 - hw/pci/pci.c | 1 - hw/pci/pcie_host.c | 1 - hw/ppc/e500.c | 1 - hw/ppc/mac_newworld.c | 1 - hw/ppc/mac_oldworld.c | 1 - hw/ppc/ppc405_boards.c | 1 - hw/ppc/ppc405_uc.c | 1 - hw/ppc/ppc440_bamboo.c | 1 - hw/ppc/ppc4xx_devs.c | 1 - hw/ppc/ppc4xx_pci.c | 1 - hw/ppc/prep.c | 1 - hw/ppc/spapr.c | 1 - hw/ppc/spapr_iommu.c | 1 - hw/ppc/spapr_pci.c | 1 - hw/ppc/virtex_ml507.c | 1 - hw/s390x/css.c | 1 - hw/s390x/s390-virtio-ccw.c | 1 - hw/s390x/s390-virtio.c | 1 - hw/sh4/r2d.c | 1 - hw/sh4/sh7750.c | 1 - hw/sh4/sh_pci.c | 1 - hw/sh4/shix.c | 1 - hw/sparc/leon3.c | 1 - hw/sparc64/sun4u.c | 1 - hw/timer/m48t59.c | 1 - hw/timer/sh_timer.c | 1 - hw/tpm/tpm_tis.c | 1 - hw/unicore32/puv3.c | 1 - hw/virtio/dataplane/vring.c | 1 - hw/virtio/vhost.c | 1 - hw/virtio/virtio-balloon.c | 1 - hw/virtio/virtio.c | 1 - hw/xen/xen_platform.c | 1 - hw/xen/xen_pt.c | 1 - hw/xtensa/xtensa_lx60.c | 1 - hw/xtensa/xtensa_sim.c | 1 - include/disas/disas.h | 6 +- include/exec/address-spaces.h | 41 ---- include/exec/cpu-all.h | 6 + include/exec/cpu-common.h | 5 + include/exec/exec-all.h | 302 +---------------------------- include/exec/gdbstub.h | 4 +- include/exec/memory.h | 19 +- include/exec/ram_addr.h | 5 + include/exec/softmmu_template.h | 1 - include/exec/translate.h | 310 ++++++++++++++++++++++++++++++ include/hw/arm/allwinner-a10.h | 1 - include/hw/arm/omap.h | 6 + include/hw/hw.h | 13 +- include/hw/i386/apic.h | 6 + include/hw/i386/apic_internal.h | 6 + include/hw/sh4/sh_intc.h | 2 +- include/hw/xen/xen.h | 4 +- include/migration/vmstate.h | 11 ++ include/qemu-common.h | 11 -- include/qemu/log.h | 7 +- include/qom/cpu.h | 14 -- include/sysemu/dma.h | 1 - include/sysemu/kvm.h | 12 +- include/sysemu/memory_mapping.h | 3 +- ioport.c | 1 - kvm-all.c | 1 - kvm-stub.c | 1 - memory.c | 1 - memory_mapping.c | 7 +- monitor.c | 1 - target-sparc/mmu_helper.c | 1 - target-xtensa/op_helper.c | 1 - tcg/README | 2 +- tcg/tcg.h | 6 + tci.c | 2 +- translate-all.c | 10 +- translate-all.h | 27 --- ui/input.c | 2 - user-exec.c | 7 +- xen-all.c | 1 - 160 files changed, 552 insertions(+), 563 deletions(-) create mode 100644 docs/api-hierarchy.txt delete mode 100644 include/exec/address-spaces.h create mode 100644 include/exec/translate.h delete mode 100644 translate-all.h
Signature · 1 line
1.7.9.5
PATCH 1/10 docs: add docs/api-hierarchy.txt
--- docs/api-hierarchy.txt | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 docs/api-hierarchy.txt
docs/api-hierarchy.txt new file +93 -0
@@ -0,0 +1,93 @@ +API hierarchy +============= + +1) QEMU common API + + |-------------------------------| + | C99 API | + | - <stdio.h> <stdlib.h> ... | + |-------------------------------| + | QEMU basic API | + | - include/qemu/* | + |-------------------------------| + | QEMU utility/helper API | + | - block | + | - disas | + | - migration | + | - monitor | + | - net | + | - qapi | + | - ... | + |-------------------------------| + +2) CPUArchState API + + |-----------------------------------------------------------------------| + | qom/Object | QEMU common API | + |--------------| - Linux API | + | - QEMU basic API | + | - QEMU utility/helper API | + |-----------------------------------------------------------------------| + | qdev/DeviceState | + |-----------------------------------------------------------------------| + | Create new file? | sysemu/kvm.h | hw/xen/xen.h | + | exec/cpu-exec.h? | | | + |------------------------------------------------| + | TODO: consider to abstract vcpu here? | + | include/qom/vcpu.h? | + |-----------------------------------------------------------------------| + | qom/CPUState | + |-----------------------------------------------------------------------| + | target-xxx/CPUArchState | sysemu/sysemu.h | + |-----------------------------------------------------------------------| + + cpu-exec.h is for one (tcg) of the 3 accelerators: tcg, kvm and xen. + +3) Memory API + + |--------------------------------------------------------------| + | linux-user | softmmu | + | gueust virtual address | guest physical address | + | | guest virtual address | + | | | + | | --------------------------------| + | | | Memory modelling | + | | | | + | | | MemoryRegion | RAMBlock | + | | | memory.h | | + | | --------------------------------| + | | | softmmu API | + | | | - include/exec/softmmu*.h | + | | | - include/exec/cputlb.h | + |--------------------------------------------------------------| + | memory load/store API | + | include/exec/cpu-common.h | + |--------------------------------------------------------------| + +4) exec API + + architecture-independent | architecture + | specific + |------------------| | + | memory | | + | load/store API | | + | cpu-common.h | | + |-----------------------------------------------------|---------------| + | tcg framework | tcg frontend | + | tcg/tcg*.h | | + |------------------|---------------|---------------| + | TranslationBlock | | + | translate.h | | + |-------------------------------------|---------------|---------------| + | | misc cpu API | misc cpu API | + | include/exec/exec-all.h | cpu-common.h | cpu-all.h | + |-------------------------------------|---------------|---------------| + + include/exec includes: + - Memory API + - TranslationBlock API + - misc cpu API (both architecture-independent and architecture-specific) + + include/exec/cpu-all.h is for architecture-specific, it's only included + in target-xxx/* files. +
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 01/10] docs: add docs/api-hierarchy.txt
Quoted 5 lines · Xuebing Wang
Signed-off-by Xuebing Wang <[email protected]>--- docs/api-hierarchy.txt | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 docs/api-hierarchy.txt
This type of documentation gets outdated really quickly. I'm not sure it should be merged.
Documenting the various APIs as doc comments in the code would have a better chance of staying up-to-date.
Re: [Qemu-devel] [Discussion 01/10] docs: add docs/api-hierarchy.txt
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Xuebing Wang
Signed-off-by Xuebing Wang <[email protected]>--- docs/api-hierarchy.txt | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)create mode 100644
docs/api-hierarchy.txt
Quoted 6 lines
This type of documentation gets outdated really quickly. I'm not sure it should be merged.
Documenting the various APIs as doc comments in the code would have a better chance of staying up-to-date.
Thanks. But, doc comments in the code don't show the hierarchy and their dependencies (or inheriting relationship).
Any idea how to draw the hierarchy to show the big picture of the APIs (as a high-level API design doc)? :-)
Signature · 2 lines
Thanks, Xuebing Wang
Re: [Qemu-devel] [Discussion 01/10] docs: add docs/api-hierarchy.txt
Quoted 15 lines · Xuebing wang
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Xuebing Wang
Signed-off-by Xuebing Wang <[email protected]>--- docs/api-hierarchy.txt | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 docs/api-hierarchy.txtQuoted 6 lines
This type of documentation gets outdated really quickly. I'm not sure it should be merged.
Documenting the various APIs as doc comments in the code would have a better chance of staying up-to-date.
Quoted 5 lines
Thanks. But, doc comments in the code don't show the hierarchy and their dependencies (or inheriting relationship).
Any idea how to draw the hierarchy to show the big picture of the APIs (as a high-level API design doc)? :-)
We do have high-level documentation for specific modules. For example, see include/qom/object.h. It documents more than just individual functions. So if you want to find out about QEMU Object Model, then object.h has the documentation you need to get the big picture *and* understand the APIs.
The relationships between modules are a different issue. I don't think it's worth trying to document them because they will get out of date. What's worse than no documentation? Incorrect documentation.
QEMU does not have a stable API, things can change at any time. This has many benefits but also the drawback that documentation gets outdated quickly. I don't think it's a good idea to give the impression that things are stable when they are not.
In other words, module-level documentation is good but high-level API design doesn't exist because we don't have a stable API.
PATCH 2/10 NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
In reply to Xuebing WangNote: there is a FIXME to be addressed in this patch.
This patch handles NEED_CPU_H (thus "target-xxx/cpu.h") only. The changes are:
- Remove inclusion of "cpu.h" from qemu-common.h
- CPU_SAVE_VERSION is defined in target-xxx/cpu.h as well, thus move it
out of qemu-common.h, and move it into include/exec/cpu-all.h
- To make --enable-kvm build, add '#include "config-target.h"' into
sysemu/kvm.h
- To make target-i386 build, change apic_internal.h and apic.h in folder
include/hw/i386/
- To make target-arm build, change include/hw/arm/omap.h
- To make target-alpha build (which uses VMSTATE_CPU), move VMSTATE_CPU()
from include/qom/cpu.h => include/migration/vmstate.h
- The rest changes are generic to all targets, to make all targets build
Why use "#ifndef NEED_CPU_H, then #error ...", is because "target-xxx/cpu.h" is better included for the whole file.
If "target-xxx/cpu.h" is only needed for part of the file, use "#ifdef NEED_CPU_H, then #include "cpu.h"".
Notes on NEED_CPU_H
-------------------NEED_CPU_H means that code needs architecture-specific information. Here are a few examples:
- CPUArchState - TARGET_LONG_BITS - TARGET_PAGE_BITS - TARGET_PHYS_ADDR_SPACE_BITS, TARGET_VIRT_ADDR_SPACE_BITS
And constructs that are derived from above, examples are:
- target_long, target_ulong
Examples of non-architecture-dependent are:
- hwaddr - vaddr - ram_addr_t
--- hw/dma/soc_dma.c | 5 +++++ include/disas/disas.h | 6 +++--- include/exec/cpu-all.h | 6 ++++++ include/exec/gdbstub.h | 4 +++- include/exec/ram_addr.h | 5 +++++ include/hw/arm/omap.h | 6 ++++++ include/hw/i386/apic.h | 6 ++++++ include/hw/i386/apic_internal.h | 6 ++++++ include/hw/xen/xen.h | 2 +- include/migration/vmstate.h | 11 +++++++++++ include/qemu-common.h | 11 ----------- include/qom/cpu.h | 14 -------------- include/sysemu/kvm.h | 10 ++++++++++ tcg/tcg.h | 6 ++++++ 14 files changed, 68 insertions(+), 30 deletions(-)
hw/dma/soc_dma.c +5 -0
@@ -21,6 +21,11 @@#include "qemu/timer.h" #include "hw/arm/soc_dma.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_FMT_lx etc */ +static void transfer_mem2mem (struct soc_dma_ch_s *ch) {memcpy (ch->paddr[0 ], ch->paddr[1 ], ch->bytes);
include/disas/disas.h +3 -3
@@ -1,9 +1,9 @@#ifndef _QEMU_DISAS_H#define _QEMU_DISAS_H -#include "qemu-common.h" -#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ /* Disassemble this for me please... (debugging). */ void disas (FILE *out,void *code,unsigned long size); void target_disas(FILE *out, CPUArchState *env, target_ulong code,
@@ -14,7 +14,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,/* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr); -#endif +#endif /* NEED_CPU_H */ struct syminfo ;struct elf32_sym ;
include/exec/cpu-all.h +6 -0
@@ -490,4 +490,10 @@ void qemu_mutex_unlock_ramlist(void);int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,int is_write); +/* CPU save/load. */ +#ifdef CPU_SAVE_VERSION +void cpu_save (QEMUFile *f,void *opaque); +int cpu_load (QEMUFile *f,void *opaque,int version_id); +#endif +#endif /* CPU_ALL_H */
include/exec/gdbstub.h +3 -1
@@ -11,6 +11,8 @@#define GDB_WATCHPOINT_ACCESS 4#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ typedef void (*gdb_syscall_complete_cb )(CPUState *cpu,target_ulong ret,target_ulong err);
@@ -76,7 +78,7 @@ static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)#define ldtul_p (addr) ldl_p(addr)#endif -#endif +#endif /* NEED_CPU_H */ #ifdef CONFIG_USER_ONLY int gdbserver_start (int );
include/exec/ram_addr.h +5 -0
@@ -19,6 +19,11 @@#ifndef RAM_ADDR_H #define RAM_ADDR_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_PAGE_BITS etc */ +#ifndef CONFIG_USER_ONLY #include "hw/xen/xen.h"
include/hw/arm/omap.h +6 -0
@@ -17,10 +17,16 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef hw_omap_h +#include "exec/memory.h" # define hw_omap_h "omap.h"#include "hw/irq.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for ARMCPU etc */ +# define OMAP_EMIFS_BASE 0x00000000# define OMAP2_Q0_BASE 0x00000000# define OMAP_CS0_BASE 0x00000000
include/hw/i386/apic.h +6 -0
@@ -1,6 +1,12 @@#ifndef APIC_H #define APIC_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for X86CPU, target_ulong, +TPRAccess */ +#include "qemu-common.h" /* apic.c */
include/hw/i386/apic_internal.h +6 -0
@@ -20,6 +20,12 @@#ifndef QEMU_APIC_INTERNAL_H #define QEMU_APIC_INTERNAL_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for X86CPU, target_ulong, +TPRAccess */ +#include "exec/memory.h" #include "hw/cpu/icc_bus.h" #include "qemu/timer.h"
include/hw/xen/xen.h +1 -1
@@ -9,7 +9,7 @@#include <inttypes.h> #include "hw/irq.h" -#include "qemu-common.h" +#include "exec/cpu-common.h" /* for ram_addr_t */ /* xen-machine.c */ enum xen_mode {
include/migration/vmstate.h +11 -0
@@ -138,8 +138,19 @@ struct VMStateDescription {#ifdef CONFIG_USER_ONLY extern const VMStateDescription vmstate_dummy; +#define vmstate_cpu_common vmstate_dummy +#else +extern const struct VMStateDescription vmstate_cpu_common;#endif +#define VMSTATE_CPU () { \ + .name = "parent_obj", \ + .size = sizeof(CPUState), \ + .vmsd = &vmstate_cpu_common, \ + .flags = VMS_STRUCT, \ + .offset = 0, \ +} +extern const VMStateInfo vmstate_info_bool;extern const VMStateInfo vmstate_info_int8;
include/qemu-common.h +0 -11
@@ -111,11 +111,6 @@ extern int use_icount;#include "qemu/osdep.h" #include "qemu/bswap.h" -/* FIXME: Remove NEED_CPU_H. */ -#ifdef NEED_CPU_H -#include "cpu.h" -#endif /* !defined(NEED_CPU_H) */ -/* main function, renamed */ #if defined(CONFIG_COCOA )int qemu_main (int argc,char **argv,char **envp);
@@ -273,12 +268,6 @@ bool tcg_enabled(void);void cpu_exec_init_all (void ); -/* CPU save/load. */ -#ifdef CPU_SAVE_VERSION -void cpu_save (QEMUFile *f,void *opaque); -int cpu_load (QEMUFile *f,void *opaque,int version_id); -#endif -/* Unblock cpu */ void qemu_cpu_kick_self (void );
include/qom/cpu.h +0 -14
@@ -510,18 +510,4 @@ void qemu_init_vcpu(CPUState *cpu);*/ void cpu_single_step (CPUState *cpu,int enabled); -#ifdef CONFIG_SOFTMMU -extern const struct VMStateDescription vmstate_cpu_common; -#else -#define vmstate_cpu_common vmstate_dummy -#endif - -#define VMSTATE_CPU () { \ - .name = "parent_obj", \ - .size = sizeof(CPUState), \ - .vmsd = &vmstate_cpu_common, \ - .flags = VMS_STRUCT, \ - .offset = 0, \ -} -#endif
include/sysemu/kvm.h +10 -0
@@ -19,6 +19,15 @@#include "qemu/queue.h" #include "qom/cpu.h" +/* Ideally, for every appearance of NEED_CPU_H, there must be followed by +* the inclusion of "target-xxx/cpu.h". +* +* FIXME: find another logic other than using NEED_CPU_H. +*/ +#ifdef NEED_CPU_H +#include "config-target.h" /* for CONFIG_KVM */ +#endif +#ifdef CONFIG_KVM #include <linux/kvm.h> #include <linux/kvm_para.h>
@@ -169,6 +178,7 @@ int kvm_init_vcpu(CPUState *cpu);int kvm_cpu_exec (CPUState *cpu);#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong */ void kvm_setup_guest_memory (void *start,size_t size);void kvm_flush_coalesced_mmio_buffer (void );
tcg/tcg.h +6 -0
@@ -29,6 +29,12 @@#include "qemu/bitops.h" #include "tcg-target.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState, +TARGET_LONG_BITS in tcg-opc.h */ +/* Default target word size to pointer size. */ #ifndef TCG_TARGET_REG_BITS # if UINTPTR_MAX ==UINT32_MAX
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Hi,
in general I agree with this patch. I have a few comments, and I suggest that you split it in multiple patches so that it's easier to get it in when each part is ready.
hw/dma/soc_dma.c line 26
Quoted 11 lines
hw/dma/soc_dma.c +3
-0@@ -21,6 +21,11 @@#include "qemu/timer.h" #include "hw/arm/soc_dma.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif
Not needed; include/exec/cpu-defs.h already has a similar #error.
hw/dma/soc_dma.c line 27
Quoted 1 line
hw/dma/soc_dma.c +1
-0+#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_FMT_lx etc */
Space line below the #include, not above.
Quoted 20 lines
hw/dma/soc_dma.c +0
-0static void transfer_mem2mem (struct soc_dma_ch_s *ch) {memcpy (ch->paddr[0 ], ch->paddr[1 ], ch->bytes);include/disas/disas.h +2
-2@@ -1,9 +1,9 @@#ifndef _QEMU_DISAS_H#define _QEMU_DISAS_H -#include "qemu-common.h" -#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ /* Disassemble this for me please... (debugging). */ void disas (FILE *out,void *code,unsigned long size); void target_disas(FILE *out, CPUArchState *env, target_ulong code,
include/disas/disas.h void monitor_disas(Monitor *mon, CPUArchState *env, · line 17
Quoted 5 lines
include/disas/disas.h +1
-1@@ -14,7 +14,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,/* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr); -#endif +#endif /* NEED_CPU_H */
Perhaps the file that includes disas/disas.h can instead include cpu.h too? Most of them already do:
$ git grep -L include.*cpu.h $(git grep -l disas/disas.h) bsd-user/elfload.c hw/core/loader.c linux-user/elfload.c vl.c
Of these, vl.c and linux-user/elfload.c should not include disas/disas.h at all, and hw/core/loader.c is !NEED_CPU_H. So there are just two files where you can add a #include "cpu.h" manually.
Quoted 7 lines
include/disas/disas.h +0
-0struct syminfo ;struct elf32_sym ;include/exec/cpu-all.h +0
-0
include/exec/cpu-all.h void qemu_mutex_unlock_ramlist(void); · line 497
Quoted 8 lines
include/exec/cpu-all.h +5
-0@@ -490,4 +490,10 @@ void qemu_mutex_unlock_ramlist(void);int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,int is_write); +/* CPU save/load. */ +#ifdef CPU_SAVE_VERSION +void cpu_save (QEMUFile *f,void *opaque); +int cpu_load (QEMUFile *f,void *opaque,int version_id); +#endif
Good.
Quoted 15 lines
include/exec/cpu-all.h +0
-0#endif /* CPU_ALL_H */ include/exec/gdbstub.h +2
-0@@ -11,6 +11,8 @@#define GDB_WATCHPOINT_ACCESS 4#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ typedef void (*gdb_syscall_complete_cb )(CPUState *cpu,target_ulong ret,target_ulong err);
include/exec/gdbstub.h static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val) · line 84
Quoted 8 lines
include/exec/gdbstub.h +1
-1@@ -76,7 +78,7 @@ static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)#define ldtul_p (addr) ldl_p(addr)#endif -#endif +#endif /* NEED_CPU_H */ #ifdef CONFIG_USER_ONLY int gdbserver_start (int );
Same here: I'd rather add a cpu.h inclusion to the following files:
cpus.ctarget-alpha/gdbstub.ctarget-arm/gdbstub.ctarget-arm/gdbstub64.ctarget-cris/gdbstub.ctarget-i386/gdbstub.ctarget-lm32/gdbstub.ctarget-m68k/gdbstub.ctarget-microblaze/gdbstub.ctarget-mips/gdbstub.ctarget-openrisc/gdbstub.ctarget-ppc/gdbstub.ctarget-ppc/translate_init.ctarget-s390x/gdbstub.ctarget-sh4/gdbstub.ctarget-sparc/gdbstub.ctarget-xtensa/gdbstub.c
include/exec/ram_addr.h line 25
Quoted 12 lines
include/exec/ram_addr.h +4
-0@@ -19,6 +19,11 @@#ifndef RAM_ADDR_H #define RAM_ADDR_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_PAGE_BITS etc */
As above, this #ifndef is not needed.
Quoted 9 lines
include/exec/ram_addr.h +0
-0#ifndef CONFIG_USER_ONLY #include "hw/xen/xen.h" include/hw/arm/omap.h +0
-0@@ -17,10 +17,16 @@* with this program; if not, see <http://www.gnu.org/licenses/>.
include/hw/arm/omap.h line 27
Quoted 10 lines
include/hw/arm/omap.h +4
-0*/ #ifndef hw_omap_h +#include "exec/memory.h" # define hw_omap_h "omap.h"#include "hw/irq.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif
#ifndef not needed.
Quoted 10 lines
include/hw/arm/omap.h +2
-0+#include "cpu.h" /* target-xxx/cpu.h, required for ARMCPU etc */ +# define OMAP_EMIFS_BASE 0x00000000# define OMAP2_Q0_BASE 0x00000000# define OMAP_CS0_BASE 0x00000000include/hw/i386/apic.h +0
-0
include/hw/i386/apic.h line 6
Quoted 6 lines
include/hw/i386/apic.h +3
-0@@ -1,6 +1,12 @@#ifndef APIC_H #define APIC_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif
#ifndef not needed.
include/hw/i386/apic.h line 8
Quoted 2 lines
include/hw/i386/apic.h +2
-0+#include "cpu.h" /* target-xxx/cpu.h, required for X86CPU, target_ulong, +TPRAccess */
Should be included after qemu-common.h.
Quoted 8 lines
include/hw/i386/apic.h +0
-0#include "qemu-common.h" /* apic.c */ include/hw/i386/apic_internal.h +0
-0
include/hw/i386/apic_internal.h line 25
Quoted 6 lines
include/hw/i386/apic_internal.h +3
-0@@ -20,6 +20,12 @@#ifndef QEMU_APIC_INTERNAL_H #define QEMU_APIC_INTERNAL_H +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif
#ifndef not needed.
Quoted 11 lines
include/hw/i386/apic_internal.h +3
-0+#include "cpu.h" /* target-xxx/cpu.h, required for X86CPU, target_ulong, +TPRAccess */ +#include "exec/memory.h" #include "hw/cpu/icc_bus.h" #include "qemu/timer.h" include/hw/xen/xen.h +0
-0
include/hw/xen/xen.h line 12
Quoted 5 lines
include/hw/xen/xen.h +1
-1@@ -9,7 +9,7 @@#include <inttypes.h> #include "hw/irq.h" -#include "qemu-common.h" +#include "exec/cpu-common.h" /* for ram_addr_t */
Ok.
Quoted 31 lines
include/hw/xen/xen.h +0
-0/* xen-machine.c */ enum xen_mode {include/migration/vmstate.h +11
-0@@ -138,8 +138,19 @@ struct VMStateDescription {#ifdef CONFIG_USER_ONLY extern const VMStateDescription vmstate_dummy; +#define vmstate_cpu_common vmstate_dummy +#else +extern const struct VMStateDescription vmstate_cpu_common;#endif +#define VMSTATE_CPU () { \ + .name = "parent_obj", \ + .size = sizeof(CPUState), \ + .vmsd = &vmstate_cpu_common, \ + .flags = VMS_STRUCT, \ + .offset = 0, \ +} +extern const VMStateInfo vmstate_info_bool;extern const VMStateInfo vmstate_info_int8;include/qemu-common.h +0
-0
include/qemu-common.h extern int use_icount; · line 117
Quoted 7 lines
include/qemu-common.h +0
-4@@ -111,11 +111,6 @@ extern int use_icount;#include "qemu/osdep.h" #include "qemu/bswap.h" -/* FIXME: Remove NEED_CPU_H. */ -#ifdef NEED_CPU_H -#include "cpu.h" -#endif /* !defined(NEED_CPU_H) */
Ok.
include/qemu-common.h bool tcg_enabled(void); · line 281
Quoted 13 lines
include/qemu-common.h +0
-6/* main function, renamed */ #if defined(CONFIG_COCOA )int qemu_main (int argc,char **argv,char **envp);@@ -273,12 +268,6 @@ bool tcg_enabled(void);void cpu_exec_init_all (void ); -/* CPU save/load. */ -#ifdef CPU_SAVE_VERSION -void cpu_save (QEMUFile *f,void *opaque); -int cpu_load (QEMUFile *f,void *opaque,int version_id); -#endif -
Ok.
Quoted 15 lines
include/qemu-common.h +0
-0/* Unblock cpu */ void qemu_cpu_kick_self (void );include/qom/cpu.h +0
-4@@ -510,18 +510,4 @@ void qemu_init_vcpu(CPUState *cpu);*/ void cpu_single_step (CPUState *cpu,int enabled); -#ifdef CONFIG_SOFTMMU -extern const struct VMStateDescription vmstate_cpu_common; -#else -#define vmstate_cpu_common vmstate_dummy
include/qom/cpu.h void qemu_init_vcpu(CPUState *cpu); · line 526
Quoted 10 lines
include/qom/cpu.h +0
-10-#endif - -#define VMSTATE_CPU () { \ - .name = "parent_obj", \ - .size = sizeof(CPUState), \ - .vmsd = &vmstate_cpu_common, \ - .flags = VMS_STRUCT, \ - .offset = 0, \ -} -
Like Andreas I don't like this particularly. You can add migration/vmstate.h to qom/cpu.h instead.
Quoted 7 lines
include/qom/cpu.h +0
-0#endif include/sysemu/kvm.h +0
-0@@ -19,6 +19,15 @@#include "qemu/queue.h"
include/sysemu/kvm.h line 29
Quoted 10 lines
include/sysemu/kvm.h +8
-0#include "qom/cpu.h" +/* Ideally, for every appearance of NEED_CPU_H, there must be followed by +* the inclusion of "target-xxx/cpu.h". +* +* FIXME: find another logic other than using NEED_CPU_H. +*/ +#ifdef NEED_CPU_H +#include "config-target.h" /* for CONFIG_KVM */ +#endif
I think this is okay.
include/sysemu/kvm.h int kvm_init_vcpu(CPUState *cpu); · line 184
Quoted 12 lines
include/sysemu/kvm.h +2
-0+#ifdef CONFIG_KVM #include <linux/kvm.h> #include <linux/kvm_para.h> @@ -169,6 +178,7 @@ int kvm_init_vcpu(CPUState *cpu);int kvm_cpu_exec (CPUState *cpu);#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong */ void kvm_setup_guest_memory (void *start,size_t size);void kvm_flush_coalesced_mmio_buffer (void );
Perhaps move debugging-related definitions to a new file sysemu/kvm-debug.h and include it only from gdbstub.c, kvm-all.c, kvm-stub.c, target-*/kvm.c.
tcg/tcg.h line 36
Quoted 13 lines
tcg/tcg.h +5
-0@@ -29,6 +29,12 @@#include "qemu/bitops.h" #include "tcg-target.h" +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState, +TARGET_LONG_BITS in tcg-opc.h */
#ifndef not needed.
Paolo
Quoted 4 lines
tcg/tcg.h +0
-0/* Default target word size to pointer size. */ #ifndef TCG_TARGET_REG_BITS # if UINTPTR_MAX ==UINT32_MAX
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Hi Paolo, thanks for reviewing.
Quoted 3 lines · Paolo Bonzini
Hi,
in general I agree with this patch. I have a few comments, and I suggest that you split it in multiple patches so that it's easier to get it in when each part is ready.
I spent some time trying to reduce it. I may be wrong, but this is the smallest patch I can get to get all targets (linuxuser vs softmmu, kvm enable/disable) build.
Quoted 9 lines
Quoted 9 lines
hw/dma/soc_dma.c +0
-0@@ -21,6 +21,11 @@#include "qemu/timer.h" #include "hw/arm/soc_dma.h"
Quoted 6 lines
Quoted 4 lines
hw/dma/soc_dma.c +2
-0+#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific arerequired
+#endifNot needed;
include/exec/cpu-defs.halready has a similar #error.
I guess this is my personal preference.
My original idea is to emphasize that this *whole* file is "target-specific", as "target-independent" vs "target-specific" is important for qemu framework (everything except target-xxx, tcg backend and hw/arch*/). Ideally all qemu framework is designed to be target-independent, right?
In my docs/api-hierarchy.txt, I am trying my best to illustrate what are "target-independent", and what are "target-specific".
cpu-defs.h is NOT included in this file.
The idea is the same for the rest "#ifndef NEED_CPU_H"
Why use "#ifndef NEED_CPU_H, then #error ...", is because
"target-xxx/cpu.h"
is better included for the whole file.
If "target-xxx/cpu.h" is only needed for part of the file, use "#ifdef NEED_CPU_H, then #include "cpu.h"".
Thanks.
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
In reply to Paolo BonziniQuoted 26 lines
Quoted 18 lines
include/disas/disas.h +2
-2@@ -1,9 +1,9 @@#ifndef _QEMU_DISAS_H#define _QEMU_DISAS_H -#include "qemu-common.h" -#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ /* Disassemble this for me please... (debugging). */ void disas (FILE *out,void *code,unsigned long size); void target_disas(FILE *out, CPUArchState *env, target_ulong code,include/disas/disas.h void monitor_disas(Monitor *mon, CPUArchState *env, · line 17
Quoted 5 lines
include/disas/disas.h +1
-1@@ -14,7 +14,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,/* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr); -#endif +#endif /* NEED_CPU_H */ Perhaps the file that includes
disas/disas.hcan instead includecpu.htoo? Most of them already do:
Quoted 8 lines
$ git grep -L include.*cpu.h $(git grep -l disas/disas.h) bsd-user/elfload.c hw/core/loader.c linux-user/elfload.c vl.cOf these,
vl.candlinux-user/elfload.cshould not includedisas/disas.hat all, andhw/core/loader.cis !NEED_CPU_H. So there are just two files where you can add a #include "cpu.h" manually.
My idea is to keep disas/disas.h correct just by itself, regardless how it's used by *.c files.
I have almost zero knowledge about static code analyzer, I am not sure whether disas.h can pass it without including "cpu.h"
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Il 04/03/2014 13:02, Xuebing wang ha scritto:
Quoted 8 lines
Quoted 5 lines
Of these,
vl.candlinux-user/elfload.cshould not includedisas/disas.hat all, andhw/core/loader.cis !NEED_CPU_H. So there are just two files where you can add a #include "cpu.h" manually.My idea is to keep
disas/disas.hcorrect just by itself, regardless how it's used by *.c files.
In general, it's a good idea to make headers self-contained by recursively including whatever's necessary.
However, there are a few very central headers that are just too complicated to make self-consistent without introducing circular references.
In particular, for QEMU these are qemu-common.h and cpu.h (and also others, such as exec-all.h but perhaps the solution there is to split them). It's much simpler to ask people to include these two files in the C files.
Paolo
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
In reply to Paolo BonziniQuoted 37 lines
Quoted 24 lines
include/exec/gdbstub.h +3
-1@@ -11,6 +11,8 @@#define GDB_WATCHPOINT_ACCESS 4#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ typedef void (*gdb_syscall_complete_cb )(CPUState *cpu,target_ulong ret,target_ulong err);@@ -76,7 +78,7 @@ static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val)#define ldtul_p (addr) ldl_p(addr)#endif -#endif +#endif /* NEED_CPU_H */ #ifdef CONFIG_USER_ONLY Quoted 1 line
int
gdbserver_start(int);Same here: I'd rather add a
cpu.hinclusion to the following files:
cpus.ctarget-alpha/gdbstub.ctarget-arm/gdbstub.ctarget-arm/gdbstub64.ctarget-cris/gdbstub.ctarget-i386/gdbstub.ctarget-lm32/gdbstub.ctarget-m68k/gdbstub.ctarget-microblaze/gdbstub.c
Quoted 9 lines
target-mips/gdbstub.ctarget-openrisc/gdbstub.ctarget-ppc/gdbstub.ctarget-ppc/translate_init.ctarget-s390x/gdbstub.ctarget-sh4/gdbstub.ctarget-sparc/gdbstub.ctarget-xtensa/gdbstub.c
I personally prefer keeping gdbstub.h correct by itself. I am not sure if this is only my personal preference or not.
target-*/gdbstub.c implementers only need to know gdbstub hooks (thus gdbstub API), they don't care "cpu.h", although knowledge of "cpu.h" helps.
Agree?
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Quoted 2 lines · Xuebing wang
target-*/gdbstub.cimplementers only need to know gdbstub hooks (thus gdbstub API), they don't care "cpu.h", although knowledge of "cpu.h" helps.
The gdbstub.c code is just a tiny part of the target-* frontend; there is no way that anybody working on the gdbstub isn't going to know already about the cpu.h interfaces. In particular, the code in those files is generally implementing the gdbstub interfaces by looking at the internal details of the target CPU. The only reason they don't just include cpu.h is simply that at the moment qemu-common.h does it for them.
thanks
-- PMM
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Hi Peter,
Thanks. You are correct, I don't know what I was thinking. :-)
Quoted 14 lines · Peter Maydell
Quoted 2 lines · Xuebing wang
target-*/gdbstub.cimplementers only need to know gdbstub hooks (thus gdbstub API), they don't care "cpu.h", although knowledge of "cpu.h" helps.The
gdbstub.ccode is just a tiny part of the target-* frontend; there is no way that anybody working on the gdbstub isn't going to know already about thecpu.hinterfaces. In particular, the code in those files is generally implementing the gdbstub interfaces by looking at the internal details of the target CPU. The only reason they don't just includecpu.his simply that at the momentqemu-common.hdoes it for them.thanks
-- PMM
Signature · 2 lines
Thanks, Xuebing Wang
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
In reply to Paolo BonziniQuoted 19 lines
Quoted 19 lines
index 367eda1..f0157e3 100644
include/qom/cpu.h +0
-10@@ -510,18 +510,4 @@ void qemu_init_vcpu(CPUState *cpu);*/ void cpu_single_step (CPUState *cpu,int enabled); -#ifdef CONFIG_SOFTMMU -extern const struct VMStateDescription vmstate_cpu_common; -#else -#define vmstate_cpu_common vmstate_dummy -#endif - -#define VMSTATE_CPU () { \ - .name = "parent_obj", \ - .size = sizeof(CPUState), \ - .vmsd = &vmstate_cpu_common, \
Quoted 9 lines
include/qom/cpu.h void qemu_init_vcpu(CPUState *cpu); · line 526
Quoted 6 lines
include/qom/cpu.h +0
-1- .flags =
VMS_STRUCT, \
- .offset =
0, \include/qom/cpu.h +0
-2-} -Like Andreas I don't like this particularly. You can add
migration/vmstate.htoqom/cpu.hinstead.
In my humble opinion, qom/cpu is part of virtual machine along with other hw peripherals, thus I'd prefer vmstate to depend on qom/cpu.
From object oriented design perspective, qom/cpu is one-level lower than the modeling of virtual machine, do you agree?
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Il 04/03/2014 13:19, Xuebing wang ha scritto:
Quoted 10 lines
Quoted 4 lines
Like Andreas I don't like this particularly. You can add
migration/vmstate.htoqom/cpu.hinstead.In my humble opinion, qom/cpu is part of virtual machine along with other hw peripherals, thus I'd prefer vmstate to depend on qom/cpu.
From object oriented design perspective, qom/cpu is one-level lower than the modeling of virtual machine, do you agree?
vmstate is just the name of the infrastructure that takes a description of a struct's fields and serializes it onto a QEMUFile. If you look at include/migration, there's nothing that is specific to virtual machines except perhaps the declaration of two functions vmstate_register_ram and vmstate_unregister_ram.
Paolo
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
In reply to Paolo BonziniQuoted 7 lines
Quoted 7 lines
#ifdef
CONFIG_KVM
#include <linux/kvm.h>
#include <linux/kvm_para.h>include/sysemu/kvm.h +0
-0@@ -169,6 +178,7 @@ int kvm_init_vcpu(CPUState *cpu);int kvm_cpu_exec (CPUState *cpu);
Quoted 8 lines
include/sysemu/kvm.h int kvm_init_vcpu(CPUState *cpu); · line 184
Quoted 5 lines
include/sysemu/kvm.h +1
-0#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong */ void kvm_setup_guest_memory (void *start,size_t size);void kvm_flush_coalesced_mmio_buffer (void );Perhaps move debugging-related definitions to a new file
sysemu/kvm-debug.hand include it only fromgdbstub.c,kvm-all.c,kvm-stub.c,target-*/kvm.c.
Thanks for suggestion. This patch is strictly confined to "NEED_CPU_H" and making qemu build. :-)
Re: [Qemu-devel] [Discussion 02/10] NEED_CPU_H: remove '#include "cpu.h"' from include/qemu-common.h
Il 04/03/2014 13:26, Xuebing wang ha scritto:
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
#ifdef
NEED_CPU_H
+#include "cpu.h" /*target-xxx/cpu.h, required fortarget_ulong*/void
kvm_setup_guest_memory(void *start, size_t size); voidkvm_flush_coalesced_mmio_buffer(void);
Quoted 7 lines
Quoted 4 lines
Perhaps move debugging-related definitions to a new file
sysemu/kvm-debug.hand include it only fromgdbstub.c,kvm-all.c,kvm-stub.c,target-*/kvm.c.Thanks for suggestion. This patch is strictly confined to "
NEED_CPU_H" and making qemu build. :-)
Making QEMU build is not a good idea if it complicates things. Adding dependencies to a file complicates things. What you're doing here is taking dependencies out of one central file (qemu-common.h) and adding it to a dozen peripheral files. This complicates things.
Removing "#ifdef NEED_CPU_H" can be a good idea, but it has to make things simpler, otherwise it is not a good idea anymore.
Paolo
PATCH 3/10 NEED_CPU_H: remove unnecessary use of NEED_CPU_H
In reply to Xuebing WangNote: there is a FIXME to be addressed in this patch.
For every appearance of NEED_CPU_H, there must be '#include "cpu.h"' to include "target-xxx/cpu.h", because the code below NEED_CPU_H depends on architecture-specific information.
--- include/exec/cpu-common.h | 5 +++++ include/hw/hw.h | 13 +++++++++---- include/hw/xen/xen.h | 2 +- include/qemu/log.h | 7 ++++--- include/sysemu/kvm.h | 2 +- ui/input.c | 2 -- 6 files changed, 20 insertions(+), 11 deletions(-)
include/exec/cpu-common.h +5 -0
@@ -98,6 +98,11 @@ void stl_be_phys(AddressSpace *as, hwaddr addr, uint32_t val);void stq_le_phys (AddressSpace *as,hwaddr addr,uint64_t val);void stq_be_phys (AddressSpace *as,hwaddr addr,uint64_t val); +/* +* FIXME: although it's nice to keep ld/st APIs together with above, +* below violates the idea that every NEED_CPU_H should be followed +* by inclusion of "target-xxx/cpu.h" +*/ #ifdef NEED_CPU_H uint32_t lduw_phys (AddressSpace *as,hwaddr addr);uint32_t ldl_phys (AddressSpace *as,hwaddr addr);
include/hw/hw.h +9 -4
@@ -4,7 +4,7 @@#include "qemu-common.h" -#if !defined(CONFIG_USER_ONLY ) && !defined(NEED_CPU_H ) +#if !defined(CONFIG_USER_ONLY )#include "exec/cpu-common.h" #endif
@@ -15,6 +15,8 @@#include "qemu/log.h" #ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_LONG_BITS */ +#if TARGET_LONG_BITS ==64 #define qemu_put_betl qemu_put_be64#define qemu_get_betl qemu_get_be64
@@ -34,7 +36,7 @@#define qemu_put_sbetls qemu_put_sbe32s#define qemu_get_sbetls qemu_get_sbe32s#endif -#endif +#endif /* NEED_CPU_H */ typedef void QEMUResetHandler (void *opaque);
@@ -48,6 +50,8 @@ void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);int qemu_boot_set (const char *boot_order);#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_LONG_BITS */ +#if TARGET_LONG_BITS ==64 #define VMSTATE_UINTTL_V (_f, _s, _v) \ VMSTATE_UINT64_V(_f, _s, _v)
@@ -63,6 +67,7 @@ int qemu_boot_set(const char *boot_order);#define VMSTATE_UINTTL_ARRAY_V (_f, _s, _n, _v) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)#endif +#define VMSTATE_UINTTL (_f, _s) \ VMSTATE_UINTTL_V(_f, _s, 0)#define VMSTATE_UINTTL_EQUAL (_f, _s) \
@@ -70,6 +75,6 @@ int qemu_boot_set(const char *boot_order);#define VMSTATE_UINTTL_ARRAY (_f, _s, _n) \ VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0) -#endif +#endif /* NEED_CPU_H */ -#endif +#endif /* QEMU_HW_H */
include/hw/xen/xen.h +1 -1
@@ -40,7 +40,7 @@ int xen_init(void);int xen_hvm_init (MemoryRegion **ram_memory);void xenstore_store_pv_console_info (int i,struct CharDriverState *chr); -#if defined(NEED_CPU_H ) && !defined(CONFIG_USER_ONLY ) +#if !defined(CONFIG_USER_ONLY )void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size,struct MemoryRegion *mr);void xen_modified_memory (ram_addr_t start,ram_addr_t length);
include/qemu/log.h +4 -3
@@ -6,9 +6,7 @@#include <stdio.h> #include "qemu/compiler.h" #include "qom/cpu.h" -#ifdef NEED_CPU_H #include "disas/disas.h" -#endif /* Private global variables, don't use */ extern FILE *qemu_logfile;
@@ -102,6 +100,9 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) }#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ +/* disas() and target_disas() to qemu_logfile: */ static inline void log_target_disas (CPUArchState *env,target_ulong start,target_ulong len,int flags)
@@ -121,7 +122,7 @@ static inline void log_page_dump(void)page_dump (qemu_logfile); }#endif -#endif +#endif /* NEED_CPU_H */ /* Maintenance: */
include/sysemu/kvm.h +1 -1
@@ -58,7 +58,7 @@ extern bool kvm_gsi_routing_allowed;extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed; -#if definedCONFIG_KVM || !definedNEED_CPU_H +#if definedCONFIG_KVM #define kvm_enabled () (kvm_allowed)/** * kvm_irqchip_in_kernel:
ui/input.c +0 -2
@@ -187,7 +187,6 @@ static const int key_defs[] = { [Q_KEY_CODE_INSERT] = 0xd2, [Q_KEY_CODE_DELETE ] =0xd3 , -#ifdef NEED_CPU_H #if defined(TARGET_SPARC) && !defined(TARGET_SPARC64) [Q_KEY_CODE_STOP] = 0xf0, [Q_KEY_CODE_AGAIN] = 0xf1,
@@ -205,7 +204,6 @@ static const int key_defs[] = { [Q_KEY_CODE_META_R] = 0xfd, [Q_KEY_CODE_COMPOSE] = 0xfe, #endif -#endif [Q_KEY_CODE_MAX] = 0, };
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 03/10] NEED_CPU_H: remove unnecessary use of NEED_CPU_H
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 7 lines
Note: there is a FIXME to be addressed in this patch.
For every appearance of
NEED_CPU_H, there must be '#include "cpu.h"' to include "target-xxx/cpu.h", because the code belowNEED_CPU_Hdepends on architecture-specific information.Signed-off-by Xuebing Wang <[email protected]>
Here I disagree. I think that if cpu.h is needed by a header, it should be included by whoever needs that header.
Quoted 133 lines
--- include/exec/cpu-common.h | 5 +++++ include/hw/hw.h | 13 +++++++++---- include/hw/xen/xen.h | 2 +- include/qemu/log.h | 7 ++++--- include/sysemu/kvm.h | 2 +- ui/input.c | 2 -- 6 files changed, 20 insertions(+), 11 deletions(-)include/exec/cpu-common.h +5
-0@@ -98,6 +98,11 @@ void stl_be_phys(AddressSpace *as, hwaddr addr, uint32_t val);void stq_le_phys (AddressSpace *as,hwaddr addr,uint64_t val);void stq_be_phys (AddressSpace *as,hwaddr addr,uint64_t val); +/* +* FIXME: although it's nice to keep ld/st APIs together with above, +* below violates the idea that every NEED_CPU_H should be followed +* by inclusion of "target-xxx/cpu.h" +*/ #ifdef NEED_CPU_H uint32_t lduw_phys (AddressSpace *as,hwaddr addr);uint32_t ldl_phys (AddressSpace *as,hwaddr addr);include/hw/hw.h +9
-4@@ -4,7 +4,7 @@#include "qemu-common.h" -#if !defined(CONFIG_USER_ONLY ) && !defined(NEED_CPU_H ) +#if !defined(CONFIG_USER_ONLY )#include "exec/cpu-common.h" #endif @@ -15,6 +15,8 @@#include "qemu/log.h" #ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_LONG_BITS */ +#if TARGET_LONG_BITS ==64 #define qemu_put_betl qemu_put_be64#define qemu_get_betl qemu_get_be64@@ -34,7 +36,7 @@#define qemu_put_sbetls qemu_put_sbe32s#define qemu_get_sbetls qemu_get_sbe32s#endif -#endif +#endif /* NEED_CPU_H */ typedef void QEMUResetHandler (void *opaque);@@ -48,6 +50,8 @@ void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);int qemu_boot_set (const char *boot_order);#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for TARGET_LONG_BITS */ +#if TARGET_LONG_BITS ==64 #define VMSTATE_UINTTL_V (_f, _s, _v) \ VMSTATE_UINT64_V(_f, _s, _v)@@ -63,6 +67,7 @@ int qemu_boot_set(const char *boot_order);#define VMSTATE_UINTTL_ARRAY_V (_f, _s, _n, _v) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)#endif +#define VMSTATE_UINTTL (_f, _s) \ VMSTATE_UINTTL_V(_f, _s, 0)#define VMSTATE_UINTTL_EQUAL (_f, _s) \@@ -70,6 +75,6 @@ int qemu_boot_set(const char *boot_order);#define VMSTATE_UINTTL_ARRAY (_f, _s, _n) \ VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0) -#endif +#endif /* NEED_CPU_H */ -#endif +#endif /* QEMU_HW_H */ include/hw/xen/xen.h +1
-1@@ -40,7 +40,7 @@ int xen_init(void);int xen_hvm_init (MemoryRegion **ram_memory);void xenstore_store_pv_console_info (int i,struct CharDriverState *chr); -#if defined(NEED_CPU_H ) && !defined(CONFIG_USER_ONLY ) +#if !defined(CONFIG_USER_ONLY )void xen_ram_alloc (ram_addr_t ram_addr,ram_addr_t size,struct MemoryRegion *mr);void xen_modified_memory (ram_addr_t start,ram_addr_t length);include/qemu/log.h +4
-3@@ -6,9 +6,7 @@#include <stdio.h> #include "qemu/compiler.h" #include "qom/cpu.h" -#ifdef NEED_CPU_H #include "disas/disas.h" -#endif /* Private global variables, don't use */ extern FILE *qemu_logfile;@@ -102,6 +100,9 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) }#ifdef NEED_CPU_H +#include "cpu.h" /* target-xxx/cpu.h, required for target_ulong, +CPUArchState */ +/* disas() and target_disas() to qemu_logfile: */ static inline void log_target_disas (CPUArchState *env,target_ulong start,target_ulong len,int flags)@@ -121,7 +122,7 @@ static inline void log_page_dump(void)page_dump (qemu_logfile); }#endif -#endif +#endif /* NEED_CPU_H */ /* Maintenance: */ include/sysemu/kvm.h +0
-0
include/sysemu/kvm.h extern bool kvm_gsi_routing_allowed; · line 62
Quoted 6 lines
include/sysemu/kvm.h +1
-1@@ -58,7 +58,7 @@ extern bool kvm_gsi_routing_allowed;extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed; -#if definedCONFIG_KVM || !definedNEED_CPU_H +#if definedCONFIG_KVM #define kvm_enabled () (kvm_allowed)
This is wrong. There are files that do not need cpu.h and need kvm_enabled().
Paolo
Quoted 23 lines
include/sysemu/kvm.h +0
-0/** * kvm_irqchip_in_kernel: ui/input.c +0
-2@@ -187,7 +187,6 @@ static const int key_defs[] = { [Q_KEY_CODE_INSERT] = 0xd2, [Q_KEY_CODE_DELETE ] =0xd3 , -#ifdef NEED_CPU_H #if defined(TARGET_SPARC) && !defined(TARGET_SPARC64) [Q_KEY_CODE_STOP] = 0xf0, [Q_KEY_CODE_AGAIN] = 0xf1,@@ -205,7 +204,6 @@ static const int key_defs[] = { [Q_KEY_CODE_META_R] = 0xfd, [Q_KEY_CODE_COMPOSE] = 0xfe, #endif -#endif [Q_KEY_CODE_MAX] = 0, };
PATCH 4/10 memory_mapping: make this architecture-independent
In reply to Xuebing WangUse vaddr (instead of target_ulong) for virtual address. See document HACKING for more information about vaddr and target_ulong.
--- include/sysemu/memory_mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/sysemu/memory_mapping.h +2 -1
@@ -16,6 +16,7 @@#include "qemu/queue.h" #include "qemu/typedefs.h" +#include "qom/cpu.h" /* for vaddr */ typedef struct GuestPhysBlock { /* visible to guest, reflects PCI hole, etc */
@@ -39,7 +40,7 @@ typedef struct GuestPhysBlockList {/* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping {hwaddr phys_addr; -target_ulong virt_addr; +vaddr virt_addr;ram_addr_t length;QTAILQ_ENTRY (MemoryMapping) next; }MemoryMapping ;
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 04/10] memory_mapping: make this architecture-independent
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 22 lines
Use vaddr (instead of
target_ulong) for virtual address. See document HACKING for more information about vaddr andtarget_ulong.Signed-off-by Xuebing Wang <[email protected]>--- include/sysemu/memory_mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/sysemu/memory_mapping.h +1
-0@@ -16,6 +16,7 @@#include "qemu/queue.h" #include "qemu/typedefs.h" +#include "qom/cpu.h" /* for vaddr */ typedef struct GuestPhysBlock { /* visible to guest, reflects PCI hole, etc */
include/sysemu/memory_mapping.h typedef struct GuestPhysBlockList { · line 46
Quoted 8 lines
include/sysemu/memory_mapping.h +1
-1@@ -39,7 +40,7 @@ typedef struct GuestPhysBlockList {/* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping {hwaddr phys_addr; -target_ulong virt_addr; +vaddr virt_addr;ram_addr_t length;QTAILQ_ENTRY (MemoryMapping) next; }MemoryMapping ;
Makes sense.
Paolo
Re: [Qemu-devel] [Discussion 04/10] memory_mapping: make this architecture-independent
In reply to Xuebing WangQuoted 30 lines · Xuebing Wang
Use vaddr (instead of
target_ulong) for virtual address. See document HACKING for more information about vaddr andtarget_ulong.Signed-off-by Xuebing Wang <[email protected]>--- include/sysemu/memory_mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/sysemu/memory_mapping.h +2
-2@@ -16,6 +16,7 @@#include "qemu/queue.h" #include "qemu/typedefs.h" +#include "qom/cpu.h" /* for vaddr */ typedef struct GuestPhysBlock { /* visible to guest, reflects PCI hole, etc */@@ -39,7 +40,7 @@ typedef struct GuestPhysBlockList {/* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping {hwaddr phys_addr; -target_ulong virt_addr; +vaddr virt_addr;ram_addr_t length;QTAILQ_ENTRY (MemoryMapping) next; }MemoryMapping ; --
Quoted 1 line
1.7.9.5
If we're going to do this we should be consistent in this API:
at the moment most of the functions (private or otherwise) in memory_mapping.c use "hwaddr" for virtual addresses. It seems like a good idea, though.
thanks
-- PMM
PATCH 5/10 NEED_CPU_H: remove unnecessary inclusion of "cpu.h" in root
In reply to Xuebing WangEnforce the strict associativity between NEED_CPU_H and "inclusion of cpu.h", for every appearance of '#include "cpu.h"', there must have the check of NEED_CPU_H, and conversely.
This patch only checks file in qemu root directory by:
grep -nw "cpu.h" *.[ch] .
Note: remove unnecessary inclusion of "cpu-all.h" too. "cpu-all.h" is architecture-specific, should ONLY be included from target-xxx/*
- 'git grep -nw "cpu-all.h"' confirms this
--- arch_init.c | 1 - cpu-exec.c | 7 ++++++- cputlb.c | 6 +++++- disas.c | 7 ++++++- dump.c | 2 -- exec.c | 2 -- gdbstub.c | 8 +++++++- kvm-stub.c | 1 - memory_mapping.c | 6 +++--- monitor.c | 1 - translate-all.c | 7 ++++++- user-exec.c | 7 ++++++- 12 files changed, 39 insertions(+), 16 deletions(-)
arch_init.c +0 -1
@@ -47,7 +47,6 @@#include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" -#include "exec/cpu-all.h" #include "exec/ram_addr.h" #include "hw/acpi/acpi.h" #include "qemu/host-utils.h"
cpu-exec.c +6 -1
@@ -16,8 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #include "qemu/atomic.h"
cputlb.c +5 -1
@@ -17,8 +17,12 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "exec/exec-all.h" #include "exec/memory.h" #include "exec/address-spaces.h"
disas.c +6 -1
@@ -1,10 +1,15 @@/* General "disassemble this chunk" code. Used for debugging. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" #include "disas/bfd.h" #include "elf.h" #include <errno.h> -#include "cpu.h" #include "disas/disas.h" typedef struct CPUDebug {
dump.c +0 -2
@@ -13,8 +13,6 @@#include "qemu-common.h" #include "elf.h" -#include "cpu.h" -#include "exec/cpu-all.h" #include "exec/hwaddr.h" #include "monitor/monitor.h" #include "sysemu/kvm.h"
exec.c +0 -2
@@ -25,7 +25,6 @@#endif #include "qemu-common.h" -#include "cpu.h" #include "tcg.h" #include "hw/hw.h" #include "hw/qdev.h"
@@ -44,7 +43,6 @@#include "sysemu/xen-mapcache.h" #include "trace.h" #endif -#include "exec/cpu-all.h" #include "exec/cputlb.h" #include "translate-all.h"
gdbstub.c +7 -1
@@ -16,6 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +/* TODO: to remove using CPUArchState to make thie file arch-independent. */ +#include "config.h" #include "qemu-common.h" #ifdef CONFIG_USER_ONLY
@@ -37,7 +44,6 @@#define MAX_PACKET_LENGTH 4096 -#include "cpu.h" #include "qemu/sockets.h" #include "sysemu/kvm.h"
kvm-stub.c +0 -1
@@ -12,7 +12,6 @@#include "qemu-common.h" #include "hw/hw.h" -#include "cpu.h" #include "sysemu/kvm.h" #ifndef CONFIG_USER_ONLY
memory_mapping.c +3 -3
@@ -13,11 +13,11 @@#include <glib.h> -#include "cpu.h" -#include "exec/cpu-all.h" -#include "sysemu/memory_mapping.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" /* for ram_addr_t */ #include "exec/memory.h" #include "exec/address-spaces.h" +#include "sysemu/memory_mapping.h" //#define DEBUG_GUEST_PHYS_REGION_ADD
monitor.c +0 -1
@@ -58,7 +58,6 @@#include "qapi/qmp/json-parser.h" #include <qom/object_interfaces.h> #include "qemu/osdep.h" -#include "cpu.h" #include "trace.h" #include "trace/control.h" #ifdef CONFIG_TRACE_SIMPLE
translate-all.c +6 -1
@@ -16,6 +16,12 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#ifdef _WIN32#include <windows.h> #else
@@ -32,7 +38,6 @@#include "qemu-common.h" #define NO_CPU_IO_DEFS -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #if defined(CONFIG_USER_ONLY )
user-exec.c +6 -1
@@ -16,8 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #include "qemu/bitops.h"
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 05/10] NEED_CPU_H: remove unnecessary inclusion of "cpu.h" in root
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 3 lines
Enforce the strict associativity between
NEED_CPU_Hand "inclusion ofcpu.h", for every appearance of '#include "cpu.h"', there must have the check ofNEED_CPU_H, and conversely.
As mentioned earlier, the #ifndef is unnecessary. It is already provided by include/exec/cpu-defs.h
Quoted 6 lines
This patch only checks file in qemu root directory by:
grep -nw "cpu.h" *.[ch] .Note: remove unnecessary inclusion of "
cpu-all.h" too. "cpu-all.h" is architecture-specific, should ONLY be included from target-xxx/*
- 'git grep -nw "cpu-all.h"' confirms this
Should be a separate patch. I agree with removing unnecessary #includes in general, but please check that the include is _really_ removed and not just included indirectly now.
Paolo
Quoted 233 lines
Signed-off-by Xuebing Wang <[email protected]>--- arch_init.c | 1 - cpu-exec.c | 7 ++++++- cputlb.c | 6 +++++- disas.c | 7 ++++++- dump.c | 2 -- exec.c | 2 -- gdbstub.c | 8 +++++++- kvm-stub.c | 1 - memory_mapping.c | 6 +++--- monitor.c | 1 - translate-all.c | 7 ++++++- user-exec.c | 7 ++++++- 12 files changed, 39 insertions(+), 16 deletions(-)arch_init.c +0
-1@@ -47,7 +47,6 @@#include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" -#include "exec/cpu-all.h" #include "exec/ram_addr.h" #include "hw/acpi/acpi.h" #include "qemu/host-utils.h" cpu-exec.c +6
-1@@ -16,8 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #include "qemu/atomic.h" cputlb.c +5
-1@@ -17,8 +17,12 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "exec/exec-all.h" #include "exec/memory.h" #include "exec/address-spaces.h" disas.c +6
-1@@ -1,10 +1,15 @@/* General "disassemble this chunk" code. Used for debugging. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" #include "disas/bfd.h" #include "elf.h" #include <errno.h> -#include "cpu.h" #include "disas/disas.h" typedef struct CPUDebug {dump.c +0
-2@@ -13,8 +13,6 @@#include "qemu-common.h" #include "elf.h" -#include "cpu.h" -#include "exec/cpu-all.h" #include "exec/hwaddr.h" #include "monitor/monitor.h" #include "sysemu/kvm.h" exec.c +0
-2@@ -25,7 +25,6 @@#endif #include "qemu-common.h" -#include "cpu.h" #include "tcg.h" #include "hw/hw.h" #include "hw/qdev.h" @@ -44,7 +43,6 @@#include "sysemu/xen-mapcache.h" #include "trace.h" #endif -#include "exec/cpu-all.h" #include "exec/cputlb.h" #include "translate-all.h" gdbstub.c +7
-1@@ -16,6 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +/* TODO: to remove using CPUArchState to make thie file arch-independent. */ +#include "config.h" #include "qemu-common.h" #ifdef CONFIG_USER_ONLY @@ -37,7 +44,6 @@#define MAX_PACKET_LENGTH 4096 -#include "cpu.h" #include "qemu/sockets.h" #include "sysemu/kvm.h" kvm-stub.c +0
-1@@ -12,7 +12,6 @@#include "qemu-common.h" #include "hw/hw.h" -#include "cpu.h" #include "sysemu/kvm.h" #ifndef CONFIG_USER_ONLY memory_mapping.c +3
-3@@ -13,11 +13,11 @@#include <glib.h> -#include "cpu.h" -#include "exec/cpu-all.h" -#include "sysemu/memory_mapping.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" /* for ram_addr_t */ #include "exec/memory.h" #include "exec/address-spaces.h" +#include "sysemu/memory_mapping.h" //#define DEBUG_GUEST_PHYS_REGION_ADD monitor.c +0
-1@@ -58,7 +58,6 @@#include "qapi/qmp/json-parser.h" #include <qom/object_interfaces.h> #include "qemu/osdep.h" -#include "cpu.h" #include "trace.h" #include "trace/control.h" #ifdef CONFIG_TRACE_SIMPLE translate-all.c +6
-1@@ -16,6 +16,12 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#ifdef _WIN32#include <windows.h> #else @@ -32,7 +38,6 @@#include "qemu-common.h" #define NO_CPU_IO_DEFS -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #if defined(CONFIG_USER_ONLY )user-exec.c +6
-1@@ -16,8 +16,13 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef NEED_CPU_H +#error target-xxx/cpu.h must be included because target-specific are required +#endif +#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ +#include "config.h" -#include "cpu.h" #include "disas/disas.h" #include "tcg.h" #include "qemu/bitops.h"
PATCH 6/10 memory: move contents in include/exec/address-spaces.h => memory.h
In reply to Xuebing WangIn preparation for removing include/exec/address-spaces.h
--- include/exec/address-spaces.h | 29 ----------------------------- include/exec/memory.h | 19 +++++++++++++++---- include/hw/sh4/sh_intc.h | 1 + 3 files changed, 16 insertions(+), 33 deletions(-)
include/exec/address-spaces.h +0 -29
@@ -10,32 +10,3 @@* 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
include/exec/memory.h +15 -4
@@ -25,9 +25,7 @@#include <stdbool.h> #include "qemu-common.h" #include "exec/cpu-common.h" -#ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" -#endif #include "qemu/queue.h" #include "qemu/int128.h" #include "qemu/notify.h"
@@ -1052,6 +1050,19 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, int is_write, hwaddr access_len); -#endif +/* 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 /* !CONFIG_USER_ONLY */ -#endif +#endif /* MEMORY_H */
include/hw/sh4/sh_intc.h +1 -0
@@ -4,6 +4,7 @@#include "qemu-common.h" #include "hw/irq.h" #include "exec/address-spaces.h" +#include "exec/memory.h" typedef unsigned char intc_enum ;
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 06/10] memory: move contents in include/exec/address-spaces.h => memory.h
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 1 line
In preparation for removing
include/exec/address-spaces.h
Why?
Paolo
Quoted 93 lines
Signed-off-by Xuebing Wang <[email protected]>--- include/exec/address-spaces.h | 29 ----------------------------- include/exec/memory.h | 19 +++++++++++++++---- include/hw/sh4/sh_intc.h | 1 + 3 files changed, 16 insertions(+), 33 deletions(-)include/exec/address-spaces.h +0
-29@@ -10,32 +10,3 @@* 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 include/exec/memory.h +15
-4@@ -25,9 +25,7 @@#include <stdbool.h> #include "qemu-common.h" #include "exec/cpu-common.h" -#ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" -#endif #include "qemu/queue.h" #include "qemu/int128.h" #include "qemu/notify.h" @@ -1052,6 +1050,19 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, int is_write, hwaddr access_len); -#endif +/* 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 /* !CONFIG_USER_ONLY */ -#endif +#endif /* MEMORY_H */ include/hw/sh4/sh_intc.h +1
-0@@ -4,6 +4,7 @@#include "qemu-common.h" #include "hw/irq.h" #include "exec/address-spaces.h" +#include "exec/memory.h" typedef unsigned char intc_enum ;
PATCH 7/10 memory: remove file include/exec/address-spaces.h
In reply to Xuebing WangRemove '#include "exec/address-spaces.h"' is done by:
git grep -w "exec\/address-spaces.h" | cut -d: -f1 |
xargs sed -i '/exec\/address-spaces.h/d'
--- arch_init.c | 1 - cputlb.c | 1 - exec.c | 1 - hw/acpi/ich9.c | 1 - hw/acpi/pcihp.c | 1 - hw/acpi/piix4.c | 1 - hw/alpha/typhoon.c | 1 - hw/arm/boot.c | 1 - hw/arm/collie.c | 1 - hw/arm/digic_boards.c | 1 - hw/arm/exynos4_boards.c | 1 - hw/arm/gumstix.c | 1 - hw/arm/highbank.c | 1 - hw/arm/integratorcp.c | 1 - hw/arm/kzm.c | 1 - hw/arm/mainstone.c | 1 - hw/arm/musicpal.c | 1 - hw/arm/nseries.c | 1 - hw/arm/omap_sx1.c | 1 - hw/arm/palm.c | 1 - hw/arm/realview.c | 1 - hw/arm/spitz.c | 1 - hw/arm/stellaris.c | 1 - hw/arm/tosa.c | 1 - hw/arm/versatilepb.c | 1 - hw/arm/vexpress.c | 1 - hw/arm/virt.c | 1 - hw/arm/xilinx_zynq.c | 1 - hw/arm/z2.c | 1 - hw/block/onenand.c | 1 - hw/block/pflash_cfi01.c | 1 - hw/block/pflash_cfi02.c | 1 - hw/char/mcf_uart.c | 1 - hw/char/omap_uart.c | 1 - hw/char/serial.c | 1 - hw/char/sh_serial.c | 1 - hw/core/loader.c | 1 - hw/core/sysbus.c | 1 - hw/cris/axis_dev88.c | 1 - hw/display/sm501.c | 1 - hw/dma/etraxfs_dma.c | 1 - hw/dma/pl080.c | 1 - hw/dma/sun4m_iommu.c | 1 - hw/i386/pc.c | 1 - hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 1 - hw/intc/armv7m_nvic.c | 1 - hw/intc/openpic_kvm.c | 1 - hw/isa/isa-bus.c | 1 - hw/isa/lpc_ich9.c | 1 - hw/isa/vt82c686.c | 1 - hw/lm32/lm32_boards.c | 1 - hw/lm32/milkymist.c | 1 - hw/m68k/an5206.c | 1 - hw/m68k/dummy_m68k.c | 1 - hw/m68k/mcf5206.c | 1 - hw/m68k/mcf5208.c | 1 - hw/m68k/mcf_intc.c | 1 - hw/microblaze/petalogix_ml605_mmu.c | 1 - hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 - hw/mips/gt64xxx_pci.c | 1 - hw/mips/mips_fulong2e.c | 1 - hw/mips/mips_jazz.c | 1 - hw/mips/mips_malta.c | 1 - hw/mips/mips_mipssim.c | 1 - hw/mips/mips_r4k.c | 1 - hw/misc/arm_integrator_debug.c | 1 - hw/misc/omap_gpmc.c | 1 - hw/misc/vfio.c | 1 - hw/moxie/moxiesim.c | 1 - hw/net/mcf_fec.c | 1 - hw/net/ne2000-isa.c | 1 - hw/openrisc/openrisc_sim.c | 1 - hw/pci-host/apb.c | 1 - hw/pci-host/bonito.c | 1 - hw/pci-host/ppce500.c | 1 - hw/pci-host/prep.c | 1 - hw/pci-host/versatile.c | 1 - hw/pci/pci.c | 1 - hw/pci/pcie_host.c | 1 - hw/ppc/e500.c | 1 - hw/ppc/mac_newworld.c | 1 - hw/ppc/mac_oldworld.c | 1 - hw/ppc/ppc405_boards.c | 1 - hw/ppc/ppc405_uc.c | 1 - hw/ppc/ppc440_bamboo.c | 1 - hw/ppc/ppc4xx_devs.c | 1 - hw/ppc/ppc4xx_pci.c | 1 - hw/ppc/prep.c | 1 - hw/ppc/spapr.c | 1 - hw/ppc/spapr_iommu.c | 1 - hw/ppc/spapr_pci.c | 1 - hw/ppc/virtex_ml507.c | 1 - hw/s390x/css.c | 1 - hw/s390x/s390-virtio-ccw.c | 1 - hw/s390x/s390-virtio.c | 1 - hw/sh4/r2d.c | 1 - hw/sh4/sh7750.c | 1 - hw/sh4/sh_pci.c | 1 - hw/sh4/shix.c | 1 - hw/sparc/leon3.c | 1 - hw/sparc64/sun4u.c | 1 - hw/timer/m48t59.c | 1 - hw/timer/sh_timer.c | 1 - hw/tpm/tpm_tis.c | 1 - hw/unicore32/puv3.c | 1 - hw/virtio/dataplane/vring.c | 1 - hw/virtio/vhost.c | 1 - hw/virtio/virtio-balloon.c | 1 - hw/virtio/virtio.c | 1 - hw/xen/xen_platform.c | 1 - hw/xen/xen_pt.c | 1 - hw/xtensa/xtensa_lx60.c | 1 - hw/xtensa/xtensa_sim.c | 1 - include/exec/address-spaces.h | 12 ------------ include/exec/softmmu_template.h | 1 - include/hw/arm/allwinner-a10.h | 1 - include/hw/sh4/sh_intc.h | 1 - include/sysemu/dma.h | 1 - ioport.c | 1 - kvm-all.c | 1 - memory.c | 1 - memory_mapping.c | 1 - target-sparc/mmu_helper.c | 1 - target-xtensa/op_helper.c | 1 - translate-all.c | 1 - xen-all.c | 1 - 127 files changed, 138 deletions(-) delete mode 100644 include/exec/address-spaces.h
arch_init.c +0 -1
@@ -41,7 +41,6 @@#include "sysemu/kvm.h" #include "migration/migration.h" #include "hw/i386/smbios.h" -#include "exec/address-spaces.h" #include "hw/audio/pcspk.h" #include "migration/page_cache.h" #include "qemu/config-file.h"
cputlb.c +0 -1
@@ -25,7 +25,6 @@#include "config.h" #include "exec/exec-all.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "exec/cputlb.h"
exec.c +0 -1
@@ -36,7 +36,6 @@#include "qemu/config-file.h" #include "exec/memory.h" #include "sysemu/dma.h" -#include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY )#include <qemu.h> #else /* !CONFIG_USER_ONLY */
hw/acpi/ich9.c +0 -1
@@ -31,7 +31,6 @@#include "sysemu/sysemu.h" #include "hw/acpi/acpi.h" #include "sysemu/kvm.h" -#include "exec/address-spaces.h" #include "hw/i386/ich9.h"
hw/acpi/pcihp.c +0 -1
@@ -33,7 +33,6 @@#include "sysemu/sysemu.h" #include "qemu/range.h" #include "exec/ioport.h" -#include "exec/address-spaces.h" #include "hw/pci/pci_bus.h" #include "qom/qom-qobject.h" #include "qapi/qmp/qint.h"
hw/acpi/piix4.c +0 -1
@@ -28,7 +28,6 @@#include "qemu/range.h" #include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" -#include "exec/address-spaces.h" #include "hw/acpi/piix4.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/cpu_hotplug.h"
hw/alpha/typhoon.c +0 -1
@@ -11,7 +11,6 @@#include "hw/devices.h" #include "sysemu/sysemu.h" #include "alpha_sys.h" -#include "exec/address-spaces.h" #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
hw/arm/boot.c +0 -1
@@ -16,7 +16,6 @@#include "elf.h" #include "sysemu/device_tree.h" #include "qemu/config-file.h" -#include "exec/address-spaces.h" /* Kernel boot protocol is specified in the kernel docs * Documentation/arm/Booting and Documentation/arm64/booting.txt
hw/arm/collie.c +0 -1
@@ -16,7 +16,6 @@#include "hw/arm/arm.h" #include "hw/block/flash.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" static struct arm_boot_info collie_binfo = { .loader_start =SA_SDCS0 ,
hw/arm/digic_boards.c +0 -1
@@ -24,7 +24,6 @@*/ #include "hw/boards.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" #include "hw/arm/digic.h" #include "hw/block/flash.h"
hw/arm/exynos4_boards.c +0 -1
@@ -26,7 +26,6 @@#include "hw/sysbus.h" #include "net/net.h" #include "hw/arm/arm.h" -#include "exec/address-spaces.h" #include "hw/arm/exynos4210.h" #include "hw/boards.h"
hw/arm/gumstix.c +0 -1
@@ -41,7 +41,6 @@#include "hw/devices.h" #include "hw/boards.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" static const int sector_len =128 *1024 ;
hw/arm/highbank.c +0 -1
@@ -25,7 +25,6 @@#include "sysemu/sysemu.h" #include "hw/boards.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" #define SMP_BOOT_ADDR 0x100
hw/arm/integratorcp.c +0 -1
@@ -13,7 +13,6 @@#include "hw/arm/arm.h" #include "hw/misc/arm_integrator_debug.h" #include "net/net.h" -#include "exec/address-spaces.h" #include "sysemu/sysemu.h" #define TYPE_INTEGRATOR_CM "integrator_core"
hw/arm/kzm.c +0 -1
@@ -14,7 +14,6 @@*/ #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "hw/hw.h" #include "hw/arm/arm.h" #include "hw/devices.h"
hw/arm/mainstone.c +0 -1
@@ -20,7 +20,6 @@#include "hw/block/flash.h" #include "sysemu/blockdev.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" /* Device addresses */
hw/arm/musicpal.c +0 -1
@@ -23,7 +23,6 @@#include "ui/console.h" #include "hw/i2c/i2c.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "ui/pixel_ops.h" #define MP_MISC_BASE 0x80002000
hw/arm/nseries.c +0 -1
@@ -33,7 +33,6 @@#include "hw/loader.h" #include "sysemu/blockdev.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" /* Nokia N8x0 support */ struct n800_s {
hw/arm/omap_sx1.c +0 -1
@@ -33,7 +33,6 @@#include "hw/block/flash.h" #include "sysemu/blockdev.h" #include "sysemu/qtest.h" -#include "exec/address-spaces.h" /*****************************************************************************/ /* Siemens SX1 Cellphone V1 */
hw/arm/palm.c +0 -1
@@ -26,7 +26,6 @@#include "hw/arm/arm.h" #include "hw/devices.h" #include "hw/loader.h" -#include "exec/address-spaces.h" static uint32_t static_readb (void *opaque,hwaddr offset) {
hw/arm/realview.c +0 -1
@@ -17,7 +17,6 @@#include "hw/boards.h" #include "hw/i2c/i2c.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0xe0000000#define SMP_BOOTREG_ADDR 0x10000030
hw/arm/spitz.c +0 -1
@@ -27,7 +27,6 @@#include "hw/boards.h" #include "sysemu/blockdev.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #undef REG_FMT#define REG_FMT "0x%02lx"
hw/arm/stellaris.c +0 -1
@@ -15,7 +15,6 @@#include "hw/i2c/i2c.h" #include "net/net.h" #include "hw/boards.h" -#include "exec/address-spaces.h" #define GPIO_A 0#define GPIO_B 1
hw/arm/tosa.c +0 -1
@@ -23,7 +23,6 @@#include "hw/ssi.h" #include "sysemu/blockdev.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #define TOSA_RAM 0x04000000#define TOSA_ROM 0x00800000
hw/arm/versatilepb.c +0 -1
@@ -16,7 +16,6 @@#include "hw/i2c/i2c.h" #include "hw/boards.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "hw/block/flash.h" #define VERSATILE_FLASH_ADDR 0x34000000
hw/arm/vexpress.c +0 -1
@@ -28,7 +28,6 @@#include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "exec/address-spaces.h" #include "sysemu/blockdev.h" #include "hw/block/flash.h" #include "sysemu/device_tree.h"
hw/arm/virt.c +0 -1
@@ -37,7 +37,6 @@#include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "hw/boards.h" -#include "exec/address-spaces.h" #include "qemu/bitops.h" #include "qemu/error-report.h"
hw/arm/xilinx_zynq.c +0 -1
@@ -18,7 +18,6 @@#include "hw/sysbus.h" #include "hw/arm/arm.h" #include "net/net.h" -#include "exec/address-spaces.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/block/flash.h"
hw/arm/z2.c +0 -1
@@ -23,7 +23,6 @@#include "sysemu/blockdev.h" #include "ui/console.h" #include "audio/audio.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #ifdef DEBUG_Z2
hw/block/onenand.c +0 -1
@@ -24,7 +24,6 @@#include "hw/irq.h" #include "sysemu/blockdev.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "hw/sysbus.h" #include "qemu/error-report.h"
hw/block/pflash_cfi01.c +0 -1
@@ -41,7 +41,6 @@#include "block/block.h" #include "qemu/timer.h" #include "qemu/bitops.h" -#include "exec/address-spaces.h" #include "qemu/host-utils.h" #include "hw/sysbus.h"
hw/block/pflash_cfi02.c +0 -1
@@ -39,7 +39,6 @@#include "hw/block/flash.h" #include "qemu/timer.h" #include "block/block.h" -#include "exec/address-spaces.h" #include "qemu/host-utils.h" #include "hw/sysbus.h"
hw/char/mcf_uart.c +0 -1
@@ -8,7 +8,6 @@#include "hw/hw.h" #include "hw/m68k/mcf.h" #include "sysemu/char.h" -#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem;
hw/char/omap_uart.c +0 -1
@@ -21,7 +21,6 @@#include "hw/hw.h" #include "hw/arm/omap.h" #include "hw/char/serial.h" -#include "exec/address-spaces.h" /* UARTs */ struct omap_uart_s {
hw/char/serial.c +0 -1
@@ -26,7 +26,6 @@#include "hw/char/serial.h" #include "sysemu/char.h" #include "qemu/timer.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" //#define DEBUG_SERIAL
hw/char/sh_serial.c +0 -1
@@ -27,7 +27,6 @@#include "hw/hw.h" #include "hw/sh4/sh.h" #include "sysemu/char.h" -#include "exec/address-spaces.h" //#define DEBUG_SERIAL
hw/core/loader.c +0 -1
@@ -50,7 +50,6 @@#include "hw/loader.h" #include "hw/nvram/fw_cfg.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include <zlib.h>
hw/core/sysbus.c +0 -1
@@ -19,7 +19,6 @@#include "hw/sysbus.h" #include "monitor/monitor.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);
hw/cris/axis_dev88.c +0 -1
@@ -31,7 +31,6 @@#include "elf.h" #include "boot.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #define D (x)
hw/display/sm501.c +0 -1
@@ -30,7 +30,6 @@#include "hw/sysbus.h" #include "qemu/range.h" #include "ui/pixel_ops.h" -#include "exec/address-spaces.h" /* * Status: 2010/05/07
hw/dma/etraxfs_dma.c +0 -1
@@ -24,7 +24,6 @@#include <stdio.h> #include <sys/time.h> #include "hw/hw.h" -#include "exec/address-spaces.h" #include "qemu-common.h" #include "sysemu/sysemu.h"
hw/dma/pl080.c +0 -1
@@ -8,7 +8,6 @@*/ #include "hw/sysbus.h" -#include "exec/address-spaces.h" #define PL080_MAX_CHANNELS 8#define PL080_CONF_E 0x1
hw/dma/sun4m_iommu.c +0 -1
@@ -24,7 +24,6 @@#include "hw/sparc/sun4m.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "trace.h" /*
hw/i386/pc.c +0 -1
@@ -48,7 +48,6 @@#include "hw/block/block.h" #include "ui/qemu-spice.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "sysemu/arch_init.h" #include "qemu/bitmap.h" #include "qemu/config-file.h"
hw/i386/pc_piix.c +0 -1
@@ -45,7 +45,6 @@#include "hw/i2c/smbus.h" #include "hw/xen/xen.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "hw/acpi/acpi.h" #include "cpu.h" #ifdef CONFIG_XEN
hw/i386/pc_q35.c +0 -1
@@ -37,7 +37,6 @@#include "sysemu/kvm.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" -#include "exec/address-spaces.h" #include "hw/i386/ich9.h" #include "hw/i386/smbios.h" #include "hw/ide/pci.h"
hw/intc/armv7m_nvic.c +0 -1
@@ -13,7 +13,6 @@#include "hw/sysbus.h" #include "qemu/timer.h" #include "hw/arm/arm.h" -#include "exec/address-spaces.h" #include "gic_internal.h" typedef struct {
hw/intc/openpic_kvm.c +0 -1
@@ -23,7 +23,6 @@*/ #include <sys/ioctl.h> -#include "exec/address-spaces.h" #include "hw/hw.h" #include "hw/ppc/openpic.h" #include "hw/pci/msi.h"
hw/isa/isa-bus.c +0 -1
@@ -21,7 +21,6 @@#include "hw/sysbus.h" #include "sysemu/sysemu.h" #include "hw/isa/isa.h" -#include "exec/address-spaces.h" static ISABus *isabus;hwaddr isa_mem_base =0 ;
hw/isa/lpc_ich9.c +0 -1
@@ -43,7 +43,6 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" #include "hw/pci/pci_bus.h" -#include "exec/address-spaces.h" #include "sysemu/sysemu.h" static int ich9_lpc_sci_irq (ICH9LPCState *lpc);
hw/isa/vt82c686.c +0 -1
@@ -24,7 +24,6 @@#include "hw/i2c/pm_smbus.h" #include "sysemu/sysemu.h" #include "qemu/timer.h" -#include "exec/address-spaces.h" //#define DEBUG_VT82C686B
hw/lm32/lm32_boards.c +0 -1
@@ -27,7 +27,6 @@#include "elf.h" #include "lm32_hwsetup.h" #include "lm32.h" -#include "exec/address-spaces.h" typedef struct { LM32CPU *cpu;
hw/lm32/milkymist.c +0 -1
@@ -29,7 +29,6 @@#include "sysemu/blockdev.h" #include "milkymist-hw.h" #include "lm32.h" -#include "exec/address-spaces.h" #define BIOS_FILENAME "mmone-bios.bin"#define BIOS_OFFSET 0x00860000
hw/m68k/an5206.c +0 -1
@@ -11,7 +11,6 @@#include "hw/boards.h" #include "hw/loader.h" #include "elf.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #define KERNEL_LOAD_ADDR 0x10000
hw/m68k/dummy_m68k.c +0 -1
@@ -10,7 +10,6 @@#include "hw/boards.h" #include "hw/loader.h" #include "elf.h" -#include "exec/address-spaces.h" #define KERNEL_LOAD_ADDR 0x10000
hw/m68k/mcf5206.c +0 -1
@@ -10,7 +10,6 @@#include "qemu/timer.h" #include "hw/ptimer.h" #include "sysemu/sysemu.h" -#include "exec/address-spaces.h" /* General purpose timer module. */ typedef struct {
hw/m68k/mcf5208.c +0 -1
@@ -15,7 +15,6 @@#include "hw/boards.h" #include "hw/loader.h" #include "elf.h" -#include "exec/address-spaces.h" #define SYS_FREQ 66000000
hw/m68k/mcf_intc.c +0 -1
@@ -7,7 +7,6 @@*/ #include "hw/hw.h" #include "hw/m68k/mcf.h" -#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem;
hw/microblaze/petalogix_ml605_mmu.c +0 -1
@@ -34,7 +34,6 @@#include "hw/boards.h" #include "sysemu/blockdev.h" #include "hw/char/serial.h" -#include "exec/address-spaces.h" #include "hw/ssi.h" #include "boot.h"
hw/microblaze/petalogix_s3adsp1800_mmu.c +0 -1
@@ -31,7 +31,6 @@#include "hw/devices.h" #include "hw/boards.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "boot.h"
hw/mips/gt64xxx_pci.c +0 -1
@@ -27,7 +27,6 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/i386/pc.h" -#include "exec/address-spaces.h" //#define DEBUG
hw/mips/mips_fulong2e.c +0 -1
@@ -42,7 +42,6 @@#include "hw/timer/mc146818rtc.h" #include "hw/timer/i8254.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "qemu/error-report.h"
hw/mips/mips_jazz.c +0 -1
@@ -41,7 +41,6 @@#include "hw/audio/pcspk.h" #include "sysemu/blockdev.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "qemu/error-report.h"
hw/mips/mips_malta.c +0 -1
@@ -45,7 +45,6 @@#include "hw/timer/mc146818rtc.h" #include "hw/timer/i8254.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "hw/sysbus.h" /* SysBusDevice */ #include "qemu/host-utils.h" #include "sysemu/qtest.h"
hw/mips/mips_mipssim.c +0 -1
@@ -36,7 +36,6 @@#include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" #include "sysemu/qtest.h"
hw/mips/mips_r4k.c +0 -1
@@ -25,7 +25,6 @@#include "hw/timer/mc146818rtc.h" #include "hw/timer/i8254.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "sysemu/qtest.h" #define MAX_IDE_BUS 2
hw/misc/arm_integrator_debug.c +0 -1
@@ -16,7 +16,6 @@#include "hw/hw.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "hw/misc/arm_integrator_debug.h" #define INTEGRATOR_DEBUG (obj) \
hw/misc/omap_gpmc.c +0 -1
@@ -22,7 +22,6 @@#include "hw/block/flash.h" #include "hw/arm/omap.h" #include "exec/memory.h" -#include "exec/address-spaces.h" /* General-Purpose Memory Controller */ struct omap_gpmc_s {
hw/misc/vfio.c +0 -1
@@ -27,7 +27,6 @@#include <unistd.h> #include "config.h" -#include "exec/address-spaces.h" #include "exec/memory.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h"
hw/moxie/moxiesim.c +0 -1
@@ -33,7 +33,6 @@#include "hw/boards.h" #include "hw/loader.h" #include "hw/char/serial.h" -#include "exec/address-spaces.h" #define PHYS_MEM_BASE 0x80000000
hw/net/mcf_fec.c +0 -1
@@ -10,7 +10,6 @@#include "hw/m68k/mcf.h" /* For crc32 */ #include <zlib.h> -#include "exec/address-spaces.h" //#define DEBUG_FEC 1
hw/net/ne2000-isa.c +0 -1
@@ -27,7 +27,6 @@#include "hw/qdev.h" #include "net/net.h" #include "ne2000.h" -#include "exec/address-spaces.h" #define TYPE_ISA_NE2000 "ne2k_isa"#define ISA_NE2000 (obj) OBJECT_CHECK(ISANE2000State, (obj), TYPE_ISA_NE2000)
hw/openrisc/openrisc_sim.c +0 -1
@@ -24,7 +24,6 @@#include "hw/char/serial.h" #include "net/net.h" #include "hw/loader.h" -#include "exec/address-spaces.h" #include "sysemu/sysemu.h" #include "hw/sysbus.h" #include "sysemu/qtest.h"
hw/pci-host/apb.c +0 -1
@@ -34,7 +34,6 @@#include "hw/pci/pci_bus.h" #include "hw/pci-host/apb.h" #include "sysemu/sysemu.h" -#include "exec/address-spaces.h" /* debug APB */ //#define DEBUG_APB
hw/pci-host/bonito.c +0 -1
@@ -45,7 +45,6 @@#include "hw/mips/mips.h" #include "hw/pci/pci_host.h" #include "sysemu/sysemu.h" -#include "exec/address-spaces.h" //#define DEBUG_BONITO
hw/pci-host/ppce500.c +0 -1
@@ -317,7 +317,6 @@ static const VMStateDescription vmstate_ppce500_pci = { } }; -#include "exec/address-spaces.h" static int e500_pcihost_bridge_initfn (PCIDevice *d) {
hw/pci-host/prep.c +0 -1
@@ -28,7 +28,6 @@#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/i386/pc.h" -#include "exec/address-spaces.h" #define TYPE_RAVEN_PCI_DEVICE "raven"#define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost"
hw/pci-host/versatile.c +0 -1
@@ -11,7 +11,6 @@#include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" -#include "exec/address-spaces.h" /* Old and buggy versions of QEMU used the wrong mapping from * PCI IRQs to system interrupt lines. Unfortunately the Linux
hw/pci/pci.c +0 -1
@@ -34,7 +34,6 @@#include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" -#include "exec/address-spaces.h" #include "hw/hotplug.h" //#define DEBUG_PCI
hw/pci/pcie_host.c +0 -1
@@ -22,7 +22,6 @@#include "hw/hw.h" #include "hw/pci/pci.h" #include "hw/pci/pcie_host.h" -#include "exec/address-spaces.h" /* a helper function to get a PCIDevice for a given mmconfig address */ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s,
hw/ppc/e500.c +0 -1
@@ -33,7 +33,6 @@#include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" -#include "exec/address-spaces.h" #include "qemu/host-utils.h" #include "hw/pci-host/ppce500.h"
hw/ppc/mac_newworld.c +0 -1
@@ -66,7 +66,6 @@#include "kvm_ppc.h" #include "hw/usb.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #include "hw/sysbus.h" #define MAX_IDE_BUS 2
hw/ppc/mac_oldworld.c +0 -1
@@ -41,7 +41,6 @@#include "sysemu/kvm.h" #include "kvm_ppc.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #define MAX_IDE_BUS 2#define CFG_ADDR 0xf0000510
hw/ppc/ppc405_boards.c +0 -1
@@ -34,7 +34,6 @@#include "qemu/error-report.h" #include "hw/loader.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #define BIOS_FILENAME "ppc405_rom.bin"#define BIOS_SIZE (2048 * 1024)
hw/ppc/ppc405_uc.c +0 -1
@@ -28,7 +28,6 @@#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "qemu/log.h" -#include "exec/address-spaces.h" //#define DEBUG_OPBA //#define DEBUG_SDRAM
hw/ppc/ppc440_bamboo.c +0 -1
@@ -22,7 +22,6 @@#include "sysemu/device_tree.h" #include "hw/loader.h" #include "elf.h" -#include "exec/address-spaces.h" #include "hw/char/serial.h" #include "hw/ppc/ppc.h" #include "ppc405.h"
hw/ppc/ppc4xx_devs.c +0 -1
@@ -25,7 +25,6 @@#include "hw/ppc/ppc.h" #include "hw/ppc/ppc4xx.h" #include "qemu/log.h" -#include "exec/address-spaces.h" #define DEBUG_UIC
hw/ppc/ppc4xx_pci.c +0 -1
@@ -24,7 +24,6 @@#include "hw/ppc/ppc4xx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" -#include "exec/address-spaces.h" #undef DEBUG#ifdef DEBUG
hw/ppc/prep.c +0 -1
@@ -41,7 +41,6 @@#include "sysemu/blockdev.h" #include "sysemu/arch_init.h" #include "sysemu/qtest.h" -#include "exec/address-spaces.h" #include "elf.h" //#define HARD_DEBUG_PPC_IO
hw/ppc/spapr.c +0 -1
@@ -46,7 +46,6 @@#include "hw/pci/pci.h" -#include "exec/address-spaces.h" #include "hw/usb.h" #include "qemu/config-file.h"
hw/ppc/spapr_iommu.c +0 -1
@@ -21,7 +21,6 @@#include "hw/qdev.h" #include "kvm_ppc.h" #include "sysemu/dma.h" -#include "exec/address-spaces.h" #include "trace.h" #include "hw/ppc/spapr.h"
hw/ppc/spapr_pci.c +0 -1
@@ -29,7 +29,6 @@#include "hw/pci/pci_host.h" #include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" -#include "exec/address-spaces.h" #include <libfdt.h> #include "trace.h"
hw/ppc/virtex_ml507.c +0 -1
@@ -33,7 +33,6 @@#include "hw/loader.h" #include "elf.h" #include "qemu/log.h" -#include "exec/address-spaces.h" #include "hw/ppc/ppc.h" #include "hw/ppc/ppc4xx.h"
hw/s390x/css.c +0 -1
@@ -11,7 +11,6 @@#include <hw/qdev.h> #include "qemu/bitops.h" -#include "exec/address-spaces.h" #include "cpu.h" #include "ioinst.h" #include "css.h"
hw/s390x/s390-virtio-ccw.c +0 -1
@@ -10,7 +10,6 @@*/ #include "hw/boards.h" -#include "exec/address-spaces.h" #include "s390-virtio.h" #include "hw/s390x/sclp.h" #include "ioinst.h"
hw/s390x/s390-virtio.c +0 -1
@@ -32,7 +32,6 @@#include "hw/virtio/virtio.h" #include "hw/sysbus.h" #include "sysemu/kvm.h" -#include "exec/address-spaces.h" #include "hw/s390x/s390-virtio-bus.h" #include "hw/s390x/sclp.h"
hw/sh4/r2d.c +0 -1
@@ -37,7 +37,6 @@#include "hw/usb.h" #include "hw/block/flash.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" #define FLASH_BASE 0x00000000#define FLASH_SIZE 0x02000000
hw/sh4/sh7750.c +0 -1
@@ -30,7 +30,6 @@#include "sh7750_regnames.h" #include "hw/sh4/sh_intc.h" #include "cpu.h" -#include "exec/address-spaces.h" #define NB_DEVICES 4
hw/sh4/sh_pci.c +0 -1
@@ -26,7 +26,6 @@#include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "qemu/bswap.h" -#include "exec/address-spaces.h" #define TYPE_SH_PCI_HOST_BRIDGE "sh_pci"
hw/sh4/shix.c +0 -1
@@ -33,7 +33,6 @@#include "sysemu/qtest.h" #include "hw/boards.h" #include "hw/loader.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" #define BIOS_FILENAME "shix_bios.bin"
hw/sparc/leon3.c +0 -1
@@ -31,7 +31,6 @@#include "hw/loader.h" #include "elf.h" #include "trace.h" -#include "exec/address-spaces.h" #include "hw/sparc/grlib.h"
hw/sparc64/sun4u.c +0 -1
@@ -39,7 +39,6 @@#include "hw/loader.h" #include "elf.h" #include "sysemu/blockdev.h" -#include "exec/address-spaces.h" //#define DEBUG_IRQ //#define DEBUG_EBUS
hw/timer/m48t59.c +0 -1
@@ -27,7 +27,6 @@#include "sysemu/sysemu.h" #include "hw/sysbus.h" #include "hw/isa/isa.h" -#include "exec/address-spaces.h" //#define DEBUG_NVRAM
hw/timer/sh_timer.c +0 -1
@@ -12,7 +12,6 @@#include "hw/sh4/sh.h" #include "qemu/timer.h" #include "qemu/main-loop.h" -#include "exec/address-spaces.h" #include "hw/ptimer.h" //#define DEBUG_TIMER
hw/tpm/tpm_tis.c +0 -1
@@ -22,7 +22,6 @@#include "sysemu/tpm_backend.h" #include "tpm_int.h" #include "block/block.h" -#include "exec/address-spaces.h" #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/pci/pci_ids.h"
hw/unicore32/puv3.c +0 -1
@@ -12,7 +12,6 @@#include "qemu-common.h" #include "ui/console.h" #include "elf.h" -#include "exec/address-spaces.h" #include "hw/sysbus.h" #include "hw/boards.h" #include "hw/loader.h"
hw/virtio/dataplane/vring.c +0 -1
@@ -17,7 +17,6 @@#include "trace.h" #include "hw/hw.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "hw/virtio/dataplane/vring.h" #include "qemu/error-report.h"
hw/virtio/vhost.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/atomic.h" #include "qemu/range.h" #include <linux/vhost.h> -#include "exec/address-spaces.h" #include "hw/virtio/virtio-bus.h" static void vhost_dev_sync_region(struct vhost_dev *dev,
hw/virtio/virtio-balloon.c +0 -1
@@ -22,7 +22,6 @@#include "sysemu/balloon.h" #include "hw/virtio/virtio-balloon.h" #include "sysemu/kvm.h" -#include "exec/address-spaces.h" #include "qapi/visitor.h" #if defined(__linux__)
hw/virtio/virtio.c +0 -1
@@ -14,7 +14,6 @@#include <inttypes.h> #include "trace.h" -#include "exec/address-spaces.h" #include "qemu/error-report.h" #include "hw/virtio/virtio.h" #include "qemu/atomic.h"
hw/xen/xen_platform.c +0 -1
@@ -33,7 +33,6 @@#include "hw/xen/xen_common.h" #include "hw/xen/xen_backend.h" #include "trace.h" -#include "exec/address-spaces.h" #include <xenguest.h>
hw/xen/xen_pt.c +0 -1
@@ -59,7 +59,6 @@#include "hw/xen/xen_backend.h" #include "xen_pt.h" #include "qemu/range.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 };
hw/xtensa/xtensa_lx60.c +0 -1
@@ -30,7 +30,6 @@#include "hw/loader.h" #include "elf.h" #include "exec/memory.h" -#include "exec/address-spaces.h" #include "hw/char/serial.h" #include "net/net.h" #include "hw/sysbus.h"
hw/xtensa/xtensa_sim.c +0 -1
@@ -30,7 +30,6 @@#include "hw/loader.h" #include "elf.h" #include "exec/memory.h" -#include "exec/address-spaces.h" static uint64_t translate_phys_addr (void *opaque,uint64_t addr) {
include/exec/address-spaces.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* -* Internal memory management interfaces -* -* Copyright 2011 Red Hat, Inc. and/or its affiliates -* -* Authors: -* Avi Kivity <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2. See -* the COPYING file in the top-level directory. -* -*/
include/exec/softmmu_template.h +0 -1
@@ -22,7 +22,6 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/timer.h" -#include "exec/address-spaces.h" #include "exec/memory.h" #define DATA_SIZE (1 << SHIFT)
include/hw/arm/allwinner-a10.h +0 -1
@@ -9,7 +9,6 @@#include "hw/net/allwinner_emac.h" #include "sysemu/sysemu.h" -#include "exec/address-spaces.h" #define AW_A10_PIC_REG_BASE 0x01c20400
include/hw/sh4/sh_intc.h +0 -1
@@ -3,7 +3,6 @@#include "qemu-common.h" #include "hw/irq.h" -#include "exec/address-spaces.h" #include "exec/memory.h" typedef unsigned char intc_enum ;
include/sysemu/dma.h +0 -1
@@ -12,7 +12,6 @@#include <stdio.h> #include "exec/memory.h" -#include "exec/address-spaces.h" #include "hw/hw.h" #include "block/block.h" #include "sysemu/kvm.h"
ioport.c +0 -1
@@ -28,7 +28,6 @@#include "exec/ioport.h" #include "trace.h" #include "exec/memory.h" -#include "exec/address-spaces.h" //#define DEBUG_IOPORT
kvm-all.c +0 -1
@@ -32,7 +32,6 @@#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/ram_addr.h" -#include "exec/address-spaces.h" #include "qemu/event_notifier.h" #include "trace.h"
memory.c +0 -1
@@ -14,7 +14,6 @@*/ #include "exec/memory.h" -#include "exec/address-spaces.h" #include "exec/ioport.h" #include "qemu/bitops.h" #include "qom/object.h"
memory_mapping.c +0 -1
@@ -16,7 +16,6 @@#include "qemu-common.h" #include "exec/cpu-common.h" /* for ram_addr_t */ #include "exec/memory.h" -#include "exec/address-spaces.h" #include "sysemu/memory_mapping.h" //#define DEBUG_GUEST_PHYS_REGION_ADD
target-sparc/mmu_helper.c +0 -1
@@ -19,7 +19,6 @@#include "cpu.h" #include "trace.h" -#include "exec/address-spaces.h" /* Sparc MMU emulation */
target-xtensa/op_helper.c +0 -1
@@ -29,7 +29,6 @@#include "helper.h" #include "qemu/host-utils.h" #include "exec/softmmu_exec.h" -#include "exec/address-spaces.h" static void do_unaligned_access (CPUXtensaState *env,target_ulong addr,int is_write,int is_user,uintptr_t retaddr);
translate-all.c +0 -1
@@ -58,7 +58,6 @@#endif #endif #else -#include "exec/address-spaces.h" #endif #include "exec/cputlb.h"
xen-all.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/range.h" #include "sysemu/xen-mapcache.h" #include "trace.h" -#include "exec/address-spaces.h" #include <xen/hvm/ioreq.h> #include <xen/hvm/params.h>
Signature · 1 line
1.7.9.5
PATCH 8/10 exec: move TranslationBlock API from exec-all.h => translate.h
In reply to Xuebing Wang--- include/exec/exec-all.h | 302 +-------------------------------------------- include/exec/translate.h | 306 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+), 301 deletions(-) create mode 100644 include/exec/translate.h
include/exec/exec-all.h +1 -301
@@ -20,307 +20,7 @@#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 page_size_init (void ); - -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 ) -void tcg_cpu_address_space_init (CPUState *cpu,AddressSpace *as); -/* 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 (AddressSpace *as,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(__aarch64__) \ - || 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; -}; - -#include "exec/spinlock.h" - -typedef struct TBContext TBContext ; - -struct TBContext { - -TranslationBlock *tbs; -TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE ]; -int nb_tbs; -/* any access to the tbs or the page table must use this lock */ -spinlock_t tb_lock; - -/* statistics */ -int tb_flush_count; -int tb_phys_invalidate_count; - -int tb_invalidated_flag; -}; - -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); - -#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(__aarch64__) -void aarch64_tb_set_jmp_target (uintptr_t jmp_addr,uintptr_t addr); -#define tb_set_jmp_target1 aarch64_tb_set_jmp_target -#elif defined(__arm__) -static inline void tb_set_jmp_target1 (uintptr_t jmp_addr,uintptr_t addr) -{ -#if !QEMU_GNUC_PREREQ (4 ,1 ) - registerunsigned long _beg __asm ("a1" ); - registerunsigned long _end __asm ("a2" ); - registerunsigned 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)); - } -} - -/* GETRA is the true target of the return instruction that we'll execute, -defined here for simplicity of defining the follow-up macros. */ -#if defined(CONFIG_TCG_INTERPRETER ) -extern uintptr_t tci_tb_ptr; -# define GETRA () tci_tb_ptr -#else -# define GETRA () \ - ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) -#endif - -/* The true return address will often point to a host insn that is part of -the next translated guest insn. Adjust the address backward to point to -the middle of the call insn. Subtracting one would do the job except for -several compressed mode architectures (arm, mips) which set the low bit -to indicate the compressed mode; subtracting two works around that. It -is also the case that there are no host isas that contain a call insn -smaller than 4 bytes, so we don't worry about special-casing this. */ -#if defined(CONFIG_TCG_INTERPRETER ) -# define GETPC_ADJ 0 -#else -# define GETPC_ADJ 2 -#endif - -#define GETPC () (GETRA() - GETPC_ADJ) +#include "exec/translate.h" #if !defined(CONFIG_USER_ONLY )
include/exec/translate.h new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 08/10] exec: move TranslationBlock API from exec-all.h => translate.h
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 6 lines
Signed-off-by Xuebing Wang <[email protected]>--- include/exec/exec-all.h | 302 +-------------------------------------------- include/exec/translate.h | 306 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+), 301 deletions(-) create mode 100644 include/exec/translate.h
Very good idea.
Paolo
Quoted 626 lines
include/exec/exec-all.h +1
-301@@ -20,307 +20,7 @@#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 page_size_init (void ); - -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 ) -void tcg_cpu_address_space_init (CPUState *cpu,AddressSpace *as); -/* 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 (AddressSpace *as,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(__aarch64__) \ - || 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; -}; - -#include "exec/spinlock.h" - -typedef struct TBContext TBContext ; - -struct TBContext { - -TranslationBlock *tbs; -TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE ]; -int nb_tbs; -/* any access to the tbs or the page table must use this lock */ -spinlock_t tb_lock; - -/* statistics */ -int tb_flush_count; -int tb_phys_invalidate_count; - -int tb_invalidated_flag; -}; - -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); - -#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(__aarch64__) -void aarch64_tb_set_jmp_target (uintptr_t jmp_addr,uintptr_t addr); -#define tb_set_jmp_target1 aarch64_tb_set_jmp_target -#elif defined(__arm__) -static inline void tb_set_jmp_target1 (uintptr_t jmp_addr,uintptr_t addr) -{ -#if !QEMU_GNUC_PREREQ (4 ,1 ) - registerunsigned long _beg __asm ("a1" ); - registerunsigned long _end __asm ("a2" ); - registerunsigned 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)); - } -} - -/* GETRA is the true target of the return instruction that we'll execute, -defined here for simplicity of defining the follow-up macros. */ -#if defined(CONFIG_TCG_INTERPRETER ) -extern uintptr_t tci_tb_ptr; -# define GETRA () tci_tb_ptr -#else -# define GETRA () \ - ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) -#endif - -/* The true return address will often point to a host insn that is part of -the next translated guest insn. Adjust the address backward to point to -the middle of the call insn. Subtracting one would do the job except for -several compressed mode architectures (arm, mips) which set the low bit -to indicate the compressed mode; subtracting two works around that. It -is also the case that there are no host isas that contain a call insn -smaller than 4 bytes, so we don't worry about special-casing this. */ -#if defined(CONFIG_TCG_INTERPRETER ) -# define GETPC_ADJ 0 -#else -# define GETPC_ADJ 2 -#endif - -#define GETPC () (GETRA() - GETPC_ADJ) +#include "exec/translate.h" #if !defined(CONFIG_USER_ONLY )include/exec/translate.h new file +306
-0@@ -0,0 +1,306 @@ +#ifndef EXEC_TRANSLATE_H +#define EXEC_TRANSLATE_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 page_size_init (void ); + +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 ) +void tcg_cpu_address_space_init (CPUState *cpu,AddressSpace *as); +/* 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 (AddressSpace *as,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(__aarch64__) \ + || 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; +}; + +#include "exec/spinlock.h" + +typedef struct TBContext TBContext ; + +struct TBContext { + +TranslationBlock *tbs; +TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE ]; +int nb_tbs; +/* any access to the tbs or the page table must use this lock */ +spinlock_t tb_lock; + +/* statistics */ +int tb_flush_count; +int tb_phys_invalidate_count; + +int tb_invalidated_flag; +}; + +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); + +#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(__aarch64__) +void aarch64_tb_set_jmp_target (uintptr_t jmp_addr,uintptr_t addr); +#define tb_set_jmp_target1 aarch64_tb_set_jmp_target +#elif defined(__arm__) +static inline void tb_set_jmp_target1 (uintptr_t jmp_addr,uintptr_t addr) +{ +#if !QEMU_GNUC_PREREQ (4 ,1 ) + registerunsigned long _beg __asm ("a1" ); + registerunsigned long _end __asm ("a2" ); + registerunsigned 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)); + } +} + +/* GETRA is the true target of the return instruction that we'll execute, +defined here for simplicity of defining the follow-up macros. */ +#if defined(CONFIG_TCG_INTERPRETER ) +extern uintptr_t tci_tb_ptr; +# define GETRA () tci_tb_ptr +#else +# define GETRA () \ + ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) +#endif + +/* The true return address will often point to a host insn that is part of +the next translated guest insn. Adjust the address backward to point to +the middle of the call insn. Subtracting one would do the job except for +several compressed mode architectures (arm, mips) which set the low bit +to indicate the compressed mode; subtracting two works around that. It +is also the case that there are no host isas that contain a call insn +smaller than 4 bytes, so we don't worry about special-casing this. */ +#if defined(CONFIG_TCG_INTERPRETER ) +# define GETPC_ADJ 0 +#else +# define GETPC_ADJ 2 +#endif + +#define GETPC () (GETRA() - GETPC_ADJ) + +#endif /* EXEC_TRANSLATE_H */
PATCH 9/10 exec: remove the unnecessary include of "exec-all.h"
In reply to Xuebing Wanginclude/exec/exec-all.h should ONLY be included in target-xxx/*
- 'git grep -nw exec-all.h' confirms this
--- cputlb.c | 1 - tcg/README | 2 +- tci.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
cputlb.c +0 -1
@@ -23,7 +23,6 @@#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ #include "config.h" -#include "exec/exec-all.h" #include "exec/memory.h" #include "exec/cputlb.h"
tcg/README +1 -1
@@ -530,7 +530,7 @@ register. inline TCG may still be faster for longer sequences. - The hard limit on the number of TCG instructions you can generate - per guest instruction is set by MAX_OP_PER_INSTR in exec-all.h -- + per guest instruction is set by MAX_OP_PER_INSTR in translate.h -- you cannot exceed this without risking a buffer overrun. - Use the 'discard' instruction if you know that TCG won't be able to
tci.c +1 -1
@@ -25,7 +25,7 @@#endif #include "qemu-common.h" -#include "exec/exec-all.h" /* MAX_OPC_PARAM_IARGS */ +#include "exec/translate.h" /* MAX_OPC_PARAM_IARGS */ #include "tcg-op.h" /* Marker for missing code. */
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 09/10] exec: remove the unnecessary include of "exec-all.h"
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Quoted 2 lines
include/exec/exec-all.hshould ONLY be included in target-xxx/*
- 'git grep -nwexec-all.h' confirms this
Ok.
Paolo
Quoted 46 lines
Signed-off-by Xuebing Wang <[email protected]>--- cputlb.c | 1 - tcg/README | 2 +- tci.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)cputlb.c +0
-1@@ -23,7 +23,6 @@#include "cpu.h" /* target-xxx/cpu.h, required for CPUArchState etc */ #include "config.h" -#include "exec/exec-all.h" #include "exec/memory.h" #include "exec/cputlb.h" tcg/README +1
-1@@ -530,7 +530,7 @@ register. inline TCG may still be faster for longer sequences. - The hard limit on the number of TCG instructions you can generate - per guest instruction is set by MAX_OP_PER_INSTR in exec-all.h -- + per guest instruction is set by MAX_OP_PER_INSTR in translate.h -- you cannot exceed this without risking a buffer overrun. - Use the 'discard' instruction if you know that TCG won't be able totci.c +1
-1@@ -25,7 +25,7 @@#endif #include "qemu-common.h" -#include "exec/exec-all.h" /* MAX_OPC_PARAM_IARGS */ +#include "exec/translate.h" /* MAX_OPC_PARAM_IARGS */ #include "tcg-op.h" /* Marker for missing code. */
Re: [Qemu-devel] [Discussion 09/10] exec: remove the unnecessary include of "exec-all.h"
In reply to Xuebing WangQuoted 1 line · Xuebing Wang
include/exec/exec-all.hshould ONLY be included in target-xxx/*
Why?
This header file defines a number of functions and types that are used outside target-xxx/. At the moment we implicitly rely on cpu.h pulling them in. Maybe it would be nice to split out the things that only the target frontends care about from APIs used by other parts of QEMU, but that's not what this patch is doing.
thanks
-- PMM
Re: [Qemu-devel] [Discussion 09/10] exec: remove the unnecessary include of "exec-all.h"
Quoted 8 lines · Peter Maydell
Quoted 1 line · Xuebing Wang
include/exec/exec-all.hshould ONLY be included in target-xxx/*Why?
This header file defines a number of functions and types that are used outside target-xxx/. At the moment we implicitly rely on
cpu.hpulling them in.
My question still stands, but this bit is wrong:
Quoted 4 lines
Maybe it would be nice to split
out the things that only the target frontends care about from APIs used by other parts of QEMU, but that's not what this patch is doing.
...because that is what patch 8 does. Sorry, read those out of order.
thanks
-- PMM
PATCH 10/10 translate: remove file translate-all.h
In reply to Xuebing WangThis patch does below:
- Move the declaration of 2 translate functions from translate-all.h into
include/exec/translate.h
- remove file translate-all.h
--- exec.c | 2 -- include/exec/translate.h | 4 ++++ translate-all.c | 2 +- translate-all.h | 27 --------------------------- 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 translate-all.h
exec.c +0 -2
@@ -44,8 +44,6 @@#endif #include "exec/cputlb.h" -#include "translate-all.h" -#include "exec/memory-internal.h" #include "exec/ram_addr.h" #include "qemu/cache-utils.h"
include/exec/translate.h +4 -0
@@ -303,4 +303,8 @@ extern uintptr_t tci_tb_ptr;#define GETPC () (GETRA() - GETPC_ADJ) +/* translate-all.c */ +void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len); +void tb_check_watchpoint (CPUArchState *env); +#endif /* EXEC_TRANSLATE_H */
translate-all.c +1 -1
@@ -61,7 +61,7 @@#endif #include "exec/cputlb.h" -#include "translate-all.h" +#include "exec/translate.h" #include "qemu/timer.h" //#define DEBUG_TB_INVALIDATE
translate-all.h deleted +0 -27
@@ -1,27 +0,0 @@ -/* -* Translated block 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 <http://www.gnu.org/licenses/>. -*/ -#ifndef TRANSLATE_ALL_H -#define TRANSLATE_ALL_H - -/* translate-all.c */ -void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len); -void cpu_unlink_tb (CPUState *cpu); -void tb_check_watchpoint (CPUArchState *env); - -#endif /* TRANSLATE_ALL_H */
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [Discussion 10/10] translate: remove file translate-all.h
Il 04/03/2014 03:47, Xuebing Wang ha scritto:
Review
Quoted 4 lines
This patch does below:
(quoted diff) +0
-2- Move the declaration of 2 translate functions from translate-all.h into include/exec/translate.h - remove file translate-all.h
No, this is backwards. :)
translate-all.h is a private interface between exec.c and translate-all.c.
What you really want is to remove the inclusion of exec/translate.h from exec/exec-all.h. And possibly also the inclusion of exec/exec-all.h from */cpu.h. Both of these are quite complex, however.
Paolo
Quoted 82 lines
Signed-off-by Xuebing Wang <[email protected]>--- exec.c | 2 -- include/exec/translate.h | 4 ++++ translate-all.c | 2 +- translate-all.h | 27 --------------------------- 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 translate-all.hexec.c +0
-2@@ -44,8 +44,6 @@#endif #include "exec/cputlb.h" -#include "translate-all.h" -#include "exec/memory-internal.h" #include "exec/ram_addr.h" #include "qemu/cache-utils.h" include/exec/translate.h +4
-0@@ -303,4 +303,8 @@ extern uintptr_t tci_tb_ptr;#define GETPC () (GETRA() - GETPC_ADJ) +/* translate-all.c */ +void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len); +void tb_check_watchpoint (CPUArchState *env); +#endif /* EXEC_TRANSLATE_H */ translate-all.c +1
-1@@ -61,7 +61,7 @@#endif #include "exec/cputlb.h" -#include "translate-all.h" +#include "exec/translate.h" #include "qemu/timer.h" //#define DEBUG_TB_INVALIDATE translate-all.h deleted +0
-27@@ -1,27 +0,0 @@ -/* -* Translated block 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 <http://www.gnu.org/licenses/>. -*/ -#ifndef TRANSLATE_ALL_H -#define TRANSLATE_ALL_H - -/* translate-all.c */ -void tb_invalidate_phys_page_fast (tb_page_addr_t start,int len); -void cpu_unlink_tb (CPUState *cpu); -void tb_check_watchpoint (CPUArchState *env); - -#endif /* TRANSLATE_ALL_H */
Hi Xuebing,
Am 04.03.2014 03:47, schrieb Xuebing Wang:
Quoted 1 line
Q2) Does it make sense to remove
NEED_CPU_Hfromqemu-common.h?
IMO not in this way. Work has been ongoing to obsolete NEED_CPU_H by introducing CPUState in addition to CPUArchState and moving fields into CPUState, so that less files need to include target-xxx/cpu.h. Your approach seems to be rather spreading it to more and different files.
Please explain in more detail: Why is code being moved from qom/cpu.h to vmstate.h for target-alpha?
Concerning gdbstub.h, have you investigated replacing remaining CPUArchState usages with CPUState, like I started in a previous series?
Concerning memory_mapping.h, have you checked the mailing list archives for reasons why I didn't use my vaddr there myself? Pointing me to my HACKING entry does not answer that. ;) (Either vaddr didn't exist yet at the time or there was some reason not to use it, I would hope!)
An important thing to watch out for when moving includes around is avoiding (more) circular dependencies. CC'ing Eduardo.
Also note that I still haven't fully rebased my qom-cpu-13 branch yet, which includes a number of field movements and is likely to clash with some of your refactorings in CPU/exec/translate files.
Your observation is correct that not all things are in the best shape. The question is in which way and in which order to address them. To better judge, what are the immediate gains of your proposals? For example, I don't spot any Makefile changes in your diffstat that benefit from a dropped cpu.h include somewhere in terms of build dependencies. Nor does your series include a proof of concept that something becomes possible that wasn't before. Understanding the exact advantages would help me in determining what priority to assign such changes. Thanks.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Hi Andreas, thank you very much for your reply.
Would you please help review/correct doc/api-hierarchy too?
Quoted 8 lines · Andreas Färber
Hi Xuebing,
Am 04.03.2014 03:47, schrieb Xuebing Wang:
Quoted 1 line
Q2) Does it make sense to remove
NEED_CPU_Hfromqemu-common.h?IMO not in this way. Work has been ongoing to obsolete
NEED_CPU_Hby introducing CPUState in addition to CPUArchState and moving fields into CPUState, so that less files need to includetarget-xxx/cpu.h. Your approach seems to be rather spreading it to more and different files.
IMHO, CPUArchState is NOT the only data structure that is target-specific, thus needs "cpu.h".
target_ulong is a define, thus can NOT be moved into CPUState. And there are TARGET_LONG_BITS, TARGET_PAGE_BITS, etc
More importantly, their derivatives (for lack of a better word) need "cpu.h" too. 'git grep -nw target_ulong include/' lists the derivatives of target_ulong. And there could be derivatives of the derivatives.
After this patchset, excluding folders (bsd/user, disas/, hw/, include/hw, target-xxx/), only a few files need "cpu.h"
Quoted 2 lines
Please explain in more detail: Why is code being moved from
qom/cpu.htovmstate.hfor target-alpha?
target alpha and openrisc use VMSTATE_CPU(), for alpha-linuxuser VMSTATE_CPU() uses vmstate_cpu_common and vmstate_dummy, and vmstate_dummy is declared in include/migration/vmstate.h. Currently, vmstate.h is NOT included in qom/cpu.h
Considering API hierarchy (and their dependencies), I'd consider vmstate to depend on qom/cpu, rather than conversely. Do you agree?
Quoted 2 lines
Concerning
gdbstub.h, have you investigated replacing remaining CPUArchState usages with CPUState, like I started in a previous series?
Yes, I did. I even tried to replace CPUArchState with CPUState for other subsystems, to make them architecture-independent. But, it involves changing too many places. :-)
Quoted 5 lines
Concerning
memory_mapping.h, have you checked the mailing list archives for reasons why I didn't use my vaddr there myself? Pointing me to my HACKING entry does not answer that. ;) (Either vaddr didn't exist yet at the time or there was some reason not to use it, I would hope!)
"target_ulong virt_addr" was there before the born of vaddr. vaddr was introduced in your commit 577f42c0e11a5bfb462ff3a217701cd5c4356fb4 dated Jul 6 2013. :-)
At this moment, do you think we better use vaddr to make memory_mapping target-independent?
Quoted 3 lines
An important thing to watch out for when moving includes around is avoiding (more) circular dependencies. CC'ing Eduardo.
Thanks for reminding. Yes, I keep avoiding circular dependencies in mind, that's the reason I wrote document docs/api-hierarchy.
Do you agree that in general, strictly following api hierarchy is a good approach to avoid circular dependencies?
Quoted 4 lines
Also note that I still haven't fully rebased my qom-cpu-13 branch yet, which includes a number of field movements and is likely to clash with some of your refactorings in CPU/exec/translate files.
Thanks for reminding.
Quoted 9 lines
Your observation is correct that not all things are in the best shape. The question is in which way and in which order to address them. To better judge, what are the immediate gains of your proposals? For example, I don't spot any
Makefilechanges in your diffstat that benefit from a droppedcpu.hinclude somewhere in terms of build dependencies. Nor does your series include a proof of concept that something becomes possible that wasn't before. Understanding the exact advantages would help me in determining what priority to assign such changes. Thanks.
My idea of the immediate gains is to circulate the api-hierarchy, and watch out dependencies while we adding new features. That's why I name this discussion "about API hierarchy"
Here is a quote from Anthony's "kvm forum 2011" keynote (slide 3):
We're growing so fast, and are so popular, that we simply don't have time to exercise and eat healthy.
http://www.linux-kvm.org/wiki/images/5/57/2011-forum-qemu-keynote-liguori.pdf
I hope api-hierarchy and removing NEED_CPU_H from qemu-common.h is the low-hanging fruit, in the sense of "exercise". :-)
Quoted 4 lines
Regards,
Andreas
Signature · 2 lines
Thanks, Xuebing Wang